mindee
Version:
Mindee Client Library for Node.js
108 lines (107 loc) • 4.33 kB
JavaScript
"use strict";
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 _PayslipV3PaidTimeOff_instances, _PayslipV3PaidTimeOff_printableValues;
Object.defineProperty(exports, "__esModule", { value: true });
exports.PayslipV3PaidTimeOff = void 0;
const common_1 = require("../../../parsing/common");
/**
* Information about paid time off.
*/
class PayslipV3PaidTimeOff {
constructor({ prediction = {} }) {
_PayslipV3PaidTimeOff_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"] !== undefined &&
prediction["accrued"] !== null &&
!isNaN(prediction["accrued"])) {
this.accrued = +parseFloat(prediction["accrued"]);
}
else {
this.accrued = null;
}
this.period = prediction["period"];
this.ptoType = prediction["pto_type"];
if (prediction["remaining"] !== undefined &&
prediction["remaining"] !== null &&
!isNaN(prediction["remaining"])) {
this.remaining = +parseFloat(prediction["remaining"]);
}
else {
this.remaining = null;
}
if (prediction["used"] !== undefined &&
prediction["used"] !== null &&
!isNaN(prediction["used"])) {
this.used = +parseFloat(prediction["used"]);
}
else {
this.used = 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, _PayslipV3PaidTimeOff_instances, "m", _PayslipV3PaidTimeOff_printableValues).call(this);
return ("Accrued: " +
printable.accrued +
", Period: " +
printable.period +
", Type: " +
printable.ptoType +
", Remaining: " +
printable.remaining +
", Used: " +
printable.used);
}
/**
* Output in a format suitable for inclusion in an rST table.
*/
toTableLine() {
const printable = __classPrivateFieldGet(this, _PayslipV3PaidTimeOff_instances, "m", _PayslipV3PaidTimeOff_printableValues).call(this);
return ("| " +
printable.accrued.padEnd(9) +
" | " +
printable.period.padEnd(6) +
" | " +
printable.ptoType.padEnd(11) +
" | " +
printable.remaining.padEnd(9) +
" | " +
printable.used.padEnd(9) +
" |");
}
}
exports.PayslipV3PaidTimeOff = PayslipV3PaidTimeOff;
_PayslipV3PaidTimeOff_instances = new WeakSet(), _PayslipV3PaidTimeOff_printableValues = function _PayslipV3PaidTimeOff_printableValues() {
return {
accrued: this.accrued !== undefined ? (0, common_1.floatToString)(this.accrued) : "",
period: this.period ?
this.period.length <= 6 ?
(0, common_1.cleanSpecialChars)(this.period) :
(0, common_1.cleanSpecialChars)(this.period).slice(0, 3) + "..." :
"",
ptoType: this.ptoType ?
this.ptoType.length <= 11 ?
(0, common_1.cleanSpecialChars)(this.ptoType) :
(0, common_1.cleanSpecialChars)(this.ptoType).slice(0, 8) + "..." :
"",
remaining: this.remaining !== undefined ? (0, common_1.floatToString)(this.remaining) : "",
used: this.used !== undefined ? (0, common_1.floatToString)(this.used) : "",
};
};