Skip to content

Commit

Permalink
CU-86aywanzr_Expanded-printout-enhancement-for-fields-50F-and-59F
Browse files Browse the repository at this point in the history
  • Loading branch information
ptorres-prowide committed Dec 21, 2023
1 parent c28da25 commit 8a8c948
Show file tree
Hide file tree
Showing 2 changed files with 80 additions and 0 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
# Prowide Core - CHANGELOG

#### 9.4.14 - SNAPSHOT
* Expanded printout enhancement for field 59F

#### 9.4.13 - November 2023
* (PW-1697) Fixed validation/parse pattern in field 29O
* (PW-1697) MT306 changes in field 30I
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1476,6 +1476,83 @@ public static Field59F fromJson(final String json) {
return field;
}

/**
* Specific implementation for field 59F using dynamic labels based on line identifiers.
*
* <p>For component 3 this implementation will return the labels provided by
* {@link #getLabelForLineNumber(String)} while for all other cases it will return the
* default label.
*
* <p>
* Also since the party identifier can be an account or a code plus the identifier,
* then for component 1 if the value starts with a slash, this implementation will return
* "Account" as label instead of the generic "Party Identifier".
*
* @param number a component number
* @return english label for the field component
*
* @since 9.4.14
*/
@Override
public String getComponentLabel(final int number) {
if (number == 1 && StringUtils.startsWith(getComponent1(), "/")) {
return "Account";
}
if (number == 3 || number == 5 || number == 7) {
String label = getLabelForLineNumber(getComponent(number-1));
if (label != null) {
return label;
}
}
return super.getComponentLabel(number);
}


/**
* Return the line labels based on the structured line number identification as follows:
*
* <ul>
* <li>1 -&gt; Name of Beneficiary Customer</li>
* <li>2 -&gt; Address Line</li>
* <li>3 -&gt; Country and Town</li>
* <li>For any other number returns null</li>
* </ul>
*
* <p>This is used in {@link #getComponentLabel(int)} to determine a suitable label dynamically
* based on the line identifiers. For example if the field value is this:
* <pre>
* 1/John Smith
* 2/Hoogstrat 6
* 3/BE/Brussel
* </pre>
* The components will be parsed as follows:
* <ul>
* <li>1 -&gt; John Smith</li>
* <li>2 -&gt; 1</li>
* <li>3 -&gt; Hoogstrat 6</li>
* <li>4 -&gt; 2</li>
* <li>5 -&gt; BE/Brussel</li>
* <li>5 -&gt; 3</li>
* </ul>
*
* <p>
* @param lineIdentifier the line number identifier, 1 to 3 according to the specification.
* @return the line label
* @since 9.4.14
*/
public String getLabelForLineNumber(String lineIdentifier) {
if (StringUtils.isNumeric(StringUtils.trimToNull(lineIdentifier))) {
int number = Integer.valueOf(lineIdentifier.trim());

Check notice

Code scanning / CodeQL

Missing catch of NumberFormatException Note generated

Potential uncaught 'java.lang.NumberFormatException'.
if (number == 1) {
return "Name of Beneficiary Customer";
} else if (number == 2) {
return "Address Line";
} else if (number == 3) {
return "Country and Town";
}
}
return null;
}
/**
* Get the details (right part of the line) based on the line identification number.
* This API is specific for the structured field 59F.
Expand Down

0 comments on commit 8a8c948

Please sign in to comment.