rymghosn commented on code in PR #6285:
URL: https://github.com/apache/fineract/pull/6285#discussion_r4181213207
##########
fineract-provider/src/main/java/org/apache/fineract/portfolio/loanaccount/jobs/transferfeechargeforloans/TransferFeeChargeForLoansTasklet.java:
##########
@@ -78,9 +84,27 @@ public RepeatStatus execute(StepContribution contribution,
ChunkContext chunkCon
break;
}
final boolean isExceptionForBalanceCheck = false;
+ BigDecimal amountWithTax =
installmentChargeData.getAmountOutstanding();
+ if (loanCharge != null) {
+ if (loanCharge.getCharge().getTaxGroup() !=
null && log.isInfoEnabled()) {
+ log.info(
+ "Scheduled charge payment tax
evaluation: loanId={}, loanChargeId={}, installmentNumber={}, txDate={},
baseAmount={}, applicableTaxComponents={}",
+ chargeData.getLoanId(),
chargeData.getId(), installmentChargeData.getInstallmentNumber(),
+ DateUtils.getBusinessLocalDate(),
amountWithTax, TaxUtils.getApplicableTaxComponentSummaries(
+
loanCharge.getCharge().getTaxGroup(), DateUtils.getBusinessLocalDate()));
+ }
Review Comment:
Removed.
##########
fineract-provider/src/main/java/org/apache/fineract/portfolio/loanaccount/jobs/transferfeechargeforloans/TransferFeeChargeForLoansTasklet.java:
##########
@@ -78,9 +84,27 @@ public RepeatStatus execute(StepContribution contribution,
ChunkContext chunkCon
break;
}
final boolean isExceptionForBalanceCheck = false;
+ BigDecimal amountWithTax =
installmentChargeData.getAmountOutstanding();
+ if (loanCharge != null) {
+ if (loanCharge.getCharge().getTaxGroup() !=
null && log.isInfoEnabled()) {
+ log.info(
+ "Scheduled charge payment tax
evaluation: loanId={}, loanChargeId={}, installmentNumber={}, txDate={},
baseAmount={}, applicableTaxComponents={}",
+ chargeData.getLoanId(),
chargeData.getId(), installmentChargeData.getInstallmentNumber(),
+ DateUtils.getBusinessLocalDate(),
amountWithTax, TaxUtils.getApplicableTaxComponentSummaries(
+
loanCharge.getCharge().getTaxGroup(), DateUtils.getBusinessLocalDate()));
+ }
+ amountWithTax =
TaxUtils.calculateChargeAmountWithTax(amountWithTax,
loanCharge.getCharge().getTaxGroup(),
+ DateUtils.getBusinessLocalDate(),
loanCharge.getLoan().getCurrency().getDigitsAfterDecimal());
+ if (loanCharge.getCharge().getTaxGroup() !=
null && log.isInfoEnabled()) {
+ log.info(
+ "Scheduled charge payment tax
result: loanId={}, loanChargeId={}, installmentNumber={}, txDate={},
amountAfterTax={}",
+ chargeData.getLoanId(),
chargeData.getId(), installmentChargeData.getInstallmentNumber(),
+ DateUtils.getBusinessLocalDate(),
amountWithTax);
+ }
Review Comment:
Removed.
##########
fineract-provider/src/main/java/org/apache/fineract/portfolio/loanaccount/jobs/transferfeechargeforloans/TransferFeeChargeForLoansTasklet.java:
##########
@@ -98,12 +122,28 @@ public RepeatStatus execute(StepContribution contribution,
ChunkContext chunkCon
continue;
}
final boolean isExceptionForBalanceCheck = false;
- final AccountTransferDTO accountTransferDTO = new
AccountTransferDTO(DateUtils.getBusinessLocalDate(),
- chargeData.getAmountOutstanding(),
PortfolioAccountType.SAVINGS, PortfolioAccountType.LOAN,
- portfolioAccountData.getId(),
chargeData.getLoanId(), "Loan Charge Payment", null, null, null, null,
- LoanTransactionType.CHARGE_PAYMENT.getValue(),
chargeData.getId(), null,
- AccountTransferType.CHARGE_PAYMENT.getValue(),
null, null, ExternalId.empty(), null, null, null,
- isRegularTransaction, isExceptionForBalanceCheck);
+ BigDecimal amountWithTax =
chargeData.getAmountOutstanding();
+ if (loanCharge != null) {
+ if (loanCharge.getCharge().getTaxGroup() != null &&
log.isInfoEnabled()) {
+ log.info(
+ "Scheduled charge payment tax evaluation:
loanId={}, loanChargeId={}, installmentNumber={}, txDate={}, baseAmount={},
applicableTaxComponents={}",
+ chargeData.getLoanId(),
chargeData.getId(), null, DateUtils.getBusinessLocalDate(), amountWithTax,
+
TaxUtils.getApplicableTaxComponentSummaries(loanCharge.getCharge().getTaxGroup(),
+ DateUtils.getBusinessLocalDate()));
+ }
Review Comment:
Removed.
##########
fineract-provider/src/main/java/org/apache/fineract/portfolio/loanaccount/jobs/transferfeechargeforloans/TransferFeeChargeForLoansTasklet.java:
##########
@@ -98,12 +122,28 @@ public RepeatStatus execute(StepContribution contribution,
ChunkContext chunkCon
continue;
}
final boolean isExceptionForBalanceCheck = false;
- final AccountTransferDTO accountTransferDTO = new
AccountTransferDTO(DateUtils.getBusinessLocalDate(),
- chargeData.getAmountOutstanding(),
PortfolioAccountType.SAVINGS, PortfolioAccountType.LOAN,
- portfolioAccountData.getId(),
chargeData.getLoanId(), "Loan Charge Payment", null, null, null, null,
- LoanTransactionType.CHARGE_PAYMENT.getValue(),
chargeData.getId(), null,
- AccountTransferType.CHARGE_PAYMENT.getValue(),
null, null, ExternalId.empty(), null, null, null,
- isRegularTransaction, isExceptionForBalanceCheck);
+ BigDecimal amountWithTax =
chargeData.getAmountOutstanding();
+ if (loanCharge != null) {
+ if (loanCharge.getCharge().getTaxGroup() != null &&
log.isInfoEnabled()) {
+ log.info(
+ "Scheduled charge payment tax evaluation:
loanId={}, loanChargeId={}, installmentNumber={}, txDate={}, baseAmount={},
applicableTaxComponents={}",
+ chargeData.getLoanId(),
chargeData.getId(), null, DateUtils.getBusinessLocalDate(), amountWithTax,
+
TaxUtils.getApplicableTaxComponentSummaries(loanCharge.getCharge().getTaxGroup(),
+ DateUtils.getBusinessLocalDate()));
+ }
+ amountWithTax =
TaxUtils.calculateChargeAmountWithTax(amountWithTax,
loanCharge.getCharge().getTaxGroup(),
+ DateUtils.getBusinessLocalDate(),
loanCharge.getLoan().getCurrency().getDigitsAfterDecimal());
+ if (loanCharge.getCharge().getTaxGroup() != null &&
log.isInfoEnabled()) {
+ log.info(
+ "Scheduled charge payment tax result:
loanId={}, loanChargeId={}, installmentNumber={}, txDate={}, amountAfterTax={}",
+ chargeData.getLoanId(),
chargeData.getId(), null, DateUtils.getBusinessLocalDate(), amountWithTax);
+ }
Review Comment:
Removed.
##########
fineract-provider/src/main/java/org/apache/fineract/portfolio/loanaccount/service/LoanChargeWritePlatformServiceImpl.java:
##########
@@ -667,6 +669,23 @@ public CommandProcessingResult payLoanCharge(final Long
loanId, Long loanChargeI
amount = chargePerInstallment.getAmountOutstanding();
}
+ // Loan-charge payments should transfer the tax-inclusive amount, the
same way disbursement-time
+ // charge collection and charge application transactions do.
+ final LocalDate effectiveTransactionDate = transactionDate != null ?
transactionDate : DateUtils.getBusinessLocalDate();
+ final TaxGroup taxGroup = loanCharge.getCharge().getTaxGroup();
+ if (taxGroup != null && log.isInfoEnabled()) {
+ log.info(
+ "Charge payment tax evaluation: loanId={},
loanChargeId={}, installmentNumber={}, txDate={}, baseAmount={},
applicableTaxComponents={}",
+ loanId, loanChargeId, loanInstallmentNumber,
effectiveTransactionDate, amount,
+ TaxUtils.getApplicableTaxComponentSummaries(taxGroup,
effectiveTransactionDate));
+ }
Review Comment:
Removed.
##########
fineract-provider/src/main/java/org/apache/fineract/portfolio/loanaccount/service/LoanChargeWritePlatformServiceImpl.java:
##########
@@ -667,6 +669,23 @@ public CommandProcessingResult payLoanCharge(final Long
loanId, Long loanChargeI
amount = chargePerInstallment.getAmountOutstanding();
}
+ // Loan-charge payments should transfer the tax-inclusive amount, the
same way disbursement-time
+ // charge collection and charge application transactions do.
+ final LocalDate effectiveTransactionDate = transactionDate != null ?
transactionDate : DateUtils.getBusinessLocalDate();
+ final TaxGroup taxGroup = loanCharge.getCharge().getTaxGroup();
+ if (taxGroup != null && log.isInfoEnabled()) {
+ log.info(
+ "Charge payment tax evaluation: loanId={},
loanChargeId={}, installmentNumber={}, txDate={}, baseAmount={},
applicableTaxComponents={}",
+ loanId, loanChargeId, loanInstallmentNumber,
effectiveTransactionDate, amount,
+ TaxUtils.getApplicableTaxComponentSummaries(taxGroup,
effectiveTransactionDate));
+ }
+ amount = TaxUtils.calculateChargeAmountWithTax(amount, taxGroup,
effectiveTransactionDate,
+ loan.getCurrency().getDigitsAfterDecimal());
+ if (taxGroup != null && log.isInfoEnabled()) {
+ log.info("Charge payment tax result: loanId={}, loanChargeId={},
installmentNumber={}, txDate={}, amountAfterTax={}", loanId,
+ loanChargeId, loanInstallmentNumber,
effectiveTransactionDate, amount);
+ }
Review Comment:
Removed.
##########
fineract-provider/src/main/java/org/apache/fineract/portfolio/loanaccount/service/LoanWritePlatformServiceJpaRepositoryImpl.java:
##########
@@ -487,7 +488,19 @@ public CommandProcessingResult disburseLoan(final Long
loanId, final JsonCommand
for (final LoanCharge loanCharge : loanCharges) {
if (loanCharge.isDueAtDisbursement() &&
loanCharge.getChargePaymentMode().isPaymentModeAccountTransfer()
&& loanCharge.isChargePending()) {
- disBuLoanCharges.put(loanCharge.getId(),
loanCharge.amountOutstanding());
+ if (loanCharge.getCharge().getTaxGroup() != null &&
log.isInfoEnabled()) {
+ log.info(
+ "Disbursement charge tax evaluation: loanId={},
loanChargeId={}, txDate={}, baseAmount={}, applicableTaxComponents={}",
+ loanId, loanCharge.getId(),
actualDisbursementDate, loanCharge.amountOutstanding(),
+
TaxUtils.getApplicableTaxComponentSummaries(loanCharge.getCharge().getTaxGroup(),
actualDisbursementDate));
+ }
Review Comment:
Removed.
##########
fineract-provider/src/main/java/org/apache/fineract/portfolio/loanaccount/service/LoanWritePlatformServiceJpaRepositoryImpl.java:
##########
@@ -487,7 +488,19 @@ public CommandProcessingResult disburseLoan(final Long
loanId, final JsonCommand
for (final LoanCharge loanCharge : loanCharges) {
if (loanCharge.isDueAtDisbursement() &&
loanCharge.getChargePaymentMode().isPaymentModeAccountTransfer()
&& loanCharge.isChargePending()) {
- disBuLoanCharges.put(loanCharge.getId(),
loanCharge.amountOutstanding());
+ if (loanCharge.getCharge().getTaxGroup() != null &&
log.isInfoEnabled()) {
+ log.info(
+ "Disbursement charge tax evaluation: loanId={},
loanChargeId={}, txDate={}, baseAmount={}, applicableTaxComponents={}",
+ loanId, loanCharge.getId(),
actualDisbursementDate, loanCharge.amountOutstanding(),
+
TaxUtils.getApplicableTaxComponentSummaries(loanCharge.getCharge().getTaxGroup(),
actualDisbursementDate));
+ }
+ final BigDecimal chargeAmountWithTax =
TaxUtils.calculateChargeAmountWithTax(loanCharge.amountOutstanding(),
+ loanCharge.getCharge().getTaxGroup(),
actualDisbursementDate, loan.getCurrency().getDigitsAfterDecimal());
+ if (loanCharge.getCharge().getTaxGroup() != null &&
log.isInfoEnabled()) {
+ log.info("Disbursement charge tax result: loanId={},
loanChargeId={}, txDate={}, amountAfterTax={}", loanId,
+ loanCharge.getId(), actualDisbursementDate,
chargeAmountWithTax);
+ }
Review Comment:
Removed.
##########
fineract-provider/src/main/java/org/apache/fineract/portfolio/loanaccount/service/LoanWritePlatformServiceJpaRepositoryImpl.java:
##########
@@ -836,7 +849,19 @@ public Map<String, Object> bulkLoanDisbursal(final
JsonCommand command, final Co
for (final LoanCharge loanCharge : loanCharges) {
if (loanCharge.isDueAtDisbursement() &&
loanCharge.getChargePaymentMode().isPaymentModeAccountTransfer()
&& loanCharge.isChargePending()) {
- disBuLoanCharges.put(loanCharge.getId(),
loanCharge.amountOutstanding());
+ if (loanCharge.getCharge().getTaxGroup() != null &&
log.isInfoEnabled()) {
+ log.info(
+ "Disbursement charge tax evaluation:
loanId={}, loanChargeId={}, txDate={}, baseAmount={},
applicableTaxComponents={}",
+ loan.getId(), loanCharge.getId(),
actualDisbursementDate, loanCharge.amountOutstanding(),
+
TaxUtils.getApplicableTaxComponentSummaries(loanCharge.getCharge().getTaxGroup(),
actualDisbursementDate));
+ }
Review Comment:
Removed.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]