mindee
Version:
Mindee Client Library for Node.js
85 lines (84 loc) • 3.76 kB
JavaScript
;
var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
};
var _PayslipV2Pto_instances, _PayslipV2Pto_printableValues;
Object.defineProperty(exports, "__esModule", { value: true });
exports.PayslipV2Pto = void 0;
const common_1 = require("../../../parsing/common");
/**
* Information about paid time off.
*/
class PayslipV2Pto {
constructor({ prediction = {} }) {
_PayslipV2Pto_instances.add(this);
/** Confidence score */
this.confidence = 0.0;
/**
* Contains the relative vertices coordinates (points) of a polygon containing
* the field in the document.
*/
this.polygon = [];
if (prediction["accrued_this_period"] !== undefined &&
prediction["accrued_this_period"] !== null &&
!isNaN(prediction["accrued_this_period"])) {
this.accruedThisPeriod = +parseFloat(prediction["accrued_this_period"]);
}
else {
this.accruedThisPeriod = null;
}
if (prediction["balance_end_of_period"] !== undefined &&
prediction["balance_end_of_period"] !== null &&
!isNaN(prediction["balance_end_of_period"])) {
this.balanceEndOfPeriod = +parseFloat(prediction["balance_end_of_period"]);
}
else {
this.balanceEndOfPeriod = null;
}
if (prediction["used_this_period"] !== undefined &&
prediction["used_this_period"] !== null &&
!isNaN(prediction["used_this_period"])) {
this.usedThisPeriod = +parseFloat(prediction["used_this_period"]);
}
else {
this.usedThisPeriod = null;
}
this.pageId = prediction["page_id"];
this.confidence = prediction["confidence"] ? prediction.confidence : 0.0;
if (prediction["polygon"]) {
this.polygon = prediction.polygon;
}
}
/**
* Default string representation.
*/
toString() {
const printable = __classPrivateFieldGet(this, _PayslipV2Pto_instances, "m", _PayslipV2Pto_printableValues).call(this);
return ("Accrued This Period: " +
printable.accruedThisPeriod +
", Balance End of Period: " +
printable.balanceEndOfPeriod +
", Used This Period: " +
printable.usedThisPeriod);
}
/**
* Output in a format suitable for inclusion in a field list.
*/
toFieldList() {
const printable = __classPrivateFieldGet(this, _PayslipV2Pto_instances, "m", _PayslipV2Pto_printableValues).call(this);
return `
:Accrued This Period: ${printable.accruedThisPeriod}
:Balance End of Period: ${printable.balanceEndOfPeriod}
:Used This Period: ${printable.usedThisPeriod}`.trimEnd();
}
}
exports.PayslipV2Pto = PayslipV2Pto;
_PayslipV2Pto_instances = new WeakSet(), _PayslipV2Pto_printableValues = function _PayslipV2Pto_printableValues() {
return {
accruedThisPeriod: this.accruedThisPeriod !== undefined ? (0, common_1.floatToString)(this.accruedThisPeriod) : "",
balanceEndOfPeriod: this.balanceEndOfPeriod !== undefined ? (0, common_1.floatToString)(this.balanceEndOfPeriod) : "",
usedThisPeriod: this.usedThisPeriod !== undefined ? (0, common_1.floatToString)(this.usedThisPeriod) : "",
};
};