remove unused warnings, replace toDateMidnight with toDateTimeAtStartOfDay method as recommended by joda time lib.
This commit is contained in:
+9
-9
@@ -267,10 +267,10 @@ public class JournalEntryWritePlatformServiceJpaRepositoryImpl implements Journa
|
||||
.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 boolean manualEntry = true;
|
||||
|
||||
|
||||
for (final JournalEntry journalEntry : journalEntries) {
|
||||
JournalEntry reversalJournalEntry;
|
||||
final String reversalComment = "Reversal entry for Journal Entry with Entry Id :" + journalEntry.getId()
|
||||
@@ -330,7 +330,7 @@ public class JournalEntryWritePlatformServiceJpaRepositoryImpl implements Journa
|
||||
private void validateBusinessRulesForJournalEntries(final JournalEntryCommand command) {
|
||||
/** check if date of Journal entry is valid ***/
|
||||
final LocalDate entryLocalDate = command.getTransactionDate();
|
||||
final Date transactionDate = entryLocalDate.toDateMidnight().toDate();
|
||||
final Date transactionDate = entryLocalDate.toDateTimeAtStartOfDay().toDate();
|
||||
// shouldn't be in the future
|
||||
final Date todaysDate = new 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();
|
||||
|
||||
// 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); }
|
||||
|
||||
checkDebitAndCreditAmounts(credits, debits);
|
||||
@@ -381,11 +381,11 @@ public class JournalEntryWritePlatformServiceJpaRepositoryImpl implements Journa
|
||||
* TODO: Need a better implementation with guaranteed uniqueness (but not a
|
||||
* long UUID)...maybe something tied to system clock..
|
||||
*/
|
||||
private String generateTransactionId(Long officeId) {
|
||||
AppUser user = this.context.authenticatedUser();
|
||||
Long time = System.currentTimeMillis();
|
||||
String uniqueVal = String.valueOf(time) + user.getId() + officeId;
|
||||
String transactionId = Long.toHexString(Long.parseLong(uniqueVal));
|
||||
private String generateTransactionId(final Long officeId) {
|
||||
final AppUser user = this.context.authenticatedUser();
|
||||
final Long time = System.currentTimeMillis();
|
||||
final String uniqueVal = String.valueOf(time) + user.getId() + officeId;
|
||||
final String transactionId = Long.toHexString(Long.parseLong(uniqueVal));
|
||||
return transactionId;
|
||||
}
|
||||
|
||||
|
||||
+2
-2
@@ -28,7 +28,7 @@ import com.google.gson.reflect.TypeToken;
|
||||
|
||||
/**
|
||||
* Immutable representation of a command.
|
||||
*
|
||||
*
|
||||
* Wraps the provided JSON with convenience functions for extracting parameter
|
||||
* values and checking for changes against an existing value.
|
||||
*/
|
||||
@@ -295,7 +295,7 @@ public final class JsonCommand {
|
||||
public Date DateValueOfParameterNamed(final String parameterName) {
|
||||
final LocalDate localDate = this.fromApiJsonHelper.extractLocalDateNamed(parameterName, this.parsedCommand);
|
||||
if (localDate == null) { return null; }
|
||||
return localDate.toDateMidnight().toDate();
|
||||
return localDate.toDateTimeAtStartOfDay().toDate();
|
||||
}
|
||||
|
||||
public boolean isChangeInStringParameterNamed(final String parameterName, final String existingValue) {
|
||||
|
||||
+2
-2
@@ -23,7 +23,7 @@ import org.mifosplatform.infrastructure.core.exception.PlatformApiDataValidation
|
||||
public class DateUtils {
|
||||
|
||||
public static Date getDateOfTenant() {
|
||||
return getLocalDateOfTenant().toDateMidnight().toDate();
|
||||
return getLocalDateOfTenant().toDateTimeAtStartOfDay().toDate();
|
||||
}
|
||||
|
||||
public static LocalDate getLocalDateOfTenant() {
|
||||
@@ -63,7 +63,7 @@ public class DateUtils {
|
||||
final String formattedSqlDate = df.format(date);
|
||||
return formattedSqlDate;
|
||||
}
|
||||
|
||||
|
||||
public static boolean isDateInTheFuture(final LocalDate localDate){
|
||||
return localDate.isAfter(getLocalDateOfTenant());
|
||||
}
|
||||
|
||||
+1
-1
@@ -76,7 +76,7 @@ public class Office extends AbstractPersistable<Long> {
|
||||
|
||||
private Office(final Office parent, final String name, final LocalDate openingDate, final String externalId) {
|
||||
this.parent = parent;
|
||||
this.openingDate = openingDate.toDateMidnight().toDate();
|
||||
this.openingDate = openingDate.toDateTimeAtStartOfDay().toDate();
|
||||
if (parent != null) {
|
||||
this.parent.addChild(this);
|
||||
}
|
||||
|
||||
+2
-2
@@ -80,13 +80,13 @@ public class Calendar extends AbstractAuditableCustom<AppUser, Long> {
|
||||
this.location = StringUtils.defaultIfEmpty(location, null);
|
||||
|
||||
if (null != startDate) {
|
||||
this.startDate = startDate.toDateMidnight().toDate();
|
||||
this.startDate = startDate.toDateTimeAtStartOfDay().toDate();
|
||||
} else {
|
||||
this.startDate = null;
|
||||
}
|
||||
|
||||
if (null != endDate) {
|
||||
this.endDate = endDate.toDateMidnight().toDate();
|
||||
this.endDate = endDate.toDateTimeAtStartOfDay().toDate();
|
||||
} else {
|
||||
this.endDate = null;
|
||||
}
|
||||
|
||||
+2
-2
@@ -178,10 +178,10 @@ public final class Client extends AbstractPersistable<Long> {
|
||||
}
|
||||
|
||||
if (activationDate != null) {
|
||||
this.activationDate = activationDate.toDateMidnight().toDate();
|
||||
this.activationDate = activationDate.toDateTimeAtStartOfDay().toDate();
|
||||
}
|
||||
if (officeJoiningDate != null) {
|
||||
this.officeJoiningDate = officeJoiningDate.toDateMidnight().toDate();
|
||||
this.officeJoiningDate = officeJoiningDate.toDateTimeAtStartOfDay().toDate();
|
||||
}
|
||||
if (StringUtils.isNotBlank(firstname)) {
|
||||
this.firstname = firstname.trim();
|
||||
|
||||
+4
-5
@@ -10,7 +10,6 @@ public class LoanInstallmentChargeData {
|
||||
private final LocalDate dueDate;
|
||||
@SuppressWarnings("unused")
|
||||
private final BigDecimal amount;
|
||||
@SuppressWarnings("unused")
|
||||
private final BigDecimal amountOutstanding;
|
||||
private final boolean paid;
|
||||
private final boolean waived;
|
||||
@@ -32,15 +31,15 @@ public class LoanInstallmentChargeData {
|
||||
public LocalDate getDueDate() {
|
||||
return this.dueDate;
|
||||
}
|
||||
|
||||
|
||||
public boolean isPaymentPending(){
|
||||
return !(paid || waived);
|
||||
return !(this.paid || this.waived);
|
||||
}
|
||||
|
||||
|
||||
|
||||
public BigDecimal getAmountOutstanding() {
|
||||
return this.amountOutstanding;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
+41
-42
@@ -72,7 +72,6 @@ public class LoanCharge extends AbstractPersistable<Long> {
|
||||
@Column(name = "calculation_on_amount", scale = 6, precision = 19, nullable = true)
|
||||
private BigDecimal amountPercentageAppliedTo;
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
@Column(name = "charge_amount_or_percentage", scale = 6, precision = 19, nullable = false)
|
||||
private BigDecimal amountOrPercentage;
|
||||
|
||||
@@ -105,10 +104,10 @@ public class LoanCharge extends AbstractPersistable<Long> {
|
||||
|
||||
@Column(name = "max_cap", scale = 6, precision = 19, nullable = true)
|
||||
private BigDecimal maxCap;
|
||||
|
||||
|
||||
@LazyCollection(LazyCollectionOption.FALSE)
|
||||
@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) {
|
||||
|
||||
@@ -248,18 +247,18 @@ public class LoanCharge extends AbstractPersistable<Long> {
|
||||
break;
|
||||
}
|
||||
this.amountOrPercentage = chargeAmount;
|
||||
if(this.loan!=null && this.isInstalmentFee()){
|
||||
Set<LoanInstallmentCharge> chargePerInstallments = this.loan.generateInstallmentLoanCharges(this);
|
||||
if(this.loan!=null && isInstalmentFee()){
|
||||
final Set<LoanInstallmentCharge> chargePerInstallments = this.loan.generateInstallmentLoanCharges(this);
|
||||
if(this.loanInstallmentCharge.isEmpty()){
|
||||
this.loanInstallmentCharge.addAll(chargePerInstallments);
|
||||
}else{
|
||||
int index = 0;
|
||||
LoanInstallmentCharge[] loanChargePerInstallments = new LoanInstallmentCharge[chargePerInstallments.size()];
|
||||
LoanInstallmentCharge[] loanChargePerInstallmentArray = chargePerInstallments.toArray(loanChargePerInstallments);
|
||||
for(LoanInstallmentCharge chargePerInstallment:this.loanInstallmentCharge){
|
||||
final LoanInstallmentCharge[] loanChargePerInstallments = new LoanInstallmentCharge[chargePerInstallments.size()];
|
||||
final LoanInstallmentCharge[] loanChargePerInstallmentArray = chargePerInstallments.toArray(loanChargePerInstallments);
|
||||
for(final LoanInstallmentCharge chargePerInstallment:this.loanInstallmentCharge){
|
||||
chargePerInstallment.copyFrom(loanChargePerInstallmentArray[index++]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -276,7 +275,7 @@ public class LoanCharge extends AbstractPersistable<Long> {
|
||||
this.amountOutstanding = calculateAmountOutstanding(currency);
|
||||
this.paid = false;
|
||||
this.waived = false;
|
||||
for(LoanInstallmentCharge installmentCharge:loanInstallmentCharge){
|
||||
for(final LoanInstallmentCharge installmentCharge:this.loanInstallmentCharge){
|
||||
installmentCharge.resetPaidAmount(currency);
|
||||
}
|
||||
}
|
||||
@@ -285,15 +284,15 @@ public class LoanCharge extends AbstractPersistable<Long> {
|
||||
this.amountPaid = BigDecimal.ZERO;
|
||||
this.amountOutstanding = calculateAmountOutstanding(currency);
|
||||
this.paid = false;
|
||||
for(LoanInstallmentCharge installmentCharge:loanInstallmentCharge){
|
||||
for(final LoanInstallmentCharge installmentCharge:this.loanInstallmentCharge){
|
||||
installmentCharge.resetPaidAmount(currency);
|
||||
}
|
||||
}
|
||||
|
||||
public Money waive(final MonetaryCurrency currency, Integer loanInstallmentNumber) {
|
||||
public Money waive(final MonetaryCurrency currency, final Integer loanInstallmentNumber) {
|
||||
if(isInstalmentFee()){
|
||||
LoanInstallmentCharge chargePerInstallment = getInstallmentLoanCharge(loanInstallmentNumber);
|
||||
Money amountWaived = chargePerInstallment.waive(currency);
|
||||
final LoanInstallmentCharge chargePerInstallment = getInstallmentLoanCharge(loanInstallmentNumber);
|
||||
final Money amountWaived = chargePerInstallment.waive(currency);
|
||||
if(this.amountWaived == null){
|
||||
this.amountWaived = BigDecimal.ZERO;
|
||||
}
|
||||
@@ -310,7 +309,7 @@ public class LoanCharge extends AbstractPersistable<Long> {
|
||||
this.paid = false;
|
||||
this.waived = true;
|
||||
return getAmountWaived(currency);
|
||||
|
||||
|
||||
}
|
||||
|
||||
private BigDecimal calculateAmountOutstanding(final MonetaryCurrency currency) {
|
||||
@@ -353,15 +352,15 @@ public class LoanCharge extends AbstractPersistable<Long> {
|
||||
break;
|
||||
}
|
||||
this.amountOrPercentage = amount;
|
||||
if(this.loan !=null && this.isInstalmentFee()){
|
||||
Set<LoanInstallmentCharge> chargePerInstallments = this.loan.generateInstallmentLoanCharges(this);
|
||||
if(this.loan !=null && isInstalmentFee()){
|
||||
final Set<LoanInstallmentCharge> chargePerInstallments = this.loan.generateInstallmentLoanCharges(this);
|
||||
if(this.loanInstallmentCharge.isEmpty()){
|
||||
this.loanInstallmentCharge.addAll(chargePerInstallments);
|
||||
}else{
|
||||
int index = 0;
|
||||
LoanInstallmentCharge[] loanChargePerInstallments = new LoanInstallmentCharge[chargePerInstallments.size()];
|
||||
LoanInstallmentCharge[] loanChargePerInstallmentArray = chargePerInstallments.toArray(loanChargePerInstallments);
|
||||
for(LoanInstallmentCharge chargePerInstallment:this.loanInstallmentCharge){
|
||||
final LoanInstallmentCharge[] loanChargePerInstallments = new LoanInstallmentCharge[chargePerInstallments.size()];
|
||||
final LoanInstallmentCharge[] loanChargePerInstallmentArray = chargePerInstallments.toArray(loanChargePerInstallments);
|
||||
for(final LoanInstallmentCharge chargePerInstallment:this.loanInstallmentCharge){
|
||||
chargePerInstallment.copyFrom(loanChargePerInstallmentArray[index++]);
|
||||
}
|
||||
}
|
||||
@@ -416,15 +415,15 @@ public class LoanCharge extends AbstractPersistable<Long> {
|
||||
break;
|
||||
}
|
||||
this.amountOrPercentage = newValue;
|
||||
if(this.isInstalmentFee()){
|
||||
Set<LoanInstallmentCharge> chargePerInstallments = this.loan.generateInstallmentLoanCharges(this);
|
||||
if(isInstalmentFee()){
|
||||
final Set<LoanInstallmentCharge> chargePerInstallments = this.loan.generateInstallmentLoanCharges(this);
|
||||
if(this.loanInstallmentCharge.isEmpty()){
|
||||
this.loanInstallmentCharge.addAll(chargePerInstallments);
|
||||
}else{
|
||||
int index = 0;
|
||||
LoanInstallmentCharge[] loanChargePerInstallments = new LoanInstallmentCharge[chargePerInstallments.size()];
|
||||
LoanInstallmentCharge[] loanChargePerInstallmentArray = chargePerInstallments.toArray(loanChargePerInstallments);
|
||||
for(LoanInstallmentCharge chargePerInstallment:this.loanInstallmentCharge){
|
||||
final LoanInstallmentCharge[] loanChargePerInstallments = new LoanInstallmentCharge[chargePerInstallments.size()];
|
||||
final LoanInstallmentCharge[] loanChargePerInstallmentArray = chargePerInstallments.toArray(loanChargePerInstallments);
|
||||
for(final LoanInstallmentCharge chargePerInstallment:this.loanInstallmentCharge){
|
||||
chargePerInstallment.copyFrom(loanChargePerInstallmentArray[index++]);
|
||||
}
|
||||
}
|
||||
@@ -615,9 +614,9 @@ public class LoanCharge extends AbstractPersistable<Long> {
|
||||
* Amount used to pay off 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());
|
||||
if(this.isInstalmentFee()){
|
||||
if(isInstalmentFee()){
|
||||
if(installmentNumber == null){
|
||||
processAmount = getUnpaidInstallmentLoanCharge().updatePaidAmountBy(incrementBy, feeAmount);
|
||||
}else{
|
||||
@@ -701,7 +700,7 @@ public class LoanCharge extends AbstractPersistable<Long> {
|
||||
|
||||
public LoanInstallmentCharge getUnpaidInstallmentLoanCharge() {
|
||||
LoanInstallmentCharge unpaidChargePerInstallment = null;
|
||||
for (LoanInstallmentCharge loanChargePerInstallment : this.loanInstallmentCharge) {
|
||||
for (final LoanInstallmentCharge loanChargePerInstallment : this.loanInstallmentCharge) {
|
||||
if (loanChargePerInstallment.isPending()
|
||||
&& (unpaidChargePerInstallment == null || unpaidChargePerInstallment.getRepaymentInstallment().getDueDate()
|
||||
.isAfter(loanChargePerInstallment.getRepaymentInstallment().getDueDate()))) {
|
||||
@@ -710,40 +709,40 @@ public class LoanCharge extends AbstractPersistable<Long> {
|
||||
}
|
||||
return unpaidChargePerInstallment;
|
||||
}
|
||||
|
||||
public LoanInstallmentCharge getInstallmentLoanCharge(LocalDate periodDueDate) {
|
||||
for (LoanInstallmentCharge loanChargePerInstallment : this.loanInstallmentCharge) {
|
||||
|
||||
public LoanInstallmentCharge getInstallmentLoanCharge(final LocalDate periodDueDate) {
|
||||
for (final LoanInstallmentCharge loanChargePerInstallment : this.loanInstallmentCharge) {
|
||||
if (periodDueDate.isEqual(loanChargePerInstallment.getRepaymentInstallment().getDueDate())) {
|
||||
return loanChargePerInstallment;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public LoanInstallmentCharge getInstallmentLoanCharge(Integer installmentNumber) {
|
||||
for (LoanInstallmentCharge loanChargePerInstallment : this.loanInstallmentCharge) {
|
||||
|
||||
public LoanInstallmentCharge getInstallmentLoanCharge(final Integer installmentNumber) {
|
||||
for (final LoanInstallmentCharge loanChargePerInstallment : this.loanInstallmentCharge) {
|
||||
if (installmentNumber.equals(loanChargePerInstallment.getRepaymentInstallment().getInstallmentNumber().intValue()) ){
|
||||
return loanChargePerInstallment;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
public void clearLoanInstallmentCharges(){
|
||||
this.loanInstallmentCharge.clear();
|
||||
}
|
||||
|
||||
public void addLoanInstallmentCharges(Collection<LoanInstallmentCharge> installmentCharges){
|
||||
|
||||
public void addLoanInstallmentCharges(final Collection<LoanInstallmentCharge> installmentCharges){
|
||||
this.loanInstallmentCharge.addAll(installmentCharges);
|
||||
}
|
||||
|
||||
|
||||
public boolean hasNoLoanInstallmentCharges(){
|
||||
return this.loanInstallmentCharge.isEmpty();
|
||||
}
|
||||
|
||||
public LoanRepaymentScheduleInstallment fetchRepaymentInstallment(Money trasferedAmount){
|
||||
for (LoanInstallmentCharge loanChargePerInstallment : this.loanInstallmentCharge) {
|
||||
if (loanChargePerInstallment.isPending() &&
|
||||
|
||||
public LoanRepaymentScheduleInstallment fetchRepaymentInstallment(final Money trasferedAmount){
|
||||
for (final LoanInstallmentCharge loanChargePerInstallment : this.loanInstallmentCharge) {
|
||||
if (loanChargePerInstallment.isPending() &&
|
||||
trasferedAmount.getAmount().equals(loanChargePerInstallment.getAmountThroughChargePayment(trasferedAmount.getCurrency()).getAmount()) ){
|
||||
return loanChargePerInstallment.getRepaymentInstallment();
|
||||
}
|
||||
|
||||
+25
-26
@@ -21,11 +21,10 @@ import org.springframework.data.jpa.domain.AbstractPersistable;
|
||||
@Table(name = "m_loan_installment_charge")
|
||||
public class LoanInstallmentCharge extends AbstractPersistable<Long> {
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
@ManyToOne(optional = false)
|
||||
@JoinColumn(name = "loan_charge_id", referencedColumnName = "id", nullable = false)
|
||||
private LoanCharge loancharge;
|
||||
|
||||
|
||||
@ManyToOne(optional = false)
|
||||
@JoinColumn(name = "loan_schedule_id", referencedColumnName = "id", nullable = false)
|
||||
private LoanRepaymentScheduleInstallment installment;
|
||||
@@ -44,7 +43,7 @@ public class LoanInstallmentCharge extends AbstractPersistable<Long> {
|
||||
|
||||
@Column(name = "amount_outstanding_derived", scale = 6, precision = 19, nullable = false)
|
||||
private BigDecimal amountOutstanding;
|
||||
|
||||
|
||||
@Column(name = "amount_through_charge_payment", scale = 6, precision = 19, nullable = true)
|
||||
private BigDecimal amountThroughChargePayment;
|
||||
|
||||
@@ -53,13 +52,13 @@ public class LoanInstallmentCharge extends AbstractPersistable<Long> {
|
||||
|
||||
@Column(name = "waived", nullable = false)
|
||||
private boolean waived = false;
|
||||
|
||||
|
||||
|
||||
|
||||
public LoanInstallmentCharge() {
|
||||
// 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.installment = installment;
|
||||
this.amount = amount;
|
||||
@@ -68,15 +67,15 @@ public class LoanInstallmentCharge extends AbstractPersistable<Long> {
|
||||
this.amountWaived = null;
|
||||
this.amountWrittenOff = null;
|
||||
}
|
||||
|
||||
public void copyFrom(LoanInstallmentCharge loanChargePerInstallment){
|
||||
|
||||
public void copyFrom(final LoanInstallmentCharge loanChargePerInstallment){
|
||||
this.amount = loanChargePerInstallment.amount;
|
||||
this.installment = loanChargePerInstallment.installment;
|
||||
this.amountOutstanding = calculateOutstanding();
|
||||
this.paid = determineIfFullyPaid();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
public Money waive(final MonetaryCurrency currency) {
|
||||
this.amountWaived = this.amountOutstanding;
|
||||
this.amountOutstanding = BigDecimal.ZERO;
|
||||
@@ -89,14 +88,14 @@ public class LoanInstallmentCharge extends AbstractPersistable<Long> {
|
||||
public Money getAmountWaived(final MonetaryCurrency currency) {
|
||||
return Money.of(currency, this.amountWaived);
|
||||
}
|
||||
|
||||
|
||||
private boolean determineIfFullyPaid() {
|
||||
if(this.amount == null){
|
||||
return true;
|
||||
}
|
||||
return BigDecimal.ZERO.compareTo(calculateOutstanding()) == 0;
|
||||
}
|
||||
|
||||
|
||||
private BigDecimal calculateOutstanding() {
|
||||
if(this.amount == null){
|
||||
return null;
|
||||
@@ -121,11 +120,11 @@ public class LoanInstallmentCharge extends AbstractPersistable<Long> {
|
||||
return this.amount.subtract(totalAccountedFor);
|
||||
}
|
||||
|
||||
|
||||
|
||||
public BigDecimal getAmount() {
|
||||
return this.amount;
|
||||
}
|
||||
|
||||
|
||||
public Money getAmount(final MonetaryCurrency currency) {
|
||||
return Money.of(currency, this.amount);
|
||||
}
|
||||
@@ -137,12 +136,12 @@ public class LoanInstallmentCharge extends AbstractPersistable<Long> {
|
||||
public BigDecimal getAmountOutstanding() {
|
||||
return this.amountOutstanding;
|
||||
}
|
||||
|
||||
|
||||
private BigDecimal calculateAmountOutstanding(final MonetaryCurrency currency) {
|
||||
return getAmount(currency).minus(getAmountWaived(currency)).minus(getAmountPaid(currency)).getAmount();
|
||||
}
|
||||
|
||||
|
||||
|
||||
public boolean isPaid() {
|
||||
return this.paid;
|
||||
}
|
||||
@@ -152,16 +151,16 @@ public class LoanInstallmentCharge extends AbstractPersistable<Long> {
|
||||
}
|
||||
|
||||
public boolean isPending(){
|
||||
return !(isPaid() || isWaived());
|
||||
return !(isPaid() || isWaived());
|
||||
}
|
||||
|
||||
|
||||
|
||||
public LoanRepaymentScheduleInstallment getRepaymentInstallment() {
|
||||
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);
|
||||
final Money amountOutstanding = Money.of(incrementBy.getCurrency(), this.amountOutstanding);
|
||||
|
||||
@@ -183,17 +182,17 @@ public class LoanInstallmentCharge extends AbstractPersistable<Long> {
|
||||
return amountPaidOnThisCharge;
|
||||
}
|
||||
|
||||
|
||||
|
||||
public Money getAmountWrittenOff(final MonetaryCurrency currency) {
|
||||
return Money.of(currency, this.amountWrittenOff);
|
||||
}
|
||||
|
||||
|
||||
public void resetPaidAmount(final MonetaryCurrency currency) {
|
||||
this.amountPaid = BigDecimal.ZERO;
|
||||
this.amountOutstanding = calculateAmountOutstanding(currency);
|
||||
this.paid = false;
|
||||
}
|
||||
|
||||
|
||||
public void resetToOriginal(final MonetaryCurrency currency) {
|
||||
this.amountPaid = BigDecimal.ZERO;
|
||||
this.amountWaived = BigDecimal.ZERO;
|
||||
@@ -203,7 +202,7 @@ public class LoanInstallmentCharge extends AbstractPersistable<Long> {
|
||||
this.waived = false;
|
||||
}
|
||||
|
||||
|
||||
|
||||
public Money getAmountThroughChargePayment(final MonetaryCurrency currency) {
|
||||
return Money.of(currency, this.amountThroughChargePayment);
|
||||
}
|
||||
|
||||
+3
-10
@@ -7,22 +7,15 @@ package org.mifosplatform.portfolio.loanaccount.domain;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.Date;
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
||||
import javax.persistence.CascadeType;
|
||||
import javax.persistence.Column;
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.FetchType;
|
||||
import javax.persistence.JoinColumn;
|
||||
import javax.persistence.ManyToOne;
|
||||
import javax.persistence.OneToMany;
|
||||
import javax.persistence.Table;
|
||||
import javax.persistence.Temporal;
|
||||
import javax.persistence.TemporalType;
|
||||
|
||||
import org.hibernate.annotations.LazyCollection;
|
||||
import org.hibernate.annotations.LazyCollectionOption;
|
||||
import org.joda.time.LocalDate;
|
||||
import org.mifosplatform.infrastructure.core.domain.AbstractAuditableCustom;
|
||||
import org.mifosplatform.organisation.monetary.domain.MonetaryCurrency;
|
||||
@@ -105,7 +98,7 @@ public final class LoanRepaymentScheduleInstallment extends AbstractAuditableCus
|
||||
@Temporal(TemporalType.DATE)
|
||||
@Column(name = "obligations_met_on_date")
|
||||
private Date obligationsMetOnDate;
|
||||
|
||||
|
||||
protected LoanRepaymentScheduleInstallment() {
|
||||
this.installmentNumber = null;
|
||||
this.fromDate = null;
|
||||
@@ -118,8 +111,8 @@ public final class LoanRepaymentScheduleInstallment extends AbstractAuditableCus
|
||||
final BigDecimal penaltyCharges) {
|
||||
this.loan = loan;
|
||||
this.installmentNumber = installmentNumber;
|
||||
this.fromDate = fromDate.toDateMidnight().toDate();
|
||||
this.dueDate = dueDate.toDateMidnight().toDate();
|
||||
this.fromDate = fromDate.toDateTimeAtStartOfDay().toDate();
|
||||
this.dueDate = dueDate.toDateTimeAtStartOfDay().toDate();
|
||||
this.principal = defaultToNullIfZero(principal);
|
||||
this.interestCharged = defaultToNullIfZero(interest);
|
||||
this.feeChargesCharged = defaultToNullIfZero(feeCharges);
|
||||
|
||||
+14
-14
@@ -133,21 +133,21 @@ public final class LoanTransaction extends AbstractPersistable<Long> {
|
||||
}
|
||||
|
||||
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()
|
||||
.getTotalInterestOutstanding(), loan.getSummary().getTotalFeeChargesOutstanding(), loan.getSummary()
|
||||
.getTotalPenaltyChargesOutstanding(), null, false, null,null);
|
||||
}
|
||||
|
||||
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()
|
||||
.getTotalInterestOutstanding(), loan.getSummary().getTotalFeeChargesOutstanding(), loan.getSummary()
|
||||
.getTotalPenaltyChargesOutstanding(), null, false, null,null);
|
||||
}
|
||||
|
||||
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()
|
||||
.getTotalInterestOutstanding(), loan.getSummary().getTotalFeeChargesOutstanding(), loan.getSummary()
|
||||
.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,
|
||||
final LoanTransaction newLoanTransaction) {
|
||||
if (loanTransaction.getAmount(currency).isEqualTo(newLoanTransaction.getAmount(currency))
|
||||
&& (loanTransaction.getPrincipalPortion(currency).isEqualTo(newLoanTransaction.getPrincipalPortion(currency)))
|
||||
&& (loanTransaction.getInterestPortion(currency).isEqualTo(newLoanTransaction.getInterestPortion(currency)))
|
||||
&& (loanTransaction.getFeeChargesPortion(currency).isEqualTo(newLoanTransaction.getFeeChargesPortion(currency)))
|
||||
&& (loanTransaction.getPenaltyChargesPortion(currency).isEqualTo(newLoanTransaction.getPenaltyChargesPortion(currency)))
|
||||
&& (loanTransaction.getOverPaymentPortion(currency).isEqualTo(newLoanTransaction.getOverPaymentPortion(currency)))) { return true; }
|
||||
&& loanTransaction.getPrincipalPortion(currency).isEqualTo(newLoanTransaction.getPrincipalPortion(currency))
|
||||
&& loanTransaction.getInterestPortion(currency).isEqualTo(newLoanTransaction.getInterestPortion(currency))
|
||||
&& loanTransaction.getFeeChargesPortion(currency).isEqualTo(newLoanTransaction.getFeeChargesPortion(currency))
|
||||
&& loanTransaction.getPenaltyChargesPortion(currency).isEqualTo(newLoanTransaction.getPenaltyChargesPortion(currency))
|
||||
&& loanTransaction.getOverPaymentPortion(currency).isEqualTo(newLoanTransaction.getOverPaymentPortion(currency))) { return true; }
|
||||
return false;
|
||||
}
|
||||
|
||||
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 penaltyChargesPortion, final BigDecimal overPaymentPortion, final boolean reversed,
|
||||
final PaymentDetail paymentDetail,String externalId) {
|
||||
final PaymentDetail paymentDetail,final String externalId) {
|
||||
super();
|
||||
this.loan = loan;
|
||||
this.typeOf = typeOf;
|
||||
@@ -222,7 +222,7 @@ public final class LoanTransaction extends AbstractPersistable<Long> {
|
||||
this.loan = loan;
|
||||
this.typeOf = type.getValue();
|
||||
this.amount = amount;
|
||||
this.dateOf = date.toDateMidnight().toDate();
|
||||
this.dateOf = date.toDateTimeAtStartOfDay().toDate();
|
||||
this.externalId = externalId;
|
||||
this.office = office;
|
||||
}
|
||||
@@ -233,7 +233,7 @@ public final class LoanTransaction extends AbstractPersistable<Long> {
|
||||
this.typeOf = type.getValue();
|
||||
this.paymentDetail = paymentDetail;
|
||||
this.amount = amount;
|
||||
this.dateOf = date.toDateMidnight().toDate();
|
||||
this.dateOf = date.toDateTimeAtStartOfDay().toDate();
|
||||
this.externalId = externalId;
|
||||
this.office = office;
|
||||
}
|
||||
@@ -256,7 +256,7 @@ public final class LoanTransaction extends AbstractPersistable<Long> {
|
||||
/**
|
||||
* This updates the derived fields of a loan transaction for the principal,
|
||||
* interest and interest waived portions.
|
||||
*
|
||||
*
|
||||
* This accumulates the values passed to the already existent values for
|
||||
* each of the portions.
|
||||
*/
|
||||
@@ -503,8 +503,8 @@ public final class LoanTransaction extends AbstractPersistable<Long> {
|
||||
return LoanTransactionType.REFUND.equals(getTypeOf()) && isNotReversed();
|
||||
}
|
||||
|
||||
|
||||
public void updateExternalId(String externalId) {
|
||||
|
||||
public void updateExternalId(final String externalId) {
|
||||
this.externalId = externalId;
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -73,7 +73,7 @@ public class GuarantorCommand {
|
||||
}
|
||||
|
||||
public Date getDobAsDate() {
|
||||
return this.dob.toDateMidnight().toDate();
|
||||
return this.dob.toDateTimeAtStartOfDay().toDate();
|
||||
}
|
||||
|
||||
public void validateForCreate() {
|
||||
|
||||
+6
-8
@@ -5,10 +5,8 @@
|
||||
*/
|
||||
package org.mifosplatform.portfolio.loanaccount.service;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
@@ -151,7 +149,7 @@ public class LoanApplicationWritePlatformServiceJpaRepositoryImpl implements Loa
|
||||
this.calendarInstanceRepository = calendarInstanceRepository;
|
||||
this.savingsAccountAssembler = savingsAccountAssembler;
|
||||
this.accountAssociationsRepository = accountAssociationsRepository;
|
||||
this.loanChargeRepository = loanChargeRepository;
|
||||
this.loanChargeRepository = loanChargeRepository;
|
||||
}
|
||||
|
||||
private LoanLifecycleStateMachine defaultLoanLifecycleStateMachine() {
|
||||
@@ -340,14 +338,14 @@ public class LoanApplicationWritePlatformServiceJpaRepositoryImpl implements Loa
|
||||
|
||||
if (changes.containsKey("recalculateLoanSchedule")) {
|
||||
changes.remove("recalculateLoanSchedule");
|
||||
|
||||
|
||||
final JsonElement parsedQuery = this.fromJsonHelper.parse(command.json());
|
||||
final JsonQuery query = JsonQuery.from(command.json(), parsedQuery, this.fromJsonHelper);
|
||||
|
||||
final LoanScheduleModel loanSchedule = this.calculationPlatformService.calculateLoanSchedule(query);
|
||||
existingLoanApplication.updateLoanSchedule(loanSchedule);
|
||||
}
|
||||
|
||||
|
||||
final String chargesParamName = "charges";
|
||||
if (changes.containsKey(chargesParamName)) {
|
||||
final Set<LoanCharge> loanCharges = this.loanChargeAssembler.fromParsedJson(command.parsedJson());
|
||||
@@ -361,10 +359,10 @@ public class LoanApplicationWritePlatformServiceJpaRepositoryImpl implements Loa
|
||||
final Note note = Note.loanNote(existingLoanApplication, submittedOnNote);
|
||||
this.noteRepository.save(note);
|
||||
}
|
||||
|
||||
|
||||
for (final LoanCharge loanCharge : existingLoanApplication.charges()) {
|
||||
if(loanCharge.isInstalmentFee() && loanCharge.hasNoLoanInstallmentCharges()){
|
||||
Set<LoanInstallmentCharge> chargePerInstallments = existingLoanApplication.generateInstallmentLoanCharges(loanCharge);
|
||||
if (loanCharge.isInstalmentFee() && loanCharge.hasNoLoanInstallmentCharges()) {
|
||||
final Set<LoanInstallmentCharge> chargePerInstallments = existingLoanApplication.generateInstallmentLoanCharges(loanCharge);
|
||||
loanCharge.addLoanInstallmentCharges(chargePerInstallments);
|
||||
this.loanChargeRepository.save(loanCharge);
|
||||
}
|
||||
|
||||
+6
-6
@@ -40,10 +40,10 @@ import com.google.gson.JsonArray;
|
||||
/**
|
||||
* Loan products allow for categorisation of an organisations loans into
|
||||
* something meaningful to them.
|
||||
*
|
||||
*
|
||||
* They provide a means of simplifying creation/maintenance of loans. They can
|
||||
* also allow for product comparison to take place when reporting.
|
||||
*
|
||||
*
|
||||
* They allow for constraints to be added at product level.
|
||||
*/
|
||||
@Entity
|
||||
@@ -193,11 +193,11 @@ public class LoanProduct extends AbstractPersistable<Long> {
|
||||
this.includeInBorrowerCycle = includeInBorrowerCycle;
|
||||
|
||||
if (startDate != null) {
|
||||
this.startDate = startDate.toDateMidnight().toDate();
|
||||
this.startDate = startDate.toDateTimeAtStartOfDay().toDate();
|
||||
}
|
||||
|
||||
if (closeDate != null) {
|
||||
this.closeDate = closeDate.toDateMidnight().toDate();
|
||||
this.closeDate = closeDate.toDateTimeAtStartOfDay().toDate();
|
||||
}
|
||||
|
||||
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> newSetOfCharges = new HashSet<Charge>(newProductCharges);
|
||||
|
||||
if (!(currentSetOfCharges.equals(newSetOfCharges))) {
|
||||
if (!currentSetOfCharges.equals(newSetOfCharges)) {
|
||||
updated = true;
|
||||
this.charges = newProductCharges;
|
||||
}
|
||||
@@ -401,7 +401,7 @@ public class LoanProduct extends AbstractPersistable<Long> {
|
||||
// If all min and max fields are null then loanProductMinMaxConstraints
|
||||
// initialising to null
|
||||
// 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;
|
||||
return this.loanProductMinMaxConstraints;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user