josehernandezfintecheandomx commented on code in PR #3366:
URL: https://github.com/apache/fineract/pull/3366#discussion_r1300325153


##########
fineract-core/src/main/java/org/apache/fineract/portfolio/savings/SavingsAccountTransactionType.java:
##########
@@ -38,8 +38,9 @@ public enum SavingsAccountTransactionType {
     WITHDRAWAL_FEE(4, "savingsAccountTransactionType.withdrawalFee", 
TransactionEntryType.DEBIT), //
     ANNUAL_FEE(5, "savingsAccountTransactionType.annualFee", 
TransactionEntryType.DEBIT), //
     WAIVE_CHARGES(6, "savingsAccountTransactionType.waiveCharge"), //
-    PAY_CHARGE(7, "savingsAccountTransactionType.payCharge", 
TransactionEntryType.DEBIT), //
-    DIVIDEND_PAYOUT(8, "savingsAccountTransactionType.dividendPayout", 
TransactionEntryType.CREDIT), //
+    PAY_CHARGE(7, "savingsAccountTransactionType.payCharge"), //

Review Comment:
   Done! Lines restored



##########
fineract-provider/src/main/java/org/apache/fineract/portfolio/savings/api/SavingsProductsApiResourceSwagger.java:
##########
@@ -226,88 +226,34 @@ public static final class 
GetSavingsProductsProductIdResponse {
 
         private GetSavingsProductsProductIdResponse() {}
 
-        static final class GetSavingsProductsAccountingMappings {
-
-            private GetSavingsProductsAccountingMappings() {}
-
-            static final class GetSavingsProductsSavingsReferenceAccount {
-
-                private GetSavingsProductsSavingsReferenceAccount() {}
-
-                @Schema(example = "12")
-                public Integer id;
-                @Schema(example = "savings ref")
-                public String name;
-                @Schema(example = "20")
-                public Integer glCode;
-            }
-
-            static final class GetSavingsProductsIncomeFromFeeAccount {
-
-                private GetSavingsProductsIncomeFromFeeAccount() {}
-
-                @Schema(example = "16")
-                public Integer id;
-                @Schema(example = "income from savings fee")
-                public String name;
-                @Schema(example = "24")
-                public Integer glCode;
-            }
-
-            static final class GetSavingsProductsIncomeFromPenaltyAccount {
-
-                private GetSavingsProductsIncomeFromPenaltyAccount() {}
-
-                @Schema(example = "17")
-                public Integer id;
-                @Schema(example = "income from sav penalties")
-                public String name;
-                @Schema(example = "25")
-                public Integer glCode;
-            }
-
-            static final class GetSavingsProductsInterestOnSavingsAccount {
+        static final class GetSavingsProductsGlAccount {
 
-                private GetSavingsProductsInterestOnSavingsAccount() {}
-
-                @Schema(example = "15")
-                public Integer id;
-                @Schema(example = "interest on savings")
-                public String name;
-                @Schema(example = "23")
-                public Integer glCode;
-            }
+            private GetSavingsProductsGlAccount() {}
 
-            static final class GetSavingsProductsSavingsControlAccount {
-
-                private GetSavingsProductsSavingsControlAccount() {}
-

Review Comment:
   Same as above, remove similar classes declarations and just keep one class 
with these `ProductsGlAccount` attributes



##########
fineract-core/src/main/java/org/apache/fineract/portfolio/savings/SavingsAccountTransactionType.java:
##########
@@ -94,9 +95,33 @@ public boolean isDebitEntryType() {
         return entryType != null && entryType.isDebit();
     }
 
-    public static SavingsAccountTransactionType fromInt(final Integer value) {
-        SavingsAccountTransactionType transactionType = BY_ID.get(value);
-        return transactionType == null ? INVALID : transactionType;
+    public static SavingsAccountTransactionType fromInt(final Integer 
transactionType) {
+

Review Comment:
   Those lines for the INVALID default case are being considered switch that 
appears below



##########
fineract-provider/src/main/java/org/apache/fineract/portfolio/savings/api/RecurringDepositProductsApiResourceSwagger.java:
##########
@@ -343,88 +343,30 @@ private 
GetRecurringDepositProductsProductIdInterestCompoundingPeriodType() {}
             public String description;
         }
 
-        static final class 
GetRecurringDepositProductsProductIdAccountingMappings {
-
-            private GetRecurringDepositProductsProductIdAccountingMappings() {}
-
-            static final class 
GetRecurringDepositProductsProductIdSavingsReferenceAccount {
-
-                private 
GetRecurringDepositProductsProductIdSavingsReferenceAccount() {}

Review Comment:
   The purpose of those deletions are because there were a lot of the same 
class declaration with `id`, `name` and `glCode` attributes but with different 
class name. So If we create just one class with these three attributes and we 
just add the other attributes as type of the new class mapping ie. 
`GetRecurringDepositProductsGlAccount` 



##########
fineract-loan/src/main/java/org/apache/fineract/accounting/producttoaccountmapping/serialization/ProductToGLAccountMappingFromApiJsonDeserializer.java:
##########
@@ -84,7 +84,7 @@ public void validateForLoanProductCreate(final String json) {
         final Integer accountingRuleType = 
this.fromApiJsonHelper.extractIntegerNamed("accountingRule", element, 
Locale.getDefault());
         
baseDataValidator.reset().parameter("accountingRule").value(accountingRuleType).notNull().inMinMaxRange(1,
 4);
 
-        if (isCashBasedAccounting(accountingRuleType) || 
isAccrualBasedAccounting(accountingRuleType)) {
+        if (AccountingValidations.isCashBasedAccounting(accountingRuleType)) {

Review Comment:
   Yes, I mean we are creating common functionality like this to evaluate the 
accounting type and put this logic in a new static class to be used in 
different places. Remember the Deposit has three different cases Savings, Fixed 
Deposit and Recurring Deposit in all the three classes exists the same method 
implementation



##########
fineract-loan/src/main/java/org/apache/fineract/accounting/producttoaccountmapping/service/SavingsProductToGLAccountMappingHelper.java:
##########
@@ -229,6 +249,61 @@ public void 
handleChangesToSavingsProductToGLAccountMappings(final Long savingsP
                         savingsProductId, 
CashAccountsForSavings.ESCHEAT_LIABILITY.getValue(), changes);
             break;
             case ACCRUAL_PERIODIC:
+                // asset
+                mergeSavingsToAssetAccountMappingChanges(element, 
SavingProductAccountingParams.SAVINGS_REFERENCE.getValue(),
+                        savingsProductId, 
AccrualAccountsForSavings.SAVINGS_REFERENCE.getValue(),

Review Comment:
   Done! similar as above, new base method reused



##########
fineract-loan/src/main/java/org/apache/fineract/accounting/producttoaccountmapping/service/ProductToGLAccountMappingReadPlatformServiceImpl.java:
##########
@@ -233,41 +237,99 @@ public Map<String, Object> 
fetchAccountMappingDetailsForSavingsProduct(final Lon
         final List<Map<String, Object>> listOfProductToGLAccountMaps = 
this.jdbcTemplate.query(sql, rm, // NOSONAR
                 new Object[] { PortfolioProductType.SAVING.getValue(), 
savingsProductId });
 
-        if (AccountingRuleType.CASH_BASED.getValue().equals(accountingType)) {
+        if (AccountingValidations.isCashBasedAccounting(accountingType)) {
 
             for (final Map<String, Object> productToGLAccountMap : 
listOfProductToGLAccountMaps) {
 
                 final Integer financialAccountType = (Integer) 
productToGLAccountMap.get("financialAccountType");
-                final CashAccountsForSavings glAccountForSavings = 
CashAccountsForSavings.fromInt(financialAccountType);
+                CashAccountsForSavings glAccountForSavings = 
CashAccountsForSavings.fromInt(financialAccountType);
+
+                if (glAccountForSavings != null) {
+                    final Long glAccountId = (Long) 
productToGLAccountMap.get("glAccountId");

Review Comment:
   Done, We create a new method for the base or common mappings, In the Accrual 
Accounting case we just add the other 3 new mappings
   
   <img width="1868" alt="Screenshot 2023-08-21 at 16 15 07" 
src="https://github.com/apache/fineract/assets/44206706/650268ff-f1cf-479d-beb0-0c34bf0e5ac8";>
   



-- 
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]

Reply via email to