Search in sources :

Example 91 with Date

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());
}
Also used : ClientNameDetailDto(org.mifos.dto.screen.ClientNameDetailDto) ClientPersonalDetailDto(org.mifos.dto.screen.ClientPersonalDetailDto) ArrayList(java.util.ArrayList) SavingsOfferingBO(org.mifos.accounts.productdefinition.business.SavingsOfferingBO) Date(java.sql.Date) Test(org.junit.Test)

Example 92 with Date

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));
    }
}
Also used : AccountActionDateEntity(org.mifos.accounts.business.AccountActionDateEntity) LoanBO(org.mifos.accounts.loan.business.LoanBO) Date(java.sql.Date)

Example 93 with Date

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));
    }
}
Also used : AccountActionDateEntity(org.mifos.accounts.business.AccountActionDateEntity) LoanBO(org.mifos.accounts.loan.business.LoanBO) Date(java.sql.Date)

Example 94 with Date

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);
}
Also used : AuditLogRecord(org.mifos.framework.components.audit.business.AuditLogRecord) AuditLogView(org.mifos.framework.components.audit.util.helpers.AuditLogView) AuditLog(org.mifos.framework.components.audit.business.AuditLog) Date(java.sql.Date) HashSet(java.util.HashSet) Test(org.junit.Test)

Example 95 with Date

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;
}
Also used : Money(org.mifos.framework.util.helpers.Money) RepayLoanInfoDto(org.mifos.dto.screen.RepayLoanInfoDto) HashMap(java.util.HashMap) RepayLoanDto(org.mifos.dto.screen.RepayLoanDto) LoanBO(org.mifos.accounts.loan.business.LoanBO) CustomerBO(org.mifos.customers.business.CustomerBO) MifosUser(org.mifos.security.MifosUser) DateTime(org.joda.time.DateTime) Date(java.sql.Date) LocalDate(org.joda.time.LocalDate) BigDecimal(java.math.BigDecimal) RequestMapping(org.springframework.web.bind.annotation.RequestMapping) ResponseBody(org.springframework.web.bind.annotation.ResponseBody)

Aggregations

Date (java.sql.Date)689 Test (org.junit.Test)286 PreparedStatement (java.sql.PreparedStatement)127 ResultSet (java.sql.ResultSet)122 Timestamp (java.sql.Timestamp)117 Connection (java.sql.Connection)107 Money (org.mifos.framework.util.helpers.Money)83 ArrayList (java.util.ArrayList)66 SQLException (java.sql.SQLException)60 Properties (java.util.Properties)60 Time (java.sql.Time)55 PDate (org.apache.phoenix.schema.types.PDate)55 ProductDefinitionException (org.mifos.accounts.productdefinition.exceptions.ProductDefinitionException)50 LocalDate (java.time.LocalDate)42 BigDecimal (java.math.BigDecimal)41 MeetingBO (org.mifos.application.meeting.business.MeetingBO)39 Test (org.testng.annotations.Test)39 Calendar (java.util.Calendar)36 PhoenixConnection (org.apache.phoenix.jdbc.PhoenixConnection)30 DateWritable (org.apache.hadoop.hive.serde2.io.DateWritable)28