Search in sources :

Example 31 with PaymentTypeEntity

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

the class AcceptedPaymentTypePersistenceIntegrationTest method testRetrieveAcceptedPaymentTypes.

@Test
public void testRetrieveAcceptedPaymentTypes() throws Exception {
    for (TrxnTypes transactionType : TrxnTypes.values()) {
        Short transactionId = transactionType.getValue();
        List<AcceptedPaymentType> acceptedPaymentTypes = legacyAcceptedPaymentTypeDao.getAcceptedPaymentTypesForATransaction(transactionId, TrxnTypes.loan_repayment);
        List<PaymentTypeEntity> paymentTypeEntities = legacyAcceptedPaymentTypeDao.getAcceptedPaymentTypesForATransaction(DEFAULT_LOCALE_ID, transactionId);
        compare(paymentTypeEntities, acceptedPaymentTypes);
    }
}
Also used : PaymentTypeEntity(org.mifos.application.master.business.PaymentTypeEntity) AcceptedPaymentType(org.mifos.accounts.acceptedpaymenttype.business.AcceptedPaymentType) TrxnTypes(org.mifos.application.util.helpers.TrxnTypes) Test(org.junit.Test)

Example 32 with PaymentTypeEntity

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

the class AdminServiceFacadeWebTier method process.

private void process(List<PaymentTypeDto> selectedPaymentTypes, List<PaymentTypeDto> outList, List<AcceptedPaymentType> deletedPaymentTypeList, List<AcceptedPaymentType> addedPaymentTypeList, LegacyAcceptedPaymentTypeDao persistence, TrxnTypes transactionType) {
    AcceptedPaymentType acceptedPaymentType = null;
    if ((outList != null) && (outList.size() > 0)) {
        for (PaymentTypeDto paymentType : outList) {
            if (findDelete(paymentType, selectedPaymentTypes)) {
                acceptedPaymentType = persistence.getAcceptedPaymentType(paymentType.getAcceptedPaymentTypeId());
                deletedPaymentTypeList.add(acceptedPaymentType);
            }
        }
    }
    for (PaymentTypeDto selectedPaymentType : selectedPaymentTypes) {
        Short paymentTypeId = selectedPaymentType.getId();
        if (findNew(paymentTypeId, outList)) {
            acceptedPaymentType = new AcceptedPaymentType();
            PaymentTypeEntity paymentTypeEntity = new PaymentTypeEntity(paymentTypeId);
            acceptedPaymentType.setPaymentTypeEntity(paymentTypeEntity);
            TransactionTypeEntity transactionEntity = new TransactionTypeEntity();
            transactionEntity.setTransactionId(transactionType.getValue());
            acceptedPaymentType.setTransactionTypeEntity(transactionEntity);
            addedPaymentTypeList.add(acceptedPaymentType);
        }
    }
}
Also used : PaymentTypeEntity(org.mifos.application.master.business.PaymentTypeEntity) AcceptedPaymentType(org.mifos.accounts.acceptedpaymenttype.business.AcceptedPaymentType) AcceptedPaymentTypeDto(org.mifos.dto.domain.AcceptedPaymentTypeDto) PaymentTypeDto(org.mifos.dto.screen.PaymentTypeDto) TransactionTypeEntity(org.mifos.accounts.acceptedpaymenttype.business.TransactionTypeEntity)

Example 33 with PaymentTypeEntity

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

the class LegacyAccountDaoIntegrationTest method testFindingAccountPaymentShouldReturnZeroPayments.

