remove unused warnings, replace toDateMidnight with toDateTimeAtStartOfDay method as recommended by joda time lib.

This commit is contained in:
Keith Woodlock
2013-11-13 10:34:10 +00:00
parent aa0df6a0c3
commit 40882a002b
14 changed files with 118 additions and 130 deletions
@@ -267,7 +267,7 @@ public class JournalEntryWritePlatformServiceJpaRepositoryImpl implements Journa
.getTransactionId()); .getTransactionId());
if (journalEntries.size() <= 1) { throw new JournalEntriesNotFoundException(command.getTransactionId()); } if (journalEntries.size() <= 1) { throw new JournalEntriesNotFoundException(command.getTransactionId()); }
Long officeId = journalEntries.get(0).getOffice().getId(); final Long officeId = journalEntries.get(0).getOffice().getId();
final String reversalTransactionId = generateTransactionId(officeId); final String reversalTransactionId = generateTransactionId(officeId);
final boolean manualEntry = true; final boolean manualEntry = true;
@@ -330,7 +330,7 @@ public class JournalEntryWritePlatformServiceJpaRepositoryImpl implements Journa
private void validateBusinessRulesForJournalEntries(final JournalEntryCommand command) { private void validateBusinessRulesForJournalEntries(final JournalEntryCommand command) {
/** check if date of Journal entry is valid ***/ /** check if date of Journal entry is valid ***/
final LocalDate entryLocalDate = command.getTransactionDate(); final LocalDate entryLocalDate = command.getTransactionDate();
final Date transactionDate = entryLocalDate.toDateMidnight().toDate(); final Date transactionDate = entryLocalDate.toDateTimeAtStartOfDay().toDate();
// shouldn't be in the future // shouldn't be in the future
final Date todaysDate = new Date(); final Date todaysDate = new Date();
if (transactionDate.after(todaysDate)) { throw new JournalEntryInvalidException(GL_JOURNAL_ENTRY_INVALID_REASON.FUTURE_DATE, if (transactionDate.after(todaysDate)) { throw new JournalEntryInvalidException(GL_JOURNAL_ENTRY_INVALID_REASON.FUTURE_DATE,
@@ -347,7 +347,7 @@ public class JournalEntryWritePlatformServiceJpaRepositoryImpl implements Journa
final SingleDebitOrCreditEntryCommand[] debits = command.getDebits(); final SingleDebitOrCreditEntryCommand[] debits = command.getDebits();
// atleast one debit or credit must be present // atleast one debit or credit must be present
if ((credits == null || credits.length <= 0) || (debits == null || debits.length <= 0)) { throw new JournalEntryInvalidException( if (credits == null || credits.length <= 0 || debits == null || debits.length <= 0) { throw new JournalEntryInvalidException(
GL_JOURNAL_ENTRY_INVALID_REASON.NO_DEBITS_OR_CREDITS, null, null, null); } GL_JOURNAL_ENTRY_INVALID_REASON.NO_DEBITS_OR_CREDITS, null, null, null); }
checkDebitAndCreditAmounts(credits, debits); checkDebitAndCreditAmounts(credits, debits);
@@ -381,11 +381,11 @@ public class JournalEntryWritePlatformServiceJpaRepositoryImpl implements Journa
* TODO: Need a better implementation with guaranteed uniqueness (but not a * TODO: Need a better implementation with guaranteed uniqueness (but not a
* long UUID)...maybe something tied to system clock.. * long UUID)...maybe something tied to system clock..
*/ */
private String generateTransactionId(Long officeId) { private String generateTransactionId(final Long officeId) {
AppUser user = this.context.authenticatedUser(); final AppUser user = this.context.authenticatedUser();
Long time = System.currentTimeMillis(); final Long time = System.currentTimeMillis();
String uniqueVal = String.valueOf(time) + user.getId() + officeId; final String uniqueVal = String.valueOf(time) + user.getId() + officeId;
String transactionId = Long.toHexString(Long.parseLong(uniqueVal)); final String transactionId = Long.toHexString(Long.parseLong(uniqueVal));
return transactionId; return transactionId;
} }
@@ -295,7 +295,7 @@ public final class JsonCommand {
public Date DateValueOfParameterNamed(final String parameterName) { public Date DateValueOfParameterNamed(final String parameterName) {
final LocalDate localDate = this.fromApiJsonHelper.extractLocalDateNamed(parameterName, this.parsedCommand); final LocalDate localDate = this.fromApiJsonHelper.extractLocalDateNamed(parameterName, this.parsedCommand);
if (localDate == null) { return null; } if (localDate == null) { return null; }
return localDate.toDateMidnight().toDate(); return localDate.toDateTimeAtStartOfDay().toDate();
} }
public boolean isChangeInStringParameterNamed(final String parameterName, final String existingValue) { public boolean isChangeInStringParameterNamed(final String parameterName, final String existingValue) {
@@ -23,7 +23,7 @@ import org.mifosplatform.infrastructure.core.exception.PlatformApiDataValidation
public class DateUtils { public class DateUtils {
public static Date getDateOfTenant() { public static Date getDateOfTenant() {
return getLocalDateOfTenant().toDateMidnight().toDate(); return getLocalDateOfTenant().toDateTimeAtStartOfDay().toDate();
} }
public static LocalDate getLocalDateOfTenant() { public static LocalDate getLocalDateOfTenant() {
@@ -76,7 +76,7 @@ public class Office extends AbstractPersistable<Long> {
private Office(final Office parent, final String name, final LocalDate openingDate, final String externalId) { private Office(final Office parent, final String name, final LocalDate openingDate, final String externalId) {
this.parent = parent; this.parent = parent;
this.openingDate = openingDate.toDateMidnight().toDate(); this.openingDate = openingDate.toDateTimeAtStartOfDay().toDate();
if (parent != null) { if (parent != null) {
this.parent.addChild(this); this.parent.addChild(this);
} }
@@ -80,13 +80,13 @@ public class Calendar extends AbstractAuditableCustom<AppUser, Long> {
this.location = StringUtils.defaultIfEmpty(location, null); this.location = StringUtils.defaultIfEmpty(location, null);
if (null != startDate) { if (null != startDate) {
this.startDate = startDate.toDateMidnight().toDate(); this.startDate = startDate.toDateTimeAtStartOfDay().toDate();
} else { } else {
this.startDate = null; this.startDate = null;
} }
if (null != endDate) { if (null != endDate) {
this.endDate = endDate.toDateMidnight().toDate(); this.endDate = endDate.toDateTimeAtStartOfDay().toDate();
} else { } else {
this.endDate = null; this.endDate = null;
} }
@@ -178,10 +178,10 @@ public final class Client extends AbstractPersistable<Long> {
} }
if (activationDate != null) { if (activationDate != null) {
this.activationDate = activationDate.toDateMidnight().toDate(); this.activationDate = activationDate.toDateTimeAtStartOfDay().toDate();
} }
if (officeJoiningDate != null) { if (officeJoiningDate != null) {
this.officeJoiningDate = officeJoiningDate.toDateMidnight().toDate(); this.officeJoiningDate = officeJoiningDate.toDateTimeAtStartOfDay().toDate();
} }
if (StringUtils.isNotBlank(firstname)) { if (StringUtils.isNotBlank(firstname)) {
this.firstname = firstname.trim(); this.firstname = firstname.trim();
@@ -10,7 +10,6 @@ public class LoanInstallmentChargeData {
private final LocalDate dueDate; private final LocalDate dueDate;
@SuppressWarnings("unused") @SuppressWarnings("unused")
private final BigDecimal amount; private final BigDecimal amount;
@SuppressWarnings("unused")
private final BigDecimal amountOutstanding; private final BigDecimal amountOutstanding;
private final boolean paid; private final boolean paid;
private final boolean waived; private final boolean waived;
@@ -34,7 +33,7 @@ public class LoanInstallmentChargeData {
} }
public boolean isPaymentPending(){ public boolean isPaymentPending(){
return !(paid || waived); return !(this.paid || this.waived);
} }
@@ -72,7 +72,6 @@ public class LoanCharge extends AbstractPersistable<Long> {
@Column(name = "calculation_on_amount", scale = 6, precision = 19, nullable = true) @Column(name = "calculation_on_amount", scale = 6, precision = 19, nullable = true)
private BigDecimal amountPercentageAppliedTo; private BigDecimal amountPercentageAppliedTo;
@SuppressWarnings("unused")
@Column(name = "charge_amount_or_percentage", scale = 6, precision = 19, nullable = false) @Column(name = "charge_amount_or_percentage", scale = 6, precision = 19, nullable = false)
private BigDecimal amountOrPercentage; private BigDecimal amountOrPercentage;
@@ -108,7 +107,7 @@ public class LoanCharge extends AbstractPersistable<Long> {
@LazyCollection(LazyCollectionOption.FALSE) @LazyCollection(LazyCollectionOption.FALSE)
@OneToMany(cascade = CascadeType.ALL, mappedBy = "loancharge", orphanRemoval = true) @OneToMany(cascade = CascadeType.ALL, mappedBy = "loancharge", orphanRemoval = true)
private Set<LoanInstallmentCharge> loanInstallmentCharge = new HashSet<LoanInstallmentCharge>(); private final Set<LoanInstallmentCharge> loanInstallmentCharge = new HashSet<LoanInstallmentCharge>();
public static LoanCharge createNewFromJson(final Loan loan, final Charge chargeDefinition, final JsonCommand command) { public static LoanCharge createNewFromJson(final Loan loan, final Charge chargeDefinition, final JsonCommand command) {
@@ -248,15 +247,15 @@ public class LoanCharge extends AbstractPersistable<Long> {
break; break;
} }
this.amountOrPercentage = chargeAmount; this.amountOrPercentage = chargeAmount;
if(this.loan!=null && this.isInstalmentFee()){ if(this.loan!=null && isInstalmentFee()){
Set<LoanInstallmentCharge> chargePerInstallments = this.loan.generateInstallmentLoanCharges(this); final Set<LoanInstallmentCharge> chargePerInstallments = this.loan.generateInstallmentLoanCharges(this);
if(this.loanInstallmentCharge.isEmpty()){ if(this.loanInstallmentCharge.isEmpty()){
this.loanInstallmentCharge.addAll(chargePerInstallments); this.loanInstallmentCharge.addAll(chargePerInstallments);
}else{ }else{
int index = 0; int index = 0;
LoanInstallmentCharge[] loanChargePerInstallments = new LoanInstallmentCharge[chargePerInstallments.size()]; final LoanInstallmentCharge[] loanChargePerInstallments = new LoanInstallmentCharge[chargePerInstallments.size()];
LoanInstallmentCharge[] loanChargePerInstallmentArray = chargePerInstallments.toArray(loanChargePerInstallments); final LoanInstallmentCharge[] loanChargePerInstallmentArray = chargePerInstallments.toArray(loanChargePerInstallments);
for(LoanInstallmentCharge chargePerInstallment:this.loanInstallmentCharge){ for(final LoanInstallmentCharge chargePerInstallment:this.loanInstallmentCharge){
chargePerInstallment.copyFrom(loanChargePerInstallmentArray[index++]); chargePerInstallment.copyFrom(loanChargePerInstallmentArray[index++]);
} }
} }
@@ -276,7 +275,7 @@ public class LoanCharge extends AbstractPersistable<Long> {
this.amountOutstanding = calculateAmountOutstanding(currency); this.amountOutstanding = calculateAmountOutstanding(currency);
this.paid = false; this.paid = false;
this.waived = false; this.waived = false;
for(LoanInstallmentCharge installmentCharge:loanInstallmentCharge){ for(final LoanInstallmentCharge installmentCharge:this.loanInstallmentCharge){
installmentCharge.resetPaidAmount(currency); installmentCharge.resetPaidAmount(currency);
} }
} }
@@ -285,15 +284,15 @@ public class LoanCharge extends AbstractPersistable<Long> {
this.amountPaid = BigDecimal.ZERO; this.amountPaid = BigDecimal.ZERO;
this.amountOutstanding = calculateAmountOutstanding(currency); this.amountOutstanding = calculateAmountOutstanding(currency);
this.paid = false; this.paid = false;
for(LoanInstallmentCharge installmentCharge:loanInstallmentCharge){ for(final LoanInstallmentCharge installmentCharge:this.loanInstallmentCharge){
installmentCharge.resetPaidAmount(currency); installmentCharge.resetPaidAmount(currency);
} }
} }
public Money waive(final MonetaryCurrency currency, Integer loanInstallmentNumber) { public Money waive(final MonetaryCurrency currency, final Integer loanInstallmentNumber) {
if(isInstalmentFee()){ if(isInstalmentFee()){
LoanInstallmentCharge chargePerInstallment = getInstallmentLoanCharge(loanInstallmentNumber); final LoanInstallmentCharge chargePerInstallment = getInstallmentLoanCharge(loanInstallmentNumber);
Money amountWaived = chargePerInstallment.waive(currency); final Money amountWaived = chargePerInstallment.waive(currency);
if(this.amountWaived == null){ if(this.amountWaived == null){
this.amountWaived = BigDecimal.ZERO; this.amountWaived = BigDecimal.ZERO;
} }
@@ -353,15 +352,15 @@ public class LoanCharge extends AbstractPersistable<Long> {
break; break;
} }
this.amountOrPercentage = amount; this.amountOrPercentage = amount;
if(this.loan !=null && this.isInstalmentFee()){ if(this.loan !=null && isInstalmentFee()){
Set<LoanInstallmentCharge> chargePerInstallments = this.loan.generateInstallmentLoanCharges(this); final Set<LoanInstallmentCharge> chargePerInstallments = this.loan.generateInstallmentLoanCharges(this);
if(this.loanInstallmentCharge.isEmpty()){ if(this.loanInstallmentCharge.isEmpty()){
this.loanInstallmentCharge.addAll(chargePerInstallments); this.loanInstallmentCharge.addAll(chargePerInstallments);
}else{ }else{
int index = 0; int index = 0;
LoanInstallmentCharge[] loanChargePerInstallments = new LoanInstallmentCharge[chargePerInstallments.size()]; final LoanInstallmentCharge[] loanChargePerInstallments = new LoanInstallmentCharge[chargePerInstallments.size()];
LoanInstallmentCharge[] loanChargePerInstallmentArray = chargePerInstallments.toArray(loanChargePerInstallments); final LoanInstallmentCharge[] loanChargePerInstallmentArray = chargePerInstallments.toArray(loanChargePerInstallments);
for(LoanInstallmentCharge chargePerInstallment:this.loanInstallmentCharge){ for(final LoanInstallmentCharge chargePerInstallment:this.loanInstallmentCharge){
chargePerInstallment.copyFrom(loanChargePerInstallmentArray[index++]); chargePerInstallment.copyFrom(loanChargePerInstallmentArray[index++]);
} }
} }
@@ -416,15 +415,15 @@ public class LoanCharge extends AbstractPersistable<Long> {
break; break;
} }
this.amountOrPercentage = newValue; this.amountOrPercentage = newValue;
if(this.isInstalmentFee()){ if(isInstalmentFee()){
Set<LoanInstallmentCharge> chargePerInstallments = this.loan.generateInstallmentLoanCharges(this); final Set<LoanInstallmentCharge> chargePerInstallments = this.loan.generateInstallmentLoanCharges(this);
if(this.loanInstallmentCharge.isEmpty()){ if(this.loanInstallmentCharge.isEmpty()){
this.loanInstallmentCharge.addAll(chargePerInstallments); this.loanInstallmentCharge.addAll(chargePerInstallments);
}else{ }else{
int index = 0; int index = 0;
LoanInstallmentCharge[] loanChargePerInstallments = new LoanInstallmentCharge[chargePerInstallments.size()]; final LoanInstallmentCharge[] loanChargePerInstallments = new LoanInstallmentCharge[chargePerInstallments.size()];
LoanInstallmentCharge[] loanChargePerInstallmentArray = chargePerInstallments.toArray(loanChargePerInstallments); final LoanInstallmentCharge[] loanChargePerInstallmentArray = chargePerInstallments.toArray(loanChargePerInstallments);
for(LoanInstallmentCharge chargePerInstallment:this.loanInstallmentCharge){ for(final LoanInstallmentCharge chargePerInstallment:this.loanInstallmentCharge){
chargePerInstallment.copyFrom(loanChargePerInstallmentArray[index++]); chargePerInstallment.copyFrom(loanChargePerInstallmentArray[index++]);
} }
} }
@@ -615,9 +614,9 @@ public class LoanCharge extends AbstractPersistable<Long> {
* Amount used to pay off this charge * Amount used to pay off this charge
* @return Actual amount paid on this charge * @return Actual amount paid on this charge
*/ */
public Money updatePaidAmountBy(final Money incrementBy,final Integer installmentNumber, Money feeAmount) { public Money updatePaidAmountBy(final Money incrementBy,final Integer installmentNumber, final Money feeAmount) {
Money processAmount = Money.zero(incrementBy.getCurrency()); Money processAmount = Money.zero(incrementBy.getCurrency());
if(this.isInstalmentFee()){ if(isInstalmentFee()){
if(installmentNumber == null){ if(installmentNumber == null){
processAmount = getUnpaidInstallmentLoanCharge().updatePaidAmountBy(incrementBy, feeAmount); processAmount = getUnpaidInstallmentLoanCharge().updatePaidAmountBy(incrementBy, feeAmount);
}else{ }else{
@@ -701,7 +700,7 @@ public class LoanCharge extends AbstractPersistable<Long> {
public LoanInstallmentCharge getUnpaidInstallmentLoanCharge() { public LoanInstallmentCharge getUnpaidInstallmentLoanCharge() {
LoanInstallmentCharge unpaidChargePerInstallment = null; LoanInstallmentCharge unpaidChargePerInstallment = null;
for (LoanInstallmentCharge loanChargePerInstallment : this.loanInstallmentCharge) { for (final LoanInstallmentCharge loanChargePerInstallment : this.loanInstallmentCharge) {
if (loanChargePerInstallment.isPending() if (loanChargePerInstallment.isPending()
&& (unpaidChargePerInstallment == null || unpaidChargePerInstallment.getRepaymentInstallment().getDueDate() && (unpaidChargePerInstallment == null || unpaidChargePerInstallment.getRepaymentInstallment().getDueDate()
.isAfter(loanChargePerInstallment.getRepaymentInstallment().getDueDate()))) { .isAfter(loanChargePerInstallment.getRepaymentInstallment().getDueDate()))) {
@@ -711,8 +710,8 @@ public class LoanCharge extends AbstractPersistable<Long> {
return unpaidChargePerInstallment; return unpaidChargePerInstallment;
} }
public LoanInstallmentCharge getInstallmentLoanCharge(LocalDate periodDueDate) { public LoanInstallmentCharge getInstallmentLoanCharge(final LocalDate periodDueDate) {
for (LoanInstallmentCharge loanChargePerInstallment : this.loanInstallmentCharge) { for (final LoanInstallmentCharge loanChargePerInstallment : this.loanInstallmentCharge) {
if (periodDueDate.isEqual(loanChargePerInstallment.getRepaymentInstallment().getDueDate())) { if (periodDueDate.isEqual(loanChargePerInstallment.getRepaymentInstallment().getDueDate())) {
return loanChargePerInstallment; return loanChargePerInstallment;
} }
@@ -720,8 +719,8 @@ public class LoanCharge extends AbstractPersistable<Long> {
return null; return null;
} }
public LoanInstallmentCharge getInstallmentLoanCharge(Integer installmentNumber) { public LoanInstallmentCharge getInstallmentLoanCharge(final Integer installmentNumber) {
for (LoanInstallmentCharge loanChargePerInstallment : this.loanInstallmentCharge) { for (final LoanInstallmentCharge loanChargePerInstallment : this.loanInstallmentCharge) {
if (installmentNumber.equals(loanChargePerInstallment.getRepaymentInstallment().getInstallmentNumber().intValue()) ){ if (installmentNumber.equals(loanChargePerInstallment.getRepaymentInstallment().getInstallmentNumber().intValue()) ){
return loanChargePerInstallment; return loanChargePerInstallment;
} }
@@ -733,7 +732,7 @@ public class LoanCharge extends AbstractPersistable<Long> {
this.loanInstallmentCharge.clear(); this.loanInstallmentCharge.clear();
} }
public void addLoanInstallmentCharges(Collection<LoanInstallmentCharge> installmentCharges){ public void addLoanInstallmentCharges(final Collection<LoanInstallmentCharge> installmentCharges){
this.loanInstallmentCharge.addAll(installmentCharges); this.loanInstallmentCharge.addAll(installmentCharges);
} }
@@ -741,8 +740,8 @@ public class LoanCharge extends AbstractPersistable<Long> {
return this.loanInstallmentCharge.isEmpty(); return this.loanInstallmentCharge.isEmpty();
} }
public LoanRepaymentScheduleInstallment fetchRepaymentInstallment(Money trasferedAmount){ public LoanRepaymentScheduleInstallment fetchRepaymentInstallment(final Money trasferedAmount){
for (LoanInstallmentCharge loanChargePerInstallment : this.loanInstallmentCharge) { for (final LoanInstallmentCharge loanChargePerInstallment : this.loanInstallmentCharge) {
if (loanChargePerInstallment.isPending() && if (loanChargePerInstallment.isPending() &&
trasferedAmount.getAmount().equals(loanChargePerInstallment.getAmountThroughChargePayment(trasferedAmount.getCurrency()).getAmount()) ){ trasferedAmount.getAmount().equals(loanChargePerInstallment.getAmountThroughChargePayment(trasferedAmount.getCurrency()).getAmount()) ){
return loanChargePerInstallment.getRepaymentInstallment(); return loanChargePerInstallment.getRepaymentInstallment();
@@ -21,7 +21,6 @@ import org.springframework.data.jpa.domain.AbstractPersistable;
@Table(name = "m_loan_installment_charge") @Table(name = "m_loan_installment_charge")
public class LoanInstallmentCharge extends AbstractPersistable<Long> { public class LoanInstallmentCharge extends AbstractPersistable<Long> {
@SuppressWarnings("unused")
@ManyToOne(optional = false) @ManyToOne(optional = false)
@JoinColumn(name = "loan_charge_id", referencedColumnName = "id", nullable = false) @JoinColumn(name = "loan_charge_id", referencedColumnName = "id", nullable = false)
private LoanCharge loancharge; private LoanCharge loancharge;
@@ -59,7 +58,7 @@ public class LoanInstallmentCharge extends AbstractPersistable<Long> {
// TODO Auto-generated constructor stub // TODO Auto-generated constructor stub
} }
public LoanInstallmentCharge(BigDecimal amount,LoanCharge loanCharge,LoanRepaymentScheduleInstallment installment) { public LoanInstallmentCharge(final BigDecimal amount,final LoanCharge loanCharge,final LoanRepaymentScheduleInstallment installment) {
this.loancharge = loanCharge; this.loancharge = loanCharge;
this.installment = installment; this.installment = installment;
this.amount = amount; this.amount = amount;
@@ -69,7 +68,7 @@ public class LoanInstallmentCharge extends AbstractPersistable<Long> {
this.amountWrittenOff = null; this.amountWrittenOff = null;
} }
public void copyFrom(LoanInstallmentCharge loanChargePerInstallment){ public void copyFrom(final LoanInstallmentCharge loanChargePerInstallment){
this.amount = loanChargePerInstallment.amount; this.amount = loanChargePerInstallment.amount;
this.installment = loanChargePerInstallment.installment; this.installment = loanChargePerInstallment.installment;
this.amountOutstanding = calculateOutstanding(); this.amountOutstanding = calculateOutstanding();
@@ -160,7 +159,7 @@ public class LoanInstallmentCharge extends AbstractPersistable<Long> {
return this.installment; return this.installment;
} }
public Money updatePaidAmountBy(final Money incrementBy, Money feeAmount) { public Money updatePaidAmountBy(final Money incrementBy, final Money feeAmount) {
Money amountPaidToDate = Money.of(incrementBy.getCurrency(), this.amountPaid); Money amountPaidToDate = Money.of(incrementBy.getCurrency(), this.amountPaid);
final Money amountOutstanding = Money.of(incrementBy.getCurrency(), this.amountOutstanding); final Money amountOutstanding = Money.of(incrementBy.getCurrency(), this.amountOutstanding);
@@ -7,22 +7,15 @@ package org.mifosplatform.portfolio.loanaccount.domain;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.util.Date; import java.util.Date;
import java.util.HashSet;
import java.util.Set;
import javax.persistence.CascadeType;
import javax.persistence.Column; import javax.persistence.Column;
import javax.persistence.Entity; import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.JoinColumn; import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne; import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.Table; import javax.persistence.Table;
import javax.persistence.Temporal; import javax.persistence.Temporal;
import javax.persistence.TemporalType; import javax.persistence.TemporalType;
import org.hibernate.annotations.LazyCollection;
import org.hibernate.annotations.LazyCollectionOption;
import org.joda.time.LocalDate; import org.joda.time.LocalDate;
import org.mifosplatform.infrastructure.core.domain.AbstractAuditableCustom; import org.mifosplatform.infrastructure.core.domain.AbstractAuditableCustom;
import org.mifosplatform.organisation.monetary.domain.MonetaryCurrency; import org.mifosplatform.organisation.monetary.domain.MonetaryCurrency;
@@ -118,8 +111,8 @@ public final class LoanRepaymentScheduleInstallment extends AbstractAuditableCus
final BigDecimal penaltyCharges) { final BigDecimal penaltyCharges) {
this.loan = loan; this.loan = loan;
this.installmentNumber = installmentNumber; this.installmentNumber = installmentNumber;
this.fromDate = fromDate.toDateMidnight().toDate(); this.fromDate = fromDate.toDateTimeAtStartOfDay().toDate();
this.dueDate = dueDate.toDateMidnight().toDate(); this.dueDate = dueDate.toDateTimeAtStartOfDay().toDate();
this.principal = defaultToNullIfZero(principal); this.principal = defaultToNullIfZero(principal);
this.interestCharged = defaultToNullIfZero(interest); this.interestCharged = defaultToNullIfZero(interest);
this.feeChargesCharged = defaultToNullIfZero(feeCharges); this.feeChargesCharged = defaultToNullIfZero(feeCharges);
@@ -133,21 +133,21 @@ public final class LoanTransaction extends AbstractPersistable<Long> {
} }
public static LoanTransaction initiateTransfer(final Office office, final Loan loan, final LocalDate transferDate) { public static LoanTransaction initiateTransfer(final Office office, final Loan loan, final LocalDate transferDate) {
return new LoanTransaction(loan, office, LoanTransactionType.INITIATE_TRANSFER.getValue(), transferDate.toDateMidnight().toDate(), return new LoanTransaction(loan, office, LoanTransactionType.INITIATE_TRANSFER.getValue(), transferDate.toDateTimeAtStartOfDay().toDate(),
loan.getSummary().getTotalOutstanding(), loan.getSummary().getTotalPrincipalOutstanding(), loan.getSummary() loan.getSummary().getTotalOutstanding(), loan.getSummary().getTotalPrincipalOutstanding(), loan.getSummary()
.getTotalInterestOutstanding(), loan.getSummary().getTotalFeeChargesOutstanding(), loan.getSummary() .getTotalInterestOutstanding(), loan.getSummary().getTotalFeeChargesOutstanding(), loan.getSummary()
.getTotalPenaltyChargesOutstanding(), null, false, null,null); .getTotalPenaltyChargesOutstanding(), null, false, null,null);
} }
public static LoanTransaction approveTransfer(final Office office, final Loan loan, final LocalDate transferDate) { public static LoanTransaction approveTransfer(final Office office, final Loan loan, final LocalDate transferDate) {
return new LoanTransaction(loan, office, LoanTransactionType.APPROVE_TRANSFER.getValue(), transferDate.toDateMidnight().toDate(), return new LoanTransaction(loan, office, LoanTransactionType.APPROVE_TRANSFER.getValue(), transferDate.toDateTimeAtStartOfDay().toDate(),
loan.getSummary().getTotalOutstanding(), loan.getSummary().getTotalPrincipalOutstanding(), loan.getSummary() loan.getSummary().getTotalOutstanding(), loan.getSummary().getTotalPrincipalOutstanding(), loan.getSummary()
.getTotalInterestOutstanding(), loan.getSummary().getTotalFeeChargesOutstanding(), loan.getSummary() .getTotalInterestOutstanding(), loan.getSummary().getTotalFeeChargesOutstanding(), loan.getSummary()
.getTotalPenaltyChargesOutstanding(), null, false, null,null); .getTotalPenaltyChargesOutstanding(), null, false, null,null);
} }
public static LoanTransaction withdrawTransfer(final Office office, final Loan loan, final LocalDate transferDate) { public static LoanTransaction withdrawTransfer(final Office office, final Loan loan, final LocalDate transferDate) {
return new LoanTransaction(loan, office, LoanTransactionType.WITHDRAW_TRANSFER.getValue(), transferDate.toDateMidnight().toDate(), return new LoanTransaction(loan, office, LoanTransactionType.WITHDRAW_TRANSFER.getValue(), transferDate.toDateTimeAtStartOfDay().toDate(),
loan.getSummary().getTotalOutstanding(), loan.getSummary().getTotalPrincipalOutstanding(), loan.getSummary() loan.getSummary().getTotalOutstanding(), loan.getSummary().getTotalPrincipalOutstanding(), loan.getSummary()
.getTotalInterestOutstanding(), loan.getSummary().getTotalFeeChargesOutstanding(), loan.getSummary() .getTotalInterestOutstanding(), loan.getSummary().getTotalFeeChargesOutstanding(), loan.getSummary()
.getTotalPenaltyChargesOutstanding(), null, false, null,null); .getTotalPenaltyChargesOutstanding(), null, false, null,null);
@@ -176,18 +176,18 @@ public final class LoanTransaction extends AbstractPersistable<Long> {
public static boolean transactionAmountsMatch(final MonetaryCurrency currency, final LoanTransaction loanTransaction, public static boolean transactionAmountsMatch(final MonetaryCurrency currency, final LoanTransaction loanTransaction,
final LoanTransaction newLoanTransaction) { final LoanTransaction newLoanTransaction) {
if (loanTransaction.getAmount(currency).isEqualTo(newLoanTransaction.getAmount(currency)) if (loanTransaction.getAmount(currency).isEqualTo(newLoanTransaction.getAmount(currency))
&& (loanTransaction.getPrincipalPortion(currency).isEqualTo(newLoanTransaction.getPrincipalPortion(currency))) && loanTransaction.getPrincipalPortion(currency).isEqualTo(newLoanTransaction.getPrincipalPortion(currency))
&& (loanTransaction.getInterestPortion(currency).isEqualTo(newLoanTransaction.getInterestPortion(currency))) && loanTransaction.getInterestPortion(currency).isEqualTo(newLoanTransaction.getInterestPortion(currency))
&& (loanTransaction.getFeeChargesPortion(currency).isEqualTo(newLoanTransaction.getFeeChargesPortion(currency))) && loanTransaction.getFeeChargesPortion(currency).isEqualTo(newLoanTransaction.getFeeChargesPortion(currency))
&& (loanTransaction.getPenaltyChargesPortion(currency).isEqualTo(newLoanTransaction.getPenaltyChargesPortion(currency))) && loanTransaction.getPenaltyChargesPortion(currency).isEqualTo(newLoanTransaction.getPenaltyChargesPortion(currency))
&& (loanTransaction.getOverPaymentPortion(currency).isEqualTo(newLoanTransaction.getOverPaymentPortion(currency)))) { return true; } && loanTransaction.getOverPaymentPortion(currency).isEqualTo(newLoanTransaction.getOverPaymentPortion(currency))) { return true; }
return false; return false;
} }
private LoanTransaction(final Loan loan, final Office office, final Integer typeOf, final Date dateOf, final BigDecimal amount, private LoanTransaction(final Loan loan, final Office office, final Integer typeOf, final Date dateOf, final BigDecimal amount,
final BigDecimal principalPortion, final BigDecimal interestPortion, final BigDecimal feeChargesPortion, final BigDecimal principalPortion, final BigDecimal interestPortion, final BigDecimal feeChargesPortion,
final BigDecimal penaltyChargesPortion, final BigDecimal overPaymentPortion, final boolean reversed, final BigDecimal penaltyChargesPortion, final BigDecimal overPaymentPortion, final boolean reversed,
final PaymentDetail paymentDetail,String externalId) { final PaymentDetail paymentDetail,final String externalId) {
super(); super();
this.loan = loan; this.loan = loan;
this.typeOf = typeOf; this.typeOf = typeOf;
@@ -222,7 +222,7 @@ public final class LoanTransaction extends AbstractPersistable<Long> {
this.loan = loan; this.loan = loan;
this.typeOf = type.getValue(); this.typeOf = type.getValue();
this.amount = amount; this.amount = amount;
this.dateOf = date.toDateMidnight().toDate(); this.dateOf = date.toDateTimeAtStartOfDay().toDate();
this.externalId = externalId; this.externalId = externalId;
this.office = office; this.office = office;
} }
@@ -233,7 +233,7 @@ public final class LoanTransaction extends AbstractPersistable<Long> {
this.typeOf = type.getValue(); this.typeOf = type.getValue();
this.paymentDetail = paymentDetail; this.paymentDetail = paymentDetail;
this.amount = amount; this.amount = amount;
this.dateOf = date.toDateMidnight().toDate(); this.dateOf = date.toDateTimeAtStartOfDay().toDate();
this.externalId = externalId; this.externalId = externalId;
this.office = office; this.office = office;
} }
@@ -504,7 +504,7 @@ public final class LoanTransaction extends AbstractPersistable<Long> {
} }
public void updateExternalId(String externalId) { public void updateExternalId(final String externalId) {
this.externalId = externalId; this.externalId = externalId;
} }
@@ -73,7 +73,7 @@ public class GuarantorCommand {
} }
public Date getDobAsDate() { public Date getDobAsDate() {
return this.dob.toDateMidnight().toDate(); return this.dob.toDateTimeAtStartOfDay().toDate();
} }
public void validateForCreate() { public void validateForCreate() {
@@ -5,10 +5,8 @@
*/ */
package org.mifosplatform.portfolio.loanaccount.service; package org.mifosplatform.portfolio.loanaccount.service;
import java.math.BigDecimal;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Set; import java.util.Set;
@@ -151,7 +149,7 @@ public class LoanApplicationWritePlatformServiceJpaRepositoryImpl implements Loa
this.calendarInstanceRepository = calendarInstanceRepository; this.calendarInstanceRepository = calendarInstanceRepository;
this.savingsAccountAssembler = savingsAccountAssembler; this.savingsAccountAssembler = savingsAccountAssembler;
this.accountAssociationsRepository = accountAssociationsRepository; this.accountAssociationsRepository = accountAssociationsRepository;
this.loanChargeRepository = loanChargeRepository; this.loanChargeRepository = loanChargeRepository;
} }
private LoanLifecycleStateMachine defaultLoanLifecycleStateMachine() { private LoanLifecycleStateMachine defaultLoanLifecycleStateMachine() {
@@ -363,8 +361,8 @@ public class LoanApplicationWritePlatformServiceJpaRepositoryImpl implements Loa
} }
for (final LoanCharge loanCharge : existingLoanApplication.charges()) { for (final LoanCharge loanCharge : existingLoanApplication.charges()) {
if(loanCharge.isInstalmentFee() && loanCharge.hasNoLoanInstallmentCharges()){ if (loanCharge.isInstalmentFee() && loanCharge.hasNoLoanInstallmentCharges()) {
Set<LoanInstallmentCharge> chargePerInstallments = existingLoanApplication.generateInstallmentLoanCharges(loanCharge); final Set<LoanInstallmentCharge> chargePerInstallments = existingLoanApplication.generateInstallmentLoanCharges(loanCharge);
loanCharge.addLoanInstallmentCharges(chargePerInstallments); loanCharge.addLoanInstallmentCharges(chargePerInstallments);
this.loanChargeRepository.save(loanCharge); this.loanChargeRepository.save(loanCharge);
} }
@@ -193,11 +193,11 @@ public class LoanProduct extends AbstractPersistable<Long> {
this.includeInBorrowerCycle = includeInBorrowerCycle; this.includeInBorrowerCycle = includeInBorrowerCycle;
if (startDate != null) { if (startDate != null) {
this.startDate = startDate.toDateMidnight().toDate(); this.startDate = startDate.toDateTimeAtStartOfDay().toDate();
} }
if (closeDate != null) { if (closeDate != null) {
this.closeDate = closeDate.toDateMidnight().toDate(); this.closeDate = closeDate.toDateTimeAtStartOfDay().toDate();
} }
this.externalId = externalId; this.externalId = externalId;
@@ -227,7 +227,7 @@ public class LoanProduct extends AbstractPersistable<Long> {
final Set<Charge> currentSetOfCharges = new HashSet<Charge>(this.charges); final Set<Charge> currentSetOfCharges = new HashSet<Charge>(this.charges);
final Set<Charge> newSetOfCharges = new HashSet<Charge>(newProductCharges); final Set<Charge> newSetOfCharges = new HashSet<Charge>(newProductCharges);
if (!(currentSetOfCharges.equals(newSetOfCharges))) { if (!currentSetOfCharges.equals(newSetOfCharges)) {
updated = true; updated = true;
this.charges = newProductCharges; this.charges = newProductCharges;
} }
@@ -401,7 +401,7 @@ public class LoanProduct extends AbstractPersistable<Long> {
// If all min and max fields are null then loanProductMinMaxConstraints // If all min and max fields are null then loanProductMinMaxConstraints
// initialising to null // initialising to null
// Reset LoanProductMinMaxConstraints with null values. // Reset LoanProductMinMaxConstraints with null values.
this.loanProductMinMaxConstraints = (this.loanProductMinMaxConstraints == null) ? new LoanProductMinMaxConstraints(null, null, this.loanProductMinMaxConstraints = this.loanProductMinMaxConstraints == null ? new LoanProductMinMaxConstraints(null, null,
null, null, null, null) : this.loanProductMinMaxConstraints; null, null, null, null) : this.loanProductMinMaxConstraints;
return this.loanProductMinMaxConstraints; return this.loanProductMinMaxConstraints;
} }