Search in sources :

Example 11 with AccountPaymentParametersDto

use of org.mifos.dto.domain.AccountPaymentParametersDto in project head by mifos.

the class StandardAccountServiceIntegrationTest method testValidatePaymentWithInvalidLargePaymentAmount.

@Test
public void testValidatePaymentWithInvalidLargePaymentAmount() throws Exception {
    String paymentAmount = "700000";
    AccountPaymentParametersDto accountPaymentParametersDto = new AccountPaymentParametersDto(new UserReferenceDto(groupLoan.getPersonnel().getPersonnelId()), new AccountReferenceDto(groupLoan.getAccountId()), new BigDecimal(paymentAmount), new LocalDate(), defaultPaymentType, "");
    List<InvalidPaymentReason> errors = standardAccountService.validatePayment(accountPaymentParametersDto);
    Assert.assertTrue(errors.contains(InvalidPaymentReason.INVALID_PAYMENT_AMOUNT));
}
Also used : UserReferenceDto(org.mifos.dto.domain.UserReferenceDto) AccountReferenceDto(org.mifos.dto.domain.AccountReferenceDto) AccountPaymentParametersDto(org.mifos.dto.domain.AccountPaymentParametersDto) LocalDate(org.joda.time.LocalDate) BigDecimal(java.math.BigDecimal) Test(org.junit.Test)

Example 12 with AccountPaymentParametersDto

use of org.mifos.dto.domain.AccountPaymentParametersDto in project head by mifos.

the class StandardAccountServiceIntegrationTest method testMakePaymentForSavingsAccountOnDeposit.

@Test
public void testMakePaymentForSavingsAccountOnDeposit() throws Exception {
    savingsBO = createClientSavingsAccount();
    String deposit = "400";
    CustomerDto clientDto = new CustomerDto();
    clientDto.setCustomerId(client.getCustomerId());
    //FIXME why one day in future payment is allowed
    LocalDate paymentDate = new LocalDate().plusDays(1);
    LocalDate receiptDate = new LocalDate().minusDays(3);
    String receiptNumber = "AA/03/UX-9Q";
    Assert.assertEquals(0, savingsBO.getAccountPayments().size());
    AccountPaymentParametersDto depositPayment = new AccountPaymentParametersDto(new UserReferenceDto(savingsBO.getPersonnel().getPersonnelId()), new AccountReferenceDto(savingsBO.getAccountId()), new BigDecimal(deposit), paymentDate, defaultPaymentType, "comment", receiptDate, receiptNumber, clientDto);
    standardAccountService.makePayment(depositPayment);
    TestObjectFactory.updateObject(savingsBO);
    Assert.assertEquals("The amount returned for the payment should have been " + deposit, Double.parseDouble(deposit), savingsBO.getLastPmntAmnt());
    Assert.assertEquals(1, savingsBO.getAccountPayments().size());
    for (AccountPaymentEntity payment : savingsBO.getAccountPayments()) {
        Assert.assertEquals(TestUtils.createMoney(deposit), payment.getAmount());
        Assert.assertEquals(1, payment.getAccountTrxns().size());
        Assert.assertEquals(paymentDate.toDateMidnight().toDate(), payment.getPaymentDate());
        Assert.assertEquals(defaultPaymentType.getName(), payment.getPaymentType().getName());
        Assert.assertEquals("comment", payment.getComment());
        Assert.assertEquals(savingsBO, payment.getAccount());
        Assert.assertEquals(savingsBO.getPersonnel(), payment.getCreatedByUser());
        Assert.assertEquals(receiptDate.toDateMidnight().toDate(), payment.getReceiptDate());
        Assert.assertEquals(receiptNumber, payment.getReceiptNumber());
        Assert.assertNull(payment.getCheckNumber());
        Assert.assertNull(payment.getBankName());
        Assert.assertNull(payment.getVoucherNumber());
        Assert.assertTrue(payment.isSavingsDeposit());
        Assert.assertFalse(payment.isSavingsWithdrawal());
        Assert.assertTrue(payment.isSavingsDepositOrWithdrawal());
        for (AccountTrxnEntity accountTrxn : payment.getAccountTrxns()) {
            Assert.assertEquals(client.getCustomerId(), accountTrxn.getCustomer().getCustomerId());
        }
    }
}
Also used : UserReferenceDto(org.mifos.dto.domain.UserReferenceDto) AccountTrxnEntity(org.mifos.accounts.business.AccountTrxnEntity) AccountReferenceDto(org.mifos.dto.domain.AccountReferenceDto) CustomerDto(org.mifos.dto.domain.CustomerDto) AccountPaymentEntity(org.mifos.accounts.business.AccountPaymentEntity) AccountPaymentParametersDto(org.mifos.dto.domain.AccountPaymentParametersDto) LocalDate(org.joda.time.LocalDate) BigDecimal(java.math.BigDecimal) Test(org.junit.Test)

Example 13 with AccountPaymentParametersDto

use of org.mifos.dto.domain.AccountPaymentParametersDto in project head by mifos.

the class StandardAccountServiceIntegrationTest method testValidatePaymentWithInvalidDate.

