Search in sources :

Example 11 with PaymentTypeEntity

use of org.mifos.application.master.business.PaymentTypeEntity in project head by mifos.

the class SavingsServiceFacadeWebTier method retrieveDepositPaymentTypes.

private List<ListElement> retrieveDepositPaymentTypes(UserContext userContext) {
    try {
        List<ListElement> depositPaymentTypes = new ArrayList<ListElement>();
        List<PaymentTypeEntity> acceptedPaymentEntityTypes = legacyAcceptedPaymentTypeDao.getAcceptedPaymentTypesForATransaction(userContext.getLocaleId(), TrxnTypes.savings_deposit.getValue());
        for (PaymentTypeEntity paymentTypeEntity : acceptedPaymentEntityTypes) {
            LookUpValueEntity lookupValue = paymentTypeEntity.getLookUpValue();
            String messageText = lookupValue.getMessageText();
            if (StringUtils.isBlank(messageText)) {
                messageText = ApplicationContextProvider.getBean(MessageLookup.class).lookup(lookupValue.getPropertiesKey());
            }
            depositPaymentTypes.add(new ListElement(paymentTypeEntity.getId().intValue(), messageText));
        }
        return depositPaymentTypes;
    } catch (PersistenceException e) {
        throw new MifosRuntimeException(e);
    }
}
Also used : PaymentTypeEntity(org.mifos.application.master.business.PaymentTypeEntity) ArrayList(java.util.ArrayList) ListElement(org.mifos.dto.screen.ListElement) PersistenceException(org.mifos.framework.exceptions.PersistenceException) LookUpValueEntity(org.mifos.application.master.business.LookUpValueEntity) MifosRuntimeException(org.mifos.core.MifosRuntimeException)

Example 12 with PaymentTypeEntity

use of org.mifos.application.master.business.PaymentTypeEntity in project head by mifos.

the class LookupOptionsAction method update.

@TransactionDemarcate(validateAndResetToken = true)
public ActionForward update(ActionMapping mapping, ActionForm form, HttpServletRequest request, @SuppressWarnings("unused") HttpServletResponse response) throws Exception {
    logger.debug("Inside update method");
    // setHiddenFields(request);
    LookupOptionsActionForm lookupOptionsActionForm = (LookupOptionsActionForm) form;
    LookupOptionData data = (LookupOptionData) SessionUtils.getAttribute(ConfigurationConstants.LOOKUP_OPTION_DATA, request);
    data.setLookupValue(lookupOptionsActionForm.getLookupValue());
    String entity = request.getParameter(ConfigurationConstants.ENTITY);
    if (data.getLookupId() > 0) {
        legacyMasterDao.updateValueListElementForLocale(data.getLookupId(), data.getLookupValue());
    } else {
        LookUpValueEntity newLookupValue = legacyMasterDao.addValueListElementForLocale(DynamicLookUpValueCreationTypes.LookUpOption, data.getValueListId(), data.getLookupValue());
        /*
             * Add a special case for payment types since we not only need to create a new
             * lookup value but also a new PaymentTypeEntity when adding an entry
             */
        if (entity.equals(ConfigurationConstants.CONFIG_PAYMENT_TYPE)) {
            PaymentTypeEntity newPaymentType = new PaymentTypeEntity(newLookupValue);
            legacyMasterDao.createOrUpdate(newPaymentType);
            StaticHibernateUtil.commitTransaction();
        }
    }
    return mapping.findForward(ActionForwards.update_success.toString());
}
Also used : PaymentTypeEntity(org.mifos.application.master.business.PaymentTypeEntity) LookupOptionsActionForm(org.mifos.config.struts.actionform.LookupOptionsActionForm) LookupOptionData(org.mifos.config.util.helpers.LookupOptionData) LookUpValueEntity(org.mifos.application.master.business.LookUpValueEntity) TransactionDemarcate(org.mifos.framework.util.helpers.TransactionDemarcate)

Example 13 with PaymentTypeEntity

use of org.mifos.application.master.business.PaymentTypeEntity in project head by mifos.

the class LegacyAccountDaoIntegrationTest method testFindingAccountPaymentShouldReturnOnePayment.

@Test
public void testFindingAccountPaymentShouldReturnOnePayment() throws Exception {
    savingsBO = createSavingsAccount();
    AccountPaymentEntity accountPaymentEntity = new AccountPaymentEntity(savingsBO, TestUtils.createMoney(100), "1111", new Date(System.currentTimeMillis()), new PaymentTypeEntity(Short.valueOf("1")), new Date(System.currentTimeMillis()));
    List<AccountPaymentEntity> payments = new ArrayList<AccountPaymentEntity>();
    payments.add(accountPaymentEntity);
    savingsBO.setAccountPayments(payments);
    legacyAccountDao.createOrUpdate(savingsBO);
    StaticHibernateUtil.commitTransaction();
    List<AccountPaymentEntity> result = legacyAccountDao.findAccountPaymentsByReceiptNumber("1111");
    Assert.assertNotNull(result);
    Assert.assertEquals(1, result.size());
    Assert.assertEquals("1111", result.get(0).getReceiptNumber());
}
Also used : PaymentTypeEntity(org.mifos.application.master.business.PaymentTypeEntity) AccountPaymentEntity(org.mifos.accounts.business.AccountPaymentEntity) ArrayList(java.util.ArrayList) Date(java.util.Date) Test(org.junit.Test)

Example 14 with PaymentTypeEntity

