List of usage examples for org.joda.time LocalDate toDateMidnight
@Deprecated
public DateMidnight toDateMidnight()
From source file:org.apache.isis.objectstore.jdo.datanucleus.Utils.java
License:Apache License
public static long toMillis(int year, int monthOfYear, int dayOfMonth) { LocalDate d = new LocalDate(year, monthOfYear, dayOfMonth); return d.toDateMidnight().getMillis(); }
From source file:org.mifos.accounts.api.StandardAccountService.java
License:Open Source License
private Date reciptDateNullValidation(LocalDate reciptDate) { return null == reciptDate ? null : reciptDate.toDateMidnight().toDate(); }
From source file:org.mifos.accounts.api.StandardAccountService.java
License:Open Source License
public void handleLoanDisbursal(Locale locale, LoanBO loan, PersonnelBO personnelBO, BigDecimal paymentAmount, PaymentTypeDto paymentType, LocalDate receiptLocalDate, LocalDate paymentLocalDate, String receiptId) throws PersistenceException, AccountException { if ("MPESA".equals(paymentType.getName())) { paymentAmount = computeWithdrawnForMPESA(paymentAmount, loan); }//from w w w. jav a2s.c om PaymentTypeEntity paymentTypeEntity = legacyMasterDao.getPersistentObject(PaymentTypeEntity.class, paymentType.getValue()); Money amount = new Money(loan.getCurrency(), paymentAmount); Date receiptDate = null; if (null != receiptLocalDate) { receiptDate = receiptLocalDate.toDateMidnight().toDate(); } Date transactionDate = paymentLocalDate.toDateMidnight().toDate(); AccountPaymentEntity disbursalPayment = new AccountPaymentEntity(loan, amount, receiptId, receiptDate, paymentTypeEntity, transactionDate); disbursalPayment.setCreatedByUser(personnelBO); Double interestRate = loan.getInterestRate(); Date oldDisbursementDate = loan.getDisbursementDate(); List<RepaymentScheduleInstallment> originalInstallments = loan.toRepaymentScheduleDto(locale); loan.disburseLoan(disbursalPayment); if (!loan.isVariableInstallmentsAllowed()) { originalInstallments = loan.toRepaymentScheduleDto(locale); } Date newDisbursementDate = loan.getDisbursementDate(); boolean variableInstallmentsAllowed = loan.isVariableInstallmentsAllowed(); loanBusinessService.adjustDatesForVariableInstallments(variableInstallmentsAllowed, loan.isFixedRepaymentSchedule(), originalInstallments, oldDisbursementDate, newDisbursementDate, loan.getOfficeId()); Date today = new LocalDate().toDateMidnight().toDate(); Date disburseDay = new LocalDate(oldDisbursementDate).toDateMidnight().toDate(); if (!today.equals(disburseDay)) { loanBusinessService .applyDailyInterestRatesWhereApplicable(new LoanScheduleGenerationDto(newDisbursementDate, loan, variableInstallmentsAllowed, amount, interestRate), originalInstallments); } loanBusinessService.persistOriginalSchedule(loan); }
From source file:org.mifos.accounts.business.AccountBO.java
License:Open Source License
public AccountActionDateEntity getDetailsOfNextInstallmentOn(LocalDate asOf) { AccountActionDateEntity nextAccountAction = null; Date currentDate = asOf.toDateMidnight().toDate(); if (getAccountActionDates() != null && getAccountActionDates().size() > 0) { for (AccountActionDateEntity accountAction : getAccountActionDates()) { if (accountAction.getActionDate().compareTo(currentDate) >= 0) { if (null == nextAccountAction || nextAccountAction.getInstallmentId() > accountAction.getInstallmentId()) { nextAccountAction = accountAction; }/*from w ww . jav a 2 s . c o m*/ } } } return nextAccountAction; }
From source file:org.mifos.accounts.loan.business.LoanBO.java
License:Open Source License
public void recordOverpayment(Money balance, LocalDate paymentDate, PersonnelBO user, String receiptId, LocalDate receiptDate, Short modeOfPayment) throws AccountException { if (balance.isGreaterThanZero()) { Date transactionDate = paymentDate.toDateMidnight().toDate(); PaymentData paymentData = new PaymentData(balance, user, modeOfPayment, transactionDate); if (receiptId != null) { paymentData.setReceiptNum(receiptId); }/*from w w w .j a va 2 s . co m*/ if (receiptDate != null) { paymentData.setReceiptDate(receiptDate.toDateMidnight().toDate()); } AccountPaymentEntity accountPaymentEntity = prePayment(paymentData); // update Money overpayment = balance; List<AccountActionDateEntity> paidInstallments = getDetailsOfPaidInstallmentsOn(paymentDate); if (!paidInstallments.isEmpty()) { LoanScheduleEntity lastFullyPaidInstallment = (LoanScheduleEntity) paidInstallments .get(paidInstallments.size() - 1); lastFullyPaidInstallment.updatePrincipalPaidby(accountPaymentEntity, user); LoanTrxnDetailEntity loanTrxnDetailEntity = new LoanTrxnDetailEntity(accountPaymentEntity, lastFullyPaidInstallment, user, transactionDate, AccountActionTypes.LOAN_REPAYMENT, AccountConstants.PAYMENT_RCVD, legacyLoanDao); accountPaymentEntity.addAccountTrxn(loanTrxnDetailEntity); PaymentAllocation paymentAllocation = new PaymentAllocation(overpayment.getCurrency()); paymentAllocation.allocateForPrincipal(overpayment); this.loanSummary.updatePaymentDetails(paymentAllocation); } LoanPaymentTypes loanPaymentType = getLoanPaymentType(paymentData.getTotalAmount()); postPayment(paymentData, accountPaymentEntity, loanPaymentType); addAccountPayment(accountPaymentEntity); buildFinancialEntries(accountPaymentEntity.getAccountTrxns()); } }
From source file:org.mifos.accounts.loan.business.LoanBO.java
License:Open Source License
public Money applyNewPaymentMechanism(LocalDate paymentDate, BigDecimal repaymentAmount, PersonnelBO user, String receiptId, LocalDate receiptDate, Short modeOfPayment) throws AccountException { Money totalAmount = new Money(getCurrency(), repaymentAmount); Date transactionDate = paymentDate.toDateMidnight().toDate(); PaymentData paymentData = new PaymentData(totalAmount, user, modeOfPayment, transactionDate); if (receiptId != null) { paymentData.setReceiptNum(receiptId); }//w w w.j av a2 s .c om if (receiptDate != null) { paymentData.setReceiptDate(receiptDate.toDateMidnight().toDate()); } AccountPaymentEntity accountPaymentEntity = prePayment(paymentData); Money balance = totalAmount; LoanPaymentTypes loanPaymentType = getLoanPaymentType(paymentData.getTotalAmount()); // 1. pay off installments in arrears List<AccountActionDateEntity> inArrears = getDetailsOfInstallmentsInArrearsOn(paymentDate); for (AccountActionDateEntity accountActionDate : inArrears) { balance = ((LoanScheduleEntity) accountActionDate).applyPayment(accountPaymentEntity, balance, user, transactionDate); } // 2. pay off due installment (normal way) if (balance.isGreaterThanZero()) { AccountActionDateEntity upcomingInstallment = getDetailsOfNextInstallmentOn(paymentDate); balance = ((LoanScheduleEntity) upcomingInstallment).applyPayment(accountPaymentEntity, balance, user, transactionDate); } if (!accountPaymentEntity.getAccountTrxns().isEmpty()) { postPayment(paymentData, accountPaymentEntity, loanPaymentType); addAccountPayment(accountPaymentEntity); buildFinancialEntries(accountPaymentEntity.getAccountTrxns()); } return balance; }
From source file:org.mifos.accounts.loan.business.LoanBO.java
License:Open Source License
public void approve(PersonnelBO createdBy, String comment, LocalDate approvalDate) { AccountStateEntity approvedState = new AccountStateEntity(AccountState.LOAN_APPROVED); AccountStatusChangeHistoryEntity historyEntity = new AccountStatusChangeHistoryEntity( this.getAccountState(), approvedState, createdBy, this); AccountNotesEntity accountNotesEntity = new AccountNotesEntity(approvalDate.toDateMidnight().toDate(), comment, createdBy, this); this.addAccountStatusChangeHistory(historyEntity); this.setAccountState(approvedState); this.addAccountNotes(accountNotesEntity); }
From source file:org.mifos.accounts.loan.persistance.StandardClientAttendanceDao.java
License:Open Source License
@Override @SuppressWarnings("unchecked") public List<ClientAttendanceBO> findClientAttendance(final Short branchId, final String searchId, final LocalDate meetingDate) throws PersistenceException { Map<String, Object> queryParameters = new HashMap<String, Object>(); queryParameters.put("BRANCH_ID", branchId); queryParameters.put("SEARCH_ID", searchId + ".%"); queryParameters.put("MEETING_DATE", meetingDate.toDateMidnight().toDate()); return legacyMasterDao.executeNamedQuery("ClientAttendance.getAttendanceForClientsOnMeetingDate", queryParameters);//from w ww . ja va2 s . c o m }
From source file:org.mifos.accounts.loan.util.helpers.RepaymentScheduleInstallment.java
License:Open Source License
public static RepaymentScheduleInstallment createForScheduleCopy(Integer installmentNumber, String principal, String interest, LocalDate dueDate, Locale locale, MifosCurrency currency) { Money feess = null;//from w w w .ja v a 2 s. c o m Money miscFeess = null; Money miscPenaltys = null; return new RepaymentScheduleInstallment(installmentNumber, new java.sql.Date(dueDate.toDateMidnight().toDate().getTime()), new Money(currency, principal), new Money(currency, interest), feess, miscFeess, miscPenaltys); }
From source file:org.mifos.accounts.savings.business.SavingsBO.java
License:Open Source License
/** * Responsible for creating savings account in valid initial state. */// www . ja v a 2 s .co m public static SavingsBO createOpeningBalanceIndividualSavingsAccount(CustomerBO customer, SavingsOfferingBO savingsProduct, Money recommendedOrMandatoryAmount, AccountState savingsAccountState, LocalDate createdDate, Integer createdById, SavingsAccountActivationDetail activationDetails, PersonnelBO createdBy, Money openingBalance) { RecommendedAmountUnit recommendedAmountUnit = RecommendedAmountUnit.COMPLETE_GROUP; CreationDetail creationDetail = new CreationDetail(createdDate.toDateMidnight().toDateTime(), createdById); SavingsBO savingsAccount = new SavingsBO(savingsAccountState, customer, activationDetails, creationDetail, savingsProduct, recommendedAmountUnit, recommendedOrMandatoryAmount, createdBy, openingBalance); return savingsAccount; }