mindee
Version:
Mindee Client Library for Node.js
51 lines (50 loc) • 1.7 kB
JavaScript
import { cleanOutString, } from "../../../../v1/parsing/common/index.js";
import { AmountField, DateField, StringField, } from "../../../../v1/parsing/standard/index.js";
/**
* Bank Check API version 1.1 document data.
*/
export class BankCheckV1Document {
constructor(rawPrediction, pageId) {
/** List of the check's payees (recipients). */
this.payees = [];
this.accountNumber = new StringField({
prediction: rawPrediction["account_number"],
pageId: pageId,
});
this.amount = new AmountField({
prediction: rawPrediction["amount"],
pageId: pageId,
});
this.checkNumber = new StringField({
prediction: rawPrediction["check_number"],
pageId: pageId,
});
this.date = new DateField({
prediction: rawPrediction["date"],
pageId: pageId,
});
if (rawPrediction["payees"]) {
rawPrediction["payees"].map((itemPrediction) => this.payees.push(new StringField({
prediction: itemPrediction,
pageId: pageId,
})));
}
this.routingNumber = new StringField({
prediction: rawPrediction["routing_number"],
pageId: pageId,
});
}
/**
* Default string representation.
*/
toString() {
const payees = this.payees.join("\n ");
const outStr = `:Check Issue Date: ${this.date}
:Amount: ${this.amount}
:Payees: ${payees}
:Routing Number: ${this.routingNumber}
:Account Number: ${this.accountNumber}
:Check Number: ${this.checkNumber}`.trimEnd();
return cleanOutString(outStr);
}
}