use of org.mifos.application.master.business.PaymentTypeEntity in project head by mifos.

the class SavingsAccountBuilder method withWithdrawalOf.

public SavingsAccountBuilder withWithdrawalOf(String withdrawalAmount) {
    Money amount = TestUtils.createMoney(withdrawalAmount);
    String receiptNumber = null;
    Date receiptDate = null;
    PaymentTypeEntity paymentType = new PaymentTypeEntity(PaymentTypes.CASH.getValue());
    Date paymentDate = new DateTime().toDate();
    AccountPaymentEntity deposit = new AccountPaymentEntity(null, amount, receiptNumber, receiptDate, paymentType, paymentDate);
    this.withdrawals.add(deposit);
    return this;
}
Also used : PaymentTypeEntity(org.mifos.application.master.business.PaymentTypeEntity) Money(org.mifos.framework.util.helpers.Money) AccountPaymentEntity(org.mifos.accounts.business.AccountPaymentEntity) Date(java.util.Date) LocalDate(org.joda.time.LocalDate) DateTime(org.joda.time.DateTime)

Example 15 with PaymentTypeEntity

use of org.mifos.application.master.business.PaymentTypeEntity in project head by mifos.

the class CustomerTrxnDetailEntityIntegrationTest method testGenerateReverseTrxn.

@Test
public void testGenerateReverseTrxn() throws Exception {
    accountBO = client.getCustomerAccount();
    Date currentDate = new Date(System.currentTimeMillis());
    CustomerAccountBO customerAccountBO = (CustomerAccountBO) accountBO;
    customerAccountBO.setUserContext(userContext);
    CustomerScheduleEntity accountAction = (CustomerScheduleEntity) customerAccountBO.getAccountActionDate(Short.valueOf("1"));
    accountAction.setMiscFeePaid(TestUtils.createMoney(100));
    accountAction.setMiscPenaltyPaid(TestUtils.createMoney(100));
    accountAction.setPaymentDate(currentDate);
    accountAction.setPaymentStatus(PaymentStatus.PAID);
    AccountPaymentEntity accountPaymentEntity = new AccountPaymentEntity(accountBO, 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()) {
        CustomerAccountBOTestUtils.setFeeAmountPaid((CustomerFeeScheduleEntity) accountFeesActionDetailEntity, TestUtils.createMoney(100));
        FeesTrxnDetailEntity feeTrxn = new FeesTrxnDetailEntity(accountTrxnEntity, accountFeesActionDetailEntity.getAccountFee(), accountFeesActionDetailEntity.getFeeAmount());
        accountTrxnEntity.addFeesTrxnDetail(feeTrxn);
    }
    accountPaymentEntity.addAccountTrxn(accountTrxnEntity);
    AccountTestUtils.addAccountPayment(accountPaymentEntity, customerAccountBO);
    PersonnelBO loggedInUser = legacyPersonnelDao.getPersonnel(userContext.getId());
    for (AccountTrxnEntity accntTrxn : customerAccountBO.findMostRecentPaymentByPaymentDate().getAccountTrxns()) {
        AccountTrxnEntity reverseAccntTrxn = ((CustomerTrxnDetailEntity) accntTrxn).generateReverseTrxn(loggedInUser, "adjustment");
        Assert.assertEquals(reverseAccntTrxn.getAmount(), accntTrxn.getAmount().negate());
        Assert.assertEquals(loggedInUser.getPersonnelId(), reverseAccntTrxn.getPersonnel().getPersonnelId());
    }
}
Also used : PaymentTypeEntity(org.mifos.application.master.business.PaymentTypeEntity) AccountTrxnEntity(org.mifos.accounts.business.AccountTrxnEntity) AccountFeesActionDetailEntity(org.mifos.accounts.business.AccountFeesActionDetailEntity) PersonnelBO(org.mifos.customers.personnel.business.PersonnelBO) AccountPaymentEntity(org.mifos.accounts.business.AccountPaymentEntity) Date(java.sql.Date) FeesTrxnDetailEntity(org.mifos.accounts.business.FeesTrxnDetailEntity) Test(org.junit.Test)

Aggregations

PaymentTypeEntity (org.mifos.application.master.business.PaymentTypeEntity)40 AccountPaymentEntity (org.mifos.accounts.business.AccountPaymentEntity)24 LocalDate (org.joda.time.LocalDate)16 Money (org.mifos.framework.util.helpers.Money)16 Date (java.util.Date)15 ArrayList (java.util.ArrayList)13 UserContext (org.mifos.security.util.UserContext)12 PersonnelBO (org.mifos.customers.personnel.business.PersonnelBO)10 Date (java.sql.Date)9 Test (org.junit.Test)9 SavingsBO (org.mifos.accounts.savings.business.SavingsBO)8 MifosRuntimeException (org.mifos.core.MifosRuntimeException)8 PersistenceException (org.mifos.framework.exceptions.PersistenceException)8 TransactionDemarcate (org.mifos.framework.util.helpers.TransactionDemarcate)8 CustomerBO (org.mifos.customers.business.CustomerBO)6 DateTime (org.joda.time.DateTime)4 AcceptedPaymentType (org.mifos.accounts.acceptedpaymenttype.business.AcceptedPaymentType)4 DateTimeService (org.mifos.framework.util.DateTimeService)4 BigDecimal (java.math.BigDecimal)3 LegacyAcceptedPaymentTypeDao (org.mifos.accounts.acceptedpaymenttype.persistence.LegacyAcceptedPaymentTypeDao)3