use of org.mifos.accounts.financial.business.GLCodeEntity in project head by mifos.
the class TestObjectFactory method createOneTimeAmountFee.
public static FeeBO createOneTimeAmountFee(final String feeName, final FeeCategory feeCategory, final String feeAmnt, final FeePayment feePayment, final UserContext userContext, String categoryTypeName) {
GLCodeEntity glCode = (GLCodeEntity) StaticHibernateUtil.getSessionTL().get(GLCodeEntity.class, TestGeneralLedgerCode.FEES);
try {
CategoryTypeEntity categoryType = new CategoryTypeEntity(feeCategory);
LookUpValueEntity lookUpValue = new LookUpValueEntity();
lookUpValue.setLookUpName(categoryTypeName);
categoryType.setLookUpValue(lookUpValue);
FeeBO fee = new AmountFeeBO(userContext, feeName, categoryType, new FeeFrequencyTypeEntity(FeeFrequencyType.ONETIME), glCode, TestUtils.createMoney(feeAmnt), false, new FeePaymentEntity(feePayment));
return testObjectPersistence.createFee(fee);
} catch (Exception e) {
throw new RuntimeException(e);
}
}
use of org.mifos.accounts.financial.business.GLCodeEntity in project head by mifos.
the class InterestAdjustmentAccountingEntry method logTransactions_v2.
private void logTransactions_v2(LoanTrxnDetailEntity loanTrxn) throws FinancialException {
GLCodeEntity glcodeCredit = ((LoanBO) loanTrxn.getAccount()).getLoanOffering().getInterestGLcode();
FinancialActionTypeEntity finActionInterest = FinancialActionCache.getFinancialAction(FinancialActionConstants.INTERESTPOSTING);
addAccountEntryDetails(loanTrxn.getInterestAmount(), finActionInterest, getGLcode(finActionInterest.getApplicableDebitCharts()), FinancialConstants.CREDIT);
addAccountEntryDetails(loanTrxn.getInterestAmount(), finActionInterest, glcodeCredit, FinancialConstants.DEBIT);
boolean isLastPayment = ((LoanBO) loanTrxn.getAccount()).isLastInstallment(loanTrxn.getInstallmentId());
if (!isLastPayment) {
return;
}
boolean interestWasCharged = loanTrxn.getInterestAmount().isLessThanZero();
// log the reversed 999 account
if (!interestWasCharged) {
return;
}
Money account999 = ((LoanBO) loanTrxn.getAccount()).calculate999Account(!isLastPayment);
Money zeroAmount = new Money(account999.getCurrency(), "0");
// only log if amount > or < 0
if (account999.equals(zeroAmount)) {
return;
}
FinancialActionTypeEntity finActionRounding = FinancialActionCache.getFinancialAction(FinancialActionConstants.ROUNDING);
GLCodeEntity codeToDebit = null;
GLCodeEntity codeToCredit = null;
if (account999.isGreaterThanZero()) {
// this code is defined as below in chart of account
// <GLAccount code="31401" name="Income from 999 Account" />
codeToDebit = getGLcode(finActionRounding.getApplicableCreditCharts());
codeToCredit = glcodeCredit;
} else if (account999.isLessThanZero()) {
codeToDebit = glcodeCredit;
codeToCredit = getGLcode(finActionRounding.getApplicableDebitCharts());
account999 = account999.negate();
}
addAccountEntryDetails(account999, finActionRounding, codeToDebit, FinancialConstants.DEBIT);
addAccountEntryDetails(account999, finActionRounding, codeToCredit, FinancialConstants.CREDIT);
}
use of org.mifos.accounts.financial.business.GLCodeEntity in project head by mifos.
the class InterestAdjustmentAccountingEntry method logTransactions_v1.
private void logTransactions_v1(LoanTrxnDetailEntity loanTrxn) throws FinancialException {
GLCodeEntity glcodeCredit = ((LoanBO) loanTrxn.getAccount()).getLoanOffering().getInterestGLcode();
FinancialActionTypeEntity finActionInterest = FinancialActionCache.getFinancialAction(FinancialActionConstants.INTERESTPOSTING);
addAccountEntryDetails(loanTrxn.getInterestAmount(), finActionInterest, getGLcode(finActionInterest.getApplicableDebitCharts()), FinancialConstants.CREDIT);
addAccountEntryDetails(loanTrxn.getInterestAmount(), finActionInterest, glcodeCredit, FinancialConstants.DEBIT);
// check if rounding is required
Money roundedAmount = Money.round(loanTrxn.getInterestAmount(), loanTrxn.getInterestAmount().getCurrency().getRoundingAmount(), AccountingRules.getCurrencyRoundingMode());
if (!roundedAmount.equals(loanTrxn.getInterestAmount())) {
FinancialActionTypeEntity finActionRounding = FinancialActionCache.getFinancialAction(FinancialActionConstants.ROUNDING);
addAccountEntryDetails(roundedAmount.subtract(loanTrxn.getInterestAmount()).negate(), finActionRounding, getGLcode(finActionInterest.getApplicableCreditCharts()), FinancialConstants.DEBIT);
addAccountEntryDetails(roundedAmount.subtract(loanTrxn.getInterestAmount()), finActionRounding, getGLcode(finActionRounding.getApplicableCreditCharts()), FinancialConstants.CREDIT);
}
}
use of org.mifos.accounts.financial.business.GLCodeEntity 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.financial.business.GLCodeEntity 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);
}
}
Aggregations