|
@@ -64,7 +64,7 @@ function report_sales (reporting){
|
|
|
return self.fect_generar(self.invoice);
|
|
|
}).then(function(currency){
|
|
|
self.currency = currency;
|
|
|
- return self.fect_cabecera(self.resCompany, self.invoice);
|
|
|
+ // return self.fect_cabecera(self.resCompany, self.invoice);
|
|
|
});
|
|
|
},
|
|
|
// Buscar Diario
|
|
@@ -317,10 +317,15 @@ function report_sales (reporting){
|
|
|
var self = this;
|
|
|
// Cabecera
|
|
|
var datos = [];
|
|
|
- var periodo =(this.$el.find('#from').val());
|
|
|
+ var periodo;
|
|
|
var company_ruc;
|
|
|
var agent_ruc;
|
|
|
var version = 2;
|
|
|
+ var total = 0;
|
|
|
+ var cantidad = 0;
|
|
|
+ var valor = 0;
|
|
|
+ var periodo;
|
|
|
+ var period =this.$el.find('#current-period').val();
|
|
|
_.each(resCompanys, function(resCompany){
|
|
|
company_ruc = resCompany.company_ruc.split("-");
|
|
|
agent_ruc = resCompany.agent_ruc.split("-");
|
|
@@ -328,7 +333,7 @@ function report_sales (reporting){
|
|
|
datos.push(1);
|
|
|
datos.push('\t');
|
|
|
// Periodo
|
|
|
- datos.push(moment(periodo).format("YYYYMM"));
|
|
|
+ datos.push(201708);
|
|
|
datos.push('\t');
|
|
|
// Tipo de reporte
|
|
|
datos.push(1);
|
|
@@ -380,99 +385,67 @@ function report_sales (reporting){
|
|
|
var iva_10 = 0;
|
|
|
var IVA = 0;
|
|
|
var TAX = 0;
|
|
|
- var total = 0;
|
|
|
var valor = 0;
|
|
|
var condicion;
|
|
|
var untaxed;
|
|
|
var ingreso = 0;
|
|
|
- _.each(invoices, function(invoice){
|
|
|
- // obtener el ruc y el DV del cliente
|
|
|
- customer_ruc = self.getCustomer(invoice.partner_id[0]);
|
|
|
- ruc = customer_ruc.ruc.split("-");
|
|
|
- // Determinar si la factura es a credito o al contado
|
|
|
- condicion = 1;
|
|
|
- if (invoice.credito == true){
|
|
|
- condicion = 2;
|
|
|
- }
|
|
|
- // Determinar la cantidad de cuotas
|
|
|
- cuota = _.flatten(self.getPaymentTerm(invoice.payment_term[0])).length - 2;
|
|
|
- if (condicion == 1 || cuota < 1){
|
|
|
- cuota = 0;
|
|
|
- }
|
|
|
- // Manejo de impuestos
|
|
|
- IVA = accounting.formatNumber(((invoice.amount_untaxed * 10)/100),"","");
|
|
|
- TAX = accounting.formatNumber(invoice.amount_tax,"","");
|
|
|
- untaxed = 0;
|
|
|
- iva_5 = 0;
|
|
|
- iva_10 = 0;
|
|
|
- tasa_10 = 0;
|
|
|
- tasa_5 = 0;
|
|
|
- // Determinar si fue aplicado algun impuesto a la factura.
|
|
|
- if(invoice.amount_total == invoice.amount_untaxed){
|
|
|
- untaxed = accounting.formatNumber(invoice.amount_untaxed,"","");
|
|
|
- }else{
|
|
|
- // Si fue aplicado impuesto, determina si fue de 10% o 5%.
|
|
|
- if(IVA == TAX){
|
|
|
- iva_10 = accounting.formatNumber(invoice.amount_tax,"","");;
|
|
|
- tasa_10 = accounting.formatNumber(invoice.amount_untaxed,"","");
|
|
|
- }else{
|
|
|
- iva_5 = accounting.formatNumber(invoice.amount_tax,"","");;
|
|
|
- tasa_5 = accounting.formatNumber(invoice.amount_untaxed,"","");
|
|
|
- }
|
|
|
- }
|
|
|
- total = 0;
|
|
|
- total = parseInt(tasa_10) + parseInt(iva_10) + parseInt(tasa_5) + parseInt(iva_5) + parseInt(untaxed);
|
|
|
- // tipo de registro
|
|
|
- datos.push(2);
|
|
|
- datos.push('\t');
|
|
|
- // ruc del cliente
|
|
|
- datos.push(ruc[0]);
|
|
|
- datos.push('\t');
|
|
|
- // dv del cliente
|
|
|
- datos.push(ruc[1]);
|
|
|
- datos.push('\t');
|
|
|
- // Nombre o denominacion del cliente
|
|
|
- datos.push(invoice.partner_id[1]);
|
|
|
- datos.push('\t');
|
|
|
- // tipo de documento
|
|
|
- datos.push(1);
|
|
|
- datos.push('\t');
|
|
|
- // Numero de documento
|
|
|
- datos.push(invoice.number);
|
|
|
- datos.push('\t');
|
|
|
- // Fecha de documento
|
|
|
- datos.push(moment(invoice.date_invoice).format("DD/MM/YYYY"));
|
|
|
- datos.push('\t');
|
|
|
- // Monto de la venta a la tasa 10%
|
|
|
- datos.push(tasa_10);
|
|
|
- datos.push('\t');
|
|
|
- // IVA debito 10%
|
|
|
- datos.push(iva_10);
|
|
|
- datos.push('\t');
|
|
|
- // Monto de la venta a la tasa 5%
|
|
|
- datos.push(tasa_5);
|
|
|
- datos.push('\t');
|
|
|
- // IVA debito 5%
|
|
|
- datos.push(iva_5);
|
|
|
- datos.push('\t');
|
|
|
- // Monto de la venta no gravada o exenta
|
|
|
- datos.push(untaxed);
|
|
|
- datos.push('\t');
|
|
|
- // Monto del ingreso
|
|
|
- datos.push(total);
|
|
|
- datos.push('\t');
|
|
|
- // Condicion de venta
|
|
|
- datos.push(condicion);
|
|
|
- datos.push('\t');
|
|
|
- // Cantidad de cuotas
|
|
|
- datos.push(cuota);
|
|
|
- datos.push('\t');
|
|
|
- // Numero de timbrado
|
|
|
- datos.push(invoice.number);
|
|
|
- datos.push('\r\n');
|
|
|
- cantidad += 1;
|
|
|
- ingreso += total;
|
|
|
+ _.each(invoices, function(newInvoice){
|
|
|
+ if(newInvoice.period_id == period){
|
|
|
+ // tipo de registro
|
|
|
+ datos.push(newInvoice.tipo_registro);
|
|
|
+ datos.push('\t');
|
|
|
+ // ruc del cliente
|
|
|
+ datos.push(newInvoice.ruc_cliente);
|
|
|
+ datos.push('\t');
|
|
|
+ // dv del cliente
|
|
|
+ datos.push(newInvoice.dv);
|
|
|
+ datos.push('\t');
|
|
|
+ // Nombre o denominacion del cliente
|
|
|
+ datos.push(newInvoice.partner);
|
|
|
+ datos.push('\t');
|
|
|
+ // tipo de documento
|
|
|
+ datos.push(newInvoice.tipo_documento);
|
|
|
+ datos.push('\t');
|
|
|
+ // Numero de documento
|
|
|
+ datos.push(newInvoice.numero_documento);
|
|
|
+ datos.push('\t');
|
|
|
+ // Fecha de documento
|
|
|
+ datos.push(newInvoice.date);
|
|
|
+ datos.push('\t');
|
|
|
+ // Monto de la venta a la tasa 10%
|
|
|
+ datos.push(newInvoice.tasa_10);
|
|
|
+ datos.push('\t');
|
|
|
+ // IVA debito 10%
|
|
|
+ datos.push(newInvoice.iva_10);
|
|
|
+ datos.push('\t');
|
|
|
+ // Monto de la venta a la tasa 5%
|
|
|
+ datos.push(newInvoice.tasa_5);
|
|
|
+ datos.push('\t');
|
|
|
+ // IVA debito 5%
|
|
|
+ datos.push(newInvoice.iva_5);
|
|
|
+ datos.push('\t');
|
|
|
+ // Monto de la venta no gravada o exenta
|
|
|
+ datos.push(newInvoice.amount);
|
|
|
+ datos.push('\t');
|
|
|
+ // Monto del ingreso
|
|
|
+ datos.push(newInvoice.total);
|
|
|
+ datos.push('\t');
|
|
|
+ // Condicion de venta
|
|
|
+ datos.push(newInvoice.condicion_venta);
|
|
|
+ datos.push('\t');
|
|
|
+ // Cantidad de cuotas
|
|
|
+ datos.push(newInvoice.cantidad_cuotas);
|
|
|
+ datos.push('\t');
|
|
|
+ // Numero de timbrado
|
|
|
+ datos.push(newInvoice.number);
|
|
|
+ datos.push('\r\n');
|
|
|
+ cantidad += 1;
|
|
|
+ ingreso += parseInt(newInvoice.total);
|
|
|
+ periodo = newInvoice.period_name.split("/");
|
|
|
+ }
|
|
|
});
|
|
|
+ datos.splice(2,0);
|
|
|
+ datos[2] = periodo[1] + periodo[0];
|
|
|
datos.splice(22,0);
|
|
|
datos[22] = cantidad;
|
|
|
datos.splice(24,0);
|
|
@@ -500,13 +473,29 @@ function report_sales (reporting){
|
|
|
var table = this.$el.find('#table');
|
|
|
table.bootstrapTable('load',rowsTable);
|
|
|
},
|
|
|
+
|
|
|
// Genera el archivo txt, con el nombre correspondiente
|
|
|
generarTxt: function () {
|
|
|
var self = this;
|
|
|
- var periodo = self.newInvoice[0].period_name.split("/");
|
|
|
- var fileName = "Ventas " + periodo[1] + periodo[0];
|
|
|
- download(self.newCabecera, fileName, "text/plain");
|
|
|
+ var newInvoice = self.newInvoice;
|
|
|
+ var period =this.$el.find('#current-period').val();
|
|
|
+ if (period != 9999999){
|
|
|
+ newInvoice=_.filter(newInvoice, function (inv){
|
|
|
+ return inv.period_id == period;
|
|
|
+ });
|
|
|
+ if(newInvoice.length != 0){
|
|
|
+ var periodo = newInvoice[0].period_name.split("/");
|
|
|
+ var fileName = "Ventas " + periodo[1] + periodo[0];
|
|
|
+ self.fect_cabecera(self.resCompany, self.newInvoice);
|
|
|
+ download(self.newCabecera, fileName, "text/plain");
|
|
|
+ }else{
|
|
|
+ alert('No hay registros para importar');
|
|
|
+ }
|
|
|
+ }else{
|
|
|
+ alert('Debe elegir un periodo');
|
|
|
+ }
|
|
|
},
|
|
|
+
|
|
|
// Descargar el archivo adjunto
|
|
|
downloadAttachment: function (e) {
|
|
|
var self = this;
|