@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());
            }
        }
    }
@Test
    public void testMakePaymentForSavingsAccountOnDeposit() throws Exception {
        savingsBO = createClientSavingsAccount();
        String deposit = "400";
        CustomerDto clientDto = new CustomerDto();
        clientDto.setCustomerId(client.getCustomerId());
       
        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());
            }
        }
    }
@test public void testmakepaymentforsavingsaccountondeposit() throws exception { savingsbo = createclientsavingsaccount(); string deposit = "400"; customerdto clientdto = new customerdto(); clientdto.setcustomerid(client.getcustomerid()); 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()); } } }