Search in sources :

Example 61 with Date

use of java.sql.Date in project head by mifos.

the class SavingsOverDueDepositsTag method buildUI.

StringBuilder buildUI(List<AccountActionDateEntity> installmentsInArrears, Locale locale) {
    StringBuilder builder = new StringBuilder();
    SavingsScheduleEntity installment = null;
    Date actionDate = null;
    Collections.sort(installmentsInArrears, new Comparator<AccountActionDateEntity>() {

        @Override
        public int compare(AccountActionDateEntity actionDate1, AccountActionDateEntity actionDate2) {
            return actionDate1.getActionDate().compareTo(actionDate2.getActionDate());
        }
    });
    for (int i = 0; i < installmentsInArrears.size(); ) {
        actionDate = installmentsInArrears.get(i).getActionDate();
        Money totalAmount = new Money(installmentsInArrears.get(i).getAccount().getCurrency());
        do {
            installment = (SavingsScheduleEntity) installmentsInArrears.get(i);
            if (!(installment.getCustomer().getCustomerLevel().getId().equals(CustomerLevel.CLIENT.getValue()) && installment.getCustomer().getStatus().equals(CustomerStatus.CLIENT_CLOSED))) {
                totalAmount = totalAmount.add(installment.getTotalDepositDue());
            }
            i++;
        } while (i < installmentsInArrears.size() && actionDate.equals(installmentsInArrears.get(i).getActionDate()));
        if (totalAmount.isGreaterThanZero()) {
            builder.append(buildDepositDueUIRow(locale, actionDate, totalAmount));
        }
    }
    return builder;
}
Also used : AccountActionDateEntity(org.mifos.accounts.business.AccountActionDateEntity) Money(org.mifos.framework.util.helpers.Money) SavingsScheduleEntity(org.mifos.accounts.savings.business.SavingsScheduleEntity) Date(java.sql.Date)

Example 62 with Date

use of java.sql.Date in project head by mifos.

the class AccountApplyPaymentActionForm method setTransactionDate.

public void setTransactionDate(String receiptDate) throws InvalidDateException {
    if (StringUtils.isBlank(receiptDate)) {
        transactionDateDD = null;
        transactionDateMM = null;
        transactionDateYY = null;
    } else {
        Calendar cal = new GregorianCalendar();
        java.sql.Date date = getDateAsSentFromBrowser(receiptDate);
        cal.setTime(date);
        transactionDateDD = Integer.toString(cal.get(Calendar.DAY_OF_MONTH));
        transactionDateMM = Integer.toString(cal.get(Calendar.MONTH) + 1);
        transactionDateYY = Integer.toString(cal.get(Calendar.YEAR));
    }
}
Also used : Calendar(java.util.Calendar) GregorianCalendar(java.util.GregorianCalendar) GregorianCalendar(java.util.GregorianCalendar) Date(java.sql.Date)

Example 63 with Date

use of java.sql.Date in project head by mifos.

the class LegacyLoanDaoIntegrationTest method getBadAccount.

private LoanBO getBadAccount() {
    Date startDate = new Date(System.currentTimeMillis());
    LoanOfferingBO loanOffering = TestObjectFactory.createLoanOffering("Loanabcd", "abcd", ApplicableTo.CLIENTS, startDate, PrdStatus.LOAN_ACTIVE, 300.0, 1.2, (short) 3, InterestType.FLAT, meeting);
    return TestObjectFactory.createLoanAccount("42423142323", group, AccountState.LOAN_ACTIVE_IN_BAD_STANDING, startDate, loanOffering);
}
Also used : LoanOfferingBO(org.mifos.accounts.productdefinition.business.LoanOfferingBO) Date(java.sql.Date)

Example 64 with Date

use of java.sql.Date in project head by mifos.

the class LegacyLoanDaoIntegrationTest method testSaveAndGetOriginalLoanScheduleEntityWithFees.