@Test
public void testValidatePaymentWithInvalidDate() throws Exception {
    String paymentAmount = "700";
    AccountPaymentParametersDto accountPaymentParametersDto = new AccountPaymentParametersDto(new UserReferenceDto(groupLoan.getPersonnel().getPersonnelId()), new AccountReferenceDto(groupLoan.getAccountId()), new BigDecimal(paymentAmount), new LocalDate(1980, 1, 1), defaultPaymentType, "");
    List<InvalidPaymentReason> errors = standardAccountService.validatePayment(accountPaymentParametersDto);
    Assert.assertTrue(errors.contains(InvalidPaymentReason.INVALID_DATE));
}
Also used : UserReferenceDto(org.mifos.dto.domain.UserReferenceDto) AccountReferenceDto(org.mifos.dto.domain.AccountReferenceDto) AccountPaymentParametersDto(org.mifos.dto.domain.AccountPaymentParametersDto) LocalDate(org.joda.time.LocalDate) BigDecimal(java.math.BigDecimal) Test(org.junit.Test)

Example 14 with AccountPaymentParametersDto

use of org.mifos.dto.domain.AccountPaymentParametersDto in project head by mifos.

the class StandardAccountServiceIntegrationTest method testValidatePaymentWithInvalidNegativePaymentAmount.

@Test
public void testValidatePaymentWithInvalidNegativePaymentAmount() throws Exception {
    String paymentAmount = "-1";
    AccountPaymentParametersDto accountPaymentParametersDto = new AccountPaymentParametersDto(new UserReferenceDto(groupLoan.getPersonnel().getPersonnelId()), new AccountReferenceDto(groupLoan.getAccountId()), new BigDecimal(paymentAmount), new LocalDate(), defaultPaymentType, "");
    List<InvalidPaymentReason> errors = standardAccountService.validatePayment(accountPaymentParametersDto);
    Assert.assertTrue(errors.contains(InvalidPaymentReason.INVALID_PAYMENT_AMOUNT));
}
Also used : UserReferenceDto(org.mifos.dto.domain.UserReferenceDto) AccountReferenceDto(org.mifos.dto.domain.AccountReferenceDto) AccountPaymentParametersDto(org.mifos.dto.domain.AccountPaymentParametersDto) LocalDate(org.joda.time.LocalDate) BigDecimal(java.math.BigDecimal) Test(org.junit.Test)

Example 15 with AccountPaymentParametersDto

use of org.mifos.dto.domain.AccountPaymentParametersDto in project head by mifos.

the class StandardAccountServiceTest method testDisbursalAmountScaleDifferenceDoesNotMatter.

@Test
public void testDisbursalAmountScaleDifferenceDoesNotMatter() throws Exception {
    when(mockLoanAccount.getLoanAmount()).thenReturn(new Money(TestUtils.EURO, "300"));
    AccountPaymentParametersDto disbursal = new AccountPaymentParametersDto(new UserReferenceDto((short) 1), new AccountReferenceDto(1), new BigDecimal("300.0000000000000"), new LocalDate(), new PaymentTypeDto((short) 1, "CASH"), "");
    List<InvalidPaymentReason> errors = new ArrayList<InvalidPaymentReason>();
    standardAccountService.disbursalAmountMatchesFullLoanAmount(disbursal.getPaymentAmount(), errors, mockLoanAccount);
    assertThat(errors.isEmpty(), is(true));
}
Also used : UserReferenceDto(org.mifos.dto.domain.UserReferenceDto) Money(org.mifos.framework.util.helpers.Money) AccountReferenceDto(org.mifos.dto.domain.AccountReferenceDto) ArrayList(java.util.ArrayList) AccountPaymentParametersDto(org.mifos.dto.domain.AccountPaymentParametersDto) PaymentTypeDto(org.mifos.dto.domain.PaymentTypeDto) LocalDate(org.joda.time.LocalDate) BigDecimal(java.math.BigDecimal) Test(org.junit.Test)

Aggregations

AccountPaymentParametersDto (org.mifos.dto.domain.AccountPaymentParametersDto)29 AccountReferenceDto (org.mifos.dto.domain.AccountReferenceDto)21 BigDecimal (java.math.BigDecimal)18 UserReferenceDto (org.mifos.dto.domain.UserReferenceDto)18 LocalDate (org.joda.time.LocalDate)17 PaymentTypeDto (org.mifos.dto.domain.PaymentTypeDto)12 Test (org.junit.Test)11 LoanBO (org.mifos.accounts.loan.business.LoanBO)10 Money (org.mifos.framework.util.helpers.Money)8 UserContext (org.mifos.security.util.UserContext)8 AccountBO (org.mifos.accounts.business.AccountBO)7 ArrayList (java.util.ArrayList)6 HashMap (java.util.HashMap)6 CustomerAccountBO (org.mifos.customers.business.CustomerAccountBO)6 CustomerDto (org.mifos.dto.domain.CustomerDto)6 MifosUser (org.mifos.security.MifosUser)6 AccountPaymentEntity (org.mifos.accounts.business.AccountPaymentEntity)5 AccountPaymentDto (org.mifos.accounts.servicefacade.AccountPaymentDto)5 Date (java.util.Date)4 AccountException (org.mifos.accounts.exceptions.AccountException)4