This is an automated email from the ASF dual-hosted git repository.

ptuomola pushed a commit to branch develop
in repository https://gitbox.apache.org/repos/asf/fineract.git


The following commit(s) were added to refs/heads/develop by this push:
     new cf309b1  FINERACT-1413 : charge-payment-narration
cf309b1 is described below

commit cf309b1f8ff883dbda51b727f4c2c78bbc9d5ac5
Author: Manoj <[email protected]>
AuthorDate: Fri Nov 19 01:57:36 2021 +0530

    FINERACT-1413 : charge-payment-narration
---
 .../savings/data/SavingsAccountConstant.java          |  2 +-
 .../portfolio/savings/domain/SavingsAccount.java      | 15 ++++++++-------
 ...sAccountWritePlatformServiceJpaRepositoryImpl.java | 19 +++++++++++++++----
 3 files changed, 24 insertions(+), 12 deletions(-)

diff --git 
a/fineract-provider/src/main/java/org/apache/fineract/portfolio/savings/data/SavingsAccountConstant.java
 
b/fineract-provider/src/main/java/org/apache/fineract/portfolio/savings/data/SavingsAccountConstant.java
index 150eaba..e7cbb41 100644
--- 
a/fineract-provider/src/main/java/org/apache/fineract/portfolio/savings/data/SavingsAccountConstant.java
+++ 
b/fineract-provider/src/main/java/org/apache/fineract/portfolio/savings/data/SavingsAccountConstant.java
@@ -67,6 +67,6 @@ public class SavingsAccountConstant extends 
SavingsApiConstants {
                     feeOnMonthDayParamName, monthDayFormatParamName, 
feeIntervalParamName));
 
     protected static final Set<String> 
SAVINGS_ACCOUNT_CHARGES_PAY_CHARGE_REQUEST_DATA_PARAMETERS = new HashSet<>(
-            Arrays.asList(amountParamName, dueAsOfDateParamName, 
dateFormatParamName, localeParamName));
+            Arrays.asList(amountParamName, dueAsOfDateParamName, 
dateFormatParamName, localeParamName, noteParamName));
 
 }
diff --git 
a/fineract-provider/src/main/java/org/apache/fineract/portfolio/savings/domain/SavingsAccount.java
 
b/fineract-provider/src/main/java/org/apache/fineract/portfolio/savings/domain/SavingsAccount.java
index bc0301e..b882955 100644
--- 
a/fineract-provider/src/main/java/org/apache/fineract/portfolio/savings/domain/SavingsAccount.java
+++ 
b/fineract-provider/src/main/java/org/apache/fineract/portfolio/savings/domain/SavingsAccount.java
@@ -2708,8 +2708,8 @@ public class SavingsAccount extends 
AbstractPersistableCustom {
         return false;
     }
 
-    public void payCharge(final SavingsAccountCharge savingsAccountCharge, 
final BigDecimal amountPaid, final LocalDate transactionDate,
-            final DateTimeFormatter formatter, final AppUser user) {
+    public SavingsAccountTransaction payCharge(final SavingsAccountCharge 
savingsAccountCharge, final BigDecimal amountPaid,
+            final LocalDate transactionDate, final DateTimeFormatter 
formatter, final AppUser user) {
 
         final List<ApiParameterError> dataValidationErrors = new ArrayList<>();
         final DataValidatorBuilder baseDataValidator = new 
DataValidatorBuilder(dataValidationErrors)
@@ -2797,16 +2797,16 @@ public class SavingsAccount extends 
AbstractPersistableCustom {
             }
         }
 
-        this.payCharge(savingsAccountCharge, chargePaid, transactionDate, 
user);
+        return this.payCharge(savingsAccountCharge, chargePaid, 
transactionDate, user);
     }
 
