Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -881,6 +881,15 @@ public CommandWrapperBuilder rejectLoanApplication(final Long loanId) {
this.href = "/loans/" + loanId;
return this;
}

public CommandWrapperBuilder rejectGLIMApplication(final Long glimId) {
this.actionName = "REJECT";
this.entityName = "GLIMLOAN";
this.entityId = glimId;
this.loanId = glimId;
this.href = "/loans/" + glimId;
return this;
}

public CommandWrapperBuilder withdrawLoanApplication(final Long loanId) {
this.actionName = "WITHDRAW";
Expand All @@ -899,6 +908,50 @@ public CommandWrapperBuilder approveLoanApplication(final Long loanId) {
this.href = "/loans/" + loanId;
return this;
}

public CommandWrapperBuilder approveGLIMLoanApplication(final Long glimId) {
this.actionName = "APPROVE";
this.entityName = "GLIMLOAN";
this.entityId = glimId;
this.loanId = glimId;
this.href = "/loans/" + glimId;
return this;
}

public CommandWrapperBuilder disburseGlimLoanApplication(final Long glimId) {
this.actionName = "DISBURSE";
this.entityName = "GLIMLOAN";
this.entityId = glimId;
this.loanId = glimId;
this.href = "/loans/" + glimId;
return this;
}

public CommandWrapperBuilder repaymentGlimLoanApplication(final Long glimId) {
this.actionName = "REPAYMENT";
this.entityName = "GLIMLOAN";
this.entityId = glimId;
this.loanId = glimId;
this.href = "/loans/" + glimId;
return this;
}
public CommandWrapperBuilder undoGLIMLoanDisbursal(final Long glimId) {
this.actionName = "UNDODISBURSAL";
this.entityName = "GLIMLOAN";
this.entityId = glimId;
this.loanId = glimId;
this.href = "/loans/" + glimId;
return this;
}

public CommandWrapperBuilder undoGLIMLoanApproval(final Long glimId) {
this.actionName = "UNDOAPPROVAL";
this.entityName = "GLIMLOAN";
this.entityId = glimId;
this.loanId = glimId;
this.href = "/loans/" + glimId;
return this;
}

public CommandWrapperBuilder disburseLoanApplication(final Long loanId) {
this.actionName = "DISBURSE";
Expand Down Expand Up @@ -1124,6 +1177,14 @@ public CommandWrapperBuilder createSavingsAccount() {
this.href = "/savingsaccounts/template";
return this;
}

public CommandWrapperBuilder createGSIMAccount() {
this.actionName = "CREATE";
this.entityName = "GSIMACCOUNT";
this.entityId = null;
this.href = "/gsimaccounts/template";
return this;
}

public CommandWrapperBuilder updateSavingsAccount(final Long accountId) {
this.actionName = "UPDATE";
Expand All @@ -1132,6 +1193,14 @@ public CommandWrapperBuilder updateSavingsAccount(final Long accountId) {
this.href = "/savingsaccounts/" + accountId;
return this;
}

public CommandWrapperBuilder updateGSIMAccount(final Long accountId) {
this.actionName = "UPDATE";
this.entityName = "GSIMACCOUNT";
this.entityId = accountId;
this.href = "/gsimaccounts/" + accountId;
return this;
}

public CommandWrapperBuilder deleteSavingsAccount(final Long accountId) {
this.actionName = "DELETE";
Expand All @@ -1149,6 +1218,15 @@ public CommandWrapperBuilder rejectSavingsAccountApplication(final Long accountI
this.href = "/savingsaccounts/" + accountId + "?command=reject";
return this;
}

public CommandWrapperBuilder rejectGSIMAccountApplication(final Long accountId) {
this.actionName = "REJECT";
this.entityName = "GSIMACCOUNT";
this.entityId = accountId;
this.savingsId = accountId;
this.href = "/savingsaccounts/" + accountId + "?command=reject";
return this;
}

public CommandWrapperBuilder withdrawSavingsAccountApplication(final Long accountId) {
this.actionName = "WITHDRAW";
Expand All @@ -1167,6 +1245,15 @@ public CommandWrapperBuilder approveSavingsAccountApplication(final Long account
this.href = "/savingsaccounts/" + accountId + "?command=approve";
return this;
}

public CommandWrapperBuilder approveGSIMAccountApplication(final Long accountId) {
this.actionName = "APPROVE";
this.entityName = "GSIMACCOUNT";
this.entityId = accountId;
this.savingsId = accountId;
this.href = "/gsimsaccounts/" + accountId + "?command=approve";
return this;
}

public CommandWrapperBuilder undoSavingsAccountApplication(final Long accountId) {
this.actionName = "APPROVALUNDO";
Expand All @@ -1176,7 +1263,17 @@ public CommandWrapperBuilder undoSavingsAccountApplication(final Long accountId)
this.href = "/savingsaccounts/" + accountId + "?command=undoapproval";
return this;
}


public CommandWrapperBuilder undoGSIMApplicationApproval(final Long accountId) {
this.actionName = "APPROVALUNDO";
this.entityName = "GSIMACCOUNT";
this.entityId = accountId;
this.savingsId = accountId;
this.href = "/savingsaccounts/" + accountId + "?command=undoapproval";
return this;
}


public CommandWrapperBuilder savingsAccountActivation(final Long accountId) {
this.actionName = "ACTIVATE";
this.entityName = "SAVINGSACCOUNT";
Expand All @@ -1185,6 +1282,15 @@ public CommandWrapperBuilder savingsAccountActivation(final Long accountId) {
this.href = "/savingsaccounts/" + accountId + "?command=activate";
return this;
}

public CommandWrapperBuilder gsimAccountActivation(final Long accountId) {
this.actionName = "ACTIVATE";
this.entityName = "GSIMACCOUNT";
this.savingsId = accountId;
this.entityId = null;
this.href = "/savingsaccounts/" + accountId + "?command=activate";
return this;
}

public CommandWrapperBuilder closeSavingsAccountApplication(final Long accountId) {
this.actionName = "CLOSE";
Expand All @@ -1194,6 +1300,15 @@ public CommandWrapperBuilder closeSavingsAccountApplication(final Long accountId
this.href = "/savingsaccounts/" + accountId + "?command=close";
return this;
}

public CommandWrapperBuilder closeGSIMApplication(final Long accountId) {
this.actionName = "CLOSE";
this.entityName = "GSIMACCOUNT";
this.entityId = accountId;
this.savingsId = accountId;
this.href = "/savingsaccounts/" + accountId + "?command=close";
return this;
}

public CommandWrapperBuilder createAccountTransfer() {
this.actionName = "CREATE";
Expand Down Expand Up @@ -1235,6 +1350,15 @@ public CommandWrapperBuilder savingsAccountDeposit(final Long accountId) {
this.href = "/savingsaccounts/" + accountId + "/transactions";
return this;
}

public CommandWrapperBuilder gsimSavingsAccountDeposit(final Long accountId) {
this.actionName = "DEPOSIT";
this.entityName = "GSIMACCOUNT";
this.savingsId = accountId;
this.entityId = null;
this.href = "/savingsaccounts/" + accountId + "/transactions";
return this;
}

public CommandWrapperBuilder savingsAccountWithdrawal(final Long accountId) {
this.actionName = "WITHDRAWAL";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,13 @@ public static JsonCommand fromExistingCommand(JsonCommand command, final JsonEle
command.resourceId, command.subresourceId, command.groupId, command.clientId, command.loanId, command.savingsId,
command.transactionId, command.url, command.productId,command.creditBureauId,command.organisationCreditBureauId);
}

public static JsonCommand fromExistingCommand(JsonCommand command, final JsonElement parsedCommand,final Long clientId) {
final String jsonCommand = command.fromApiJsonHelper.toJson(parsedCommand);
return new JsonCommand(command.commandId, jsonCommand, parsedCommand, command.fromApiJsonHelper, command.entityName,
command.resourceId, command.subresourceId, command.groupId, clientId, command.loanId, command.savingsId,
command.transactionId, command.url, command.productId,command.creditBureauId,command.organisationCreditBureauId);
}

public JsonCommand(final Long commandId, final String jsonCommand, final JsonElement parsedCommand,
final FromJsonHelper fromApiJsonHelper, final String entityName, final Long resourceId, final Long subresourceId,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,8 @@
import org.apache.fineract.portfolio.loanaccount.service.LoanReadPlatformService;
import org.apache.fineract.portfolio.paymentdetail.domain.PaymentDetail;
import org.apache.fineract.portfolio.savings.SavingsTransactionBooleanValues;
import org.apache.fineract.portfolio.savings.domain.GSIMRepositoy;
import org.apache.fineract.portfolio.savings.domain.GroupSavingsIndividualMonitoring;
import org.apache.fineract.portfolio.savings.domain.SavingsAccount;
import org.apache.fineract.portfolio.savings.domain.SavingsAccountAssembler;
import org.apache.fineract.portfolio.savings.domain.SavingsAccountDomainService;
Expand All @@ -78,6 +80,7 @@ public class AccountTransfersWritePlatformServiceImpl implements AccountTransfer
private final SavingsAccountWritePlatformService savingsAccountWritePlatformService;
private final AccountTransferDetailRepository accountTransferDetailRepository;
private final LoanReadPlatformService loanReadPlatformService;
private final GSIMRepositoy gsimRepository;

@Autowired
public AccountTransfersWritePlatformServiceImpl(final AccountTransfersDataValidator accountTransfersDataValidator,
Expand All @@ -86,7 +89,8 @@ public AccountTransfersWritePlatformServiceImpl(final AccountTransfersDataValida
final LoanAssembler loanAssembler, final LoanAccountDomainService loanAccountDomainService,
final SavingsAccountWritePlatformService savingsAccountWritePlatformService,
final AccountTransferDetailRepository accountTransferDetailRepository,
final LoanReadPlatformService loanReadPlatformService) {
final LoanReadPlatformService loanReadPlatformService,
final GSIMRepositoy gsimRepository) {
this.accountTransfersDataValidator = accountTransfersDataValidator;
this.accountTransferAssembler = accountTransferAssembler;
this.accountTransferRepository = accountTransferRepository;
Expand All @@ -97,6 +101,7 @@ public AccountTransfersWritePlatformServiceImpl(final AccountTransfersDataValida
this.savingsAccountWritePlatformService = savingsAccountWritePlatformService;
this.accountTransferDetailRepository = accountTransferDetailRepository;
this.loanReadPlatformService = loanReadPlatformService;
this.gsimRepository=gsimRepository;
}

@Transactional
Expand Down Expand Up @@ -411,6 +416,18 @@ public Long transferFunds(final AccountTransferDTO accountTransferDTO) {
toSavingsAccount, deposit, loanTransaction);
this.accountTransferDetailRepository.saveAndFlush(accountTransferDetails);
transferTransactionId = accountTransferDetails.getId();

// if the savings account is GSIM, update its parent as well
if(toSavingsAccount.getGsim()!=null)
{
GroupSavingsIndividualMonitoring gsim=gsimRepository.findOne(toSavingsAccount.getGsim().getId());
BigDecimal currentBalance=gsim.getParentDeposit();
BigDecimal newBalance=currentBalance.add(accountTransferDTO.getTransactionAmount());
gsim.setParentDeposit(newBalance);
gsimRepository.save(gsim);
}


} else {
throw new GeneralPlatformDomainRuleException("error.msg.accounttransfer.loan.to.loan.not.supported",
"Account transfer from loan to another loan is not supported");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,25 +27,33 @@
public class AccountSummaryCollectionData {

private final Collection<LoanAccountSummaryData> loanAccounts;
private final Collection<LoanAccountSummaryData> groupLoanIndividualMonitoringAccounts;
private final Collection<SavingsAccountSummaryData> savingsAccounts;
private final Collection<ShareAccountSummaryData> shareAccounts ;

private final Collection<LoanAccountSummaryData> memberLoanAccounts;
private final Collection<SavingsAccountSummaryData> memberSavingsAccounts;

public AccountSummaryCollectionData(final Collection<LoanAccountSummaryData> loanAccounts,

/* METHOD SIGNATURE CHANGE NOTICE: Method's signature
was changed for GLIM & GSIM implementation*/

public AccountSummaryCollectionData(final Collection<LoanAccountSummaryData> loanAccounts,final Collection<LoanAccountSummaryData> groupLoanIndividualMonitoringAccounts,
final Collection<SavingsAccountSummaryData> savingsAccounts, final Collection<ShareAccountSummaryData> shareAccounts) {
this.loanAccounts = defaultLoanAccountsIfEmpty(loanAccounts);
this.groupLoanIndividualMonitoringAccounts=groupLoanIndividualMonitoringAccounts;
this.savingsAccounts = defaultSavingsAccountsIfEmpty(savingsAccounts);
this.shareAccounts = defaultShareAccountsIfEmpty(shareAccounts) ;
this.memberLoanAccounts = null;
this.memberSavingsAccounts = null;
}

public AccountSummaryCollectionData(final Collection<LoanAccountSummaryData> loanAccounts,
/* Note to Self: GSIM not passed in*/

public AccountSummaryCollectionData(final Collection<LoanAccountSummaryData> loanAccounts,final Collection<LoanAccountSummaryData> groupLoanIndividualMonitoringAccounts,
final Collection<SavingsAccountSummaryData> savingsAccounts, final Collection<LoanAccountSummaryData> memberLoanAccounts,
final Collection<SavingsAccountSummaryData> memberSavingsAccounts) {
this.loanAccounts = defaultLoanAccountsIfEmpty(loanAccounts);
this.groupLoanIndividualMonitoringAccounts=groupLoanIndividualMonitoringAccounts;
this.savingsAccounts = defaultSavingsAccountsIfEmpty(savingsAccounts);
this.shareAccounts = null ;
this.memberLoanAccounts = defaultLoanAccountsIfEmpty(memberLoanAccounts);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ public class LoanAccountSummaryData {

private final Long id;
private final String accountNo;
private final String parentAccountNumber;
private final String externalId;
private final Long productId;
private final String productName;
Expand All @@ -50,6 +51,28 @@ public LoanAccountSummaryData(final Long id, final String accountNo, final Strin
final LoanApplicationTimelineData timeline, final Boolean inArrears,final BigDecimal originalLoan,final BigDecimal loanBalance,final BigDecimal amountPaid) {
this.id = id;
this.accountNo = accountNo;
this.parentAccountNumber=null;
this.externalId = externalId;
this.productId = productId;
this.productName = loanProductName;
this.shortProductName = shortLoanProductName;
this.status = loanStatus;
this.loanType = loanType;
this.loanCycle = loanCycle;
this.timeline = timeline;
this.inArrears = inArrears;
this.loanBalance = loanBalance;
this.originalLoan = originalLoan;
this.amountPaid = amountPaid;
}


public LoanAccountSummaryData(final Long id, final String accountNo,final String parentAccountNumber, final String externalId, final Long productId,
final String loanProductName, final String shortLoanProductName, final LoanStatusEnumData loanStatus, final EnumOptionData loanType, final Integer loanCycle,
final LoanApplicationTimelineData timeline, final Boolean inArrears,final BigDecimal originalLoan,final BigDecimal loanBalance,final BigDecimal amountPaid) {
this.id = id;
this.accountNo = accountNo;
this.parentAccountNumber=parentAccountNumber;
this.externalId = externalId;
this.productId = productId;
this.productName = loanProductName;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,4 +70,19 @@ public SavingsAccountSummaryData(final Long id, final String accountNo, final St
this.subStatus = subStatus;
this.lastActiveTransactionDate = lastActiveTransactionDate;
}

public String getAccountNo() {
return accountNo;
}

public Long getId() {
return id;
}







}
Loading