Reorganizing business events

This commit is contained in:
Arnold Galovics
2022-05-31 21:51:57 +02:00
committed by Arnold Gálovics
parent e7b2d6dff5
commit 89a4db47cc
23 changed files with 414 additions and 427 deletions
@@ -28,9 +28,10 @@ import javax.annotation.PostConstruct;
import org.apache.fineract.infrastructure.campaigns.email.domain.EmailCampaign;
import org.apache.fineract.infrastructure.campaigns.email.domain.EmailCampaignRepository;
import org.apache.fineract.infrastructure.campaigns.sms.constants.SmsCampaignTriggerType;
import org.apache.fineract.portfolio.common.BusinessEventNotificationConstants;
import org.apache.fineract.portfolio.common.service.BusinessEventListener;
import org.apache.fineract.portfolio.common.service.BusinessEventNotifierService;
import org.apache.fineract.portfolio.businessevent.BusinessEventListener;
import org.apache.fineract.portfolio.businessevent.domain.BusinessEntity;
import org.apache.fineract.portfolio.businessevent.domain.BusinessEvent;
import org.apache.fineract.portfolio.businessevent.service.BusinessEventNotifierService;
import org.apache.fineract.portfolio.loanaccount.domain.Loan;
import org.apache.fineract.portfolio.loanaccount.domain.LoanTransaction;
import org.slf4j.Logger;
@@ -56,20 +57,19 @@ public class EmailCampaignDomainServiceImpl implements EmailCampaignDomainServic
@PostConstruct
public void addListeners() {
this.businessEventNotifierService.addBusinessEventPostListeners(BusinessEventNotificationConstants.BusinessEvents.LOAN_APPROVED,
this.businessEventNotifierService.addBusinessEventPostListeners(BusinessEvent.LOAN_APPROVED,
new EmailCampaignDomainServiceImpl.SendEmailOnLoanApproved());
this.businessEventNotifierService.addBusinessEventPostListeners(BusinessEventNotificationConstants.BusinessEvents.LOAN_REJECTED,
this.businessEventNotifierService.addBusinessEventPostListeners(BusinessEvent.LOAN_REJECTED,
new EmailCampaignDomainServiceImpl.SendEmailOnLoanRejected());
this.businessEventNotifierService.addBusinessEventPostListeners(
BusinessEventNotificationConstants.BusinessEvents.LOAN_MAKE_REPAYMENT,
this.businessEventNotifierService.addBusinessEventPostListeners(BusinessEvent.LOAN_MAKE_REPAYMENT,
new EmailCampaignDomainServiceImpl.SendEmailOnLoanRepayment());
}
private class SendEmailOnLoanRepayment extends EmailBusinessEventAdapter {
@Override
public void businessEventWasExecuted(Map<BusinessEventNotificationConstants.BusinessEntity, Object> businessEventEntity) {
Object entity = businessEventEntity.get(BusinessEventNotificationConstants.BusinessEntity.LOAN_TRANSACTION);
public void businessEventWasExecuted(Map<BusinessEntity, Object> businessEventEntity) {
Object entity = businessEventEntity.get(BusinessEntity.LOAN_TRANSACTION);
if (entity instanceof LoanTransaction) {
LoanTransaction loanTransaction = (LoanTransaction) entity;
try {
@@ -84,8 +84,8 @@ public class EmailCampaignDomainServiceImpl implements EmailCampaignDomainServic
private class SendEmailOnLoanRejected extends EmailBusinessEventAdapter {
@Override
public void businessEventWasExecuted(Map<BusinessEventNotificationConstants.BusinessEntity, Object> businessEventEntity) {
Object entity = businessEventEntity.get(BusinessEventNotificationConstants.BusinessEntity.LOAN);
public void businessEventWasExecuted(Map<BusinessEntity, Object> businessEventEntity) {
Object entity = businessEventEntity.get(BusinessEntity.LOAN);
if (entity instanceof Loan) {
Loan loan = (Loan) entity;
try {
@@ -100,8 +100,8 @@ public class EmailCampaignDomainServiceImpl implements EmailCampaignDomainServic
private class SendEmailOnLoanApproved extends EmailBusinessEventAdapter {
@Override
public void businessEventWasExecuted(Map<BusinessEventNotificationConstants.BusinessEntity, Object> businessEventEntity) {
Object entity = businessEventEntity.get(BusinessEventNotificationConstants.BusinessEntity.LOAN);
public void businessEventWasExecuted(Map<BusinessEntity, Object> businessEventEntity) {
Object entity = businessEventEntity.get(BusinessEntity.LOAN);
if (entity instanceof Loan) {
Loan loan = (Loan) entity;
try {
@@ -138,7 +138,7 @@ public class EmailCampaignDomainServiceImpl implements EmailCampaignDomainServic
private abstract static class EmailBusinessEventAdapter implements BusinessEventListener {
@Override
public void businessEventToBeExecuted(Map<BusinessEventNotificationConstants.BusinessEntity, Object> businessEventEntity) {
public void businessEventToBeExecuted(Map<BusinessEntity, Object> businessEventEntity) {
// Nothing to do
}
}
@@ -42,12 +42,11 @@ import org.apache.fineract.infrastructure.sms.domain.SmsMessageRepository;
import org.apache.fineract.infrastructure.sms.scheduler.SmsMessageScheduledJobService;
import org.apache.fineract.organisation.office.domain.Office;
import org.apache.fineract.organisation.office.domain.OfficeRepository;
import org.apache.fineract.portfolio.businessevent.BusinessEventListener;
import org.apache.fineract.portfolio.businessevent.domain.BusinessEntity;
import org.apache.fineract.portfolio.businessevent.domain.BusinessEvent;
import org.apache.fineract.portfolio.businessevent.service.BusinessEventNotifierService;
import org.apache.fineract.portfolio.client.domain.Client;
import org.apache.fineract.portfolio.common.BusinessEventNotificationConstants;
import org.apache.fineract.portfolio.common.BusinessEventNotificationConstants.BusinessEntity;
import org.apache.fineract.portfolio.common.BusinessEventNotificationConstants.BusinessEvents;
import org.apache.fineract.portfolio.common.service.BusinessEventListener;
import org.apache.fineract.portfolio.common.service.BusinessEventNotifierService;
import org.apache.fineract.portfolio.group.domain.Group;
import org.apache.fineract.portfolio.group.domain.GroupRepository;
import org.apache.fineract.portfolio.loanaccount.domain.Loan;
@@ -94,18 +93,17 @@ public class SmsCampaignDomainServiceImpl implements SmsCampaignDomainService {
@PostConstruct
public void addListeners() {
this.businessEventNotifierService.addBusinessEventPostListeners(BusinessEvents.LOAN_APPROVED, new SendSmsOnLoanApproved());
this.businessEventNotifierService.addBusinessEventPostListeners(BusinessEvents.LOAN_REJECTED, new SendSmsOnLoanRejected());
this.businessEventNotifierService.addBusinessEventPostListeners(BusinessEvents.LOAN_MAKE_REPAYMENT, new SendSmsOnLoanRepayment());
this.businessEventNotifierService.addBusinessEventPostListeners(BusinessEvents.CLIENTS_ACTIVATE, new ClientActivatedListener());
this.businessEventNotifierService.addBusinessEventPostListeners(BusinessEvents.CLIENTS_REJECT, new ClientRejectedListener());
this.businessEventNotifierService.addBusinessEventPostListeners(BusinessEvents.SAVINGS_ACTIVATE,
this.businessEventNotifierService.addBusinessEventPostListeners(BusinessEvent.LOAN_APPROVED, new SendSmsOnLoanApproved());
this.businessEventNotifierService.addBusinessEventPostListeners(BusinessEvent.LOAN_REJECTED, new SendSmsOnLoanRejected());
this.businessEventNotifierService.addBusinessEventPostListeners(BusinessEvent.LOAN_MAKE_REPAYMENT, new SendSmsOnLoanRepayment());
this.businessEventNotifierService.addBusinessEventPostListeners(BusinessEvent.CLIENTS_ACTIVATE, new ClientActivatedListener());
this.businessEventNotifierService.addBusinessEventPostListeners(BusinessEvent.CLIENTS_REJECT, new ClientRejectedListener());
this.businessEventNotifierService.addBusinessEventPostListeners(BusinessEvent.SAVINGS_ACTIVATE,
new SavingsAccountActivatedListener());
this.businessEventNotifierService.addBusinessEventPostListeners(BusinessEvents.SAVINGS_REJECT,
new SavingsAccountRejectedListener());
this.businessEventNotifierService.addBusinessEventPostListeners(BusinessEvents.SAVINGS_DEPOSIT,
this.businessEventNotifierService.addBusinessEventPostListeners(BusinessEvent.SAVINGS_REJECT, new SavingsAccountRejectedListener());
this.businessEventNotifierService.addBusinessEventPostListeners(BusinessEvent.SAVINGS_DEPOSIT,
new SavingsAccountTransactionListener(true));
this.businessEventNotifierService.addBusinessEventPostListeners(BusinessEvents.SAVINGS_WITHDRAWAL,
this.businessEventNotifierService.addBusinessEventPostListeners(BusinessEvent.SAVINGS_WITHDRAWAL,
new SavingsAccountTransactionListener(false));
}
@@ -395,8 +393,8 @@ public class SmsCampaignDomainServiceImpl implements SmsCampaignDomainService {
private class SendSmsOnLoanApproved extends SmsBusinessEventAdapter {
@Override
public void businessEventWasExecuted(Map<BusinessEventNotificationConstants.BusinessEntity, Object> businessEventEntity) {
Object entity = businessEventEntity.get(BusinessEventNotificationConstants.BusinessEntity.LOAN);
public void businessEventWasExecuted(Map<BusinessEntity, Object> businessEventEntity) {
Object entity = businessEventEntity.get(BusinessEntity.LOAN);
if (entity instanceof Loan) {
Loan loan = (Loan) entity;
notifyAcceptedLoanOwner(loan);
@@ -407,8 +405,8 @@ public class SmsCampaignDomainServiceImpl implements SmsCampaignDomainService {
private class SendSmsOnLoanRejected extends SmsBusinessEventAdapter {
@Override
public void businessEventWasExecuted(Map<BusinessEventNotificationConstants.BusinessEntity, Object> businessEventEntity) {
Object entity = businessEventEntity.get(BusinessEventNotificationConstants.BusinessEntity.LOAN);
public void businessEventWasExecuted(Map<BusinessEntity, Object> businessEventEntity) {
Object entity = businessEventEntity.get(BusinessEntity.LOAN);
if (entity instanceof Loan) {
Loan loan = (Loan) entity;
notifyRejectedLoanOwner(loan);
@@ -419,8 +417,8 @@ public class SmsCampaignDomainServiceImpl implements SmsCampaignDomainService {
private class SendSmsOnLoanRepayment extends SmsBusinessEventAdapter {
@Override
public void businessEventWasExecuted(Map<BusinessEventNotificationConstants.BusinessEntity, Object> businessEventEntity) {
Object entity = businessEventEntity.get(BusinessEventNotificationConstants.BusinessEntity.LOAN_TRANSACTION);
public void businessEventWasExecuted(Map<BusinessEntity, Object> businessEventEntity) {
Object entity = businessEventEntity.get(BusinessEntity.LOAN_TRANSACTION);
if (entity instanceof LoanTransaction) {
LoanTransaction loanTransaction = (LoanTransaction) entity;
sendSmsForLoanRepayment(loanTransaction);
@@ -432,7 +430,7 @@ public class SmsCampaignDomainServiceImpl implements SmsCampaignDomainService {
@Override
public void businessEventWasExecuted(Map<BusinessEntity, Object> businessEventEntity) {
Object entity = businessEventEntity.get(BusinessEventNotificationConstants.BusinessEntity.CLIENT);
Object entity = businessEventEntity.get(BusinessEntity.CLIENT);
if (entity instanceof Client) {
notifyClientActivated((Client) entity);
}
@@ -443,7 +441,7 @@ public class SmsCampaignDomainServiceImpl implements SmsCampaignDomainService {
@Override
public void businessEventWasExecuted(Map<BusinessEntity, Object> businessEventEntity) {
Object entity = businessEventEntity.get(BusinessEventNotificationConstants.BusinessEntity.CLIENT);
Object entity = businessEventEntity.get(BusinessEntity.CLIENT);
if (entity instanceof Client) {
notifyClientRejected((Client) entity);
}
@@ -455,7 +453,7 @@ public class SmsCampaignDomainServiceImpl implements SmsCampaignDomainService {
@Override
public void businessEventWasExecuted(Map<BusinessEntity, Object> businessEventEntity) {
Object entity = businessEventEntity.get(BusinessEventNotificationConstants.BusinessEntity.SAVING);
Object entity = businessEventEntity.get(BusinessEntity.SAVING);
if (entity instanceof SavingsAccount) {
notifySavingsAccountActivated((SavingsAccount) entity);
}
@@ -467,7 +465,7 @@ public class SmsCampaignDomainServiceImpl implements SmsCampaignDomainService {
@Override
public void businessEventWasExecuted(Map<BusinessEntity, Object> businessEventEntity) {
Object entity = businessEventEntity.get(BusinessEventNotificationConstants.BusinessEntity.SAVING);
Object entity = businessEventEntity.get(BusinessEntity.SAVING);
if (entity instanceof SavingsAccount) {
notifySavingsAccountRejected((SavingsAccount) entity);
}
@@ -484,7 +482,7 @@ public class SmsCampaignDomainServiceImpl implements SmsCampaignDomainService {
@Override
public void businessEventWasExecuted(Map<BusinessEntity, Object> businessEventEntity) {
Object entity = businessEventEntity.get(BusinessEventNotificationConstants.BusinessEntity.SAVINGS_TRANSACTION);
Object entity = businessEventEntity.get(BusinessEntity.SAVINGS_TRANSACTION);
if (entity instanceof SavingsAccountTransaction) {
sendSmsForSavingsTransaction((SavingsAccountTransaction) entity, this.isDeposit);
}
@@ -31,12 +31,11 @@ import org.apache.fineract.infrastructure.core.service.ThreadLocalContextUtil;
import org.apache.fineract.infrastructure.security.service.PlatformSecurityContext;
import org.apache.fineract.notification.data.NotificationData;
import org.apache.fineract.notification.eventandlistener.NotificationEventPublisher;
import org.apache.fineract.portfolio.businessevent.BusinessEventListener;
import org.apache.fineract.portfolio.businessevent.domain.BusinessEntity;
import org.apache.fineract.portfolio.businessevent.domain.BusinessEvent;
import org.apache.fineract.portfolio.businessevent.service.BusinessEventNotifierService;
import org.apache.fineract.portfolio.client.domain.Client;
import org.apache.fineract.portfolio.common.BusinessEventNotificationConstants;
import org.apache.fineract.portfolio.common.BusinessEventNotificationConstants.BusinessEntity;
import org.apache.fineract.portfolio.common.BusinessEventNotificationConstants.BusinessEvents;
import org.apache.fineract.portfolio.common.service.BusinessEventListener;
import org.apache.fineract.portfolio.common.service.BusinessEventNotifierService;
import org.apache.fineract.portfolio.loanaccount.domain.Loan;
import org.apache.fineract.portfolio.loanproduct.domain.LoanProduct;
import org.apache.fineract.portfolio.savings.DepositAccountType;
@@ -61,36 +60,35 @@ public class NotificationDomainServiceImpl implements NotificationDomainService
@PostConstruct
public void addListeners() {
businessEventNotifierService.addBusinessEventPostListeners(BusinessEvents.CLIENTS_CREATE, new ClientCreatedListener());
businessEventNotifierService.addBusinessEventPostListeners(BusinessEvents.SAVINGS_APPROVE, new SavingsAccountApprovedListener());
businessEventNotifierService.addBusinessEventPostListeners(BusinessEvents.CENTERS_CREATE, new CenterCreatedListener());
businessEventNotifierService.addBusinessEventPostListeners(BusinessEvents.GROUPS_CREATE, new GroupCreatedListener());
businessEventNotifierService.addBusinessEventPostListeners(BusinessEvents.SAVINGS_DEPOSIT, new SavingsAccountDepositListener());
businessEventNotifierService.addBusinessEventPostListeners(BusinessEvents.SHARE_PRODUCT_DIVIDENDS_CREATE,
businessEventNotifierService.addBusinessEventPostListeners(BusinessEvent.CLIENTS_CREATE, new ClientCreatedListener());
businessEventNotifierService.addBusinessEventPostListeners(BusinessEvent.SAVINGS_APPROVE, new SavingsAccountApprovedListener());
businessEventNotifierService.addBusinessEventPostListeners(BusinessEvent.CENTERS_CREATE, new CenterCreatedListener());
businessEventNotifierService.addBusinessEventPostListeners(BusinessEvent.GROUPS_CREATE, new GroupCreatedListener());
businessEventNotifierService.addBusinessEventPostListeners(BusinessEvent.SAVINGS_DEPOSIT, new SavingsAccountDepositListener());
businessEventNotifierService.addBusinessEventPostListeners(BusinessEvent.SHARE_PRODUCT_DIVIDENDS_CREATE,
new ShareProductDividendCreatedListener());
businessEventNotifierService.addBusinessEventPostListeners(BusinessEvents.FIXED_DEPOSIT_ACCOUNT_CREATE,
businessEventNotifierService.addBusinessEventPostListeners(BusinessEvent.FIXED_DEPOSIT_ACCOUNT_CREATE,
new FixedDepositAccountCreatedListener());
businessEventNotifierService.addBusinessEventPostListeners(BusinessEvents.RECURRING_DEPOSIT_ACCOUNT_CREATE,
businessEventNotifierService.addBusinessEventPostListeners(BusinessEvent.RECURRING_DEPOSIT_ACCOUNT_CREATE,
new RecurringDepositAccountCreatedListener());
businessEventNotifierService.addBusinessEventPostListeners(BusinessEvents.SAVINGS_POST_INTEREST, new SavingsPostInterestListener());
businessEventNotifierService.addBusinessEventPostListeners(BusinessEvents.LOAN_CREATE, new LoanCreatedListener());
businessEventNotifierService.addBusinessEventPostListeners(BusinessEvents.LOAN_APPROVED, new LoanApprovedListener());
businessEventNotifierService.addBusinessEventPostListeners(BusinessEvents.LOAN_CLOSE, new LoanClosedListener());
businessEventNotifierService.addBusinessEventPostListeners(BusinessEvents.LOAN_CLOSE_AS_RESCHEDULE,
businessEventNotifierService.addBusinessEventPostListeners(BusinessEvent.SAVINGS_POST_INTEREST, new SavingsPostInterestListener());
businessEventNotifierService.addBusinessEventPostListeners(BusinessEvent.LOAN_CREATE, new LoanCreatedListener());
businessEventNotifierService.addBusinessEventPostListeners(BusinessEvent.LOAN_APPROVED, new LoanApprovedListener());
businessEventNotifierService.addBusinessEventPostListeners(BusinessEvent.LOAN_CLOSE, new LoanClosedListener());
businessEventNotifierService.addBusinessEventPostListeners(BusinessEvent.LOAN_CLOSE_AS_RESCHEDULE,
new LoanCloseAsRescheduledListener());
businessEventNotifierService.addBusinessEventPostListeners(BusinessEvents.LOAN_MAKE_REPAYMENT, new LoanMakeRepaymentListener());
businessEventNotifierService.addBusinessEventPostListeners(BusinessEvents.LOAN_PRODUCT_CREATE, new LoanProductCreatedListener());
businessEventNotifierService.addBusinessEventPostListeners(BusinessEvents.SAVINGS_CREATE, new SavingsAccountCreatedListener());
businessEventNotifierService.addBusinessEventPostListeners(BusinessEvents.SAVINGS_CLOSE, new SavingsAccountClosedListener());
businessEventNotifierService.addBusinessEventPostListeners(BusinessEvents.SHARE_ACCOUNT_CREATE, new ShareAccountCreatedListener());
businessEventNotifierService.addBusinessEventPostListeners(BusinessEvents.SHARE_ACCOUNT_APPROVE,
new ShareAccountApprovedListener());
businessEventNotifierService.addBusinessEventPostListeners(BusinessEvent.LOAN_MAKE_REPAYMENT, new LoanMakeRepaymentListener());
businessEventNotifierService.addBusinessEventPostListeners(BusinessEvent.LOAN_PRODUCT_CREATE, new LoanProductCreatedListener());
businessEventNotifierService.addBusinessEventPostListeners(BusinessEvent.SAVINGS_CREATE, new SavingsAccountCreatedListener());
businessEventNotifierService.addBusinessEventPostListeners(BusinessEvent.SAVINGS_CLOSE, new SavingsAccountClosedListener());
businessEventNotifierService.addBusinessEventPostListeners(BusinessEvent.SHARE_ACCOUNT_CREATE, new ShareAccountCreatedListener());
businessEventNotifierService.addBusinessEventPostListeners(BusinessEvent.SHARE_ACCOUNT_APPROVE, new ShareAccountApprovedListener());
}
private abstract static class NotificationBusinessEventAdapter implements BusinessEventListener {
@Override
public void businessEventToBeExecuted(Map<BusinessEventNotificationConstants.BusinessEntity, Object> businessEventEntity) {}
public void businessEventToBeExecuted(Map<BusinessEntity, Object> businessEventEntity) {}
}
private class ClientCreatedListener extends NotificationBusinessEventAdapter {
@@ -98,7 +96,7 @@ public class NotificationDomainServiceImpl implements NotificationDomainService
@Override
public void businessEventWasExecuted(Map<BusinessEntity, Object> businessEventEntity) {
Client client;
Object entity = businessEventEntity.get(BusinessEventNotificationConstants.BusinessEntity.CLIENT);
Object entity = businessEventEntity.get(BusinessEntity.CLIENT);
if (entity != null) {
client = (Client) entity;
buildNotification("ACTIVATE_CLIENT", "client", client.getId(), "New client created", "created",
@@ -110,7 +108,7 @@ public class NotificationDomainServiceImpl implements NotificationDomainService
private class CenterCreatedListener extends NotificationBusinessEventAdapter {
@Override
public void businessEventWasExecuted(Map<BusinessEventNotificationConstants.BusinessEntity, Object> businessEventEntity) {
public void businessEventWasExecuted(Map<BusinessEntity, Object> businessEventEntity) {
CommandProcessingResult commandProcessingResult;
Object entity = businessEventEntity.get(BusinessEntity.GROUP);
if (entity != null) {
@@ -124,7 +122,7 @@ public class NotificationDomainServiceImpl implements NotificationDomainService
private class GroupCreatedListener extends NotificationBusinessEventAdapter {
@Override
public void businessEventWasExecuted(Map<BusinessEventNotificationConstants.BusinessEntity, Object> businessEventEntity) {
public void businessEventWasExecuted(Map<BusinessEntity, Object> businessEventEntity) {
CommandProcessingResult commandProcessingResult;
Object entity = businessEventEntity.get(BusinessEntity.GROUP);
if (entity != null) {
@@ -16,10 +16,10 @@
* specific language governing permissions and limitations
* under the License.
*/
package org.apache.fineract.portfolio.common.service;
package org.apache.fineract.portfolio.businessevent;
import java.util.Map;
import org.apache.fineract.portfolio.common.BusinessEventNotificationConstants.BusinessEntity;
import org.apache.fineract.portfolio.businessevent.domain.BusinessEntity;
/**
* The interface to be implemented by classes that want to be informed when a Business Event executes. example: on
@@ -0,0 +1,44 @@
/**
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package org.apache.fineract.portfolio.businessevent.domain;
public enum BusinessEntity {
LOAN("loan"), //
LOAN_TRANSACTION("loan_transaction"), //
LOAN_CHARGE("loan_charge"), //
LOAN_ADJUSTED_TRANSACTION("loan_adjusted_transaction"), SAVING("saving"), //
CLIENT("client"), //
SAVINGS_TRANSACTION("Savings Transaction"), //
GROUP("group"), //
SHARE_ACCOUNT("share_account"), //
SHARE_PRODUCT("share_product"), //
DEPOSIT_ACCOUNT("deposit_account"), //
LOAN_PRODUCT("loan_product");
private final String value;
BusinessEntity(final String value) {
this.value = value;
}
public String getValue() {
return value;
}
}
@@ -0,0 +1,103 @@
/**
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package org.apache.fineract.portfolio.businessevent.domain;
import java.util.HashSet;
import java.util.Set;
public enum BusinessEvent {
LOAN_APPROVED("loan_approved"), //
LOAN_REJECTED("loan_reject"), //
LOAN_UNDO_APPROVAL("loan_undo_approval"), //
LOAN_UNDO_DISBURSAL("loan_undo_disbursal"), //
LOAN_UNDO_LASTDISBURSAL("loan_undo_lastdisbursal"), //
LOAN_UNDO_TRANSACTION("loan_undo_transaction"), //
LOAN_ADJUST_TRANSACTION("loan_adjust_transaction"), //
LOAN_MAKE_REPAYMENT("loan_repayment_transaction"), //
LOAN_MERCHANT_ISSUED_REFUND("loan_merchant_issued_refund"), //
LOAN_PAYOUT_REFUND("loan_payout_refund"), //
LOAN_GOODWILL_CREDIT("loan_goodwill_credit"), //
LOAN_RECOVERY_PAYMENT("loan_recovery_payment"), //
LOAN_WRITTEN_OFF("loan_writtenoff"), //
LOAN_UNDO_WRITTEN_OFF("loan_undo_writtenoff"), //
LOAN_DISBURSAL("loan_disbursal"), //
LOAN_WAIVE_INTEREST("loan_waive_interest"), //
LOAN_CLOSE("loan_close"), //
LOAN_CLOSE_AS_RESCHEDULE("loan_close_as_reschedule"), //
LOAN_ADD_CHARGE("loan_add_charge"), //
LOAN_UPDATE_CHARGE("loan_update_charge"), //
LOAN_WAIVE_CHARGE_UNDO("loan_waive_charge_undo"), //
LOAN_WAIVE_CHARGE("loan_waive_charge"), //
LOAN_DELETE_CHARGE("loan_delete_charge"), //
LOAN_CHARGE_PAYMENT("loan_charge_payment"), //
LOAN_INITIATE_TRANSFER("loan_initiate_transfer"), //
LOAN_ACCEPT_TRANSFER("loan_accept_transfer"), //
LOAN_WITHDRAW_TRANSFER("loan_withdraw_transfer"), //
LOAN_REJECT_TRANSFER("loan_reject_transfer"), //
LOAN_REASSIGN_OFFICER("loan_reassign_officer"), //
LOAN_REMOVE_OFFICER("loan_remove_officer"), //
LOAN_APPLY_OVERDUE_CHARGE("loan_apply_overdue_charge"), //
LOAN_INTEREST_RECALCULATION("loan_interest_recalculation"), //
LOAN_REFUND("loan_refund"), //
LOAN_FORECLOSURE("loan_foreclosure"), //
LOAN_CREDIT_BALANCE_REFUND("loan_credit_balance_refund"), //
LOAN_CREATE("loan_create"), //
LOAN_PRODUCT_CREATE("loan_product_create"), //
SAVINGS_ACTIVATE("savings_activated"), //
SAVINGS_REJECT("savings_reject"), //
SAVINGS_POST_INTEREST("savings_post_interest"), //
SAVINGS_DEPOSIT("savings_deposit"), //
SAVINGS_CLOSE("savings_close"), //
SAVINGS_WITHDRAWAL("savings_withdrawal"), //
SAVINGS_APPROVE("savings_approve"), //
SAVINGS_CREATE("savings_create"), //
CLIENTS_ACTIVATE("clients_activate"), //
SHARE_ACCOUNT_CREATE("share_account_create"), //
CLIENTS_REJECT("clients_reject"), //
CLIENTS_CREATE("clients_create"), //
CENTERS_CREATE("centers_create"), //
GROUPS_CREATE("groups_create"), //
SHARE_PRODUCT_DIVIDENDS_CREATE("share_product_dividends_create"), //
FIXED_DEPOSIT_ACCOUNT_CREATE("fixed_deposit_account_create"), //
SHARE_ACCOUNT_APPROVE("share_account_approve"), //
RECURRING_DEPOSIT_ACCOUNT_CREATE("recurring_deposit_account_create");
private static final Set<String> VALUES = new HashSet<>();
static {
for (final BusinessEvent type : BusinessEvent.values()) {
VALUES.add(type.value);
}
}
private final String value;
BusinessEvent(final String value) {
this.value = value;
}
public static Set<String> getAllValues() {
return VALUES;
}
public String getValue() {
return value;
}
}
@@ -16,11 +16,12 @@
* specific language governing permissions and limitations
* under the License.
*/
package org.apache.fineract.portfolio.common.service;
package org.apache.fineract.portfolio.businessevent.service;
import java.util.Map;
import org.apache.fineract.portfolio.common.BusinessEventNotificationConstants.BusinessEntity;
import org.apache.fineract.portfolio.common.BusinessEventNotificationConstants.BusinessEvents;
import org.apache.fineract.portfolio.businessevent.BusinessEventListener;
import org.apache.fineract.portfolio.businessevent.domain.BusinessEntity;
import org.apache.fineract.portfolio.businessevent.domain.BusinessEvent;
/**
* Implemented class is responsible for notifying the business event to registered listeners.
@@ -31,21 +32,21 @@ public interface BusinessEventNotifierService {
/**
* Method should be called to notify listeners before Business event execution for any pre-processing of event
*/
void notifyBusinessEventToBeExecuted(BusinessEvents businessEvent, Map<BusinessEntity, Object> businessEventEntity);
void notifyBusinessEventToBeExecuted(BusinessEvent businessEvent, Map<BusinessEntity, Object> businessEventEntity);
/**
* Method should be called to notify listeners after Business event execution for any post-processing of event
*/
void notifyBusinessEventWasExecuted(BusinessEvents businessEvent, Map<BusinessEntity, Object> businessEventEntity);
void notifyBusinessEventWasExecuted(BusinessEvent businessEvent, Map<BusinessEntity, Object> businessEventEntity);
/**
* Method is to register a class as listener for pre-processing of any Business event
*/
void addBusinessEventPreListeners(BusinessEvents businessEvent, BusinessEventListener businessEventListener);
void addBusinessEventPreListeners(BusinessEvent businessEvent, BusinessEventListener businessEventListener);
/**
* Method is to register a class as listener for post-processing of any Business event
*/
void addBusinessEventPostListeners(BusinessEvents businessEvent, BusinessEventListener businessEventListener);
void addBusinessEventPostListeners(BusinessEvent businessEvent, BusinessEventListener businessEventListener);
}
@@ -16,31 +16,32 @@
* specific language governing permissions and limitations
* under the License.
*/
package org.apache.fineract.portfolio.common.service;
package org.apache.fineract.portfolio.businessevent.service;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.apache.fineract.portfolio.common.BusinessEventNotificationConstants.BusinessEntity;
import org.apache.fineract.portfolio.common.BusinessEventNotificationConstants.BusinessEvents;
import org.apache.fineract.portfolio.businessevent.BusinessEventListener;
import org.apache.fineract.portfolio.businessevent.domain.BusinessEntity;
import org.apache.fineract.portfolio.businessevent.domain.BusinessEvent;
import org.springframework.stereotype.Service;
@Service
public class BusinessEventNotifierServiceImpl implements BusinessEventNotifierService {
private final Map<BusinessEvents, List<BusinessEventListener>> preListeners = new HashMap<>(5);
private final Map<BusinessEvents, List<BusinessEventListener>> postListeners = new HashMap<>(5);
private final Map<BusinessEvent, List<BusinessEventListener>> preListeners = new HashMap<>(5);
private final Map<BusinessEvent, List<BusinessEventListener>> postListeners = new HashMap<>(5);
/*
* (non-Javadoc)
*
* @see org.apache.fineract.portfolio.common.service.BusinessEventNotifierService #notifyBusinessEventToBeExecuted
* (org.apache.fineract.portfolio.common.BusinessEventNotificationConstants .BusinessEvents,
* org.springframework.data.jpa.domain.AbstractPersistable)
* @see org.apache.fineract.portfolio.businessevent.service.BusinessEventNotifierService
* #notifyBusinessEventToBeExecuted (org.apache.fineract.portfolio.common.BusinessEventNotificationConstants
* .BusinessEvents, org.springframework.data.jpa.domain.AbstractPersistable)
*/
@Override
public void notifyBusinessEventToBeExecuted(BusinessEvents businessEvent, Map<BusinessEntity, Object> businessEventEntity) {
public void notifyBusinessEventToBeExecuted(BusinessEvent businessEvent, Map<BusinessEntity, Object> businessEventEntity) {
List<BusinessEventListener> businessEventListeners = this.preListeners.get(businessEvent);
if (businessEventListeners != null) {
for (BusinessEventListener eventListener : businessEventListeners) {
@@ -52,12 +53,12 @@ public class BusinessEventNotifierServiceImpl implements BusinessEventNotifierSe
/*
* (non-Javadoc)
*
* @see org.apache.fineract.portfolio.common.service.BusinessEventNotifierService #notifyBusinessEventWasExecuted
* (org.apache.fineract.portfolio.common.BusinessEventNotificationConstants .BusinessEvents,
* org.springframework.data.jpa.domain.AbstractPersistable)
* @see org.apache.fineract.portfolio.businessevent.service.BusinessEventNotifierService
* #notifyBusinessEventWasExecuted (org.apache.fineract.portfolio.common.BusinessEventNotificationConstants
* .BusinessEvents, org.springframework.data.jpa.domain.AbstractPersistable)
*/
@Override
public void notifyBusinessEventWasExecuted(BusinessEvents businessEvent, Map<BusinessEntity, Object> businessEventEntity) {
public void notifyBusinessEventWasExecuted(BusinessEvent businessEvent, Map<BusinessEntity, Object> businessEventEntity) {
List<BusinessEventListener> businessEventListeners = this.postListeners.get(businessEvent);
if (businessEventListeners != null) {
for (BusinessEventListener eventListener : businessEventListeners) {
@@ -69,29 +70,29 @@ public class BusinessEventNotifierServiceImpl implements BusinessEventNotifierSe
/*
* (non-Javadoc)
*
* @see org.apache.fineract.portfolio.common.service.BusinessEventNotifierService #addBusinessEventPreListeners
* (org.apache.fineract.portfolio.common.BusinessEventNotificationConstants .BusinessEvents,
* org.apache.fineract.portfolio.common.service.BusinessEventListener)
* @see org.apache.fineract.portfolio.businessevent.service.BusinessEventNotifierService
* #addBusinessEventPreListeners (org.apache.fineract.portfolio.common.BusinessEventNotificationConstants
* .BusinessEvents, org.apache.fineract.portfolio.businessevent.BusinessEventListener)
*/
@Override
public void addBusinessEventPreListeners(BusinessEvents businessEvent, BusinessEventListener businessEventListener) {
public void addBusinessEventPreListeners(BusinessEvent businessEvent, BusinessEventListener businessEventListener) {
addBusinessEventListeners(businessEvent, businessEventListener, preListeners);
}
/*
* (non-Javadoc)
*
* @see org.apache.fineract.portfolio.common.service.BusinessEventNotifierService #addBusinessEventPostListeners
* (org.apache.fineract.portfolio.common.BusinessEventNotificationConstants .BusinessEvents,
* org.apache.fineract.portfolio.common.service.BusinessEventListener)
* @see org.apache.fineract.portfolio.businessevent.service.BusinessEventNotifierService
* #addBusinessEventPostListeners (org.apache.fineract.portfolio.common.BusinessEventNotificationConstants
* .BusinessEvents, org.apache.fineract.portfolio.businessevent.BusinessEventListener)
*/
@Override
public void addBusinessEventPostListeners(BusinessEvents businessEvent, BusinessEventListener businessEventListener) {
public void addBusinessEventPostListeners(BusinessEvent businessEvent, BusinessEventListener businessEventListener) {
addBusinessEventListeners(businessEvent, businessEventListener, postListeners);
}
private void addBusinessEventListeners(BusinessEvents businessEvent, BusinessEventListener businessEventListener,
final Map<BusinessEvents, List<BusinessEventListener>> businessEventListenerMap) {
private void addBusinessEventListeners(BusinessEvent businessEvent, BusinessEventListener businessEventListener,
final Map<BusinessEvent, List<BusinessEventListener>> businessEventListenerMap) {
List<BusinessEventListener> businessEventListeners = businessEventListenerMap.get(businessEvent);
if (businessEventListeners == null) {
businessEventListeners = new ArrayList<>();
@@ -55,6 +55,9 @@ import org.apache.fineract.organisation.office.domain.OfficeRepositoryWrapper;
import org.apache.fineract.organisation.staff.domain.Staff;
import org.apache.fineract.organisation.staff.domain.StaffRepositoryWrapper;
import org.apache.fineract.portfolio.address.service.AddressWritePlatformService;
import org.apache.fineract.portfolio.businessevent.domain.BusinessEntity;
import org.apache.fineract.portfolio.businessevent.domain.BusinessEvent;
import org.apache.fineract.portfolio.businessevent.service.BusinessEventNotifierService;
import org.apache.fineract.portfolio.client.api.ClientApiConstants;
import org.apache.fineract.portfolio.client.data.ClientDataValidator;
import org.apache.fineract.portfolio.client.domain.AccountNumberGenerator;
@@ -69,9 +72,6 @@ import org.apache.fineract.portfolio.client.exception.ClientHasNoStaffException;
import org.apache.fineract.portfolio.client.exception.ClientMustBePendingToBeDeletedException;
import org.apache.fineract.portfolio.client.exception.InvalidClientSavingProductException;
import org.apache.fineract.portfolio.client.exception.InvalidClientStateTransitionException;
import org.apache.fineract.portfolio.common.BusinessEventNotificationConstants.BusinessEntity;
import org.apache.fineract.portfolio.common.BusinessEventNotificationConstants.BusinessEvents;
import org.apache.fineract.portfolio.common.service.BusinessEventNotifierService;
import org.apache.fineract.portfolio.group.domain.Group;
import org.apache.fineract.portfolio.group.domain.GroupRepository;
import org.apache.fineract.portfolio.group.exception.GroupMemberCountNotInPermissibleRangeException;
@@ -305,7 +305,7 @@ public class ClientWritePlatformServiceJpaRepositoryImpl implements ClientWriteP
this.clientRepository.saveAndFlush(newClient);
if (newClient.isActive()) {
this.businessEventNotifierService.notifyBusinessEventWasExecuted(BusinessEvents.CLIENTS_ACTIVATE,
this.businessEventNotifierService.notifyBusinessEventWasExecuted(BusinessEvent.CLIENTS_ACTIVATE,
constructEntityMap(BusinessEntity.CLIENT, newClient));
}
if (newClient.isAccountNumberRequiresAutoGeneration()) {
@@ -340,7 +340,7 @@ public class ClientWritePlatformServiceJpaRepositoryImpl implements ClientWriteP
command.arrayOfParameterNamed(ClientApiConstants.datatables));
}
this.businessEventNotifierService.notifyBusinessEventWasExecuted(BusinessEvents.CLIENTS_CREATE,
this.businessEventNotifierService.notifyBusinessEventWasExecuted(BusinessEvent.CLIENTS_CREATE,
constructEntityMap(BusinessEntity.CLIENT, newClient));
this.entityDatatableChecksWritePlatformService.runTheCheck(newClient.getId(), EntityTables.CLIENT.getName(),
@@ -595,7 +595,7 @@ public class ClientWritePlatformServiceJpaRepositoryImpl implements ClientWriteP
client.activate(currentUser, fmt, activationDate);
CommandProcessingResult result = openSavingsAccount(client, fmt);
this.clientRepository.saveAndFlush(client);
this.businessEventNotifierService.notifyBusinessEventWasExecuted(BusinessEvents.CLIENTS_ACTIVATE,
this.businessEventNotifierService.notifyBusinessEventWasExecuted(BusinessEvent.CLIENTS_ACTIVATE,
constructEntityMap(BusinessEntity.CLIENT, client));
return new CommandProcessingResultBuilder() //
.withCommandId(command.commandId()) //
@@ -850,7 +850,7 @@ public class ClientWritePlatformServiceJpaRepositoryImpl implements ClientWriteP
}
client.reject(currentUser, rejectionReason, Date.from(rejectionDate.atStartOfDay(ZoneId.systemDefault()).toInstant()));
this.clientRepository.saveAndFlush(client);
this.businessEventNotifierService.notifyBusinessEventWasExecuted(BusinessEvents.CLIENTS_REJECT,
this.businessEventNotifierService.notifyBusinessEventWasExecuted(BusinessEvent.CLIENTS_REJECT,
constructEntityMap(BusinessEntity.CLIENT, client));
return new CommandProcessingResultBuilder() //
.withCommandId(command.commandId()) //
@@ -1,132 +0,0 @@
/**
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package org.apache.fineract.portfolio.common;
import java.util.HashSet;
import java.util.Set;
public class BusinessEventNotificationConstants {
public enum BusinessEvents {
LOAN_APPROVED("loan_approved"), //
LOAN_REJECTED("loan_reject"), //
LOAN_UNDO_APPROVAL("loan_undo_approval"), //
LOAN_UNDO_DISBURSAL("loan_undo_disbursal"), //
LOAN_UNDO_LASTDISBURSAL("loan_undo_lastdisbursal"), //
LOAN_UNDO_TRANSACTION("loan_undo_transaction"), //
LOAN_ADJUST_TRANSACTION("loan_adjust_transaction"), //
LOAN_MAKE_REPAYMENT("loan_repayment_transaction"), //
LOAN_MERCHANT_ISSUED_REFUND("loan_merchant_issued_refund"), //
LOAN_PAYOUT_REFUND("loan_payout_refund"), //
LOAN_GOODWILL_CREDIT("loan_goodwill_credit"), //
LOAN_RECOVERY_PAYMENT("loan_recovery_payment"), //
LOAN_WRITTEN_OFF("loan_writtenoff"), //
LOAN_UNDO_WRITTEN_OFF("loan_undo_writtenoff"), //
LOAN_DISBURSAL("loan_disbursal"), //
LOAN_WAIVE_INTEREST("loan_waive_interest"), //
LOAN_CLOSE("loan_close"), //
LOAN_CLOSE_AS_RESCHEDULE("loan_close_as_reschedule"), //
LOAN_ADD_CHARGE("loan_add_charge"), //
LOAN_UPDATE_CHARGE("loan_update_charge"), //
LOAN_WAIVE_CHARGE_UNDO("loan_waive_charge_undo"), //
LOAN_WAIVE_CHARGE("loan_waive_charge"), //
LOAN_DELETE_CHARGE("loan_delete_charge"), //
LOAN_CHARGE_PAYMENT("loan_charge_payment"), //
LOAN_INITIATE_TRANSFER("loan_initiate_transfer"), //
LOAN_ACCEPT_TRANSFER("loan_accept_transfer"), //
LOAN_WITHDRAW_TRANSFER("loan_withdraw_transfer"), //
LOAN_REJECT_TRANSFER("loan_reject_transfer"), //
LOAN_REASSIGN_OFFICER("loan_reassign_officer"), //
LOAN_REMOVE_OFFICER("loan_remove_officer"), //
LOAN_APPLY_OVERDUE_CHARGE("loan_apply_overdue_charge"), //
LOAN_INTEREST_RECALCULATION("loan_interest_recalculation"), //
LOAN_REFUND("loan_refund"), //
LOAN_FORECLOSURE("loan_foreclosure"), //
LOAN_CREDIT_BALANCE_REFUND("loan_credit_balance_refund"), //
LOAN_CREATE("loan_create"), //
LOAN_PRODUCT_CREATE("loan_product_create"), //
SAVINGS_ACTIVATE("savings_activated"), //
SAVINGS_REJECT("savings_reject"), //
SAVINGS_POST_INTEREST("savings_post_interest"), //
SAVINGS_DEPOSIT("savings_deposit"), //
SAVINGS_CLOSE("savings_close"), //
SAVINGS_WITHDRAWAL("savings_withdrawal"), //
SAVINGS_APPROVE("savings_approve"), //
SAVINGS_CREATE("savings_create"), //
CLIENTS_ACTIVATE("clients_activate"), //
SHARE_ACCOUNT_CREATE("share_account_create"), //
CLIENTS_REJECT("clients_reject"), //
CLIENTS_CREATE("clients_create"), //
CENTERS_CREATE("centers_create"), //
GROUPS_CREATE("groups_create"), //
SHARE_PRODUCT_DIVIDENDS_CREATE("share_product_dividends_create"), //
FIXED_DEPOSIT_ACCOUNT_CREATE("fixed_deposit_account_create"), //
SHARE_ACCOUNT_APPROVE("share_account_approve"), //
RECURRING_DEPOSIT_ACCOUNT_CREATE("recurring_deposit_account_create");
private final String value;
BusinessEvents(final String value) {
this.value = value;
}
private static final Set<String> values = new HashSet<>();
static {
for (final BusinessEvents type : BusinessEvents.values()) {
values.add(type.value);
}
}
public static Set<String> getAllValues() {
return values;
}
public String getValue() {
return this.value;
}
}
public enum BusinessEntity {
LOAN("loan"), //
LOAN_TRANSACTION("loan_transaction"), //
LOAN_CHARGE("loan_charge"), //
LOAN_ADJUSTED_TRANSACTION("loan_adjusted_transaction"), SAVING("saving"), //
CLIENT("client"), //
SAVINGS_TRANSACTION("Savings Transaction"), //
GROUP("group"), //
SHARE_ACCOUNT("share_account"), //
SHARE_PRODUCT("share_product"), //
DEPOSIT_ACCOUNT("deposit_account"), //
LOAN_PRODUCT("loan_product");
private final String value;
BusinessEntity(final String value) {
this.value = value;
}
public String getValue() {
return this.value;
}
}
}
@@ -54,6 +54,9 @@ import org.apache.fineract.organisation.office.domain.OfficeRepositoryWrapper;
import org.apache.fineract.organisation.office.exception.InvalidOfficeException;
import org.apache.fineract.organisation.staff.domain.Staff;
import org.apache.fineract.organisation.staff.domain.StaffRepositoryWrapper;
import org.apache.fineract.portfolio.businessevent.domain.BusinessEntity;
import org.apache.fineract.portfolio.businessevent.domain.BusinessEvent;
import org.apache.fineract.portfolio.businessevent.service.BusinessEventNotifierService;
import org.apache.fineract.portfolio.calendar.domain.Calendar;
import org.apache.fineract.portfolio.calendar.domain.CalendarEntityType;
import org.apache.fineract.portfolio.calendar.domain.CalendarInstance;
@@ -63,10 +66,6 @@ import org.apache.fineract.portfolio.client.domain.AccountNumberGenerator;
import org.apache.fineract.portfolio.client.domain.Client;
import org.apache.fineract.portfolio.client.domain.ClientRepositoryWrapper;
import org.apache.fineract.portfolio.client.service.LoanStatusMapper;
import org.apache.fineract.portfolio.common.BusinessEventNotificationConstants;
import org.apache.fineract.portfolio.common.BusinessEventNotificationConstants.BusinessEntity;
import org.apache.fineract.portfolio.common.BusinessEventNotificationConstants.BusinessEvents;
import org.apache.fineract.portfolio.common.service.BusinessEventNotifierService;
import org.apache.fineract.portfolio.group.api.GroupingTypesApiConstants;
import org.apache.fineract.portfolio.group.domain.Group;
import org.apache.fineract.portfolio.group.domain.GroupLevel;
@@ -291,7 +290,7 @@ public class GroupingTypesWritePlatformServiceJpaRepositoryImpl implements Group
CommandProcessingResult commandProcessingResult = createGroupingType(command, GroupTypes.CENTER, centerId);
this.businessEventNotifierService.notifyBusinessEventWasExecuted(BusinessEvents.CENTERS_CREATE,
this.businessEventNotifierService.notifyBusinessEventWasExecuted(BusinessEvent.CENTERS_CREATE,
constructEntityMap(BusinessEntity.GROUP, commandProcessingResult));
return commandProcessingResult;
@@ -309,7 +308,7 @@ public class GroupingTypesWritePlatformServiceJpaRepositoryImpl implements Group
CommandProcessingResult commandProcessingResult = createGroupingType(command, GroupTypes.GROUP, centerId);
this.businessEventNotifierService.notifyBusinessEventWasExecuted(BusinessEventNotificationConstants.BusinessEvents.GROUPS_CREATE,
this.businessEventNotifierService.notifyBusinessEventWasExecuted(BusinessEvent.GROUPS_CREATE,
constructEntityMap(BusinessEntity.GROUP, commandProcessingResult));
return commandProcessingResult;
@@ -999,8 +998,7 @@ public class GroupingTypesWritePlatformServiceJpaRepositoryImpl implements Group
}
}
private Map<BusinessEventNotificationConstants.BusinessEntity, Object> constructEntityMap(final BusinessEntity entityEvent,
Object entity) {
private Map<BusinessEntity, Object> constructEntityMap(final BusinessEntity entityEvent, Object entity) {
Map<BusinessEntity, Object> map = new HashMap<>(1);
map.put(entityEvent, entity);
return map;
@@ -58,12 +58,12 @@ import org.apache.fineract.portfolio.account.domain.AccountTransferTransaction;
import org.apache.fineract.portfolio.account.domain.StandingInstructionRepository;
import org.apache.fineract.portfolio.account.domain.StandingInstructionStatus;
import org.apache.fineract.portfolio.accountdetails.domain.AccountType;
import org.apache.fineract.portfolio.businessevent.domain.BusinessEntity;
import org.apache.fineract.portfolio.businessevent.domain.BusinessEvent;
import org.apache.fineract.portfolio.businessevent.service.BusinessEventNotifierService;
import org.apache.fineract.portfolio.client.domain.Client;
import org.apache.fineract.portfolio.client.exception.ClientNotActiveException;
import org.apache.fineract.portfolio.common.BusinessEventNotificationConstants.BusinessEntity;
import org.apache.fineract.portfolio.common.BusinessEventNotificationConstants.BusinessEvents;
import org.apache.fineract.portfolio.common.domain.PeriodFrequencyType;
import org.apache.fineract.portfolio.common.service.BusinessEventNotifierService;
import org.apache.fineract.portfolio.group.domain.Group;
import org.apache.fineract.portfolio.group.exception.GroupNotActiveException;
import org.apache.fineract.portfolio.loanaccount.data.HolidayDetailDTO;
@@ -179,7 +179,7 @@ public class LoanAccountDomainServiceJpa implements LoanAccountDomainService {
AppUser currentUser = getAppUserIfPresent();
checkClientOrGroupActive(loan);
BusinessEvents repaymentTypeEvent = getRepaymentTypeBusinessEvent(repaymentTransactionType, isRecoveryRepayment);
BusinessEvent repaymentTypeEvent = getRepaymentTypeBusinessEvent(repaymentTransactionType, isRecoveryRepayment);
this.businessEventNotifierService.notifyBusinessEventToBeExecuted(repaymentTypeEvent,
constructEntityMap(BusinessEntity.LOAN, loan));
@@ -287,18 +287,18 @@ public class LoanAccountDomainServiceJpa implements LoanAccountDomainService {
return newRepaymentTransaction;
}
private BusinessEvents getRepaymentTypeBusinessEvent(LoanTransactionType repaymentTransactionType, boolean isRecoveryRepayment) {
BusinessEvents repaymentTypeEvent = null;
private BusinessEvent getRepaymentTypeBusinessEvent(LoanTransactionType repaymentTransactionType, boolean isRecoveryRepayment) {
BusinessEvent repaymentTypeEvent = null;
if (repaymentTransactionType.isRepayment()) {
repaymentTypeEvent = BusinessEvents.LOAN_MAKE_REPAYMENT;
repaymentTypeEvent = BusinessEvent.LOAN_MAKE_REPAYMENT;
} else if (repaymentTransactionType.isMerchantIssuedRefund()) {
repaymentTypeEvent = BusinessEvents.LOAN_MERCHANT_ISSUED_REFUND;
repaymentTypeEvent = BusinessEvent.LOAN_MERCHANT_ISSUED_REFUND;
} else if (repaymentTransactionType.isPayoutRefund()) {
repaymentTypeEvent = BusinessEvents.LOAN_PAYOUT_REFUND;
repaymentTypeEvent = BusinessEvent.LOAN_PAYOUT_REFUND;
} else if (repaymentTransactionType.isGoodwillCredit()) {
repaymentTypeEvent = BusinessEvents.LOAN_GOODWILL_CREDIT;
repaymentTypeEvent = BusinessEvent.LOAN_GOODWILL_CREDIT;
} else if (isRecoveryRepayment) {
repaymentTypeEvent = BusinessEvents.LOAN_RECOVERY_PAYMENT;
repaymentTypeEvent = BusinessEvent.LOAN_RECOVERY_PAYMENT;
}
return repaymentTypeEvent;
}
@@ -364,7 +364,7 @@ public class LoanAccountDomainServiceJpa implements LoanAccountDomainService {
AppUser currentUser = getAppUserIfPresent();
boolean isAccountTransfer = true;
checkClientOrGroupActive(loan);
this.businessEventNotifierService.notifyBusinessEventToBeExecuted(BusinessEvents.LOAN_CHARGE_PAYMENT,
this.businessEventNotifierService.notifyBusinessEventToBeExecuted(BusinessEvent.LOAN_CHARGE_PAYMENT,
constructEntityMap(BusinessEntity.LOAN, loan));
final List<Long> existingTransactionIds = new ArrayList<>();
final List<Long> existingReversedTransactionIds = new ArrayList<>();
@@ -400,7 +400,7 @@ public class LoanAccountDomainServiceJpa implements LoanAccountDomainService {
postJournalEntries(loan, existingTransactionIds, existingReversedTransactionIds, isAccountTransfer);
recalculateAccruals(loan);
this.businessEventNotifierService.notifyBusinessEventWasExecuted(BusinessEvents.LOAN_CHARGE_PAYMENT,
this.businessEventNotifierService.notifyBusinessEventWasExecuted(BusinessEvent.LOAN_CHARGE_PAYMENT,
constructEntityMap(BusinessEntity.LOAN_TRANSACTION, newPaymentTransaction));
return newPaymentTransaction;
}
@@ -450,7 +450,7 @@ public class LoanAccountDomainServiceJpa implements LoanAccountDomainService {
boolean isAccountTransfer = true;
final Loan loan = this.loanAccountAssembler.assembleFrom(accountId);
checkClientOrGroupActive(loan);
this.businessEventNotifierService.notifyBusinessEventToBeExecuted(BusinessEvents.LOAN_REFUND,
this.businessEventNotifierService.notifyBusinessEventToBeExecuted(BusinessEvent.LOAN_REFUND,
constructEntityMap(BusinessEntity.LOAN, loan));
final List<Long> existingTransactionIds = new ArrayList<>();
final List<Long> existingReversedTransactionIds = new ArrayList<>();
@@ -476,7 +476,7 @@ public class LoanAccountDomainServiceJpa implements LoanAccountDomainService {
}
postJournalEntries(loan, existingTransactionIds, existingReversedTransactionIds, isAccountTransfer);
this.businessEventNotifierService.notifyBusinessEventWasExecuted(BusinessEvents.LOAN_REFUND,
this.businessEventNotifierService.notifyBusinessEventWasExecuted(BusinessEvent.LOAN_REFUND,
constructEntityMap(BusinessEntity.LOAN_TRANSACTION, newRefundTransaction));
builderResult.withEntityId(newRefundTransaction.getId()).withOfficeId(loan.getOfficeId()).withClientId(loan.getClientId())
.withGroupId(loan.getGroupId());
@@ -646,7 +646,7 @@ public class LoanAccountDomainServiceJpa implements LoanAccountDomainService {
public CommandProcessingResultBuilder creditBalanceRefund(Long loanId, LocalDate transactionDate, BigDecimal transactionAmount,
String noteText, String externalId) {
final Loan loan = this.loanAccountAssembler.assembleFrom(loanId);
this.businessEventNotifierService.notifyBusinessEventToBeExecuted(BusinessEvents.LOAN_CREDIT_BALANCE_REFUND,
this.businessEventNotifierService.notifyBusinessEventToBeExecuted(BusinessEvent.LOAN_CREDIT_BALANCE_REFUND,
constructEntityMap(BusinessEntity.LOAN, loan));
final List<Long> existingTransactionIds = new ArrayList<>();
final List<Long> existingReversedTransactionIds = new ArrayList<>();
@@ -668,7 +668,7 @@ public class LoanAccountDomainServiceJpa implements LoanAccountDomainService {
postJournalEntries(loan, existingTransactionIds, existingReversedTransactionIds, false);
recalculateAccruals(loan);
this.businessEventNotifierService.notifyBusinessEventWasExecuted(BusinessEvents.LOAN_CREDIT_BALANCE_REFUND,
this.businessEventNotifierService.notifyBusinessEventWasExecuted(BusinessEvent.LOAN_CREDIT_BALANCE_REFUND,
constructEntityMap(BusinessEntity.LOAN_TRANSACTION, newCreditBalanceRefundTransaction));
return new CommandProcessingResultBuilder().withEntityId(newCreditBalanceRefundTransaction.getId()) //
@@ -682,7 +682,7 @@ public class LoanAccountDomainServiceJpa implements LoanAccountDomainService {
BigDecimal transactionAmount, PaymentDetail paymentDetail, String noteText, String txnExternalId) {
final Loan loan = this.loanAccountAssembler.assembleFrom(accountId);
checkClientOrGroupActive(loan);
this.businessEventNotifierService.notifyBusinessEventToBeExecuted(BusinessEvents.LOAN_REFUND,
this.businessEventNotifierService.notifyBusinessEventToBeExecuted(BusinessEvent.LOAN_REFUND,
constructEntityMap(BusinessEntity.LOAN, loan));
final List<Long> existingTransactionIds = new ArrayList<>();
final List<Long> existingReversedTransactionIds = new ArrayList<>();
@@ -709,7 +709,7 @@ public class LoanAccountDomainServiceJpa implements LoanAccountDomainService {
postJournalEntries(loan, existingTransactionIds, existingReversedTransactionIds, false);
recalculateAccruals(loan);
this.businessEventNotifierService.notifyBusinessEventWasExecuted(BusinessEvents.LOAN_REFUND,
this.businessEventNotifierService.notifyBusinessEventWasExecuted(BusinessEvent.LOAN_REFUND,
constructEntityMap(BusinessEntity.LOAN_TRANSACTION, newRefundTransaction));
builderResult.withEntityId(newRefundTransaction.getId()).withOfficeId(loan.getOfficeId()).withClientId(loan.getClientId())
@@ -720,7 +720,7 @@ public class LoanAccountDomainServiceJpa implements LoanAccountDomainService {
@Override
public Map<String, Object> foreCloseLoan(final Loan loan, final LocalDate foreClosureDate, final String noteText) {
this.businessEventNotifierService.notifyBusinessEventToBeExecuted(BusinessEvents.LOAN_FORECLOSURE,
this.businessEventNotifierService.notifyBusinessEventToBeExecuted(BusinessEvent.LOAN_FORECLOSURE,
constructEntityMap(BusinessEntity.LOAN, loan));
MonetaryCurrency currency = loan.getCurrency();
LocalDateTime createdDate = DateUtils.getLocalDateTimeOfTenant();
@@ -820,7 +820,7 @@ public class LoanAccountDomainServiceJpa implements LoanAccountDomainService {
}
postJournalEntries(loan, existingTransactionIds, existingReversedTransactionIds, false);
this.businessEventNotifierService.notifyBusinessEventWasExecuted(BusinessEvents.LOAN_FORECLOSURE,
this.businessEventNotifierService.notifyBusinessEventWasExecuted(BusinessEvent.LOAN_FORECLOSURE,
constructEntityMap(BusinessEntity.LOAN_TRANSACTION, payment));
return changes;
@@ -28,6 +28,7 @@ import java.util.List;
import java.util.Locale;
import java.util.Map;
import javax.annotation.PostConstruct;
import lombok.RequiredArgsConstructor;
import org.apache.fineract.infrastructure.core.data.ApiParameterError;
import org.apache.fineract.infrastructure.core.data.DataValidatorBuilder;
import org.apache.fineract.infrastructure.core.exception.PlatformApiDataValidationException;
@@ -38,10 +39,10 @@ import org.apache.fineract.portfolio.account.data.AccountTransferDTO;
import org.apache.fineract.portfolio.account.domain.AccountTransferDetails;
import org.apache.fineract.portfolio.account.domain.AccountTransferType;
import org.apache.fineract.portfolio.account.service.AccountTransfersWritePlatformService;
import org.apache.fineract.portfolio.common.BusinessEventNotificationConstants.BusinessEntity;
import org.apache.fineract.portfolio.common.BusinessEventNotificationConstants.BusinessEvents;
import org.apache.fineract.portfolio.common.service.BusinessEventListener;
import org.apache.fineract.portfolio.common.service.BusinessEventNotifierService;
import org.apache.fineract.portfolio.businessevent.BusinessEventListener;
import org.apache.fineract.portfolio.businessevent.domain.BusinessEntity;
import org.apache.fineract.portfolio.businessevent.domain.BusinessEvent;
import org.apache.fineract.portfolio.businessevent.service.BusinessEventNotifierService;
import org.apache.fineract.portfolio.loanaccount.domain.Loan;
import org.apache.fineract.portfolio.loanaccount.domain.LoanTransaction;
import org.apache.fineract.portfolio.loanaccount.guarantor.GuarantorConstants;
@@ -60,10 +61,10 @@ import org.apache.fineract.portfolio.savings.domain.SavingsAccount;
import org.apache.fineract.portfolio.savings.domain.SavingsAccountAssembler;
import org.apache.fineract.portfolio.savings.domain.SavingsAccountTransaction;
import org.apache.fineract.portfolio.savings.exception.InsufficientAccountBalanceException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
@Service
@RequiredArgsConstructor
public class GuarantorDomainServiceImpl implements GuarantorDomainService {
private final GuarantorRepository guarantorRepository;
@@ -75,36 +76,19 @@ public class GuarantorDomainServiceImpl implements GuarantorDomainService {
private final Map<Long, Long> releaseLoanIds = new HashMap<>(2);
private final SavingsAccountAssembler savingsAccountAssembler;
@Autowired
public GuarantorDomainServiceImpl(final GuarantorRepository guarantorRepository,
final GuarantorFundingRepository guarantorFundingRepository,
final GuarantorFundingTransactionRepository guarantorFundingTransactionRepository,
final AccountTransfersWritePlatformService accountTransfersWritePlatformService,
final BusinessEventNotifierService businessEventNotifierService,
final DepositAccountOnHoldTransactionRepository depositAccountOnHoldTransactionRepository,
final SavingsAccountAssembler savingsAccountAssembler) {
this.guarantorRepository = guarantorRepository;
this.guarantorFundingRepository = guarantorFundingRepository;
this.guarantorFundingTransactionRepository = guarantorFundingTransactionRepository;
this.accountTransfersWritePlatformService = accountTransfersWritePlatformService;
this.businessEventNotifierService = businessEventNotifierService;
this.depositAccountOnHoldTransactionRepository = depositAccountOnHoldTransactionRepository;
this.savingsAccountAssembler = savingsAccountAssembler;
}
@PostConstruct
public void addListeners() {
this.businessEventNotifierService.addBusinessEventPostListeners(BusinessEvents.LOAN_APPROVED, new ValidateOnBusinessEvent());
this.businessEventNotifierService.addBusinessEventPostListeners(BusinessEvents.LOAN_APPROVED, new HoldFundsOnBusinessEvent());
this.businessEventNotifierService.addBusinessEventPostListeners(BusinessEvents.LOAN_UNDO_APPROVAL, new UndoAllFundTransactions());
this.businessEventNotifierService.addBusinessEventPostListeners(BusinessEvents.LOAN_UNDO_DISBURSAL,
this.businessEventNotifierService.addBusinessEventPostListeners(BusinessEvent.LOAN_APPROVED, new ValidateOnBusinessEvent());
this.businessEventNotifierService.addBusinessEventPostListeners(BusinessEvent.LOAN_APPROVED, new HoldFundsOnBusinessEvent());
this.businessEventNotifierService.addBusinessEventPostListeners(BusinessEvent.LOAN_UNDO_APPROVAL, new UndoAllFundTransactions());
this.businessEventNotifierService.addBusinessEventPostListeners(BusinessEvent.LOAN_UNDO_DISBURSAL,
new ReverseAllFundsOnBusinessEvent());
this.businessEventNotifierService.addBusinessEventPostListeners(BusinessEvents.LOAN_ADJUST_TRANSACTION,
this.businessEventNotifierService.addBusinessEventPostListeners(BusinessEvent.LOAN_ADJUST_TRANSACTION,
new AdjustFundsOnBusinessEvent());
this.businessEventNotifierService.addBusinessEventPostListeners(BusinessEvents.LOAN_MAKE_REPAYMENT,
this.businessEventNotifierService.addBusinessEventPostListeners(BusinessEvent.LOAN_MAKE_REPAYMENT,
new ReleaseFundsOnBusinessEvent());
this.businessEventNotifierService.addBusinessEventPostListeners(BusinessEvents.LOAN_WRITTEN_OFF, new ReleaseAllFunds());
this.businessEventNotifierService.addBusinessEventPostListeners(BusinessEvents.LOAN_UNDO_WRITTEN_OFF,
this.businessEventNotifierService.addBusinessEventPostListeners(BusinessEvent.LOAN_WRITTEN_OFF, new ReleaseAllFunds());
this.businessEventNotifierService.addBusinessEventPostListeners(BusinessEvent.LOAN_UNDO_WRITTEN_OFF,
new ReverseFundsOnBusinessEvent());
}
@@ -67,6 +67,9 @@ import org.apache.fineract.portfolio.account.domain.AccountAssociationType;
import org.apache.fineract.portfolio.account.domain.AccountAssociations;
import org.apache.fineract.portfolio.account.domain.AccountAssociationsRepository;
import org.apache.fineract.portfolio.accountdetails.domain.AccountType;
import org.apache.fineract.portfolio.businessevent.domain.BusinessEntity;
import org.apache.fineract.portfolio.businessevent.domain.BusinessEvent;
import org.apache.fineract.portfolio.businessevent.service.BusinessEventNotifierService;
import org.apache.fineract.portfolio.calendar.domain.Calendar;
import org.apache.fineract.portfolio.calendar.domain.CalendarEntityType;
import org.apache.fineract.portfolio.calendar.domain.CalendarFrequencyType;
@@ -84,10 +87,7 @@ import org.apache.fineract.portfolio.client.exception.ClientNotActiveException;
import org.apache.fineract.portfolio.collateralmanagement.domain.ClientCollateralManagement;
import org.apache.fineract.portfolio.collateralmanagement.domain.ClientCollateralManagementRepository;
import org.apache.fineract.portfolio.collateralmanagement.service.LoanCollateralAssembler;
import org.apache.fineract.portfolio.common.BusinessEventNotificationConstants.BusinessEntity;
import org.apache.fineract.portfolio.common.BusinessEventNotificationConstants.BusinessEvents;
import org.apache.fineract.portfolio.common.domain.PeriodFrequencyType;
import org.apache.fineract.portfolio.common.service.BusinessEventNotifierService;
import org.apache.fineract.portfolio.fund.domain.Fund;
import org.apache.fineract.portfolio.group.domain.Group;
import org.apache.fineract.portfolio.group.domain.GroupRepositoryWrapper;
@@ -588,7 +588,7 @@ public class LoanApplicationWritePlatformServiceJpaRepositoryImpl implements Loa
StatusEnum.CREATE.getCode().longValue(), EntityTables.LOAN.getForeignKeyColumnNameOnDatatable(),
newLoanApplication.productId());
this.businessEventNotifierService.notifyBusinessEventWasExecuted(BusinessEvents.LOAN_CREATE,
this.businessEventNotifierService.notifyBusinessEventWasExecuted(BusinessEvent.LOAN_CREATE,
constructEntityMap(BusinessEntity.LOAN, newLoanApplication));
return new CommandProcessingResultBuilder() //
@@ -1476,7 +1476,7 @@ public class LoanApplicationWritePlatformServiceJpaRepositoryImpl implements Loa
this.noteRepository.save(note);
}
this.businessEventNotifierService.notifyBusinessEventWasExecuted(BusinessEvents.LOAN_APPROVED,
this.businessEventNotifierService.notifyBusinessEventWasExecuted(BusinessEvent.LOAN_APPROVED,
constructEntityMap(BusinessEntity.LOAN, loan));
}
@@ -1555,7 +1555,7 @@ public class LoanApplicationWritePlatformServiceJpaRepositoryImpl implements Loa
final Note note = Note.loanNote(loan, noteText);
this.noteRepository.save(note);
}
this.businessEventNotifierService.notifyBusinessEventWasExecuted(BusinessEvents.LOAN_UNDO_APPROVAL,
this.businessEventNotifierService.notifyBusinessEventWasExecuted(BusinessEvent.LOAN_UNDO_APPROVAL,
constructEntityMap(BusinessEntity.LOAN, loan));
}
@@ -1626,7 +1626,7 @@ public class LoanApplicationWritePlatformServiceJpaRepositoryImpl implements Loa
this.noteRepository.save(note);
}
}
this.businessEventNotifierService.notifyBusinessEventWasExecuted(BusinessEvents.LOAN_REJECTED,
this.businessEventNotifierService.notifyBusinessEventWasExecuted(BusinessEvent.LOAN_REJECTED,
constructEntityMap(BusinessEntity.LOAN, loan));
return new CommandProcessingResultBuilder() //
.withCommandId(command.commandId()) //
@@ -34,10 +34,10 @@ import org.apache.fineract.infrastructure.core.service.ThreadLocalContextUtil;
import org.apache.fineract.infrastructure.core.service.database.DatabaseSpecificSQLGenerator;
import org.apache.fineract.infrastructure.jobs.annotation.CronTarget;
import org.apache.fineract.infrastructure.jobs.service.JobName;
import org.apache.fineract.portfolio.common.BusinessEventNotificationConstants.BusinessEntity;
import org.apache.fineract.portfolio.common.BusinessEventNotificationConstants.BusinessEvents;
import org.apache.fineract.portfolio.common.service.BusinessEventListener;
import org.apache.fineract.portfolio.common.service.BusinessEventNotifierService;
import org.apache.fineract.portfolio.businessevent.BusinessEventListener;
import org.apache.fineract.portfolio.businessevent.domain.BusinessEntity;
import org.apache.fineract.portfolio.businessevent.domain.BusinessEvent;
import org.apache.fineract.portfolio.businessevent.service.BusinessEventNotifierService;
import org.apache.fineract.portfolio.loanaccount.domain.Loan;
import org.apache.fineract.portfolio.loanaccount.domain.LoanCharge;
import org.apache.fineract.portfolio.loanaccount.domain.LoanRepaymentScheduleInstallment;
@@ -72,17 +72,17 @@ public class LoanArrearsAgingServiceImpl implements LoanArrearsAgingService, Bus
@PostConstruct
public void registerForNotification() {
this.businessEventNotifierService.addBusinessEventPostListeners(BusinessEvents.LOAN_REFUND, this);
this.businessEventNotifierService.addBusinessEventPostListeners(BusinessEvents.LOAN_ADJUST_TRANSACTION, this);
this.businessEventNotifierService.addBusinessEventPostListeners(BusinessEvents.LOAN_MAKE_REPAYMENT, this);
this.businessEventNotifierService.addBusinessEventPostListeners(BusinessEvents.LOAN_UNDO_WRITTEN_OFF, this);
this.businessEventNotifierService.addBusinessEventPostListeners(BusinessEvents.LOAN_WAIVE_INTEREST, this);
this.businessEventNotifierService.addBusinessEventPostListeners(BusinessEvents.LOAN_ADD_CHARGE, this);
this.businessEventNotifierService.addBusinessEventPostListeners(BusinessEvents.LOAN_WAIVE_CHARGE, this);
this.businessEventNotifierService.addBusinessEventPostListeners(BusinessEvents.LOAN_CHARGE_PAYMENT, this);
this.businessEventNotifierService.addBusinessEventPostListeners(BusinessEvents.LOAN_APPLY_OVERDUE_CHARGE, this);
this.businessEventNotifierService.addBusinessEventPostListeners(BusinessEvents.LOAN_DISBURSAL, new DisbursementEventListener());
this.businessEventNotifierService.addBusinessEventPostListeners(BusinessEvents.LOAN_FORECLOSURE, this);
this.businessEventNotifierService.addBusinessEventPostListeners(BusinessEvent.LOAN_REFUND, this);
this.businessEventNotifierService.addBusinessEventPostListeners(BusinessEvent.LOAN_ADJUST_TRANSACTION, this);
this.businessEventNotifierService.addBusinessEventPostListeners(BusinessEvent.LOAN_MAKE_REPAYMENT, this);
this.businessEventNotifierService.addBusinessEventPostListeners(BusinessEvent.LOAN_UNDO_WRITTEN_OFF, this);
this.businessEventNotifierService.addBusinessEventPostListeners(BusinessEvent.LOAN_WAIVE_INTEREST, this);
this.businessEventNotifierService.addBusinessEventPostListeners(BusinessEvent.LOAN_ADD_CHARGE, this);
this.businessEventNotifierService.addBusinessEventPostListeners(BusinessEvent.LOAN_WAIVE_CHARGE, this);
this.businessEventNotifierService.addBusinessEventPostListeners(BusinessEvent.LOAN_CHARGE_PAYMENT, this);
this.businessEventNotifierService.addBusinessEventPostListeners(BusinessEvent.LOAN_APPLY_OVERDUE_CHARGE, this);
this.businessEventNotifierService.addBusinessEventPostListeners(BusinessEvent.LOAN_DISBURSAL, new DisbursementEventListener());
this.businessEventNotifierService.addBusinessEventPostListeners(BusinessEvent.LOAN_FORECLOSURE, this);
}
@Transactional
@@ -90,6 +90,9 @@ import org.apache.fineract.portfolio.account.service.AccountAssociationsReadPlat
import org.apache.fineract.portfolio.account.service.AccountTransfersReadPlatformService;
import org.apache.fineract.portfolio.account.service.AccountTransfersWritePlatformService;
import org.apache.fineract.portfolio.accountdetails.domain.AccountType;
import org.apache.fineract.portfolio.businessevent.domain.BusinessEntity;
import org.apache.fineract.portfolio.businessevent.domain.BusinessEvent;
import org.apache.fineract.portfolio.businessevent.service.BusinessEventNotifierService;
import org.apache.fineract.portfolio.calendar.domain.Calendar;
import org.apache.fineract.portfolio.calendar.domain.CalendarEntityType;
import org.apache.fineract.portfolio.calendar.domain.CalendarInstance;
@@ -121,10 +124,7 @@ import org.apache.fineract.portfolio.collectionsheet.command.CollectionSheetBulk
import org.apache.fineract.portfolio.collectionsheet.command.CollectionSheetBulkRepaymentCommand;
import org.apache.fineract.portfolio.collectionsheet.command.SingleDisbursalCommand;
import org.apache.fineract.portfolio.collectionsheet.command.SingleRepaymentCommand;
import org.apache.fineract.portfolio.common.BusinessEventNotificationConstants.BusinessEntity;
import org.apache.fineract.portfolio.common.BusinessEventNotificationConstants.BusinessEvents;
import org.apache.fineract.portfolio.common.domain.PeriodFrequencyType;
import org.apache.fineract.portfolio.common.service.BusinessEventNotifierService;
import org.apache.fineract.portfolio.group.domain.Group;
import org.apache.fineract.portfolio.group.exception.GroupNotActiveException;
import org.apache.fineract.portfolio.loanaccount.api.LoanApiConstants;
@@ -437,7 +437,7 @@ public class LoanWritePlatformServiceJpaRepositoryImpl implements LoanWritePlatf
scheduleGeneratorDTO.isSkipRepaymentOnFirstDayofMonth(), scheduleGeneratorDTO.getNumberOfdays());
}
this.businessEventNotifierService.notifyBusinessEventToBeExecuted(BusinessEvents.LOAN_DISBURSAL,
this.businessEventNotifierService.notifyBusinessEventToBeExecuted(BusinessEvent.LOAN_DISBURSAL,
constructEntityMap(BusinessEntity.LOAN, loan));
final List<Long> existingTransactionIds = new ArrayList<>();
@@ -588,7 +588,7 @@ public class LoanWritePlatformServiceJpaRepositoryImpl implements LoanWritePlatf
updatePostDatedChecks(postDatedChecks);
}
this.businessEventNotifierService.notifyBusinessEventWasExecuted(BusinessEvents.LOAN_DISBURSAL,
this.businessEventNotifierService.notifyBusinessEventWasExecuted(BusinessEvent.LOAN_DISBURSAL,
constructEntityMap(BusinessEntity.LOAN, loan));
Long entityId = loan.getId();
@@ -743,7 +743,7 @@ public class LoanWritePlatformServiceJpaRepositoryImpl implements LoanWritePlatf
syncExpectedDateWithActualDisbursementDate(loan, actualDisbursementDate);
}
checkClientOrGroupActive(loan);
this.businessEventNotifierService.notifyBusinessEventToBeExecuted(BusinessEvents.LOAN_DISBURSAL,
this.businessEventNotifierService.notifyBusinessEventToBeExecuted(BusinessEvent.LOAN_DISBURSAL,
constructEntityMap(BusinessEntity.LOAN, loan));
final List<Long> existingTransactionIds = new ArrayList<>();
@@ -835,7 +835,7 @@ public class LoanWritePlatformServiceJpaRepositoryImpl implements LoanWritePlatf
}
updateRecurringCalendarDatesForInterestRecalculation(loan);
this.loanAccountDomainService.recalculateAccruals(loan);
this.businessEventNotifierService.notifyBusinessEventWasExecuted(BusinessEvents.LOAN_DISBURSAL,
this.businessEventNotifierService.notifyBusinessEventWasExecuted(BusinessEvent.LOAN_DISBURSAL,
constructEntityMap(BusinessEntity.LOAN, loan));
}
@@ -874,7 +874,7 @@ public class LoanWritePlatformServiceJpaRepositoryImpl implements LoanWritePlatf
final AppUser currentUser = getAppUserIfPresent();
final Loan loan = this.loanAssembler.assembleFrom(loanId);
checkClientOrGroupActive(loan);
this.businessEventNotifierService.notifyBusinessEventToBeExecuted(BusinessEvents.LOAN_UNDO_DISBURSAL,
this.businessEventNotifierService.notifyBusinessEventToBeExecuted(BusinessEvent.LOAN_UNDO_DISBURSAL,
constructEntityMap(BusinessEntity.LOAN, loan));
removeLoanCycle(loan);
final List<Long> existingTransactionIds = new ArrayList<>();
@@ -917,7 +917,7 @@ public class LoanWritePlatformServiceJpaRepositoryImpl implements LoanWritePlatf
final Map<String, Object> accountingBridgeData = loan.deriveAccountingBridgeData(applicationCurrency.toData(),
existingTransactionIds, existingReversedTransactionIds, isAccountTransfer);
this.journalEntryWritePlatformService.createJournalEntriesForLoan(accountingBridgeData);
this.businessEventNotifierService.notifyBusinessEventWasExecuted(BusinessEvents.LOAN_UNDO_DISBURSAL,
this.businessEventNotifierService.notifyBusinessEventWasExecuted(BusinessEvent.LOAN_UNDO_DISBURSAL,
constructEntityMap(BusinessEntity.LOAN, loan));
}
@@ -1087,7 +1087,7 @@ public class LoanWritePlatformServiceJpaRepositoryImpl implements LoanWritePlatf
checkClientOrGroupActive(loan);
final LoanTransaction transactionToAdjust = this.loanTransactionRepository.findById(transactionId)
.orElseThrow(() -> new LoanTransactionNotFoundException(transactionId));
this.businessEventNotifierService.notifyBusinessEventToBeExecuted(BusinessEvents.LOAN_ADJUST_TRANSACTION,
this.businessEventNotifierService.notifyBusinessEventToBeExecuted(BusinessEvent.LOAN_ADJUST_TRANSACTION,
constructEntityMap(BusinessEntity.LOAN_ADJUSTED_TRANSACTION, transactionToAdjust));
if (this.accountTransfersReadPlatformService.isAccountTransfer(transactionId, PortfolioAccountType.LOAN)) {
throw new PlatformServiceUnavailableException("error.msg.loan.transfer.transaction.update.not.allowed",
@@ -1201,7 +1201,7 @@ public class LoanWritePlatformServiceJpaRepositoryImpl implements LoanWritePlatf
if (newTransactionDetail.isRepaymentType() && newTransactionDetail.isGreaterThanZero(loan.getPrincpal().getCurrency())) {
entityMap.put(BusinessEntity.LOAN_TRANSACTION, newTransactionDetail);
}
this.businessEventNotifierService.notifyBusinessEventWasExecuted(BusinessEvents.LOAN_ADJUST_TRANSACTION, entityMap);
this.businessEventNotifierService.notifyBusinessEventWasExecuted(BusinessEvent.LOAN_ADJUST_TRANSACTION, entityMap);
return new CommandProcessingResultBuilder().withCommandId(command.commandId()).withEntityId(transactionId)
.withOfficeId(loan.getOfficeId()).withClientId(loan.getClientId()).withGroupId(loan.getGroupId()).withLoanId(loanId)
@@ -1242,7 +1242,7 @@ public class LoanWritePlatformServiceJpaRepositoryImpl implements LoanWritePlatf
}
final LoanTransaction waiveInterestTransaction = LoanTransaction.waiver(loan.getOffice(), loan, transactionAmountAsMoney,
transactionDate, interestComponent, unrecognizedIncome, DateUtils.getLocalDateTimeOfTenant(), currentUser);
this.businessEventNotifierService.notifyBusinessEventToBeExecuted(BusinessEvents.LOAN_WAIVE_INTEREST,
this.businessEventNotifierService.notifyBusinessEventToBeExecuted(BusinessEvent.LOAN_WAIVE_INTEREST,
constructEntityMap(BusinessEntity.LOAN_TRANSACTION, waiveInterestTransaction));
LocalDate recalculateFrom = null;
if (loan.repaymentScheduleDetail().isInterestRecalculationEnabled()) {
@@ -1280,7 +1280,7 @@ public class LoanWritePlatformServiceJpaRepositoryImpl implements LoanWritePlatf
postJournalEntries(loan, existingTransactionIds, existingReversedTransactionIds);
this.loanAccountDomainService.recalculateAccruals(loan);
this.businessEventNotifierService.notifyBusinessEventWasExecuted(BusinessEvents.LOAN_WAIVE_INTEREST,
this.businessEventNotifierService.notifyBusinessEventWasExecuted(BusinessEvent.LOAN_WAIVE_INTEREST,
constructEntityMap(BusinessEntity.LOAN_TRANSACTION, waiveInterestTransaction));
return new CommandProcessingResultBuilder().withCommandId(command.commandId()).withEntityId(waiveInterestTransaction.getId())
.withOfficeId(loan.getOfficeId()).withClientId(loan.getClientId()).withGroupId(loan.getGroupId()).withLoanId(loanId)
@@ -1308,7 +1308,7 @@ public class LoanWritePlatformServiceJpaRepositoryImpl implements LoanWritePlatf
}
checkClientOrGroupActive(loan);
this.businessEventNotifierService.notifyBusinessEventToBeExecuted(BusinessEvents.LOAN_WRITTEN_OFF,
this.businessEventNotifierService.notifyBusinessEventToBeExecuted(BusinessEvent.LOAN_WRITTEN_OFF,
constructEntityMap(BusinessEntity.LOAN, loan));
entityDatatableChecksWritePlatformService.runTheCheckForProduct(loanId, EntityTables.LOAN.getName(),
StatusEnum.WRITE_OFF.getCode().longValue(), EntityTables.LOAN.getForeignKeyColumnNameOnDatatable(), loan.productId());
@@ -1345,7 +1345,7 @@ public class LoanWritePlatformServiceJpaRepositoryImpl implements LoanWritePlatf
postJournalEntries(loan, existingTransactionIds, existingReversedTransactionIds);
this.loanAccountDomainService.recalculateAccruals(loan);
this.businessEventNotifierService.notifyBusinessEventWasExecuted(BusinessEvents.LOAN_WRITTEN_OFF,
this.businessEventNotifierService.notifyBusinessEventWasExecuted(BusinessEvent.LOAN_WRITTEN_OFF,
constructEntityMap(BusinessEntity.LOAN_TRANSACTION, writeoff));
return new CommandProcessingResultBuilder().withCommandId(command.commandId()).withEntityId(writeoff.getId())
.withOfficeId(loan.getOfficeId()).withClientId(loan.getClientId()).withGroupId(loan.getGroupId()).withLoanId(loanId)
@@ -1362,7 +1362,7 @@ public class LoanWritePlatformServiceJpaRepositoryImpl implements LoanWritePlatf
final Loan loan = this.loanAssembler.assembleFrom(loanId);
checkClientOrGroupActive(loan);
this.businessEventNotifierService.notifyBusinessEventToBeExecuted(BusinessEvents.LOAN_CLOSE,
this.businessEventNotifierService.notifyBusinessEventToBeExecuted(BusinessEvent.LOAN_CLOSE,
constructEntityMap(BusinessEntity.LOAN, loan));
final Map<String, Object> changes = new LinkedHashMap<>();
@@ -1405,7 +1405,7 @@ public class LoanWritePlatformServiceJpaRepositoryImpl implements LoanWritePlatf
}
this.loanAccountDomainService.recalculateAccruals(loan);
this.businessEventNotifierService.notifyBusinessEventWasExecuted(BusinessEvents.LOAN_CLOSE,
this.businessEventNotifierService.notifyBusinessEventWasExecuted(BusinessEvent.LOAN_CLOSE,
constructEntityMap(BusinessEntity.LOAN, loan));
// Update loan transaction on repayment.
@@ -1451,7 +1451,7 @@ public class LoanWritePlatformServiceJpaRepositoryImpl implements LoanWritePlatf
final Loan loan = this.loanAssembler.assembleFrom(loanId);
checkClientOrGroupActive(loan);
removeLoanCycle(loan);
this.businessEventNotifierService.notifyBusinessEventToBeExecuted(BusinessEvents.LOAN_CLOSE_AS_RESCHEDULE,
this.businessEventNotifierService.notifyBusinessEventToBeExecuted(BusinessEvent.LOAN_CLOSE_AS_RESCHEDULE,
constructEntityMap(BusinessEntity.LOAN, loan));
final Map<String, Object> changes = new LinkedHashMap<>();
@@ -1469,7 +1469,7 @@ public class LoanWritePlatformServiceJpaRepositoryImpl implements LoanWritePlatf
final Note note = Note.loanNote(loan, noteText);
this.noteRepository.save(note);
}
this.businessEventNotifierService.notifyBusinessEventWasExecuted(BusinessEvents.LOAN_CLOSE_AS_RESCHEDULE,
this.businessEventNotifierService.notifyBusinessEventWasExecuted(BusinessEvent.LOAN_CLOSE_AS_RESCHEDULE,
constructEntityMap(BusinessEntity.LOAN, loan));
// disable all active standing instructions linked to the loan
@@ -1548,7 +1548,7 @@ public class LoanWritePlatformServiceJpaRepositoryImpl implements LoanWritePlatf
disbursementDetail.expectedDisbursementDateAsLocalDate(), null, null);
loanTrancheDisbursementCharge = new LoanTrancheDisbursementCharge(loanCharge, disbursementDetail);
loanCharge.updateLoanTrancheDisbursementCharge(loanTrancheDisbursementCharge);
this.businessEventNotifierService.notifyBusinessEventToBeExecuted(BusinessEvents.LOAN_ADD_CHARGE,
this.businessEventNotifierService.notifyBusinessEventToBeExecuted(BusinessEvent.LOAN_ADD_CHARGE,
constructEntityMap(BusinessEntity.LOAN_CHARGE, loanCharge));
validateAddLoanCharge(loan, chargeDefinition, loanCharge);
addCharge(loan, chargeDefinition, loanCharge);
@@ -1561,7 +1561,7 @@ public class LoanWritePlatformServiceJpaRepositoryImpl implements LoanWritePlatf
loan.addTrancheLoanCharge(chargeDefinition);
} else {
loanCharge = LoanCharge.createNewFromJson(loan, chargeDefinition, command);
this.businessEventNotifierService.notifyBusinessEventToBeExecuted(BusinessEvents.LOAN_ADD_CHARGE,
this.businessEventNotifierService.notifyBusinessEventToBeExecuted(BusinessEvent.LOAN_ADD_CHARGE,
constructEntityMap(BusinessEntity.LOAN_CHARGE, loanCharge));
validateAddLoanCharge(loan, chargeDefinition, loanCharge);
@@ -1601,7 +1601,7 @@ public class LoanWritePlatformServiceJpaRepositoryImpl implements LoanWritePlatf
&& loan.isFeeCompoundingEnabledForInterestRecalculation()) {
this.loanAccountDomainService.recalculateAccruals(loan);
}
this.businessEventNotifierService.notifyBusinessEventWasExecuted(BusinessEvents.LOAN_ADD_CHARGE,
this.businessEventNotifierService.notifyBusinessEventWasExecuted(BusinessEvent.LOAN_ADD_CHARGE,
constructEntityMap(BusinessEntity.LOAN_CHARGE, loanCharge));
return new CommandProcessingResultBuilder().withCommandId(command.commandId()).withEntityId(loanCharge.getId())
.withOfficeId(loan.getOfficeId()).withClientId(loan.getClientId()).withGroupId(loan.getGroupId()).withLoanId(loanId)
@@ -1718,13 +1718,13 @@ public class LoanWritePlatformServiceJpaRepositoryImpl implements LoanWritePlatf
loanCharge.getId());
}
this.businessEventNotifierService.notifyBusinessEventToBeExecuted(BusinessEvents.LOAN_UPDATE_CHARGE,
this.businessEventNotifierService.notifyBusinessEventToBeExecuted(BusinessEvent.LOAN_UPDATE_CHARGE,
constructEntityMap(BusinessEntity.LOAN_CHARGE, loanCharge));
final Map<String, Object> changes = loan.updateLoanCharge(loanCharge, command);
saveLoanWithDataIntegrityViolationChecks(loan);
this.businessEventNotifierService.notifyBusinessEventWasExecuted(BusinessEvents.LOAN_UPDATE_CHARGE,
this.businessEventNotifierService.notifyBusinessEventWasExecuted(BusinessEvent.LOAN_UPDATE_CHARGE,
constructEntityMap(BusinessEntity.LOAN_CHARGE, loanCharge));
return new CommandProcessingResultBuilder() //
.withCommandId(command.commandId()) //
@@ -1778,7 +1778,7 @@ public class LoanWritePlatformServiceJpaRepositoryImpl implements LoanWritePlatf
final Map<String, Object> changes = new LinkedHashMap<>(3);
this.businessEventNotifierService.notifyBusinessEventToBeExecuted(BusinessEvents.LOAN_WAIVE_CHARGE_UNDO,
this.businessEventNotifierService.notifyBusinessEventToBeExecuted(BusinessEvent.LOAN_WAIVE_CHARGE_UNDO,
constructEntityMap(BusinessEntity.LOAN_CHARGE, loanCharge));
if (loanCharge.isInstalmentFee()) {
@@ -1867,7 +1867,7 @@ public class LoanWritePlatformServiceJpaRepositoryImpl implements LoanWritePlatf
saveLoanWithDataIntegrityViolationChecks(loan);
this.businessEventNotifierService.notifyBusinessEventWasExecuted(BusinessEvents.LOAN_WAIVE_CHARGE_UNDO,
this.businessEventNotifierService.notifyBusinessEventWasExecuted(BusinessEvent.LOAN_WAIVE_CHARGE_UNDO,
constructEntityMap(BusinessEntity.LOAN_CHARGE, loanCharge));
LoanTransaction loanTransactionData = this.loanTransactionRepository.getById(command.entityId());
@@ -1909,7 +1909,7 @@ public class LoanWritePlatformServiceJpaRepositoryImpl implements LoanWritePlatf
} else if (loanCharge.isPaid()) {
throw new LoanChargeCannotBeWaivedException(LoanChargeCannotBeWaivedReason.ALREADY_PAID, loanCharge.getId());
}
this.businessEventNotifierService.notifyBusinessEventToBeExecuted(BusinessEvents.LOAN_WAIVE_CHARGE,
this.businessEventNotifierService.notifyBusinessEventToBeExecuted(BusinessEvent.LOAN_WAIVE_CHARGE,
constructEntityMap(BusinessEntity.LOAN_CHARGE, loanCharge));
Integer loanInstallmentNumber = null;
if (loanCharge.isInstalmentFee()) {
@@ -1959,7 +1959,7 @@ public class LoanWritePlatformServiceJpaRepositoryImpl implements LoanWritePlatf
postJournalEntries(loan, existingTransactionIds, existingReversedTransactionIds);
this.businessEventNotifierService.notifyBusinessEventWasExecuted(BusinessEvents.LOAN_WAIVE_CHARGE,
this.businessEventNotifierService.notifyBusinessEventWasExecuted(BusinessEvent.LOAN_WAIVE_CHARGE,
constructEntityMap(BusinessEntity.LOAN_CHARGE, loanCharge));
return new CommandProcessingResultBuilder() //
@@ -1987,12 +1987,12 @@ public class LoanWritePlatformServiceJpaRepositoryImpl implements LoanWritePlatf
throw new LoanChargeCannotBeDeletedException(LoanChargeCannotBeDeletedReason.LOAN_NOT_IN_SUBMITTED_AND_PENDING_APPROVAL_STAGE,
loanCharge.getId());
}
this.businessEventNotifierService.notifyBusinessEventToBeExecuted(BusinessEvents.LOAN_DELETE_CHARGE,
this.businessEventNotifierService.notifyBusinessEventToBeExecuted(BusinessEvent.LOAN_DELETE_CHARGE,
constructEntityMap(BusinessEntity.LOAN_CHARGE, loanCharge));
loan.removeLoanCharge(loanCharge);
saveLoanWithDataIntegrityViolationChecks(loan);
this.businessEventNotifierService.notifyBusinessEventWasExecuted(BusinessEvents.LOAN_DELETE_CHARGE,
this.businessEventNotifierService.notifyBusinessEventWasExecuted(BusinessEvent.LOAN_DELETE_CHARGE,
constructEntityMap(BusinessEntity.LOAN_CHARGE, loanCharge));
return new CommandProcessingResultBuilder() //
.withCommandId(command.commandId()) //
@@ -2205,7 +2205,7 @@ public class LoanWritePlatformServiceJpaRepositoryImpl implements LoanWritePlatf
checkClientOrGroupActive(loan);
validateTransactionsForTransfer(loan, transferDate);
this.businessEventNotifierService.notifyBusinessEventToBeExecuted(BusinessEvents.LOAN_INITIATE_TRANSFER,
this.businessEventNotifierService.notifyBusinessEventToBeExecuted(BusinessEvent.LOAN_INITIATE_TRANSFER,
constructEntityMap(BusinessEntity.LOAN, loan));
final List<Long> existingTransactionIds = new ArrayList<>(loan.findExistingTransactionIds());
@@ -2220,7 +2220,7 @@ public class LoanWritePlatformServiceJpaRepositoryImpl implements LoanWritePlatf
saveLoanWithDataIntegrityViolationChecks(loan);
postJournalEntries(loan, existingTransactionIds, existingReversedTransactionIds);
this.businessEventNotifierService.notifyBusinessEventWasExecuted(BusinessEvents.LOAN_INITIATE_TRANSFER,
this.businessEventNotifierService.notifyBusinessEventWasExecuted(BusinessEvent.LOAN_INITIATE_TRANSFER,
constructEntityMap(BusinessEntity.LOAN, loan));
return newTransferTransaction;
}
@@ -2231,7 +2231,7 @@ public class LoanWritePlatformServiceJpaRepositoryImpl implements LoanWritePlatf
final Staff loanOfficer) {
AppUser currentUser = getAppUserIfPresent();
this.loanAssembler.setHelpers(loan);
this.businessEventNotifierService.notifyBusinessEventToBeExecuted(BusinessEvents.LOAN_ACCEPT_TRANSFER,
this.businessEventNotifierService.notifyBusinessEventToBeExecuted(BusinessEvent.LOAN_ACCEPT_TRANSFER,
constructEntityMap(BusinessEntity.LOAN, loan));
final List<Long> existingTransactionIds = new ArrayList<>(loan.findExistingTransactionIds());
final List<Long> existingReversedTransactionIds = new ArrayList<>(loan.findExistingReversedTransactionIds());
@@ -2252,7 +2252,7 @@ public class LoanWritePlatformServiceJpaRepositoryImpl implements LoanWritePlatf
saveLoanWithDataIntegrityViolationChecks(loan);
postJournalEntries(loan, existingTransactionIds, existingReversedTransactionIds);
this.businessEventNotifierService.notifyBusinessEventWasExecuted(BusinessEvents.LOAN_ACCEPT_TRANSFER,
this.businessEventNotifierService.notifyBusinessEventWasExecuted(BusinessEvent.LOAN_ACCEPT_TRANSFER,
constructEntityMap(BusinessEntity.LOAN, loan));
return newTransferAcceptanceTransaction;
@@ -2263,7 +2263,7 @@ public class LoanWritePlatformServiceJpaRepositoryImpl implements LoanWritePlatf
public LoanTransaction withdrawLoanTransfer(final Loan loan, final LocalDate transferDate) {
AppUser currentUser = getAppUserIfPresent();
this.loanAssembler.setHelpers(loan);
this.businessEventNotifierService.notifyBusinessEventToBeExecuted(BusinessEvents.LOAN_WITHDRAW_TRANSFER,
this.businessEventNotifierService.notifyBusinessEventToBeExecuted(BusinessEvent.LOAN_WITHDRAW_TRANSFER,
constructEntityMap(BusinessEntity.LOAN, loan));
final List<Long> existingTransactionIds = new ArrayList<>(loan.findExistingTransactionIds());
@@ -2278,7 +2278,7 @@ public class LoanWritePlatformServiceJpaRepositoryImpl implements LoanWritePlatf
saveLoanWithDataIntegrityViolationChecks(loan);
postJournalEntries(loan, existingTransactionIds, existingReversedTransactionIds);
this.businessEventNotifierService.notifyBusinessEventWasExecuted(BusinessEvents.LOAN_WITHDRAW_TRANSFER,
this.businessEventNotifierService.notifyBusinessEventWasExecuted(BusinessEvent.LOAN_WITHDRAW_TRANSFER,
constructEntityMap(BusinessEntity.LOAN, loan));
return newTransferAcceptanceTransaction;
@@ -2288,11 +2288,11 @@ public class LoanWritePlatformServiceJpaRepositoryImpl implements LoanWritePlatf
@Override
public void rejectLoanTransfer(final Loan loan) {
this.loanAssembler.setHelpers(loan);
this.businessEventNotifierService.notifyBusinessEventToBeExecuted(BusinessEvents.LOAN_REJECT_TRANSFER,
this.businessEventNotifierService.notifyBusinessEventToBeExecuted(BusinessEvent.LOAN_REJECT_TRANSFER,
constructEntityMap(BusinessEntity.LOAN, loan));
loan.setLoanStatus(LoanStatus.TRANSFER_ON_HOLD.getValue());
saveLoanWithDataIntegrityViolationChecks(loan);
this.businessEventNotifierService.notifyBusinessEventWasExecuted(BusinessEvents.LOAN_REJECT_TRANSFER,
this.businessEventNotifierService.notifyBusinessEventWasExecuted(BusinessEvent.LOAN_REJECT_TRANSFER,
constructEntityMap(BusinessEntity.LOAN, loan));
}
@@ -2311,7 +2311,7 @@ public class LoanWritePlatformServiceJpaRepositoryImpl implements LoanWritePlatf
final Loan loan = this.loanAssembler.assembleFrom(loanId);
checkClientOrGroupActive(loan);
this.businessEventNotifierService.notifyBusinessEventToBeExecuted(BusinessEvents.LOAN_REASSIGN_OFFICER,
this.businessEventNotifierService.notifyBusinessEventToBeExecuted(BusinessEvent.LOAN_REASSIGN_OFFICER,
constructEntityMap(BusinessEntity.LOAN, loan));
if (!loan.hasLoanOfficer(fromLoanOfficer)) {
throw new LoanOfficerAssignmentException(loanId, fromLoanOfficerId);
@@ -2320,7 +2320,7 @@ public class LoanWritePlatformServiceJpaRepositoryImpl implements LoanWritePlatf
loan.reassignLoanOfficer(toLoanOfficer, dateOfLoanOfficerAssignment);
saveLoanWithDataIntegrityViolationChecks(loan);
this.businessEventNotifierService.notifyBusinessEventWasExecuted(BusinessEvents.LOAN_REASSIGN_OFFICER,
this.businessEventNotifierService.notifyBusinessEventWasExecuted(BusinessEvent.LOAN_REASSIGN_OFFICER,
constructEntityMap(BusinessEntity.LOAN, loan));
return new CommandProcessingResultBuilder() //
@@ -2351,7 +2351,7 @@ public class LoanWritePlatformServiceJpaRepositoryImpl implements LoanWritePlatf
for (final String loanIdString : loanIds) {
final Long loanId = Long.valueOf(loanIdString);
final Loan loan = this.loanAssembler.assembleFrom(loanId);
this.businessEventNotifierService.notifyBusinessEventToBeExecuted(BusinessEvents.LOAN_REASSIGN_OFFICER,
this.businessEventNotifierService.notifyBusinessEventToBeExecuted(BusinessEvent.LOAN_REASSIGN_OFFICER,
constructEntityMap(BusinessEntity.LOAN, loan));
checkClientOrGroupActive(loan);
@@ -2361,7 +2361,7 @@ public class LoanWritePlatformServiceJpaRepositoryImpl implements LoanWritePlatf
loan.reassignLoanOfficer(toLoanOfficer, dateOfLoanOfficerAssignment);
saveLoanWithDataIntegrityViolationChecks(loan);
this.businessEventNotifierService.notifyBusinessEventWasExecuted(BusinessEvents.LOAN_REASSIGN_OFFICER,
this.businessEventNotifierService.notifyBusinessEventWasExecuted(BusinessEvent.LOAN_REASSIGN_OFFICER,
constructEntityMap(BusinessEntity.LOAN, loan));
}
this.loanRepositoryWrapper.flush();
@@ -2387,13 +2387,13 @@ public class LoanWritePlatformServiceJpaRepositoryImpl implements LoanWritePlatf
if (loan.getLoanOfficer() == null) {
throw new LoanOfficerUnassignmentException(loanId);
}
this.businessEventNotifierService.notifyBusinessEventToBeExecuted(BusinessEvents.LOAN_REMOVE_OFFICER,
this.businessEventNotifierService.notifyBusinessEventToBeExecuted(BusinessEvent.LOAN_REMOVE_OFFICER,
constructEntityMap(BusinessEntity.LOAN, loan));
loan.removeLoanOfficer(dateOfLoanOfficerunAssigned);
saveLoanWithDataIntegrityViolationChecks(loan);
this.businessEventNotifierService.notifyBusinessEventWasExecuted(BusinessEvents.LOAN_REMOVE_OFFICER,
this.businessEventNotifierService.notifyBusinessEventWasExecuted(BusinessEvent.LOAN_REMOVE_OFFICER,
constructEntityMap(BusinessEntity.LOAN, loan));
return new CommandProcessingResultBuilder() //
@@ -2762,7 +2762,7 @@ public class LoanWritePlatformServiceJpaRepositoryImpl implements LoanWritePlatf
&& loan.isFeeCompoundingEnabledForInterestRecalculation()) {
this.loanAccountDomainService.recalculateAccruals(loan);
}
this.businessEventNotifierService.notifyBusinessEventWasExecuted(BusinessEvents.LOAN_APPLY_OVERDUE_CHARGE,
this.businessEventNotifierService.notifyBusinessEventWasExecuted(BusinessEvent.LOAN_APPLY_OVERDUE_CHARGE,
constructEntityMap(BusinessEntity.LOAN, loan));
}
@@ -2843,7 +2843,7 @@ public class LoanWritePlatformServiceJpaRepositoryImpl implements LoanWritePlatf
LocalDate recalculateFrom = DateUtils.getLocalDateOfTenant();
if (loan != null) {
this.businessEventNotifierService.notifyBusinessEventToBeExecuted(BusinessEvents.LOAN_APPLY_OVERDUE_CHARGE,
this.businessEventNotifierService.notifyBusinessEventToBeExecuted(BusinessEvent.LOAN_APPLY_OVERDUE_CHARGE,
constructEntityMap(BusinessEntity.LOAN, loan));
for (Map.Entry<Integer, LocalDate> entry : scheduleDates.entrySet()) {
@@ -2884,7 +2884,7 @@ public class LoanWritePlatformServiceJpaRepositoryImpl implements LoanWritePlatf
}
LocalDate recalculateFrom = null;
LoanTransaction writeOffTransaction = loan.findWriteOffTransaction();
this.businessEventNotifierService.notifyBusinessEventToBeExecuted(BusinessEvents.LOAN_UNDO_WRITTEN_OFF,
this.businessEventNotifierService.notifyBusinessEventToBeExecuted(BusinessEvent.LOAN_UNDO_WRITTEN_OFF,
constructEntityMap(BusinessEntity.LOAN_TRANSACTION, writeOffTransaction));
ScheduleGeneratorDTO scheduleGeneratorDTO = this.loanUtilService.buildScheduleGeneratorDTO(loan, recalculateFrom);
@@ -2902,7 +2902,7 @@ public class LoanWritePlatformServiceJpaRepositoryImpl implements LoanWritePlatf
postJournalEntries(loan, existingTransactionIds, existingReversedTransactionIds);
this.loanAccountDomainService.recalculateAccruals(loan);
if (writeOffTransaction != null) {
this.businessEventNotifierService.notifyBusinessEventWasExecuted(BusinessEvents.LOAN_UNDO_WRITTEN_OFF,
this.businessEventNotifierService.notifyBusinessEventWasExecuted(BusinessEvent.LOAN_UNDO_WRITTEN_OFF,
constructEntityMap(BusinessEntity.LOAN_TRANSACTION, writeOffTransaction));
}
return new CommandProcessingResultBuilder() //
@@ -3155,7 +3155,7 @@ public class LoanWritePlatformServiceJpaRepositoryImpl implements LoanWritePlatf
Loan loan = this.loanAssembler.assembleFrom(loanId);
LocalDate recalculateFrom = loan.fetchInterestRecalculateFromDate();
AppUser currentUser = getAppUserIfPresent();
this.businessEventNotifierService.notifyBusinessEventToBeExecuted(BusinessEvents.LOAN_INTEREST_RECALCULATION,
this.businessEventNotifierService.notifyBusinessEventToBeExecuted(BusinessEvent.LOAN_INTEREST_RECALCULATION,
constructEntityMap(BusinessEntity.LOAN, loan));
final List<Long> existingTransactionIds = new ArrayList<>();
final List<Long> existingReversedTransactionIds = new ArrayList<>();
@@ -3178,7 +3178,7 @@ public class LoanWritePlatformServiceJpaRepositoryImpl implements LoanWritePlatf
}
postJournalEntries(loan, existingTransactionIds, existingReversedTransactionIds);
this.loanAccountDomainService.recalculateAccruals(loan);
this.businessEventNotifierService.notifyBusinessEventWasExecuted(BusinessEvents.LOAN_INTEREST_RECALCULATION,
this.businessEventNotifierService.notifyBusinessEventWasExecuted(BusinessEvent.LOAN_INTEREST_RECALCULATION,
constructEntityMap(BusinessEntity.LOAN, loan));
}
@@ -3332,7 +3332,7 @@ public class LoanWritePlatformServiceJpaRepositoryImpl implements LoanWritePlatf
final LocalDate recalculateFromDate = loan.getLastRepaymentDate();
validateIsMultiDisbursalLoanAndDisbursedMoreThanOneTranche(loan);
checkClientOrGroupActive(loan);
this.businessEventNotifierService.notifyBusinessEventToBeExecuted(BusinessEvents.LOAN_UNDO_LASTDISBURSAL,
this.businessEventNotifierService.notifyBusinessEventToBeExecuted(BusinessEvent.LOAN_UNDO_LASTDISBURSAL,
constructEntityMap(BusinessEntity.LOAN, loan));
final MonetaryCurrency currency = loan.getCurrency();
@@ -3358,7 +3358,7 @@ public class LoanWritePlatformServiceJpaRepositoryImpl implements LoanWritePlatf
final Map<String, Object> accountingBridgeData = loan.deriveAccountingBridgeData(applicationCurrency.toData(),
existingTransactionIds, existingReversedTransactionIds, isAccountTransfer);
this.journalEntryWritePlatformService.createJournalEntriesForLoan(accountingBridgeData);
this.businessEventNotifierService.notifyBusinessEventWasExecuted(BusinessEvents.LOAN_UNDO_LASTDISBURSAL,
this.businessEventNotifierService.notifyBusinessEventWasExecuted(BusinessEvent.LOAN_UNDO_LASTDISBURSAL,
constructEntityMap(BusinessEntity.LOAN, loan));
}
@@ -35,12 +35,11 @@ import org.apache.fineract.infrastructure.core.exception.PlatformDataIntegrityEx
import org.apache.fineract.infrastructure.entityaccess.domain.FineractEntityAccessType;
import org.apache.fineract.infrastructure.entityaccess.service.FineractEntityAccessUtil;
import org.apache.fineract.infrastructure.security.service.PlatformSecurityContext;
import org.apache.fineract.portfolio.businessevent.domain.BusinessEntity;
import org.apache.fineract.portfolio.businessevent.domain.BusinessEvent;
import org.apache.fineract.portfolio.businessevent.service.BusinessEventNotifierService;
import org.apache.fineract.portfolio.charge.domain.Charge;
import org.apache.fineract.portfolio.charge.domain.ChargeRepositoryWrapper;
import org.apache.fineract.portfolio.common.BusinessEventNotificationConstants;
import org.apache.fineract.portfolio.common.BusinessEventNotificationConstants.BusinessEntity;
import org.apache.fineract.portfolio.common.BusinessEventNotificationConstants.BusinessEvents;
import org.apache.fineract.portfolio.common.service.BusinessEventNotifierService;
import org.apache.fineract.portfolio.floatingrates.domain.FloatingRate;
import org.apache.fineract.portfolio.floatingrates.domain.FloatingRateRepositoryWrapper;
import org.apache.fineract.portfolio.fund.domain.Fund;
@@ -151,10 +150,10 @@ public class LoanProductWritePlatformServiceJpaRepositoryImpl implements LoanPro
fineractEntityAccessUtil.checkConfigurationAndAddProductResrictionsForUserOffice(
FineractEntityAccessType.OFFICE_ACCESS_TO_LOAN_PRODUCTS, loanproduct.getId());
this.businessEventNotifierService.notifyBusinessEventWasExecuted(BusinessEvents.LOAN_PRODUCT_CREATE,
this.businessEventNotifierService.notifyBusinessEventWasExecuted(BusinessEvent.LOAN_PRODUCT_CREATE,
constructEntityMap(BusinessEntity.LOAN_PRODUCT, loanproduct));
this.businessEventNotifierService.notifyBusinessEventWasExecuted(BusinessEvents.LOAN_PRODUCT_CREATE,
this.businessEventNotifierService.notifyBusinessEventWasExecuted(BusinessEvent.LOAN_PRODUCT_CREATE,
constructEntityMap(BusinessEntity.LOAN_PRODUCT, loanproduct));
return new CommandProcessingResultBuilder() //
@@ -383,9 +382,8 @@ public class LoanProductWritePlatformServiceJpaRepositoryImpl implements LoanPro
LOG.error("Error occured.", dve);
}
private Map<BusinessEventNotificationConstants.BusinessEntity, Object> constructEntityMap(
final BusinessEventNotificationConstants.BusinessEntity entityEvent, Object entity) {
Map<BusinessEventNotificationConstants.BusinessEntity, Object> map = new HashMap<>(1);
private Map<BusinessEntity, Object> constructEntityMap(final BusinessEntity entityEvent, Object entity) {
Map<BusinessEntity, Object> map = new HashMap<>(1);
map.put(entityEvent, entity);
return map;
}
@@ -38,9 +38,9 @@ import org.apache.fineract.organisation.monetary.domain.ApplicationCurrencyRepos
import org.apache.fineract.organisation.monetary.domain.MonetaryCurrency;
import org.apache.fineract.organisation.monetary.domain.Money;
import org.apache.fineract.organisation.monetary.domain.MoneyHelper;
import org.apache.fineract.portfolio.common.BusinessEventNotificationConstants.BusinessEntity;
import org.apache.fineract.portfolio.common.BusinessEventNotificationConstants.BusinessEvents;
import org.apache.fineract.portfolio.common.service.BusinessEventNotifierService;
import org.apache.fineract.portfolio.businessevent.domain.BusinessEntity;
import org.apache.fineract.portfolio.businessevent.domain.BusinessEvent;
import org.apache.fineract.portfolio.businessevent.service.BusinessEventNotifierService;
import org.apache.fineract.portfolio.paymentdetail.domain.PaymentDetail;
import org.apache.fineract.portfolio.savings.SavingsAccountTransactionType;
import org.apache.fineract.portfolio.savings.SavingsTransactionBooleanValues;
@@ -139,7 +139,7 @@ public class SavingsAccountDomainServiceJpa implements SavingsAccountDomainServi
postJournalEntries(account, existingTransactionIds, existingReversedTransactionIds, transactionBooleanValues.isAccountTransfer(),
backdatedTxnsAllowedTill);
this.businessEventNotifierService.notifyBusinessEventWasExecuted(BusinessEvents.SAVINGS_WITHDRAWAL,
this.businessEventNotifierService.notifyBusinessEventWasExecuted(BusinessEvent.SAVINGS_WITHDRAWAL,
constructEntityMap(BusinessEntity.SAVINGS_TRANSACTION, withdrawal));
return withdrawal;
}
@@ -215,7 +215,7 @@ public class SavingsAccountDomainServiceJpa implements SavingsAccountDomainServi
this.savingsAccountRepository.saveAndFlush(account);
postJournalEntries(account, existingTransactionIds, existingReversedTransactionIds, isAccountTransfer, backdatedTxnsAllowedTill);
this.businessEventNotifierService.notifyBusinessEventWasExecuted(BusinessEvents.SAVINGS_DEPOSIT,
this.businessEventNotifierService.notifyBusinessEventWasExecuted(BusinessEvent.SAVINGS_DEPOSIT,
constructEntityMap(BusinessEntity.SAVINGS_TRANSACTION, deposit));
return deposit;
}
@@ -55,6 +55,9 @@ import org.apache.fineract.organisation.staff.domain.StaffRepositoryWrapper;
import org.apache.fineract.portfolio.account.domain.AccountAssociationType;
import org.apache.fineract.portfolio.account.domain.AccountAssociations;
import org.apache.fineract.portfolio.account.domain.AccountAssociationsRepository;
import org.apache.fineract.portfolio.businessevent.domain.BusinessEntity;
import org.apache.fineract.portfolio.businessevent.domain.BusinessEvent;
import org.apache.fineract.portfolio.businessevent.service.BusinessEventNotifierService;
import org.apache.fineract.portfolio.calendar.domain.Calendar;
import org.apache.fineract.portfolio.calendar.domain.CalendarEntityType;
import org.apache.fineract.portfolio.calendar.domain.CalendarFrequencyType;
@@ -66,11 +69,7 @@ import org.apache.fineract.portfolio.client.domain.AccountNumberGenerator;
import org.apache.fineract.portfolio.client.domain.Client;
import org.apache.fineract.portfolio.client.domain.ClientRepositoryWrapper;
import org.apache.fineract.portfolio.client.exception.ClientNotActiveException;
import org.apache.fineract.portfolio.common.BusinessEventNotificationConstants;
import org.apache.fineract.portfolio.common.BusinessEventNotificationConstants.BusinessEntity;
import org.apache.fineract.portfolio.common.BusinessEventNotificationConstants.BusinessEvents;
import org.apache.fineract.portfolio.common.domain.PeriodFrequencyType;
import org.apache.fineract.portfolio.common.service.BusinessEventNotifierService;
import org.apache.fineract.portfolio.group.domain.Group;
import org.apache.fineract.portfolio.group.domain.GroupRepository;
import org.apache.fineract.portfolio.group.exception.CenterNotActiveException;
@@ -232,10 +231,10 @@ public class DepositApplicationProcessWritePlatformServiceJpaRepositoryImpl impl
}
final Long savingsId = account.getId();
this.businessEventNotifierService.notifyBusinessEventWasExecuted(BusinessEvents.FIXED_DEPOSIT_ACCOUNT_CREATE,
this.businessEventNotifierService.notifyBusinessEventWasExecuted(BusinessEvent.FIXED_DEPOSIT_ACCOUNT_CREATE,
constructEntityMap(BusinessEntity.DEPOSIT_ACCOUNT, account));
this.businessEventNotifierService.notifyBusinessEventWasExecuted(BusinessEvents.FIXED_DEPOSIT_ACCOUNT_CREATE,
this.businessEventNotifierService.notifyBusinessEventWasExecuted(BusinessEvent.FIXED_DEPOSIT_ACCOUNT_CREATE,
constructEntityMap(BusinessEntity.DEPOSIT_ACCOUNT, account));
return new CommandProcessingResultBuilder() //
@@ -295,10 +294,10 @@ public class DepositApplicationProcessWritePlatformServiceJpaRepositoryImpl impl
financialYearBeginningMonth);
account.validateApplicableInterestRate();
this.savingAccountRepository.save(account);
this.businessEventNotifierService.notifyBusinessEventWasExecuted(BusinessEvents.RECURRING_DEPOSIT_ACCOUNT_CREATE,
this.businessEventNotifierService.notifyBusinessEventWasExecuted(BusinessEvent.RECURRING_DEPOSIT_ACCOUNT_CREATE,
constructEntityMap(BusinessEntity.DEPOSIT_ACCOUNT, account));
this.businessEventNotifierService.notifyBusinessEventWasExecuted(BusinessEvents.RECURRING_DEPOSIT_ACCOUNT_CREATE,
this.businessEventNotifierService.notifyBusinessEventWasExecuted(BusinessEvent.RECURRING_DEPOSIT_ACCOUNT_CREATE,
constructEntityMap(BusinessEntity.DEPOSIT_ACCOUNT, account));
return new CommandProcessingResultBuilder() //
@@ -794,9 +793,8 @@ public class DepositApplicationProcessWritePlatformServiceJpaRepositoryImpl impl
}
}
private Map<BusinessEventNotificationConstants.BusinessEntity, Object> constructEntityMap(final BusinessEntity entityEvent,
Object entity) {
Map<BusinessEventNotificationConstants.BusinessEntity, Object> map = new HashMap<>(1);
private Map<BusinessEntity, Object> constructEntityMap(final BusinessEntity entityEvent, Object entity) {
Map<BusinessEntity, Object> map = new HashMap<>(1);
map.put(entityEvent, entity);
return map;
}
@@ -79,14 +79,14 @@ import org.apache.fineract.portfolio.account.domain.StandingInstructionRepositor
import org.apache.fineract.portfolio.account.domain.StandingInstructionStatus;
import org.apache.fineract.portfolio.account.service.AccountAssociationsReadPlatformService;
import org.apache.fineract.portfolio.account.service.AccountTransfersReadPlatformService;
import org.apache.fineract.portfolio.businessevent.domain.BusinessEntity;
import org.apache.fineract.portfolio.businessevent.domain.BusinessEvent;
import org.apache.fineract.portfolio.businessevent.service.BusinessEventNotifierService;
import org.apache.fineract.portfolio.charge.domain.Charge;
import org.apache.fineract.portfolio.charge.domain.ChargeRepositoryWrapper;
import org.apache.fineract.portfolio.charge.domain.ChargeTimeType;
import org.apache.fineract.portfolio.client.domain.Client;
import org.apache.fineract.portfolio.client.exception.ClientNotActiveException;
import org.apache.fineract.portfolio.common.BusinessEventNotificationConstants.BusinessEntity;
import org.apache.fineract.portfolio.common.BusinessEventNotificationConstants.BusinessEvents;
import org.apache.fineract.portfolio.common.service.BusinessEventNotifierService;
import org.apache.fineract.portfolio.group.domain.Group;
import org.apache.fineract.portfolio.group.exception.GroupNotActiveException;
import org.apache.fineract.portfolio.note.domain.Note;
@@ -272,7 +272,7 @@ public class SavingsAccountWritePlatformServiceJpaRepositoryImpl implements Savi
}
postJournalEntries(account, existingTransactionIds, existingReversedTransactionIds, false);
this.businessEventNotifierService.notifyBusinessEventWasExecuted(BusinessEvents.SAVINGS_ACTIVATE,
this.businessEventNotifierService.notifyBusinessEventWasExecuted(BusinessEvent.SAVINGS_ACTIVATE,
constructEntityMap(BusinessEntity.SAVING, account));
return new CommandProcessingResultBuilder() //
@@ -576,7 +576,7 @@ public class SavingsAccountWritePlatformServiceJpaRepositoryImpl implements Savi
}
postInterest(account, postInterestAs, transactionDate, backdatedTxnsAllowedTill);
this.businessEventNotifierService.notifyBusinessEventWasExecuted(BusinessEvents.SAVINGS_POST_INTEREST,
this.businessEventNotifierService.notifyBusinessEventWasExecuted(BusinessEvent.SAVINGS_POST_INTEREST,
constructEntityMap(BusinessEntity.SAVING, account));
return new CommandProcessingResultBuilder() //
.withEntityId(savingsId) //
@@ -1031,7 +1031,7 @@ public class SavingsAccountWritePlatformServiceJpaRepositoryImpl implements Savi
}
this.businessEventNotifierService.notifyBusinessEventWasExecuted(BusinessEvents.SAVINGS_CLOSE,
this.businessEventNotifierService.notifyBusinessEventWasExecuted(BusinessEvent.SAVINGS_CLOSE,
constructEntityMap(BusinessEntity.SAVING, account));
// disable all standing orders linked to the savings account
this.disableStandingInstructionsLinkedToClosedSavings(account);
@@ -56,13 +56,13 @@ import org.apache.fineract.infrastructure.security.service.PlatformSecurityConte
import org.apache.fineract.organisation.monetary.domain.Money;
import org.apache.fineract.organisation.staff.domain.Staff;
import org.apache.fineract.organisation.staff.domain.StaffRepositoryWrapper;
import org.apache.fineract.portfolio.businessevent.domain.BusinessEntity;
import org.apache.fineract.portfolio.businessevent.domain.BusinessEvent;
import org.apache.fineract.portfolio.businessevent.service.BusinessEventNotifierService;
import org.apache.fineract.portfolio.client.domain.AccountNumberGenerator;
import org.apache.fineract.portfolio.client.domain.Client;
import org.apache.fineract.portfolio.client.domain.ClientRepositoryWrapper;
import org.apache.fineract.portfolio.client.exception.ClientNotActiveException;
import org.apache.fineract.portfolio.common.BusinessEventNotificationConstants.BusinessEntity;
import org.apache.fineract.portfolio.common.BusinessEventNotificationConstants.BusinessEvents;
import org.apache.fineract.portfolio.common.service.BusinessEventNotifierService;
import org.apache.fineract.portfolio.group.domain.Group;
import org.apache.fineract.portfolio.group.domain.GroupRepository;
import org.apache.fineract.portfolio.group.domain.GroupRepositoryWrapper;
@@ -305,7 +305,7 @@ public class SavingsApplicationProcessWritePlatformServiceJpaRepositoryImpl impl
this.entityDatatableChecksWritePlatformService.runTheCheckForProduct(savingsId, EntityTables.SAVING.getName(),
StatusEnum.CREATE.getCode().longValue(), EntityTables.SAVING.getForeignKeyColumnNameOnDatatable(), account.productId());
this.businessEventNotifierService.notifyBusinessEventWasExecuted(BusinessEvents.SAVINGS_CREATE,
this.businessEventNotifierService.notifyBusinessEventWasExecuted(BusinessEvent.SAVINGS_CREATE,
constructEntityMap(BusinessEntity.SAVING, account));
return new CommandProcessingResultBuilder() //
@@ -534,7 +534,7 @@ public class SavingsApplicationProcessWritePlatformServiceJpaRepositoryImpl impl
}
}
this.businessEventNotifierService.notifyBusinessEventWasExecuted(BusinessEvents.SAVINGS_APPROVE,
this.businessEventNotifierService.notifyBusinessEventWasExecuted(BusinessEvent.SAVINGS_APPROVE,
constructEntityMap(BusinessEntity.SAVING, savingsAccount));
return new CommandProcessingResultBuilder() //
@@ -657,7 +657,7 @@ public class SavingsApplicationProcessWritePlatformServiceJpaRepositoryImpl impl
this.noteRepository.save(note);
}
}
this.businessEventNotifierService.notifyBusinessEventWasExecuted(BusinessEvents.SAVINGS_REJECT,
this.businessEventNotifierService.notifyBusinessEventWasExecuted(BusinessEvent.SAVINGS_REJECT,
constructEntityMap(BusinessEntity.SAVING, savingsAccount));
return new CommandProcessingResultBuilder() //
.withCommandId(command.commandId()) //
@@ -42,11 +42,10 @@ import org.apache.fineract.infrastructure.core.service.DateUtils;
import org.apache.fineract.organisation.monetary.data.CurrencyData;
import org.apache.fineract.organisation.monetary.domain.MonetaryCurrency;
import org.apache.fineract.portfolio.accounts.constants.ShareAccountApiConstants;
import org.apache.fineract.portfolio.businessevent.domain.BusinessEntity;
import org.apache.fineract.portfolio.businessevent.domain.BusinessEvent;
import org.apache.fineract.portfolio.businessevent.service.BusinessEventNotifierService;
import org.apache.fineract.portfolio.client.domain.AccountNumberGenerator;
import org.apache.fineract.portfolio.common.BusinessEventNotificationConstants;
import org.apache.fineract.portfolio.common.BusinessEventNotificationConstants.BusinessEntity;
import org.apache.fineract.portfolio.common.BusinessEventNotificationConstants.BusinessEvents;
import org.apache.fineract.portfolio.common.service.BusinessEventNotifierService;
import org.apache.fineract.portfolio.note.domain.Note;
import org.apache.fineract.portfolio.note.domain.NoteRepository;
import org.apache.fineract.portfolio.shareaccounts.data.ShareAccountTransactionEnumData;
@@ -106,7 +105,7 @@ public class ShareAccountWritePlatformServiceJpaRepositoryImpl implements ShareA
journalEntryWritePlatformService.createJournalEntriesForShares(
populateJournalEntries(account, account.getPendingForApprovalSharePurchaseTransactions()));
this.businessEventNotifierService.notifyBusinessEventWasExecuted(BusinessEvents.SHARE_ACCOUNT_CREATE,
this.businessEventNotifierService.notifyBusinessEventWasExecuted(BusinessEvent.SHARE_ACCOUNT_CREATE,
constructEntityMap(BusinessEntity.SHARE_ACCOUNT, account));
return new CommandProcessingResultBuilder() //
@@ -283,7 +282,7 @@ public class ShareAccountWritePlatformServiceJpaRepositoryImpl implements ShareA
this.journalEntryWritePlatformService.createJournalEntriesForShares(populateJournalEntries(account, journalTransactions));
this.businessEventNotifierService.notifyBusinessEventWasExecuted(BusinessEvents.SHARE_ACCOUNT_APPROVE,
this.businessEventNotifierService.notifyBusinessEventWasExecuted(BusinessEvent.SHARE_ACCOUNT_APPROVE,
constructEntityMap(BusinessEntity.SHARE_ACCOUNT, account));
return new CommandProcessingResultBuilder() //
@@ -531,9 +530,8 @@ public class ShareAccountWritePlatformServiceJpaRepositoryImpl implements ShareA
"Unknown data integrity issue with resource.");
}
private Map<BusinessEventNotificationConstants.BusinessEntity, Object> constructEntityMap(
final BusinessEventNotificationConstants.BusinessEntity entityEvent, Object entity) {
Map<BusinessEventNotificationConstants.BusinessEntity, Object> map = new HashMap<>(1);
private Map<BusinessEntity, Object> constructEntityMap(final BusinessEntity entityEvent, Object entity) {
Map<BusinessEntity, Object> map = new HashMap<>(1);
map.put(entityEvent, entity);
return map;
}
@@ -31,10 +31,9 @@ import org.apache.fineract.infrastructure.core.data.CommandProcessingResult;
import org.apache.fineract.infrastructure.core.data.CommandProcessingResultBuilder;
import org.apache.fineract.infrastructure.core.exception.PlatformDataIntegrityException;
import org.apache.fineract.infrastructure.core.serialization.FromJsonHelper;
import org.apache.fineract.portfolio.common.BusinessEventNotificationConstants;
import org.apache.fineract.portfolio.common.BusinessEventNotificationConstants.BusinessEntity;
import org.apache.fineract.portfolio.common.BusinessEventNotificationConstants.BusinessEvents;
import org.apache.fineract.portfolio.common.service.BusinessEventNotifierService;
import org.apache.fineract.portfolio.businessevent.domain.BusinessEntity;
import org.apache.fineract.portfolio.businessevent.domain.BusinessEvent;
import org.apache.fineract.portfolio.businessevent.service.BusinessEventNotifierService;
import org.apache.fineract.portfolio.shareproducts.constants.ShareProductApiConstants;
import org.apache.fineract.portfolio.shareproducts.domain.ShareProduct;
import org.apache.fineract.portfolio.shareproducts.domain.ShareProductDividendPayOutDetails;
@@ -151,7 +150,7 @@ public class ShareProductWritePlatformServiceJpaRepositoryImpl implements ShareP
}
this.shareProductDividentPayOutDetailsRepository.save(dividendPayOutDetails);
this.businessEventNotifierService.notifyBusinessEventWasExecuted(BusinessEvents.SHARE_PRODUCT_DIVIDENDS_CREATE,
this.businessEventNotifierService.notifyBusinessEventWasExecuted(BusinessEvent.SHARE_PRODUCT_DIVIDENDS_CREATE,
constructEntityMap(BusinessEntity.SHARE_PRODUCT, productId));
return new CommandProcessingResultBuilder() //
@@ -221,9 +220,8 @@ public class ShareProductWritePlatformServiceJpaRepositoryImpl implements ShareP
"Unknown data integrity issue with resource.");
}
private Map<BusinessEventNotificationConstants.BusinessEntity, Object> constructEntityMap(
final BusinessEventNotificationConstants.BusinessEntity entityEvent, Object entity) {
Map<BusinessEventNotificationConstants.BusinessEntity, Object> map = new HashMap<>(1);
private Map<BusinessEntity, Object> constructEntityMap(final BusinessEntity entityEvent, Object entity) {
Map<BusinessEntity, Object> map = new HashMap<>(1);
map.put(entityEvent, entity);
return map;
}