UNPKG

tecnospeed-nfe

Version:

Emit NFe through TecnoSpeed API

177 lines (149 loc) 3.26 kB
'use strict' const moment = require('moment-timezone') moment.tz.setDefault('America/Sao_Paulo') const Order = require('./order') const Company = require('./company') const Customer = require('./customer') const TX2 = require('./tx2') class Note extends TX2 { constructor() { super() this.code = null this.group = null this.order = new Order() this.company = new Company() this.customer = new Customer() this.description = 'OBRIGADO PELA PREFERENCIA :)' } /** * @returns {Note} */ setCompany(company) { this.company = company return this } /** * @returns {Company} */ getCompany() { return this.company } /** * @param {String} code * @returns {Note} */ setCode(code) { this.code = code return this } /** * @returns {String} */ getCode() { return this.code } /** * @returns {Note} * @param {String} group */ setGroup(group) { this.group = group return this } /** * @returns {String} */ getGroup() { return this.group } /** * @returns {Note} * @param {Order} order */ setOrder(order) { this.order = order return this } /** * @returns {Order} */ getOrder() { return this.order } /** * @returns {Note} * @param {Customer} customer */ setCustomer(customer) { this.customer = customer return this } /** * @returns {Customer} */ getCustomer() { return this.customer } /** * @returns {Note} */ setDescription(description) { this.description = description return this } /** * @returns {String} */ getDescription() { return this.description } /** * @returns {String} */ toTX2() { const tx2 = [] // Define o formato tx2.push('formato=tx2') tx2.push('numlote=0') tx2.push('INCLUIR') // Informações gerais da NF tx2.push('dhEmi_B09=' + moment().format()) tx2.push('versao_A02=4.00') tx2.push('cNF_B03=667') tx2.push('natOp_B04=VENDA') tx2.push('mod_B06=65') tx2.push('serie_B07=10') tx2.push('nNF_B08=1') tx2.push('tpNF_B11=1') tx2.push('idDest_B11a=1') tx2.push('cMunFG_B12=4314407') tx2.push('tpImp_B21=4') tx2.push('tpEmis_B22=1') tx2.push('tpAmb_B24=1') tx2.push('finNFe_B25=1') tx2.push('indFinal_B25a=1') tx2.push('indPres_B25b=1') tx2.push('procEmi_B26=0') tx2.push('indIEDest_E16a=9') tx2.push('verProc_B27=MEZA DELIVERY 1.0.0') // Informações da Empresa Emissora tx2.push(this.getCompany().toTX2()) // Endereço da Empresa Emissora tx2.push(this.getCompany().getAddress().toTX2()) // Identificação do Consumidor PF/PJ tx2.push(this.getCustomer().toTX2()) // Itens da Nota Fiscal tx2.push(this.getOrder().toTX2()) // Informações de Contato de Tecnologia da Informação tx2.push('CNPJ_ZD02=34084235000120') tx2.push('xContato_ZD04=MEZA DIGITAL') tx2.push('email_ZD05=infrastructure@meza.digital') tx2.push('fone_ZD06=053981206186') // Finalizar tx2.push('infCpl_Z03=' + this.getDescription()) tx2.push('SALVAR') // Transforma tudo em TX2 return tx2.join('\n') } } module.exports = Note