Refactored business events

This commit is contained in:
Arnold Galovics
2022-06-23 13:04:43 +02:00
committed by Arnold Gálovics
parent ddc6a76689
commit cd38262152
87 changed files with 2505 additions and 1314 deletions
@@ -23,92 +23,72 @@ import com.fasterxml.jackson.databind.ObjectMapper;
import java.io.IOException; import java.io.IOException;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map;
import javax.annotation.PostConstruct; import javax.annotation.PostConstruct;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.apache.fineract.infrastructure.campaigns.email.domain.EmailCampaign; import org.apache.fineract.infrastructure.campaigns.email.domain.EmailCampaign;
import org.apache.fineract.infrastructure.campaigns.email.domain.EmailCampaignRepository; import org.apache.fineract.infrastructure.campaigns.email.domain.EmailCampaignRepository;
import org.apache.fineract.infrastructure.campaigns.sms.constants.SmsCampaignTriggerType; import org.apache.fineract.infrastructure.campaigns.sms.constants.SmsCampaignTriggerType;
import org.apache.fineract.portfolio.businessevent.BusinessEventListener; import org.apache.fineract.portfolio.businessevent.BusinessEventListener;
import org.apache.fineract.portfolio.businessevent.domain.BusinessEntity; import org.apache.fineract.portfolio.businessevent.domain.loan.LoanApprovedBusinessEvent;
import org.apache.fineract.portfolio.businessevent.domain.BusinessEvent; import org.apache.fineract.portfolio.businessevent.domain.loan.LoanRejectedBusinessEvent;
import org.apache.fineract.portfolio.businessevent.domain.loan.transaction.LoanMakeRepaymentBusinessEvent;
import org.apache.fineract.portfolio.businessevent.service.BusinessEventNotifierService; import org.apache.fineract.portfolio.businessevent.service.BusinessEventNotifierService;
import org.apache.fineract.portfolio.loanaccount.domain.Loan; import org.apache.fineract.portfolio.loanaccount.domain.Loan;
import org.apache.fineract.portfolio.loanaccount.domain.LoanTransaction; import org.apache.fineract.portfolio.loanaccount.domain.LoanTransaction;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
@Service @Service
@RequiredArgsConstructor
@Slf4j
public class EmailCampaignDomainServiceImpl implements EmailCampaignDomainService { public class EmailCampaignDomainServiceImpl implements EmailCampaignDomainService {
private static final Logger LOG = LoggerFactory.getLogger(EmailCampaignDomainServiceImpl.class);
private final BusinessEventNotifierService businessEventNotifierService; private final BusinessEventNotifierService businessEventNotifierService;
private final EmailCampaignWritePlatformService emailCampaignWritePlatformService; private final EmailCampaignWritePlatformService emailCampaignWritePlatformService;
private final EmailCampaignRepository emailCampaignRepository; private final EmailCampaignRepository emailCampaignRepository;
@Autowired
public EmailCampaignDomainServiceImpl(BusinessEventNotifierService businessEventNotifierService,
EmailCampaignWritePlatformService emailCampaignWritePlatformService, EmailCampaignRepository emailCampaignRepository) {
this.businessEventNotifierService = businessEventNotifierService;
this.emailCampaignWritePlatformService = emailCampaignWritePlatformService;
this.emailCampaignRepository = emailCampaignRepository;
}
@PostConstruct @PostConstruct
public void addListeners() { public void addListeners() {
this.businessEventNotifierService.addBusinessEventPostListeners(BusinessEvent.LOAN_APPROVED, businessEventNotifierService.addBusinessEventListener(LoanApprovedBusinessEvent.class, new SendEmailOnLoanApproved());
new EmailCampaignDomainServiceImpl.SendEmailOnLoanApproved()); businessEventNotifierService.addBusinessEventListener(LoanRejectedBusinessEvent.class, new SendEmailOnLoanRejected());
this.businessEventNotifierService.addBusinessEventPostListeners(BusinessEvent.LOAN_REJECTED, businessEventNotifierService.addBusinessEventListener(LoanMakeRepaymentBusinessEvent.class, new SendEmailOnLoanRepayment());
new EmailCampaignDomainServiceImpl.SendEmailOnLoanRejected());
this.businessEventNotifierService.addBusinessEventPostListeners(BusinessEvent.LOAN_MAKE_REPAYMENT,
new EmailCampaignDomainServiceImpl.SendEmailOnLoanRepayment());
} }
private class SendEmailOnLoanRepayment extends EmailBusinessEventAdapter { private class SendEmailOnLoanRepayment implements BusinessEventListener<LoanMakeRepaymentBusinessEvent> {
@Override @Override
public void businessEventWasExecuted(Map<BusinessEntity, Object> businessEventEntity) { public void onBusinessEvent(LoanMakeRepaymentBusinessEvent event) {
Object entity = businessEventEntity.get(BusinessEntity.LOAN_TRANSACTION); LoanTransaction loanTransaction = event.get();
if (entity instanceof LoanTransaction) { try {
LoanTransaction loanTransaction = (LoanTransaction) entity; notifyLoanOwner(loanTransaction, "Loan Repayment");
try { } catch (IOException e) {
notifyLoanOwner(loanTransaction, "Loan Repayment"); log.error("Exception when trying to send triggered email: {}", e.getMessage());
} catch (IOException e) {
LOG.error("Exception when trying to send triggered email: {}", e.getMessage());
}
} }
} }
} }
private class SendEmailOnLoanRejected extends EmailBusinessEventAdapter { private class SendEmailOnLoanRejected implements BusinessEventListener<LoanRejectedBusinessEvent> {
@Override @Override
public void businessEventWasExecuted(Map<BusinessEntity, Object> businessEventEntity) { public void onBusinessEvent(LoanRejectedBusinessEvent event) {
Object entity = businessEventEntity.get(BusinessEntity.LOAN); Loan loan = event.get();
if (entity instanceof Loan) { try {
Loan loan = (Loan) entity; notifyLoanOwner(loan, "Loan Rejected");
try { } catch (IOException e) {
notifyLoanOwner(loan, "Loan Rejected"); log.error("Exception when trying to send triggered email: {}", e.getMessage());
} catch (IOException e) {
LOG.error("Exception when trying to send triggered email: {}", e.getMessage());
}
} }
} }
} }
private class SendEmailOnLoanApproved extends EmailBusinessEventAdapter { private class SendEmailOnLoanApproved implements BusinessEventListener<LoanApprovedBusinessEvent> {
@Override @Override
public void businessEventWasExecuted(Map<BusinessEntity, Object> businessEventEntity) { public void onBusinessEvent(LoanApprovedBusinessEvent event) {
Object entity = businessEventEntity.get(BusinessEntity.LOAN); Loan loan = event.get();
if (entity instanceof Loan) { try {
Loan loan = (Loan) entity; notifyLoanOwner(loan, "Loan Approved");
try { } catch (IOException e) {
notifyLoanOwner(loan, "Loan Approved"); log.error("Exception when trying to send triggered email: {}", e.getMessage());
} catch (IOException e) {
LOG.error("Exception when trying to send triggered email: {}", e.getMessage());
}
} }
} }
} }
@@ -135,14 +115,6 @@ public class EmailCampaignDomainServiceImpl implements EmailCampaignDomainServic
} }
} }
private abstract static class EmailBusinessEventAdapter implements BusinessEventListener {
@Override
public void businessEventToBeExecuted(Map<BusinessEntity, Object> businessEventEntity) {
// Nothing to do
}
}
private List<EmailCampaign> retrieveEmailCampaigns(String paramValue) { private List<EmailCampaign> retrieveEmailCampaigns(String paramValue) {
List<EmailCampaign> emailCampaigns = emailCampaignRepository.findActiveEmailCampaigns("%" + paramValue + "%", List<EmailCampaign> emailCampaigns = emailCampaignRepository.findActiveEmailCampaigns("%" + paramValue + "%",
SmsCampaignTriggerType.TRIGGERED.getValue()); SmsCampaignTriggerType.TRIGGERED.getValue());
@@ -32,6 +32,8 @@ import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Set; import java.util.Set;
import javax.annotation.PostConstruct; import javax.annotation.PostConstruct;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.apache.fineract.infrastructure.campaigns.sms.constants.SmsCampaignTriggerType; import org.apache.fineract.infrastructure.campaigns.sms.constants.SmsCampaignTriggerType;
import org.apache.fineract.infrastructure.campaigns.sms.domain.SmsCampaign; import org.apache.fineract.infrastructure.campaigns.sms.domain.SmsCampaign;
import org.apache.fineract.infrastructure.campaigns.sms.domain.SmsCampaignRepository; import org.apache.fineract.infrastructure.campaigns.sms.domain.SmsCampaignRepository;
@@ -43,8 +45,15 @@ import org.apache.fineract.infrastructure.sms.scheduler.SmsMessageScheduledJobSe
import org.apache.fineract.organisation.office.domain.Office; import org.apache.fineract.organisation.office.domain.Office;
import org.apache.fineract.organisation.office.domain.OfficeRepository; import org.apache.fineract.organisation.office.domain.OfficeRepository;
import org.apache.fineract.portfolio.businessevent.BusinessEventListener; import org.apache.fineract.portfolio.businessevent.BusinessEventListener;
import org.apache.fineract.portfolio.businessevent.domain.BusinessEntity; import org.apache.fineract.portfolio.businessevent.domain.client.ClientActivateBusinessEvent;
import org.apache.fineract.portfolio.businessevent.domain.BusinessEvent; import org.apache.fineract.portfolio.businessevent.domain.client.ClientRejectBusinessEvent;
import org.apache.fineract.portfolio.businessevent.domain.loan.LoanApprovedBusinessEvent;
import org.apache.fineract.portfolio.businessevent.domain.loan.LoanRejectedBusinessEvent;
import org.apache.fineract.portfolio.businessevent.domain.loan.transaction.LoanMakeRepaymentBusinessEvent;
import org.apache.fineract.portfolio.businessevent.domain.savings.SavingsActivateBusinessEvent;
import org.apache.fineract.portfolio.businessevent.domain.savings.SavingsRejectBusinessEvent;
import org.apache.fineract.portfolio.businessevent.domain.savings.transaction.SavingsDepositBusinessEvent;
import org.apache.fineract.portfolio.businessevent.domain.savings.transaction.SavingsWithdrawalBusinessEvent;
import org.apache.fineract.portfolio.businessevent.service.BusinessEventNotifierService; import org.apache.fineract.portfolio.businessevent.service.BusinessEventNotifierService;
import org.apache.fineract.portfolio.client.domain.Client; import org.apache.fineract.portfolio.client.domain.Client;
import org.apache.fineract.portfolio.group.domain.Group; import org.apache.fineract.portfolio.group.domain.Group;
@@ -54,18 +63,13 @@ import org.apache.fineract.portfolio.loanaccount.domain.LoanTransaction;
import org.apache.fineract.portfolio.loanaccount.exception.InvalidLoanTypeException; import org.apache.fineract.portfolio.loanaccount.exception.InvalidLoanTypeException;
import org.apache.fineract.portfolio.savings.domain.SavingsAccount; import org.apache.fineract.portfolio.savings.domain.SavingsAccount;
import org.apache.fineract.portfolio.savings.domain.SavingsAccountTransaction; import org.apache.fineract.portfolio.savings.domain.SavingsAccountTransaction;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
@Service @Service
@Slf4j
@RequiredArgsConstructor
public class SmsCampaignDomainServiceImpl implements SmsCampaignDomainService { public class SmsCampaignDomainServiceImpl implements SmsCampaignDomainService {
private static final Logger LOG = LoggerFactory.getLogger(SmsCampaignDomainServiceImpl.class);
// private static final int POOL_SIZE = 5 ;
private final SmsCampaignRepository smsCampaignRepository; private final SmsCampaignRepository smsCampaignRepository;
private final SmsMessageRepository smsMessageRepository; private final SmsMessageRepository smsMessageRepository;
private final OfficeRepository officeRepository; private final OfficeRepository officeRepository;
@@ -76,35 +80,19 @@ public class SmsCampaignDomainServiceImpl implements SmsCampaignDomainService {
private final SmsMessageScheduledJobService smsMessageScheduledJobService; private final SmsMessageScheduledJobService smsMessageScheduledJobService;
private final SmsCampaignValidator smsCampaignValidator; private final SmsCampaignValidator smsCampaignValidator;
@Autowired
public SmsCampaignDomainServiceImpl(final SmsCampaignRepository smsCampaignRepository, final SmsMessageRepository smsMessageRepository,
final BusinessEventNotifierService businessEventNotifierService, final OfficeRepository officeRepository,
final SmsCampaignWritePlatformService smsCampaignWritePlatformCommandHandler, final GroupRepository groupRepository,
final SmsMessageScheduledJobService smsMessageScheduledJobService, final SmsCampaignValidator smsCampaignValidator) {
this.smsCampaignRepository = smsCampaignRepository;
this.smsMessageRepository = smsMessageRepository;
this.businessEventNotifierService = businessEventNotifierService;
this.officeRepository = officeRepository;
this.smsCampaignWritePlatformCommandHandler = smsCampaignWritePlatformCommandHandler;
this.groupRepository = groupRepository;
this.smsMessageScheduledJobService = smsMessageScheduledJobService;
this.smsCampaignValidator = smsCampaignValidator;
}
@PostConstruct @PostConstruct
public void addListeners() { public void addListeners() {
this.businessEventNotifierService.addBusinessEventPostListeners(BusinessEvent.LOAN_APPROVED, new SendSmsOnLoanApproved()); businessEventNotifierService.addBusinessEventListener(LoanApprovedBusinessEvent.class, new SendSmsOnLoanApproved());
this.businessEventNotifierService.addBusinessEventPostListeners(BusinessEvent.LOAN_REJECTED, new SendSmsOnLoanRejected()); businessEventNotifierService.addBusinessEventListener(LoanRejectedBusinessEvent.class, new SendSmsOnLoanRejected());
this.businessEventNotifierService.addBusinessEventPostListeners(BusinessEvent.LOAN_MAKE_REPAYMENT, new SendSmsOnLoanRepayment()); businessEventNotifierService.addBusinessEventListener(LoanMakeRepaymentBusinessEvent.class, new SendSmsOnLoanRepayment());
this.businessEventNotifierService.addBusinessEventPostListeners(BusinessEvent.CLIENTS_ACTIVATE, new ClientActivatedListener()); businessEventNotifierService.addBusinessEventListener(ClientActivateBusinessEvent.class, new ClientActivatedListener());
this.businessEventNotifierService.addBusinessEventPostListeners(BusinessEvent.CLIENTS_REJECT, new ClientRejectedListener()); businessEventNotifierService.addBusinessEventListener(ClientRejectBusinessEvent.class, new ClientRejectedListener());
this.businessEventNotifierService.addBusinessEventPostListeners(BusinessEvent.SAVINGS_ACTIVATE, businessEventNotifierService.addBusinessEventListener(SavingsActivateBusinessEvent.class, new SavingsAccountActivatedListener());
new SavingsAccountActivatedListener()); businessEventNotifierService.addBusinessEventListener(SavingsRejectBusinessEvent.class, new SavingsAccountRejectedListener());
this.businessEventNotifierService.addBusinessEventPostListeners(BusinessEvent.SAVINGS_REJECT, new SavingsAccountRejectedListener()); businessEventNotifierService.addBusinessEventListener(SavingsDepositBusinessEvent.class,
this.businessEventNotifierService.addBusinessEventPostListeners(BusinessEvent.SAVINGS_DEPOSIT, new DepositSavingsAccountTransactionListener());
new SavingsAccountTransactionListener(true)); businessEventNotifierService.addBusinessEventListener(SavingsWithdrawalBusinessEvent.class,
this.businessEventNotifierService.addBusinessEventPostListeners(BusinessEvent.SAVINGS_WITHDRAWAL, new NonDepositSavingsAccountTransactionListener());
new SavingsAccountTransactionListener(false));
} }
private void notifyRejectedLoanOwner(Loan loan) { private void notifyRejectedLoanOwner(Loan loan) {
@@ -227,9 +215,9 @@ public class SmsCampaignDomainServiceImpl implements SmsCampaignDomainService {
} }
} }
} catch (final IOException e) { } catch (final IOException e) {
LOG.error("smsParams does not contain the key: ", e); log.error("smsParams does not contain the key: ", e);
} catch (final RuntimeException e) { } catch (final RuntimeException e) {
LOG.debug("Client Office Id and SMS Campaign Office id doesn't match ", e); log.debug("Client Office Id and SMS Campaign Office id doesn't match ", e);
} }
} }
} }
@@ -282,9 +270,9 @@ public class SmsCampaignDomainServiceImpl implements SmsCampaignDomainService {
this.smsMessageScheduledJobService.sendTriggeredMessages(smsDataMap); this.smsMessageScheduledJobService.sendTriggeredMessages(smsDataMap);
} }
} catch (final IOException e) { } catch (final IOException e) {
LOG.error("smsParams does not contain the key: ", e); log.error("smsParams does not contain the key: ", e);
} catch (final RuntimeException e) { } catch (final RuntimeException e) {
LOG.debug("Client Office Id and SMS Campaign Office id doesn't match ", e); log.debug("Client Office Id and SMS Campaign Office id doesn't match ", e);
} }
} }
} }
@@ -382,123 +370,77 @@ public class SmsCampaignDomainServiceImpl implements SmsCampaignDomainService {
return smsParams; return smsParams;
} }
private abstract static class SmsBusinessEventAdapter implements BusinessEventListener { private class SendSmsOnLoanApproved implements BusinessEventListener<LoanApprovedBusinessEvent> {
@Override @Override
public void businessEventToBeExecuted(Map<BusinessEntity, Object> businessEventEntity) { public void onBusinessEvent(LoanApprovedBusinessEvent event) {
// Nothing to do Loan loan = event.get();
notifyAcceptedLoanOwner(loan);
} }
} }
private class SendSmsOnLoanApproved extends SmsBusinessEventAdapter { private class SendSmsOnLoanRejected implements BusinessEventListener<LoanRejectedBusinessEvent> {
@Override @Override
public void businessEventWasExecuted(Map<BusinessEntity, Object> businessEventEntity) { public void onBusinessEvent(LoanRejectedBusinessEvent event) {
Object entity = businessEventEntity.get(BusinessEntity.LOAN); Loan loan = event.get();
if (entity instanceof Loan) { notifyRejectedLoanOwner(loan);
Loan loan = (Loan) entity;
notifyAcceptedLoanOwner(loan);
}
} }
} }
private class SendSmsOnLoanRejected extends SmsBusinessEventAdapter { private class SendSmsOnLoanRepayment implements BusinessEventListener<LoanMakeRepaymentBusinessEvent> {
@Override @Override
public void businessEventWasExecuted(Map<BusinessEntity, Object> businessEventEntity) { public void onBusinessEvent(LoanMakeRepaymentBusinessEvent event) {
Object entity = businessEventEntity.get(BusinessEntity.LOAN); sendSmsForLoanRepayment(event.get());
if (entity instanceof Loan) {
Loan loan = (Loan) entity;
notifyRejectedLoanOwner(loan);
}
} }
} }
private class SendSmsOnLoanRepayment extends SmsBusinessEventAdapter { private class ClientActivatedListener implements BusinessEventListener<ClientActivateBusinessEvent> {
@Override @Override
public void businessEventWasExecuted(Map<BusinessEntity, Object> businessEventEntity) { public void onBusinessEvent(ClientActivateBusinessEvent event) {
Object entity = businessEventEntity.get(BusinessEntity.LOAN_TRANSACTION); notifyClientActivated(event.get());
if (entity instanceof LoanTransaction) {
LoanTransaction loanTransaction = (LoanTransaction) entity;
sendSmsForLoanRepayment(loanTransaction);
}
} }
} }
private class ClientActivatedListener extends SmsBusinessEventAdapter { private class ClientRejectedListener implements BusinessEventListener<ClientRejectBusinessEvent> {
@Override @Override
public void businessEventWasExecuted(Map<BusinessEntity, Object> businessEventEntity) { public void onBusinessEvent(ClientRejectBusinessEvent event) {
Object entity = businessEventEntity.get(BusinessEntity.CLIENT); notifyClientRejected(event.get());
if (entity instanceof Client) {
notifyClientActivated((Client) entity);
}
} }
} }
private class ClientRejectedListener extends SmsBusinessEventAdapter { private class SavingsAccountActivatedListener implements BusinessEventListener<SavingsActivateBusinessEvent> {
@Override @Override
public void businessEventWasExecuted(Map<BusinessEntity, Object> businessEventEntity) { public void onBusinessEvent(SavingsActivateBusinessEvent event) {
Object entity = businessEventEntity.get(BusinessEntity.CLIENT); notifySavingsAccountActivated(event.get());
if (entity instanceof Client) {
notifyClientRejected((Client) entity);
}
} }
} }
private class SavingsAccountActivatedListener extends SmsBusinessEventAdapter { private class SavingsAccountRejectedListener implements BusinessEventListener<SavingsRejectBusinessEvent> {
@Override @Override
public void businessEventWasExecuted(Map<BusinessEntity, Object> businessEventEntity) { public void onBusinessEvent(SavingsRejectBusinessEvent event) {
Object entity = businessEventEntity.get(BusinessEntity.SAVING); notifySavingsAccountRejected(event.get());
if (entity instanceof SavingsAccount) {
notifySavingsAccountActivated((SavingsAccount) entity);
}
} }
} }
private class SavingsAccountRejectedListener extends SmsBusinessEventAdapter { private class DepositSavingsAccountTransactionListener implements BusinessEventListener<SavingsDepositBusinessEvent> {
@Override @Override
public void businessEventWasExecuted(Map<BusinessEntity, Object> businessEventEntity) { public void onBusinessEvent(SavingsDepositBusinessEvent event) {
Object entity = businessEventEntity.get(BusinessEntity.SAVING); sendSmsForSavingsTransaction(event.get(), true);
if (entity instanceof SavingsAccount) {
notifySavingsAccountRejected((SavingsAccount) entity);
}
} }
} }
private class SavingsAccountTransactionListener extends SmsBusinessEventAdapter { private class NonDepositSavingsAccountTransactionListener implements BusinessEventListener<SavingsWithdrawalBusinessEvent> {
final boolean isDeposit;
SavingsAccountTransactionListener(final boolean isDeposit) {
this.isDeposit = isDeposit;
}
@Override @Override
public void businessEventWasExecuted(Map<BusinessEntity, Object> businessEventEntity) { public void onBusinessEvent(SavingsWithdrawalBusinessEvent event) {
Object entity = businessEventEntity.get(BusinessEntity.SAVINGS_TRANSACTION); sendSmsForSavingsTransaction(event.get(), false);
if (entity instanceof SavingsAccountTransaction) {
sendSmsForSavingsTransaction((SavingsAccountTransaction) entity, this.isDeposit);
}
} }
} }
/*
* private abstract class Task implements Runnable {
*
* protected final FineractPlatformTenant tenant;
*
* protected final String reportName ;
*
* private final Object entity ;
*
* public Task(final FineractPlatformTenant tenant, final String reportName, final Object entity) { this.tenant =
* tenant; this.reportName = reportName ; this.entity = entity ; } }
*/
} }
@@ -21,7 +21,6 @@ package org.apache.fineract.notification.service;
import static java.util.stream.Collectors.toSet; import static java.util.stream.Collectors.toSet;
import java.util.Collection; import java.util.Collection;
import java.util.Map;
import java.util.Set; import java.util.Set;
import javax.annotation.PostConstruct; import javax.annotation.PostConstruct;
import lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;
@@ -32,8 +31,25 @@ import org.apache.fineract.infrastructure.security.service.PlatformSecurityConte
import org.apache.fineract.notification.data.NotificationData; import org.apache.fineract.notification.data.NotificationData;
import org.apache.fineract.notification.eventandlistener.NotificationEventPublisher; import org.apache.fineract.notification.eventandlistener.NotificationEventPublisher;
import org.apache.fineract.portfolio.businessevent.BusinessEventListener; import org.apache.fineract.portfolio.businessevent.BusinessEventListener;
import org.apache.fineract.portfolio.businessevent.domain.BusinessEntity; import org.apache.fineract.portfolio.businessevent.domain.client.ClientCreateBusinessEvent;
import org.apache.fineract.portfolio.businessevent.domain.BusinessEvent; import org.apache.fineract.portfolio.businessevent.domain.deposit.FixedDepositAccountCreateBusinessEvent;
import org.apache.fineract.portfolio.businessevent.domain.deposit.RecurringDepositAccountCreateBusinessEvent;
import org.apache.fineract.portfolio.businessevent.domain.group.CentersCreateBusinessEvent;
import org.apache.fineract.portfolio.businessevent.domain.group.GroupsCreateBusinessEvent;
import org.apache.fineract.portfolio.businessevent.domain.loan.LoanApprovedBusinessEvent;
import org.apache.fineract.portfolio.businessevent.domain.loan.LoanCloseAsRescheduleBusinessEvent;
import org.apache.fineract.portfolio.businessevent.domain.loan.LoanCloseBusinessEvent;
import org.apache.fineract.portfolio.businessevent.domain.loan.LoanCreatedBusinessEvent;
import org.apache.fineract.portfolio.businessevent.domain.loan.product.LoanProductCreateBusinessEvent;
import org.apache.fineract.portfolio.businessevent.domain.loan.transaction.LoanMakeRepaymentBusinessEvent;
import org.apache.fineract.portfolio.businessevent.domain.savings.SavingsApproveBusinessEvent;
import org.apache.fineract.portfolio.businessevent.domain.savings.SavingsCloseBusinessEvent;
import org.apache.fineract.portfolio.businessevent.domain.savings.SavingsCreateBusinessEvent;
import org.apache.fineract.portfolio.businessevent.domain.savings.SavingsPostInterestBusinessEvent;
import org.apache.fineract.portfolio.businessevent.domain.savings.transaction.SavingsDepositBusinessEvent;
import org.apache.fineract.portfolio.businessevent.domain.share.ShareAccountApproveBusinessEvent;
import org.apache.fineract.portfolio.businessevent.domain.share.ShareAccountCreateBusinessEvent;
import org.apache.fineract.portfolio.businessevent.domain.share.ShareProductDividentsCreateBusinessEvent;
import org.apache.fineract.portfolio.businessevent.service.BusinessEventNotifierService; import org.apache.fineract.portfolio.businessevent.service.BusinessEventNotifierService;
import org.apache.fineract.portfolio.client.domain.Client; import org.apache.fineract.portfolio.client.domain.Client;
import org.apache.fineract.portfolio.loanaccount.domain.Loan; import org.apache.fineract.portfolio.loanaccount.domain.Loan;
@@ -60,318 +76,231 @@ public class NotificationDomainServiceImpl implements NotificationDomainService
@PostConstruct @PostConstruct
public void addListeners() { public void addListeners() {
businessEventNotifierService.addBusinessEventPostListeners(BusinessEvent.CLIENTS_CREATE, new ClientCreatedListener()); businessEventNotifierService.addBusinessEventListener(ClientCreateBusinessEvent.class, new ClientCreatedListener());
businessEventNotifierService.addBusinessEventPostListeners(BusinessEvent.SAVINGS_APPROVE, new SavingsAccountApprovedListener()); businessEventNotifierService.addBusinessEventListener(SavingsApproveBusinessEvent.class, new SavingsAccountApprovedListener());
businessEventNotifierService.addBusinessEventPostListeners(BusinessEvent.CENTERS_CREATE, new CenterCreatedListener()); businessEventNotifierService.addBusinessEventListener(CentersCreateBusinessEvent.class, new CenterCreatedListener());
businessEventNotifierService.addBusinessEventPostListeners(BusinessEvent.GROUPS_CREATE, new GroupCreatedListener()); businessEventNotifierService.addBusinessEventListener(GroupsCreateBusinessEvent.class, new GroupCreatedListener());
businessEventNotifierService.addBusinessEventPostListeners(BusinessEvent.SAVINGS_DEPOSIT, new SavingsAccountDepositListener()); businessEventNotifierService.addBusinessEventListener(SavingsDepositBusinessEvent.class, new SavingsAccountDepositListener());
businessEventNotifierService.addBusinessEventPostListeners(BusinessEvent.SHARE_PRODUCT_DIVIDENDS_CREATE, businessEventNotifierService.addBusinessEventListener(ShareProductDividentsCreateBusinessEvent.class,
new ShareProductDividendCreatedListener()); new ShareProductDividendCreatedListener());
businessEventNotifierService.addBusinessEventPostListeners(BusinessEvent.FIXED_DEPOSIT_ACCOUNT_CREATE, businessEventNotifierService.addBusinessEventListener(FixedDepositAccountCreateBusinessEvent.class,
new FixedDepositAccountCreatedListener()); new FixedDepositAccountCreatedListener());
businessEventNotifierService.addBusinessEventPostListeners(BusinessEvent.RECURRING_DEPOSIT_ACCOUNT_CREATE, businessEventNotifierService.addBusinessEventListener(RecurringDepositAccountCreateBusinessEvent.class,
new RecurringDepositAccountCreatedListener()); new RecurringDepositAccountCreatedListener());
businessEventNotifierService.addBusinessEventPostListeners(BusinessEvent.SAVINGS_POST_INTEREST, new SavingsPostInterestListener()); businessEventNotifierService.addBusinessEventListener(SavingsPostInterestBusinessEvent.class, new SavingsPostInterestListener());
businessEventNotifierService.addBusinessEventPostListeners(BusinessEvent.LOAN_CREATE, new LoanCreatedListener()); businessEventNotifierService.addBusinessEventListener(LoanCreatedBusinessEvent.class, new LoanCreatedListener());
businessEventNotifierService.addBusinessEventPostListeners(BusinessEvent.LOAN_APPROVED, new LoanApprovedListener()); businessEventNotifierService.addBusinessEventListener(LoanApprovedBusinessEvent.class, new LoanApprovedListener());
businessEventNotifierService.addBusinessEventPostListeners(BusinessEvent.LOAN_CLOSE, new LoanClosedListener()); businessEventNotifierService.addBusinessEventListener(LoanCloseBusinessEvent.class, new LoanClosedListener());
businessEventNotifierService.addBusinessEventPostListeners(BusinessEvent.LOAN_CLOSE_AS_RESCHEDULE, businessEventNotifierService.addBusinessEventListener(LoanCloseAsRescheduleBusinessEvent.class,
new LoanCloseAsRescheduledListener()); new LoanCloseAsRescheduledListener());
businessEventNotifierService.addBusinessEventPostListeners(BusinessEvent.LOAN_MAKE_REPAYMENT, new LoanMakeRepaymentListener()); businessEventNotifierService.addBusinessEventListener(LoanMakeRepaymentBusinessEvent.class, new LoanMakeRepaymentListener());
businessEventNotifierService.addBusinessEventPostListeners(BusinessEvent.LOAN_PRODUCT_CREATE, new LoanProductCreatedListener()); businessEventNotifierService.addBusinessEventListener(LoanProductCreateBusinessEvent.class, new LoanProductCreatedListener());
businessEventNotifierService.addBusinessEventPostListeners(BusinessEvent.SAVINGS_CREATE, new SavingsAccountCreatedListener()); businessEventNotifierService.addBusinessEventListener(SavingsCreateBusinessEvent.class, new SavingsAccountCreatedListener());
businessEventNotifierService.addBusinessEventPostListeners(BusinessEvent.SAVINGS_CLOSE, new SavingsAccountClosedListener()); businessEventNotifierService.addBusinessEventListener(SavingsCloseBusinessEvent.class, new SavingsAccountClosedListener());
businessEventNotifierService.addBusinessEventPostListeners(BusinessEvent.SHARE_ACCOUNT_CREATE, new ShareAccountCreatedListener()); businessEventNotifierService.addBusinessEventListener(ShareAccountCreateBusinessEvent.class, new ShareAccountCreatedListener());
businessEventNotifierService.addBusinessEventPostListeners(BusinessEvent.SHARE_ACCOUNT_APPROVE, new ShareAccountApprovedListener()); businessEventNotifierService.addBusinessEventListener(ShareAccountApproveBusinessEvent.class, new ShareAccountApprovedListener());
} }
private abstract static class NotificationBusinessEventAdapter implements BusinessEventListener { private class ClientCreatedListener implements BusinessEventListener<ClientCreateBusinessEvent> {
@Override @Override
public void businessEventToBeExecuted(Map<BusinessEntity, Object> businessEventEntity) {} public void onBusinessEvent(ClientCreateBusinessEvent event) {
Client client = event.get();
buildNotification("ACTIVATE_CLIENT", "client", client.getId(), "New client created", "created",
context.authenticatedUser().getId(), client.getOffice().getId());
}
} }
private class ClientCreatedListener extends NotificationBusinessEventAdapter { private class CenterCreatedListener implements BusinessEventListener<CentersCreateBusinessEvent> {
@Override @Override
public void businessEventWasExecuted(Map<BusinessEntity, Object> businessEventEntity) { public void onBusinessEvent(CentersCreateBusinessEvent event) {
Client client; CommandProcessingResult commandProcessingResult = event.get();
Object entity = businessEventEntity.get(BusinessEntity.CLIENT); buildNotification("ACTIVATE_CENTER", "center", commandProcessingResult.getGroupId(), "New center created", "created",
if (entity != null) { context.authenticatedUser().getId(), commandProcessingResult.getOfficeId());
client = (Client) entity; }
buildNotification("ACTIVATE_CLIENT", "client", client.getId(), "New client created", "created", }
context.authenticatedUser().getId(), client.getOffice().getId());
private class GroupCreatedListener implements BusinessEventListener<GroupsCreateBusinessEvent> {
@Override
public void onBusinessEvent(GroupsCreateBusinessEvent event) {
CommandProcessingResult commandProcessingResult = event.get();
buildNotification("ACTIVATE_GROUP", "group", commandProcessingResult.getGroupId(), "New group created", "created",
context.authenticatedUser().getId(), commandProcessingResult.getOfficeId());
}
}
private class SavingsAccountDepositListener implements BusinessEventListener<SavingsDepositBusinessEvent> {
@Override
public void onBusinessEvent(SavingsDepositBusinessEvent event) {
SavingsAccountTransaction savingsAccountTransaction = event.get();
buildNotification("READ_SAVINGSACCOUNT", "savingsAccount", savingsAccountTransaction.getSavingsAccount().getId(),
"Deposit made", "depositMade", context.authenticatedUser().getId(),
savingsAccountTransaction.getSavingsAccount().officeId());
}
}
private class ShareProductDividendCreatedListener implements BusinessEventListener<ShareProductDividentsCreateBusinessEvent> {
@Override
public void onBusinessEvent(ShareProductDividentsCreateBusinessEvent event) {
Long shareProductId = event.get();
buildNotification("READ_DIVIDEND_SHAREPRODUCT", "shareProduct", shareProductId, "Dividend posted to account", "dividendPosted",
context.authenticatedUser().getId(), context.authenticatedUser().getOffice().getId());
}
}
private class FixedDepositAccountCreatedListener implements BusinessEventListener<FixedDepositAccountCreateBusinessEvent> {
@Override
public void onBusinessEvent(FixedDepositAccountCreateBusinessEvent event) {
FixedDepositAccount fixedDepositAccount = event.get();
buildNotification("APPROVE_FIXEDDEPOSITACCOUNT", "fixedDeposit", fixedDepositAccount.getId(),
"New fixed deposit account created", "created", context.authenticatedUser().getId(), fixedDepositAccount.officeId());
}
}
private class RecurringDepositAccountCreatedListener implements BusinessEventListener<RecurringDepositAccountCreateBusinessEvent> {
@Override
public void onBusinessEvent(RecurringDepositAccountCreateBusinessEvent event) {
RecurringDepositAccount recurringDepositAccount = event.get();
buildNotification("APPROVE_RECURRINGDEPOSITACCOUNT", "recurringDepositAccount", recurringDepositAccount.getId(),
"New recurring deposit account created", "created", context.authenticatedUser().getId(),
recurringDepositAccount.officeId());
}
}
private class SavingsAccountApprovedListener implements BusinessEventListener<SavingsApproveBusinessEvent> {
@Override
public void onBusinessEvent(SavingsApproveBusinessEvent event) {
SavingsAccount savingsAccount = event.get();
if (savingsAccount.depositAccountType().equals(DepositAccountType.FIXED_DEPOSIT)) {
buildNotification("ACTIVATE_FIXEDDEPOSITACCOUNT", "fixedDeposit", savingsAccount.getId(), "Fixed deposit account approved",
"approved", context.authenticatedUser().getId(), savingsAccount.officeId());
} else if (savingsAccount.depositAccountType().equals(DepositAccountType.RECURRING_DEPOSIT)) {
buildNotification("ACTIVATE_RECURRINGDEPOSITACCOUNT", "recurringDepositAccount", savingsAccount.getId(),
"Recurring deposit account approved", "approved", context.authenticatedUser().getId(), savingsAccount.officeId());
} else if (savingsAccount.depositAccountType().equals(DepositAccountType.SAVINGS_DEPOSIT)) {
buildNotification("ACTIVATE_SAVINGSACCOUNT", "savingsAccount", savingsAccount.getId(), "Savings account approved",
"approved", context.authenticatedUser().getId(), savingsAccount.officeId());
} }
} }
} }
private class CenterCreatedListener extends NotificationBusinessEventAdapter { private class SavingsPostInterestListener implements BusinessEventListener<SavingsPostInterestBusinessEvent> {
@Override @Override
public void businessEventWasExecuted(Map<BusinessEntity, Object> businessEventEntity) { public void onBusinessEvent(SavingsPostInterestBusinessEvent event) {
CommandProcessingResult commandProcessingResult; SavingsAccount savingsAccount = event.get();
Object entity = businessEventEntity.get(BusinessEntity.GROUP); buildNotification("READ_SAVINGSACCOUNT", "savingsAccount", savingsAccount.getId(), "Interest posted to account",
if (entity != null) { "interestPosted", context.authenticatedUser().getId(), savingsAccount.officeId());
commandProcessingResult = (CommandProcessingResult) entity;
buildNotification("ACTIVATE_CENTER", "center", commandProcessingResult.getGroupId(), "New center created", "created",
context.authenticatedUser().getId(), commandProcessingResult.getOfficeId());
}
} }
} }
private class GroupCreatedListener extends NotificationBusinessEventAdapter { private class LoanCreatedListener implements BusinessEventListener<LoanCreatedBusinessEvent> {
@Override @Override
public void businessEventWasExecuted(Map<BusinessEntity, Object> businessEventEntity) { public void onBusinessEvent(LoanCreatedBusinessEvent event) {
CommandProcessingResult commandProcessingResult; Loan loan = event.get();
Object entity = businessEventEntity.get(BusinessEntity.GROUP); buildNotification("APPROVE_LOAN", "loan", loan.getId(), "New loan created", "created", context.authenticatedUser().getId(),
if (entity != null) { loan.getOfficeId());
commandProcessingResult = (CommandProcessingResult) entity;
buildNotification("ACTIVATE_GROUP", "group", commandProcessingResult.getGroupId(), "New group created", "created",
context.authenticatedUser().getId(), commandProcessingResult.getOfficeId());
}
} }
} }
private class SavingsAccountDepositListener extends NotificationBusinessEventAdapter { private class LoanApprovedListener implements BusinessEventListener<LoanApprovedBusinessEvent> {
@Override @Override
public void businessEventWasExecuted(Map<BusinessEntity, Object> businessEventEntity) { public void onBusinessEvent(LoanApprovedBusinessEvent event) {
SavingsAccountTransaction savingsAccountTransaction; Loan loan = event.get();
Object entity = businessEventEntity.get(BusinessEntity.SAVINGS_TRANSACTION); buildNotification("DISBURSE_LOAN", "loan", loan.getId(), "New loan approved", "approved", context.authenticatedUser().getId(),
if (entity != null) { loan.getOfficeId());
savingsAccountTransaction = (SavingsAccountTransaction) entity;
buildNotification("READ_SAVINGSACCOUNT", "savingsAccount", savingsAccountTransaction.getSavingsAccount().getId(),
"Deposit made", "depositMade", context.authenticatedUser().getId(),
savingsAccountTransaction.getSavingsAccount().officeId());
}
} }
} }
private class ShareProductDividendCreatedListener extends NotificationBusinessEventAdapter { private class LoanClosedListener implements BusinessEventListener<LoanCloseBusinessEvent> {
@Override @Override
public void businessEventWasExecuted(Map<BusinessEntity, Object> businessEventEntity) { public void onBusinessEvent(LoanCloseBusinessEvent event) {
Long shareProductId; Loan loan = event.get();
Object entity = businessEventEntity.get(BusinessEntity.SHARE_PRODUCT); buildNotification("READ_LOAN", "loan", loan.getId(), "Loan closed", "loanClosed", context.authenticatedUser().getId(),
if (entity != null) { loan.getOfficeId());
shareProductId = (Long) entity;
buildNotification("READ_DIVIDEND_SHAREPRODUCT", "shareProduct", shareProductId, "Dividend posted to account",
"dividendPosted", context.authenticatedUser().getId(), context.authenticatedUser().getOffice().getId());
}
} }
} }
private class FixedDepositAccountCreatedListener extends NotificationBusinessEventAdapter { private class LoanCloseAsRescheduledListener implements BusinessEventListener<LoanCloseAsRescheduleBusinessEvent> {
@Override @Override
public void businessEventWasExecuted(Map<BusinessEntity, Object> businessEventEntity) { public void onBusinessEvent(LoanCloseAsRescheduleBusinessEvent event) {
FixedDepositAccount fixedDepositAccount; Loan loan = event.get();
Object entity = businessEventEntity.get(BusinessEntity.DEPOSIT_ACCOUNT); buildNotification("READ_Rescheduled Loans", "loan", loan.getId(), "Loan has been rescheduled", "loanRescheduled",
if (entity != null) { context.authenticatedUser().getId(), loan.getOfficeId());
fixedDepositAccount = (FixedDepositAccount) entity;
buildNotification("APPROVE_FIXEDDEPOSITACCOUNT", "fixedDeposit", fixedDepositAccount.getId(),
"New fixed deposit account created", "created", context.authenticatedUser().getId(),
fixedDepositAccount.officeId());
}
} }
} }
private class RecurringDepositAccountCreatedListener extends NotificationBusinessEventAdapter { private class LoanMakeRepaymentListener implements BusinessEventListener<LoanMakeRepaymentBusinessEvent> {
@Override @Override
public void businessEventWasExecuted(Map<BusinessEntity, Object> businessEventEntity) { public void onBusinessEvent(LoanMakeRepaymentBusinessEvent event) {
RecurringDepositAccount recurringDepositAccount; Loan loan = event.get().getLoan();
Object entity = businessEventEntity.get(BusinessEntity.DEPOSIT_ACCOUNT); buildNotification("READ_LOAN", "loan", loan.getId(), "Repayment made", "repaymentMade", context.authenticatedUser().getId(),
if (entity != null) { loan.getOfficeId());
recurringDepositAccount = (RecurringDepositAccount) entity;
buildNotification("APPROVE_RECURRINGDEPOSITACCOUNT", "recurringDepositAccount", recurringDepositAccount.getId(),
"New recurring deposit account created", "created", context.authenticatedUser().getId(),
recurringDepositAccount.officeId());
}
} }
} }
private class SavingsAccountApprovedListener extends NotificationBusinessEventAdapter { private class LoanProductCreatedListener implements BusinessEventListener<LoanProductCreateBusinessEvent> {
@Override @Override
public void businessEventWasExecuted(Map<BusinessEntity, Object> businessEventEntity) { public void onBusinessEvent(LoanProductCreateBusinessEvent event) {
SavingsAccount savingsAccount; LoanProduct loanProduct = event.get();
Object entity = businessEventEntity.get(BusinessEntity.SAVING); buildNotification("READ_LOANPRODUCT", "loanProduct", loanProduct.getId(), "New loan product created", "created",
if (entity != null) { context.authenticatedUser().getId(), context.authenticatedUser().getOffice().getId());
savingsAccount = (SavingsAccount) entity;
if (savingsAccount.depositAccountType().equals(DepositAccountType.FIXED_DEPOSIT)) {
buildNotification("ACTIVATE_FIXEDDEPOSITACCOUNT", "fixedDeposit", savingsAccount.getId(),
"Fixed deposit account approved", "approved", context.authenticatedUser().getId(), savingsAccount.officeId());
} else if (savingsAccount.depositAccountType().equals(DepositAccountType.RECURRING_DEPOSIT)) {
buildNotification("ACTIVATE_RECURRINGDEPOSITACCOUNT", "recurringDepositAccount", savingsAccount.getId(),
"Recurring deposit account approved", "approved", context.authenticatedUser().getId(),
savingsAccount.officeId());
} else if (savingsAccount.depositAccountType().equals(DepositAccountType.SAVINGS_DEPOSIT)) {
buildNotification("ACTIVATE_SAVINGSACCOUNT", "savingsAccount", savingsAccount.getId(), "Savings account approved",
"approved", context.authenticatedUser().getId(), savingsAccount.officeId());
}
}
} }
} }
private class SavingsPostInterestListener extends NotificationBusinessEventAdapter { private class SavingsAccountCreatedListener implements BusinessEventListener<SavingsCreateBusinessEvent> {
@Override @Override
public void businessEventWasExecuted(Map<BusinessEntity, Object> businessEventEntity) { public void onBusinessEvent(SavingsCreateBusinessEvent event) {
SavingsAccount savingsAccount; SavingsAccount savingsAccount = event.get();
Object entity = businessEventEntity.get(BusinessEntity.SAVING); buildNotification("APPROVE_SAVINGSACCOUNT", "savingsAccount", savingsAccount.getId(), "New savings account created", "created",
if (entity != null) { context.authenticatedUser().getId(), savingsAccount.officeId());
savingsAccount = (SavingsAccount) entity;
buildNotification("READ_SAVINGSACCOUNT", "savingsAccount", savingsAccount.getId(), "Interest posted to account",
"interestPosted", context.authenticatedUser().getId(), savingsAccount.officeId());
}
} }
} }
private class LoanCreatedListener extends NotificationBusinessEventAdapter { private class SavingsAccountClosedListener implements BusinessEventListener<SavingsCloseBusinessEvent> {
@Override @Override
public void businessEventWasExecuted(Map<BusinessEntity, Object> businessEventEntity) { public void onBusinessEvent(SavingsCloseBusinessEvent event) {
Loan loan; SavingsAccount savingsAccount = event.get();
Object entity = businessEventEntity.get(BusinessEntity.LOAN); buildNotification("READ_SAVINGSACCOUNT", "savingsAccount", savingsAccount.getId(), "Savings has gone into dormant", "closed",
if (entity != null) { context.authenticatedUser().getId(), savingsAccount.officeId());
loan = (Loan) entity;
buildNotification("APPROVE_LOAN", "loan", loan.getId(), "New loan created", "created", context.authenticatedUser().getId(),
loan.getOfficeId());
}
} }
} }
private class LoanApprovedListener extends NotificationBusinessEventAdapter { private class ShareAccountCreatedListener implements BusinessEventListener<ShareAccountCreateBusinessEvent> {
@Override @Override
public void businessEventWasExecuted(Map<BusinessEntity, Object> businessEventEntity) { public void onBusinessEvent(ShareAccountCreateBusinessEvent event) {
Loan loan; ShareAccount shareAccount = event.get();
Object entity = businessEventEntity.get(BusinessEntity.LOAN); buildNotification("APPROVE_SHAREACCOUNT", "shareAccount", shareAccount.getId(), "New share account created", "created",
if (entity != null) { context.authenticatedUser().getId(), shareAccount.getOfficeId());
loan = (Loan) entity;
buildNotification("DISBURSE_LOAN", "loan", loan.getId(), "New loan approved", "approved",
context.authenticatedUser().getId(), loan.getOfficeId());
}
} }
} }
private class LoanClosedListener extends NotificationBusinessEventAdapter { private class ShareAccountApprovedListener implements BusinessEventListener<ShareAccountApproveBusinessEvent> {
@Override @Override
public void businessEventWasExecuted(Map<BusinessEntity, Object> businessEventEntity) { public void onBusinessEvent(ShareAccountApproveBusinessEvent event) {
ShareAccount shareAccount = event.get();
Loan loan; buildNotification("ACTIVATE_SHAREACCOUNT", "shareAccount", shareAccount.getId(), "Share account approved", "approved",
Object entity = businessEventEntity.get(BusinessEntity.LOAN); context.authenticatedUser().getId(), shareAccount.getOfficeId());
if (entity != null) {
loan = (Loan) entity;
buildNotification("READ_LOAN", "loan", loan.getId(), "Loan closed", "loanClosed", context.authenticatedUser().getId(),
loan.getOfficeId());
}
}
}
private class LoanCloseAsRescheduledListener extends NotificationBusinessEventAdapter {
@Override
public void businessEventWasExecuted(Map<BusinessEntity, Object> businessEventEntity) {
Loan loan;
Object entity = businessEventEntity.get(BusinessEntity.LOAN);
if (entity != null) {
loan = (Loan) entity;
buildNotification("READ_Rescheduled Loans", "loan", loan.getId(), "Loan has been rescheduled", "loanRescheduled",
context.authenticatedUser().getId(), loan.getOfficeId());
}
}
}
private class LoanMakeRepaymentListener extends NotificationBusinessEventAdapter {
@Override
public void businessEventWasExecuted(Map<BusinessEntity, Object> businessEventEntity) {
Loan loan;
Object entity = businessEventEntity.get(BusinessEntity.LOAN);
if (entity != null) {
loan = (Loan) entity;
buildNotification("READ_LOAN", "loan", loan.getId(), "Repayment made", "repaymentMade", context.authenticatedUser().getId(),
loan.getOfficeId());
}
}
}
private class LoanProductCreatedListener extends NotificationBusinessEventAdapter {
@Override
public void businessEventWasExecuted(Map<BusinessEntity, Object> businessEventEntity) {
LoanProduct loanProduct;
Object entity = businessEventEntity.get(BusinessEntity.LOAN_PRODUCT);
if (entity != null) {
loanProduct = (LoanProduct) entity;
buildNotification("READ_LOANPRODUCT", "loanProduct", loanProduct.getId(), "New loan product created", "created",
context.authenticatedUser().getId(), context.authenticatedUser().getOffice().getId());
}
}
}
private class SavingsAccountCreatedListener extends NotificationBusinessEventAdapter {
@Override
public void businessEventWasExecuted(Map<BusinessEntity, Object> businessEventEntity) {
SavingsAccount savingsAccount;
Object entity = businessEventEntity.get(BusinessEntity.SAVING);
if (entity != null) {
savingsAccount = (SavingsAccount) entity;
buildNotification("APPROVE_SAVINGSACCOUNT", "savingsAccount", savingsAccount.getId(), "New savings account created",
"created", context.authenticatedUser().getId(), savingsAccount.officeId());
}
}
}
private class SavingsAccountClosedListener extends NotificationBusinessEventAdapter {
@Override
public void businessEventWasExecuted(Map<BusinessEntity, Object> businessEventEntity) {
SavingsAccount savingsAccount;
Object entity = businessEventEntity.get(BusinessEntity.SAVING);
if (entity != null) {
savingsAccount = (SavingsAccount) entity;
buildNotification("READ_SAVINGSACCOUNT", "savingsAccount", savingsAccount.getId(), "Savings has gone into dormant",
"closed", context.authenticatedUser().getId(), savingsAccount.officeId());
}
}
}
private class ShareAccountCreatedListener extends NotificationBusinessEventAdapter {
@Override
public void businessEventWasExecuted(Map<BusinessEntity, Object> businessEventEntity) {
ShareAccount shareAccount;
Object entity = businessEventEntity.get(BusinessEntity.SHARE_ACCOUNT);
if (entity != null) {
shareAccount = (ShareAccount) entity;
buildNotification("APPROVE_SHAREACCOUNT", "shareAccount", shareAccount.getId(), "New share account created", "created",
context.authenticatedUser().getId(), shareAccount.getOfficeId());
}
}
}
private class ShareAccountApprovedListener extends NotificationBusinessEventAdapter {
@Override
public void businessEventWasExecuted(Map<BusinessEntity, Object> businessEventEntity) {
ShareAccount shareAccount;
Object entity = businessEventEntity.get(BusinessEntity.SHARE_ACCOUNT);
if (entity != null) {
shareAccount = (ShareAccount) entity;
buildNotification("ACTIVATE_SHAREACCOUNT", "shareAccount", shareAccount.getId(), "Share account approved", "approved",
context.authenticatedUser().getId(), shareAccount.getOfficeId());
}
} }
} }
@@ -18,24 +18,18 @@
*/ */
package org.apache.fineract.portfolio.businessevent; package org.apache.fineract.portfolio.businessevent;
import java.util.Map; import org.apache.fineract.portfolio.businessevent.domain.BusinessEvent;
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 * The interface to be implemented by classes that want to be informed when a Business Event executes. example: on
* completion of loan approval event need to block guarantor funds * completion of loan approval event need to block guarantor funds
* *
*/ */
public interface BusinessEventListener { public interface BusinessEventListener<T extends BusinessEvent<?>> {
/**
* Implement this method for notifications before executing Business Event
*/
void businessEventToBeExecuted(Map<BusinessEntity, Object> businessEventEntity);
/** /**
* Implement this method for notifications after executing Business Event * Implement this method for notifications after executing Business Event
*/ */
void businessEventWasExecuted(Map<BusinessEntity, Object> businessEventEntity); void onBusinessEvent(T event);
} }
@@ -18,27 +18,15 @@
*/ */
package org.apache.fineract.portfolio.businessevent.domain; package org.apache.fineract.portfolio.businessevent.domain;
public enum BusinessEntity { import lombok.RequiredArgsConstructor;
LOAN("loan"), // @RequiredArgsConstructor
LOAN_TRANSACTION("loan_transaction"), // public abstract class AbstractBusinessEvent<T> implements BusinessEvent<T> {
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; private final T value;
BusinessEntity(final String value) { @Override
this.value = value; public T get() {
}
public String getValue() {
return value; return value;
} }
} }
@@ -18,86 +18,7 @@
*/ */
package org.apache.fineract.portfolio.businessevent.domain; package org.apache.fineract.portfolio.businessevent.domain;
import java.util.HashSet; public interface BusinessEvent<T> {
import java.util.Set;
public enum BusinessEvent { T get();
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;
}
} }
@@ -0,0 +1,28 @@
/**
* 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.client;
import org.apache.fineract.portfolio.client.domain.Client;
public class ClientActivateBusinessEvent extends ClientBusinessEvent {
public ClientActivateBusinessEvent(Client value) {
super(value);
}
}
@@ -0,0 +1,29 @@
/**
* 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.client;
import org.apache.fineract.portfolio.businessevent.domain.AbstractBusinessEvent;
import org.apache.fineract.portfolio.client.domain.Client;
public abstract class ClientBusinessEvent extends AbstractBusinessEvent<Client> {
public ClientBusinessEvent(Client value) {
super(value);
}
}
@@ -0,0 +1,28 @@
/**
* 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.client;
import org.apache.fineract.portfolio.client.domain.Client;
public class ClientCreateBusinessEvent extends ClientBusinessEvent {
public ClientCreateBusinessEvent(Client value) {
super(value);
}
}
@@ -0,0 +1,28 @@
/**
* 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.client;
import org.apache.fineract.portfolio.client.domain.Client;
public class ClientRejectBusinessEvent extends ClientBusinessEvent {
public ClientRejectBusinessEvent(Client value) {
super(value);
}
}
@@ -0,0 +1,29 @@
/**
* 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.deposit;
import org.apache.fineract.portfolio.businessevent.domain.AbstractBusinessEvent;
import org.apache.fineract.portfolio.savings.domain.FixedDepositAccount;
public abstract class FixedDepositAccountBusinessEvent extends AbstractBusinessEvent<FixedDepositAccount> {
public FixedDepositAccountBusinessEvent(FixedDepositAccount value) {
super(value);
}
}
@@ -0,0 +1,28 @@
/**
* 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.deposit;
import org.apache.fineract.portfolio.savings.domain.FixedDepositAccount;
public class FixedDepositAccountCreateBusinessEvent extends FixedDepositAccountBusinessEvent {
public FixedDepositAccountCreateBusinessEvent(FixedDepositAccount value) {
super(value);
}
}
@@ -0,0 +1,29 @@
/**
* 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.deposit;
import org.apache.fineract.portfolio.businessevent.domain.AbstractBusinessEvent;
import org.apache.fineract.portfolio.savings.domain.RecurringDepositAccount;
public abstract class RecurringDepositAccountBusinessEvent extends AbstractBusinessEvent<RecurringDepositAccount> {
public RecurringDepositAccountBusinessEvent(RecurringDepositAccount value) {
super(value);
}
}
@@ -0,0 +1,28 @@
/**
* 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.deposit;
import org.apache.fineract.portfolio.savings.domain.RecurringDepositAccount;
public class RecurringDepositAccountCreateBusinessEvent extends RecurringDepositAccountBusinessEvent {
public RecurringDepositAccountCreateBusinessEvent(RecurringDepositAccount value) {
super(value);
}
}
@@ -0,0 +1,28 @@
/**
* 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.group;
import org.apache.fineract.infrastructure.core.data.CommandProcessingResult;
public class CentersCreateBusinessEvent extends GroupsBusinessEvent {
public CentersCreateBusinessEvent(CommandProcessingResult value) {
super(value);
}
}
@@ -0,0 +1,29 @@
/**
* 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.group;
import org.apache.fineract.infrastructure.core.data.CommandProcessingResult;
import org.apache.fineract.portfolio.businessevent.domain.AbstractBusinessEvent;
public abstract class GroupsBusinessEvent extends AbstractBusinessEvent<CommandProcessingResult> {
public GroupsBusinessEvent(CommandProcessingResult value) {
super(value);
}
}
@@ -0,0 +1,28 @@
/**
* 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.group;
import org.apache.fineract.infrastructure.core.data.CommandProcessingResult;
public class GroupsCreateBusinessEvent extends GroupsBusinessEvent {
public GroupsCreateBusinessEvent(CommandProcessingResult value) {
super(value);
}
}
@@ -0,0 +1,28 @@
/**
* 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.loan;
import org.apache.fineract.portfolio.loanaccount.domain.Loan;
public class LoanAcceptTransferBusinessEvent extends LoanBusinessEvent {
public LoanAcceptTransferBusinessEvent(Loan value) {
super(value);
}
}
@@ -0,0 +1,41 @@
/**
* 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.loan;
import lombok.Getter;
import lombok.RequiredArgsConstructor;
import lombok.Setter;
import org.apache.fineract.portfolio.businessevent.domain.AbstractBusinessEvent;
import org.apache.fineract.portfolio.loanaccount.domain.LoanTransaction;
public class LoanAdjustTransactionBusinessEvent extends AbstractBusinessEvent<LoanAdjustTransactionBusinessEvent.Data> {
public LoanAdjustTransactionBusinessEvent(Data value) {
super(value);
}
@RequiredArgsConstructor
@Getter
public static class Data {
private final LoanTransaction transactionToAdjust;
@Setter
private LoanTransaction newTransactionDetail;
}
}
@@ -0,0 +1,28 @@
/**
* 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.loan;
import org.apache.fineract.portfolio.loanaccount.domain.Loan;
public class LoanApplyOverdueChargeBusinessEvent extends LoanBusinessEvent {
public LoanApplyOverdueChargeBusinessEvent(Loan value) {
super(value);
}
}
@@ -0,0 +1,28 @@
/**
* 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.loan;
import org.apache.fineract.portfolio.loanaccount.domain.Loan;
public class LoanApprovedBusinessEvent extends LoanBusinessEvent {
public LoanApprovedBusinessEvent(Loan value) {
super(value);
}
}
@@ -0,0 +1,29 @@
/**
* 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.loan;
import org.apache.fineract.portfolio.businessevent.domain.AbstractBusinessEvent;
import org.apache.fineract.portfolio.loanaccount.domain.Loan;
public abstract class LoanBusinessEvent extends AbstractBusinessEvent<Loan> {
public LoanBusinessEvent(Loan value) {
super(value);
}
}
@@ -0,0 +1,28 @@
/**
* 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.loan;
import org.apache.fineract.portfolio.loanaccount.domain.Loan;
public class LoanCloseAsRescheduleBusinessEvent extends LoanBusinessEvent {
public LoanCloseAsRescheduleBusinessEvent(Loan value) {
super(value);
}
}
@@ -0,0 +1,28 @@
/**
* 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.loan;
import org.apache.fineract.portfolio.loanaccount.domain.Loan;
public class LoanCloseBusinessEvent extends LoanBusinessEvent {
public LoanCloseBusinessEvent(Loan value) {
super(value);
}
}
@@ -0,0 +1,28 @@
/**
* 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.loan;
import org.apache.fineract.portfolio.loanaccount.domain.Loan;
public class LoanCreatedBusinessEvent extends LoanBusinessEvent {
public LoanCreatedBusinessEvent(Loan value) {
super(value);
}
}
@@ -0,0 +1,28 @@
/**
* 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.loan;
import org.apache.fineract.portfolio.loanaccount.domain.Loan;
public class LoanDisbursalBusinessEvent extends LoanBusinessEvent {
public LoanDisbursalBusinessEvent(Loan value) {
super(value);
}
}
@@ -0,0 +1,28 @@
/**
* 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.loan;
import org.apache.fineract.portfolio.loanaccount.domain.Loan;
public class LoanInitiateTransferBusinessEvent extends LoanBusinessEvent {
public LoanInitiateTransferBusinessEvent(Loan value) {
super(value);
}
}
@@ -0,0 +1,28 @@
/**
* 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.loan;
import org.apache.fineract.portfolio.loanaccount.domain.Loan;
public class LoanInterestRecalculationBusinessEvent extends LoanBusinessEvent {
public LoanInterestRecalculationBusinessEvent(Loan value) {
super(value);
}
}
@@ -0,0 +1,28 @@
/**
* 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.loan;
import org.apache.fineract.portfolio.loanaccount.domain.Loan;
public class LoanReassignOfficerBusinessEvent extends LoanBusinessEvent {
public LoanReassignOfficerBusinessEvent(Loan value) {
super(value);
}
}
@@ -0,0 +1,28 @@
/**
* 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.loan;
import org.apache.fineract.portfolio.loanaccount.domain.Loan;
public class LoanRejectTransferBusinessEvent extends LoanBusinessEvent {
public LoanRejectTransferBusinessEvent(Loan value) {
super(value);
}
}
@@ -0,0 +1,28 @@
/**
* 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.loan;
import org.apache.fineract.portfolio.loanaccount.domain.Loan;
public class LoanRejectedBusinessEvent extends LoanBusinessEvent {
public LoanRejectedBusinessEvent(Loan value) {
super(value);
}
}
@@ -0,0 +1,28 @@
/**
* 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.loan;
import org.apache.fineract.portfolio.loanaccount.domain.Loan;
public class LoanRemoveOfficerBusinessEvent extends LoanBusinessEvent {
public LoanRemoveOfficerBusinessEvent(Loan value) {
super(value);
}
}
@@ -0,0 +1,28 @@
/**
* 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.loan;
import org.apache.fineract.portfolio.loanaccount.domain.Loan;
public class LoanUndoApprovalBusinessEvent extends LoanBusinessEvent {
public LoanUndoApprovalBusinessEvent(Loan value) {
super(value);
}
}
@@ -0,0 +1,28 @@
/**
* 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.loan;
import org.apache.fineract.portfolio.loanaccount.domain.Loan;
public class LoanUndoDisbursalBusinessEvent extends LoanBusinessEvent {
public LoanUndoDisbursalBusinessEvent(Loan value) {
super(value);
}
}
@@ -0,0 +1,28 @@
/**
* 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.loan;
import org.apache.fineract.portfolio.loanaccount.domain.Loan;
public class LoanUndoLastDisbursalBusinessEvent extends LoanBusinessEvent {
public LoanUndoLastDisbursalBusinessEvent(Loan value) {
super(value);
}
}
@@ -0,0 +1,28 @@
/**
* 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.loan;
import org.apache.fineract.portfolio.loanaccount.domain.Loan;
public class LoanWithdrawTransferBusinessEvent extends LoanBusinessEvent {
public LoanWithdrawTransferBusinessEvent(Loan value) {
super(value);
}
}
@@ -0,0 +1,28 @@
/**
* 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.loan.charge;
import org.apache.fineract.portfolio.loanaccount.domain.LoanCharge;
public class LoanAddChargeBusinessEvent extends LoanChargeBusinessEvent {
public LoanAddChargeBusinessEvent(LoanCharge value) {
super(value);
}
}
@@ -0,0 +1,29 @@
/**
* 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.loan.charge;
import org.apache.fineract.portfolio.businessevent.domain.AbstractBusinessEvent;
import org.apache.fineract.portfolio.loanaccount.domain.LoanCharge;
public abstract class LoanChargeBusinessEvent extends AbstractBusinessEvent<LoanCharge> {
public LoanChargeBusinessEvent(LoanCharge value) {
super(value);
}
}
@@ -0,0 +1,28 @@
/**
* 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.loan.charge;
import org.apache.fineract.portfolio.loanaccount.domain.LoanCharge;
public class LoanDeleteChargeBusinessEvent extends LoanChargeBusinessEvent {
public LoanDeleteChargeBusinessEvent(LoanCharge value) {
super(value);
}
}
@@ -0,0 +1,28 @@
/**
* 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.loan.charge;
import org.apache.fineract.portfolio.loanaccount.domain.LoanCharge;
public class LoanUpdateChargeBusinessEvent extends LoanChargeBusinessEvent {
public LoanUpdateChargeBusinessEvent(LoanCharge value) {
super(value);
}
}
@@ -0,0 +1,28 @@
/**
* 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.loan.charge;
import org.apache.fineract.portfolio.loanaccount.domain.LoanCharge;
public class LoanWaiveChargeBusinessEvent extends LoanChargeBusinessEvent {
public LoanWaiveChargeBusinessEvent(LoanCharge value) {
super(value);
}
}
@@ -0,0 +1,28 @@
/**
* 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.loan.charge;
import org.apache.fineract.portfolio.loanaccount.domain.LoanCharge;
public class LoanWaiveChargeUndoBusinessEvent extends LoanChargeBusinessEvent {
public LoanWaiveChargeUndoBusinessEvent(LoanCharge value) {
super(value);
}
}
@@ -0,0 +1,29 @@
/**
* 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.loan.product;
import org.apache.fineract.portfolio.businessevent.domain.AbstractBusinessEvent;
import org.apache.fineract.portfolio.loanproduct.domain.LoanProduct;
public abstract class LoanProductBusinessEvent extends AbstractBusinessEvent<LoanProduct> {
public LoanProductBusinessEvent(LoanProduct value) {
super(value);
}
}
@@ -0,0 +1,28 @@
/**
* 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.loan.product;
import org.apache.fineract.portfolio.loanproduct.domain.LoanProduct;
public class LoanProductCreateBusinessEvent extends LoanProductBusinessEvent {
public LoanProductCreateBusinessEvent(LoanProduct value) {
super(value);
}
}
@@ -0,0 +1,28 @@
/**
* 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.loan.transaction;
import org.apache.fineract.portfolio.loanaccount.domain.LoanTransaction;
public class LoanChargePaymentBusinessEvent extends LoanTransactionBusinessEvent {
public LoanChargePaymentBusinessEvent(LoanTransaction value) {
super(value);
}
}
@@ -0,0 +1,28 @@
/**
* 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.loan.transaction;
import org.apache.fineract.portfolio.loanaccount.domain.LoanTransaction;
public class LoanCreditBalanceRefundBusinessEvent extends LoanTransactionBusinessEvent {
public LoanCreditBalanceRefundBusinessEvent(LoanTransaction value) {
super(value);
}
}
@@ -0,0 +1,28 @@
/**
* 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.loan.transaction;
import org.apache.fineract.portfolio.loanaccount.domain.LoanTransaction;
public class LoanForeClosureBusinessEvent extends LoanTransactionBusinessEvent {
public LoanForeClosureBusinessEvent(LoanTransaction value) {
super(value);
}
}
@@ -0,0 +1,28 @@
/**
* 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.loan.transaction;
import org.apache.fineract.portfolio.loanaccount.domain.LoanTransaction;
public class LoanGoodwillCreditBusinessEvent extends LoanTransactionBusinessEvent {
public LoanGoodwillCreditBusinessEvent(LoanTransaction value) {
super(value);
}
}
@@ -0,0 +1,28 @@
/**
* 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.loan.transaction;
import org.apache.fineract.portfolio.loanaccount.domain.LoanTransaction;
public class LoanMakeRepaymentBusinessEvent extends LoanTransactionBusinessEvent {
public LoanMakeRepaymentBusinessEvent(LoanTransaction value) {
super(value);
}
}
@@ -0,0 +1,28 @@
/**
* 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.loan.transaction;
import org.apache.fineract.portfolio.loanaccount.domain.LoanTransaction;
public class LoanMerchantIssuedRefundBusinessEvent extends LoanTransactionBusinessEvent {
public LoanMerchantIssuedRefundBusinessEvent(LoanTransaction value) {
super(value);
}
}
@@ -0,0 +1,28 @@
/**
* 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.loan.transaction;
import org.apache.fineract.portfolio.loanaccount.domain.LoanTransaction;
public class LoanPayoutRefundBusinessEvent extends LoanTransactionBusinessEvent {
public LoanPayoutRefundBusinessEvent(LoanTransaction value) {
super(value);
}
}
@@ -0,0 +1,28 @@
/**
* 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.loan.transaction;
import org.apache.fineract.portfolio.loanaccount.domain.LoanTransaction;
public class LoanRecoveryPaymentBusinessEvent extends LoanTransactionBusinessEvent {
public LoanRecoveryPaymentBusinessEvent(LoanTransaction value) {
super(value);
}
}
@@ -0,0 +1,28 @@
/**
* 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.loan.transaction;
import org.apache.fineract.portfolio.loanaccount.domain.LoanTransaction;
public class LoanRefundBusinessEvent extends LoanTransactionBusinessEvent {
public LoanRefundBusinessEvent(LoanTransaction value) {
super(value);
}
}
@@ -0,0 +1,29 @@
/**
* 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.loan.transaction;
import org.apache.fineract.portfolio.businessevent.domain.AbstractBusinessEvent;
import org.apache.fineract.portfolio.loanaccount.domain.LoanTransaction;
public abstract class LoanTransactionBusinessEvent extends AbstractBusinessEvent<LoanTransaction> {
public LoanTransactionBusinessEvent(LoanTransaction value) {
super(value);
}
}
@@ -0,0 +1,28 @@
/**
* 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.loan.transaction;
import org.apache.fineract.portfolio.loanaccount.domain.LoanTransaction;
public class LoanUndoWrittenOffBusinessEvent extends LoanTransactionBusinessEvent {
public LoanUndoWrittenOffBusinessEvent(LoanTransaction value) {
super(value);
}
}
@@ -0,0 +1,28 @@
/**
* 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.loan.transaction;
import org.apache.fineract.portfolio.loanaccount.domain.LoanTransaction;
public class LoanWaiveInterestBusinessEvent extends LoanTransactionBusinessEvent {
public LoanWaiveInterestBusinessEvent(LoanTransaction value) {
super(value);
}
}
@@ -0,0 +1,28 @@
/**
* 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.loan.transaction;
import org.apache.fineract.portfolio.loanaccount.domain.LoanTransaction;
public class LoanWrittenOffBusinessEvent extends LoanTransactionBusinessEvent {
public LoanWrittenOffBusinessEvent(LoanTransaction value) {
super(value);
}
}
@@ -0,0 +1,29 @@
/**
* 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.savings;
import org.apache.fineract.portfolio.businessevent.domain.AbstractBusinessEvent;
import org.apache.fineract.portfolio.savings.domain.SavingsAccount;
public abstract class SavingsAccountBusinessEvent extends AbstractBusinessEvent<SavingsAccount> {
public SavingsAccountBusinessEvent(SavingsAccount value) {
super(value);
}
}
@@ -0,0 +1,28 @@
/**
* 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.savings;
import org.apache.fineract.portfolio.savings.domain.SavingsAccount;
public class SavingsActivateBusinessEvent extends SavingsAccountBusinessEvent {
public SavingsActivateBusinessEvent(SavingsAccount value) {
super(value);
}
}
@@ -0,0 +1,28 @@
/**
* 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.savings;
import org.apache.fineract.portfolio.savings.domain.SavingsAccount;
public class SavingsApproveBusinessEvent extends SavingsAccountBusinessEvent {
public SavingsApproveBusinessEvent(SavingsAccount value) {
super(value);
}
}
@@ -0,0 +1,28 @@
/**
* 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.savings;
import org.apache.fineract.portfolio.savings.domain.SavingsAccount;
public class SavingsCloseBusinessEvent extends SavingsAccountBusinessEvent {
public SavingsCloseBusinessEvent(SavingsAccount value) {
super(value);
}
}
@@ -0,0 +1,28 @@
/**
* 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.savings;
import org.apache.fineract.portfolio.savings.domain.SavingsAccount;
public class SavingsCreateBusinessEvent extends SavingsAccountBusinessEvent {
public SavingsCreateBusinessEvent(SavingsAccount value) {
super(value);
}
}
@@ -0,0 +1,28 @@
/**
* 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.savings;
import org.apache.fineract.portfolio.savings.domain.SavingsAccount;
public class SavingsPostInterestBusinessEvent extends SavingsAccountBusinessEvent {
public SavingsPostInterestBusinessEvent(SavingsAccount value) {
super(value);
}
}
@@ -0,0 +1,28 @@
/**
* 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.savings;
import org.apache.fineract.portfolio.savings.domain.SavingsAccount;
public class SavingsRejectBusinessEvent extends SavingsAccountBusinessEvent {
public SavingsRejectBusinessEvent(SavingsAccount value) {
super(value);
}
}
@@ -0,0 +1,29 @@
/**
* 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.savings.transaction;
import org.apache.fineract.portfolio.businessevent.domain.AbstractBusinessEvent;
import org.apache.fineract.portfolio.savings.domain.SavingsAccountTransaction;
public abstract class SavingsAccountTransactionBusinessEvent extends AbstractBusinessEvent<SavingsAccountTransaction> {
public SavingsAccountTransactionBusinessEvent(SavingsAccountTransaction value) {
super(value);
}
}
@@ -0,0 +1,28 @@
/**
* 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.savings.transaction;
import org.apache.fineract.portfolio.savings.domain.SavingsAccountTransaction;
public class SavingsDepositBusinessEvent extends SavingsAccountTransactionBusinessEvent {
public SavingsDepositBusinessEvent(SavingsAccountTransaction value) {
super(value);
}
}
@@ -0,0 +1,28 @@
/**
* 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.savings.transaction;
import org.apache.fineract.portfolio.savings.domain.SavingsAccountTransaction;
public class SavingsWithdrawalBusinessEvent extends SavingsAccountTransactionBusinessEvent {
public SavingsWithdrawalBusinessEvent(SavingsAccountTransaction value) {
super(value);
}
}
@@ -0,0 +1,28 @@
/**
* 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.share;
import org.apache.fineract.portfolio.shareaccounts.domain.ShareAccount;
public class ShareAccountApproveBusinessEvent extends ShareAccountBusinessEvent {
public ShareAccountApproveBusinessEvent(ShareAccount value) {
super(value);
}
}
@@ -0,0 +1,29 @@
/**
* 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.share;
import org.apache.fineract.portfolio.businessevent.domain.AbstractBusinessEvent;
import org.apache.fineract.portfolio.shareaccounts.domain.ShareAccount;
public abstract class ShareAccountBusinessEvent extends AbstractBusinessEvent<ShareAccount> {
public ShareAccountBusinessEvent(ShareAccount value) {
super(value);
}
}
@@ -0,0 +1,28 @@
/**
* 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.share;
import org.apache.fineract.portfolio.shareaccounts.domain.ShareAccount;
public class ShareAccountCreateBusinessEvent extends ShareAccountBusinessEvent {
public ShareAccountCreateBusinessEvent(ShareAccount value) {
super(value);
}
}
@@ -0,0 +1,28 @@
/**
* 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.share;
import org.apache.fineract.portfolio.businessevent.domain.AbstractBusinessEvent;
public class ShareProductDividentsCreateBusinessEvent extends AbstractBusinessEvent<Long> {
public ShareProductDividentsCreateBusinessEvent(Long value) {
super(value);
}
}
@@ -18,9 +18,7 @@
*/ */
package org.apache.fineract.portfolio.businessevent.service; package org.apache.fineract.portfolio.businessevent.service;
import java.util.Map;
import org.apache.fineract.portfolio.businessevent.BusinessEventListener; 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.domain.BusinessEvent;
/** /**
@@ -29,24 +27,14 @@ import org.apache.fineract.portfolio.businessevent.domain.BusinessEvent;
*/ */
public interface BusinessEventNotifierService { public interface BusinessEventNotifierService {
/**
* Method should be called to notify listeners before Business event execution for any pre-processing of event
*/
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 * Method should be called to notify listeners after Business event execution for any post-processing of event
*/ */
void notifyBusinessEventWasExecuted(BusinessEvent businessEvent, Map<BusinessEntity, Object> businessEventEntity); void notifyBusinessEvent(BusinessEvent<?> businessEvent);
/**
* Method is to register a class as listener for pre-processing of any Business event
*/
void addBusinessEventPreListeners(BusinessEvent businessEvent, BusinessEventListener businessEventListener);
/** /**
* Method is to register a class as listener for post-processing of any Business event * Method is to register a class as listener for post-processing of any Business event
*/ */
void addBusinessEventPostListeners(BusinessEvent businessEvent, BusinessEventListener businessEventListener); <T extends BusinessEvent<?>> void addBusinessEventListener(Class<T> eventType, BusinessEventListener<T> listener);
} }
@@ -23,32 +23,14 @@ import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import org.apache.fineract.portfolio.businessevent.BusinessEventListener; 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.domain.BusinessEvent;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
@Service @Service
@SuppressWarnings({ "unchecked", "rawtypes" })
public class BusinessEventNotifierServiceImpl implements BusinessEventNotifierService { public class BusinessEventNotifierServiceImpl implements BusinessEventNotifierService {
private final Map<BusinessEvent, List<BusinessEventListener>> preListeners = new HashMap<>(5); private final Map<Class, List<BusinessEventListener>> listeners = new HashMap<>();
private final Map<BusinessEvent, List<BusinessEventListener>> postListeners = new HashMap<>(5);
/*
* (non-Javadoc)
*
* @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(BusinessEvent businessEvent, Map<BusinessEntity, Object> businessEventEntity) {
List<BusinessEventListener> businessEventListeners = this.preListeners.get(businessEvent);
if (businessEventListeners != null) {
for (BusinessEventListener eventListener : businessEventListeners) {
eventListener.businessEventToBeExecuted(businessEventEntity);
}
}
}
/* /*
* (non-Javadoc) * (non-Javadoc)
@@ -58,27 +40,15 @@ public class BusinessEventNotifierServiceImpl implements BusinessEventNotifierSe
* .BusinessEvents, org.springframework.data.jpa.domain.AbstractPersistable) * .BusinessEvents, org.springframework.data.jpa.domain.AbstractPersistable)
*/ */
@Override @Override
public void notifyBusinessEventWasExecuted(BusinessEvent businessEvent, Map<BusinessEntity, Object> businessEventEntity) { public void notifyBusinessEvent(BusinessEvent<?> businessEvent) {
List<BusinessEventListener> businessEventListeners = this.postListeners.get(businessEvent); List<BusinessEventListener> businessEventListeners = listeners.get(businessEvent.getClass());
if (businessEventListeners != null) { if (businessEventListeners != null) {
for (BusinessEventListener eventListener : businessEventListeners) { for (BusinessEventListener eventListener : businessEventListeners) {
eventListener.businessEventWasExecuted(businessEventEntity); eventListener.onBusinessEvent(businessEvent);
} }
} }
} }
/*
* (non-Javadoc)
*
* @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(BusinessEvent businessEvent, BusinessEventListener businessEventListener) {
addBusinessEventListeners(businessEvent, businessEventListener, preListeners);
}
/* /*
* (non-Javadoc) * (non-Javadoc)
* *
@@ -87,18 +57,13 @@ public class BusinessEventNotifierServiceImpl implements BusinessEventNotifierSe
* .BusinessEvents, org.apache.fineract.portfolio.businessevent.BusinessEventListener) * .BusinessEvents, org.apache.fineract.portfolio.businessevent.BusinessEventListener)
*/ */
@Override @Override
public void addBusinessEventPostListeners(BusinessEvent businessEvent, BusinessEventListener businessEventListener) { public <T extends BusinessEvent<?>> void addBusinessEventListener(Class<T> eventType, BusinessEventListener<T> listener) {
addBusinessEventListeners(businessEvent, businessEventListener, postListeners); List<BusinessEventListener> businessEventListeners = listeners.get(eventType);
}
private void addBusinessEventListeners(BusinessEvent businessEvent, BusinessEventListener businessEventListener,
final Map<BusinessEvent, List<BusinessEventListener>> businessEventListenerMap) {
List<BusinessEventListener> businessEventListeners = businessEventListenerMap.get(businessEvent);
if (businessEventListeners == null) { if (businessEventListeners == null) {
businessEventListeners = new ArrayList<>(); businessEventListeners = new ArrayList<>();
businessEventListenerMap.put(businessEvent, businessEventListeners); listeners.put(eventType, businessEventListeners);
} }
businessEventListeners.add(businessEventListener); businessEventListeners.add(listener);
} }
} }
@@ -23,12 +23,12 @@ import java.time.LocalDate;
import java.time.ZoneId; import java.time.ZoneId;
import java.time.format.DateTimeFormatter; import java.time.format.DateTimeFormatter;
import java.util.Date; import java.util.Date;
import java.util.HashMap;
import java.util.LinkedHashMap; import java.util.LinkedHashMap;
import java.util.List; import java.util.List;
import java.util.Locale; import java.util.Locale;
import java.util.Map; import java.util.Map;
import javax.persistence.PersistenceException; import javax.persistence.PersistenceException;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.exception.ExceptionUtils; import org.apache.commons.lang3.exception.ExceptionUtils;
import org.apache.fineract.commands.domain.CommandWrapper; import org.apache.fineract.commands.domain.CommandWrapper;
import org.apache.fineract.commands.service.CommandProcessingService; import org.apache.fineract.commands.service.CommandProcessingService;
@@ -55,8 +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.Staff;
import org.apache.fineract.organisation.staff.domain.StaffRepositoryWrapper; import org.apache.fineract.organisation.staff.domain.StaffRepositoryWrapper;
import org.apache.fineract.portfolio.address.service.AddressWritePlatformService; import org.apache.fineract.portfolio.address.service.AddressWritePlatformService;
import org.apache.fineract.portfolio.businessevent.domain.BusinessEntity; import org.apache.fineract.portfolio.businessevent.domain.client.ClientActivateBusinessEvent;
import org.apache.fineract.portfolio.businessevent.domain.BusinessEvent; import org.apache.fineract.portfolio.businessevent.domain.client.ClientCreateBusinessEvent;
import org.apache.fineract.portfolio.businessevent.domain.client.ClientRejectBusinessEvent;
import org.apache.fineract.portfolio.businessevent.service.BusinessEventNotifierService; import org.apache.fineract.portfolio.businessevent.service.BusinessEventNotifierService;
import org.apache.fineract.portfolio.client.api.ClientApiConstants; import org.apache.fineract.portfolio.client.api.ClientApiConstants;
import org.apache.fineract.portfolio.client.data.ClientDataValidator; import org.apache.fineract.portfolio.client.data.ClientDataValidator;
@@ -87,8 +88,6 @@ import org.apache.fineract.portfolio.savings.domain.SavingsProductRepository;
import org.apache.fineract.portfolio.savings.exception.SavingsProductNotFoundException; import org.apache.fineract.portfolio.savings.exception.SavingsProductNotFoundException;
import org.apache.fineract.portfolio.savings.service.SavingsApplicationProcessWritePlatformService; import org.apache.fineract.portfolio.savings.service.SavingsApplicationProcessWritePlatformService;
import org.apache.fineract.useradministration.domain.AppUser; import org.apache.fineract.useradministration.domain.AppUser;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.dao.DataIntegrityViolationException; import org.springframework.dao.DataIntegrityViolationException;
import org.springframework.orm.jpa.JpaSystemException; import org.springframework.orm.jpa.JpaSystemException;
@@ -96,10 +95,9 @@ import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
@Service @Service
@Slf4j
public class ClientWritePlatformServiceJpaRepositoryImpl implements ClientWritePlatformService { public class ClientWritePlatformServiceJpaRepositoryImpl implements ClientWritePlatformService {
private static final Logger LOG = LoggerFactory.getLogger(ClientWritePlatformServiceJpaRepositoryImpl.class);
private final PlatformSecurityContext context; private final PlatformSecurityContext context;
private final ClientRepositoryWrapper clientRepository; private final ClientRepositoryWrapper clientRepository;
private final ClientNonPersonRepositoryWrapper clientNonPersonRepository; private final ClientNonPersonRepositoryWrapper clientNonPersonRepository;
@@ -191,7 +189,7 @@ public class ClientWritePlatformServiceJpaRepositoryImpl implements ClientWriteP
.build(); .build();
} catch (final JpaSystemException | DataIntegrityViolationException dve) { } catch (final JpaSystemException | DataIntegrityViolationException dve) {
Throwable throwable = ExceptionUtils.getRootCause(dve.getCause()); Throwable throwable = ExceptionUtils.getRootCause(dve.getCause());
LOG.error("Error occured.", throwable); log.error("Error occured.", throwable);
throw new PlatformDataIntegrityException("error.msg.client.unknown.data.integrity.issue", throw new PlatformDataIntegrityException("error.msg.client.unknown.data.integrity.issue",
"Unknown data integrity issue with resource.", dve); "Unknown data integrity issue with resource.", dve);
} }
@@ -305,8 +303,7 @@ public class ClientWritePlatformServiceJpaRepositoryImpl implements ClientWriteP
this.clientRepository.saveAndFlush(newClient); this.clientRepository.saveAndFlush(newClient);
if (newClient.isActive()) { if (newClient.isActive()) {
this.businessEventNotifierService.notifyBusinessEventWasExecuted(BusinessEvent.CLIENTS_ACTIVATE, businessEventNotifierService.notifyBusinessEvent(new ClientActivateBusinessEvent(newClient));
constructEntityMap(BusinessEntity.CLIENT, newClient));
} }
if (newClient.isAccountNumberRequiresAutoGeneration()) { if (newClient.isAccountNumberRequiresAutoGeneration()) {
AccountNumberFormat accountNumberFormat = this.accountNumberFormatRepository.findByAccountType(EntityAccountType.CLIENT); AccountNumberFormat accountNumberFormat = this.accountNumberFormatRepository.findByAccountType(EntityAccountType.CLIENT);
@@ -340,10 +337,9 @@ public class ClientWritePlatformServiceJpaRepositoryImpl implements ClientWriteP
command.arrayOfParameterNamed(ClientApiConstants.datatables)); command.arrayOfParameterNamed(ClientApiConstants.datatables));
} }
this.businessEventNotifierService.notifyBusinessEventWasExecuted(BusinessEvent.CLIENTS_CREATE, businessEventNotifierService.notifyBusinessEvent(new ClientCreateBusinessEvent(newClient));
constructEntityMap(BusinessEntity.CLIENT, newClient));
this.entityDatatableChecksWritePlatformService.runTheCheck(newClient.getId(), EntityTables.CLIENT.getName(), entityDatatableChecksWritePlatformService.runTheCheck(newClient.getId(), EntityTables.CLIENT.getName(),
StatusEnum.CREATE.getCode().longValue(), EntityTables.CLIENT.getForeignKeyColumnNameOnDatatable()); StatusEnum.CREATE.getCode().longValue(), EntityTables.CLIENT.getForeignKeyColumnNameOnDatatable());
return new CommandProcessingResultBuilder() // return new CommandProcessingResultBuilder() //
.withCommandId(command.commandId()) // .withCommandId(command.commandId()) //
@@ -594,9 +590,8 @@ public class ClientWritePlatformServiceJpaRepositoryImpl implements ClientWriteP
final AppUser currentUser = this.context.authenticatedUser(); final AppUser currentUser = this.context.authenticatedUser();
client.activate(currentUser, fmt, activationDate); client.activate(currentUser, fmt, activationDate);
CommandProcessingResult result = openSavingsAccount(client, fmt); CommandProcessingResult result = openSavingsAccount(client, fmt);
this.clientRepository.saveAndFlush(client); clientRepository.saveAndFlush(client);
this.businessEventNotifierService.notifyBusinessEventWasExecuted(BusinessEvent.CLIENTS_ACTIVATE, businessEventNotifierService.notifyBusinessEvent(new ClientActivateBusinessEvent(client));
constructEntityMap(BusinessEntity.CLIENT, client));
return new CommandProcessingResultBuilder() // return new CommandProcessingResultBuilder() //
.withCommandId(command.commandId()) // .withCommandId(command.commandId()) //
.withOfficeId(client.officeId()) // .withOfficeId(client.officeId()) //
@@ -627,7 +622,7 @@ public class ClientWritePlatformServiceJpaRepositoryImpl implements ClientWriteP
} }
private void logAsErrorUnexpectedDataIntegrityException(final Exception dve) { private void logAsErrorUnexpectedDataIntegrityException(final Exception dve) {
LOG.error("Error occured.", dve); log.error("Error occured.", dve);
} }
@Transactional @Transactional
@@ -849,9 +844,8 @@ public class ClientWritePlatformServiceJpaRepositoryImpl implements ClientWriteP
rejectionDate, client.getSubmittedOnDate()); rejectionDate, client.getSubmittedOnDate());
} }
client.reject(currentUser, rejectionReason, Date.from(rejectionDate.atStartOfDay(ZoneId.systemDefault()).toInstant())); client.reject(currentUser, rejectionReason, Date.from(rejectionDate.atStartOfDay(ZoneId.systemDefault()).toInstant()));
this.clientRepository.saveAndFlush(client); clientRepository.saveAndFlush(client);
this.businessEventNotifierService.notifyBusinessEventWasExecuted(BusinessEvent.CLIENTS_REJECT, businessEventNotifierService.notifyBusinessEvent(new ClientRejectBusinessEvent(client));
constructEntityMap(BusinessEntity.CLIENT, client));
return new CommandProcessingResultBuilder() // return new CommandProcessingResultBuilder() //
.withCommandId(command.commandId()) // .withCommandId(command.commandId()) //
.withClientId(entityId) // .withClientId(entityId) //
@@ -966,10 +960,4 @@ public class ClientWritePlatformServiceJpaRepositoryImpl implements ClientWriteP
.withEntityId(entityId) // .withEntityId(entityId) //
.build(); .build();
} }
private Map<BusinessEntity, Object> constructEntityMap(final BusinessEntity entityEvent, Object entity) {
Map<BusinessEntity, Object> map = new HashMap<>(1);
map.put(entityEvent, entity);
return map;
}
} }
@@ -29,6 +29,8 @@ import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Set; import java.util.Set;
import javax.persistence.PersistenceException; import javax.persistence.PersistenceException;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.exception.ExceptionUtils; import org.apache.commons.lang3.exception.ExceptionUtils;
import org.apache.fineract.commands.domain.CommandWrapper; import org.apache.fineract.commands.domain.CommandWrapper;
import org.apache.fineract.commands.service.CommandProcessingService; import org.apache.fineract.commands.service.CommandProcessingService;
@@ -54,8 +56,8 @@ import org.apache.fineract.organisation.office.domain.OfficeRepositoryWrapper;
import org.apache.fineract.organisation.office.exception.InvalidOfficeException; import org.apache.fineract.organisation.office.exception.InvalidOfficeException;
import org.apache.fineract.organisation.staff.domain.Staff; import org.apache.fineract.organisation.staff.domain.Staff;
import org.apache.fineract.organisation.staff.domain.StaffRepositoryWrapper; import org.apache.fineract.organisation.staff.domain.StaffRepositoryWrapper;
import org.apache.fineract.portfolio.businessevent.domain.BusinessEntity; import org.apache.fineract.portfolio.businessevent.domain.group.CentersCreateBusinessEvent;
import org.apache.fineract.portfolio.businessevent.domain.BusinessEvent; import org.apache.fineract.portfolio.businessevent.domain.group.GroupsCreateBusinessEvent;
import org.apache.fineract.portfolio.businessevent.service.BusinessEventNotifierService; import org.apache.fineract.portfolio.businessevent.service.BusinessEventNotifierService;
import org.apache.fineract.portfolio.calendar.domain.Calendar; import org.apache.fineract.portfolio.calendar.domain.Calendar;
import org.apache.fineract.portfolio.calendar.domain.CalendarEntityType; import org.apache.fineract.portfolio.calendar.domain.CalendarEntityType;
@@ -86,9 +88,6 @@ import org.apache.fineract.portfolio.note.domain.NoteRepository;
import org.apache.fineract.portfolio.savings.domain.SavingsAccount; import org.apache.fineract.portfolio.savings.domain.SavingsAccount;
import org.apache.fineract.portfolio.savings.domain.SavingsAccountRepositoryWrapper; import org.apache.fineract.portfolio.savings.domain.SavingsAccountRepositoryWrapper;
import org.apache.fineract.useradministration.domain.AppUser; import org.apache.fineract.useradministration.domain.AppUser;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.dao.DataIntegrityViolationException; import org.springframework.dao.DataIntegrityViolationException;
import org.springframework.orm.jpa.JpaSystemException; import org.springframework.orm.jpa.JpaSystemException;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
@@ -97,10 +96,10 @@ import org.springframework.util.CollectionUtils;
import org.springframework.util.ObjectUtils; import org.springframework.util.ObjectUtils;
@Service @Service
@Slf4j
@RequiredArgsConstructor
public class GroupingTypesWritePlatformServiceJpaRepositoryImpl implements GroupingTypesWritePlatformService { public class GroupingTypesWritePlatformServiceJpaRepositoryImpl implements GroupingTypesWritePlatformService {
private static final Logger LOG = LoggerFactory.getLogger(GroupingTypesWritePlatformServiceJpaRepositoryImpl.class);
private final PlatformSecurityContext context; private final PlatformSecurityContext context;
private final GroupRepositoryWrapper groupRepository; private final GroupRepositoryWrapper groupRepository;
private final ClientRepositoryWrapper clientRepositoryWrapper; private final ClientRepositoryWrapper clientRepositoryWrapper;
@@ -120,38 +119,6 @@ public class GroupingTypesWritePlatformServiceJpaRepositoryImpl implements Group
private final EntityDatatableChecksWritePlatformService entityDatatableChecksWritePlatformService; private final EntityDatatableChecksWritePlatformService entityDatatableChecksWritePlatformService;
private final BusinessEventNotifierService businessEventNotifierService; private final BusinessEventNotifierService businessEventNotifierService;
@Autowired
public GroupingTypesWritePlatformServiceJpaRepositoryImpl(final PlatformSecurityContext context,
final GroupRepositoryWrapper groupRepository, final ClientRepositoryWrapper clientRepositoryWrapper,
final OfficeRepositoryWrapper officeRepositoryWrapper, final StaffRepositoryWrapper staffRepository,
final NoteRepository noteRepository, final GroupLevelRepository groupLevelRepository,
final GroupingTypesDataValidator fromApiJsonDeserializer, final SavingsAccountRepositoryWrapper savingsAccountRepositoryWrapper,
final CodeValueRepositoryWrapper codeValueRepository, final CommandProcessingService commandProcessingService,
final CalendarInstanceRepository calendarInstanceRepository, final ConfigurationDomainService configurationDomainService,
final LoanRepositoryWrapper loanRepositoryWrapper, final AccountNumberFormatRepositoryWrapper accountNumberFormatRepository,
final AccountNumberGenerator accountNumberGenerator,
final EntityDatatableChecksWritePlatformService entityDatatableChecksWritePlatformService,
final BusinessEventNotifierService businessEventNotifierService) {
this.context = context;
this.groupRepository = groupRepository;
this.clientRepositoryWrapper = clientRepositoryWrapper;
this.officeRepositoryWrapper = officeRepositoryWrapper;
this.staffRepository = staffRepository;
this.noteRepository = noteRepository;
this.groupLevelRepository = groupLevelRepository;
this.fromApiJsonDeserializer = fromApiJsonDeserializer;
this.savingsAccountRepositoryWrapper = savingsAccountRepositoryWrapper;
this.codeValueRepository = codeValueRepository;
this.commandProcessingService = commandProcessingService;
this.calendarInstanceRepository = calendarInstanceRepository;
this.configurationDomainService = configurationDomainService;
this.loanRepositoryWrapper = loanRepositoryWrapper;
this.accountNumberFormatRepository = accountNumberFormatRepository;
this.accountNumberGenerator = accountNumberGenerator;
this.entityDatatableChecksWritePlatformService = entityDatatableChecksWritePlatformService;
this.businessEventNotifierService = businessEventNotifierService;
}
private CommandProcessingResult createGroupingType(final JsonCommand command, final GroupTypes groupingType, final Long centerId) { private CommandProcessingResult createGroupingType(final JsonCommand command, final GroupTypes groupingType, final Long centerId) {
try { try {
final String accountNo = command.stringValueOfParameterNamed(GroupingTypesApiConstants.accountNoParamName); final String accountNo = command.stringValueOfParameterNamed(GroupingTypesApiConstants.accountNoParamName);
@@ -290,8 +257,7 @@ public class GroupingTypesWritePlatformServiceJpaRepositoryImpl implements Group
CommandProcessingResult commandProcessingResult = createGroupingType(command, GroupTypes.CENTER, centerId); CommandProcessingResult commandProcessingResult = createGroupingType(command, GroupTypes.CENTER, centerId);
this.businessEventNotifierService.notifyBusinessEventWasExecuted(BusinessEvent.CENTERS_CREATE, businessEventNotifierService.notifyBusinessEvent(new CentersCreateBusinessEvent(commandProcessingResult));
constructEntityMap(BusinessEntity.GROUP, commandProcessingResult));
return commandProcessingResult; return commandProcessingResult;
} }
@@ -308,8 +274,7 @@ public class GroupingTypesWritePlatformServiceJpaRepositoryImpl implements Group
CommandProcessingResult commandProcessingResult = createGroupingType(command, GroupTypes.GROUP, centerId); CommandProcessingResult commandProcessingResult = createGroupingType(command, GroupTypes.GROUP, centerId);
this.businessEventNotifierService.notifyBusinessEventWasExecuted(BusinessEvent.GROUPS_CREATE, businessEventNotifierService.notifyBusinessEvent(new GroupsCreateBusinessEvent(commandProcessingResult));
constructEntityMap(BusinessEntity.GROUP, commandProcessingResult));
return commandProcessingResult; return commandProcessingResult;
} }
@@ -605,7 +570,7 @@ public class GroupingTypesWritePlatformServiceJpaRepositoryImpl implements Group
.build(); .build();
} catch (final JpaSystemException | DataIntegrityViolationException dve) { } catch (final JpaSystemException | DataIntegrityViolationException dve) {
Throwable throwable = ExceptionUtils.getRootCause(dve.getCause()); Throwable throwable = ExceptionUtils.getRootCause(dve.getCause());
LOG.error("Error occured.", throwable); log.error("Error occured.", throwable);
throw new PlatformDataIntegrityException("error.msg.group.unknown.data.integrity.issue", throw new PlatformDataIntegrityException("error.msg.group.unknown.data.integrity.issue",
"Unknown data integrity issue with resource.", dve); "Unknown data integrity issue with resource.", dve);
} }
@@ -799,7 +764,7 @@ public class GroupingTypesWritePlatformServiceJpaRepositoryImpl implements Group
name); name);
} }
LOG.error("Error occured.", dve); log.error("Error occured.", dve);
throw new PlatformDataIntegrityException("error.msg.group.unknown.data.integrity.issue", throw new PlatformDataIntegrityException("error.msg.group.unknown.data.integrity.issue",
"Unknown data integrity issue with resource."); "Unknown data integrity issue with resource.");
} }
@@ -997,10 +962,4 @@ public class GroupingTypesWritePlatformServiceJpaRepositoryImpl implements Group
} }
} }
} }
private Map<BusinessEntity, Object> constructEntityMap(final BusinessEntity entityEvent, Object entity) {
Map<BusinessEntity, Object> map = new HashMap<>(1);
map.put(entityEvent, entity);
return map;
}
} }
@@ -26,11 +26,11 @@ import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
import java.util.Collection; import java.util.Collection;
import java.util.Date; import java.util.Date;
import java.util.HashMap;
import java.util.LinkedHashMap; import java.util.LinkedHashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Set; import java.util.Set;
import lombok.RequiredArgsConstructor;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.apache.fineract.accounting.journalentry.service.JournalEntryWritePlatformService; import org.apache.fineract.accounting.journalentry.service.JournalEntryWritePlatformService;
import org.apache.fineract.infrastructure.configuration.domain.ConfigurationDomainService; import org.apache.fineract.infrastructure.configuration.domain.ConfigurationDomainService;
@@ -58,8 +58,16 @@ import org.apache.fineract.portfolio.account.domain.AccountTransferTransaction;
import org.apache.fineract.portfolio.account.domain.StandingInstructionRepository; import org.apache.fineract.portfolio.account.domain.StandingInstructionRepository;
import org.apache.fineract.portfolio.account.domain.StandingInstructionStatus; import org.apache.fineract.portfolio.account.domain.StandingInstructionStatus;
import org.apache.fineract.portfolio.accountdetails.domain.AccountType; import org.apache.fineract.portfolio.accountdetails.domain.AccountType;
import org.apache.fineract.portfolio.businessevent.domain.BusinessEntity; import org.apache.fineract.portfolio.businessevent.domain.loan.transaction.LoanChargePaymentBusinessEvent;
import org.apache.fineract.portfolio.businessevent.domain.BusinessEvent; import org.apache.fineract.portfolio.businessevent.domain.loan.transaction.LoanCreditBalanceRefundBusinessEvent;
import org.apache.fineract.portfolio.businessevent.domain.loan.transaction.LoanForeClosureBusinessEvent;
import org.apache.fineract.portfolio.businessevent.domain.loan.transaction.LoanGoodwillCreditBusinessEvent;
import org.apache.fineract.portfolio.businessevent.domain.loan.transaction.LoanMakeRepaymentBusinessEvent;
import org.apache.fineract.portfolio.businessevent.domain.loan.transaction.LoanMerchantIssuedRefundBusinessEvent;
import org.apache.fineract.portfolio.businessevent.domain.loan.transaction.LoanPayoutRefundBusinessEvent;
import org.apache.fineract.portfolio.businessevent.domain.loan.transaction.LoanRecoveryPaymentBusinessEvent;
import org.apache.fineract.portfolio.businessevent.domain.loan.transaction.LoanRefundBusinessEvent;
import org.apache.fineract.portfolio.businessevent.domain.loan.transaction.LoanTransactionBusinessEvent;
import org.apache.fineract.portfolio.businessevent.service.BusinessEventNotifierService; import org.apache.fineract.portfolio.businessevent.service.BusinessEventNotifierService;
import org.apache.fineract.portfolio.client.domain.Client; import org.apache.fineract.portfolio.client.domain.Client;
import org.apache.fineract.portfolio.client.exception.ClientNotActiveException; import org.apache.fineract.portfolio.client.exception.ClientNotActiveException;
@@ -79,13 +87,13 @@ import org.apache.fineract.portfolio.repaymentwithpostdatedchecks.data.PostDated
import org.apache.fineract.portfolio.repaymentwithpostdatedchecks.domain.PostDatedChecks; import org.apache.fineract.portfolio.repaymentwithpostdatedchecks.domain.PostDatedChecks;
import org.apache.fineract.portfolio.repaymentwithpostdatedchecks.domain.PostDatedChecksRepository; import org.apache.fineract.portfolio.repaymentwithpostdatedchecks.domain.PostDatedChecksRepository;
import org.apache.fineract.useradministration.domain.AppUser; import org.apache.fineract.useradministration.domain.AppUser;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.dao.DataIntegrityViolationException; import org.springframework.dao.DataIntegrityViolationException;
import org.springframework.orm.jpa.JpaSystemException; import org.springframework.orm.jpa.JpaSystemException;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
@Service @Service
@RequiredArgsConstructor
public class LoanAccountDomainServiceJpa implements LoanAccountDomainService { public class LoanAccountDomainServiceJpa implements LoanAccountDomainService {
private final LoanAssembler loanAccountAssembler; private final LoanAssembler loanAccountAssembler;
@@ -100,7 +108,6 @@ public class LoanAccountDomainServiceJpa implements LoanAccountDomainService {
private final NoteRepository noteRepository; private final NoteRepository noteRepository;
private final AccountTransferRepository accountTransferRepository; private final AccountTransferRepository accountTransferRepository;
private final ApplicationCurrencyRepositoryWrapper applicationCurrencyRepository; private final ApplicationCurrencyRepositoryWrapper applicationCurrencyRepository;
private final LoanRepaymentScheduleInstallmentRepository repaymentScheduleInstallmentRepository;
private final LoanAccrualPlatformService loanAccrualPlatformService; private final LoanAccrualPlatformService loanAccrualPlatformService;
private final PlatformSecurityContext context; private final PlatformSecurityContext context;
private final BusinessEventNotifierService businessEventNotifierService; private final BusinessEventNotifierService businessEventNotifierService;
@@ -109,41 +116,6 @@ public class LoanAccountDomainServiceJpa implements LoanAccountDomainService {
private final PostDatedChecksRepository postDatedChecksRepository; private final PostDatedChecksRepository postDatedChecksRepository;
private final LoanCollateralManagementRepository loanCollateralManagementRepository; private final LoanCollateralManagementRepository loanCollateralManagementRepository;
@Autowired
public LoanAccountDomainServiceJpa(final LoanAssembler loanAccountAssembler, final LoanRepositoryWrapper loanRepositoryWrapper,
final LoanTransactionRepository loanTransactionRepository, final NoteRepository noteRepository,
final ConfigurationDomainService configurationDomainService, final HolidayRepository holidayRepository,
final WorkingDaysRepositoryWrapper workingDaysRepository,
final ApplicationCurrencyRepositoryWrapper applicationCurrencyRepositoryWrapper,
final JournalEntryWritePlatformService journalEntryWritePlatformService,
final AccountTransferRepository accountTransferRepository,
final ApplicationCurrencyRepositoryWrapper applicationCurrencyRepository,
final LoanRepaymentScheduleInstallmentRepository repaymentScheduleInstallmentRepository,
final LoanAccrualPlatformService loanAccrualPlatformService, final PlatformSecurityContext context,
final BusinessEventNotifierService businessEventNotifierService, final LoanUtilService loanUtilService,
final StandingInstructionRepository standingInstructionRepository, final PostDatedChecksRepository postDatedChecksRepository,
final LoanCollateralManagementRepository loanCollateralManagementRepository) {
this.loanAccountAssembler = loanAccountAssembler;
this.loanTransactionRepository = loanTransactionRepository;
this.noteRepository = noteRepository;
this.configurationDomainService = configurationDomainService;
this.holidayRepository = holidayRepository;
this.workingDaysRepository = workingDaysRepository;
this.applicationCurrencyRepositoryWrapper = applicationCurrencyRepositoryWrapper;
this.journalEntryWritePlatformService = journalEntryWritePlatformService;
this.accountTransferRepository = accountTransferRepository;
this.applicationCurrencyRepository = applicationCurrencyRepository;
this.repaymentScheduleInstallmentRepository = repaymentScheduleInstallmentRepository;
this.loanAccrualPlatformService = loanAccrualPlatformService;
this.context = context;
this.businessEventNotifierService = businessEventNotifierService;
this.loanUtilService = loanUtilService;
this.standingInstructionRepository = standingInstructionRepository;
this.postDatedChecksRepository = postDatedChecksRepository;
this.loanCollateralManagementRepository = loanCollateralManagementRepository;
this.loanRepositoryWrapper = loanRepositoryWrapper;
}
@Transactional @Transactional
@Override @Override
public LoanTransaction makeRepayment(final LoanTransactionType repaymentTransactionType, final Loan loan, public LoanTransaction makeRepayment(final LoanTransactionType repaymentTransactionType, final Loan loan,
@@ -179,10 +151,6 @@ public class LoanAccountDomainServiceJpa implements LoanAccountDomainService {
AppUser currentUser = getAppUserIfPresent(); AppUser currentUser = getAppUserIfPresent();
checkClientOrGroupActive(loan); checkClientOrGroupActive(loan);
BusinessEvent repaymentTypeEvent = getRepaymentTypeBusinessEvent(repaymentTransactionType, isRecoveryRepayment);
this.businessEventNotifierService.notifyBusinessEventToBeExecuted(repaymentTypeEvent,
constructEntityMap(BusinessEntity.LOAN, loan));
// TODO: Is it required to validate transaction date with meeting dates // TODO: Is it required to validate transaction date with meeting dates
// if repayments is synced with meeting? // if repayments is synced with meeting?
/* /*
@@ -245,8 +213,9 @@ public class LoanAccountDomainServiceJpa implements LoanAccountDomainService {
recalculateAccruals(loan); recalculateAccruals(loan);
this.businessEventNotifierService.notifyBusinessEventWasExecuted(repaymentTypeEvent, LoanTransactionBusinessEvent repaymentEvent = getRepaymentTypeBusinessEvent(repaymentTransactionType, isRecoveryRepayment,
constructEntityMap(BusinessEntity.LOAN_TRANSACTION, newRepaymentTransaction)); newRepaymentTransaction);
businessEventNotifierService.notifyBusinessEvent(repaymentEvent);
// disable all active standing orders linked to this loan if status // disable all active standing orders linked to this loan if status
// changes to closed // changes to closed
@@ -287,20 +256,21 @@ public class LoanAccountDomainServiceJpa implements LoanAccountDomainService {
return newRepaymentTransaction; return newRepaymentTransaction;
} }
private BusinessEvent getRepaymentTypeBusinessEvent(LoanTransactionType repaymentTransactionType, boolean isRecoveryRepayment) { private LoanTransactionBusinessEvent getRepaymentTypeBusinessEvent(LoanTransactionType repaymentTransactionType,
BusinessEvent repaymentTypeEvent = null; boolean isRecoveryRepayment, LoanTransaction transaction) {
LoanTransactionBusinessEvent repaymentEvent = null;
if (repaymentTransactionType.isRepayment()) { if (repaymentTransactionType.isRepayment()) {
repaymentTypeEvent = BusinessEvent.LOAN_MAKE_REPAYMENT; repaymentEvent = new LoanMakeRepaymentBusinessEvent(transaction);
} else if (repaymentTransactionType.isMerchantIssuedRefund()) { } else if (repaymentTransactionType.isMerchantIssuedRefund()) {
repaymentTypeEvent = BusinessEvent.LOAN_MERCHANT_ISSUED_REFUND; repaymentEvent = new LoanMerchantIssuedRefundBusinessEvent(transaction);
} else if (repaymentTransactionType.isPayoutRefund()) { } else if (repaymentTransactionType.isPayoutRefund()) {
repaymentTypeEvent = BusinessEvent.LOAN_PAYOUT_REFUND; repaymentEvent = new LoanPayoutRefundBusinessEvent(transaction);
} else if (repaymentTransactionType.isGoodwillCredit()) { } else if (repaymentTransactionType.isGoodwillCredit()) {
repaymentTypeEvent = BusinessEvent.LOAN_GOODWILL_CREDIT; repaymentEvent = new LoanGoodwillCreditBusinessEvent(transaction);
} else if (isRecoveryRepayment) { } else if (isRecoveryRepayment) {
repaymentTypeEvent = BusinessEvent.LOAN_RECOVERY_PAYMENT; repaymentEvent = new LoanRecoveryPaymentBusinessEvent(transaction);
} }
return repaymentTypeEvent; return repaymentEvent;
} }
private void saveLoanTransactionWithDataIntegrityViolationChecks(LoanTransaction newRepaymentTransaction) { private void saveLoanTransactionWithDataIntegrityViolationChecks(LoanTransaction newRepaymentTransaction) {
@@ -364,8 +334,6 @@ public class LoanAccountDomainServiceJpa implements LoanAccountDomainService {
AppUser currentUser = getAppUserIfPresent(); AppUser currentUser = getAppUserIfPresent();
boolean isAccountTransfer = true; boolean isAccountTransfer = true;
checkClientOrGroupActive(loan); checkClientOrGroupActive(loan);
this.businessEventNotifierService.notifyBusinessEventToBeExecuted(BusinessEvent.LOAN_CHARGE_PAYMENT,
constructEntityMap(BusinessEntity.LOAN, loan));
final List<Long> existingTransactionIds = new ArrayList<>(); final List<Long> existingTransactionIds = new ArrayList<>();
final List<Long> existingReversedTransactionIds = new ArrayList<>(); final List<Long> existingReversedTransactionIds = new ArrayList<>();
@@ -400,8 +368,7 @@ public class LoanAccountDomainServiceJpa implements LoanAccountDomainService {
postJournalEntries(loan, existingTransactionIds, existingReversedTransactionIds, isAccountTransfer); postJournalEntries(loan, existingTransactionIds, existingReversedTransactionIds, isAccountTransfer);
recalculateAccruals(loan); recalculateAccruals(loan);
this.businessEventNotifierService.notifyBusinessEventWasExecuted(BusinessEvent.LOAN_CHARGE_PAYMENT, businessEventNotifierService.notifyBusinessEvent(new LoanChargePaymentBusinessEvent(newPaymentTransaction));
constructEntityMap(BusinessEntity.LOAN_TRANSACTION, newPaymentTransaction));
return newPaymentTransaction; return newPaymentTransaction;
} }
@@ -450,8 +417,6 @@ public class LoanAccountDomainServiceJpa implements LoanAccountDomainService {
boolean isAccountTransfer = true; boolean isAccountTransfer = true;
final Loan loan = this.loanAccountAssembler.assembleFrom(accountId); final Loan loan = this.loanAccountAssembler.assembleFrom(accountId);
checkClientOrGroupActive(loan); checkClientOrGroupActive(loan);
this.businessEventNotifierService.notifyBusinessEventToBeExecuted(BusinessEvent.LOAN_REFUND,
constructEntityMap(BusinessEntity.LOAN, loan));
final List<Long> existingTransactionIds = new ArrayList<>(); final List<Long> existingTransactionIds = new ArrayList<>();
final List<Long> existingReversedTransactionIds = new ArrayList<>(); final List<Long> existingReversedTransactionIds = new ArrayList<>();
@@ -476,8 +441,7 @@ public class LoanAccountDomainServiceJpa implements LoanAccountDomainService {
} }
postJournalEntries(loan, existingTransactionIds, existingReversedTransactionIds, isAccountTransfer); postJournalEntries(loan, existingTransactionIds, existingReversedTransactionIds, isAccountTransfer);
this.businessEventNotifierService.notifyBusinessEventWasExecuted(BusinessEvent.LOAN_REFUND, businessEventNotifierService.notifyBusinessEvent(new LoanRefundBusinessEvent(newRefundTransaction));
constructEntityMap(BusinessEntity.LOAN_TRANSACTION, newRefundTransaction));
builderResult.withEntityId(newRefundTransaction.getId()).withOfficeId(loan.getOfficeId()).withClientId(loan.getClientId()) builderResult.withEntityId(newRefundTransaction.getId()).withOfficeId(loan.getOfficeId()).withClientId(loan.getClientId())
.withGroupId(loan.getGroupId()); .withGroupId(loan.getGroupId());
@@ -646,8 +610,6 @@ public class LoanAccountDomainServiceJpa implements LoanAccountDomainService {
public CommandProcessingResultBuilder creditBalanceRefund(Long loanId, LocalDate transactionDate, BigDecimal transactionAmount, public CommandProcessingResultBuilder creditBalanceRefund(Long loanId, LocalDate transactionDate, BigDecimal transactionAmount,
String noteText, String externalId) { String noteText, String externalId) {
final Loan loan = this.loanAccountAssembler.assembleFrom(loanId); final Loan loan = this.loanAccountAssembler.assembleFrom(loanId);
this.businessEventNotifierService.notifyBusinessEventToBeExecuted(BusinessEvent.LOAN_CREDIT_BALANCE_REFUND,
constructEntityMap(BusinessEntity.LOAN, loan));
final List<Long> existingTransactionIds = new ArrayList<>(); final List<Long> existingTransactionIds = new ArrayList<>();
final List<Long> existingReversedTransactionIds = new ArrayList<>(); final List<Long> existingReversedTransactionIds = new ArrayList<>();
AppUser currentUser = getAppUserIfPresent(); AppUser currentUser = getAppUserIfPresent();
@@ -668,8 +630,7 @@ public class LoanAccountDomainServiceJpa implements LoanAccountDomainService {
postJournalEntries(loan, existingTransactionIds, existingReversedTransactionIds, false); postJournalEntries(loan, existingTransactionIds, existingReversedTransactionIds, false);
recalculateAccruals(loan); recalculateAccruals(loan);
this.businessEventNotifierService.notifyBusinessEventWasExecuted(BusinessEvent.LOAN_CREDIT_BALANCE_REFUND, businessEventNotifierService.notifyBusinessEvent(new LoanCreditBalanceRefundBusinessEvent(newCreditBalanceRefundTransaction));
constructEntityMap(BusinessEntity.LOAN_TRANSACTION, newCreditBalanceRefundTransaction));
return new CommandProcessingResultBuilder().withEntityId(newCreditBalanceRefundTransaction.getId()) // return new CommandProcessingResultBuilder().withEntityId(newCreditBalanceRefundTransaction.getId()) //
.withOfficeId(loan.getOfficeId()) // .withOfficeId(loan.getOfficeId()) //
@@ -682,8 +643,6 @@ public class LoanAccountDomainServiceJpa implements LoanAccountDomainService {
BigDecimal transactionAmount, PaymentDetail paymentDetail, String noteText, String txnExternalId) { BigDecimal transactionAmount, PaymentDetail paymentDetail, String noteText, String txnExternalId) {
final Loan loan = this.loanAccountAssembler.assembleFrom(accountId); final Loan loan = this.loanAccountAssembler.assembleFrom(accountId);
checkClientOrGroupActive(loan); checkClientOrGroupActive(loan);
this.businessEventNotifierService.notifyBusinessEventToBeExecuted(BusinessEvent.LOAN_REFUND,
constructEntityMap(BusinessEntity.LOAN, loan));
final List<Long> existingTransactionIds = new ArrayList<>(); final List<Long> existingTransactionIds = new ArrayList<>();
final List<Long> existingReversedTransactionIds = new ArrayList<>(); final List<Long> existingReversedTransactionIds = new ArrayList<>();
AppUser currentUser = getAppUserIfPresent(); AppUser currentUser = getAppUserIfPresent();
@@ -709,8 +668,7 @@ public class LoanAccountDomainServiceJpa implements LoanAccountDomainService {
postJournalEntries(loan, existingTransactionIds, existingReversedTransactionIds, false); postJournalEntries(loan, existingTransactionIds, existingReversedTransactionIds, false);
recalculateAccruals(loan); recalculateAccruals(loan);
this.businessEventNotifierService.notifyBusinessEventWasExecuted(BusinessEvent.LOAN_REFUND, businessEventNotifierService.notifyBusinessEvent(new LoanRefundBusinessEvent(newRefundTransaction));
constructEntityMap(BusinessEntity.LOAN_TRANSACTION, newRefundTransaction));
builderResult.withEntityId(newRefundTransaction.getId()).withOfficeId(loan.getOfficeId()).withClientId(loan.getClientId()) builderResult.withEntityId(newRefundTransaction.getId()).withOfficeId(loan.getOfficeId()).withClientId(loan.getClientId())
.withGroupId(loan.getGroupId()); .withGroupId(loan.getGroupId());
@@ -720,8 +678,6 @@ public class LoanAccountDomainServiceJpa implements LoanAccountDomainService {
@Override @Override
public Map<String, Object> foreCloseLoan(final Loan loan, final LocalDate foreClosureDate, final String noteText) { public Map<String, Object> foreCloseLoan(final Loan loan, final LocalDate foreClosureDate, final String noteText) {
this.businessEventNotifierService.notifyBusinessEventToBeExecuted(BusinessEvent.LOAN_FORECLOSURE,
constructEntityMap(BusinessEntity.LOAN, loan));
MonetaryCurrency currency = loan.getCurrency(); MonetaryCurrency currency = loan.getCurrency();
LocalDateTime createdDate = DateUtils.getLocalDateTimeOfTenant(); LocalDateTime createdDate = DateUtils.getLocalDateTimeOfTenant();
final Map<String, Object> changes = new LinkedHashMap<>(); final Map<String, Object> changes = new LinkedHashMap<>();
@@ -820,18 +776,11 @@ public class LoanAccountDomainServiceJpa implements LoanAccountDomainService {
} }
postJournalEntries(loan, existingTransactionIds, existingReversedTransactionIds, false); postJournalEntries(loan, existingTransactionIds, existingReversedTransactionIds, false);
this.businessEventNotifierService.notifyBusinessEventWasExecuted(BusinessEvent.LOAN_FORECLOSURE, businessEventNotifierService.notifyBusinessEvent(new LoanForeClosureBusinessEvent(payment));
constructEntityMap(BusinessEntity.LOAN_TRANSACTION, payment));
return changes; return changes;
} }
private Map<BusinessEntity, Object> constructEntityMap(final BusinessEntity entityEvent, Object entity) {
Map<BusinessEntity, Object> map = new HashMap<>(1);
map.put(entityEvent, entity);
return map;
}
@Override @Override
@Transactional @Transactional
public void disableStandingInstructionsLinkedToClosedLoan(Loan loan) { public void disableStandingInstructionsLinkedToClosedLoan(Loan loan) {
@@ -40,8 +40,13 @@ import org.apache.fineract.portfolio.account.domain.AccountTransferDetails;
import org.apache.fineract.portfolio.account.domain.AccountTransferType; import org.apache.fineract.portfolio.account.domain.AccountTransferType;
import org.apache.fineract.portfolio.account.service.AccountTransfersWritePlatformService; import org.apache.fineract.portfolio.account.service.AccountTransfersWritePlatformService;
import org.apache.fineract.portfolio.businessevent.BusinessEventListener; import org.apache.fineract.portfolio.businessevent.BusinessEventListener;
import org.apache.fineract.portfolio.businessevent.domain.BusinessEntity; import org.apache.fineract.portfolio.businessevent.domain.loan.LoanAdjustTransactionBusinessEvent;
import org.apache.fineract.portfolio.businessevent.domain.BusinessEvent; import org.apache.fineract.portfolio.businessevent.domain.loan.LoanApprovedBusinessEvent;
import org.apache.fineract.portfolio.businessevent.domain.loan.LoanUndoApprovalBusinessEvent;
import org.apache.fineract.portfolio.businessevent.domain.loan.LoanUndoDisbursalBusinessEvent;
import org.apache.fineract.portfolio.businessevent.domain.loan.transaction.LoanMakeRepaymentBusinessEvent;
import org.apache.fineract.portfolio.businessevent.domain.loan.transaction.LoanUndoWrittenOffBusinessEvent;
import org.apache.fineract.portfolio.businessevent.domain.loan.transaction.LoanWrittenOffBusinessEvent;
import org.apache.fineract.portfolio.businessevent.service.BusinessEventNotifierService; import org.apache.fineract.portfolio.businessevent.service.BusinessEventNotifierService;
import org.apache.fineract.portfolio.loanaccount.domain.Loan; import org.apache.fineract.portfolio.loanaccount.domain.Loan;
import org.apache.fineract.portfolio.loanaccount.domain.LoanTransaction; import org.apache.fineract.portfolio.loanaccount.domain.LoanTransaction;
@@ -78,18 +83,14 @@ public class GuarantorDomainServiceImpl implements GuarantorDomainService {
@PostConstruct @PostConstruct
public void addListeners() { public void addListeners() {
this.businessEventNotifierService.addBusinessEventPostListeners(BusinessEvent.LOAN_APPROVED, new ValidateOnBusinessEvent()); businessEventNotifierService.addBusinessEventListener(LoanApprovedBusinessEvent.class, new ValidateOnBusinessEvent());
this.businessEventNotifierService.addBusinessEventPostListeners(BusinessEvent.LOAN_APPROVED, new HoldFundsOnBusinessEvent()); businessEventNotifierService.addBusinessEventListener(LoanApprovedBusinessEvent.class, new HoldFundsOnBusinessEvent());
this.businessEventNotifierService.addBusinessEventPostListeners(BusinessEvent.LOAN_UNDO_APPROVAL, new UndoAllFundTransactions()); businessEventNotifierService.addBusinessEventListener(LoanUndoApprovalBusinessEvent.class, new UndoAllFundTransactions());
this.businessEventNotifierService.addBusinessEventPostListeners(BusinessEvent.LOAN_UNDO_DISBURSAL, businessEventNotifierService.addBusinessEventListener(LoanUndoDisbursalBusinessEvent.class, new ReverseAllFundsOnBusinessEvent());
new ReverseAllFundsOnBusinessEvent()); businessEventNotifierService.addBusinessEventListener(LoanAdjustTransactionBusinessEvent.class, new AdjustFundsOnBusinessEvent());
this.businessEventNotifierService.addBusinessEventPostListeners(BusinessEvent.LOAN_ADJUST_TRANSACTION, businessEventNotifierService.addBusinessEventListener(LoanMakeRepaymentBusinessEvent.class, new ReleaseFundsOnBusinessEvent());
new AdjustFundsOnBusinessEvent()); businessEventNotifierService.addBusinessEventListener(LoanWrittenOffBusinessEvent.class, new ReleaseAllFunds());
this.businessEventNotifierService.addBusinessEventPostListeners(BusinessEvent.LOAN_MAKE_REPAYMENT, businessEventNotifierService.addBusinessEventListener(LoanUndoWrittenOffBusinessEvent.class, new ReverseFundsOnBusinessEvent());
new ReleaseFundsOnBusinessEvent());
this.businessEventNotifierService.addBusinessEventPostListeners(BusinessEvent.LOAN_WRITTEN_OFF, new ReleaseAllFunds());
this.businessEventNotifierService.addBusinessEventPostListeners(BusinessEvent.LOAN_UNDO_WRITTEN_OFF,
new ReverseFundsOnBusinessEvent());
} }
@Override @Override
@@ -509,138 +510,91 @@ public class GuarantorDomainServiceImpl implements GuarantorDomainService {
} }
} }
private class ValidateOnBusinessEvent implements BusinessEventListener { private class ValidateOnBusinessEvent implements BusinessEventListener<LoanApprovedBusinessEvent> {
@Override @Override
public void businessEventToBeExecuted(@SuppressWarnings("unused") Map<BusinessEntity, Object> businessEventEntity) {} public void onBusinessEvent(LoanApprovedBusinessEvent event) {
Loan loan = event.get();
@Override validateGuarantorBusinessRules(loan);
public void businessEventWasExecuted(Map<BusinessEntity, Object> businessEventEntity) {
Object entity = businessEventEntity.get(BusinessEntity.LOAN);
if (entity instanceof Loan) {
Loan loan = (Loan) entity;
validateGuarantorBusinessRules(loan);
}
} }
} }
private class HoldFundsOnBusinessEvent implements BusinessEventListener { private class HoldFundsOnBusinessEvent implements BusinessEventListener<LoanApprovedBusinessEvent> {
@Override @Override
public void businessEventToBeExecuted(@SuppressWarnings("unused") Map<BusinessEntity, Object> businessEventEntity) {} public void onBusinessEvent(LoanApprovedBusinessEvent event) {
Loan loan = event.get();
@Override holdGuarantorFunds(loan);
public void businessEventWasExecuted(Map<BusinessEntity, Object> businessEventEntity) {
Object entity = businessEventEntity.get(BusinessEntity.LOAN);
if (entity instanceof Loan) {
Loan loan = (Loan) entity;
holdGuarantorFunds(loan);
}
} }
} }
private class ReleaseFundsOnBusinessEvent implements BusinessEventListener { private class ReleaseFundsOnBusinessEvent implements BusinessEventListener<LoanMakeRepaymentBusinessEvent> {
@Override @Override
public void businessEventToBeExecuted(@SuppressWarnings("unused") Map<BusinessEntity, Object> businessEventEntity) {} public void onBusinessEvent(LoanMakeRepaymentBusinessEvent event) {
LoanTransaction loanTransaction = event.get();
@Override if (releaseLoanIds.containsKey(loanTransaction.getLoan().getId())) {
public void businessEventWasExecuted(Map<BusinessEntity, Object> businessEventEntity) { completeGuarantorFund(loanTransaction);
Object entity = businessEventEntity.get(BusinessEntity.LOAN_TRANSACTION); } else {
if (entity instanceof LoanTransaction) {
LoanTransaction loanTransaction = (LoanTransaction) entity;
if (releaseLoanIds.containsKey(loanTransaction.getLoan().getId())) {
completeGuarantorFund(loanTransaction);
} else {
releaseGuarantorFunds(loanTransaction);
}
}
}
}
private class ReverseFundsOnBusinessEvent implements BusinessEventListener {
@Override
public void businessEventToBeExecuted(@SuppressWarnings("unused") Map<BusinessEntity, Object> businessEventEntity) {}
@Override
public void businessEventWasExecuted(Map<BusinessEntity, Object> businessEventEntity) {
Object entity = businessEventEntity.get(BusinessEntity.LOAN_TRANSACTION);
if (entity instanceof LoanTransaction) {
LoanTransaction loanTransaction = (LoanTransaction) entity;
List<Long> reersedTransactions = new ArrayList<>(1);
reersedTransactions.add(loanTransaction.getId());
reverseTransaction(reersedTransactions);
}
}
}
private class AdjustFundsOnBusinessEvent implements BusinessEventListener {
@Override
public void businessEventToBeExecuted(@SuppressWarnings("unused") Map<BusinessEntity, Object> businessEventEntity) {}
@Override
public void businessEventWasExecuted(Map<BusinessEntity, Object> businessEventEntity) {
Object entity = businessEventEntity.get(BusinessEntity.LOAN_ADJUSTED_TRANSACTION);
if (entity instanceof LoanTransaction) {
LoanTransaction loanTransaction = (LoanTransaction) entity;
List<Long> reersedTransactions = new ArrayList<>(1);
reersedTransactions.add(loanTransaction.getId());
reverseTransaction(reersedTransactions);
}
Object transactionentity = businessEventEntity.get(BusinessEntity.LOAN_TRANSACTION);
if (transactionentity != null && transactionentity instanceof LoanTransaction) {
LoanTransaction loanTransaction = (LoanTransaction) transactionentity;
releaseGuarantorFunds(loanTransaction); releaseGuarantorFunds(loanTransaction);
} }
} }
} }
private class ReverseAllFundsOnBusinessEvent implements BusinessEventListener { private class ReverseFundsOnBusinessEvent implements BusinessEventListener<LoanUndoWrittenOffBusinessEvent> {
@Override @Override
public void businessEventToBeExecuted(@SuppressWarnings("unused") Map<BusinessEntity, Object> businessEventEntity) {} public void onBusinessEvent(LoanUndoWrittenOffBusinessEvent event) {
LoanTransaction loanTransaction = event.get();
List<Long> reversedTransactions = new ArrayList<>();
reversedTransactions.add(loanTransaction.getId());
reverseTransaction(reversedTransactions);
}
}
private class AdjustFundsOnBusinessEvent implements BusinessEventListener<LoanAdjustTransactionBusinessEvent> {
@Override @Override
public void businessEventWasExecuted(Map<BusinessEntity, Object> businessEventEntity) { public void onBusinessEvent(LoanAdjustTransactionBusinessEvent event) {
Object entity = businessEventEntity.get(BusinessEntity.LOAN); LoanAdjustTransactionBusinessEvent.Data eventData = event.get();
if (entity instanceof Loan) {
Loan loan = (Loan) entity; LoanTransaction loanTransaction = eventData.getTransactionToAdjust();
List<Long> reersedTransactions = new ArrayList<>(1); List<Long> reersedTransactions = new ArrayList<>(1);
reersedTransactions.addAll(loan.findExistingTransactionIds()); reersedTransactions.add(loanTransaction.getId());
reverseTransaction(reersedTransactions); reverseTransaction(reersedTransactions);
LoanTransaction newTransaction = event.get().getNewTransactionDetail();
if (newTransaction != null) {
releaseGuarantorFunds(newTransaction);
} }
} }
} }
private class UndoAllFundTransactions implements BusinessEventListener { private class ReverseAllFundsOnBusinessEvent implements BusinessEventListener<LoanUndoDisbursalBusinessEvent> {
@Override @Override
public void businessEventToBeExecuted(@SuppressWarnings("unused") Map<BusinessEntity, Object> businessEventEntity) {} public void onBusinessEvent(LoanUndoDisbursalBusinessEvent event) {
Loan loan = event.get();
@Override List<Long> reversedTransactions = new ArrayList<>(loan.findExistingTransactionIds());
public void businessEventWasExecuted(Map<BusinessEntity, Object> businessEventEntity) { reverseTransaction(reversedTransactions);
Object entity = businessEventEntity.get(BusinessEntity.LOAN);
if (entity instanceof Loan) {
Loan loan = (Loan) entity;
reverseAllFundTransaction(loan);
}
} }
} }
private class ReleaseAllFunds implements BusinessEventListener { private class UndoAllFundTransactions implements BusinessEventListener<LoanUndoApprovalBusinessEvent> {
@Override @Override
public void businessEventToBeExecuted(@SuppressWarnings("unused") Map<BusinessEntity, Object> businessEventEntity) {} public void onBusinessEvent(LoanUndoApprovalBusinessEvent event) {
Loan loan = event.get();
reverseAllFundTransaction(loan);
}
}
private class ReleaseAllFunds implements BusinessEventListener<LoanWrittenOffBusinessEvent> {
@Override @Override
public void businessEventWasExecuted(Map<BusinessEntity, Object> businessEventEntity) { public void onBusinessEvent(LoanWrittenOffBusinessEvent event) {
Object entity = businessEventEntity.get(BusinessEntity.LOAN_TRANSACTION); LoanTransaction loanTransaction = event.get();
if (entity instanceof LoanTransaction) { releaseAllGuarantors(loanTransaction);
LoanTransaction loanTransaction = (LoanTransaction) entity;
releaseAllGuarantors(loanTransaction);
}
} }
} }
@@ -67,8 +67,10 @@ import org.apache.fineract.portfolio.account.domain.AccountAssociationType;
import org.apache.fineract.portfolio.account.domain.AccountAssociations; import org.apache.fineract.portfolio.account.domain.AccountAssociations;
import org.apache.fineract.portfolio.account.domain.AccountAssociationsRepository; import org.apache.fineract.portfolio.account.domain.AccountAssociationsRepository;
import org.apache.fineract.portfolio.accountdetails.domain.AccountType; import org.apache.fineract.portfolio.accountdetails.domain.AccountType;
import org.apache.fineract.portfolio.businessevent.domain.BusinessEntity; import org.apache.fineract.portfolio.businessevent.domain.loan.LoanApprovedBusinessEvent;
import org.apache.fineract.portfolio.businessevent.domain.BusinessEvent; import org.apache.fineract.portfolio.businessevent.domain.loan.LoanCreatedBusinessEvent;
import org.apache.fineract.portfolio.businessevent.domain.loan.LoanRejectedBusinessEvent;
import org.apache.fineract.portfolio.businessevent.domain.loan.LoanUndoApprovalBusinessEvent;
import org.apache.fineract.portfolio.businessevent.service.BusinessEventNotifierService; import org.apache.fineract.portfolio.businessevent.service.BusinessEventNotifierService;
import org.apache.fineract.portfolio.calendar.domain.Calendar; import org.apache.fineract.portfolio.calendar.domain.Calendar;
import org.apache.fineract.portfolio.calendar.domain.CalendarEntityType; import org.apache.fineract.portfolio.calendar.domain.CalendarEntityType;
@@ -588,8 +590,7 @@ public class LoanApplicationWritePlatformServiceJpaRepositoryImpl implements Loa
StatusEnum.CREATE.getCode().longValue(), EntityTables.LOAN.getForeignKeyColumnNameOnDatatable(), StatusEnum.CREATE.getCode().longValue(), EntityTables.LOAN.getForeignKeyColumnNameOnDatatable(),
newLoanApplication.productId()); newLoanApplication.productId());
this.businessEventNotifierService.notifyBusinessEventWasExecuted(BusinessEvent.LOAN_CREATE, businessEventNotifierService.notifyBusinessEvent(new LoanCreatedBusinessEvent(newLoanApplication));
constructEntityMap(BusinessEntity.LOAN, newLoanApplication));
return new CommandProcessingResultBuilder() // return new CommandProcessingResultBuilder() //
.withCommandId(command.commandId()) // .withCommandId(command.commandId()) //
@@ -1476,8 +1477,7 @@ public class LoanApplicationWritePlatformServiceJpaRepositoryImpl implements Loa
this.noteRepository.save(note); this.noteRepository.save(note);
} }
this.businessEventNotifierService.notifyBusinessEventWasExecuted(BusinessEvent.LOAN_APPROVED, businessEventNotifierService.notifyBusinessEvent(new LoanApprovedBusinessEvent(loan));
constructEntityMap(BusinessEntity.LOAN, loan));
} }
return new CommandProcessingResultBuilder() // return new CommandProcessingResultBuilder() //
@@ -1555,8 +1555,7 @@ public class LoanApplicationWritePlatformServiceJpaRepositoryImpl implements Loa
final Note note = Note.loanNote(loan, noteText); final Note note = Note.loanNote(loan, noteText);
this.noteRepository.save(note); this.noteRepository.save(note);
} }
this.businessEventNotifierService.notifyBusinessEventWasExecuted(BusinessEvent.LOAN_UNDO_APPROVAL, businessEventNotifierService.notifyBusinessEvent(new LoanUndoApprovalBusinessEvent(loan));
constructEntityMap(BusinessEntity.LOAN, loan));
} }
return new CommandProcessingResultBuilder() // return new CommandProcessingResultBuilder() //
@@ -1626,8 +1625,7 @@ public class LoanApplicationWritePlatformServiceJpaRepositoryImpl implements Loa
this.noteRepository.save(note); this.noteRepository.save(note);
} }
} }
this.businessEventNotifierService.notifyBusinessEventWasExecuted(BusinessEvent.LOAN_REJECTED, businessEventNotifierService.notifyBusinessEvent(new LoanRejectedBusinessEvent(loan));
constructEntityMap(BusinessEntity.LOAN, loan));
return new CommandProcessingResultBuilder() // return new CommandProcessingResultBuilder() //
.withCommandId(command.commandId()) // .withCommandId(command.commandId()) //
.withEntityId(loan.getId()) // .withEntityId(loan.getId()) //
@@ -1762,12 +1760,6 @@ public class LoanApplicationWritePlatformServiceJpaRepositoryImpl implements Loa
return user; return user;
} }
private Map<BusinessEntity, Object> constructEntityMap(final BusinessEntity entityEvent, Object entity) {
Map<BusinessEntity, Object> map = new HashMap<>(1);
map.put(entityEvent, entity);
return map;
}
private void officeSpecificLoanProductValidation(final Long productId, final Long officeId) { private void officeSpecificLoanProductValidation(final Long productId, final Long officeId) {
final GlobalConfigurationProperty restrictToUserOfficeProperty = this.globalConfigurationRepository final GlobalConfigurationProperty restrictToUserOfficeProperty = this.globalConfigurationRepository
.findOneByNameWithNotFoundDetection(FineractEntityAccessConstants.GLOBAL_CONFIG_FOR_OFFICE_SPECIFIC_PRODUCTS); .findOneByNameWithNotFoundDetection(FineractEntityAccessConstants.GLOBAL_CONFIG_FOR_OFFICE_SPECIFIC_PRODUCTS);
@@ -28,6 +28,8 @@ import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import javax.annotation.PostConstruct; import javax.annotation.PostConstruct;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.apache.fineract.infrastructure.core.domain.JdbcSupport; import org.apache.fineract.infrastructure.core.domain.JdbcSupport;
import org.apache.fineract.infrastructure.core.service.DateUtils; import org.apache.fineract.infrastructure.core.service.DateUtils;
import org.apache.fineract.infrastructure.core.service.ThreadLocalContextUtil; import org.apache.fineract.infrastructure.core.service.ThreadLocalContextUtil;
@@ -35,8 +37,17 @@ import org.apache.fineract.infrastructure.core.service.database.DatabaseSpecific
import org.apache.fineract.infrastructure.jobs.annotation.CronTarget; import org.apache.fineract.infrastructure.jobs.annotation.CronTarget;
import org.apache.fineract.infrastructure.jobs.service.JobName; import org.apache.fineract.infrastructure.jobs.service.JobName;
import org.apache.fineract.portfolio.businessevent.BusinessEventListener; import org.apache.fineract.portfolio.businessevent.BusinessEventListener;
import org.apache.fineract.portfolio.businessevent.domain.BusinessEntity; import org.apache.fineract.portfolio.businessevent.domain.loan.LoanAdjustTransactionBusinessEvent;
import org.apache.fineract.portfolio.businessevent.domain.BusinessEvent; import org.apache.fineract.portfolio.businessevent.domain.loan.LoanApplyOverdueChargeBusinessEvent;
import org.apache.fineract.portfolio.businessevent.domain.loan.LoanDisbursalBusinessEvent;
import org.apache.fineract.portfolio.businessevent.domain.loan.charge.LoanAddChargeBusinessEvent;
import org.apache.fineract.portfolio.businessevent.domain.loan.charge.LoanWaiveChargeBusinessEvent;
import org.apache.fineract.portfolio.businessevent.domain.loan.transaction.LoanChargePaymentBusinessEvent;
import org.apache.fineract.portfolio.businessevent.domain.loan.transaction.LoanForeClosureBusinessEvent;
import org.apache.fineract.portfolio.businessevent.domain.loan.transaction.LoanMakeRepaymentBusinessEvent;
import org.apache.fineract.portfolio.businessevent.domain.loan.transaction.LoanRefundBusinessEvent;
import org.apache.fineract.portfolio.businessevent.domain.loan.transaction.LoanUndoWrittenOffBusinessEvent;
import org.apache.fineract.portfolio.businessevent.domain.loan.transaction.LoanWaiveInterestBusinessEvent;
import org.apache.fineract.portfolio.businessevent.service.BusinessEventNotifierService; import org.apache.fineract.portfolio.businessevent.service.BusinessEventNotifierService;
import org.apache.fineract.portfolio.loanaccount.domain.Loan; import org.apache.fineract.portfolio.loanaccount.domain.Loan;
import org.apache.fineract.portfolio.loanaccount.domain.LoanCharge; import org.apache.fineract.portfolio.loanaccount.domain.LoanCharge;
@@ -44,9 +55,6 @@ import org.apache.fineract.portfolio.loanaccount.domain.LoanRepaymentScheduleIns
import org.apache.fineract.portfolio.loanaccount.domain.LoanSummary; import org.apache.fineract.portfolio.loanaccount.domain.LoanSummary;
import org.apache.fineract.portfolio.loanaccount.domain.LoanTransaction; import org.apache.fineract.portfolio.loanaccount.domain.LoanTransaction;
import org.apache.fineract.portfolio.loanaccount.loanschedule.data.LoanSchedulePeriodData; import org.apache.fineract.portfolio.loanaccount.loanschedule.data.LoanSchedulePeriodData;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.dao.DataAccessException; import org.springframework.dao.DataAccessException;
import org.springframework.jdbc.core.JdbcTemplate; import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.jdbc.core.ResultSetExtractor; import org.springframework.jdbc.core.ResultSetExtractor;
@@ -54,35 +62,31 @@ import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
@Service @Service
public class LoanArrearsAgingServiceImpl implements LoanArrearsAgingService, BusinessEventListener { @Slf4j
@RequiredArgsConstructor
public class LoanArrearsAgingServiceImpl implements LoanArrearsAgingService {
private static final Logger LOG = LoggerFactory.getLogger(LoanArrearsAgingServiceImpl.class); private final DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd");
private final JdbcTemplate jdbcTemplate;
private final BusinessEventNotifierService businessEventNotifierService; private final BusinessEventNotifierService businessEventNotifierService;
private final DatabaseSpecificSQLGenerator sqlGenerator; private final DatabaseSpecificSQLGenerator sqlGenerator;
private final DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd");
private final JdbcTemplate jdbcTemplate;
@Autowired
public LoanArrearsAgingServiceImpl(final JdbcTemplate jdbcTemplate, final BusinessEventNotifierService businessEventNotifierService,
DatabaseSpecificSQLGenerator sqlGenerator) {
this.jdbcTemplate = jdbcTemplate;
this.businessEventNotifierService = businessEventNotifierService;
this.sqlGenerator = sqlGenerator;
}
@PostConstruct @PostConstruct
public void registerForNotification() { public void registerForNotification() {
this.businessEventNotifierService.addBusinessEventPostListeners(BusinessEvent.LOAN_REFUND, this); businessEventNotifierService.addBusinessEventListener(LoanRefundBusinessEvent.class, new RefundEventListener());
this.businessEventNotifierService.addBusinessEventPostListeners(BusinessEvent.LOAN_ADJUST_TRANSACTION, this); businessEventNotifierService.addBusinessEventListener(LoanAdjustTransactionBusinessEvent.class,
this.businessEventNotifierService.addBusinessEventPostListeners(BusinessEvent.LOAN_MAKE_REPAYMENT, this); new AdjustTransactionBusinessEventEventListener());
this.businessEventNotifierService.addBusinessEventPostListeners(BusinessEvent.LOAN_UNDO_WRITTEN_OFF, this); businessEventNotifierService.addBusinessEventListener(LoanMakeRepaymentBusinessEvent.class, new MakeRepaymentEventListener());
this.businessEventNotifierService.addBusinessEventPostListeners(BusinessEvent.LOAN_WAIVE_INTEREST, this); businessEventNotifierService.addBusinessEventListener(LoanUndoWrittenOffBusinessEvent.class, new UndoWrittenOffEventListener());
this.businessEventNotifierService.addBusinessEventPostListeners(BusinessEvent.LOAN_ADD_CHARGE, this); businessEventNotifierService.addBusinessEventListener(LoanWaiveInterestBusinessEvent.class, new WaiveInterestEventListener());
this.businessEventNotifierService.addBusinessEventPostListeners(BusinessEvent.LOAN_WAIVE_CHARGE, this); businessEventNotifierService.addBusinessEventListener(LoanAddChargeBusinessEvent.class, new AddChargeEventListener());
this.businessEventNotifierService.addBusinessEventPostListeners(BusinessEvent.LOAN_CHARGE_PAYMENT, this); businessEventNotifierService.addBusinessEventListener(LoanWaiveChargeBusinessEvent.class, new WaiveChargeEventListener());
this.businessEventNotifierService.addBusinessEventPostListeners(BusinessEvent.LOAN_APPLY_OVERDUE_CHARGE, this); businessEventNotifierService.addBusinessEventListener(LoanChargePaymentBusinessEvent.class, new LoanChargePaymentEventListener());
this.businessEventNotifierService.addBusinessEventPostListeners(BusinessEvent.LOAN_DISBURSAL, new DisbursementEventListener()); businessEventNotifierService.addBusinessEventListener(LoanApplyOverdueChargeBusinessEvent.class,
this.businessEventNotifierService.addBusinessEventPostListeners(BusinessEvent.LOAN_FORECLOSURE, this); new ApplyOverdueChargeEventListener());
businessEventNotifierService.addBusinessEventListener(LoanDisbursalBusinessEvent.class, new DisbursementEventListener());
businessEventNotifierService.addBusinessEventListener(LoanForeClosureBusinessEvent.class, new LoanForeClosureEventListener());
} }
@Transactional @Transactional
@@ -129,7 +133,7 @@ public class LoanArrearsAgingServiceImpl implements LoanArrearsAgingService, Bus
result += i; result += i;
} }
LOG.info("{}: Records affected by updateLoanArrearsAgeingDetails: {}", ThreadLocalContextUtil.getTenant().getName(), result); log.info("{}: Records affected by updateLoanArrearsAgeingDetails: {}", ThreadLocalContextUtil.getTenant().getName(), result);
} }
@Override @Override
@@ -474,32 +478,7 @@ public class LoanArrearsAgingServiceImpl implements LoanArrearsAgingService, Bus
} }
} }
@SuppressWarnings("unused") private void handleArrearsForLoan(Loan loan) {
@Override
public void businessEventToBeExecuted(Map<BusinessEntity, Object> businessEventEntity) {
// TODO Auto-generated method stub
}
@Override
public void businessEventWasExecuted(Map<BusinessEntity, Object> businessEventEntity) {
Loan loan = null;
Object loanEntity = businessEventEntity.get(BusinessEntity.LOAN);
Object loanTransactionEntity = businessEventEntity.get(BusinessEntity.LOAN_TRANSACTION);
Object loanAdjustTransactionEntity = businessEventEntity.get(BusinessEntity.LOAN_ADJUSTED_TRANSACTION);
Object loanChargeEntity = businessEventEntity.get(BusinessEntity.LOAN_CHARGE);
if (loanEntity != null) {
loan = (Loan) loanEntity;
} else if (loanTransactionEntity != null) {
LoanTransaction loanTransaction = (LoanTransaction) loanTransactionEntity;
loan = loanTransaction.getLoan();
} else if (loanAdjustTransactionEntity != null) {
LoanTransaction loanTransaction = (LoanTransaction) loanAdjustTransactionEntity;
loan = loanTransaction.getLoan();
} else if (loanChargeEntity != null) {
LoanCharge loanCharge = (LoanCharge) loanChargeEntity;
loan = loanCharge.getLoan();
}
if (loan != null && loan.isOpen() && loan.repaymentScheduleDetail().isInterestRecalculationEnabled() if (loan != null && loan.isOpen() && loan.repaymentScheduleDetail().isInterestRecalculationEnabled()
&& loan.loanProduct().isArrearsBasedOnOriginalSchedule()) { && loan.loanProduct().isArrearsBasedOnOriginalSchedule()) {
updateLoanArrearsAgeingDetailsWithOriginalSchedule(loan); updateLoanArrearsAgeingDetailsWithOriginalSchedule(loan);
@@ -508,24 +487,116 @@ public class LoanArrearsAgingServiceImpl implements LoanArrearsAgingService, Bus
} }
} }
private class DisbursementEventListener implements BusinessEventListener { private class RefundEventListener implements BusinessEventListener<LoanRefundBusinessEvent> {
@SuppressWarnings("unused") @SuppressWarnings("unused")
@Override @Override
public void businessEventToBeExecuted(Map<BusinessEntity, Object> businessEventEntity) { public void onBusinessEvent(LoanRefundBusinessEvent event) {
// TODO Auto-generated method stub LoanTransaction loanTransaction = event.get();
Loan loan = loanTransaction.getLoan();
handleArrearsForLoan(loan);
} }
}
private class AdjustTransactionBusinessEventEventListener implements BusinessEventListener<LoanAdjustTransactionBusinessEvent> {
@Override @Override
public void businessEventWasExecuted(Map<BusinessEntity, Object> businessEventEntity) { public void onBusinessEvent(LoanAdjustTransactionBusinessEvent event) {
Object loanEntity = businessEventEntity.get(BusinessEntity.LOAN); LoanTransaction loanTransaction = event.get().getTransactionToAdjust();
if (loanEntity != null) { if (loanTransaction == null) {
Loan loan = (Loan) loanEntity; loanTransaction = event.get().getNewTransactionDetail();
updateLoanArrearsAgeingDetails(loan);
} }
Loan loan = loanTransaction.getLoan();
handleArrearsForLoan(loan);
} }
}
private class MakeRepaymentEventListener implements BusinessEventListener<LoanMakeRepaymentBusinessEvent> {
@Override
public void onBusinessEvent(LoanMakeRepaymentBusinessEvent event) {
LoanTransaction loanTransaction = event.get();
Loan loan = loanTransaction.getLoan();
handleArrearsForLoan(loan);
}
}
private class UndoWrittenOffEventListener implements BusinessEventListener<LoanUndoWrittenOffBusinessEvent> {
@Override
public void onBusinessEvent(LoanUndoWrittenOffBusinessEvent event) {
LoanTransaction loanTransaction = event.get();
Loan loan = loanTransaction.getLoan();
handleArrearsForLoan(loan);
}
}
private class WaiveInterestEventListener implements BusinessEventListener<LoanWaiveInterestBusinessEvent> {
@Override
public void onBusinessEvent(LoanWaiveInterestBusinessEvent event) {
LoanTransaction loanTransaction = event.get();
Loan loan = loanTransaction.getLoan();
handleArrearsForLoan(loan);
}
}
private class LoanForeClosureEventListener implements BusinessEventListener<LoanForeClosureBusinessEvent> {
@Override
public void onBusinessEvent(LoanForeClosureBusinessEvent event) {
LoanTransaction loanTransaction = event.get();
Loan loan = loanTransaction.getLoan();
handleArrearsForLoan(loan);
}
}
private class LoanChargePaymentEventListener implements BusinessEventListener<LoanChargePaymentBusinessEvent> {
@Override
public void onBusinessEvent(LoanChargePaymentBusinessEvent event) {
LoanTransaction loanTransaction = event.get();
Loan loan = loanTransaction.getLoan();
handleArrearsForLoan(loan);
}
}
private class AddChargeEventListener implements BusinessEventListener<LoanAddChargeBusinessEvent> {
@Override
public void onBusinessEvent(LoanAddChargeBusinessEvent event) {
LoanCharge loanCharge = event.get();
Loan loan = loanCharge.getLoan();
handleArrearsForLoan(loan);
}
}
private class WaiveChargeEventListener implements BusinessEventListener<LoanWaiveChargeBusinessEvent> {
@Override
public void onBusinessEvent(LoanWaiveChargeBusinessEvent event) {
LoanCharge loanCharge = event.get();
Loan loan = loanCharge.getLoan();
handleArrearsForLoan(loan);
}
}
private class ApplyOverdueChargeEventListener implements BusinessEventListener<LoanApplyOverdueChargeBusinessEvent> {
@Override
public void onBusinessEvent(LoanApplyOverdueChargeBusinessEvent event) {
Loan loan = event.get();
handleArrearsForLoan(loan);
}
}
private class DisbursementEventListener implements BusinessEventListener<LoanDisbursalBusinessEvent> {
@SuppressWarnings("unused")
@Override
public void onBusinessEvent(LoanDisbursalBusinessEvent event) {
Loan loan = event.get();
updateLoanArrearsAgeingDetails(loan);
}
} }
} }
@@ -37,6 +37,8 @@ import java.util.List;
import java.util.Locale; import java.util.Locale;
import java.util.Map; import java.util.Map;
import java.util.Set; import java.util.Set;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.apache.fineract.accounting.journalentry.service.JournalEntryWritePlatformService; import org.apache.fineract.accounting.journalentry.service.JournalEntryWritePlatformService;
import org.apache.fineract.infrastructure.codes.domain.CodeValue; import org.apache.fineract.infrastructure.codes.domain.CodeValue;
@@ -90,8 +92,28 @@ import org.apache.fineract.portfolio.account.service.AccountAssociationsReadPlat
import org.apache.fineract.portfolio.account.service.AccountTransfersReadPlatformService; import org.apache.fineract.portfolio.account.service.AccountTransfersReadPlatformService;
import org.apache.fineract.portfolio.account.service.AccountTransfersWritePlatformService; import org.apache.fineract.portfolio.account.service.AccountTransfersWritePlatformService;
import org.apache.fineract.portfolio.accountdetails.domain.AccountType; import org.apache.fineract.portfolio.accountdetails.domain.AccountType;
import org.apache.fineract.portfolio.businessevent.domain.BusinessEntity; import org.apache.fineract.portfolio.businessevent.domain.loan.LoanAcceptTransferBusinessEvent;
import org.apache.fineract.portfolio.businessevent.domain.BusinessEvent; import org.apache.fineract.portfolio.businessevent.domain.loan.LoanAdjustTransactionBusinessEvent;
import org.apache.fineract.portfolio.businessevent.domain.loan.LoanApplyOverdueChargeBusinessEvent;
import org.apache.fineract.portfolio.businessevent.domain.loan.LoanCloseAsRescheduleBusinessEvent;
import org.apache.fineract.portfolio.businessevent.domain.loan.LoanCloseBusinessEvent;
import org.apache.fineract.portfolio.businessevent.domain.loan.LoanDisbursalBusinessEvent;
import org.apache.fineract.portfolio.businessevent.domain.loan.LoanInitiateTransferBusinessEvent;
import org.apache.fineract.portfolio.businessevent.domain.loan.LoanInterestRecalculationBusinessEvent;
import org.apache.fineract.portfolio.businessevent.domain.loan.LoanReassignOfficerBusinessEvent;
import org.apache.fineract.portfolio.businessevent.domain.loan.LoanRejectTransferBusinessEvent;
import org.apache.fineract.portfolio.businessevent.domain.loan.LoanRemoveOfficerBusinessEvent;
import org.apache.fineract.portfolio.businessevent.domain.loan.LoanUndoDisbursalBusinessEvent;
import org.apache.fineract.portfolio.businessevent.domain.loan.LoanUndoLastDisbursalBusinessEvent;
import org.apache.fineract.portfolio.businessevent.domain.loan.LoanWithdrawTransferBusinessEvent;
import org.apache.fineract.portfolio.businessevent.domain.loan.charge.LoanAddChargeBusinessEvent;
import org.apache.fineract.portfolio.businessevent.domain.loan.charge.LoanDeleteChargeBusinessEvent;
import org.apache.fineract.portfolio.businessevent.domain.loan.charge.LoanUpdateChargeBusinessEvent;
import org.apache.fineract.portfolio.businessevent.domain.loan.charge.LoanWaiveChargeBusinessEvent;
import org.apache.fineract.portfolio.businessevent.domain.loan.charge.LoanWaiveChargeUndoBusinessEvent;
import org.apache.fineract.portfolio.businessevent.domain.loan.transaction.LoanUndoWrittenOffBusinessEvent;
import org.apache.fineract.portfolio.businessevent.domain.loan.transaction.LoanWaiveInterestBusinessEvent;
import org.apache.fineract.portfolio.businessevent.domain.loan.transaction.LoanWrittenOffBusinessEvent;
import org.apache.fineract.portfolio.businessevent.service.BusinessEventNotifierService; import org.apache.fineract.portfolio.businessevent.service.BusinessEventNotifierService;
import org.apache.fineract.portfolio.calendar.domain.Calendar; import org.apache.fineract.portfolio.calendar.domain.Calendar;
import org.apache.fineract.portfolio.calendar.domain.CalendarEntityType; import org.apache.fineract.portfolio.calendar.domain.CalendarEntityType;
@@ -198,19 +220,16 @@ import org.apache.fineract.portfolio.repaymentwithpostdatedchecks.service.Repaym
import org.apache.fineract.portfolio.savings.domain.SavingsAccount; import org.apache.fineract.portfolio.savings.domain.SavingsAccount;
import org.apache.fineract.portfolio.transfer.api.TransferApiConstants; import org.apache.fineract.portfolio.transfer.api.TransferApiConstants;
import org.apache.fineract.useradministration.domain.AppUser; import org.apache.fineract.useradministration.domain.AppUser;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.dao.DataIntegrityViolationException; import org.springframework.dao.DataIntegrityViolationException;
import org.springframework.orm.jpa.JpaSystemException; import org.springframework.orm.jpa.JpaSystemException;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
@Service @Service
@Slf4j
@RequiredArgsConstructor
public class LoanWritePlatformServiceJpaRepositoryImpl implements LoanWritePlatformService { public class LoanWritePlatformServiceJpaRepositoryImpl implements LoanWritePlatformService {
private static final Logger LOG = LoggerFactory.getLogger(LoanWritePlatformServiceJpaRepositoryImpl.class);
private final PlatformSecurityContext context; private final PlatformSecurityContext context;
private final LoanEventApiJsonValidator loanEventApiJsonValidator; private final LoanEventApiJsonValidator loanEventApiJsonValidator;
private final LoanUpdateCommandFromApiJsonDeserializer loanUpdateCommandFromApiJsonDeserializer; private final LoanUpdateCommandFromApiJsonDeserializer loanUpdateCommandFromApiJsonDeserializer;
@@ -253,78 +272,6 @@ public class LoanWritePlatformServiceJpaRepositoryImpl implements LoanWritePlatf
private final RepaymentWithPostDatedChecksAssembler repaymentWithPostDatedChecksAssembler; private final RepaymentWithPostDatedChecksAssembler repaymentWithPostDatedChecksAssembler;
private final PostDatedChecksRepository postDatedChecksRepository; private final PostDatedChecksRepository postDatedChecksRepository;
@Autowired
public LoanWritePlatformServiceJpaRepositoryImpl(final PlatformSecurityContext context,
final LoanEventApiJsonValidator loanEventApiJsonValidator,
final LoanUpdateCommandFromApiJsonDeserializer loanUpdateCommandFromApiJsonDeserializer, final LoanAssembler loanAssembler,
final LoanAccountDomainService loanAccountDomainService, final LoanTransactionRepository loanTransactionRepository,
final NoteRepository noteRepository, final ChargeRepositoryWrapper chargeRepository,
final LoanChargeRepository loanChargeRepository, final ApplicationCurrencyRepositoryWrapper applicationCurrencyRepository,
final JournalEntryWritePlatformService journalEntryWritePlatformService,
final CalendarInstanceRepository calendarInstanceRepository,
final PaymentDetailWritePlatformService paymentDetailWritePlatformService, final HolidayRepositoryWrapper holidayRepository,
final ConfigurationDomainService configurationDomainService, final WorkingDaysRepositoryWrapper workingDaysRepository,
final AccountTransfersWritePlatformService accountTransfersWritePlatformService,
final AccountTransfersReadPlatformService accountTransfersReadPlatformService,
final AccountAssociationsReadPlatformService accountAssociationsReadPlatformService,
final LoanChargeReadPlatformService loanChargeReadPlatformService, final LoanReadPlatformService loanReadPlatformService,
final FromJsonHelper fromApiJsonHelper, final AccountTransferRepository accountTransferRepository,
final CalendarRepository calendarRepository,
final LoanScheduleHistoryWritePlatformService loanScheduleHistoryWritePlatformService,
final LoanApplicationCommandFromApiJsonHelper loanApplicationCommandFromApiJsonHelper,
final AccountAssociationsRepository accountAssociationRepository,
final AccountTransferDetailRepository accountTransferDetailRepository,
final BusinessEventNotifierService businessEventNotifierService, final GuarantorDomainService guarantorDomainService,
final LoanUtilService loanUtilService, final LoanSummaryWrapper loanSummaryWrapper,
final EntityDatatableChecksWritePlatformService entityDatatableChecksWritePlatformService,
final LoanRepaymentScheduleTransactionProcessorFactory transactionProcessingStrategy,
final CodeValueRepositoryWrapper codeValueRepository, final LoanRepositoryWrapper loanRepositoryWrapper,
final CashierTransactionDataValidator cashierTransactionDataValidator, final GLIMAccountInfoRepository glimRepository,
final LoanRepository loanRepository, final RepaymentWithPostDatedChecksAssembler repaymentWithPostDatedChecksAssembler,
final PostDatedChecksRepository postDatedChecksRepository) {
this.context = context;
this.loanEventApiJsonValidator = loanEventApiJsonValidator;
this.loanAssembler = loanAssembler;
this.loanRepositoryWrapper = loanRepositoryWrapper;
this.loanAccountDomainService = loanAccountDomainService;
this.loanTransactionRepository = loanTransactionRepository;
this.noteRepository = noteRepository;
this.chargeRepository = chargeRepository;
this.loanChargeRepository = loanChargeRepository;
this.applicationCurrencyRepository = applicationCurrencyRepository;
this.journalEntryWritePlatformService = journalEntryWritePlatformService;
this.loanUpdateCommandFromApiJsonDeserializer = loanUpdateCommandFromApiJsonDeserializer;
this.calendarInstanceRepository = calendarInstanceRepository;
this.paymentDetailWritePlatformService = paymentDetailWritePlatformService;
this.holidayRepository = holidayRepository;
this.configurationDomainService = configurationDomainService;
this.workingDaysRepository = workingDaysRepository;
this.accountTransfersWritePlatformService = accountTransfersWritePlatformService;
this.accountTransfersReadPlatformService = accountTransfersReadPlatformService;
this.accountAssociationsReadPlatformService = accountAssociationsReadPlatformService;
this.loanChargeReadPlatformService = loanChargeReadPlatformService;
this.loanReadPlatformService = loanReadPlatformService;
this.fromApiJsonHelper = fromApiJsonHelper;
this.accountTransferRepository = accountTransferRepository;
this.calendarRepository = calendarRepository;
this.loanScheduleHistoryWritePlatformService = loanScheduleHistoryWritePlatformService;
this.loanApplicationCommandFromApiJsonHelper = loanApplicationCommandFromApiJsonHelper;
this.accountAssociationRepository = accountAssociationRepository;
this.accountTransferDetailRepository = accountTransferDetailRepository;
this.businessEventNotifierService = businessEventNotifierService;
this.guarantorDomainService = guarantorDomainService;
this.loanUtilService = loanUtilService;
this.loanSummaryWrapper = loanSummaryWrapper;
this.transactionProcessingStrategy = transactionProcessingStrategy;
this.entityDatatableChecksWritePlatformService = entityDatatableChecksWritePlatformService;
this.codeValueRepository = codeValueRepository;
this.cashierTransactionDataValidator = cashierTransactionDataValidator;
this.loanRepository = loanRepository;
this.glimRepository = glimRepository;
this.repaymentWithPostDatedChecksAssembler = repaymentWithPostDatedChecksAssembler;
this.postDatedChecksRepository = postDatedChecksRepository;
}
private LoanLifecycleStateMachine defaultLoanLifecycleStateMachine() { private LoanLifecycleStateMachine defaultLoanLifecycleStateMachine() {
final List<LoanStatus> allowedLoanStatuses = Arrays.asList(LoanStatus.values()); final List<LoanStatus> allowedLoanStatuses = Arrays.asList(LoanStatus.values());
return new DefaultLoanLifecycleStateMachine(allowedLoanStatuses); return new DefaultLoanLifecycleStateMachine(allowedLoanStatuses);
@@ -430,9 +377,6 @@ public class LoanWritePlatformServiceJpaRepositoryImpl implements LoanWritePlatf
scheduleGeneratorDTO.isSkipRepaymentOnFirstDayofMonth(), scheduleGeneratorDTO.getNumberOfdays()); scheduleGeneratorDTO.isSkipRepaymentOnFirstDayofMonth(), scheduleGeneratorDTO.getNumberOfdays());
} }
this.businessEventNotifierService.notifyBusinessEventToBeExecuted(BusinessEvent.LOAN_DISBURSAL,
constructEntityMap(BusinessEntity.LOAN, loan));
final List<Long> existingTransactionIds = new ArrayList<>(); final List<Long> existingTransactionIds = new ArrayList<>();
final List<Long> existingReversedTransactionIds = new ArrayList<>(); final List<Long> existingReversedTransactionIds = new ArrayList<>();
@@ -581,8 +525,7 @@ public class LoanWritePlatformServiceJpaRepositoryImpl implements LoanWritePlatf
updatePostDatedChecks(postDatedChecks); updatePostDatedChecks(postDatedChecks);
} }
this.businessEventNotifierService.notifyBusinessEventWasExecuted(BusinessEvent.LOAN_DISBURSAL, businessEventNotifierService.notifyBusinessEvent(new LoanDisbursalBusinessEvent(loan));
constructEntityMap(BusinessEntity.LOAN, loan));
Long entityId = loan.getId(); Long entityId = loan.getId();
@@ -736,8 +679,6 @@ public class LoanWritePlatformServiceJpaRepositoryImpl implements LoanWritePlatf
syncExpectedDateWithActualDisbursementDate(loan, actualDisbursementDate); syncExpectedDateWithActualDisbursementDate(loan, actualDisbursementDate);
} }
checkClientOrGroupActive(loan); checkClientOrGroupActive(loan);
this.businessEventNotifierService.notifyBusinessEventToBeExecuted(BusinessEvent.LOAN_DISBURSAL,
constructEntityMap(BusinessEntity.LOAN, loan));
final List<Long> existingTransactionIds = new ArrayList<>(); final List<Long> existingTransactionIds = new ArrayList<>();
final List<Long> existingReversedTransactionIds = new ArrayList<>(); final List<Long> existingReversedTransactionIds = new ArrayList<>();
@@ -827,9 +768,8 @@ public class LoanWritePlatformServiceJpaRepositoryImpl implements LoanWritePlatf
this.accountTransfersWritePlatformService.transferFunds(accountTransferDTO); this.accountTransfersWritePlatformService.transferFunds(accountTransferDTO);
} }
updateRecurringCalendarDatesForInterestRecalculation(loan); updateRecurringCalendarDatesForInterestRecalculation(loan);
this.loanAccountDomainService.recalculateAccruals(loan); loanAccountDomainService.recalculateAccruals(loan);
this.businessEventNotifierService.notifyBusinessEventWasExecuted(BusinessEvent.LOAN_DISBURSAL, businessEventNotifierService.notifyBusinessEvent(new LoanDisbursalBusinessEvent(loan));
constructEntityMap(BusinessEntity.LOAN, loan));
} }
return changes; return changes;
@@ -867,8 +807,6 @@ public class LoanWritePlatformServiceJpaRepositoryImpl implements LoanWritePlatf
final AppUser currentUser = getAppUserIfPresent(); final AppUser currentUser = getAppUserIfPresent();
final Loan loan = this.loanAssembler.assembleFrom(loanId); final Loan loan = this.loanAssembler.assembleFrom(loanId);
checkClientOrGroupActive(loan); checkClientOrGroupActive(loan);
this.businessEventNotifierService.notifyBusinessEventToBeExecuted(BusinessEvent.LOAN_UNDO_DISBURSAL,
constructEntityMap(BusinessEntity.LOAN, loan));
removeLoanCycle(loan); removeLoanCycle(loan);
final List<Long> existingTransactionIds = new ArrayList<>(); final List<Long> existingTransactionIds = new ArrayList<>();
final List<Long> existingReversedTransactionIds = new ArrayList<>(); final List<Long> existingReversedTransactionIds = new ArrayList<>();
@@ -909,9 +847,8 @@ public class LoanWritePlatformServiceJpaRepositoryImpl implements LoanWritePlatf
boolean isAccountTransfer = false; boolean isAccountTransfer = false;
final Map<String, Object> accountingBridgeData = loan.deriveAccountingBridgeData(applicationCurrency.toData(), final Map<String, Object> accountingBridgeData = loan.deriveAccountingBridgeData(applicationCurrency.toData(),
existingTransactionIds, existingReversedTransactionIds, isAccountTransfer); existingTransactionIds, existingReversedTransactionIds, isAccountTransfer);
this.journalEntryWritePlatformService.createJournalEntriesForLoan(accountingBridgeData); journalEntryWritePlatformService.createJournalEntriesForLoan(accountingBridgeData);
this.businessEventNotifierService.notifyBusinessEventWasExecuted(BusinessEvent.LOAN_UNDO_DISBURSAL, businessEventNotifierService.notifyBusinessEvent(new LoanUndoDisbursalBusinessEvent(loan));
constructEntityMap(BusinessEntity.LOAN, loan));
} }
return new CommandProcessingResultBuilder() // return new CommandProcessingResultBuilder() //
@@ -941,7 +878,7 @@ public class LoanWritePlatformServiceJpaRepositoryImpl implements LoanWritePlatf
Long[] childLoanId = new Long[repayments.size()]; Long[] childLoanId = new Long[repayments.size()];
for (int i = 0; i < repayments.size(); i++) { for (int i = 0; i < repayments.size(); i++) {
jsonObject = repayments.get(i).getAsJsonObject(); jsonObject = repayments.get(i).getAsJsonObject();
LOG.info("{}", jsonObject.toString()); log.info("{}", jsonObject.toString());
childLoanId[i] = jsonObject.get("loanId").getAsLong(); childLoanId[i] = jsonObject.get("loanId").getAsLong();
} }
int j = 0; int j = 0;
@@ -1080,8 +1017,6 @@ public class LoanWritePlatformServiceJpaRepositoryImpl implements LoanWritePlatf
checkClientOrGroupActive(loan); checkClientOrGroupActive(loan);
final LoanTransaction transactionToAdjust = this.loanTransactionRepository.findById(transactionId) final LoanTransaction transactionToAdjust = this.loanTransactionRepository.findById(transactionId)
.orElseThrow(() -> new LoanTransactionNotFoundException(transactionId)); .orElseThrow(() -> new LoanTransactionNotFoundException(transactionId));
this.businessEventNotifierService.notifyBusinessEventToBeExecuted(BusinessEvent.LOAN_ADJUST_TRANSACTION,
constructEntityMap(BusinessEntity.LOAN_ADJUSTED_TRANSACTION, transactionToAdjust));
if (this.accountTransfersReadPlatformService.isAccountTransfer(transactionId, PortfolioAccountType.LOAN)) { if (this.accountTransfersReadPlatformService.isAccountTransfer(transactionId, PortfolioAccountType.LOAN)) {
throw new PlatformServiceUnavailableException("error.msg.loan.transfer.transaction.update.not.allowed", throw new PlatformServiceUnavailableException("error.msg.loan.transfer.transaction.update.not.allowed",
"Loan transaction:" + transactionId + " update not allowed as it involves in account transfer", transactionId); "Loan transaction:" + transactionId + " update not allowed as it involves in account transfer", transactionId);
@@ -1190,11 +1125,11 @@ public class LoanWritePlatformServiceJpaRepositoryImpl implements LoanWritePlatf
postJournalEntries(loan, existingTransactionIds, existingReversedTransactionIds); postJournalEntries(loan, existingTransactionIds, existingReversedTransactionIds);
this.loanAccountDomainService.recalculateAccruals(loan); this.loanAccountDomainService.recalculateAccruals(loan);
Map<BusinessEntity, Object> entityMap = constructEntityMap(BusinessEntity.LOAN_ADJUSTED_TRANSACTION, transactionToAdjust); LoanAdjustTransactionBusinessEvent.Data eventData = new LoanAdjustTransactionBusinessEvent.Data(transactionToAdjust);
if (newTransactionDetail.isRepaymentType() && newTransactionDetail.isGreaterThanZero(loan.getPrincpal().getCurrency())) { if (newTransactionDetail.isRepaymentType() && newTransactionDetail.isGreaterThanZero(loan.getPrincpal().getCurrency())) {
entityMap.put(BusinessEntity.LOAN_TRANSACTION, newTransactionDetail); eventData.setNewTransactionDetail(newTransactionDetail);
} }
this.businessEventNotifierService.notifyBusinessEventWasExecuted(BusinessEvent.LOAN_ADJUST_TRANSACTION, entityMap); businessEventNotifierService.notifyBusinessEvent(new LoanAdjustTransactionBusinessEvent(eventData));
return new CommandProcessingResultBuilder().withCommandId(command.commandId()).withEntityId(transactionId) return new CommandProcessingResultBuilder().withCommandId(command.commandId()).withEntityId(transactionId)
.withOfficeId(loan.getOfficeId()).withClientId(loan.getClientId()).withGroupId(loan.getGroupId()).withLoanId(loanId) .withOfficeId(loan.getOfficeId()).withClientId(loan.getClientId()).withGroupId(loan.getGroupId()).withLoanId(loanId)
@@ -1235,8 +1170,6 @@ public class LoanWritePlatformServiceJpaRepositoryImpl implements LoanWritePlatf
} }
final LoanTransaction waiveInterestTransaction = LoanTransaction.waiver(loan.getOffice(), loan, transactionAmountAsMoney, final LoanTransaction waiveInterestTransaction = LoanTransaction.waiver(loan.getOffice(), loan, transactionAmountAsMoney,
transactionDate, interestComponent, unrecognizedIncome, DateUtils.getLocalDateTimeOfTenant(), currentUser); transactionDate, interestComponent, unrecognizedIncome, DateUtils.getLocalDateTimeOfTenant(), currentUser);
this.businessEventNotifierService.notifyBusinessEventToBeExecuted(BusinessEvent.LOAN_WAIVE_INTEREST,
constructEntityMap(BusinessEntity.LOAN_TRANSACTION, waiveInterestTransaction));
LocalDate recalculateFrom = null; LocalDate recalculateFrom = null;
if (loan.repaymentScheduleDetail().isInterestRecalculationEnabled()) { if (loan.repaymentScheduleDetail().isInterestRecalculationEnabled()) {
recalculateFrom = transactionDate; recalculateFrom = transactionDate;
@@ -1272,9 +1205,8 @@ public class LoanWritePlatformServiceJpaRepositoryImpl implements LoanWritePlatf
} }
postJournalEntries(loan, existingTransactionIds, existingReversedTransactionIds); postJournalEntries(loan, existingTransactionIds, existingReversedTransactionIds);
this.loanAccountDomainService.recalculateAccruals(loan); loanAccountDomainService.recalculateAccruals(loan);
this.businessEventNotifierService.notifyBusinessEventWasExecuted(BusinessEvent.LOAN_WAIVE_INTEREST, businessEventNotifierService.notifyBusinessEvent(new LoanWaiveInterestBusinessEvent(waiveInterestTransaction));
constructEntityMap(BusinessEntity.LOAN_TRANSACTION, waiveInterestTransaction));
return new CommandProcessingResultBuilder().withCommandId(command.commandId()).withEntityId(waiveInterestTransaction.getId()) return new CommandProcessingResultBuilder().withCommandId(command.commandId()).withEntityId(waiveInterestTransaction.getId())
.withOfficeId(loan.getOfficeId()).withClientId(loan.getClientId()).withGroupId(loan.getGroupId()).withLoanId(loanId) .withOfficeId(loan.getOfficeId()).withClientId(loan.getClientId()).withGroupId(loan.getGroupId()).withLoanId(loanId)
.with(changes).build(); .with(changes).build();
@@ -1301,8 +1233,6 @@ public class LoanWritePlatformServiceJpaRepositoryImpl implements LoanWritePlatf
} }
checkClientOrGroupActive(loan); checkClientOrGroupActive(loan);
this.businessEventNotifierService.notifyBusinessEventToBeExecuted(BusinessEvent.LOAN_WRITTEN_OFF,
constructEntityMap(BusinessEntity.LOAN, loan));
entityDatatableChecksWritePlatformService.runTheCheckForProduct(loanId, EntityTables.LOAN.getName(), entityDatatableChecksWritePlatformService.runTheCheckForProduct(loanId, EntityTables.LOAN.getName(),
StatusEnum.WRITE_OFF.getCode().longValue(), EntityTables.LOAN.getForeignKeyColumnNameOnDatatable(), loan.productId()); StatusEnum.WRITE_OFF.getCode().longValue(), EntityTables.LOAN.getForeignKeyColumnNameOnDatatable(), loan.productId());
@@ -1322,8 +1252,8 @@ public class LoanWritePlatformServiceJpaRepositoryImpl implements LoanWritePlatf
final ChangedTransactionDetail changedTransactionDetail = loan.closeAsWrittenOff(command, defaultLoanLifecycleStateMachine(), final ChangedTransactionDetail changedTransactionDetail = loan.closeAsWrittenOff(command, defaultLoanLifecycleStateMachine(),
changes, existingTransactionIds, existingReversedTransactionIds, currentUser, scheduleGeneratorDTO); changes, existingTransactionIds, existingReversedTransactionIds, currentUser, scheduleGeneratorDTO);
LoanTransaction writeoff = changedTransactionDetail.getNewTransactionMappings().remove(0L); LoanTransaction writeOff = changedTransactionDetail.getNewTransactionMappings().remove(0L);
this.loanTransactionRepository.saveAndFlush(writeoff); this.loanTransactionRepository.saveAndFlush(writeOff);
for (final Map.Entry<Long, LoanTransaction> mapEntry : changedTransactionDetail.getNewTransactionMappings().entrySet()) { for (final Map.Entry<Long, LoanTransaction> mapEntry : changedTransactionDetail.getNewTransactionMappings().entrySet()) {
this.loanTransactionRepository.save(mapEntry.getValue()); this.loanTransactionRepository.save(mapEntry.getValue());
this.accountTransfersWritePlatformService.updateLoanTransaction(mapEntry.getKey(), mapEntry.getValue()); this.accountTransfersWritePlatformService.updateLoanTransaction(mapEntry.getKey(), mapEntry.getValue());
@@ -1332,15 +1262,14 @@ public class LoanWritePlatformServiceJpaRepositoryImpl implements LoanWritePlatf
final String noteText = command.stringValueOfParameterNamed("note"); final String noteText = command.stringValueOfParameterNamed("note");
if (StringUtils.isNotBlank(noteText)) { if (StringUtils.isNotBlank(noteText)) {
changes.put("note", noteText); changes.put("note", noteText);
final Note note = Note.loanTransactionNote(loan, writeoff, noteText); final Note note = Note.loanTransactionNote(loan, writeOff, noteText);
this.noteRepository.save(note); this.noteRepository.save(note);
} }
postJournalEntries(loan, existingTransactionIds, existingReversedTransactionIds); postJournalEntries(loan, existingTransactionIds, existingReversedTransactionIds);
this.loanAccountDomainService.recalculateAccruals(loan); loanAccountDomainService.recalculateAccruals(loan);
this.businessEventNotifierService.notifyBusinessEventWasExecuted(BusinessEvent.LOAN_WRITTEN_OFF, businessEventNotifierService.notifyBusinessEvent(new LoanWrittenOffBusinessEvent(writeOff));
constructEntityMap(BusinessEntity.LOAN_TRANSACTION, writeoff)); return new CommandProcessingResultBuilder().withCommandId(command.commandId()).withEntityId(writeOff.getId())
return new CommandProcessingResultBuilder().withCommandId(command.commandId()).withEntityId(writeoff.getId())
.withOfficeId(loan.getOfficeId()).withClientId(loan.getClientId()).withGroupId(loan.getGroupId()).withLoanId(loanId) .withOfficeId(loan.getOfficeId()).withClientId(loan.getClientId()).withGroupId(loan.getGroupId()).withLoanId(loanId)
.with(changes).build(); .with(changes).build();
} }
@@ -1355,8 +1284,6 @@ public class LoanWritePlatformServiceJpaRepositoryImpl implements LoanWritePlatf
final Loan loan = this.loanAssembler.assembleFrom(loanId); final Loan loan = this.loanAssembler.assembleFrom(loanId);
checkClientOrGroupActive(loan); checkClientOrGroupActive(loan);
this.businessEventNotifierService.notifyBusinessEventToBeExecuted(BusinessEvent.LOAN_CLOSE,
constructEntityMap(BusinessEntity.LOAN, loan));
final Map<String, Object> changes = new LinkedHashMap<>(); final Map<String, Object> changes = new LinkedHashMap<>();
changes.put("transactionDate", command.stringValueOfParameterNamed("transactionDate")); changes.put("transactionDate", command.stringValueOfParameterNamed("transactionDate"));
@@ -1396,10 +1323,9 @@ public class LoanWritePlatformServiceJpaRepositoryImpl implements LoanWritePlatf
if (possibleClosingTransaction != null) { if (possibleClosingTransaction != null) {
postJournalEntries(loan, existingTransactionIds, existingReversedTransactionIds); postJournalEntries(loan, existingTransactionIds, existingReversedTransactionIds);
} }
this.loanAccountDomainService.recalculateAccruals(loan); loanAccountDomainService.recalculateAccruals(loan);
this.businessEventNotifierService.notifyBusinessEventWasExecuted(BusinessEvent.LOAN_CLOSE, businessEventNotifierService.notifyBusinessEvent(new LoanCloseBusinessEvent(loan));
constructEntityMap(BusinessEntity.LOAN, loan));
// Update loan transaction on repayment. // Update loan transaction on repayment.
if (AccountType.fromInt(loan.getLoanType()).isIndividualAccount()) { if (AccountType.fromInt(loan.getLoanType()).isIndividualAccount()) {
@@ -1444,8 +1370,6 @@ public class LoanWritePlatformServiceJpaRepositoryImpl implements LoanWritePlatf
final Loan loan = this.loanAssembler.assembleFrom(loanId); final Loan loan = this.loanAssembler.assembleFrom(loanId);
checkClientOrGroupActive(loan); checkClientOrGroupActive(loan);
removeLoanCycle(loan); removeLoanCycle(loan);
this.businessEventNotifierService.notifyBusinessEventToBeExecuted(BusinessEvent.LOAN_CLOSE_AS_RESCHEDULE,
constructEntityMap(BusinessEntity.LOAN, loan));
final Map<String, Object> changes = new LinkedHashMap<>(); final Map<String, Object> changes = new LinkedHashMap<>();
changes.put("transactionDate", command.stringValueOfParameterNamed("transactionDate")); changes.put("transactionDate", command.stringValueOfParameterNamed("transactionDate"));
@@ -1462,8 +1386,7 @@ public class LoanWritePlatformServiceJpaRepositoryImpl implements LoanWritePlatf
final Note note = Note.loanNote(loan, noteText); final Note note = Note.loanNote(loan, noteText);
this.noteRepository.save(note); this.noteRepository.save(note);
} }
this.businessEventNotifierService.notifyBusinessEventWasExecuted(BusinessEvent.LOAN_CLOSE_AS_RESCHEDULE, businessEventNotifierService.notifyBusinessEvent(new LoanCloseAsRescheduleBusinessEvent(loan));
constructEntityMap(BusinessEntity.LOAN, loan));
// disable all active standing instructions linked to the loan // disable all active standing instructions linked to the loan
this.loanAccountDomainService.disableStandingInstructionsLinkedToClosedLoan(loan); this.loanAccountDomainService.disableStandingInstructionsLinkedToClosedLoan(loan);
@@ -1541,8 +1464,6 @@ public class LoanWritePlatformServiceJpaRepositoryImpl implements LoanWritePlatf
disbursementDetail.expectedDisbursementDateAsLocalDate(), null, null); disbursementDetail.expectedDisbursementDateAsLocalDate(), null, null);
loanTrancheDisbursementCharge = new LoanTrancheDisbursementCharge(loanCharge, disbursementDetail); loanTrancheDisbursementCharge = new LoanTrancheDisbursementCharge(loanCharge, disbursementDetail);
loanCharge.updateLoanTrancheDisbursementCharge(loanTrancheDisbursementCharge); loanCharge.updateLoanTrancheDisbursementCharge(loanTrancheDisbursementCharge);
this.businessEventNotifierService.notifyBusinessEventToBeExecuted(BusinessEvent.LOAN_ADD_CHARGE,
constructEntityMap(BusinessEntity.LOAN_CHARGE, loanCharge));
validateAddLoanCharge(loan, chargeDefinition, loanCharge); validateAddLoanCharge(loan, chargeDefinition, loanCharge);
addCharge(loan, chargeDefinition, loanCharge); addCharge(loan, chargeDefinition, loanCharge);
isAppliedOnBackDate = true; isAppliedOnBackDate = true;
@@ -1554,8 +1475,6 @@ public class LoanWritePlatformServiceJpaRepositoryImpl implements LoanWritePlatf
loan.addTrancheLoanCharge(chargeDefinition); loan.addTrancheLoanCharge(chargeDefinition);
} else { } else {
loanCharge = LoanCharge.createNewFromJson(loan, chargeDefinition, command); loanCharge = LoanCharge.createNewFromJson(loan, chargeDefinition, command);
this.businessEventNotifierService.notifyBusinessEventToBeExecuted(BusinessEvent.LOAN_ADD_CHARGE,
constructEntityMap(BusinessEntity.LOAN_CHARGE, loanCharge));
validateAddLoanCharge(loan, chargeDefinition, loanCharge); validateAddLoanCharge(loan, chargeDefinition, loanCharge);
isAppliedOnBackDate = addCharge(loan, chargeDefinition, loanCharge); isAppliedOnBackDate = addCharge(loan, chargeDefinition, loanCharge);
@@ -1594,8 +1513,7 @@ public class LoanWritePlatformServiceJpaRepositoryImpl implements LoanWritePlatf
&& loan.isFeeCompoundingEnabledForInterestRecalculation()) { && loan.isFeeCompoundingEnabledForInterestRecalculation()) {
this.loanAccountDomainService.recalculateAccruals(loan); this.loanAccountDomainService.recalculateAccruals(loan);
} }
this.businessEventNotifierService.notifyBusinessEventWasExecuted(BusinessEvent.LOAN_ADD_CHARGE, businessEventNotifierService.notifyBusinessEvent(new LoanAddChargeBusinessEvent(loanCharge));
constructEntityMap(BusinessEntity.LOAN_CHARGE, loanCharge));
return new CommandProcessingResultBuilder().withCommandId(command.commandId()).withEntityId(loanCharge.getId()) return new CommandProcessingResultBuilder().withCommandId(command.commandId()).withEntityId(loanCharge.getId())
.withOfficeId(loan.getOfficeId()).withClientId(loan.getClientId()).withGroupId(loan.getGroupId()).withLoanId(loanId) .withOfficeId(loan.getOfficeId()).withClientId(loan.getClientId()).withGroupId(loan.getGroupId()).withLoanId(loanId)
.build(); .build();
@@ -1711,14 +1629,10 @@ public class LoanWritePlatformServiceJpaRepositoryImpl implements LoanWritePlatf
loanCharge.getId()); loanCharge.getId());
} }
this.businessEventNotifierService.notifyBusinessEventToBeExecuted(BusinessEvent.LOAN_UPDATE_CHARGE,
constructEntityMap(BusinessEntity.LOAN_CHARGE, loanCharge));
final Map<String, Object> changes = loan.updateLoanCharge(loanCharge, command); final Map<String, Object> changes = loan.updateLoanCharge(loanCharge, command);
saveLoanWithDataIntegrityViolationChecks(loan); saveLoanWithDataIntegrityViolationChecks(loan);
this.businessEventNotifierService.notifyBusinessEventWasExecuted(BusinessEvent.LOAN_UPDATE_CHARGE, businessEventNotifierService.notifyBusinessEvent(new LoanUpdateChargeBusinessEvent(loanCharge));
constructEntityMap(BusinessEntity.LOAN_CHARGE, loanCharge));
return new CommandProcessingResultBuilder() // return new CommandProcessingResultBuilder() //
.withCommandId(command.commandId()) // .withCommandId(command.commandId()) //
.withEntityId(loanChargeId) // .withEntityId(loanChargeId) //
@@ -1770,9 +1684,6 @@ public class LoanWritePlatformServiceJpaRepositoryImpl implements LoanWritePlatf
final Map<String, Object> changes = new LinkedHashMap<>(3); final Map<String, Object> changes = new LinkedHashMap<>(3);
this.businessEventNotifierService.notifyBusinessEventToBeExecuted(BusinessEvent.LOAN_WAIVE_CHARGE_UNDO,
constructEntityMap(BusinessEntity.LOAN_CHARGE, loanCharge));
if (loanCharge.isInstalmentFee()) { if (loanCharge.isInstalmentFee()) {
LoanInstallmentCharge chargePerInstallment = null; LoanInstallmentCharge chargePerInstallment = null;
@@ -1859,8 +1770,7 @@ public class LoanWritePlatformServiceJpaRepositoryImpl implements LoanWritePlatf
saveLoanWithDataIntegrityViolationChecks(loan); saveLoanWithDataIntegrityViolationChecks(loan);
this.businessEventNotifierService.notifyBusinessEventWasExecuted(BusinessEvent.LOAN_WAIVE_CHARGE_UNDO, businessEventNotifierService.notifyBusinessEvent(new LoanWaiveChargeUndoBusinessEvent(loanCharge));
constructEntityMap(BusinessEntity.LOAN_CHARGE, loanCharge));
LoanTransaction loanTransactionData = this.loanTransactionRepository.getById(command.entityId()); LoanTransaction loanTransactionData = this.loanTransactionRepository.getById(command.entityId());
changes.put("principalPortion", loanTransactionData.getPrincipalPortion()); changes.put("principalPortion", loanTransactionData.getPrincipalPortion());
@@ -1901,8 +1811,6 @@ public class LoanWritePlatformServiceJpaRepositoryImpl implements LoanWritePlatf
} else if (loanCharge.isPaid()) { } else if (loanCharge.isPaid()) {
throw new LoanChargeCannotBeWaivedException(LoanChargeCannotBeWaivedReason.ALREADY_PAID, loanCharge.getId()); throw new LoanChargeCannotBeWaivedException(LoanChargeCannotBeWaivedReason.ALREADY_PAID, loanCharge.getId());
} }
this.businessEventNotifierService.notifyBusinessEventToBeExecuted(BusinessEvent.LOAN_WAIVE_CHARGE,
constructEntityMap(BusinessEntity.LOAN_CHARGE, loanCharge));
Integer loanInstallmentNumber = null; Integer loanInstallmentNumber = null;
if (loanCharge.isInstalmentFee()) { if (loanCharge.isInstalmentFee()) {
LoanInstallmentCharge chargePerInstallment = null; LoanInstallmentCharge chargePerInstallment = null;
@@ -1951,8 +1859,7 @@ public class LoanWritePlatformServiceJpaRepositoryImpl implements LoanWritePlatf
postJournalEntries(loan, existingTransactionIds, existingReversedTransactionIds); postJournalEntries(loan, existingTransactionIds, existingReversedTransactionIds);
this.businessEventNotifierService.notifyBusinessEventWasExecuted(BusinessEvent.LOAN_WAIVE_CHARGE, businessEventNotifierService.notifyBusinessEvent(new LoanWaiveChargeBusinessEvent(loanCharge));
constructEntityMap(BusinessEntity.LOAN_CHARGE, loanCharge));
return new CommandProcessingResultBuilder() // return new CommandProcessingResultBuilder() //
.withCommandId(command.commandId()) // .withCommandId(command.commandId()) //
@@ -1979,13 +1886,10 @@ public class LoanWritePlatformServiceJpaRepositoryImpl implements LoanWritePlatf
throw new LoanChargeCannotBeDeletedException(LoanChargeCannotBeDeletedReason.LOAN_NOT_IN_SUBMITTED_AND_PENDING_APPROVAL_STAGE, throw new LoanChargeCannotBeDeletedException(LoanChargeCannotBeDeletedReason.LOAN_NOT_IN_SUBMITTED_AND_PENDING_APPROVAL_STAGE,
loanCharge.getId()); loanCharge.getId());
} }
this.businessEventNotifierService.notifyBusinessEventToBeExecuted(BusinessEvent.LOAN_DELETE_CHARGE,
constructEntityMap(BusinessEntity.LOAN_CHARGE, loanCharge));
loan.removeLoanCharge(loanCharge); loan.removeLoanCharge(loanCharge);
saveLoanWithDataIntegrityViolationChecks(loan); saveLoanWithDataIntegrityViolationChecks(loan);
this.businessEventNotifierService.notifyBusinessEventWasExecuted(BusinessEvent.LOAN_DELETE_CHARGE, businessEventNotifierService.notifyBusinessEvent(new LoanDeleteChargeBusinessEvent(loanCharge));
constructEntityMap(BusinessEntity.LOAN_CHARGE, loanCharge));
return new CommandProcessingResultBuilder() // return new CommandProcessingResultBuilder() //
.withCommandId(command.commandId()) // .withCommandId(command.commandId()) //
.withEntityId(loanChargeId) // .withEntityId(loanChargeId) //
@@ -2172,7 +2076,7 @@ public class LoanWritePlatformServiceJpaRepositoryImpl implements LoanWritePlatf
try { try {
this.accountTransfersWritePlatformService.transferFunds(accountTransferDTO); this.accountTransfersWritePlatformService.transferFunds(accountTransferDTO);
} catch (RuntimeException e) { } catch (RuntimeException e) {
LOG.error("Exception while paying charge {} for loan id {}", accountTransferDTO.getChargeId(), log.error("Exception while paying charge {} for loan id {}", accountTransferDTO.getChargeId(),
accountTransferDTO.getToAccountId(), e); accountTransferDTO.getToAccountId(), e);
errors.add(e); errors.add(e);
} }
@@ -2197,9 +2101,6 @@ public class LoanWritePlatformServiceJpaRepositoryImpl implements LoanWritePlatf
checkClientOrGroupActive(loan); checkClientOrGroupActive(loan);
validateTransactionsForTransfer(loan, transferDate); validateTransactionsForTransfer(loan, transferDate);
this.businessEventNotifierService.notifyBusinessEventToBeExecuted(BusinessEvent.LOAN_INITIATE_TRANSFER,
constructEntityMap(BusinessEntity.LOAN, loan));
final List<Long> existingTransactionIds = new ArrayList<>(loan.findExistingTransactionIds()); final List<Long> existingTransactionIds = new ArrayList<>(loan.findExistingTransactionIds());
final List<Long> existingReversedTransactionIds = new ArrayList<>(loan.findExistingReversedTransactionIds()); final List<Long> existingReversedTransactionIds = new ArrayList<>(loan.findExistingReversedTransactionIds());
@@ -2212,8 +2113,7 @@ public class LoanWritePlatformServiceJpaRepositoryImpl implements LoanWritePlatf
saveLoanWithDataIntegrityViolationChecks(loan); saveLoanWithDataIntegrityViolationChecks(loan);
postJournalEntries(loan, existingTransactionIds, existingReversedTransactionIds); postJournalEntries(loan, existingTransactionIds, existingReversedTransactionIds);
this.businessEventNotifierService.notifyBusinessEventWasExecuted(BusinessEvent.LOAN_INITIATE_TRANSFER, businessEventNotifierService.notifyBusinessEvent(new LoanInitiateTransferBusinessEvent(loan));
constructEntityMap(BusinessEntity.LOAN, loan));
return newTransferTransaction; return newTransferTransaction;
} }
@@ -2223,8 +2123,6 @@ public class LoanWritePlatformServiceJpaRepositoryImpl implements LoanWritePlatf
final Staff loanOfficer) { final Staff loanOfficer) {
AppUser currentUser = getAppUserIfPresent(); AppUser currentUser = getAppUserIfPresent();
this.loanAssembler.setHelpers(loan); this.loanAssembler.setHelpers(loan);
this.businessEventNotifierService.notifyBusinessEventToBeExecuted(BusinessEvent.LOAN_ACCEPT_TRANSFER,
constructEntityMap(BusinessEntity.LOAN, loan));
final List<Long> existingTransactionIds = new ArrayList<>(loan.findExistingTransactionIds()); final List<Long> existingTransactionIds = new ArrayList<>(loan.findExistingTransactionIds());
final List<Long> existingReversedTransactionIds = new ArrayList<>(loan.findExistingReversedTransactionIds()); final List<Long> existingReversedTransactionIds = new ArrayList<>(loan.findExistingReversedTransactionIds());
@@ -2244,8 +2142,7 @@ public class LoanWritePlatformServiceJpaRepositoryImpl implements LoanWritePlatf
saveLoanWithDataIntegrityViolationChecks(loan); saveLoanWithDataIntegrityViolationChecks(loan);
postJournalEntries(loan, existingTransactionIds, existingReversedTransactionIds); postJournalEntries(loan, existingTransactionIds, existingReversedTransactionIds);
this.businessEventNotifierService.notifyBusinessEventWasExecuted(BusinessEvent.LOAN_ACCEPT_TRANSFER, businessEventNotifierService.notifyBusinessEvent(new LoanAcceptTransferBusinessEvent(loan));
constructEntityMap(BusinessEntity.LOAN, loan));
return newTransferAcceptanceTransaction; return newTransferAcceptanceTransaction;
} }
@@ -2255,8 +2152,6 @@ public class LoanWritePlatformServiceJpaRepositoryImpl implements LoanWritePlatf
public LoanTransaction withdrawLoanTransfer(final Loan loan, final LocalDate transferDate) { public LoanTransaction withdrawLoanTransfer(final Loan loan, final LocalDate transferDate) {
AppUser currentUser = getAppUserIfPresent(); AppUser currentUser = getAppUserIfPresent();
this.loanAssembler.setHelpers(loan); this.loanAssembler.setHelpers(loan);
this.businessEventNotifierService.notifyBusinessEventToBeExecuted(BusinessEvent.LOAN_WITHDRAW_TRANSFER,
constructEntityMap(BusinessEntity.LOAN, loan));
final List<Long> existingTransactionIds = new ArrayList<>(loan.findExistingTransactionIds()); final List<Long> existingTransactionIds = new ArrayList<>(loan.findExistingTransactionIds());
final List<Long> existingReversedTransactionIds = new ArrayList<>(loan.findExistingReversedTransactionIds()); final List<Long> existingReversedTransactionIds = new ArrayList<>(loan.findExistingReversedTransactionIds());
@@ -2270,8 +2165,7 @@ public class LoanWritePlatformServiceJpaRepositoryImpl implements LoanWritePlatf
saveLoanWithDataIntegrityViolationChecks(loan); saveLoanWithDataIntegrityViolationChecks(loan);
postJournalEntries(loan, existingTransactionIds, existingReversedTransactionIds); postJournalEntries(loan, existingTransactionIds, existingReversedTransactionIds);
this.businessEventNotifierService.notifyBusinessEventWasExecuted(BusinessEvent.LOAN_WITHDRAW_TRANSFER, businessEventNotifierService.notifyBusinessEvent(new LoanWithdrawTransferBusinessEvent(loan));
constructEntityMap(BusinessEntity.LOAN, loan));
return newTransferAcceptanceTransaction; return newTransferAcceptanceTransaction;
} }
@@ -2280,12 +2174,9 @@ public class LoanWritePlatformServiceJpaRepositoryImpl implements LoanWritePlatf
@Override @Override
public void rejectLoanTransfer(final Loan loan) { public void rejectLoanTransfer(final Loan loan) {
this.loanAssembler.setHelpers(loan); this.loanAssembler.setHelpers(loan);
this.businessEventNotifierService.notifyBusinessEventToBeExecuted(BusinessEvent.LOAN_REJECT_TRANSFER,
constructEntityMap(BusinessEntity.LOAN, loan));
loan.setLoanStatus(LoanStatus.TRANSFER_ON_HOLD.getValue()); loan.setLoanStatus(LoanStatus.TRANSFER_ON_HOLD.getValue());
saveLoanWithDataIntegrityViolationChecks(loan); saveLoanWithDataIntegrityViolationChecks(loan);
this.businessEventNotifierService.notifyBusinessEventWasExecuted(BusinessEvent.LOAN_REJECT_TRANSFER, businessEventNotifierService.notifyBusinessEvent(new LoanRejectTransferBusinessEvent(loan));
constructEntityMap(BusinessEntity.LOAN, loan));
} }
@Transactional @Transactional
@@ -2303,8 +2194,6 @@ public class LoanWritePlatformServiceJpaRepositoryImpl implements LoanWritePlatf
final Loan loan = this.loanAssembler.assembleFrom(loanId); final Loan loan = this.loanAssembler.assembleFrom(loanId);
checkClientOrGroupActive(loan); checkClientOrGroupActive(loan);
this.businessEventNotifierService.notifyBusinessEventToBeExecuted(BusinessEvent.LOAN_REASSIGN_OFFICER,
constructEntityMap(BusinessEntity.LOAN, loan));
if (!loan.hasLoanOfficer(fromLoanOfficer)) { if (!loan.hasLoanOfficer(fromLoanOfficer)) {
throw new LoanOfficerAssignmentException(loanId, fromLoanOfficerId); throw new LoanOfficerAssignmentException(loanId, fromLoanOfficerId);
} }
@@ -2312,8 +2201,7 @@ public class LoanWritePlatformServiceJpaRepositoryImpl implements LoanWritePlatf
loan.reassignLoanOfficer(toLoanOfficer, dateOfLoanOfficerAssignment); loan.reassignLoanOfficer(toLoanOfficer, dateOfLoanOfficerAssignment);
saveLoanWithDataIntegrityViolationChecks(loan); saveLoanWithDataIntegrityViolationChecks(loan);
this.businessEventNotifierService.notifyBusinessEventWasExecuted(BusinessEvent.LOAN_REASSIGN_OFFICER, businessEventNotifierService.notifyBusinessEvent(new LoanReassignOfficerBusinessEvent(loan));
constructEntityMap(BusinessEntity.LOAN, loan));
return new CommandProcessingResultBuilder() // return new CommandProcessingResultBuilder() //
.withCommandId(command.commandId()) // .withCommandId(command.commandId()) //
@@ -2343,8 +2231,6 @@ public class LoanWritePlatformServiceJpaRepositoryImpl implements LoanWritePlatf
for (final String loanIdString : loanIds) { for (final String loanIdString : loanIds) {
final Long loanId = Long.valueOf(loanIdString); final Long loanId = Long.valueOf(loanIdString);
final Loan loan = this.loanAssembler.assembleFrom(loanId); final Loan loan = this.loanAssembler.assembleFrom(loanId);
this.businessEventNotifierService.notifyBusinessEventToBeExecuted(BusinessEvent.LOAN_REASSIGN_OFFICER,
constructEntityMap(BusinessEntity.LOAN, loan));
checkClientOrGroupActive(loan); checkClientOrGroupActive(loan);
if (!loan.hasLoanOfficer(fromLoanOfficer)) { if (!loan.hasLoanOfficer(fromLoanOfficer)) {
@@ -2353,8 +2239,7 @@ public class LoanWritePlatformServiceJpaRepositoryImpl implements LoanWritePlatf
loan.reassignLoanOfficer(toLoanOfficer, dateOfLoanOfficerAssignment); loan.reassignLoanOfficer(toLoanOfficer, dateOfLoanOfficerAssignment);
saveLoanWithDataIntegrityViolationChecks(loan); saveLoanWithDataIntegrityViolationChecks(loan);
this.businessEventNotifierService.notifyBusinessEventWasExecuted(BusinessEvent.LOAN_REASSIGN_OFFICER, businessEventNotifierService.notifyBusinessEvent(new LoanReassignOfficerBusinessEvent(loan));
constructEntityMap(BusinessEntity.LOAN, loan));
} }
this.loanRepositoryWrapper.flush(); this.loanRepositoryWrapper.flush();
@@ -2379,14 +2264,10 @@ public class LoanWritePlatformServiceJpaRepositoryImpl implements LoanWritePlatf
if (loan.getLoanOfficer() == null) { if (loan.getLoanOfficer() == null) {
throw new LoanOfficerUnassignmentException(loanId); throw new LoanOfficerUnassignmentException(loanId);
} }
this.businessEventNotifierService.notifyBusinessEventToBeExecuted(BusinessEvent.LOAN_REMOVE_OFFICER,
constructEntityMap(BusinessEntity.LOAN, loan));
loan.removeLoanOfficer(dateOfLoanOfficerunAssigned); loan.removeLoanOfficer(dateOfLoanOfficerunAssigned);
saveLoanWithDataIntegrityViolationChecks(loan); saveLoanWithDataIntegrityViolationChecks(loan);
this.businessEventNotifierService.notifyBusinessEventWasExecuted(BusinessEvent.LOAN_REMOVE_OFFICER, businessEventNotifierService.notifyBusinessEvent(new LoanRemoveOfficerBusinessEvent(loan));
constructEntityMap(BusinessEntity.LOAN, loan));
return new CommandProcessingResultBuilder() // return new CommandProcessingResultBuilder() //
.withCommandId(command.commandId()) // .withCommandId(command.commandId()) //
@@ -2754,8 +2635,7 @@ public class LoanWritePlatformServiceJpaRepositoryImpl implements LoanWritePlatf
&& loan.isFeeCompoundingEnabledForInterestRecalculation()) { && loan.isFeeCompoundingEnabledForInterestRecalculation()) {
this.loanAccountDomainService.recalculateAccruals(loan); this.loanAccountDomainService.recalculateAccruals(loan);
} }
this.businessEventNotifierService.notifyBusinessEventWasExecuted(BusinessEvent.LOAN_APPLY_OVERDUE_CHARGE, businessEventNotifierService.notifyBusinessEvent(new LoanApplyOverdueChargeBusinessEvent(loan));
constructEntityMap(BusinessEntity.LOAN, loan));
} }
} }
@@ -2835,8 +2715,6 @@ public class LoanWritePlatformServiceJpaRepositoryImpl implements LoanWritePlatf
LocalDate recalculateFrom = DateUtils.getLocalDateOfTenant(); LocalDate recalculateFrom = DateUtils.getLocalDateOfTenant();
if (loan != null) { if (loan != null) {
this.businessEventNotifierService.notifyBusinessEventToBeExecuted(BusinessEvent.LOAN_APPLY_OVERDUE_CHARGE,
constructEntityMap(BusinessEntity.LOAN, loan));
for (Map.Entry<Integer, LocalDate> entry : scheduleDates.entrySet()) { for (Map.Entry<Integer, LocalDate> entry : scheduleDates.entrySet()) {
final LoanCharge loanCharge = LoanCharge.createNewFromJson(loan, chargeDefinition, command, entry.getValue()); final LoanCharge loanCharge = LoanCharge.createNewFromJson(loan, chargeDefinition, command, entry.getValue());
@@ -2876,8 +2754,6 @@ public class LoanWritePlatformServiceJpaRepositoryImpl implements LoanWritePlatf
} }
LocalDate recalculateFrom = null; LocalDate recalculateFrom = null;
LoanTransaction writeOffTransaction = loan.findWriteOffTransaction(); LoanTransaction writeOffTransaction = loan.findWriteOffTransaction();
this.businessEventNotifierService.notifyBusinessEventToBeExecuted(BusinessEvent.LOAN_UNDO_WRITTEN_OFF,
constructEntityMap(BusinessEntity.LOAN_TRANSACTION, writeOffTransaction));
ScheduleGeneratorDTO scheduleGeneratorDTO = this.loanUtilService.buildScheduleGeneratorDTO(loan, recalculateFrom); ScheduleGeneratorDTO scheduleGeneratorDTO = this.loanUtilService.buildScheduleGeneratorDTO(loan, recalculateFrom);
@@ -2894,8 +2770,7 @@ public class LoanWritePlatformServiceJpaRepositoryImpl implements LoanWritePlatf
postJournalEntries(loan, existingTransactionIds, existingReversedTransactionIds); postJournalEntries(loan, existingTransactionIds, existingReversedTransactionIds);
this.loanAccountDomainService.recalculateAccruals(loan); this.loanAccountDomainService.recalculateAccruals(loan);
if (writeOffTransaction != null) { if (writeOffTransaction != null) {
this.businessEventNotifierService.notifyBusinessEventWasExecuted(BusinessEvent.LOAN_UNDO_WRITTEN_OFF, businessEventNotifierService.notifyBusinessEvent(new LoanUndoWrittenOffBusinessEvent(writeOffTransaction));
constructEntityMap(BusinessEntity.LOAN_TRANSACTION, writeOffTransaction));
} }
return new CommandProcessingResultBuilder() // return new CommandProcessingResultBuilder() //
.withOfficeId(loan.getOfficeId()) // .withOfficeId(loan.getOfficeId()) //
@@ -3147,8 +3022,6 @@ public class LoanWritePlatformServiceJpaRepositoryImpl implements LoanWritePlatf
Loan loan = this.loanAssembler.assembleFrom(loanId); Loan loan = this.loanAssembler.assembleFrom(loanId);
LocalDate recalculateFrom = loan.fetchInterestRecalculateFromDate(); LocalDate recalculateFrom = loan.fetchInterestRecalculateFromDate();
AppUser currentUser = getAppUserIfPresent(); AppUser currentUser = getAppUserIfPresent();
this.businessEventNotifierService.notifyBusinessEventToBeExecuted(BusinessEvent.LOAN_INTEREST_RECALCULATION,
constructEntityMap(BusinessEntity.LOAN, loan));
final List<Long> existingTransactionIds = new ArrayList<>(); final List<Long> existingTransactionIds = new ArrayList<>();
final List<Long> existingReversedTransactionIds = new ArrayList<>(); final List<Long> existingReversedTransactionIds = new ArrayList<>();
@@ -3169,9 +3042,8 @@ public class LoanWritePlatformServiceJpaRepositoryImpl implements LoanWritePlatf
} }
} }
postJournalEntries(loan, existingTransactionIds, existingReversedTransactionIds); postJournalEntries(loan, existingTransactionIds, existingReversedTransactionIds);
this.loanAccountDomainService.recalculateAccruals(loan); loanAccountDomainService.recalculateAccruals(loan);
this.businessEventNotifierService.notifyBusinessEventWasExecuted(BusinessEvent.LOAN_INTEREST_RECALCULATION, businessEventNotifierService.notifyBusinessEvent(new LoanInterestRecalculationBusinessEvent(loan));
constructEntityMap(BusinessEntity.LOAN, loan));
} }
@Override @Override
@@ -3309,12 +3181,6 @@ public class LoanWritePlatformServiceJpaRepositoryImpl implements LoanWritePlatf
return user; return user;
} }
private Map<BusinessEntity, Object> constructEntityMap(final BusinessEntity entityEvent, Object entity) {
Map<BusinessEntity, Object> map = new HashMap<>(1);
map.put(entityEvent, entity);
return map;
}
@Override @Override
@Transactional @Transactional
public CommandProcessingResult undoLastLoanDisbursal(Long loanId, JsonCommand command) { public CommandProcessingResult undoLastLoanDisbursal(Long loanId, JsonCommand command) {
@@ -3324,8 +3190,6 @@ public class LoanWritePlatformServiceJpaRepositoryImpl implements LoanWritePlatf
final LocalDate recalculateFromDate = loan.getLastRepaymentDate(); final LocalDate recalculateFromDate = loan.getLastRepaymentDate();
validateIsMultiDisbursalLoanAndDisbursedMoreThanOneTranche(loan); validateIsMultiDisbursalLoanAndDisbursedMoreThanOneTranche(loan);
checkClientOrGroupActive(loan); checkClientOrGroupActive(loan);
this.businessEventNotifierService.notifyBusinessEventToBeExecuted(BusinessEvent.LOAN_UNDO_LASTDISBURSAL,
constructEntityMap(BusinessEntity.LOAN, loan));
final MonetaryCurrency currency = loan.getCurrency(); final MonetaryCurrency currency = loan.getCurrency();
final ApplicationCurrency applicationCurrency = this.applicationCurrencyRepository.findOneWithNotFoundDetection(currency); final ApplicationCurrency applicationCurrency = this.applicationCurrencyRepository.findOneWithNotFoundDetection(currency);
@@ -3349,9 +3213,8 @@ public class LoanWritePlatformServiceJpaRepositoryImpl implements LoanWritePlatf
boolean isAccountTransfer = false; boolean isAccountTransfer = false;
final Map<String, Object> accountingBridgeData = loan.deriveAccountingBridgeData(applicationCurrency.toData(), final Map<String, Object> accountingBridgeData = loan.deriveAccountingBridgeData(applicationCurrency.toData(),
existingTransactionIds, existingReversedTransactionIds, isAccountTransfer); existingTransactionIds, existingReversedTransactionIds, isAccountTransfer);
this.journalEntryWritePlatformService.createJournalEntriesForLoan(accountingBridgeData); journalEntryWritePlatformService.createJournalEntriesForLoan(accountingBridgeData);
this.businessEventNotifierService.notifyBusinessEventWasExecuted(BusinessEvent.LOAN_UNDO_LASTDISBURSAL, businessEventNotifierService.notifyBusinessEvent(new LoanUndoLastDisbursalBusinessEvent(loan));
constructEntityMap(BusinessEntity.LOAN, loan));
} }
return new CommandProcessingResultBuilder() // return new CommandProcessingResultBuilder() //
@@ -22,7 +22,6 @@ import com.google.gson.JsonArray;
import com.google.gson.JsonObject; import com.google.gson.JsonObject;
import java.time.LocalDate; import java.time.LocalDate;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import javax.persistence.PersistenceException; import javax.persistence.PersistenceException;
@@ -35,8 +34,7 @@ import org.apache.fineract.infrastructure.core.exception.PlatformDataIntegrityEx
import org.apache.fineract.infrastructure.entityaccess.domain.FineractEntityAccessType; import org.apache.fineract.infrastructure.entityaccess.domain.FineractEntityAccessType;
import org.apache.fineract.infrastructure.entityaccess.service.FineractEntityAccessUtil; import org.apache.fineract.infrastructure.entityaccess.service.FineractEntityAccessUtil;
import org.apache.fineract.infrastructure.security.service.PlatformSecurityContext; import org.apache.fineract.infrastructure.security.service.PlatformSecurityContext;
import org.apache.fineract.portfolio.businessevent.domain.BusinessEntity; import org.apache.fineract.portfolio.businessevent.domain.loan.product.LoanProductCreateBusinessEvent;
import org.apache.fineract.portfolio.businessevent.domain.BusinessEvent;
import org.apache.fineract.portfolio.businessevent.service.BusinessEventNotifierService; import org.apache.fineract.portfolio.businessevent.service.BusinessEventNotifierService;
import org.apache.fineract.portfolio.charge.domain.Charge; import org.apache.fineract.portfolio.charge.domain.Charge;
import org.apache.fineract.portfolio.charge.domain.ChargeRepositoryWrapper; import org.apache.fineract.portfolio.charge.domain.ChargeRepositoryWrapper;
@@ -136,29 +134,25 @@ public class LoanProductWritePlatformServiceJpaRepositoryImpl implements LoanPro
floatingRate = this.floatingRateRepository floatingRate = this.floatingRateRepository
.findOneWithNotFoundDetection(command.longValueOfParameterNamed("floatingRatesId")); .findOneWithNotFoundDetection(command.longValueOfParameterNamed("floatingRatesId"));
} }
final LoanProduct loanproduct = LoanProduct.assembleFromJson(fund, loanTransactionProcessingStrategy, charges, command, final LoanProduct loanProduct = LoanProduct.assembleFromJson(fund, loanTransactionProcessingStrategy, charges, command,
this.aprCalculator, floatingRate, rates); this.aprCalculator, floatingRate, rates);
loanproduct.updateLoanProductInRelatedClasses(); loanProduct.updateLoanProductInRelatedClasses();
this.loanProductRepository.saveAndFlush(loanproduct); this.loanProductRepository.saveAndFlush(loanProduct);
// save accounting mappings // save accounting mappings
this.accountMappingWritePlatformService.createLoanProductToGLAccountMapping(loanproduct.getId(), command); this.accountMappingWritePlatformService.createLoanProductToGLAccountMapping(loanProduct.getId(), command);
// check if the office specific products are enabled. If yes, then // check if the office specific products are enabled. If yes, then
// save this savings product against a specific office // save this savings product against a specific office
// i.e. this savings product is specific for this office. // i.e. this savings product is specific for this office.
fineractEntityAccessUtil.checkConfigurationAndAddProductResrictionsForUserOffice( fineractEntityAccessUtil.checkConfigurationAndAddProductResrictionsForUserOffice(
FineractEntityAccessType.OFFICE_ACCESS_TO_LOAN_PRODUCTS, loanproduct.getId()); FineractEntityAccessType.OFFICE_ACCESS_TO_LOAN_PRODUCTS, loanProduct.getId());
this.businessEventNotifierService.notifyBusinessEventWasExecuted(BusinessEvent.LOAN_PRODUCT_CREATE, businessEventNotifierService.notifyBusinessEvent(new LoanProductCreateBusinessEvent(loanProduct));
constructEntityMap(BusinessEntity.LOAN_PRODUCT, loanproduct));
this.businessEventNotifierService.notifyBusinessEventWasExecuted(BusinessEvent.LOAN_PRODUCT_CREATE,
constructEntityMap(BusinessEntity.LOAN_PRODUCT, loanproduct));
return new CommandProcessingResultBuilder() // return new CommandProcessingResultBuilder() //
.withCommandId(command.commandId()) // .withCommandId(command.commandId()) //
.withEntityId(loanproduct.getId()) // .withEntityId(loanProduct.getId()) //
.build(); .build();
} catch (final JpaSystemException | DataIntegrityViolationException dve) { } catch (final JpaSystemException | DataIntegrityViolationException dve) {
@@ -381,10 +375,4 @@ public class LoanProductWritePlatformServiceJpaRepositoryImpl implements LoanPro
private void logAsErrorUnexpectedDataIntegrityException(final Exception dve) { private void logAsErrorUnexpectedDataIntegrityException(final Exception dve) {
LOG.error("Error occured.", dve); LOG.error("Error occured.", dve);
} }
private Map<BusinessEntity, Object> constructEntityMap(final BusinessEntity entityEvent, Object entity) {
Map<BusinessEntity, Object> map = new HashMap<>(1);
map.put(entityEvent, entity);
return map;
}
} }
@@ -24,7 +24,6 @@ import java.time.LocalDate;
import java.time.format.DateTimeFormatter; import java.time.format.DateTimeFormatter;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Date; import java.util.Date;
import java.util.HashMap;
import java.util.HashSet; import java.util.HashSet;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
@@ -38,8 +37,8 @@ import org.apache.fineract.organisation.monetary.domain.ApplicationCurrencyRepos
import org.apache.fineract.organisation.monetary.domain.MonetaryCurrency; import org.apache.fineract.organisation.monetary.domain.MonetaryCurrency;
import org.apache.fineract.organisation.monetary.domain.Money; import org.apache.fineract.organisation.monetary.domain.Money;
import org.apache.fineract.organisation.monetary.domain.MoneyHelper; import org.apache.fineract.organisation.monetary.domain.MoneyHelper;
import org.apache.fineract.portfolio.businessevent.domain.BusinessEntity; import org.apache.fineract.portfolio.businessevent.domain.savings.transaction.SavingsDepositBusinessEvent;
import org.apache.fineract.portfolio.businessevent.domain.BusinessEvent; import org.apache.fineract.portfolio.businessevent.domain.savings.transaction.SavingsWithdrawalBusinessEvent;
import org.apache.fineract.portfolio.businessevent.service.BusinessEventNotifierService; import org.apache.fineract.portfolio.businessevent.service.BusinessEventNotifierService;
import org.apache.fineract.portfolio.paymentdetail.domain.PaymentDetail; import org.apache.fineract.portfolio.paymentdetail.domain.PaymentDetail;
import org.apache.fineract.portfolio.savings.SavingsAccountTransactionType; import org.apache.fineract.portfolio.savings.SavingsAccountTransactionType;
@@ -139,8 +138,7 @@ public class SavingsAccountDomainServiceJpa implements SavingsAccountDomainServi
postJournalEntries(account, existingTransactionIds, existingReversedTransactionIds, transactionBooleanValues.isAccountTransfer(), postJournalEntries(account, existingTransactionIds, existingReversedTransactionIds, transactionBooleanValues.isAccountTransfer(),
backdatedTxnsAllowedTill); backdatedTxnsAllowedTill);
this.businessEventNotifierService.notifyBusinessEventWasExecuted(BusinessEvent.SAVINGS_WITHDRAWAL, businessEventNotifierService.notifyBusinessEvent(new SavingsWithdrawalBusinessEvent(withdrawal));
constructEntityMap(BusinessEntity.SAVINGS_TRANSACTION, withdrawal));
return withdrawal; return withdrawal;
} }
@@ -215,8 +213,7 @@ public class SavingsAccountDomainServiceJpa implements SavingsAccountDomainServi
this.savingsAccountRepository.saveAndFlush(account); this.savingsAccountRepository.saveAndFlush(account);
postJournalEntries(account, existingTransactionIds, existingReversedTransactionIds, isAccountTransfer, backdatedTxnsAllowedTill); postJournalEntries(account, existingTransactionIds, existingReversedTransactionIds, isAccountTransfer, backdatedTxnsAllowedTill);
this.businessEventNotifierService.notifyBusinessEventWasExecuted(BusinessEvent.SAVINGS_DEPOSIT, businessEventNotifierService.notifyBusinessEvent(new SavingsDepositBusinessEvent(deposit));
constructEntityMap(BusinessEntity.SAVINGS_TRANSACTION, deposit));
return deposit; return deposit;
} }
@@ -285,12 +282,6 @@ public class SavingsAccountDomainServiceJpa implements SavingsAccountDomainServi
postJournalEntries(account, existingTransactionIds, existingReversedTransactionIds, isAccountTransfer, backdatedTxnsAllowedTill); postJournalEntries(account, existingTransactionIds, existingReversedTransactionIds, isAccountTransfer, backdatedTxnsAllowedTill);
} }
private Map<BusinessEntity, Object> constructEntityMap(final BusinessEntity entityEvent, Object entity) {
Map<BusinessEntity, Object> map = new HashMap<>(1);
map.put(entityEvent, entity);
return map;
}
@Override @Override
public SavingsAccountTransaction handleReversal(SavingsAccount account, SavingsAccountTransaction savingsAccountTransaction, public SavingsAccountTransaction handleReversal(SavingsAccount account, SavingsAccountTransaction savingsAccountTransaction,
boolean backdatedTxnsAllowedTill) { boolean backdatedTxnsAllowedTill) {
@@ -27,7 +27,6 @@ import java.math.MathContext;
import java.time.LocalDate; import java.time.LocalDate;
import java.time.temporal.ChronoField; import java.time.temporal.ChronoField;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.HashMap;
import java.util.LinkedHashMap; import java.util.LinkedHashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
@@ -55,8 +54,8 @@ import org.apache.fineract.organisation.staff.domain.StaffRepositoryWrapper;
import org.apache.fineract.portfolio.account.domain.AccountAssociationType; import org.apache.fineract.portfolio.account.domain.AccountAssociationType;
import org.apache.fineract.portfolio.account.domain.AccountAssociations; import org.apache.fineract.portfolio.account.domain.AccountAssociations;
import org.apache.fineract.portfolio.account.domain.AccountAssociationsRepository; import org.apache.fineract.portfolio.account.domain.AccountAssociationsRepository;
import org.apache.fineract.portfolio.businessevent.domain.BusinessEntity; import org.apache.fineract.portfolio.businessevent.domain.deposit.FixedDepositAccountCreateBusinessEvent;
import org.apache.fineract.portfolio.businessevent.domain.BusinessEvent; import org.apache.fineract.portfolio.businessevent.domain.deposit.RecurringDepositAccountCreateBusinessEvent;
import org.apache.fineract.portfolio.businessevent.service.BusinessEventNotifierService; import org.apache.fineract.portfolio.businessevent.service.BusinessEventNotifierService;
import org.apache.fineract.portfolio.calendar.domain.Calendar; import org.apache.fineract.portfolio.calendar.domain.Calendar;
import org.apache.fineract.portfolio.calendar.domain.CalendarEntityType; import org.apache.fineract.portfolio.calendar.domain.CalendarEntityType;
@@ -231,11 +230,7 @@ public class DepositApplicationProcessWritePlatformServiceJpaRepositoryImpl impl
} }
final Long savingsId = account.getId(); final Long savingsId = account.getId();
this.businessEventNotifierService.notifyBusinessEventWasExecuted(BusinessEvent.FIXED_DEPOSIT_ACCOUNT_CREATE, businessEventNotifierService.notifyBusinessEvent(new FixedDepositAccountCreateBusinessEvent(account));
constructEntityMap(BusinessEntity.DEPOSIT_ACCOUNT, account));
this.businessEventNotifierService.notifyBusinessEventWasExecuted(BusinessEvent.FIXED_DEPOSIT_ACCOUNT_CREATE,
constructEntityMap(BusinessEntity.DEPOSIT_ACCOUNT, account));
return new CommandProcessingResultBuilder() // return new CommandProcessingResultBuilder() //
.withCommandId(command.commandId()) // .withCommandId(command.commandId()) //
@@ -293,12 +288,8 @@ public class DepositApplicationProcessWritePlatformServiceJpaRepositoryImpl impl
account.updateMaturityDateAndAmount(mc, isPreMatureClosure, isSavingsInterestPostingAtCurrentPeriodEnd, account.updateMaturityDateAndAmount(mc, isPreMatureClosure, isSavingsInterestPostingAtCurrentPeriodEnd,
financialYearBeginningMonth); financialYearBeginningMonth);
account.validateApplicableInterestRate(); account.validateApplicableInterestRate();
this.savingAccountRepository.save(account); savingAccountRepository.save(account);
this.businessEventNotifierService.notifyBusinessEventWasExecuted(BusinessEvent.RECURRING_DEPOSIT_ACCOUNT_CREATE, businessEventNotifierService.notifyBusinessEvent(new RecurringDepositAccountCreateBusinessEvent(account));
constructEntityMap(BusinessEntity.DEPOSIT_ACCOUNT, account));
this.businessEventNotifierService.notifyBusinessEventWasExecuted(BusinessEvent.RECURRING_DEPOSIT_ACCOUNT_CREATE,
constructEntityMap(BusinessEntity.DEPOSIT_ACCOUNT, account));
return new CommandProcessingResultBuilder() // return new CommandProcessingResultBuilder() //
.withCommandId(command.commandId()) // .withCommandId(command.commandId()) //
@@ -792,10 +783,4 @@ public class DepositApplicationProcessWritePlatformServiceJpaRepositoryImpl impl
} }
} }
} }
private Map<BusinessEntity, Object> constructEntityMap(final BusinessEntity entityEvent, Object entity) {
Map<BusinessEntity, Object> map = new HashMap<>(1);
map.put(entityEvent, entity);
return map;
}
} }
@@ -79,8 +79,9 @@ import org.apache.fineract.portfolio.account.domain.StandingInstructionRepositor
import org.apache.fineract.portfolio.account.domain.StandingInstructionStatus; import org.apache.fineract.portfolio.account.domain.StandingInstructionStatus;
import org.apache.fineract.portfolio.account.service.AccountAssociationsReadPlatformService; import org.apache.fineract.portfolio.account.service.AccountAssociationsReadPlatformService;
import org.apache.fineract.portfolio.account.service.AccountTransfersReadPlatformService; import org.apache.fineract.portfolio.account.service.AccountTransfersReadPlatformService;
import org.apache.fineract.portfolio.businessevent.domain.BusinessEntity; import org.apache.fineract.portfolio.businessevent.domain.savings.SavingsActivateBusinessEvent;
import org.apache.fineract.portfolio.businessevent.domain.BusinessEvent; import org.apache.fineract.portfolio.businessevent.domain.savings.SavingsCloseBusinessEvent;
import org.apache.fineract.portfolio.businessevent.domain.savings.SavingsPostInterestBusinessEvent;
import org.apache.fineract.portfolio.businessevent.service.BusinessEventNotifierService; import org.apache.fineract.portfolio.businessevent.service.BusinessEventNotifierService;
import org.apache.fineract.portfolio.charge.domain.Charge; import org.apache.fineract.portfolio.charge.domain.Charge;
import org.apache.fineract.portfolio.charge.domain.ChargeRepositoryWrapper; import org.apache.fineract.portfolio.charge.domain.ChargeRepositoryWrapper;
@@ -272,8 +273,7 @@ public class SavingsAccountWritePlatformServiceJpaRepositoryImpl implements Savi
} }
postJournalEntries(account, existingTransactionIds, existingReversedTransactionIds, false); postJournalEntries(account, existingTransactionIds, existingReversedTransactionIds, false);
this.businessEventNotifierService.notifyBusinessEventWasExecuted(BusinessEvent.SAVINGS_ACTIVATE, businessEventNotifierService.notifyBusinessEvent(new SavingsActivateBusinessEvent(account));
constructEntityMap(BusinessEntity.SAVING, account));
return new CommandProcessingResultBuilder() // return new CommandProcessingResultBuilder() //
.withEntityId(savingsId) // .withEntityId(savingsId) //
@@ -577,8 +577,7 @@ public class SavingsAccountWritePlatformServiceJpaRepositoryImpl implements Savi
} }
postInterest(account, postInterestAs, transactionDate, backdatedTxnsAllowedTill); postInterest(account, postInterestAs, transactionDate, backdatedTxnsAllowedTill);
this.businessEventNotifierService.notifyBusinessEventWasExecuted(BusinessEvent.SAVINGS_POST_INTEREST, businessEventNotifierService.notifyBusinessEvent(new SavingsPostInterestBusinessEvent(account));
constructEntityMap(BusinessEntity.SAVING, account));
return new CommandProcessingResultBuilder() // return new CommandProcessingResultBuilder() //
.withEntityId(savingsId) // .withEntityId(savingsId) //
.withOfficeId(account.officeId()) // .withOfficeId(account.officeId()) //
@@ -1032,10 +1031,9 @@ public class SavingsAccountWritePlatformServiceJpaRepositoryImpl implements Savi
} }
this.businessEventNotifierService.notifyBusinessEventWasExecuted(BusinessEvent.SAVINGS_CLOSE, businessEventNotifierService.notifyBusinessEvent(new SavingsCloseBusinessEvent(account));
constructEntityMap(BusinessEntity.SAVING, account));
// disable all standing orders linked to the savings account // disable all standing orders linked to the savings account
this.disableStandingInstructionsLinkedToClosedSavings(account); disableStandingInstructionsLinkedToClosedSavings(account);
return new CommandProcessingResultBuilder() // return new CommandProcessingResultBuilder() //
.withEntityId(savingsId) // .withEntityId(savingsId) //
.withOfficeId(account.officeId()) // .withOfficeId(account.officeId()) //
@@ -1760,12 +1758,6 @@ public class SavingsAccountWritePlatformServiceJpaRepositoryImpl implements Savi
} }
} }
private Map<BusinessEntity, Object> constructEntityMap(final BusinessEntity entityEvent, Object entity) {
Map<BusinessEntity, Object> map = new HashMap<>(1);
map.put(entityEvent, entity);
return map;
}
@Override @Override
public CommandProcessingResult blockAccount(final Long savingsId, final JsonCommand command) { public CommandProcessingResult blockAccount(final Long savingsId, final JsonCommand command) {
@@ -26,13 +26,14 @@ import java.math.BigDecimal;
import java.time.ZoneId; import java.time.ZoneId;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Date; import java.util.Date;
import java.util.HashMap;
import java.util.HashSet; import java.util.HashSet;
import java.util.LinkedHashMap; import java.util.LinkedHashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Set; import java.util.Set;
import javax.persistence.PersistenceException; import javax.persistence.PersistenceException;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.exception.ExceptionUtils; import org.apache.commons.lang3.exception.ExceptionUtils;
import org.apache.fineract.commands.domain.CommandWrapper; import org.apache.fineract.commands.domain.CommandWrapper;
@@ -56,8 +57,9 @@ import org.apache.fineract.infrastructure.security.service.PlatformSecurityConte
import org.apache.fineract.organisation.monetary.domain.Money; import org.apache.fineract.organisation.monetary.domain.Money;
import org.apache.fineract.organisation.staff.domain.Staff; import org.apache.fineract.organisation.staff.domain.Staff;
import org.apache.fineract.organisation.staff.domain.StaffRepositoryWrapper; import org.apache.fineract.organisation.staff.domain.StaffRepositoryWrapper;
import org.apache.fineract.portfolio.businessevent.domain.BusinessEntity; import org.apache.fineract.portfolio.businessevent.domain.savings.SavingsApproveBusinessEvent;
import org.apache.fineract.portfolio.businessevent.domain.BusinessEvent; import org.apache.fineract.portfolio.businessevent.domain.savings.SavingsCreateBusinessEvent;
import org.apache.fineract.portfolio.businessevent.domain.savings.SavingsRejectBusinessEvent;
import org.apache.fineract.portfolio.businessevent.service.BusinessEventNotifierService; import org.apache.fineract.portfolio.businessevent.service.BusinessEventNotifierService;
import org.apache.fineract.portfolio.client.domain.AccountNumberGenerator; import org.apache.fineract.portfolio.client.domain.AccountNumberGenerator;
import org.apache.fineract.portfolio.client.domain.Client; import org.apache.fineract.portfolio.client.domain.Client;
@@ -87,18 +89,15 @@ import org.apache.fineract.portfolio.savings.domain.SavingsProduct;
import org.apache.fineract.portfolio.savings.domain.SavingsProductRepository; import org.apache.fineract.portfolio.savings.domain.SavingsProductRepository;
import org.apache.fineract.portfolio.savings.exception.SavingsProductNotFoundException; import org.apache.fineract.portfolio.savings.exception.SavingsProductNotFoundException;
import org.apache.fineract.useradministration.domain.AppUser; import org.apache.fineract.useradministration.domain.AppUser;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.dao.DataAccessException; import org.springframework.dao.DataAccessException;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
@Service @Service
@Slf4j
@RequiredArgsConstructor
public class SavingsApplicationProcessWritePlatformServiceJpaRepositoryImpl implements SavingsApplicationProcessWritePlatformService { public class SavingsApplicationProcessWritePlatformServiceJpaRepositoryImpl implements SavingsApplicationProcessWritePlatformService {
private static final Logger LOG = LoggerFactory.getLogger(SavingsApplicationProcessWritePlatformServiceJpaRepositoryImpl.class);
private final PlatformSecurityContext context; private final PlatformSecurityContext context;
private final SavingsAccountRepositoryWrapper savingAccountRepository; private final SavingsAccountRepositoryWrapper savingAccountRepository;
private final SavingsAccountAssembler savingAccountAssembler; private final SavingsAccountAssembler savingAccountAssembler;
@@ -121,45 +120,6 @@ public class SavingsApplicationProcessWritePlatformServiceJpaRepositoryImpl impl
private final GroupRepositoryWrapper groupRepositoryWrapper; private final GroupRepositoryWrapper groupRepositoryWrapper;
private final GroupSavingsIndividualMonitoringWritePlatformService gsimWritePlatformService; private final GroupSavingsIndividualMonitoringWritePlatformService gsimWritePlatformService;
@Autowired
public SavingsApplicationProcessWritePlatformServiceJpaRepositoryImpl(final PlatformSecurityContext context,
final SavingsAccountRepositoryWrapper savingAccountRepository, final SavingsAccountAssembler savingAccountAssembler,
final SavingsAccountDataValidator savingsAccountDataValidator, final AccountNumberGenerator accountNumberGenerator,
final ClientRepositoryWrapper clientRepository, final GroupRepository groupRepository,
final SavingsProductRepository savingsProductRepository, final NoteRepository noteRepository,
final StaffRepositoryWrapper staffRepository,
final SavingsAccountApplicationTransitionApiJsonValidator savingsAccountApplicationTransitionApiJsonValidator,
final SavingsAccountChargeAssembler savingsAccountChargeAssembler, final CommandProcessingService commandProcessingService,
final SavingsAccountDomainService savingsAccountDomainService,
final SavingsAccountWritePlatformService savingsAccountWritePlatformService,
final AccountNumberFormatRepositoryWrapper accountNumberFormatRepository,
final BusinessEventNotifierService businessEventNotifierService,
final EntityDatatableChecksWritePlatformService entityDatatableChecksWritePlatformService, final GSIMRepositoy gsimRepository,
final GroupRepositoryWrapper groupRepositoryWrapper,
final GroupSavingsIndividualMonitoringWritePlatformService gsimWritePlatformService) {
this.context = context;
this.savingAccountRepository = savingAccountRepository;
this.savingAccountAssembler = savingAccountAssembler;
this.accountNumberGenerator = accountNumberGenerator;
this.savingsAccountDataValidator = savingsAccountDataValidator;
this.clientRepository = clientRepository;
this.groupRepository = groupRepository;
this.savingsProductRepository = savingsProductRepository;
this.noteRepository = noteRepository;
this.staffRepository = staffRepository;
this.savingsAccountApplicationTransitionApiJsonValidator = savingsAccountApplicationTransitionApiJsonValidator;
this.savingsAccountChargeAssembler = savingsAccountChargeAssembler;
this.commandProcessingService = commandProcessingService;
this.savingsAccountDomainService = savingsAccountDomainService;
this.accountNumberFormatRepository = accountNumberFormatRepository;
this.savingsAccountWritePlatformService = savingsAccountWritePlatformService;
this.businessEventNotifierService = businessEventNotifierService;
this.entityDatatableChecksWritePlatformService = entityDatatableChecksWritePlatformService;
this.gsimRepository = gsimRepository;
this.groupRepositoryWrapper = groupRepositoryWrapper;
this.gsimWritePlatformService = gsimWritePlatformService;
}
/* /*
* Guaranteed to throw an exception no matter what the data integrity issue is. * Guaranteed to throw an exception no matter what the data integrity issue is.
*/ */
@@ -182,7 +142,7 @@ public class SavingsApplicationProcessWritePlatformServiceJpaRepositoryImpl impl
} }
errorCodeBuilder.append(".unknown.data.integrity.issue"); errorCodeBuilder.append(".unknown.data.integrity.issue");
LOG.error("Error occured.", dve); log.error("Error occured.", dve);
throw new PlatformDataIntegrityException(errorCodeBuilder.toString(), "Unknown data integrity issue with savings account."); throw new PlatformDataIntegrityException(errorCodeBuilder.toString(), "Unknown data integrity issue with savings account.");
} }
@@ -305,8 +265,7 @@ public class SavingsApplicationProcessWritePlatformServiceJpaRepositoryImpl impl
this.entityDatatableChecksWritePlatformService.runTheCheckForProduct(savingsId, EntityTables.SAVING.getName(), this.entityDatatableChecksWritePlatformService.runTheCheckForProduct(savingsId, EntityTables.SAVING.getName(),
StatusEnum.CREATE.getCode().longValue(), EntityTables.SAVING.getForeignKeyColumnNameOnDatatable(), account.productId()); StatusEnum.CREATE.getCode().longValue(), EntityTables.SAVING.getForeignKeyColumnNameOnDatatable(), account.productId());
this.businessEventNotifierService.notifyBusinessEventWasExecuted(BusinessEvent.SAVINGS_CREATE, businessEventNotifierService.notifyBusinessEvent(new SavingsCreateBusinessEvent(account));
constructEntityMap(BusinessEntity.SAVING, account));
return new CommandProcessingResultBuilder() // return new CommandProcessingResultBuilder() //
.withCommandId(command.commandId()) // .withCommandId(command.commandId()) //
@@ -534,8 +493,7 @@ public class SavingsApplicationProcessWritePlatformServiceJpaRepositoryImpl impl
} }
} }
this.businessEventNotifierService.notifyBusinessEventWasExecuted(BusinessEvent.SAVINGS_APPROVE, businessEventNotifierService.notifyBusinessEvent(new SavingsApproveBusinessEvent(savingsAccount));
constructEntityMap(BusinessEntity.SAVING, savingsAccount));
return new CommandProcessingResultBuilder() // return new CommandProcessingResultBuilder() //
.withCommandId(command.commandId()) // .withCommandId(command.commandId()) //
@@ -657,8 +615,7 @@ public class SavingsApplicationProcessWritePlatformServiceJpaRepositoryImpl impl
this.noteRepository.save(note); this.noteRepository.save(note);
} }
} }
this.businessEventNotifierService.notifyBusinessEventWasExecuted(BusinessEvent.SAVINGS_REJECT, businessEventNotifierService.notifyBusinessEvent(new SavingsRejectBusinessEvent(savingsAccount));
constructEntityMap(BusinessEntity.SAVING, savingsAccount));
return new CommandProcessingResultBuilder() // return new CommandProcessingResultBuilder() //
.withCommandId(command.commandId()) // .withCommandId(command.commandId()) //
.withEntityId(savingsId) // .withEntityId(savingsId) //
@@ -759,10 +716,4 @@ public class SavingsApplicationProcessWritePlatformServiceJpaRepositoryImpl impl
.setRollbackTransaction(rollbackTransaction)// .setRollbackTransaction(rollbackTransaction)//
.build(); .build();
} }
private Map<BusinessEntity, Object> constructEntityMap(final BusinessEntity entityEvent, Object entity) {
Map<BusinessEntity, Object> map = new HashMap<>(1);
map.put(entityEvent, entity);
return map;
}
} }
@@ -42,8 +42,8 @@ import org.apache.fineract.infrastructure.core.service.DateUtils;
import org.apache.fineract.organisation.monetary.data.CurrencyData; import org.apache.fineract.organisation.monetary.data.CurrencyData;
import org.apache.fineract.organisation.monetary.domain.MonetaryCurrency; import org.apache.fineract.organisation.monetary.domain.MonetaryCurrency;
import org.apache.fineract.portfolio.accounts.constants.ShareAccountApiConstants; import org.apache.fineract.portfolio.accounts.constants.ShareAccountApiConstants;
import org.apache.fineract.portfolio.businessevent.domain.BusinessEntity; import org.apache.fineract.portfolio.businessevent.domain.share.ShareAccountApproveBusinessEvent;
import org.apache.fineract.portfolio.businessevent.domain.BusinessEvent; import org.apache.fineract.portfolio.businessevent.domain.share.ShareAccountCreateBusinessEvent;
import org.apache.fineract.portfolio.businessevent.service.BusinessEventNotifierService; import org.apache.fineract.portfolio.businessevent.service.BusinessEventNotifierService;
import org.apache.fineract.portfolio.client.domain.AccountNumberGenerator; import org.apache.fineract.portfolio.client.domain.AccountNumberGenerator;
import org.apache.fineract.portfolio.note.domain.Note; import org.apache.fineract.portfolio.note.domain.Note;
@@ -105,8 +105,7 @@ public class ShareAccountWritePlatformServiceJpaRepositoryImpl implements ShareA
journalEntryWritePlatformService.createJournalEntriesForShares( journalEntryWritePlatformService.createJournalEntriesForShares(
populateJournalEntries(account, account.getPendingForApprovalSharePurchaseTransactions())); populateJournalEntries(account, account.getPendingForApprovalSharePurchaseTransactions()));
this.businessEventNotifierService.notifyBusinessEventWasExecuted(BusinessEvent.SHARE_ACCOUNT_CREATE, businessEventNotifierService.notifyBusinessEvent(new ShareAccountCreateBusinessEvent(account));
constructEntityMap(BusinessEntity.SHARE_ACCOUNT, account));
return new CommandProcessingResultBuilder() // return new CommandProcessingResultBuilder() //
.withCommandId(jsonCommand.commandId()) // .withCommandId(jsonCommand.commandId()) //
@@ -282,8 +281,7 @@ public class ShareAccountWritePlatformServiceJpaRepositoryImpl implements ShareA
this.journalEntryWritePlatformService.createJournalEntriesForShares(populateJournalEntries(account, journalTransactions)); this.journalEntryWritePlatformService.createJournalEntriesForShares(populateJournalEntries(account, journalTransactions));
this.businessEventNotifierService.notifyBusinessEventWasExecuted(BusinessEvent.SHARE_ACCOUNT_APPROVE, businessEventNotifierService.notifyBusinessEvent(new ShareAccountApproveBusinessEvent(account));
constructEntityMap(BusinessEntity.SHARE_ACCOUNT, account));
return new CommandProcessingResultBuilder() // return new CommandProcessingResultBuilder() //
.withCommandId(jsonCommand.commandId()) // .withCommandId(jsonCommand.commandId()) //
@@ -529,10 +527,4 @@ public class ShareAccountWritePlatformServiceJpaRepositoryImpl implements ShareA
throw new PlatformDataIntegrityException("error.msg.shareaccount.unknown.data.integrity.issue", throw new PlatformDataIntegrityException("error.msg.shareaccount.unknown.data.integrity.issue",
"Unknown data integrity issue with resource."); "Unknown data integrity issue with resource.");
} }
private Map<BusinessEntity, Object> constructEntityMap(final BusinessEntity entityEvent, Object entity) {
Map<BusinessEntity, Object> map = new HashMap<>(1);
map.put(entityEvent, entity);
return map;
}
} }
@@ -21,9 +21,10 @@ package org.apache.fineract.portfolio.shareproducts.service;
import com.google.gson.JsonElement; import com.google.gson.JsonElement;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.time.LocalDate; import java.time.LocalDate;
import java.util.HashMap;
import java.util.Map; import java.util.Map;
import javax.persistence.PersistenceException; import javax.persistence.PersistenceException;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.exception.ExceptionUtils; import org.apache.commons.lang3.exception.ExceptionUtils;
import org.apache.fineract.accounting.producttoaccountmapping.service.ProductToGLAccountMappingWritePlatformService; import org.apache.fineract.accounting.producttoaccountmapping.service.ProductToGLAccountMappingWritePlatformService;
import org.apache.fineract.infrastructure.core.api.JsonCommand; import org.apache.fineract.infrastructure.core.api.JsonCommand;
@@ -31,8 +32,7 @@ import org.apache.fineract.infrastructure.core.data.CommandProcessingResult;
import org.apache.fineract.infrastructure.core.data.CommandProcessingResultBuilder; import org.apache.fineract.infrastructure.core.data.CommandProcessingResultBuilder;
import org.apache.fineract.infrastructure.core.exception.PlatformDataIntegrityException; import org.apache.fineract.infrastructure.core.exception.PlatformDataIntegrityException;
import org.apache.fineract.infrastructure.core.serialization.FromJsonHelper; import org.apache.fineract.infrastructure.core.serialization.FromJsonHelper;
import org.apache.fineract.portfolio.businessevent.domain.BusinessEntity; import org.apache.fineract.portfolio.businessevent.domain.share.ShareProductDividentsCreateBusinessEvent;
import org.apache.fineract.portfolio.businessevent.domain.BusinessEvent;
import org.apache.fineract.portfolio.businessevent.service.BusinessEventNotifierService; import org.apache.fineract.portfolio.businessevent.service.BusinessEventNotifierService;
import org.apache.fineract.portfolio.shareproducts.constants.ShareProductApiConstants; import org.apache.fineract.portfolio.shareproducts.constants.ShareProductApiConstants;
import org.apache.fineract.portfolio.shareproducts.domain.ShareProduct; import org.apache.fineract.portfolio.shareproducts.domain.ShareProduct;
@@ -41,18 +41,15 @@ import org.apache.fineract.portfolio.shareproducts.domain.ShareProductDividentPa
import org.apache.fineract.portfolio.shareproducts.domain.ShareProductRepositoryWrapper; import org.apache.fineract.portfolio.shareproducts.domain.ShareProductRepositoryWrapper;
import org.apache.fineract.portfolio.shareproducts.exception.DividentProcessingException; import org.apache.fineract.portfolio.shareproducts.exception.DividentProcessingException;
import org.apache.fineract.portfolio.shareproducts.serialization.ShareProductDataSerializer; import org.apache.fineract.portfolio.shareproducts.serialization.ShareProductDataSerializer;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.dao.DataIntegrityViolationException; import org.springframework.dao.DataIntegrityViolationException;
import org.springframework.orm.jpa.JpaSystemException; import org.springframework.orm.jpa.JpaSystemException;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
@Service @Service
@Slf4j
@RequiredArgsConstructor
public class ShareProductWritePlatformServiceJpaRepositoryImpl implements ShareProductWritePlatformService { public class ShareProductWritePlatformServiceJpaRepositoryImpl implements ShareProductWritePlatformService {
private static final Logger LOG = LoggerFactory.getLogger(ShareProductWritePlatformServiceJpaRepositoryImpl.class);
private final ShareProductRepositoryWrapper repository; private final ShareProductRepositoryWrapper repository;
private final ShareProductDataSerializer serializer; private final ShareProductDataSerializer serializer;
private final FromJsonHelper fromApiJsonHelper; private final FromJsonHelper fromApiJsonHelper;
@@ -61,22 +58,6 @@ public class ShareProductWritePlatformServiceJpaRepositoryImpl implements ShareP
private final ProductToGLAccountMappingWritePlatformService accountMappingWritePlatformService; private final ProductToGLAccountMappingWritePlatformService accountMappingWritePlatformService;
private final BusinessEventNotifierService businessEventNotifierService; private final BusinessEventNotifierService businessEventNotifierService;
@Autowired
public ShareProductWritePlatformServiceJpaRepositoryImpl(final ShareProductRepositoryWrapper repository,
final ShareProductDataSerializer serializer, final FromJsonHelper fromApiJsonHelper,
final ShareProductDividentPayOutDetailsRepositoryWrapper shareProductDividentPayOutDetailsRepositor,
final ShareProductDividendAssembler shareProductDividendAssembler,
final ProductToGLAccountMappingWritePlatformService accountMappingWritePlatformService,
final BusinessEventNotifierService businessEventNotifierService) {
this.repository = repository;
this.serializer = serializer;
this.fromApiJsonHelper = fromApiJsonHelper;
this.shareProductDividentPayOutDetailsRepository = shareProductDividentPayOutDetailsRepositor;
this.shareProductDividendAssembler = shareProductDividendAssembler;
this.accountMappingWritePlatformService = accountMappingWritePlatformService;
this.businessEventNotifierService = businessEventNotifierService;
}
@Override @Override
public CommandProcessingResult createShareProduct(JsonCommand jsonCommand) { public CommandProcessingResult createShareProduct(JsonCommand jsonCommand) {
try { try {
@@ -150,8 +131,7 @@ public class ShareProductWritePlatformServiceJpaRepositoryImpl implements ShareP
} }
this.shareProductDividentPayOutDetailsRepository.save(dividendPayOutDetails); this.shareProductDividentPayOutDetailsRepository.save(dividendPayOutDetails);
this.businessEventNotifierService.notifyBusinessEventWasExecuted(BusinessEvent.SHARE_PRODUCT_DIVIDENDS_CREATE, businessEventNotifierService.notifyBusinessEvent(new ShareProductDividentsCreateBusinessEvent(productId));
constructEntityMap(BusinessEntity.SHARE_PRODUCT, productId));
return new CommandProcessingResultBuilder() // return new CommandProcessingResultBuilder() //
.withCommandId(jsonCommand.commandId()) // .withCommandId(jsonCommand.commandId()) //
@@ -202,7 +182,7 @@ public class ShareProductWritePlatformServiceJpaRepositoryImpl implements ShareP
} }
private void handleDataIntegrityIssues(final Exception e) { private void handleDataIntegrityIssues(final Exception e) {
LOG.error("Unknown data integrity issue with resource", e); log.error("Unknown data integrity issue with resource", e);
throw new PlatformDataIntegrityException("error.msg.shareproduct.unknown.data.integrity.issue", throw new PlatformDataIntegrityException("error.msg.shareproduct.unknown.data.integrity.issue",
"Unknown data integrity issue with resource."); "Unknown data integrity issue with resource.");
} }
@@ -215,15 +195,8 @@ public class ShareProductWritePlatformServiceJpaRepositoryImpl implements ShareP
"Share Product with name `" + name + "` already exists", "name", name); "Share Product with name `" + name + "` already exists", "name", name);
} }
LOG.error("Unknown data integrity issue with resource", dve); log.error("Unknown data integrity issue with resource", dve);
throw new PlatformDataIntegrityException("error.msg.shareproduct.unknown.data.integrity.issue", throw new PlatformDataIntegrityException("error.msg.shareproduct.unknown.data.integrity.issue",
"Unknown data integrity issue with resource."); "Unknown data integrity issue with resource.");
} }
private Map<BusinessEntity, Object> constructEntityMap(final BusinessEntity entityEvent, Object entity) {
Map<BusinessEntity, Object> map = new HashMap<>(1);
map.put(entityEvent, entity);
return map;
}
} }