|
@@ -1,6 +1,6 @@
|
|
|
function report_sales (reporting){
|
|
|
"use strict";
|
|
|
-
|
|
|
+
|
|
|
var instance = openerp;
|
|
|
|
|
|
reporting.ReportSalesWidget = reporting.Base.extend({
|
|
@@ -10,7 +10,7 @@ function report_sales (reporting){
|
|
|
resCurrency :[],
|
|
|
resCompany:[],
|
|
|
accountJournal:[],
|
|
|
- customer:[],
|
|
|
+ customer:[],
|
|
|
newInvoice:[],
|
|
|
rowsData :[],
|
|
|
|
|
@@ -161,7 +161,7 @@ function report_sales (reporting){
|
|
|
return item.id === partner_id;
|
|
|
}).shift();
|
|
|
},
|
|
|
-
|
|
|
+
|
|
|
getPaymentTerm : function(id){
|
|
|
var self = this;
|
|
|
return _.filter(self.paymentTerm,function(item){
|
|
@@ -207,12 +207,16 @@ function report_sales (reporting){
|
|
|
var imagen;
|
|
|
var valor_timbrado;
|
|
|
_.each(invoices, function(invoice){
|
|
|
+
|
|
|
|
|
|
valor_timbrado = self.getJournal(invoice.journal_id[0]);
|
|
|
|
|
|
|
|
|
customer_ruc = self.getCustomer(invoice.partner_id[0]);
|
|
|
- ruc = customer_ruc.ruc.split("-");
|
|
|
+ if(customer_ruc.ruc){
|
|
|
+ ruc = customer_ruc.ruc.split("-");
|
|
|
+ }
|
|
|
+
|
|
|
|
|
|
if(invoice.type == 'out_invoice'){
|
|
|
tipo = 1;
|
|
@@ -244,12 +248,12 @@ function report_sales (reporting){
|
|
|
tasa_5 = 0;
|
|
|
|
|
|
if(invoice.amount_total == invoice.amount_untaxed){
|
|
|
- untaxed = accounting.formatNumber(invoice.amount_untaxed,"","");
|
|
|
+ untaxed = accounting.formatNumber(invoice.amount_untaxed,"","");
|
|
|
}else{
|
|
|
|
|
|
if(IVA == TAX){
|
|
|
iva_10 = accounting.formatNumber(invoice.amount_tax,"","");;
|
|
|
- tasa_10 = accounting.formatNumber(invoice.amount_untaxed,"","");
|
|
|
+ tasa_10 = accounting.formatNumber(invoice.amount_untaxed,"","");
|
|
|
}else{
|
|
|
iva_5 = accounting.formatNumber(invoice.amount_tax,"","");;
|
|
|
tasa_5 = accounting.formatNumber(invoice.amount_untaxed,"","");
|
|
@@ -266,11 +270,11 @@ function report_sales (reporting){
|
|
|
icons = '<a class="" href="javascript:void(0)" title="Descarga no disponible"><i class="fa fa-file fa-lg" aria-hidden="true"></i></a> <a class="" href="javascript:void(0)" title="Vista previa no disponible"><i class="fa fa-eye-slash fa-lg" aria-hidden="true"></i></a>';
|
|
|
}else{
|
|
|
if(imagen[1]=='image/png' || imagen[1]=='image/jpeg'){
|
|
|
- icons = '<a class="download" href="javascript:void(0)" title="Descargar"><i class="fa fa-download fa-lg" aria-hidden="true"></i></a> <a class="preview" title="Vista previa"><i class="fa fa-eye fa-lg" aria-hidden="true"></i></a>';
|
|
|
+ icons = '<a class="download" href="javascript:void(0)" title="Descargar"><i class="fa fa-download fa-lg" aria-hidden="true"></i></a> <a class="preview" title="Vista previa"><i class="fa fa-eye fa-lg" aria-hidden="true"></i></a>';
|
|
|
}else{
|
|
|
icons = '<a class="download" href="javascript:void(0)" title="Descargar"><i class="fa fa-download fa-lg" aria-hidden="true"></i></a> <a class="" href="javascript:void(0)" title="Vista previa no disponible"><i class="fa fa-eye-slash fa-lg" aria-hidden="true"></i></a>';
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
}
|
|
|
|
|
|
contador += 1;
|
|
@@ -298,7 +302,7 @@ function report_sales (reporting){
|
|
|
period_name : invoice.period_id[1],
|
|
|
attachment_ids : adjunto,
|
|
|
download_icon : icons,
|
|
|
- });
|
|
|
+ });
|
|
|
});
|
|
|
self.newInvoice = data;
|
|
|
this.loadTable(data);
|
|
@@ -327,7 +331,12 @@ function report_sales (reporting){
|
|
|
}
|
|
|
_.each(resCompanys, function(resCompany){
|
|
|
|
|
|
- company_ruc = resCompany.company_ruc.split("-");
|
|
|
+ if(resCompany.ruc){
|
|
|
+ company_ruc = resCompany.company_ruc.split("-");
|
|
|
+ }else {
|
|
|
+
|
|
|
+ company_ruc = ""
|
|
|
+ }
|
|
|
|
|
|
if(resCompany.juridico == true){
|
|
|
agent = resCompany.agent_ruc.split("-");
|
|
@@ -376,7 +385,7 @@ function report_sales (reporting){
|
|
|
datos.push('\t');
|
|
|
|
|
|
datos.push(version);
|
|
|
- datos.push('\r\n');
|
|
|
+ datos.push('\r\n');
|
|
|
});
|
|
|
|
|
|
var customer_ruc;
|
|
@@ -402,7 +411,7 @@ function report_sales (reporting){
|
|
|
datos.push('\t');
|
|
|
|
|
|
datos.push(newInvoice.ruc_cliente);
|
|
|
- datos.push('\t');
|
|
|
+ datos.push('\t');
|
|
|
|
|
|
datos.push(newInvoice.dv);
|
|
|
datos.push('\t');
|
|
@@ -411,7 +420,7 @@ function report_sales (reporting){
|
|
|
datos.push('\t');
|
|
|
|
|
|
datos.push(newInvoice.tipo_documento);
|
|
|
- datos.push('\t');
|
|
|
+ datos.push('\t');
|
|
|
|
|
|
datos.push(newInvoice.numero_documento);
|
|
|
datos.push('\t');
|
|
@@ -447,8 +456,8 @@ function report_sales (reporting){
|
|
|
datos.push('\r\n');
|
|
|
cantidad += 1;
|
|
|
ingreso += parseInt(newInvoice.total);
|
|
|
- periodo = newInvoice.period_name.split("/");
|
|
|
- }
|
|
|
+ periodo = newInvoice.period_name.split("/");
|
|
|
+ }
|
|
|
});
|
|
|
datos.splice(2,0);
|
|
|
datos[2] = periodo[1] + periodo[0];
|
|
@@ -456,7 +465,7 @@ function report_sales (reporting){
|
|
|
datos[22] = cantidad;
|
|
|
datos.splice(24,0);
|
|
|
datos[24] = ingreso;
|
|
|
-
|
|
|
+
|
|
|
self.newCabecera = new Blob(datos, {type: 'text/plain'});
|
|
|
},
|
|
|
|
|
@@ -480,7 +489,7 @@ function report_sales (reporting){
|
|
|
var table = this.$el.find('#table');
|
|
|
table.bootstrapTable('load',rowsTable);
|
|
|
},
|
|
|
-
|
|
|
+
|
|
|
|
|
|
generarTxt: function () {
|
|
|
var self = this;
|
|
@@ -497,7 +506,7 @@ function report_sales (reporting){
|
|
|
download(self.newCabecera, fileName, "text/plain");
|
|
|
}else{
|
|
|
self.showMensajeRegistro();
|
|
|
- }
|
|
|
+ }
|
|
|
}else{
|
|
|
self.showMensaje();
|
|
|
}
|
|
@@ -513,7 +522,7 @@ function report_sales (reporting){
|
|
|
var dato = newInvoice[orden - 1].attachment_ids;
|
|
|
download("data:"+dato.file_type+";base64,"+dato.datas+"",dato.name,dato.file_type);
|
|
|
},
|
|
|
-
|
|
|
+
|
|
|
previewAttachment: function (e) {
|
|
|
var self = this;
|
|
|
var newInvoice = self.newInvoice;
|
|
@@ -586,4 +595,4 @@ function report_sales (reporting){
|
|
|
return
|
|
|
},
|
|
|
});
|
|
|
-}
|
|
|
+}
|