fineract-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From raj...@apache.org
Subject [1/3] incubator-fineract git commit: FINERACT-174
Date Fri, 17 Jun 2016 06:16:55 GMT
Repository: incubator-fineract
Updated Branches:
  refs/heads/develop 7fe50160c -> a89a43a3f


FINERACT-174


Project: http://git-wip-us.apache.org/repos/asf/incubator-fineract/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-fineract/commit/94ef2b06
Tree: http://git-wip-us.apache.org/repos/asf/incubator-fineract/tree/94ef2b06
Diff: http://git-wip-us.apache.org/repos/asf/incubator-fineract/diff/94ef2b06

Branch: refs/heads/develop
Commit: 94ef2b0684bbb03fc5d4f7afa3f1cc0fedcfb86d
Parents: 7fe5016
Author: Nazeer Hussain Shaik <nazeer.shaik@confluxtechnologies.com>
Authored: Thu Jun 16 17:17:32 2016 +0530
Committer: Nazeer Hussain Shaik <nazeer.shaik@confluxtechnologies.com>
Committed: Thu Jun 16 17:17:32 2016 +0530

----------------------------------------------------------------------
 .../ProductToGLAccountMappingHelper.java        | 23 ++++++++++++++++++++
 .../SavingsProductToGLAccountMappingHelper.java | 10 +++++++--
 2 files changed, 31 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-fineract/blob/94ef2b06/fineract-provider/src/main/java/org/apache/fineract/accounting/producttoaccountmapping/service/ProductToGLAccountMappingHelper.java
----------------------------------------------------------------------
diff --git a/fineract-provider/src/main/java/org/apache/fineract/accounting/producttoaccountmapping/service/ProductToGLAccountMappingHelper.java
b/fineract-provider/src/main/java/org/apache/fineract/accounting/producttoaccountmapping/service/ProductToGLAccountMappingHelper.java
index 7e2ee41..b6b93f6 100755
--- a/fineract-provider/src/main/java/org/apache/fineract/accounting/producttoaccountmapping/service/ProductToGLAccountMappingHelper.java
+++ b/fineract-provider/src/main/java/org/apache/fineract/accounting/producttoaccountmapping/service/ProductToGLAccountMappingHelper.java
@@ -103,6 +103,29 @@ public class ProductToGLAccountMappingHelper {
         }
     }
 
+    public void createOrmergeProductToAccountMappingChanges(final JsonElement element, final
String paramName, final Long productId,
+            final int accountTypeId, final Map<String, Object> changes,
+            final GLAccountType expectedAccountType, final PortfolioProductType portfolioProductType)
{
+        final Long accountId = this.fromApiJsonHelper.extractLongNamed(paramName, element);
+
+        // get the existing product
+        if (accountId != null) {
+            final ProductToGLAccountMapping accountMapping = this.accountMappingRepository.findCoreProductToFinAccountMapping(productId,
+                    portfolioProductType.getValue(), accountTypeId);
+            if(accountMapping == null) {
+                final GLAccount glAccount = getAccountByIdAndType(paramName, expectedAccountType,
accountId);
+                changes.put(paramName, accountId);
+                ProductToGLAccountMapping newAccountMapping  = new ProductToGLAccountMapping(glAccount,
productId,
+                portfolioProductType.getValue(), accountTypeId) ;
+                this.accountMappingRepository.save(newAccountMapping);
+            }else if (accountMapping.getGlAccount().getId() != accountId) {
+                final GLAccount glAccount = getAccountByIdAndType(paramName, expectedAccountType,
accountId);
+                changes.put(paramName, accountId);
+                accountMapping.setGlAccount(glAccount);
+                this.accountMappingRepository.save(accountMapping);
+            }
+        }
+    }
     /**
      * Saves the payment type to Fund source mappings for a particular
      * product/product type (also populates the changes array if passed in)

http://git-wip-us.apache.org/repos/asf/incubator-fineract/blob/94ef2b06/fineract-provider/src/main/java/org/apache/fineract/accounting/producttoaccountmapping/service/SavingsProductToGLAccountMappingHelper.java
----------------------------------------------------------------------
diff --git a/fineract-provider/src/main/java/org/apache/fineract/accounting/producttoaccountmapping/service/SavingsProductToGLAccountMappingHelper.java
b/fineract-provider/src/main/java/org/apache/fineract/accounting/producttoaccountmapping/service/SavingsProductToGLAccountMappingHelper.java
index 529fb44..f888e60 100755
--- a/fineract-provider/src/main/java/org/apache/fineract/accounting/producttoaccountmapping/service/SavingsProductToGLAccountMappingHelper.java
+++ b/fineract-provider/src/main/java/org/apache/fineract/accounting/producttoaccountmapping/service/SavingsProductToGLAccountMappingHelper.java
@@ -98,6 +98,12 @@ public class SavingsProductToGLAccountMappingHelper extends ProductToGLAccountMa
                 GLAccountType.LIABILITY, PortfolioProductType.SAVING);
     }
 
+    public void createOrmergeSavingsToLiabilityAccountMappingChanges(final JsonElement element,
final String paramName, final Long productId,
+            final int accountTypeId, final Map<String, Object> changes) {
+        createOrmergeProductToAccountMappingChanges(element, paramName, productId, accountTypeId,
changes,
+                GLAccountType.LIABILITY, PortfolioProductType.SAVING);
+    }
+    
     /*** Abstractions for payments channel related to savings products ***/
 
     public void savePaymentChannelToFundSourceMappings(final JsonCommand command, final JsonElement
element, final Long productId,
@@ -222,9 +228,9 @@ public class SavingsProductToGLAccountMappingHelper extends ProductToGLAccountMa
                 mergeSavingsToLiabilityAccountMappingChanges(element, SAVINGS_PRODUCT_ACCOUNTING_PARAMS.TRANSFERS_SUSPENSE.getValue(),
                         savingsProductId, CASH_ACCOUNTS_FOR_SAVINGS.TRANSFERS_SUSPENSE.getValue(),
                         CASH_ACCOUNTS_FOR_SAVINGS.TRANSFERS_SUSPENSE.toString(), changes);
-                mergeSavingsToLiabilityAccountMappingChanges(element, SAVINGS_PRODUCT_ACCOUNTING_PARAMS.ESCHEAT_LIABILITY.getValue(),
+                createOrmergeSavingsToLiabilityAccountMappingChanges(element, SAVINGS_PRODUCT_ACCOUNTING_PARAMS.ESCHEAT_LIABILITY.getValue(),
                         savingsProductId, CASH_ACCOUNTS_FOR_SAVINGS.ESCHEAT_LIABILITY.getValue(),
-                        CASH_ACCOUNTS_FOR_SAVINGS.ESCHEAT_LIABILITY.toString(), changes);
+                         changes);
             break;
             case ACCRUAL_PERIODIC:
             break;


Mime
View raw message