ptuomola commented on a change in pull request #1985:
URL: https://github.com/apache/fineract/pull/1985#discussion_r775096486



##########
File path: 
fineract-provider/src/main/java/org/apache/fineract/portfolio/client/domain/AccountNumberGenerator.java
##########
@@ -70,6 +77,7 @@ public String generate(Loan loan, AccountNumberFormat 
accountNumberFormat) {
         Map<String, String> propertyMap = new HashMap<>();
         propertyMap.put(ID, loan.getId().toString());
         propertyMap.put(OFFICE_NAME, loan.getOffice().getName());
+        propertyMap.put(ENTITY_TYPE, "loan");

Review comment:
       Why is this change needed?

##########
File path: 
fineract-provider/src/main/java/org/apache/fineract/portfolio/client/domain/AccountNumberGenerator.java
##########
@@ -101,10 +111,9 @@ private String generateAccountNumber(Map<String, String> 
propertyMap, AccountNum
             if (customLength.getValue() != null) {
                 accountMaxLength = customLength.getValue().intValue();
             }
-
         }
 
-        String accountNumber = StringUtils.leftPad(propertyMap.get(ID), 
accountMaxLength, '0');
+        accountNumber = StringUtils.leftPad(accountNumber, accountMaxLength, 
'0');

Review comment:
       Why do we need to initialise this again? It was initialise already in 
line 103...

##########
File path: 
fineract-provider/src/main/java/org/apache/fineract/portfolio/client/domain/AccountNumberGenerator.java
##########
@@ -78,6 +86,7 @@ public String generate(SavingsAccount savingsAccount, 
AccountNumberFormat accoun
         Map<String, String> propertyMap = new HashMap<>();
         propertyMap.put(ID, savingsAccount.getId().toString());
         propertyMap.put(OFFICE_NAME, savingsAccount.office().getName());
+        propertyMap.put(ENTITY_TYPE, "savingsAccount");

Review comment:
       Same as above

##########
File path: 
fineract-provider/src/main/java/org/apache/fineract/infrastructure/accountnumberformat/domain/AccountNumberFormatRepository.java
##########
@@ -28,6 +28,12 @@
 
     String FIND_ACCOUNT_NUMBER_FORMAT_FOR_ENTITY = "select anf from  
AccountNumberFormat anf where anf.accountTypeEnum = :accountTypeEnum";
 
+    String FIND_ACCOUNT_NUMBER_FORMAT_FOR_ENTITY_BY_PREFIXENUM_ACCOUNTTYPEENUM 
= "select anf from  AccountNumberFormat anf where anf.accountTypeEnum = 
:accountTypeEnum and anf.prefixEnum = :prefixEnum";
+
     @Query(FIND_ACCOUNT_NUMBER_FORMAT_FOR_ENTITY)
     AccountNumberFormat findOneByAccountTypeEnum(@Param("accountTypeEnum") 
Integer accountTypeEnum);
+
+    @Query(FIND_ACCOUNT_NUMBER_FORMAT_FOR_ENTITY_BY_PREFIXENUM_ACCOUNTTYPEENUM)
+    AccountNumberFormat 
findOneByPrefixEnumAccountTypeEnum(@Param("accountTypeEnum") Integer 
accountTypeEnum,

Review comment:
       Same as above

##########
File path: 
fineract-provider/src/main/java/org/apache/fineract/portfolio/client/domain/AccountNumberGenerator.java
##########
@@ -133,12 +146,38 @@ private String generateAccountNumber(Map<String, String> 
propertyMap, AccountNum
             if (prefix != null) {
                 prefix = prefix.substring(0, Math.min(prefix.length(), 10));
             }
+            if 
(accountNumberPrefixType.getValue().equals(AccountNumberPrefixType.PREFIX_SHORT_NAME.getValue()))
 {
+                Integer prefixLength = prefix.length();
+                Integer numberLength = accountMaxLength - prefixLength;
+                accountNumber = StringUtils.leftPad(propertyMap.get(ID), 
numberLength, '0');
+            } else {
+                accountNumber = StringUtils.leftPad(accountNumber, 
Integer.valueOf(propertyMap.get(ID).length()), '0');
+            }
 
             accountNumber = StringUtils.overlay(accountNumber, prefix, 0, 0);
         }
         return accountNumber;
     }
 
+    private Map<String, String> prefixEight(Map<String, String> propertyMap, 
String accountNumber, Integer accountMaxLength,

Review comment:
       Should we call this function "generatePrefix" rather than "prefixEight"?

##########
File path: 
fineract-provider/src/main/java/org/apache/fineract/infrastructure/accountnumberformat/domain/AccountNumberFormatRepository.java
##########
@@ -28,6 +28,12 @@
 
     String FIND_ACCOUNT_NUMBER_FORMAT_FOR_ENTITY = "select anf from  
AccountNumberFormat anf where anf.accountTypeEnum = :accountTypeEnum";
 
+    String FIND_ACCOUNT_NUMBER_FORMAT_FOR_ENTITY_BY_PREFIXENUM_ACCOUNTTYPEENUM 
= "select anf from  AccountNumberFormat anf where anf.accountTypeEnum = 
:accountTypeEnum and anf.prefixEnum = :prefixEnum";
+

Review comment:
       Is this query still needed? I don't see it being called anywhere




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