use of org.mifos.customers.business.CustomerTrxnDetailEntity in project head by mifos.
the class CustomerFeesAdjustmentAccountingEntry method applySpecificAccountActionEntry.
@Override
protected void applySpecificAccountActionEntry() throws FinancialException {
CustomerTrxnDetailEntity customertrxn = (CustomerTrxnDetailEntity) financialActivity.getAccountTrxn();
Set<FeesTrxnDetailEntity> feesTrxn = customertrxn.getFeesTrxnDetails();
Iterator<FeesTrxnDetailEntity> iterFees = feesTrxn.iterator();
FinancialActionTypeEntity finActionFee = getFinancialAction(FinancialActionConstants.FEEPOSTING);
while (iterFees.hasNext()) {
FeesTrxnDetailEntity feeTrxn = iterFees.next();
addAccountEntryDetails(feeTrxn.getFeeAmount(), finActionFee, feeTrxn.getAccountFees().getFees().getGlCode(), FinancialConstants.DEBIT);
addAccountEntryDetails(feeTrxn.getFeeAmount(), finActionFee, getGLcode(finActionFee.getApplicableDebitCharts()), FinancialConstants.CREDIT);
}
// For Misc Fee
FinancialActionTypeEntity finActionMiscFee = FinancialActionCache.getFinancialAction(FinancialActionConstants.CUSTOMERACCOUNTMISCFEESPOSTING);
addAccountEntryDetails(customertrxn.getMiscFeeAmount(), finActionMiscFee, getGLcode(finActionMiscFee.getApplicableDebitCharts()), FinancialConstants.CREDIT);
addAccountEntryDetails(customertrxn.getMiscFeeAmount(), finActionMiscFee, getGLcode(finActionMiscFee.getApplicableCreditCharts()), FinancialConstants.DEBIT);
}
use of org.mifos.customers.business.CustomerTrxnDetailEntity in project head by mifos.
the class CustomerPenaltyAdjustmentAccountingEntry method applySpecificAccountActionEntry.
@Override
protected void applySpecificAccountActionEntry() throws FinancialException {
CustomerTrxnDetailEntity customertrxn = (CustomerTrxnDetailEntity) financialActivity.getAccountTrxn();
FinancialActionTypeEntity finActionMiscPenalty = FinancialActionCache.getFinancialAction(FinancialActionConstants.MISCPENALTYPOSTING);
addAccountEntryDetails(customertrxn.getMiscPenaltyAmount(), finActionMiscPenalty, getGLcode(finActionMiscPenalty.getApplicableDebitCharts()), FinancialConstants.CREDIT);
addAccountEntryDetails(customertrxn.getMiscPenaltyAmount(), finActionMiscPenalty, getGLcode(finActionMiscPenalty.getApplicableCreditCharts()), FinancialConstants.DEBIT);
}
use of org.mifos.customers.business.CustomerTrxnDetailEntity in project head by mifos.
the class BaseFinancialActivity method getMiscPenaltyAmount.
public Money getMiscPenaltyAmount() {
AccountBO account = getAccountTrxn().getAccount();
Money amount = new Money(account.getCurrency());
if (account.getType() == AccountTypes.LOAN_ACCOUNT) {
amount = ((LoanTrxnDetailEntity) getAccountTrxn()).getMiscPenaltyAmount();
} else if (account.getType() == AccountTypes.CUSTOMER_ACCOUNT) {
amount = ((CustomerTrxnDetailEntity) getAccountTrxn()).getMiscPenaltyAmount();
}
return amount;
}
use of org.mifos.customers.business.CustomerTrxnDetailEntity in project head by mifos.
the class CustomerAccountFeesAccountingEntry method applySpecificAccountActionEntry.
@Override
protected void applySpecificAccountActionEntry() throws FinancialException {
CustomerTrxnDetailEntity customertrxn = (CustomerTrxnDetailEntity) financialActivity.getAccountTrxn();
Set<FeesTrxnDetailEntity> feesTrxns = customertrxn.getFeesTrxnDetails();
FinancialActionTypeEntity finActionFee = getFinancialAction(FinancialActionConstants.FEEPOSTING);
for (FeesTrxnDetailEntity feeTrxn : feesTrxns) {
addAccountEntryDetails(feeTrxn.getFeeAmount(), finActionFee, feeTrxn.getAccountFees().getFees().getGlCode(), FinancialConstants.CREDIT);
addAccountEntryDetails(feeTrxn.getFeeAmount(), finActionFee, getGLcode(finActionFee.getApplicableDebitCharts()), FinancialConstants.DEBIT);
}
// For Misc Fee
FinancialActionTypeEntity finActionMiscFee = FinancialActionCache.getFinancialAction(FinancialActionConstants.CUSTOMERACCOUNTMISCFEESPOSTING);
addAccountEntryDetails(customertrxn.getMiscFeeAmount(), finActionMiscFee, getGLcode(finActionMiscFee.getApplicableDebitCharts()), FinancialConstants.DEBIT);
addAccountEntryDetails(customertrxn.getMiscFeeAmount(), finActionMiscFee, getGLcode(finActionMiscFee.getApplicableCreditCharts()), FinancialConstants.CREDIT);
}
use of org.mifos.customers.business.CustomerTrxnDetailEntity in project head by mifos.
the class AccountPaymentEntityIntegrationTest method testReversalAdjustment.
@Test
public void testReversalAdjustment() throws Exception {
userContext = TestObjectFactory.getContext();
createInitialObjects();
accountBO = client.getCustomerAccount();
Date currentDate = new Date(System.currentTimeMillis());
CustomerAccountBO customerAccountBO = (CustomerAccountBO) accountBO;
customerAccountBO.setUserContext(userContext);
CustomerScheduleEntity accountAction = (CustomerScheduleEntity) customerAccountBO.getAccountActionDate(Short.valueOf("1"));
CustomerAccountBOTestUtils.setMiscFeePaid(accountAction, TestUtils.createMoney(100));
CustomerAccountBOTestUtils.setMiscPenaltyPaid(accountAction, TestUtils.createMoney(100));
CustomerAccountBOTestUtils.setPaymentDate(accountAction, currentDate);
accountAction.setPaymentStatus(PaymentStatus.PAID);
AccountPaymentEntity accountPaymentEntity = new AccountPaymentEntity(customerAccountBO, TestUtils.createMoney(100), "1111", currentDate, new PaymentTypeEntity(Short.valueOf("1")), new Date(System.currentTimeMillis()));
CustomerTrxnDetailEntity accountTrxnEntity = new CustomerTrxnDetailEntity(accountPaymentEntity, AccountActionTypes.PAYMENT, Short.valueOf("1"), accountAction.getActionDate(), TestObjectFactory.getPersonnel(userContext.getId()), currentDate, TestUtils.createMoney(200), "payment done", null, TestUtils.createMoney(100), TestUtils.createMoney(100));
for (AccountFeesActionDetailEntity accountFeesActionDetailEntity : accountAction.getAccountFeesActionDetails()) {
accountFeesActionDetailEntity.setFeeAmountPaid(TestUtils.createMoney(100));
FeesTrxnDetailEntity feeTrxn = new FeesTrxnDetailEntity(accountTrxnEntity, accountFeesActionDetailEntity.getAccountFee(), accountFeesActionDetailEntity.getFeeAmount());
CustomerBOTestUtils.addFeesTrxnDetail(accountTrxnEntity, feeTrxn);
// TODO: is there anything to assert on here?
// totalFees = accountFeesActionDetailEntity.getFeeAmountPaid();
}
accountPaymentEntity.addAccountTrxn(accountTrxnEntity);
customerAccountBO.addAccountPayment(accountPaymentEntity);
TestObjectFactory.updateObject(customerAccountBO);
StaticHibernateUtil.flushSession();
customerAccountBO = TestObjectFactory.getObject(CustomerAccountBO.class, customerAccountBO.getAccountId());
client = customerAccountBO.getCustomer();
PersonnelBO loggedInUser = legacyPersonnelDao.getPersonnel(userContext.getId());
List<AccountTrxnEntity> reversedTrxns = customerAccountBO.findMostRecentPaymentByPaymentDate().reversalAdjustment(loggedInUser, "adjustment");
for (AccountTrxnEntity accntTrxn : reversedTrxns) {
CustomerTrxnDetailEntity custTrxn = (CustomerTrxnDetailEntity) accntTrxn;
CustomerScheduleEntity accntActionDate = (CustomerScheduleEntity) customerAccountBO.getAccountActionDate(custTrxn.getInstallmentId());
Assert.assertEquals(custTrxn.getMiscFeeAmount(), accntActionDate.getMiscFeePaid().negate());
Assert.assertEquals(custTrxn.getMiscPenaltyAmount(), accntActionDate.getMiscPenaltyPaid().negate());
Assert.assertEquals(loggedInUser.getPersonnelId(), custTrxn.getPersonnel().getPersonnelId());
}
}
Aggregations