Search in sources :

Example 56 with PaymentData

use of org.mifos.accounts.util.helpers.PaymentData in project head by mifos.

the class SavingsBOIntegrationTest method testSuccessfulApplyPaymentWhenNoDepositDue.

@Test
public void testSuccessfulApplyPaymentWhenNoDepositDue() throws Exception {
    createInitialObjects();
    savingsOffering = helper.createSavingsOffering("dfasdasd1", "sad1");
    savings = helper.createSavingsAccount("000X00000000013", savingsOffering, group, AccountStates.SAVINGS_ACC_APPROVED, userContext);
    savings.setUserContext(TestObjectFactory.getContext());
    PersonnelBO loggedInUser = IntegrationTestObjectMother.testUser();
    savings.changeStatus(AccountState.SAVINGS_CANCELLED, null, "", loggedInUser);
    StaticHibernateUtil.getSessionTL().clear();
    savings = savingsDao.findById(savings.getAccountId());
    Money enteredAmount = new Money(currency, "100.0");
    PaymentData paymentData = PaymentData.createPaymentData(enteredAmount, savings.getPersonnel(), Short.valueOf("1"), new Date(System.currentTimeMillis()));
    paymentData.setCustomer(group);
    paymentData.setReceiptDate(new Date(System.currentTimeMillis()));
    paymentData.setReceiptNum("34244");
    paymentData.addAccountPaymentData(getSavingsPaymentdata(null));
    IntegrationTestObjectMother.applyAccountPayment(savings, paymentData);
    savings = savingsDao.findById(savings.getAccountId());
    Assert.assertEquals(AccountStates.SAVINGS_ACC_APPROVED, savings.getAccountState().getId().shortValue());
    Assert.assertEquals(TestUtils.createMoney(100.0), savings.getSavingsBalance());
    Assert.assertEquals(1, savings.getSavingsActivityDetails().size());
}
Also used : Money(org.mifos.framework.util.helpers.Money) PaymentData(org.mifos.accounts.util.helpers.PaymentData) SavingsPaymentData(org.mifos.accounts.util.helpers.SavingsPaymentData) PersonnelBO(org.mifos.customers.personnel.business.PersonnelBO) Date(java.util.Date) Test(org.junit.Test)

Example 57 with PaymentData

use of org.mifos.accounts.util.helpers.PaymentData in project head by mifos.

the class SavingsBOIntegrationTest method testSuccessfulWithdraw.

@Test
public void testSuccessfulWithdraw() throws AccountException, Exception {
    MeetingBO meeting = TestObjectFactory.createMeeting(TestObjectFactory.getNewMeetingForToday(WEEKLY, EVERY_WEEK, CUSTOMER_MEETING));
    center = TestObjectFactory.createWeeklyFeeCenter("Center", meeting);
    group = TestObjectFactory.createWeeklyFeeGroupUnderCenter("Group", CustomerStatus.GROUP_ACTIVE, center);
    client1 = TestObjectFactory.createClient("Client", CustomerStatus.CLIENT_ACTIVE, group);
    savingsOffering = helper.createSavingsOffering("dfasdasd1", "sad1");
    savings = TestObjectFactory.createSavingsAccount("43245434", client1, Short.valueOf("16"), new Date(System.currentTimeMillis()), savingsOffering);
    savings = (SavingsBO) legacyAccountDao.getAccount(savings.getAccountId());
    savings.setSavingsBalance(TestUtils.createMoney("100.0"));
    Money enteredAmount = new Money(currency, "100.0");
    PaymentData paymentData = PaymentData.createPaymentData(enteredAmount, savings.getPersonnel(), Short.valueOf("1"), new Date(System.currentTimeMillis()));
    paymentData.setCustomer(client1);
    paymentData.setReceiptDate(new Date(System.currentTimeMillis()));
    paymentData.setReceiptNum("34244");
    boolean persist = true;
    savings.withdraw(paymentData, persist);
    Assert.assertEquals(TestUtils.createMoney(), savings.getSavingsBalance());
    Assert.assertEquals(1, savings.getSavingsActivityDetails().size());
    savings.getAccountPayments().clear();
}
Also used : Money(org.mifos.framework.util.helpers.Money) PaymentData(org.mifos.accounts.util.helpers.PaymentData) SavingsPaymentData(org.mifos.accounts.util.helpers.SavingsPaymentData) MeetingBO(org.mifos.application.meeting.business.MeetingBO) Date(java.util.Date) Test(org.junit.Test)

