|
@@ -72,7 +72,7 @@ function report_sales (reporting){
|
|
|
var self = this;
|
|
|
var defer = $.Deferred();
|
|
|
var Journal = new instance.web.Model('account.journal');
|
|
|
- Journal.query(['id', 'name']).filter([['type', '=', 'sale']]).all().then(function(results){
|
|
|
+ Journal.query(['id', 'name','timbrado']).filter([['type', '=', ['sale','sale_refund']]]).all().then(function(results){
|
|
|
defer.resolve(results);
|
|
|
});
|
|
|
return defer;
|
|
@@ -93,7 +93,7 @@ function report_sales (reporting){
|
|
|
var journal_ids = _.flatten(_.map(this.accountJournal, function (item) {
|
|
|
return item.id;
|
|
|
}));
|
|
|
- var filter =[['state', 'in',['open','paid']],['type', '=', 'out_invoice'],['journal_id', 'in',journal_ids]];
|
|
|
+ var filter =[['state', 'in',['open','paid']],['type', '=', ['out_invoice','out_refund']],['journal_id', 'in',journal_ids]];
|
|
|
var field =['id', 'type', 'number', 'origin', 'state', 'journal_id', 'currency_id', 'supplier_invoice_number','date_invoice','partner_id','amount_total','user_id','contado','credito','payment_term','period_id','amount_untaxed','amount_tax','attachment_ids'];
|
|
|
var defer = $.Deferred();
|
|
|
var Invoice = new instance.web.Model('account.invoice');
|
|
@@ -107,7 +107,7 @@ function report_sales (reporting){
|
|
|
var self = this;
|
|
|
var defer = $.Deferred();
|
|
|
var currency = new instance.web.Model('res.company');
|
|
|
- var field=['id', 'currency_id','exportador','agent_ruc','legal_agent','company_ruc','name'];
|
|
|
+ var field=['id', 'currency_id','exportador','agent_ruc','legal_agent','company_ruc','name','juridico'];
|
|
|
var domain=[['id','=',1]];
|
|
|
currency.query(field).filter(domain).all().then(function(results){
|
|
|
defer.resolve(results);
|
|
@@ -205,6 +205,14 @@ function report_sales (reporting){
|
|
|
return item.id === attachment_ids;
|
|
|
}).shift();
|
|
|
},
|
|
|
+
|
|
|
+ // Obtener el timbrado del diario
|
|
|
+ getJournal : function(journal_id){
|
|
|
+ var self = this;
|
|
|
+ return _.filter(self.accountJournal,function(item){
|
|
|
+ return item.id === journal_id;
|
|
|
+ }).shift();
|
|
|
+ },
|
|
|
// unir los objetos
|
|
|
fect_generar: function(invoices){
|
|
|
var self = this;
|
|
@@ -213,7 +221,7 @@ function report_sales (reporting){
|
|
|
var customer_ruc;
|
|
|
var ruc;
|
|
|
var cuota;
|
|
|
- var cuotaII;
|
|
|
+ var tipo;
|
|
|
var total;
|
|
|
var tasa_10;
|
|
|
var tasa_5;
|
|
@@ -227,7 +235,11 @@ function report_sales (reporting){
|
|
|
var contador = 0;
|
|
|
var icons = 0;
|
|
|
var imagen;
|
|
|
+ var valor_timbrado;
|
|
|
_.each(invoices, function(invoice){
|
|
|
+ // Obtener el timbrado desde el journal
|
|
|
+ valor_timbrado = self.getJournal(invoice.journal_id[0]);
|
|
|
+
|
|
|
// obtener el ruc y el DV del cliente
|
|
|
customer_ruc = self.getCustomer(invoice.partner_id[0]);
|
|
|
ruc = customer_ruc.ruc.split("-");
|
|
@@ -236,9 +248,14 @@ function report_sales (reporting){
|
|
|
if (invoice.credito == true){
|
|
|
condicion = 2;
|
|
|
}
|
|
|
+ // Determinar el tipo de factura.
|
|
|
+ if(invoice.type == 'out_invoice'){
|
|
|
+ tipo = 1;
|
|
|
+ }else{
|
|
|
+ tipo = 3;
|
|
|
+ }
|
|
|
// Determinar la cantidad de cuotas
|
|
|
cuota = _.flatten(self.getPaymentTerm(invoice.payment_term[0])).length - 2;
|
|
|
- // cuotaII = (cuota.length - 2);
|
|
|
if (condicion == 1 || cuota < 1){
|
|
|
cuota = 0;
|
|
|
}
|
|
@@ -289,7 +306,7 @@ function report_sales (reporting){
|
|
|
ruc_cliente: ruc[0],
|
|
|
dv: ruc[1],
|
|
|
partner: invoice.partner_id[1],
|
|
|
- tipo_documento : 1,
|
|
|
+ tipo_documento : tipo,
|
|
|
numero_documento : invoice.number,
|
|
|
date: moment(invoice.date_invoice).format("DD/MM/YYYY"),
|
|
|
tasa_10 : tasa_10,
|
|
@@ -300,14 +317,13 @@ function report_sales (reporting){
|
|
|
total : total,
|
|
|
condicion_venta : condicion,
|
|
|
cantidad_cuotas : cuota,
|
|
|
- number: invoice.number,
|
|
|
+ number: self.valorNull(valor_timbrado.timbrado),
|
|
|
// informacion del periodo
|
|
|
period_id : invoice.period_id[0],
|
|
|
period_name : invoice.period_id[1],
|
|
|
attachment_ids : adjunto,
|
|
|
download_icon : icons,
|
|
|
- });
|
|
|
-
|
|
|
+ });
|
|
|
});
|
|
|
self.newInvoice = data;
|
|
|
this.loadTable(data);
|
|
@@ -319,16 +335,31 @@ function report_sales (reporting){
|
|
|
var datos = [];
|
|
|
var periodo;
|
|
|
var company_ruc;
|
|
|
- var agent_ruc;
|
|
|
+ var agent;
|
|
|
var version = 2;
|
|
|
var total = 0;
|
|
|
var cantidad = 0;
|
|
|
var valor = 0;
|
|
|
var periodo;
|
|
|
- var period =this.$el.find('#current-period').val();
|
|
|
+ var tipo = 1;
|
|
|
+ var ruc_agente = 0;
|
|
|
+ var dv_agente = 0;
|
|
|
+ var nombre_agente = 0;
|
|
|
+ var period = this.$el.find('#current-period').val();
|
|
|
+ var rectificativa = $('#rectificativa').is(":checked");
|
|
|
+ if(rectificativa){
|
|
|
+ tipo = 2;
|
|
|
+ }
|
|
|
_.each(resCompanys, function(resCompany){
|
|
|
+ // Obtener el RUC y el DV de la compania
|
|
|
company_ruc = resCompany.company_ruc.split("-");
|
|
|
- agent_ruc = resCompany.agent_ruc.split("-");
|
|
|
+ // Verificar si es una persona fisica o juridica
|
|
|
+ if(resCompany.juridico == true){
|
|
|
+ agent = resCompany.agent_ruc.split("-");
|
|
|
+ ruc_agente = agent[0];
|
|
|
+ dv_agente = agent[1];
|
|
|
+ nombre_agente = resCompany.legal_agent;
|
|
|
+ }
|
|
|
// Tipo de registro
|
|
|
datos.push(1);
|
|
|
datos.push('\t');
|
|
@@ -336,7 +367,7 @@ function report_sales (reporting){
|
|
|
datos.push(201708);
|
|
|
datos.push('\t');
|
|
|
// Tipo de reporte
|
|
|
- datos.push(1);
|
|
|
+ datos.push(tipo);
|
|
|
datos.push('\t');
|
|
|
// Codigo Obligacion
|
|
|
datos.push(911);
|
|
@@ -354,13 +385,13 @@ function report_sales (reporting){
|
|
|
datos.push(resCompany.name);
|
|
|
datos.push('\t');
|
|
|
// Ruc representante legal
|
|
|
- datos.push(agent_ruc[0]);
|
|
|
+ datos.push(ruc_agente);
|
|
|
datos.push('\t');
|
|
|
// DV representante legal
|
|
|
- datos.push(agent_ruc[1]);
|
|
|
+ datos.push(dv_agente);
|
|
|
datos.push('\t');
|
|
|
// Nombre y apellido de representante legal
|
|
|
- datos.push(resCompany.legal_agent);
|
|
|
+ datos.push(nombre_agente);
|
|
|
datos.push('\t');
|
|
|
// Cantidad de registros
|
|
|
datos.push(50);
|