@Test
public void testFindingAccountPaymentShouldReturnZeroPayments() throws Exception {
    savingsBO = createSavingsAccount();
    AccountPaymentEntity accountPaymentEntity = new AccountPaymentEntity(savingsBO, TestUtils.createMoney(100), "2222", 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(0, result.size());
}
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 34 with PaymentTypeEntity

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

the class CollectionSheetServiceImplRetrieveSavingsAccountsIntegrationTest method testCollectionSheetRetrieveOnlyReturnsActiveAndInactiveSavingsAccounts.

/**
     * need to clean up test data set up
     */
@Ignore
@Test
public void testCollectionSheetRetrieveOnlyReturnsActiveAndInactiveSavingsAccounts() throws Exception {
    UserContext userContext = TestUtils.makeUser();
    collectionSheetRetrieveSavingsAccountsUtils.createSampleCenterHierarchy();
    SavingsBO centerSavingsAccount = (SavingsBO) legacyAccountDao.getAccount(collectionSheetRetrieveSavingsAccountsUtils.getCenterSavingsAccount().getAccountId());
    centerSavingsAccount.setUserContext(userContext);
    PersonnelBO loggedInUser = IntegrationTestObjectMother.testUser();
    centerSavingsAccount.changeStatus(AccountState.SAVINGS_INACTIVE, Short.valueOf("1"), "Make Center Savings Account Inactive", loggedInUser);
    SavingsBO clientSavings = (SavingsBO) legacyAccountDao.getAccount(collectionSheetRetrieveSavingsAccountsUtils.getClientOfGroupCompleteGroupSavingsAccount().getAccountId());
    AccountPaymentEntity payment = new AccountPaymentEntity(clientSavings, new Money(clientSavings.getCurrency()), null, null, new PaymentTypeEntity(Short.valueOf("1")), new Date());
    AccountNotesEntity notes = new AccountNotesEntity(new java.sql.Date(System.currentTimeMillis()), "close client savings account", TestObjectFactory.getPersonnel(userContext.getId()), clientSavings);
    clientSavings.setUserContext(userContext);
    clientSavings.closeAccount(payment, notes, clientSavings.getCustomer(), loggedInUser);
    IntegrationTestObjectMother.saveSavingsAccount(clientSavings);
    StaticHibernateUtil.flushSession();
    CollectionSheetDto collectionSheet = collectionSheetService.retrieveCollectionSheet(collectionSheetRetrieveSavingsAccountsUtils.getCenter().getCustomerId(), new LocalDate());
    List<CollectionSheetCustomerDto> customers = collectionSheet.getCollectionSheetCustomer();
    for (CollectionSheetCustomerDto customer : customers) {
        for (CollectionSheetCustomerSavingDto customerSaving : customer.getCollectionSheetCustomerSaving()) {
            Boolean accountIsActiveOrInactive = false;
            AccountBO accountBO = legacyAccountDao.getAccount(customerSaving.getAccountId());
            if ((accountBO.getState().equals(AccountState.SAVINGS_ACTIVE)) || (accountBO.getState().equals(AccountState.SAVINGS_INACTIVE))) {
                accountIsActiveOrInactive = true;
            }
            Assert.assertTrue("Found Account State: " + accountBO.getState().toString() + " - Only Active and Inactive Savings Accounts are Allowed", accountIsActiveOrInactive);
        }
    }
}
Also used : UserContext(org.mifos.security.util.UserContext) AccountPaymentEntity(org.mifos.accounts.business.AccountPaymentEntity) AccountNotesEntity(org.mifos.accounts.business.AccountNotesEntity) SavingsBO(org.mifos.accounts.savings.business.SavingsBO) LocalDate(org.joda.time.LocalDate) Date(java.util.Date) LocalDate(org.joda.time.LocalDate) PaymentTypeEntity(org.mifos.application.master.business.PaymentTypeEntity) Money(org.mifos.framework.util.helpers.Money) AccountBO(org.mifos.accounts.business.AccountBO) PersonnelBO(org.mifos.customers.personnel.business.PersonnelBO) Ignore(org.junit.Ignore) Test(org.junit.Test)

Example 35 with PaymentTypeEntity

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

the class SaveCollectionSheetStructureValidatorIntegrationTest method ignore_testShouldGetINVALID_SAVINGS_ACCOUNT_STATUSIfSavingsAccountClosed.

public void ignore_testShouldGetINVALID_SAVINGS_ACCOUNT_STATUSIfSavingsAccountClosed() throws Exception {
    LocalDate transactionDate = new LocalDate();
    // create a center hierarchy with savings accounts
    collectionSheetRetrieveSavingsAccountsUtils.createSampleCenterHierarchy();
    // retrieve the collection sheet for today
    CollectionSheetService collectionSheetService = ApplicationContextProvider.getBean(CollectionSheetService.class);
    CollectionSheetDto collectionSheet = collectionSheetService.retrieveCollectionSheet(collectionSheetRetrieveSavingsAccountsUtils.getCenter().getCustomerId(), transactionDate);
    // assemble dto for saving collection sheet
    SaveCollectionSheetDto saveCollectionSheet = saveCollectionSheetUtils.assembleSaveCollectionSheetDto(collectionSheet, transactionDate);
    // close a savings account that is about to be saved
    UserContext userContext = TestUtils.makeUser();
    SavingsBO clientSavings = (SavingsBO) legacyAccountDao.getAccount(collectionSheetRetrieveSavingsAccountsUtils.getClientOfGroupCompleteGroupSavingsAccount().getAccountId());
    AccountPaymentEntity payment = new AccountPaymentEntity(clientSavings, new Money(clientSavings.getCurrency()), null, null, new PaymentTypeEntity(Short.valueOf("1")), new Date());
    AccountNotesEntity notes = new AccountNotesEntity(new java.sql.Date(System.currentTimeMillis()), "close client savings account", TestObjectFactory.getPersonnel(userContext.getId()), clientSavings);
    clientSavings.setUserContext(userContext);
    //        clientSavings.closeAccount(payment, notes, clientSavings.getCustomer());
    StaticHibernateUtil.flushSession();
    // Save collection sheet and test for errors returned
    verifyInvalidReason(saveCollectionSheet, InvalidSaveCollectionSheetReason.INVALID_SAVINGS_ACCOUNT_STATUS);
}
Also used : UserContext(org.mifos.security.util.UserContext) AccountPaymentEntity(org.mifos.accounts.business.AccountPaymentEntity) AccountNotesEntity(org.mifos.accounts.business.AccountNotesEntity) SavingsBO(org.mifos.accounts.savings.business.SavingsBO) LocalDate(org.joda.time.LocalDate) Date(java.util.Date) LocalDate(org.joda.time.LocalDate) PaymentTypeEntity(org.mifos.application.master.business.PaymentTypeEntity) Money(org.mifos.framework.util.helpers.Money)

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