Skip to content

Commit

Permalink
DT-1657: Improve validation related to number of copies/originals
Browse files Browse the repository at this point in the history
The issue is about copies because I swapped the copies and originals
issue (the fix for other issue was already reviewed and merged despite
being for the opposite attributes). Keeping the confusing total, this
commits to the issue swapped problem.
  • Loading branch information
nt-gt committed Oct 3, 2024
1 parent d7838a8 commit 016bce6
Showing 1 changed file with 20 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -162,16 +162,29 @@ public class EBLChecks {
public static final Predicate<JsonNode> IS_ELECTRONIC = td -> td.path("isElectronic").asBoolean(false);

public static final Predicate<JsonNode> IS_AN_EBL = IS_ELECTRONIC.and(td -> td.path("transportDocumentTypeCode").asText("").equals("BOL"));
public static final Predicate<JsonNode> IS_AN_ESWB = IS_ELECTRONIC.and(td -> td.path("transportDocumentTypeCode").asText("").equals("SWB"));

private static final JsonRebaseableContentCheck EBLS_CANNOT_HAVE_COPIES_WITH_CHARGES = JsonAttribute.ifThen(
"EBLs cannot have copies with charges",
IS_AN_EBL,
JsonAttribute.path("numberOfCopiesWithCharges", JsonAttribute.matchedMustBeAbsent())
);

private static final JsonRebaseableContentCheck EBLS_CANNOT_HAVE_COPIES_WITHOUT_CHARGES = JsonAttribute.ifThen(
private static final JsonRebaseableContentCheck EBLS_CANNOT_HAVE_ORIGINALS_WITHOUT_CHARGES = JsonAttribute.ifThen(
"EBLs cannot have copies without charges",
IS_AN_EBL,
JsonAttribute.path("numberOfOriginalsWithoutCharges", JsonAttribute.matchedMustBeAbsent())
);

private static final JsonRebaseableContentCheck E_SWBS_CANNOT_HAVE_ORIGINALS_WITH_CHARGES = JsonAttribute.ifThen(
"Electronic SWBs cannot have originals with charges",
IS_AN_ESWB,
JsonAttribute.path("numberOfOriginalsWithCharges", JsonAttribute.matchedMustBeAbsent())
);

private static final JsonRebaseableContentCheck E_SWBS_CANNOT_HAVE_COPIES_WITHOUT_CHARGES = JsonAttribute.ifThen(
"Electronic SWBs cannot have originals without charges",
IS_AN_ESWB,
JsonAttribute.path("numberOfCopiesWithoutCharges", JsonAttribute.matchedMustBeAbsent())
);

Expand Down Expand Up @@ -418,7 +431,9 @@ private static Consumer<MultiAttributeValidator> allDg(Consumer<MultiAttributeVa
EBL_AT_MOST_ONE_ORIGINAL_WITHOUT_CHARGES,
EBL_AT_MOST_ONE_ORIGINAL_WITH_CHARGES,
EBLS_CANNOT_HAVE_COPIES_WITH_CHARGES,
EBLS_CANNOT_HAVE_COPIES_WITHOUT_CHARGES,
EBLS_CANNOT_HAVE_ORIGINALS_WITHOUT_CHARGES,
E_SWBS_CANNOT_HAVE_ORIGINALS_WITH_CHARGES,
E_SWBS_CANNOT_HAVE_COPIES_WITHOUT_CHARGES,
JsonAttribute.ifThenElse(
"'isElectronic' implies 'issueTo' party",
JsonAttribute.isTrue(JsonPointer.compile("/isElectronic")),
Expand All @@ -445,7 +460,9 @@ private static Consumer<MultiAttributeValidator> allDg(Consumer<MultiAttributeVa
EBL_AT_MOST_ONE_ORIGINAL_WITHOUT_CHARGES,
EBL_AT_MOST_ONE_ORIGINAL_WITH_CHARGES,
EBLS_CANNOT_HAVE_COPIES_WITH_CHARGES,
EBLS_CANNOT_HAVE_COPIES_WITHOUT_CHARGES,
EBLS_CANNOT_HAVE_ORIGINALS_WITHOUT_CHARGES,
E_SWBS_CANNOT_HAVE_ORIGINALS_WITH_CHARGES,
E_SWBS_CANNOT_HAVE_COPIES_WITHOUT_CHARGES,
JsonAttribute.ifThenElse(
"'isShippedOnBoardType' vs. 'shippedOnBoardDate' or 'receivedForShipmentDate'",
JsonAttribute.isTrue(JsonPointer.compile("/isShippedOnBoardType")),
Expand Down

0 comments on commit 016bce6

Please sign in to comment.