use of org.mifos.accounts.loan.business.LoanTrxnDetailEntity in project head by mifos.
the class TestObjectFactory method deleteAccountPayment.
private static void deleteAccountPayment(final AccountPaymentEntity accountPayment, final Session session) {
Set<AccountTrxnEntity> loanTrxns = accountPayment.getAccountTrxns();
for (AccountTrxnEntity accountTrxn : loanTrxns) {
if (accountTrxn instanceof LoanTrxnDetailEntity) {
LoanTrxnDetailEntity loanTrxn = (LoanTrxnDetailEntity) accountTrxn;
for (FeesTrxnDetailEntity feesTrxn : loanTrxn.getFeesTrxnDetails()) {
session.delete(feesTrxn);
}
for (FinancialTransactionBO financialTrxn : loanTrxn.getFinancialTransactions()) {
session.delete(financialTrxn);
}
session.delete(loanTrxn);
}
}
session.delete(accountPayment);
}
use of org.mifos.accounts.loan.business.LoanTrxnDetailEntity in project head by mifos.
the class PenaltyAccountingEntry method applySpecificAccountActionEntry.
@Override
protected void applySpecificAccountActionEntry() throws FinancialException {
if (financialActivity.getAccountTrxn() instanceof LoanTrxnDetailEntity) {
LoanTrxnDetailEntity loanTrxn = (LoanTrxnDetailEntity) financialActivity.getAccountTrxn();
Set<PenaltiesTrxnDetailEntity> penaltiesTrxn = loanTrxn.getPenaltiesTrxnDetails();
Iterator<PenaltiesTrxnDetailEntity> iterPenalties = penaltiesTrxn.iterator();
FinancialActionTypeEntity finActionPenalty = getFinancialAction(FinancialActionConstants.PENALTYPOSTING);
while (iterPenalties.hasNext()) {
PenaltiesTrxnDetailEntity penaltyTrxn = iterPenalties.next();
addAccountEntryDetails(penaltyTrxn.getPenaltyAmount(), finActionPenalty, penaltyTrxn.getAccountPenalties().getPenalty().getGlCode(), FinancialConstants.CREDIT);
addAccountEntryDetails(penaltyTrxn.getPenaltyAmount(), finActionPenalty, getGLcode(finActionPenalty.getApplicableDebitCharts()), FinancialConstants.DEBIT);
}
FinancialActionTypeEntity finActionMiscPenalty = FinancialActionCache.getFinancialAction(FinancialActionConstants.MISCPENALTYPOSTING);
addAccountEntryDetails(loanTrxn.getMiscPenaltyAmount(), finActionMiscPenalty, getGLcode(finActionMiscPenalty.getApplicableDebitCharts()), FinancialConstants.DEBIT);
addAccountEntryDetails(loanTrxn.getMiscPenaltyAmount(), finActionMiscPenalty, getGLcode(finActionMiscPenalty.getApplicableCreditCharts()), FinancialConstants.CREDIT);
} else {
Money amount = financialActivity.getMiscPenaltyAmount();
FinancialActionTypeEntity finActionMiscPenalty = FinancialActionCache.getFinancialAction(FinancialActionConstants.MISCPENALTYPOSTING);
addAccountEntryDetails(amount, finActionMiscPenalty, getGLcode(finActionMiscPenalty.getApplicableDebitCharts()), FinancialConstants.DEBIT);
addAccountEntryDetails(amount, finActionMiscPenalty, getGLcode(finActionMiscPenalty.getApplicableCreditCharts()), FinancialConstants.CREDIT);
}
}
use of org.mifos.accounts.loan.business.LoanTrxnDetailEntity in project head by mifos.
the class PrincipalAccountingEntry method applySpecificAccountActionEntry.
@Override
protected void applySpecificAccountActionEntry() throws FinancialException {
LoanTrxnDetailEntity loanTrxn = (LoanTrxnDetailEntity) financialActivity.getAccountTrxn();
GLCodeEntity glcodeCredit = ((LoanBO) loanTrxn.getAccount()).getLoanOffering().getPrincipalGLcode();
Money principalAmountNotRounded = loanTrxn.getPrincipalAmount();
Money amountToPost = null;
if (((LoanBO) loanTrxn.getAccount()).isLastInstallment(loanTrxn.getInstallmentId())) {
amountToPost = Money.round(loanTrxn.getPrincipalAmount(), AccountingRules.getFinalRoundOffMultiple(loanTrxn.getPrincipalAmount().getCurrency()), AccountingRules.getCurrencyRoundingMode());
} else {
amountToPost = principalAmountNotRounded;
}
FinancialActionTypeEntity finActionPrincipal = FinancialActionCache.getFinancialAction(FinancialActionConstants.PRINCIPALPOSTING);
addAccountEntryDetails(amountToPost, finActionPrincipal, getGLcode(finActionPrincipal.getApplicableDebitCharts()), FinancialConstants.DEBIT);
addAccountEntryDetails(amountToPost, finActionPrincipal, glcodeCredit, FinancialConstants.CREDIT);
LoanBO loan = (LoanBO) loanTrxn.getAccount();
// interest account and not to the principal account
if (!loan.isLegacyLoan()) {
return;
}
// v1 version log the 999 account to the principal account
// check if rounding is required
FinancialActionTypeEntity finActionRounding = FinancialActionCache.getFinancialAction(FinancialActionConstants.ROUNDING);
if (amountToPost.getAmount().compareTo(principalAmountNotRounded.getAmount()) > 0) {
addAccountEntryDetails(amountToPost.subtract(principalAmountNotRounded), finActionRounding, glcodeCredit, FinancialConstants.DEBIT);
addAccountEntryDetails(amountToPost.subtract(principalAmountNotRounded), finActionRounding, getGLcode(finActionRounding.getApplicableCreditCharts()), FinancialConstants.CREDIT);
} else if (amountToPost.getAmount().compareTo(principalAmountNotRounded.getAmount()) < 0) {
addAccountEntryDetails(principalAmountNotRounded.subtract(amountToPost), finActionRounding, getGLcode(finActionRounding.getApplicableDebitCharts()), FinancialConstants.DEBIT);
addAccountEntryDetails(principalAmountNotRounded.subtract(amountToPost), finActionRounding, glcodeCredit, FinancialConstants.CREDIT);
}
}
use of org.mifos.accounts.loan.business.LoanTrxnDetailEntity in project head by mifos.
the class PrincipalAdjustmentAccountingEntry method applySpecificAccountActionEntry.
@Override
protected void applySpecificAccountActionEntry() throws FinancialException {
LoanTrxnDetailEntity loanTrxn = (LoanTrxnDetailEntity) financialActivity.getAccountTrxn();
GLCodeEntity glcodeCredit = ((LoanBO) loanTrxn.getAccount()).getLoanOffering().getPrincipalGLcode();
FinancialActionTypeEntity finActionPrincipal = FinancialActionCache.getFinancialAction(FinancialActionConstants.PRINCIPALPOSTING);
addAccountEntryDetails(loanTrxn.getPrincipalAmount(), finActionPrincipal, getGLcode(finActionPrincipal.getApplicableDebitCharts()), FinancialConstants.CREDIT);
addAccountEntryDetails(loanTrxn.getPrincipalAmount(), finActionPrincipal, glcodeCredit, FinancialConstants.DEBIT);
LoanBO loan = (LoanBO) loanTrxn.getAccount();
if (!loan.isLegacyLoan()) {
return;
}
// check if rounding is required
Money roundedAmount = Money.round(loanTrxn.getPrincipalAmount(), loanTrxn.getPrincipalAmount().getCurrency().getRoundingAmount(), AccountingRules.getCurrencyRoundingMode());
if (!roundedAmount.equals(loanTrxn.getPrincipalAmount())) {
FinancialActionTypeEntity finActionRounding = FinancialActionCache.getFinancialAction(FinancialActionConstants.ROUNDING);
addAccountEntryDetails(roundedAmount.subtract(loanTrxn.getPrincipalAmount()).negate(), finActionRounding, getGLcode(finActionPrincipal.getApplicableCreditCharts()), FinancialConstants.CREDIT);
addAccountEntryDetails(roundedAmount.subtract(loanTrxn.getPrincipalAmount()), finActionRounding, getGLcode(finActionRounding.getApplicableCreditCharts()), FinancialConstants.DEBIT);
}
}
use of org.mifos.accounts.loan.business.LoanTrxnDetailEntity in project head by mifos.
the class RescheduleAccountingEntry method applySpecificAccountActionEntry.
@Override
protected void applySpecificAccountActionEntry() throws FinancialException {
LoanTrxnDetailEntity loanTrxn = (LoanTrxnDetailEntity) financialActivity.getAccountTrxn();
FinancialActionTypeEntity finActionReschedule = FinancialActionCache.getFinancialAction(FinancialActionConstants.RESCHEDULE);
addAccountEntryDetails(loanTrxn.getPrincipalAmount(), finActionReschedule, getGLcode(finActionReschedule.getApplicableDebitCharts()), FinancialConstants.DEBIT);
GLCodeEntity glcodeCredit = ((LoanBO) loanTrxn.getAccount()).getLoanOffering().getPrincipalGLcode();
addAccountEntryDetails(loanTrxn.getPrincipalAmount(), finActionReschedule, glcodeCredit, FinancialConstants.CREDIT);
// no 999 account entries are made for close-rescheduled loans because
// if some payments have already been made
// the 999 account amount is probably very small and is ignored in 1.1
// release. In the future if we want to
// calculate the 999 amount in this case we need to store the raw amount
// for each installment.
}
Aggregations