MIFOSX-1992 Addressed review comments for 1992.

This commit is contained in:
Chandrika
2015-06-02 18:57:04 -04:00
parent e8fa4b3cb6
commit a3ebe54e30
3 changed files with 28 additions and 21 deletions
+5 -1
View File
@@ -33132,7 +33132,11 @@ Request Body:
<td rowspan=2><a href="#groups">Group</a></td> <td rowspan=2><a href="#groups">Group</a></td>
<td>Name</td> <td>Name</td>
</td> </td>
<tr> <tr class=alt>
<td>Account Number</td>
</tr>
<tr class=alt>
<td></td>
<td>External Id</td> <td>External Id</td>
</td> </td>
</table> </table>
@@ -305,11 +305,10 @@ public class AccountNumberPreferencesTest {
if (isAccountPreferenceSetUp) { if (isAccountPreferenceSetUp) {
String centerPrefixName = (String) this.accountNumberPreferencesHelper.getAccountNumberPreference( String centerPrefixName = (String) this.accountNumberPreferencesHelper.getAccountNumberPreference(
this.centerAccountNumberPreferenceId, "prefixType.value"); this.centerAccountNumberPreferenceId, "prefixType.value");
final String CENTER_URL = "/mifosng-provider/api/v1/groups/" + this.centerId + "?" + Utils.TENANT_IDENTIFIER; final String CENTER_URL = "/mifosng-provider/api/v1/centers/" + this.centerId + "?" + Utils.TENANT_IDENTIFIER;
if (centerPrefixName.equals(this.officeName)) { if (centerPrefixName.equals(this.officeName)) {
final String centerOfficeName = Utils.performServerGet(requestSpec, responseSpec, CENTER_URL, "officeName"); final String centerOfficeName = Utils.performServerGet(requestSpec, responseSpec, CENTER_URL, "officeName");
this.validateAccountNumberLengthAndStartsWithPrefix(center.getAccountNo(), centerOfficeName); this.validateAccountNumberLengthAndStartsWithPrefix(center.getAccountNo(), centerOfficeName);
} }
} else { } else {
@@ -204,23 +204,9 @@ public class GroupingTypesWritePlatformServiceJpaRepositoryImpl implements Group
* groups if they exist * groups if they exist
*/ */
newGroup.generateHierarchy(); newGroup.generateHierarchy();
if (newGroup.isAccountNumberRequiresAutoGeneration()) { /* Generate account number if required */
EntityAccountType entityAccountType = null; generateAccountNumberIfRequired(newGroup);
AccountNumberFormat accountNumberFormat = null;
if(newGroup.isCenter()){
entityAccountType = EntityAccountType.CENTER;
accountNumberFormat = this.accountNumberFormatRepository
.findByAccountType(entityAccountType);
newGroup.updateAccountNo(this.accountNumberGenerator.generateCenterAccountNumber(newGroup, accountNumberFormat));
}else {
entityAccountType = EntityAccountType.GROUP;
accountNumberFormat = this.accountNumberFormatRepository
.findByAccountType(entityAccountType);
newGroup.updateAccountNo(this.accountNumberGenerator.generateGroupAccountNumber(newGroup, accountNumberFormat));
}
}
this.groupRepository.saveAndFlush(newGroup); this.groupRepository.saveAndFlush(newGroup);
newGroup.captureStaffHistoryDuringCenterCreation(staff, activationDate); newGroup.captureStaffHistoryDuringCenterCreation(staff, activationDate);
@@ -238,6 +224,24 @@ public class GroupingTypesWritePlatformServiceJpaRepositoryImpl implements Group
} }
} }
private void generateAccountNumberIfRequired(Group newGroup){
if (newGroup.isAccountNumberRequiresAutoGeneration()) {
EntityAccountType entityAccountType = null;
AccountNumberFormat accountNumberFormat = null;
if(newGroup.isCenter()){
entityAccountType = EntityAccountType.CENTER;
accountNumberFormat = this.accountNumberFormatRepository
.findByAccountType(entityAccountType);
newGroup.updateAccountNo(this.accountNumberGenerator.generateCenterAccountNumber(newGroup, accountNumberFormat));
}else {
entityAccountType = EntityAccountType.GROUP;
accountNumberFormat = this.accountNumberFormatRepository
.findByAccountType(entityAccountType);
newGroup.updateAccountNo(this.accountNumberGenerator.generateGroupAccountNumber(newGroup, accountNumberFormat));
}
}
}
@Transactional @Transactional
@Override @Override
public CommandProcessingResult createCenter(final JsonCommand command) { public CommandProcessingResult createCenter(final JsonCommand command) {