use of org.mifos.accounts.financial.business.FinancialActionTypeEntity in project head by mifos.
the class SavingsCloseTest method setupChartOfAccountsAndFinancialTransactions.
@BeforeClass
public static void setupChartOfAccountsAndFinancialTransactions() {
defaultCurrency = TestUtils.RUPEE;
Money.setDefaultCurrency(defaultCurrency);
Short glcodeId = Short.valueOf("1");
String glcode = "123456";
GLCodeEntity glCodeEntity = new GLCodeEntity(glcodeId, glcode);
COABO coabo = new COABO("testAccountName", glCodeEntity);
ChartOfAccountsCache chartOfAccountsCache = new ChartOfAccountsCache();
chartOfAccountsCache.clear();
chartOfAccountsCache.add(coabo);
Map<FinancialActionConstants, String> actionToCreditAccount = new HashMap<FinancialActionConstants, String>();
actionToCreditAccount.put(FinancialActionConstants.SAVINGS_INTERESTPOSTING, glcode);
actionToCreditAccount.put(FinancialActionConstants.MANDATORYDEPOSIT, glcode);
actionToCreditAccount.put(FinancialActionConstants.MANDATORYWITHDRAWAL, glcode);
actionToCreditAccount.put(FinancialActionConstants.MANDATORYDEPOSIT_ADJUSTMENT, glcode);
actionToCreditAccount.put(FinancialActionConstants.MANDATORYWITHDRAWAL_ADJUSTMENT, glcode);
actionToCreditAccount.put(FinancialActionConstants.ROUNDING, glcode);
FinancialRules.getInstance().setActionToCreditAccount(actionToCreditAccount);
Map<FinancialActionConstants, String> actionToDebitAccount = new HashMap<FinancialActionConstants, String>();
actionToDebitAccount.put(FinancialActionConstants.SAVINGS_INTERESTPOSTING, glcode);
actionToDebitAccount.put(FinancialActionConstants.MANDATORYDEPOSIT, glcode);
actionToDebitAccount.put(FinancialActionConstants.MANDATORYWITHDRAWAL, glcode);
actionToDebitAccount.put(FinancialActionConstants.MANDATORYDEPOSIT_ADJUSTMENT, glcode);
actionToDebitAccount.put(FinancialActionConstants.MANDATORYWITHDRAWAL_ADJUSTMENT, glcode);
actionToDebitAccount.put(FinancialActionConstants.ROUNDING, glcode);
FinancialRules.getInstance().setActionToDebitAccount(actionToDebitAccount);
FinancialActionTypeEntity roundingAction = new FinancialActionTypeEntity();
roundingAction.setId(FinancialActionConstants.ROUNDING.getValue());
FinancialActionTypeEntity depositAction = new FinancialActionTypeEntity();
depositAction.setId(FinancialActionConstants.MANDATORYDEPOSIT.getValue());
FinancialActionTypeEntity withdrawalAction = new FinancialActionTypeEntity();
withdrawalAction.setId(FinancialActionConstants.MANDATORYWITHDRAWAL.getValue());
FinancialActionTypeEntity depositAdjustmentAction = new FinancialActionTypeEntity();
depositAdjustmentAction.setId(FinancialActionConstants.MANDATORYDEPOSIT_ADJUSTMENT.getValue());
FinancialActionTypeEntity withdrawalAdjustmentAction = new FinancialActionTypeEntity();
withdrawalAdjustmentAction.setId(FinancialActionConstants.MANDATORYWITHDRAWAL_ADJUSTMENT.getValue());
FinancialActionTypeEntity interestPostingAction = new FinancialActionTypeEntity();
interestPostingAction.setId(FinancialActionConstants.SAVINGS_INTERESTPOSTING.getValue());
FinancialActionCache.addToCache(depositAction);
FinancialActionCache.addToCache(withdrawalAction);
FinancialActionCache.addToCache(depositAdjustmentAction);
FinancialActionCache.addToCache(withdrawalAdjustmentAction);
FinancialActionCache.addToCache(interestPostingAction);
FinancialActionCache.addToCache(roundingAction);
}
use of org.mifos.accounts.financial.business.FinancialActionTypeEntity in project head by mifos.
the class SavingsAdjustmentTest method setupChartOfAccountsAndFinancialTransactions.
@BeforeClass
public static void setupChartOfAccountsAndFinancialTransactions() {
defaultCurrency = TestUtils.RUPEE;
Money.setDefaultCurrency(defaultCurrency);
Short glcodeId = Short.valueOf("1");
String glcode = "123456";
GLCodeEntity glCodeEntity = new GLCodeEntity(glcodeId, glcode);
COABO coabo = new COABO("testAccountName", glCodeEntity);
ChartOfAccountsCache chartOfAccountsCache = new ChartOfAccountsCache();
chartOfAccountsCache.clear();
chartOfAccountsCache.add(coabo);
Map<FinancialActionConstants, String> actionToCreditAccount = new HashMap<FinancialActionConstants, String>();
actionToCreditAccount.put(FinancialActionConstants.MANDATORYDEPOSIT, glcode);
actionToCreditAccount.put(FinancialActionConstants.MANDATORYWITHDRAWAL, glcode);
actionToCreditAccount.put(FinancialActionConstants.MANDATORYDEPOSIT_ADJUSTMENT, glcode);
actionToCreditAccount.put(FinancialActionConstants.MANDATORYWITHDRAWAL_ADJUSTMENT, glcode);
FinancialRules.getInstance().setActionToCreditAccount(actionToCreditAccount);
Map<FinancialActionConstants, String> actionToDebitAccount = new HashMap<FinancialActionConstants, String>();
actionToDebitAccount.put(FinancialActionConstants.MANDATORYDEPOSIT, glcode);
actionToDebitAccount.put(FinancialActionConstants.MANDATORYWITHDRAWAL, glcode);
actionToDebitAccount.put(FinancialActionConstants.MANDATORYDEPOSIT_ADJUSTMENT, glcode);
actionToDebitAccount.put(FinancialActionConstants.MANDATORYWITHDRAWAL_ADJUSTMENT, glcode);
FinancialRules.getInstance().setActionToDebitAccount(actionToDebitAccount);
FinancialActionTypeEntity depositAction = new FinancialActionTypeEntity();
depositAction.setId(FinancialActionConstants.MANDATORYDEPOSIT.getValue());
FinancialActionTypeEntity withdrawalAction = new FinancialActionTypeEntity();
withdrawalAction.setId(FinancialActionConstants.MANDATORYWITHDRAWAL.getValue());
FinancialActionTypeEntity depositAdjustmentAction = new FinancialActionTypeEntity();
depositAdjustmentAction.setId(FinancialActionConstants.MANDATORYDEPOSIT_ADJUSTMENT.getValue());
FinancialActionTypeEntity withdrawalAdjustmentAction = new FinancialActionTypeEntity();
withdrawalAdjustmentAction.setId(FinancialActionConstants.MANDATORYWITHDRAWAL_ADJUSTMENT.getValue());
FinancialActionCache.addToCache(depositAction);
FinancialActionCache.addToCache(withdrawalAction);
FinancialActionCache.addToCache(depositAdjustmentAction);
FinancialActionCache.addToCache(withdrawalAdjustmentAction);
}
use of org.mifos.accounts.financial.business.FinancialActionTypeEntity 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.FinancialActionTypeEntity 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.FinancialActionTypeEntity 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);
}
}
Aggregations