MIFOSX-1992 Addressed review comments for 1992.
This commit is contained in:
@@ -33132,7 +33132,11 @@ Request Body:
|
||||
<td rowspan=2><a href="#groups">Group</a></td>
|
||||
<td>Name</td>
|
||||
</td>
|
||||
<tr>
|
||||
<tr class=alt>
|
||||
<td>Account Number</td>
|
||||
</tr>
|
||||
<tr class=alt>
|
||||
<td></td>
|
||||
<td>External Id</td>
|
||||
</td>
|
||||
</table>
|
||||
|
||||
+2
-3
@@ -305,11 +305,10 @@ public class AccountNumberPreferencesTest {
|
||||
if (isAccountPreferenceSetUp) {
|
||||
String centerPrefixName = (String) this.accountNumberPreferencesHelper.getAccountNumberPreference(
|
||||
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)) {
|
||||
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);
|
||||
}
|
||||
} else {
|
||||
|
||||
+21
-17
@@ -204,23 +204,9 @@ public class GroupingTypesWritePlatformServiceJpaRepositoryImpl implements Group
|
||||
* groups if they exist
|
||||
*/
|
||||
newGroup.generateHierarchy();
|
||||
|
||||
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));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/* Generate account number if required */
|
||||
generateAccountNumberIfRequired(newGroup);
|
||||
|
||||
this.groupRepository.saveAndFlush(newGroup);
|
||||
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
|
||||
@Override
|
||||
public CommandProcessingResult createCenter(final JsonCommand command) {
|
||||
|
||||
Reference in New Issue
Block a user