Skip to content

Commit

Permalink
Merge pull request #203 from pagopa/PAGOPA-1498-iban-postalIban-pair
Browse files Browse the repository at this point in the history
bug: [PAGOPA-1498] iban postalIban pair
  • Loading branch information
alessio-acitelli authored Jan 31, 2024
2 parents 6353542 + b7065e5 commit aaf462f
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,10 @@ public class TransferModel implements Serializable {
@NotBlank(message = "category is required")
private String category; // taxonomy

@Schema(description = "mutual exclusive with postalIban and stamp", example = "IT0000000000000000000000000")
@Schema(description = "mutual exclusive with stamp", example = "IT0000000000000000000000000")
private String iban;

@Schema(description = "mutual exclusive with iban and stamp", example = "IT0000000000000000000000000")
@Schema(description = "optional - can be combined with iban but not with stamp", example = "IT0000000000000000000000000")
private String postalIban;

@Schema(description = "mutual exclusive with iban and postalIban")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public class DebtPositionValidation {
private static final String AMOUNTS_VALIDATION_ERROR = "Amounts congruence error: payment option amount must coincide with the total of the transfers amount [payment_option_amount(in cent)=%s; total_tranfers_amount(in cent)=%s]";
private static final String NUM_TRANSFERS_VALIDATION_ERROR = "Number of transfers congruence error: Each payment option must have a maximum of %s transactions [transactions found=%s]";
private static final String TRANSFER_ID_VALIDATION_ERROR = "Transfer ID congruence error: The transaction id not have a value between those expected [transaction id=%s; expected values=%s]";
private static final String IBAN_STAMP_MUTUAL = "Iban, postalIban and Stamp are mutually exclusive [iuv=%s, transaction id=%s]. One of them is required.";
private static final String IBAN_STAMP_MUTUAL = "The Iban may be present (optionally combined with the Postal Iban) or the Stamp. Not all at the same time [iuv=%s, transaction id=%s].";

private DebtPositionValidation() {
super();
Expand Down Expand Up @@ -176,11 +176,11 @@ private static void checkMutualExclusive(String iuv, Transfer t) {
if (Strings.isNotEmpty(t.getIban())) {
i++;
}
if (Strings.isNotEmpty(t.getPostalIban())) {
i++;
}
if (Strings.isNotEmpty(t.getStampType()) && Strings.isNotEmpty(t.getHashDocument()) && Strings.isNotEmpty(t.getProvincialResidence())) {
i++;
if (Strings.isNotEmpty(t.getStampType()) &&
Strings.isNotEmpty(t.getHashDocument()) &&
Strings.isNotEmpty(t.getProvincialResidence())) {
if (Strings.isEmpty(t.getPostalIban())) i++; else throw new ValidationException(String.format(IBAN_STAMP_MUTUAL, iuv, t.getIdTransfer()));
}
if (i != 1) {
throw new ValidationException(String.format(IBAN_STAMP_MUTUAL, iuv, t.getIdTransfer()));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -942,6 +942,7 @@ public static TransferDTO createTransfersMultipleMock2() {
tMock.setAmount(500);
tMock.setRemittanceInformation("causale mock multiple 2");
tMock.setCategory("10/22252/20");
tMock.setIban("IT75I0306902887100000300005");
tMock.setPostalIban("IT82E0760113600000000118547");

return tMock;
Expand Down

0 comments on commit aaf462f

Please sign in to comment.