Skip to content

Commit

Permalink
Merge pull request #112 from dcsaorg/DT-1418
Browse files Browse the repository at this point in the history
Dt 1418
  • Loading branch information
preetamnpr authored Aug 2, 2024
2 parents 9573ace + e5f57a4 commit 15af3ff
Show file tree
Hide file tree
Showing 5 changed files with 2,381 additions and 384 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@
import java.util.stream.Collectors;
import java.util.stream.StreamSupport;

import static org.dcsa.conformance.standards.booking.checks.BookingDataSets.NATIONAL_COMMODITY_TYPE_CODES;

@UtilityClass
public class BookingChecks {

Expand Down Expand Up @@ -88,6 +90,12 @@ public static ActionCheck requestContentChecks(UUID matched, String standardVers
}
);

private static final JsonRebaseableContentCheck NATIONAL_COMMODITY_TYPE_CODE_VALIDATION = JsonAttribute.allIndividualMatchesMustBeValid(
"Validate that 'type' of 'nationalCommodityCodes' is a known code",
(mav) -> mav.submitAllMatching("requestedEquipments.*.commodities.*.nationalCommodityCodes.*.type"),
JsonAttribute.matchedMustBeDatasetKeywordIfPresent(NATIONAL_COMMODITY_TYPE_CODES)
);

