|
for loan transactions... when an external_id is duplicated... a stack trace is returned instead of a proper json result.
Basically you can now associate an externalId with a transaction (disbursement, repayment etc) like elsewhere in the system, there cannot be duplicates, if there is an error is thrown by db and we must catch the java exception and handle correctly as we do else where. Theres no externalId concept for transactions on UI (on purpose) so you will have to drive the tests through the API.
For example, in ClientWritePlatformServiceJpaRepositoryImpl and other places it picks up if there is an external_id error and throws a PlatformDataIntegrityException - this needs to be done for loan transactions. The unique constraint has already been added to LoanTransaction.java.
/*
-
Guaranteed to throw an exception no matter what the data integrity issue
-
is.
*/ private void handleDataIntegrityIssues(final JsonCommand command, final DataIntegrityViolationException dve) {
final Throwable realCause = dve.getMostSpecificCause(); if (realCause.getMessage().contains("external_id")) { final String externalId = command.stringValueOfParameterNamed("externalId"); throw new PlatformDataIntegrityException("error.msg.client.duplicate.externalId", "Client with externalId `" + externalId + "` already exists", "externalId", externalId); }
else if (realCause.getMessage().contains("account_no_UNIQUE")) { final String accountNo = command.stringValueOfParameterNamed("accountNo"); throw new PlatformDataIntegrityException("error.msg.client.duplicate.accountNo", "Client with accountNo `" + accountNo + "` already exists", "accountNo", accountNo); }
logAsErrorUnexpectedDataIntegrityException(dve); throw new PlatformDataIntegrityException("error.msg.client.unknown.data.integrity.issue", "Unknown data integrity issue with resource."); }
|