Skip to content

Commit

Permalink
DT-1447: Number of copies rules for eBLs
Browse files Browse the repository at this point in the history
  • Loading branch information
nt-gt committed Sep 24, 2024
1 parent 394400c commit 4643098
Showing 1 changed file with 19 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,21 @@ public class EBLChecks {
JsonAttribute.mustEqual(JsonPointer.compile("/transportDocumentTypeCode"), "BOL")
);

public static final Predicate<JsonNode> IS_AN_EBL = td -> td.path("isElectronic").asBoolean(false)
&& td.path("transportDocumentTypeCode").asText("").equals("BOL");

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(
"EBLs cannot have copies without charges",
IS_AN_EBL,
JsonAttribute.path("numberOfCopiesWithoutCharges", JsonAttribute.matchedMustBeAbsent())
);

private static final JsonRebaseableContentCheck NOTIFY_PARTIES_REQUIRED_IN_NEGOTIABLE_BLS = JsonAttribute.ifThen(
"The 'documentParties.notifyParties' attribute is mandatory for negotiable B/Ls",
JsonAttribute.isTrue("isToOrder"),
Expand Down Expand Up @@ -257,6 +272,8 @@ private static Consumer<MultiAttributeValidator> allDg(Consumer<MultiAttributeVa
EblDatasets.EBL_PLATFORMS_DATASET
),
ONLY_EBLS_CAN_BE_NEGOTIABLE,
EBLS_CANNOT_HAVE_COPIES_WITH_CHARGES,
EBLS_CANNOT_HAVE_COPIES_WITHOUT_CHARGES,
JsonAttribute.ifThenElse(
"'isElectronic' implies 'issueTo' party",
JsonAttribute.isTrue(JsonPointer.compile("/isElectronic")),
Expand All @@ -278,6 +295,8 @@ private static Consumer<MultiAttributeValidator> allDg(Consumer<MultiAttributeVa

private static final List<JsonRebaseableContentCheck> STATIC_TD_CHECKS = Arrays.asList(
ONLY_EBLS_CAN_BE_NEGOTIABLE,
EBLS_CANNOT_HAVE_COPIES_WITH_CHARGES,
EBLS_CANNOT_HAVE_COPIES_WITHOUT_CHARGES,
JsonAttribute.ifThenElse(
"'isShippedOnBoardType' vs. 'shippedOnBoardDate' or 'receivedForShipmentDate'",
JsonAttribute.isTrue(JsonPointer.compile("/isShippedOnBoardType")),
Expand Down

0 comments on commit 4643098

Please sign in to comment.