mindee
Version:
Mindee Client Library for Node.js
36 lines (35 loc) • 1.86 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.InvoiceSplitterV1Document = void 0;
const common_1 = require("../../parsing/common");
const invoiceSplitterV1InvoicePageGroup_1 = require("./invoiceSplitterV1InvoicePageGroup");
/**
* Invoice Splitter API version 1.4 document data.
*/
class InvoiceSplitterV1Document {
constructor(rawPrediction, pageId) {
/** List of page groups. Each group represents a single invoice within a multi-invoice document. */
this.invoicePageGroups = [];
rawPrediction["invoice_page_groups"] &&
rawPrediction["invoice_page_groups"].map((itemPrediction) => this.invoicePageGroups.push(new invoiceSplitterV1InvoicePageGroup_1.InvoiceSplitterV1InvoicePageGroup({
prediction: itemPrediction,
pageId: pageId,
})));
}
/**
* Default string representation.
*/
toString() {
let invoicePageGroupsSummary = "";
if (this.invoicePageGroups && this.invoicePageGroups.length > 0) {
const invoicePageGroupsColSizes = [74];
invoicePageGroupsSummary += "\n" + (0, common_1.lineSeparator)(invoicePageGroupsColSizes, "-") + "\n ";
invoicePageGroupsSummary += "| Page Indexes ";
invoicePageGroupsSummary += "|\n" + (0, common_1.lineSeparator)(invoicePageGroupsColSizes, "=");
invoicePageGroupsSummary += this.invoicePageGroups.map((item) => "\n " + item.toTableLine() + "\n" + (0, common_1.lineSeparator)(invoicePageGroupsColSizes, "-")).join("");
}
const outStr = `:Invoice Page Groups: ${invoicePageGroupsSummary}`.trimEnd();
return (0, common_1.cleanOutString)(outStr);
}
}
exports.InvoiceSplitterV1Document = InvoiceSplitterV1Document;