UNPKG

@facturacr/atv-sdk

Version:

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

63 lines 1.9 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() { return this.props.totalOrderLineAmount || this.subTotal + this.tax.amount; } get tax() { const rate = this.props.tax.rate; return { rate, code: this.props.tax.code, 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 }; const tax = { code: props.tax.code, rate: typeof props.tax.rate === 'number' ? props.tax.rate : 13, rateCode: props.tax.rateCode }; return new OrderLine(Object.assign(Object.assign({}, orderLineProps), { tax })); } } exports.OrderLine = OrderLine; //# sourceMappingURL=OrderLine.js.map