当前位置:   article > 正文

java datahelper_Java DateHelper.daysBetween方法代码示例

java datahelper

import nl.strohalm.cyclos.utils.DateHelper; //导入方法依赖的package包/类

private Loan doGrant(Loan loan, final GrantLoanDTO params) {

final LocalSettings localSettings = settingsService.getLocalSettings();

final TransferType transferType = params.getTransferType();

// Create the loan transfer

final TransferDTO transferDto = new TransferDTO();

if (params.isAutomatic()) {

transferDto.setContext(TransactionContext.AUTOMATIC_LOAN);

} else {

transferDto.setContext(TransactionContext.LOAN);

}

if (params.getDate() != null) {

transferDto.setDate(params.getDate());

}

transferDto.setToOwner(params.getMember());

transferDto.setFrom(accountService.getAccount(new AccountDTO(SystemAccountOwner.instance(), transferType.getFrom())));

transferDto.setTo(accountService.getAccount(new AccountDTO(transferDto.getToOwner(), transferType.getTo())));

transferDto.setAmount(params.getAmount());

transferDto.setDescription(params.getDescription());

transferDto.setTransferType(transferType);

transferDto.setCustomValues(params.getCustomValues());

transferDto.setRates(rateService.applyLoan(transferDto, params));

final Transfer transfer = (Transfer) paymentService.insertWithoutNotification(transferDto);

if (transfer.getProcessDate() == null && params.getDate() != null && DateHelper.daysBetween(params.getDate(), Calendar.getInstance()) != 0) {

throw new AuthorizedPaymentInPastException();

}

// Persist the loan

loan.setTransfer(transfer);

final List payments = loan.getPayments();

loan = loanDao.insert(loan);

loan.setPayments(new ArrayList());

// Insert the installments

int index = 0;

BigDecimal total = BigDecimal.ZERO;

for (final LoanPayment payment : payments) {

payment.setLoan(loan);

payment.setIndex(index++);

BigDecimal amount = localSettings.round(payment.getAmount());

if (index == payments.size()) {

// The last payment should round to total amount

amount = localSettings.round(loan.getTotalAmount().subtract(total));

} else {

total = total.add(amount);

}

payment.setAmount(amount);

loan.getPayments().add(loanPaymentDao.insert(payment));

}

// Notify

memberNotificationHandler.grantedLoanNotification(loan);

return loan;

}

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/小小林熬夜学编程/article/detail/403466
推荐阅读
相关标签
  

闽ICP备14008679号