UNPKG

mindee

Version:

Mindee Client Library for Node.js

96 lines (95 loc) 4.29 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.BillOfLadingV1Document = void 0; const common_1 = require("../../parsing/common"); const billOfLadingV1Shipper_1 = require("./billOfLadingV1Shipper"); const billOfLadingV1Consignee_1 = require("./billOfLadingV1Consignee"); const billOfLadingV1NotifyParty_1 = require("./billOfLadingV1NotifyParty"); const billOfLadingV1Carrier_1 = require("./billOfLadingV1Carrier"); const billOfLadingV1CarrierItem_1 = require("./billOfLadingV1CarrierItem"); const standard_1 = require("../../parsing/standard"); /** * Bill of Lading API version 1.1 document data. */ class BillOfLadingV1Document { constructor(rawPrediction, pageId) { /** The goods being shipped. */ this.carrierItems = []; this.billOfLadingNumber = new standard_1.StringField({ prediction: rawPrediction["bill_of_lading_number"], pageId: pageId, }); this.carrier = new billOfLadingV1Carrier_1.BillOfLadingV1Carrier({ prediction: rawPrediction["carrier"], pageId: pageId, }); rawPrediction["carrier_items"] && rawPrediction["carrier_items"].map((itemPrediction) => this.carrierItems.push(new billOfLadingV1CarrierItem_1.BillOfLadingV1CarrierItem({ prediction: itemPrediction, pageId: pageId, }))); this.consignee = new billOfLadingV1Consignee_1.BillOfLadingV1Consignee({ prediction: rawPrediction["consignee"], pageId: pageId, }); this.dateOfIssue = new standard_1.DateField({ prediction: rawPrediction["date_of_issue"], pageId: pageId, }); this.departureDate = new standard_1.DateField({ prediction: rawPrediction["departure_date"], pageId: pageId, }); this.notifyParty = new billOfLadingV1NotifyParty_1.BillOfLadingV1NotifyParty({ prediction: rawPrediction["notify_party"], pageId: pageId, }); this.placeOfDelivery = new standard_1.StringField({ prediction: rawPrediction["place_of_delivery"], pageId: pageId, }); this.portOfDischarge = new standard_1.StringField({ prediction: rawPrediction["port_of_discharge"], pageId: pageId, }); this.portOfLoading = new standard_1.StringField({ prediction: rawPrediction["port_of_loading"], pageId: pageId, }); this.shipper = new billOfLadingV1Shipper_1.BillOfLadingV1Shipper({ prediction: rawPrediction["shipper"], pageId: pageId, }); } /** * Default string representation. */ toString() { let carrierItemsSummary = ""; if (this.carrierItems && this.carrierItems.length > 0) { const carrierItemsColSizes = [38, 14, 13, 18, 10, 13]; carrierItemsSummary += "\n" + (0, common_1.lineSeparator)(carrierItemsColSizes, "-") + "\n "; carrierItemsSummary += "| Description "; carrierItemsSummary += "| Gross Weight "; carrierItemsSummary += "| Measurement "; carrierItemsSummary += "| Measurement Unit "; carrierItemsSummary += "| Quantity "; carrierItemsSummary += "| Weight Unit "; carrierItemsSummary += "|\n" + (0, common_1.lineSeparator)(carrierItemsColSizes, "="); carrierItemsSummary += this.carrierItems.map((item) => "\n " + item.toTableLine() + "\n" + (0, common_1.lineSeparator)(carrierItemsColSizes, "-")).join(""); } const outStr = `:Bill of Lading Number: ${this.billOfLadingNumber} :Shipper: ${this.shipper.toFieldList()} :Consignee: ${this.consignee.toFieldList()} :Notify Party: ${this.notifyParty.toFieldList()} :Carrier: ${this.carrier.toFieldList()} :Items: ${carrierItemsSummary} :Port of Loading: ${this.portOfLoading} :Port of Discharge: ${this.portOfDischarge} :Place of Delivery: ${this.placeOfDelivery} :Date of issue: ${this.dateOfIssue} :Departure Date: ${this.departureDate}`.trimEnd(); return (0, common_1.cleanOutString)(outStr); } } exports.BillOfLadingV1Document = BillOfLadingV1Document;