Example 58 with PaymentData

use of org.mifos.accounts.util.helpers.PaymentData in project head by mifos.

the class TestObjectFactory method getLoanAccountPaymentData.

public static PaymentData getLoanAccountPaymentData(final List<AccountActionDateEntity> accountActions, final Money totalAmount, final CustomerBO customer, final PersonnelBO personnel, final String receiptNum, final Short paymentId, final Date receiptDate, final Date transactionDate) {
    PaymentData paymentData = PaymentData.createPaymentData(totalAmount, personnel, paymentId, transactionDate);
    paymentData.setCustomer(customer);
    paymentData.setReceiptDate(receiptDate);
    paymentData.setReceiptNum(receiptNum);
    return paymentData;
}
Also used : PaymentData(org.mifos.accounts.util.helpers.PaymentData) CustomerAccountPaymentData(org.mifos.accounts.util.helpers.CustomerAccountPaymentData)

Example 59 with PaymentData

use of org.mifos.accounts.util.helpers.PaymentData in project head by mifos.

the class TestObjectFactory method getCustomerAccountPaymentDataView.

public static PaymentData getCustomerAccountPaymentDataView(final List<AccountActionDateEntity> accountActions, final Money totalAmount, final CustomerBO customer, final PersonnelBO personnel, final String receiptNum, final Short paymentId, final Date receiptDate, final Date transactionDate) {
    PaymentData paymentData = PaymentData.createPaymentData(totalAmount, personnel, paymentId, transactionDate);
    paymentData.setCustomer(customer);
    paymentData.setReceiptDate(receiptDate);
    paymentData.setReceiptNum(receiptNum);
    for (AccountActionDateEntity actionDate : accountActions) {
        CustomerAccountPaymentData customerAccountPaymentData = new CustomerAccountPaymentData(actionDate);
        paymentData.addAccountPaymentData(customerAccountPaymentData);
    }
    return paymentData;
}
Also used : PaymentData(org.mifos.accounts.util.helpers.PaymentData) CustomerAccountPaymentData(org.mifos.accounts.util.helpers.CustomerAccountPaymentData) AccountActionDateEntity(org.mifos.accounts.business.AccountActionDateEntity) CustomerAccountPaymentData(org.mifos.accounts.util.helpers.CustomerAccountPaymentData)

Aggregations

PaymentData (org.mifos.accounts.util.helpers.PaymentData)59 Money (org.mifos.framework.util.helpers.Money)34 Test (org.junit.Test)32 AccountActionDateEntity (org.mifos.accounts.business.AccountActionDateEntity)24 Date (java.util.Date)22 AccountException (org.mifos.accounts.exceptions.AccountException)22 LoanBO (org.mifos.accounts.loan.business.LoanBO)22 ArrayList (java.util.ArrayList)19 AccountPaymentEntity (org.mifos.accounts.business.AccountPaymentEntity)18 Date (java.sql.Date)17 MeetingBO (org.mifos.application.meeting.business.MeetingBO)15 PersonnelBO (org.mifos.customers.personnel.business.PersonnelBO)15 LocalDate (org.joda.time.LocalDate)11 UserContext (org.mifos.security.util.UserContext)11 BigDecimal (java.math.BigDecimal)10 SavingsPaymentData (org.mifos.accounts.util.helpers.SavingsPaymentData)9 MifosRuntimeException (org.mifos.core.MifosRuntimeException)8 MifosUser (org.mifos.security.MifosUser)7 AccountTrxnEntity (org.mifos.accounts.business.AccountTrxnEntity)6 DateTimeService (org.mifos.framework.util.DateTimeService)6