@teaploy/megaprint
Version:
Megaprint npm integration
23 lines (22 loc) • 1.16 kB
JavaScript
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.Emitter = void 0;
const Validations = require("../../validations");
class Emitter {
constructor(taxNumber, email, emitterName, address, commerceName, commerceCode = 1, affiliation = 'GEN') {
if (!Validations.nit(taxNumber)) {
throw new Error('Invalid tax number');
}
this.affiliation = affiliation;
this.commerceCode = commerceCode;
this.taxNumber = taxNumber.replace('-', '');
this.commerceName = commerceName;
this.address = address;
this.emitterName = emitterName;
this.email = email;
}
toDte() {
return Object.assign({ $: Object.assign(Object.assign(Object.assign(Object.assign({ AfiliacionIVA: this.affiliation }, (this.commerceCode && { CodigoEstablecimiento: this.commerceCode })), { CorreoEmisor: this.email, NITEmisor: this.taxNumber }), (this.commerceName && { NombreComercial: this.commerceName })), (this.emitterName && { NombreEmisor: this.emitterName })) }, (this.address && { 'dte:DireccionEmisor': this.address.toDte() }));
}
}
exports.Emitter = Emitter;