private static final JsonContentCheck VALIDATE_ALL_BOOKING_UN_LOCATION_CODES = JsonAttribute.allIndividualMatchesMustBeValid(
"Validate all booking UNLocationCodes",
(mav) -> {
Expand Down Expand Up @@ -191,10 +199,10 @@ public static ActionCheck requestContentChecks(UUID matched, String standardVers
JsonAttribute.matchedMustBeDatasetKeywordIfPresent(BookingDataSets.REFERENCE_TYPES)
);

private static final JsonContentCheck TLR_CC_T_COMBINATION_VALIDATIONS = JsonAttribute.allIndividualMatchesMustBeValid(
"Validate combination of 'countryCode' and 'type' in 'taxAndLegalReferences'",
private static final JsonContentCheck TLR_TYPE_CODE_VALIDATIONS = JsonAttribute.allIndividualMatchesMustBeValid(
"Validate 'type' in 'taxAndLegalReferences' static data",
mav -> mav.submitAllMatching("documentParties.*.party.taxLegalReferences.*"),
JsonAttribute.combineAndValidateAgainstDataset(BookingDataSets.LTR_CC_T_COMBINATIONS, "countryCode", "type")
JsonAttribute.matchedMustBeDatasetKeywordIfPresent(BookingDataSets.LTR_TYPE_CODES)
);

private static final JsonContentCheck ISO_EQUIPMENT_CODE_VALIDATION = JsonAttribute.allIndividualMatchesMustBeValid(
Expand Down Expand Up @@ -321,10 +329,22 @@ private static Set<String> validateDocumentPartyFields(JsonNode documentPartyNod
JsonAttribute.unique("cutOffDateTimeCode")
);

private static final JsonContentCheck AMF_CC_MTC_COMBINATION_VALIDATIONS = JsonAttribute.allIndividualMatchesMustBeValid(
"Validate combination of 'countryCode' and 'manifestTypeCode' in 'advanceManifestFilings'",
(mav) -> mav.submitAllMatching("advanceManifestFilings.*"),
JsonAttribute.combineAndValidateAgainstDataset(BookingDataSets.AMF_CC_MTC_COMBINATIONS, "countryCode", "manifestTypeCode")
private static final Consumer<MultiAttributeValidator> ALL_CUSTOMS_REFERENCES_TYPE = (mav) -> {
mav.submitAllMatching("customsReferences.*.type");
mav.submitAllMatching("requestedEquipments.*.customsReferences.*.type");
mav.submitAllMatching("requestedEquipments.*.commodities.*.customsReferences.*.type");
};

private static final JsonRebaseableContentCheck CR_TYPE_CODES_VALIDATIONS = JsonAttribute.allIndividualMatchesMustBeValid(
"Validate 'type' in 'customsReferences' must be valid",
ALL_CUSTOMS_REFERENCES_TYPE,
JsonAttribute.matchedMustBeDatasetKeywordIfPresent(BookingDataSets.CUSTOMS_REFERENCE_RE_REC_TYPE_CODES)
);

private static final JsonContentCheck AMF_MTC_VALIDATIONS = JsonAttribute.allIndividualMatchesMustBeValid(
"Validate 'manifestTypeCode' in 'advanceManifestFilings' static data",
(mav) -> mav.submitAllMatching("advanceManifestFilings.*.type"),
JsonAttribute.matchedMustBeDatasetKeywordIfPresent(BookingDataSets.AMF_CC_MTC_TYPE_CODES)
);

private static final JsonRebaseableContentCheck COUNTRY_CODE_VALIDATIONS = JsonAttribute.allIndividualMatchesMustBeValid(
Expand All @@ -340,6 +360,8 @@ private static Set<String> validateDocumentPartyFields(JsonNode documentPartyNod
mav.submitAllMatching("documentParties.serviceContractOwner.address.countryCode");
mav.submitAllMatching("documentParties.carrierBookingOffice.address.countryCode");
mav.submitAllMatching("documentParties.other.*.party.address.countryCode");
mav.submitAllMatching("placeOfBLIssue.countryCode");
mav.submitAllMatching("requestedEquipments.*.commodities.*.nationalCommodityCodes.*.countryCode");
},
JsonAttribute.matchedMustBeDatasetKeywordIfPresent(BookingDataSets.ISO_3166_ALPHA2_COUNTRY_CODES)
);
Expand Down Expand Up @@ -618,14 +640,16 @@ private static void generateScenarioRelatedChecks(List<JsonContentCheck> checks,
IS_EXPORT_DECLARATION_REFERENCE_ABSENCE,
IS_IMPORT_DECLARATION_REFERENCE_ABSENCE,
OUTER_PACKAGING_CODE_IS_VALID,
TLR_CC_T_COMBINATION_VALIDATIONS,
TLR_TYPE_CODE_VALIDATIONS,
DOCUMENT_PARTY_FUNCTIONS_MUST_BE_UNIQUE,
UNIVERSAL_SERVICE_REFERENCE,
VALIDATE_SHIPMENT_CUTOFF_TIME_CODE,
VALIDATE_ALLOWED_SHIPMENT_CUTOFF_CODE,
COUNTRY_CODE_VALIDATIONS,
VALIDATE_SHIPPER_MINIMUM_REQUEST_FIELDS,
VALIDATE_DOCUMENT_PARTY,
CR_TYPE_CODES_VALIDATIONS,
NATIONAL_COMMODITY_TYPE_CODE_VALIDATION,
JsonAttribute.atLeastOneOf(
JsonPointer.compile("/expectedDepartureDate"),
JsonPointer.compile("/expectedArrivalAtPlaceOfDeliveryStartDate"),
Expand Down Expand Up @@ -711,7 +735,7 @@ private static void generateScenarioRelatedChecks(List<JsonContentCheck> checks,
private static final List<JsonContentCheck> RESPONSE_ONLY_CHECKS = Arrays.asList(
CHECK_ABSENCE_OF_CONFIRMED_FIELDS,
ADVANCED_MANIFEST_FILING_CODES_UNIQUE,
AMF_CC_MTC_COMBINATION_VALIDATIONS,
AMF_MTC_VALIDATIONS,
SHIPMENT_CUTOFF_TIMES_UNIQUE,
CHECK_CONFIRMED_BOOKING_FIELDS,
VALIDATE_SHIPMENT_LOCATIONS,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,12 @@ public class BookingDataSets {

public static final KeywordDataset INCO_TERMS_VALUES = KeywordDataset.staticDataset("EXW", "FCA", "FAS", "FOB", "CFR", "CIF", "CPT", "CIP", "DAP", "DPU", "DDP");

public static final KeywordDataset NATIONAL_COMMODITY_TYPE_CODES = KeywordDataset.staticDataset( "NCM", "HTS", "Schedule B", "TARIC", "CN", "CUS" );

public static final KeywordDataset CUTOFF_DATE_TIME_CODES = KeywordDataset.staticDataset("DCO", "VCO", "FCO", "LCO", "ECP", "EFC");

public static final KeywordDataset AMF_CC_MTC_COMBINATIONS = KeywordDataset.fromCSVCombiningColumns(BookingDataSets.class, "/standards/booking/datasets/advancemanifestfilings-v2.0.0.csv", "/", "Country Code", "Advance Manifest Filing Type Code");
public static final KeywordDataset AMF_CC_MTC_TYPE_CODES = KeywordDataset.fromVersionedCSV(BookingDataSets.class, "/standards/booking/datasets/advancemanifestfilings-v%s.csv", "Advance Manifest Filing Type Code");

public static final KeywordDataset ISO_4217_CURRENCY_CODES = KeywordDataset.fromCSV(BookingDataSets.class, "/standards/booking/datasets/currency-codes-iso-4217.csv", "CurrencyCode");

public static final KeywordDataset REFERENCE_TYPES = KeywordDataset.fromCSV(BookingDataSets.class, "/standards/booking/datasets/general-reference-types.csv", "General Reference Type Code");
Expand All @@ -36,10 +39,12 @@ public class BookingDataSets {

public static final KeywordDataset INHALATION_ZONE_CODE = KeywordDataset.staticDataset("A", "B", "C", "D");

public static final KeywordDataset LTR_CC_T_COMBINATIONS = KeywordDataset.fromCSVCombiningColumns(BookingDataSets.class, "/standards/booking/datasets/taxandlegalreferences-v2.0.0.csv", "/", "Tax and Legal Reference Country Code", "Tax and Legal Reference Type Code");
public static final KeywordDataset LTR_TYPE_CODES = KeywordDataset.fromVersionedCSV(BookingDataSets.class, "/standards/booking/datasets/taxandlegalreferences-v%s.csv", "/", "Tax and Legal Reference Country Code", "Tax and Legal Reference Type Code");

public static final KeywordDataset ISO_3166_ALPHA2_COUNTRY_CODES = KeywordDataset.fromCSV(BookingDataSets.class, "/standards/booking/datasets/country-codes-iso3166-alpha2.csv", "Code");

public static final KeywordDataset CUSTOMS_REFERENCE_RE_REC_TYPE_CODES = KeywordDataset.fromVersionedCSV(BookingDataSets.class, "/standards/booking/datasets/customsreferences-v%s.csv", "Customs Reference Type Code");

@SneakyThrows
private static KeywordDataset loadUNLocationCodeDataset() {
var validCodes = new HashSet<>();
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
Customs Reference Type Code,Customs Reference Country Code,Customs Reference Name,Customs Reference Description
DUE,BR,Declaração Única de Exportação,"An electronic document that contains all the necessary information for export operations and serves as the basis for customs and administrative control, including the collection of statistical data on exports from Brazil."
ITN,US,Internal Transaction Number,
AES,US,Automated Export System,"The system used by persons or entities exporting goods from the United States, Puerto Rico, or the U.S. Virgin Islands to electronically declare their international exports, known as Electronic Export Information (EEI), to the Census Bureau to help compile export and trade statistics."
AES,PR,Automated Export System,"The system used by persons or entities exporting goods from the United States, Puerto Rico, or the U.S. Virgin Islands to electronically declare their international exports, known as Electronic Export Information (EEI), to the Census Bureau to help compile export and trade statistics."
AES,VI,Automated Export System,"The system used by persons or entities exporting goods from the United States, Puerto Rico, or the U.S. Virgin Islands to electronically declare their international exports, known as Electronic Export Information (EEI), to the Census Bureau to help compile export and trade statistics."
PRN,CA,Proof of Report Number,
CERS,CA,Canadian Export Reporting System,
EPN,KR,Korean customs EP reference,
BIETC,GA,Bordereau d’Identification Électronique de Traç...,Bordereau d’Identification Électronique de Traçabilité des Cargaisons
BIETC,LR,Bordereau d’Identification Électronique de Traç...,Bordereau d’Identification Électronique de Traçabilité des Cargaisons
NXP,NG,NXP number,
FMN,NG,Form M number,
BAN,NG,BA number,
ECI,ZA,Export cargo identifier,
ECTN,BJ,Electronic Cargo Tracking Note,
URN,CG,Unique Registration Number,
URN,CD,Unique Registration Number,
PEB,ID,PEB reference number,
CTN,SN,Cargo Tracking Note,
CTN,LR,Cargo Tracking Note,
BSC,SN,Bordereau de Suivi Cargaison,
BSC,LR,Bordereau de Suivi Cargaison,
ACID,EG,Advance Cargo Information Declaration,"A 19 digits number issued by the Egyptian customs portal [Nafeza.gov.eg](https://www.nafeza.gov.eg/en/site/aci-details) uniquely identifying a shipment under the Egypt ACI system."
Customs Reference number,CM,Customs Reference number,
Shipping Bill Numbers,BD,Shipping Bill Numbers,
Export entry numbers,KE,Export entry numbers,
Export entry numbers,UG,Export entry numbers,
Customs Number,DO,Customs Number,
PCIN,IN,Personal Cargo Identification Number,
CSN,IN,Cargo Summary Notification,
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@
"UNLocationCode": "NLAMS"
},
"placeOfBLIssue": {
"locationName": "Amsterdam",
"UNLocationCode" : "NLAMS"
},
"references": [
Expand Down
Loading

0 comments on commit 15af3ff

Please sign in to comment.