UNPKG

mindee

Version:

Mindee Client Library for Node.js

170 lines (169 loc) 7.77 kB
"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 _PayslipV2PayDetail_instances, _PayslipV2PayDetail_printableValues; Object.defineProperty(exports, "__esModule", { value: true }); exports.PayslipV2PayDetail = void 0; const common_1 = require("../../../parsing/common"); const geometry_1 = require("../../../geometry"); /** * Detailed information about the pay. */ class PayslipV2PayDetail { constructor({ prediction = {} }) { _PayslipV2PayDetail_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 = new geometry_1.Polygon(); if (prediction["gross_salary"] !== undefined && prediction["gross_salary"] !== null && !isNaN(prediction["gross_salary"])) { this.grossSalary = +parseFloat(prediction["gross_salary"]); } else { this.grossSalary = null; } if (prediction["gross_salary_ytd"] !== undefined && prediction["gross_salary_ytd"] !== null && !isNaN(prediction["gross_salary_ytd"])) { this.grossSalaryYtd = +parseFloat(prediction["gross_salary_ytd"]); } else { this.grossSalaryYtd = null; } if (prediction["income_tax_rate"] !== undefined && prediction["income_tax_rate"] !== null && !isNaN(prediction["income_tax_rate"])) { this.incomeTaxRate = +parseFloat(prediction["income_tax_rate"]); } else { this.incomeTaxRate = null; } if (prediction["income_tax_withheld"] !== undefined && prediction["income_tax_withheld"] !== null && !isNaN(prediction["income_tax_withheld"])) { this.incomeTaxWithheld = +parseFloat(prediction["income_tax_withheld"]); } else { this.incomeTaxWithheld = null; } if (prediction["net_paid"] !== undefined && prediction["net_paid"] !== null && !isNaN(prediction["net_paid"])) { this.netPaid = +parseFloat(prediction["net_paid"]); } else { this.netPaid = null; } if (prediction["net_paid_before_tax"] !== undefined && prediction["net_paid_before_tax"] !== null && !isNaN(prediction["net_paid_before_tax"])) { this.netPaidBeforeTax = +parseFloat(prediction["net_paid_before_tax"]); } else { this.netPaidBeforeTax = null; } if (prediction["net_taxable"] !== undefined && prediction["net_taxable"] !== null && !isNaN(prediction["net_taxable"])) { this.netTaxable = +parseFloat(prediction["net_taxable"]); } else { this.netTaxable = null; } if (prediction["net_taxable_ytd"] !== undefined && prediction["net_taxable_ytd"] !== null && !isNaN(prediction["net_taxable_ytd"])) { this.netTaxableYtd = +parseFloat(prediction["net_taxable_ytd"]); } else { this.netTaxableYtd = null; } if (prediction["total_cost_employer"] !== undefined && prediction["total_cost_employer"] !== null && !isNaN(prediction["total_cost_employer"])) { this.totalCostEmployer = +parseFloat(prediction["total_cost_employer"]); } else { this.totalCostEmployer = null; } if (prediction["total_taxes_and_deductions"] !== undefined && prediction["total_taxes_and_deductions"] !== null && !isNaN(prediction["total_taxes_and_deductions"])) { this.totalTaxesAndDeductions = +parseFloat(prediction["total_taxes_and_deductions"]); } else { this.totalTaxesAndDeductions = 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, _PayslipV2PayDetail_instances, "m", _PayslipV2PayDetail_printableValues).call(this); return ("Gross Salary: " + printable.grossSalary + ", Gross Salary YTD: " + printable.grossSalaryYtd + ", Income Tax Rate: " + printable.incomeTaxRate + ", Income Tax Withheld: " + printable.incomeTaxWithheld + ", Net Paid: " + printable.netPaid + ", Net Paid Before Tax: " + printable.netPaidBeforeTax + ", Net Taxable: " + printable.netTaxable + ", Net Taxable YTD: " + printable.netTaxableYtd + ", Total Cost Employer: " + printable.totalCostEmployer + ", Total Taxes and Deductions: " + printable.totalTaxesAndDeductions); } /** * Output in a format suitable for inclusion in a field list. */ toFieldList() { const printable = __classPrivateFieldGet(this, _PayslipV2PayDetail_instances, "m", _PayslipV2PayDetail_printableValues).call(this); return ` :Gross Salary: ${printable.grossSalary} :Gross Salary YTD: ${printable.grossSalaryYtd} :Income Tax Rate: ${printable.incomeTaxRate} :Income Tax Withheld: ${printable.incomeTaxWithheld} :Net Paid: ${printable.netPaid} :Net Paid Before Tax: ${printable.netPaidBeforeTax} :Net Taxable: ${printable.netTaxable} :Net Taxable YTD: ${printable.netTaxableYtd} :Total Cost Employer: ${printable.totalCostEmployer} :Total Taxes and Deductions: ${printable.totalTaxesAndDeductions}`.trimEnd(); } } exports.PayslipV2PayDetail = PayslipV2PayDetail; _PayslipV2PayDetail_instances = new WeakSet(), _PayslipV2PayDetail_printableValues = function _PayslipV2PayDetail_printableValues() { return { grossSalary: this.grossSalary !== undefined ? (0, common_1.floatToString)(this.grossSalary) : "", grossSalaryYtd: this.grossSalaryYtd !== undefined ? (0, common_1.floatToString)(this.grossSalaryYtd) : "", incomeTaxRate: this.incomeTaxRate !== undefined ? (0, common_1.floatToString)(this.incomeTaxRate) : "", incomeTaxWithheld: this.incomeTaxWithheld !== undefined ? (0, common_1.floatToString)(this.incomeTaxWithheld) : "", netPaid: this.netPaid !== undefined ? (0, common_1.floatToString)(this.netPaid) : "", netPaidBeforeTax: this.netPaidBeforeTax !== undefined ? (0, common_1.floatToString)(this.netPaidBeforeTax) : "", netTaxable: this.netTaxable !== undefined ? (0, common_1.floatToString)(this.netTaxable) : "", netTaxableYtd: this.netTaxableYtd !== undefined ? (0, common_1.floatToString)(this.netTaxableYtd) : "", totalCostEmployer: this.totalCostEmployer !== undefined ? (0, common_1.floatToString)(this.totalCostEmployer) : "", totalTaxesAndDeductions: this.totalTaxesAndDeductions !== undefined ? (0, common_1.floatToString)(this.totalTaxesAndDeductions) : "", }; };