Issues Found during QA
This commit is contained in:
+6
-6
@@ -375,12 +375,12 @@ public class ShareAccountCharge extends AbstractPersistable<Long> {
|
|||||||
return this.chargeTime;
|
return this.chargeTime;
|
||||||
}
|
}
|
||||||
|
|
||||||
public BigDecimal deriveChargeAmount(BigDecimal transactionAmount) {
|
public BigDecimal deriveChargeAmount(BigDecimal transactionAmount, final MonetaryCurrency currency) {
|
||||||
BigDecimal toReturnAmount = amountOrPercentage;
|
BigDecimal toReturnAmount = amountOrPercentage;
|
||||||
if (ChargeCalculationType.fromInt(this.chargeCalculation) == ChargeCalculationType.PERCENT_OF_AMOUNT) {
|
if (ChargeCalculationType.fromInt(this.chargeCalculation) == ChargeCalculationType.PERCENT_OF_AMOUNT) {
|
||||||
toReturnAmount = percentageOf(transactionAmount, this.percentage);
|
toReturnAmount = Money.of(currency, percentageOf(transactionAmount, this.percentage)).getAmount() ;
|
||||||
this.amountPercentageAppliedTo = transactionAmount;
|
this.amountPercentageAppliedTo = transactionAmount;
|
||||||
this.amount = percentageOf(this.amountPercentageAppliedTo, this.percentage);
|
this.amount = Money.of(currency, percentageOf(this.amountPercentageAppliedTo, this.percentage)).getAmount() ;
|
||||||
this.amountPaid = null;
|
this.amountPaid = null;
|
||||||
this.amountOutstanding = calculateOutstanding();
|
this.amountOutstanding = calculateOutstanding();
|
||||||
this.amountWaived = null;
|
this.amountWaived = null;
|
||||||
@@ -394,12 +394,12 @@ public class ShareAccountCharge extends AbstractPersistable<Long> {
|
|||||||
return toReturnAmount;
|
return toReturnAmount;
|
||||||
}
|
}
|
||||||
|
|
||||||
public BigDecimal updateChargeDetailsForAdditionalSharesRequest(final BigDecimal transactionAmount) {
|
public BigDecimal updateChargeDetailsForAdditionalSharesRequest(final BigDecimal transactionAmount, final MonetaryCurrency currency) {
|
||||||
BigDecimal toReturnAmount = amountOrPercentage;
|
BigDecimal toReturnAmount = amountOrPercentage;
|
||||||
if (ChargeCalculationType.fromInt(this.chargeCalculation) == ChargeCalculationType.PERCENT_OF_AMOUNT) {
|
if (ChargeCalculationType.fromInt(this.chargeCalculation) == ChargeCalculationType.PERCENT_OF_AMOUNT) {
|
||||||
toReturnAmount = percentageOf(transactionAmount, this.percentage);
|
toReturnAmount = Money.of(currency, percentageOf(transactionAmount, this.percentage)).getAmount() ;
|
||||||
this.amountPercentageAppliedTo = this.amountPercentageAppliedTo.add(transactionAmount);
|
this.amountPercentageAppliedTo = this.amountPercentageAppliedTo.add(transactionAmount);
|
||||||
this.amount = percentageOf(this.amountPercentageAppliedTo, this.percentage);
|
this.amount = Money.of(currency, percentageOf(this.amountPercentageAppliedTo, this.percentage)).getAmount() ;
|
||||||
this.amountOutstanding = calculateOutstanding();
|
this.amountOutstanding = calculateOutstanding();
|
||||||
this.amountWaived = null;
|
this.amountWaived = null;
|
||||||
this.amountWrittenOff = null;
|
this.amountWrittenOff = null;
|
||||||
|
|||||||
+26
-24
@@ -203,7 +203,7 @@ public class ShareAccountDataSerializer {
|
|||||||
Date currentDate = DateUtils.getLocalDateOfTenant().toDate();
|
Date currentDate = DateUtils.getLocalDateOfTenant().toDate();
|
||||||
for (ShareAccountCharge charge : charges) {
|
for (ShareAccountCharge charge : charges) {
|
||||||
if (charge.isActive() && charge.isShareAccountActivation()) {
|
if (charge.isActive() && charge.isShareAccountActivation()) {
|
||||||
charge.deriveChargeAmount(totalChargeAmount);
|
charge.deriveChargeAmount(totalChargeAmount, account.getCurrency());
|
||||||
ShareAccountTransaction chargeTransaction = ShareAccountTransaction.createChargeTransaction(currentDate, charge);
|
ShareAccountTransaction chargeTransaction = ShareAccountTransaction.createChargeTransaction(currentDate, charge);
|
||||||
ShareAccountChargePaidBy paidBy = new ShareAccountChargePaidBy(chargeTransaction, charge, charge.percentageOrAmount());
|
ShareAccountChargePaidBy paidBy = new ShareAccountChargePaidBy(chargeTransaction, charge, charge.percentageOrAmount());
|
||||||
chargeTransaction.addShareAccountChargePaidBy(paidBy);
|
chargeTransaction.addShareAccountChargePaidBy(paidBy);
|
||||||
@@ -215,7 +215,7 @@ public class ShareAccountDataSerializer {
|
|||||||
for (ShareAccountTransaction pending : pendingApprovalTransaction) {
|
for (ShareAccountTransaction pending : pendingApprovalTransaction) {
|
||||||
for (ShareAccountCharge charge : charges) {
|
for (ShareAccountCharge charge : charges) {
|
||||||
if (charge.isActive() && charge.isSharesPurchaseCharge()) {
|
if (charge.isActive() && charge.isSharesPurchaseCharge()) {
|
||||||
BigDecimal amount = charge.deriveChargeAmount(pending.amount());
|
BigDecimal amount = charge.deriveChargeAmount(pending.amount(), account.getCurrency());
|
||||||
ShareAccountChargePaidBy paidBy = new ShareAccountChargePaidBy(pending, charge, amount);
|
ShareAccountChargePaidBy paidBy = new ShareAccountChargePaidBy(pending, charge, amount);
|
||||||
pending.addShareAccountChargePaidBy(paidBy);
|
pending.addShareAccountChargePaidBy(paidBy);
|
||||||
totalChargeAmount = totalChargeAmount.add(amount);
|
totalChargeAmount = totalChargeAmount.add(amount);
|
||||||
@@ -481,7 +481,7 @@ public class ShareAccountDataSerializer {
|
|||||||
for(ShareAccountCharge charge: charges) {
|
for(ShareAccountCharge charge: charges) {
|
||||||
if(charge.isActive() && charge.isSharesPurchaseCharge()) {
|
if(charge.isActive() && charge.isSharesPurchaseCharge()) {
|
||||||
charge.update(transactionAmount, charge.percentageOrAmount()) ;
|
charge.update(transactionAmount, charge.percentageOrAmount()) ;
|
||||||
charge.deriveChargeAmount(transactionAmount);
|
charge.deriveChargeAmount(transactionAmount, shareAccount.getCurrency());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Set<ShareAccountTransaction> transactions = shareAccount.getShareAccountTransactions();
|
Set<ShareAccountTransaction> transactions = shareAccount.getShareAccountTransactions();
|
||||||
@@ -632,7 +632,7 @@ public class ShareAccountDataSerializer {
|
|||||||
BigDecimal totalChargeAmount = BigDecimal.ZERO;
|
BigDecimal totalChargeAmount = BigDecimal.ZERO;
|
||||||
for (ShareAccountCharge charge : charges) {
|
for (ShareAccountCharge charge : charges) {
|
||||||
if (charge.isActive() && charge.isSharesPurchaseCharge()) {
|
if (charge.isActive() && charge.isSharesPurchaseCharge()) {
|
||||||
BigDecimal amount = charge.updateChargeDetailsForAdditionalSharesRequest(purchaseTransaction.amount());
|
BigDecimal amount = charge.updateChargeDetailsForAdditionalSharesRequest(purchaseTransaction.amount(), account.getCurrency());
|
||||||
ShareAccountChargePaidBy paidBy = new ShareAccountChargePaidBy(purchaseTransaction, charge, amount);
|
ShareAccountChargePaidBy paidBy = new ShareAccountChargePaidBy(purchaseTransaction, charge, amount);
|
||||||
purchaseTransaction.addShareAccountChargePaidBy(paidBy);
|
purchaseTransaction.addShareAccountChargePaidBy(paidBy);
|
||||||
totalChargeAmount = totalChargeAmount.add(amount);
|
totalChargeAmount = totalChargeAmount.add(amount);
|
||||||
@@ -758,7 +758,7 @@ public class ShareAccountDataSerializer {
|
|||||||
boolean isTransactionBeforeExistingTransactions = false ;
|
boolean isTransactionBeforeExistingTransactions = false ;
|
||||||
Set<ShareAccountTransaction> transactions = account.getShareAccountTransactions() ;
|
Set<ShareAccountTransaction> transactions = account.getShareAccountTransactions() ;
|
||||||
for(ShareAccountTransaction transaction: transactions) {
|
for(ShareAccountTransaction transaction: transactions) {
|
||||||
if(!transaction.isChargeTransaction()) {
|
if(!transaction.isChargeTransaction() && transaction.isActive()) {
|
||||||
LocalDate transactionDate = new LocalDate(transaction.getPurchasedDate()) ;
|
LocalDate transactionDate = new LocalDate(transaction.getPurchasedDate()) ;
|
||||||
if(requestedDate.isBefore(transactionDate)) {
|
if(requestedDate.isBefore(transactionDate)) {
|
||||||
isTransactionBeforeExistingTransactions = true ;
|
isTransactionBeforeExistingTransactions = true ;
|
||||||
@@ -772,12 +772,12 @@ public class ShareAccountDataSerializer {
|
|||||||
.failWithCodeNoParameterAddedToErrorCode("redeem.transaction.date.cannot.be.before.existing.transactions");
|
.failWithCodeNoParameterAddedToErrorCode("redeem.transaction.date.cannot.be.before.existing.transactions");
|
||||||
}
|
}
|
||||||
if (!dataValidationErrors.isEmpty()) { throw new PlatformApiDataValidationException(dataValidationErrors); }
|
if (!dataValidationErrors.isEmpty()) { throw new PlatformApiDataValidationException(dataValidationErrors); }
|
||||||
|
|
||||||
ShareAccountTransaction transaction = ShareAccountTransaction.createRedeemTransaction(requestedDate.toDate(), sharesRequested,
|
ShareAccountTransaction transaction = ShareAccountTransaction.createRedeemTransaction(requestedDate.toDate(), sharesRequested,
|
||||||
unitPrice);
|
unitPrice);
|
||||||
|
validateRedeemRequest(account, transaction, baseDataValidator, dataValidationErrors) ;
|
||||||
account.addAdditionalPurchasedShares(transaction);
|
account.addAdditionalPurchasedShares(transaction);
|
||||||
actualChanges.put(ShareAccountApiConstants.requestedshares_paramname, transaction);
|
actualChanges.put(ShareAccountApiConstants.requestedshares_paramname, transaction);
|
||||||
validateRedeemRequest(account, transaction, baseDataValidator, dataValidationErrors) ;
|
|
||||||
handleRedeemSharesChargeTransactions(account, transaction);
|
handleRedeemSharesChargeTransactions(account, transaction);
|
||||||
return actualChanges;
|
return actualChanges;
|
||||||
}
|
}
|
||||||
@@ -840,22 +840,24 @@ public class ShareAccountDataSerializer {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private LocalDate deriveLockinPeriodDuration(final Integer lockinPeriod, final PeriodFrequencyType periodType, LocalDate purchaseDate) {
|
private LocalDate deriveLockinPeriodDuration(final Integer lockinPeriod, final PeriodFrequencyType periodType, LocalDate purchaseDate) {
|
||||||
LocalDate lockinDate = null ;
|
LocalDate lockinDate = purchaseDate ;
|
||||||
switch(periodType) {
|
if(periodType != null) {
|
||||||
case INVALID: //It never comes in to this state.
|
switch(periodType) {
|
||||||
break ;
|
case INVALID: //It never comes in to this state.
|
||||||
case DAYS:
|
break ;
|
||||||
lockinDate = purchaseDate.plusDays(lockinPeriod) ;
|
case DAYS:
|
||||||
break ;
|
lockinDate = purchaseDate.plusDays(lockinPeriod) ;
|
||||||
case WEEKS:
|
break ;
|
||||||
lockinDate = purchaseDate.plusWeeks(lockinPeriod) ;
|
case WEEKS:
|
||||||
break ;
|
lockinDate = purchaseDate.plusWeeks(lockinPeriod) ;
|
||||||
case MONTHS:
|
break ;
|
||||||
lockinDate = purchaseDate.plusMonths(lockinPeriod) ;
|
case MONTHS:
|
||||||
break ;
|
lockinDate = purchaseDate.plusMonths(lockinPeriod) ;
|
||||||
case YEARS:
|
break ;
|
||||||
lockinDate = purchaseDate.plusYears(lockinPeriod) ;
|
case YEARS:
|
||||||
break ;
|
lockinDate = purchaseDate.plusYears(lockinPeriod) ;
|
||||||
|
break ;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return lockinDate ;
|
return lockinDate ;
|
||||||
}
|
}
|
||||||
@@ -865,7 +867,7 @@ public class ShareAccountDataSerializer {
|
|||||||
BigDecimal totalChargeAmount = BigDecimal.ZERO;
|
BigDecimal totalChargeAmount = BigDecimal.ZERO;
|
||||||
for (ShareAccountCharge charge : charges) {
|
for (ShareAccountCharge charge : charges) {
|
||||||
if (charge.isActive() && charge.isSharesRedeemCharge()) {
|
if (charge.isActive() && charge.isSharesRedeemCharge()) {
|
||||||
BigDecimal amount = charge.updateChargeDetailsForAdditionalSharesRequest(transaction.amount());
|
BigDecimal amount = charge.updateChargeDetailsForAdditionalSharesRequest(transaction.amount(), account.getCurrency());
|
||||||
ShareAccountChargePaidBy paidBy = new ShareAccountChargePaidBy(transaction, charge, amount);
|
ShareAccountChargePaidBy paidBy = new ShareAccountChargePaidBy(transaction, charge, amount);
|
||||||
transaction.addShareAccountChargePaidBy(paidBy);
|
transaction.addShareAccountChargePaidBy(paidBy);
|
||||||
totalChargeAmount = totalChargeAmount.add(amount);
|
totalChargeAmount = totalChargeAmount.add(amount);
|
||||||
|
|||||||
+9
-15
@@ -273,6 +273,7 @@ public class ShareAccountWritePlatformServiceJpaRepositoryImpl implements ShareA
|
|||||||
journalTransactions.add(transaction);
|
journalTransactions.add(transaction);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
this.journalEntryWritePlatformService.createJournalEntriesForShares(populateJournalEntries(account, journalTransactions));
|
this.journalEntryWritePlatformService.createJournalEntriesForShares(populateJournalEntries(account, journalTransactions));
|
||||||
return new CommandProcessingResultBuilder() //
|
return new CommandProcessingResultBuilder() //
|
||||||
.withCommandId(jsonCommand.commandId()) //
|
.withCommandId(jsonCommand.commandId()) //
|
||||||
@@ -413,21 +414,14 @@ public class ShareAccountWritePlatformServiceJpaRepositoryImpl implements ShareA
|
|||||||
this.shareAccountRepository.save(account);
|
this.shareAccountRepository.save(account);
|
||||||
ShareAccountTransaction transaction = (ShareAccountTransaction) changes
|
ShareAccountTransaction transaction = (ShareAccountTransaction) changes
|
||||||
.get(ShareAccountApiConstants.requestedshares_paramname);
|
.get(ShareAccountApiConstants.requestedshares_paramname);
|
||||||
transaction = account.getShareAccountTransaction(transaction); // after
|
// after saving, entity will have different object. So need to retrieve the entity object
|
||||||
// saving,
|
transaction = account.getShareAccountTransaction(transaction);
|
||||||
// entity
|
Long redeemShares = transaction.getTotalShares() ;
|
||||||
// will
|
ShareProduct shareProduct = account.getShareProduct() ;
|
||||||
// have
|
//remove the redeem shares from total subscribed shares
|
||||||
// different
|
shareProduct.removeSubscribedShares(redeemShares);
|
||||||
// object.
|
this.shareProductRepository.save(shareProduct);
|
||||||
// So
|
|
||||||
// need
|
|
||||||
// to
|
|
||||||
// retrieve
|
|
||||||
// to
|
|
||||||
// get
|
|
||||||
// the
|
|
||||||
// id
|
|
||||||
Set<ShareAccountTransaction> transactions = new HashSet<>();
|
Set<ShareAccountTransaction> transactions = new HashSet<>();
|
||||||
transactions.add(transaction);
|
transactions.add(transaction);
|
||||||
this.journalEntryWritePlatformService.createJournalEntriesForShares(populateJournalEntries(account, transactions));
|
this.journalEntryWritePlatformService.createJournalEntriesForShares(populateJournalEntries(account, transactions));
|
||||||
|
|||||||
+7
-1
@@ -33,6 +33,7 @@ import javax.persistence.JoinColumn;
|
|||||||
import javax.persistence.JoinTable;
|
import javax.persistence.JoinTable;
|
||||||
import javax.persistence.ManyToMany;
|
import javax.persistence.ManyToMany;
|
||||||
import javax.persistence.OneToMany;
|
import javax.persistence.OneToMany;
|
||||||
|
import javax.persistence.OrderBy;
|
||||||
import javax.persistence.Table;
|
import javax.persistence.Table;
|
||||||
import javax.persistence.Temporal;
|
import javax.persistence.Temporal;
|
||||||
import javax.persistence.TemporalType;
|
import javax.persistence.TemporalType;
|
||||||
@@ -100,6 +101,7 @@ public class ShareProduct extends AbstractAuditableCustom<AppUser, Long> {
|
|||||||
@Column(name = "maximum_client_shares")
|
@Column(name = "maximum_client_shares")
|
||||||
private Long maximumShares;
|
private Long maximumShares;
|
||||||
|
|
||||||
|
@OrderBy(value = "fromDate,id")
|
||||||
@LazyCollection(LazyCollectionOption.FALSE)
|
@LazyCollection(LazyCollectionOption.FALSE)
|
||||||
@OneToMany(cascade = CascadeType.ALL, mappedBy = "product", orphanRemoval = true)
|
@OneToMany(cascade = CascadeType.ALL, mappedBy = "product", orphanRemoval = true)
|
||||||
Set<ShareProductMarketPrice> marketPrice;
|
Set<ShareProductMarketPrice> marketPrice;
|
||||||
@@ -415,7 +417,7 @@ public class ShareProduct extends AbstractAuditableCustom<AppUser, Long> {
|
|||||||
if (this.marketPrice != null && !this.marketPrice.isEmpty()) {
|
if (this.marketPrice != null && !this.marketPrice.isEmpty()) {
|
||||||
for (ShareProductMarketPrice data : this.marketPrice) {
|
for (ShareProductMarketPrice data : this.marketPrice) {
|
||||||
Date futureDate = data.getStartDate();
|
Date futureDate = data.getStartDate();
|
||||||
if (currentDate.after(futureDate)) {
|
if (currentDate.equals(futureDate) || currentDate.after(futureDate)) {
|
||||||
marketValue = data.getPrice();
|
marketValue = data.getPrice();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -430,6 +432,10 @@ public class ShareProduct extends AbstractAuditableCustom<AppUser, Long> {
|
|||||||
this.totalSubscribedShares += subscribedShares ;
|
this.totalSubscribedShares += subscribedShares ;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void removeSubscribedShares(final Long subscribedShares) {
|
||||||
|
this.totalSubscribedShares -= subscribedShares ;
|
||||||
|
}
|
||||||
|
|
||||||
public Long getSubscribedShares() {
|
public Long getSubscribedShares() {
|
||||||
return this.totalSubscribedShares ;
|
return this.totalSubscribedShares ;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user