UNPKG

falcotura-atv-sdk

Version:

Librería (SDK) de Javascript/NodeJS para acceder al API de Administración Tributaria Virtual (ATV) del Ministerio de Hacienda.

78 lines 2.5 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.OrderLine = void 0; class OrderLine { constructor(props) { this.props = props; } get detail() { return this.props.detail; } get unitaryPrice() { return this.props.unitaryPrice; } get lineNumber() { return this.props.lineNumber; } get code() { return this.props.code; } get quantity() { return this.props.quantity || 1; } get measureUnit() { return this.props.measureUnit || 'Sp'; } get subTotal() { return this.props.subTotal || this.props.unitaryPrice * this.quantity; // subtract discounts } get totalAmount() { return this.props.totalAmount || this.props.unitaryPrice * this.quantity; } get totalOrderLineAmount() { var _a, _b; return this.props.totalOrderLineAmount || this.subTotal + ((_b = (_a = this.tax) === null || _a === void 0 ? void 0 : _a.amount) !== null && _b !== void 0 ? _b : 0); } get exchangeRate() { return this.props.exchangeRate; } get currency() { return this.props.currency; } get tax() { // @ts-expect-error pending-to-fix const rate = this.props.tax.rate; return { rate, // @ts-expect-error pending-to-fix code: this.props.tax.code, // @ts-expect-error pending-to-fix rateCode: this.props.tax.rateCode, amount: this.subTotal * (rate / 100) }; } static create(props) { const orderLineProps = { lineNumber: props.lineNumber, code: props.code, quantity: props.quantity || 1, measureUnit: props.measureUnit || 'Sp', detail: props.detail, unitaryPrice: props.unitaryPrice, totalAmount: props.totalAmount, exchangeRate: props.exchangeRate, currency: props.currency }; const tax = { // @ts-expect-error pending-to-fix code: props.tax.code, // @ts-expect-error pending-to-fix rate: typeof props.tax.rate === 'number' ? props.tax.rate : 13, // @ts-expect-error pending-to-fix rateCode: props.tax.rateCode }; return new OrderLine(Object.assign(Object.assign({}, orderLineProps), { tax })); } } exports.OrderLine = OrderLine; //# sourceMappingURL=OrderLine.js.map