use of java.sql.Date in project head by mifos.
the class ClientIntegrationTest method testInitialSavingsOfferingAtCreate.
@Test
public void testInitialSavingsOfferingAtCreate() throws Exception {
savingsOffering1 = TestObjectFactory.createSavingsProduct("Offering1", "s1", SavingsType.MANDATORY, ApplicableTo.CLIENTS, new Date(System.currentTimeMillis()));
savingsOffering2 = TestObjectFactory.createSavingsProduct("Offering2", "s2", SavingsType.VOLUNTARY, ApplicableTo.CLIENTS, new Date(System.currentTimeMillis()));
ClientNameDetailDto clientNameDetailDto = new ClientNameDetailDto(NameType.CLIENT.getValue(), TestObjectFactory.SAMPLE_SALUTATION, "Client", "", "1", "");
clientNameDetailDto.setNames(ClientRules.getNameSequence());
ClientNameDetailDto spouseNameDetailView = new ClientNameDetailDto(NameType.SPOUSE.getValue(), TestObjectFactory.SAMPLE_SALUTATION, "first", "middle", "last", "secondLast");
spouseNameDetailView.setNames(ClientRules.getNameSequence());
ClientPersonalDetailDto clientPersonalDetailDto = new ClientPersonalDetailDto(1, 1, 1, 1, 1, 1, Short.valueOf("1"), Short.valueOf("1"), Short.valueOf("41"));
List<SavingsOfferingBO> offerings = new ArrayList<SavingsOfferingBO>();
offerings.add(savingsOffering1);
offerings.add(savingsOffering2);
client = new ClientBO(TestObjectFactory.getContext(), clientNameDetailDto.getDisplayName(), CustomerStatus.CLIENT_PARTIAL, null, null, null, null, null, offerings, personnel, officeBo, null, null, null, null, null, YesNoFlag.YES.getValue(), clientNameDetailDto, spouseNameDetailView, clientPersonalDetailDto);
legacyClientDao.saveClient(client);
StaticHibernateUtil.flushSession();
client = customerDao.findClientById(client.getCustomerId());
Assert.assertEquals(offerings.size(), client.getOfferingsAssociatedInCreate().size());
for (ClientInitialSavingsOfferingEntity clientOffering : client.getOfferingsAssociatedInCreate()) {
if (clientOffering.getSavingsOffering().getPrdOfferingId().equals(savingsOffering1.getPrdOfferingId())) {
Assert.assertTrue(true);
}
if (clientOffering.getSavingsOffering().getPrdOfferingId().equals(savingsOffering2.getPrdOfferingId())) {
Assert.assertTrue(true);
}
}
savingsOffering1 = (SavingsOfferingBO) TestObjectFactory.getObject(SavingsOfferingBO.class, savingsOffering1.getPrdOfferingId());
savingsOffering2 = (SavingsOfferingBO) TestObjectFactory.getObject(SavingsOfferingBO.class, savingsOffering2.getPrdOfferingId());
}
use of java.sql.Date in project head by mifos.
the class LoanArrearsHelperIntegrationTest method setDisbursementDateAsOldDate.
private void setDisbursementDateAsOldDate(AccountBO account) {
Date startDate = offSetCurrentDate(15);
LoanBO loan = (LoanBO) account;
LoanBOTestUtils.modifyDisbursementDate(loan, startDate);
for (AccountActionDateEntity actionDate : loan.getAccountActionDates()) {
LoanBOTestUtils.setActionDate(actionDate, offSetGivenDate(actionDate.getActionDate(), 18));
}
}
use of java.sql.Date in project head by mifos.
the class LoanArrearsTaskIntegrationTest method setDisbursementDateAsOldDate.
private void setDisbursementDateAsOldDate(AccountBO account) {
Date startDate = offSetCurrentDate(15);
LoanBO loan = (LoanBO) account;
LoanBOTestUtils.modifyDisbursementDate(loan, startDate);
for (AccountActionDateEntity actionDate : loan.getAccountActionDates()) {
LoanBOTestUtils.setActionDate(actionDate, offSetGivenDate(actionDate.getActionDate(), 18));
}
}
use of java.sql.Date in project head by mifos.
the class AuditBusinessServiceIntegrationTest method testGetAuditLogRecords.
@Test
public void testGetAuditLogRecords() throws Exception {
AuditLog auditLog = new AuditLog(1, (short) 2, "Mifos", new Date(System.currentTimeMillis()), (short) 3);
Set<AuditLogRecord> auditLogRecords = new HashSet<AuditLogRecord>();
AuditLogRecord auditLogRecord = new AuditLogRecord("ColumnName_1", "test_1", "new_test_1", auditLog);
auditLogRecords.add(auditLogRecord);
auditLog.addAuditLogRecords(auditLogRecords);
legacyAuditDao.save(auditLog);
AuditBusinessService auditBusinessService = new AuditBusinessService();
List<AuditLogView> auditLogViewList = auditBusinessService.getAuditLogRecords((short) 2, 1);
Assert.assertEquals(1, auditLogViewList.size());
auditLog = getAuditLog(1, (short) 2);
}
use of java.sql.Date in project head by mifos.
the class LoanAccountRESTController method fullRepay.
@RequestMapping(value = "/account/loan/num-{globalAccountNum}/fullrepay", method = RequestMethod.POST)
@ResponseBody
public Map<String, String> fullRepay(@PathVariable String globalAccountNum, @RequestParam(required = false) String paymentDate, @RequestParam(required = false) Short receiptId, @RequestParam(required = false) String receiptDate, @RequestParam(required = false) Short paymentModeId, @RequestParam Boolean waiveInterest) throws Exception {
LoanBO loan = this.loanDao.findByGlobalAccountNum(globalAccountNum);
validateLoanAccountState(loan);
MifosUser user = (MifosUser) SecurityContextHolder.getContext().getAuthentication().getPrincipal();
RepayLoanDto repayLoanDto = this.loanAccountServiceFacade.retrieveLoanRepaymentDetails(globalAccountNum);
DateTime today = new DateTime();
Date paymentDateTime = new Date(today.toDate().getTime());
if (paymentDate != null && !paymentDate.isEmpty()) {
paymentDateTime = new Date(validateDateString(paymentDate, format).toDate().getTime());
}
String receiptIdString = null;
if (receiptId != null) {
receiptIdString = receiptId.toString();
}
Date receiptDateTime = null;
if (receiptDate != null && !receiptDate.isEmpty()) {
receiptDateTime = new Date(validateDateString(receiptDate, format).toDate().getTime());
}
String paymentTypeId = null;
if (paymentModeId != null) {
paymentTypeId = paymentModeId.toString();
}
validateDisbursementPaymentTypeId(paymentModeId, accountService.getLoanPaymentTypes());
BigDecimal totalRepaymentAmount = (new Money(loan.getCurrency(), repayLoanDto.getEarlyRepaymentMoney())).getAmount();
BigDecimal waivedAmount = (new Money(loan.getCurrency(), repayLoanDto.getWaivedRepaymentMoney())).getAmount();
BigDecimal earlyRepayAmount = totalRepaymentAmount;
if (Boolean.TRUE.equals(waiveInterest)) {
earlyRepayAmount = waivedAmount;
}
RepayLoanInfoDto repayLoanInfoDto = new RepayLoanInfoDto(globalAccountNum, Double.toString(earlyRepayAmount.doubleValue()), receiptIdString, receiptDateTime, paymentTypeId, (short) user.getUserId(), waiveInterest.booleanValue(), paymentDateTime, totalRepaymentAmount, waivedAmount);
Money outstandingBeforePayment = loan.getLoanSummary().getOutstandingBalance();
this.loanAccountServiceFacade.makeEarlyRepaymentWithCommit(repayLoanInfoDto);
CustomerBO client = loan.getCustomer();
Map<String, String> map = new HashMap<String, String>();
map.put("status", "success");
map.put("clientName", client.getDisplayName());
map.put("clientNumber", client.getGlobalCustNum());
map.put("loanDisplayName", loan.getLoanOffering().getPrdOfferingName());
map.put("paymentDate", today.toLocalDate().toString());
map.put("paymentTime", today.toLocalTime().toString());
map.put("paymentAmount", loan.getLastPmnt().getAmount().toString());
map.put("paymentMadeBy", personnelDao.findPersonnelById((short) user.getUserId()).getDisplayName());
map.put("outstandingBeforePayment", outstandingBeforePayment.toString());
map.put("outstandingAfterPayment", loan.getLoanSummary().getOutstandingBalance().toString());
return map;
}
Aggregations