@Test
public void testSaveAndGetOriginalLoanScheduleEntityWithFees() throws PersistenceException {
    ArrayList<OriginalLoanScheduleEntity> originalLoanScheduleEntities = new ArrayList<OriginalLoanScheduleEntity>();
    Date date = new Date(new java.util.Date().getTime());
    Short installmentId = new Short("1");
    FeeBO upfrontFee = TestObjectFactory.createOneTimeRateFee("Upfront Fee", FeeCategory.LOAN, Double.valueOf("20"), FeeFormula.AMOUNT, FeePayment.UPFRONT, null);
    AccountFeesEntity accountUpfrontFee = new AccountFeesEntity(goodAccount, upfrontFee, new Double("20.0"), FeeStatus.ACTIVE.getValue(), null, date);
    AccountTestUtils.addAccountFees(accountUpfrontFee, goodAccount);
    TestObjectFactory.updateObject(goodAccount);
    goodAccount = (LoanBO) TestObjectFactory.getObject(AccountBO.class, goodAccount.getAccountId());
    LoanScheduleEntity loanScheduleEntity = new LoanScheduleEntity(goodAccount, group, installmentId, date, PaymentStatus.UNPAID, Money.zero(), Money.zero());
    LoanFeeScheduleEntity feesEntity = new LoanFeeScheduleEntity(loanScheduleEntity, upfrontFee, accountUpfrontFee, Money.zero());
    loanScheduleEntity.addAccountFeesAction(feesEntity);
    OriginalLoanScheduleEntity originalLoanScheduleEntity = new OriginalLoanScheduleEntity(loanScheduleEntity);
    OriginalLoanFeeScheduleEntity scheduleEntityFee = new OriginalLoanFeeScheduleEntity(feesEntity, originalLoanScheduleEntity);
    originalLoanScheduleEntities.add(originalLoanScheduleEntity);
    legacyLoanDao.saveOriginalSchedule(originalLoanScheduleEntities);
    List<OriginalLoanScheduleEntity> actual = legacyLoanDao.getOriginalLoanScheduleEntity(goodAccount.getAccountId());
    List<OriginalLoanFeeScheduleEntity> fees = new ArrayList<OriginalLoanFeeScheduleEntity>(actual.get(0).getAccountFeesActionDetails());
    Assert.assertEquals(1, actual.size());
    Assert.assertEquals(1, fees.size());
    assertThat(actual, is(new OriginalLoanScheduleEntitiesMatcher(originalLoanScheduleEntities)));
    assertThat(fees.get(0), is(new OriginalLoanFeeScheduleEntityMatcher(scheduleEntityFee)));
}
Also used : OriginalLoanScheduleEntity(org.mifos.accounts.loan.business.OriginalLoanScheduleEntity) LoanScheduleEntity(org.mifos.accounts.loan.business.LoanScheduleEntity) OriginalLoanScheduleEntity(org.mifos.accounts.loan.business.OriginalLoanScheduleEntity) OriginalLoanFeeScheduleEntityMatcher(org.mifos.accounts.loan.business.matchers.OriginalLoanFeeScheduleEntityMatcher) ArrayList(java.util.ArrayList) Date(java.sql.Date) OriginalLoanScheduleEntitiesMatcher(org.mifos.accounts.loan.business.matchers.OriginalLoanScheduleEntitiesMatcher) OriginalLoanFeeScheduleEntity(org.mifos.accounts.loan.business.OriginalLoanFeeScheduleEntity) FeeBO(org.mifos.accounts.fees.business.FeeBO) LoanFeeScheduleEntity(org.mifos.accounts.loan.business.LoanFeeScheduleEntity) OriginalLoanFeeScheduleEntity(org.mifos.accounts.loan.business.OriginalLoanFeeScheduleEntity) AccountFeesEntity(org.mifos.accounts.business.AccountFeesEntity) Test(org.junit.Test)

Example 65 with Date

use of java.sql.Date in project head by mifos.

the class LegacyLoanDaoIntegrationTest method getGoodAccount.

private LoanBO getGoodAccount() {
    Date startDate = new Date(System.currentTimeMillis());
    LoanOfferingBO loanOffering = TestObjectFactory.createLoanOffering("Loanabf", "abf", ApplicableTo.CLIENTS, startDate, PrdStatus.LOAN_ACTIVE, 300.0, 1.2, (short) 3, InterestType.FLAT, meeting);
    return TestObjectFactory.createLoanAccount("42423142342", group, AccountState.LOAN_ACTIVE_IN_GOOD_STANDING, startDate, loanOffering);
}
Also used : LoanOfferingBO(org.mifos.accounts.productdefinition.business.LoanOfferingBO) Date(java.sql.Date)

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