-    public void payCharge(final SavingsAccountCharge savingsAccountCharge, 
final Money amountPaid, final LocalDate transactionDate,
-            final AppUser user) {
+    public SavingsAccountTransaction payCharge(final SavingsAccountCharge 
savingsAccountCharge, final Money amountPaid,
+            final LocalDate transactionDate, final AppUser user) {
         savingsAccountCharge.pay(getCurrency(), amountPaid);
-        handlePayChargeTransactions(savingsAccountCharge, amountPaid, 
transactionDate, user);
+        return handlePayChargeTransactions(savingsAccountCharge, amountPaid, 
transactionDate, user);
     }
 
-    private void handlePayChargeTransactions(SavingsAccountCharge 
savingsAccountCharge, Money transactionAmount,
+    private SavingsAccountTransaction 
handlePayChargeTransactions(SavingsAccountCharge savingsAccountCharge, Money 
transactionAmount,
             final LocalDate transactionDate, final AppUser user) {
         SavingsAccountTransaction chargeTransaction = null;
 
@@ -2819,6 +2819,7 @@ public class SavingsAccount extends 
AbstractPersistableCustom {
         }
 
         handleChargeTransactions(savingsAccountCharge, chargeTransaction);
+        return chargeTransaction;
     }
 
     private void handleWaiverChargeTransactions(SavingsAccountCharge 
savingsAccountCharge, Money transactionAmount, AppUser user) {
diff --git 
a/fineract-provider/src/main/java/org/apache/fineract/portfolio/savings/service/SavingsAccountWritePlatformServiceJpaRepositoryImpl.java
 
b/fineract-provider/src/main/java/org/apache/fineract/portfolio/savings/service/SavingsAccountWritePlatformServiceJpaRepositoryImpl.java
index e03b897..e437864 100644
--- 
a/fineract-provider/src/main/java/org/apache/fineract/portfolio/savings/service/SavingsAccountWritePlatformServiceJpaRepositoryImpl.java
+++ 
b/fineract-provider/src/main/java/org/apache/fineract/portfolio/savings/service/SavingsAccountWritePlatformServiceJpaRepositoryImpl.java
@@ -1232,7 +1232,14 @@ public class 
SavingsAccountWritePlatformServiceJpaRepositoryImpl implements Savi
             }
         }
 
-        this.payCharge(savingsAccountCharge, transactionDate, amountPaid, fmt, 
user);
+        SavingsAccountTransaction chargeTransaction = 
this.payCharge(savingsAccountCharge, transactionDate, amountPaid, fmt, user);
+
+        final String noteText = command.stringValueOfParameterNamed("note");
+        if (StringUtils.isNotBlank(noteText)) {
+            final Note note = 
Note.savingsTransactionNote(savingsAccountCharge.savingsAccount(), 
chargeTransaction, noteText);
+            this.noteRepository.save(note);
+        }
+
         return new CommandProcessingResultBuilder() //
                 .withEntityId(savingsAccountCharge.getId()) //
                 
.withOfficeId(savingsAccountCharge.savingsAccount().officeId()) //
@@ -1261,8 +1268,8 @@ public class 
SavingsAccountWritePlatformServiceJpaRepositoryImpl implements Savi
     }
 
     @Transactional
-    private void payCharge(final SavingsAccountCharge savingsAccountCharge, 
final LocalDate transactionDate, final BigDecimal amountPaid,
-            final DateTimeFormatter formatter, final AppUser user) {
+    private SavingsAccountTransaction payCharge(final SavingsAccountCharge 
savingsAccountCharge, final LocalDate transactionDate,
+            final BigDecimal amountPaid, final DateTimeFormatter formatter, 
final AppUser user) {
 
         final boolean isSavingsInterestPostingAtCurrentPeriodEnd = 
this.configurationDomainService
                 .isSavingsInterestPostingAtCurrentPeriodEnd();
@@ -1274,7 +1281,7 @@ public class 
SavingsAccountWritePlatformServiceJpaRepositoryImpl implements Savi
         final Set<Long> existingTransactionIds = new HashSet<>();
         final Set<Long> existingReversedTransactionIds = new HashSet<>();
         updateExistingTransactionsDetails(account, existingTransactionIds, 
existingReversedTransactionIds);
-        account.payCharge(savingsAccountCharge, amountPaid, transactionDate, 
formatter, user);
+        SavingsAccountTransaction chargeTransaction = 
account.payCharge(savingsAccountCharge, amountPaid, transactionDate, formatter, 
user);
         boolean isInterestTransfer = false;
         LocalDate postInterestOnDate = null;
         final MathContext mc = MathContext.DECIMAL64;
@@ -1296,9 +1303,13 @@ public class 
SavingsAccountWritePlatformServiceJpaRepositoryImpl implements Savi
         account.validateAccountBalanceDoesNotBecomeNegative("." + 
SavingsAccountTransactionType.PAY_CHARGE.getCode(),
                 depositAccountOnHoldTransactions);
 
+        saveTransactionToGenerateTransactionId(chargeTransaction);
+
         this.savingAccountRepositoryWrapper.saveAndFlush(account);
 
         postJournalEntries(account, existingTransactionIds, 
existingReversedTransactionIds);
+
+        return chargeTransaction;
     }
 
     private void updateExistingTransactionsDetails(SavingsAccount account, 
Set<Long> existingTransactionIds,

Reply via email to