|
@@ -10,6 +10,7 @@ function report_sales_invoice_analysis (reporting){
|
|
|
productProduct:[],
|
|
|
Currency:[],
|
|
|
rowsData :[],
|
|
|
+ content :[],
|
|
|
rowOrigin:[],
|
|
|
accountJournal:[],
|
|
|
resCompany:[],
|
|
@@ -31,9 +32,9 @@ function report_sales_invoice_analysis (reporting){
|
|
|
this._super(parent);
|
|
|
},
|
|
|
start: function () {
|
|
|
-
|
|
|
+ var self = this;
|
|
|
var table = this.$el.find('#table');
|
|
|
- table.bootstrapTable({data : self.rowOrigin});
|
|
|
+ table.bootstrapTable({data : self.rowsData});
|
|
|
this.fecthFecha();
|
|
|
this.submitForm();
|
|
|
},
|
|
@@ -159,6 +160,66 @@ function report_sales_invoice_analysis (reporting){
|
|
|
return defer;
|
|
|
},
|
|
|
|
|
|
+ valorNull:function(dato){
|
|
|
+ var valor ="";
|
|
|
+ if (dato){
|
|
|
+ valor=dato;
|
|
|
+ }
|
|
|
+ return valor;
|
|
|
+ },
|
|
|
+
|
|
|
+ search: function () {
|
|
|
+ var self = this;
|
|
|
+ var results = self.ResPartner;
|
|
|
+ results = _.map(results, function (item) {
|
|
|
+ return {
|
|
|
+ label: item.id + '-'+ item.name + ' ' + self.valorNull(item.ruc),
|
|
|
+ value: item.id + '-'+ item.name + ' ' + self.valorNull(item.ruc)
|
|
|
+ }
|
|
|
+ });
|
|
|
+ self.$('#partner').autocomplete({
|
|
|
+ source: results,
|
|
|
+ minLength:0,
|
|
|
+ search: function(event, ui) {
|
|
|
+ if (!(self.$('#partner').val())){
|
|
|
+ self.fectSearch();
|
|
|
+ }
|
|
|
+ },
|
|
|
+ close: function( event, ui ) {
|
|
|
+ self.fectSearch();
|
|
|
+ },
|
|
|
+ select: function(event, ui) {
|
|
|
+ self.fectSearch();
|
|
|
+ }
|
|
|
+ });
|
|
|
+ },
|
|
|
+
|
|
|
+ searchProduct: function () {
|
|
|
+ var self = this;
|
|
|
+ var results = self.productProduct;
|
|
|
+ results = _.map(results, function (item) {
|
|
|
+ return {
|
|
|
+ label: item.id + '- '+ ' [ ' + self.valorNull(item.default_code) + ' - ' + self.valorNull(item.ean13) + ' ] ' + item.name + ' ( ' + self.valorNull(item.attribute_str) + ' ) ' ,
|
|
|
+ value: item.id + '- '+ ' [ ' + self.valorNull(item.default_code) + ' - ' + self.valorNull(item.ean13) + ' ] ' + item.name + ' ( ' + self.valorNull(item.attribute_str) + ' ) '
|
|
|
+ }
|
|
|
+ });
|
|
|
+ self.$('#product').autocomplete({
|
|
|
+ source: results,
|
|
|
+ minLength:0,
|
|
|
+ search: function(event, ui) {
|
|
|
+ if (!(self.$('#product').val())){
|
|
|
+ self.fectSearch();
|
|
|
+ }
|
|
|
+ },
|
|
|
+ close: function( event, ui ) {
|
|
|
+ self.fectSearch();
|
|
|
+ },
|
|
|
+ select: function(event, ui) {
|
|
|
+ self.fectSearch();
|
|
|
+ }
|
|
|
+ });
|
|
|
+ },
|
|
|
+
|
|
|
fecthAccountJournal: function(){
|
|
|
var self = this;
|
|
|
var defer = $.Deferred();
|
|
@@ -333,7 +394,7 @@ function report_sales_invoice_analysis (reporting){
|
|
|
price_tot_tot : ((item.quantity * (item.price_unit / invoice.rate))),
|
|
|
standar_tot_tot : ((item.quantity * producto.standard_price)),
|
|
|
utility_tot : (((item.quantity * (item.price_unit / invoice.rate)) - (item.quantity * producto.standard_price))),
|
|
|
- date_create :moment(invoice.date_invoice).format("DD/MM/YYYY HH:mm"),
|
|
|
+ date_create :moment(invoice.date_invoice).format("DD/MM/YYYY"),
|
|
|
date_invoice : (invoice.date_invoice),
|
|
|
partner_id : invoice.partner_id[0],
|
|
|
partner_name : invoice.partner_id[1],
|
|
@@ -342,9 +403,8 @@ function report_sales_invoice_analysis (reporting){
|
|
|
}
|
|
|
|
|
|
}
|
|
|
- this.rowsData=data;
|
|
|
- this.rowOrigin=data;
|
|
|
- this.loadTable(data)
|
|
|
+ self.content = data;
|
|
|
+ this.loadTable(data);
|
|
|
},
|
|
|
|
|
|
fectSearch: function(){
|
|
@@ -358,25 +418,25 @@ function report_sales_invoice_analysis (reporting){
|
|
|
var desde =this.$el.find('#from').val();
|
|
|
var hasta =this.$el.find('#to').val();
|
|
|
var store = this.$el.find('#current-store').val();
|
|
|
- self.rowsData=self.rowOrigin;
|
|
|
+ var content = self.content;
|
|
|
|
|
|
if ($('#A').is(":checked")){
|
|
|
- self.rowsData = _.filter(self.rowsData, function (inv){
|
|
|
+ content = _.filter(content, function (inv){
|
|
|
return moment(inv.date_invoice).format('YYYY-MM-DD') == today;
|
|
|
});
|
|
|
}
|
|
|
if ($('#B').is(":checked")){
|
|
|
- self.rowsData = _.filter(self.rowsData, function (inv){
|
|
|
+ content = _.filter(content, function (inv){
|
|
|
return moment(inv.date_invoice).format('YYYY-MM-DD') == yesterday;
|
|
|
});
|
|
|
}
|
|
|
if ($('#C').is(":checked")){
|
|
|
- self.rowsData = _.filter(self.rowsData, function (inv){
|
|
|
+ content = _.filter(content, function (inv){
|
|
|
return moment(inv.date_invoice).format('YYYY-MM') == month;
|
|
|
});
|
|
|
}
|
|
|
if ($('#D').is(":checked")){
|
|
|
- self.rowsData = _.filter(self.rowsData, function (inv){
|
|
|
+ content = _.filter(content, function (inv){
|
|
|
return moment(inv.date_invoice).format('YYYY-MM') == last_month;
|
|
|
});
|
|
|
}
|
|
@@ -385,13 +445,13 @@ function report_sales_invoice_analysis (reporting){
|
|
|
$('#datepicker').css('display','block');
|
|
|
if (desde.length > 0){
|
|
|
var date= desde.split('/');
|
|
|
- self.rowsData = _.filter(self.rowsData, function (inv){
|
|
|
+ content = _.filter(content, function (inv){
|
|
|
return inv.date_invoice >= (date[2]+"-"+date[1]+"-"+date[0]);
|
|
|
});
|
|
|
}
|
|
|
if (hasta.length > 0){
|
|
|
var date= hasta.split('/');
|
|
|
- self.rowsData = _.filter(self.rowsData, function (inv){
|
|
|
+ content = _.filter(content, function (inv){
|
|
|
return inv.date_invoice <= (date[2]+"-"+date[1]+"-"+date[0]);
|
|
|
});
|
|
|
}
|
|
@@ -399,47 +459,47 @@ function report_sales_invoice_analysis (reporting){
|
|
|
$('#datepicker').css('display','none');
|
|
|
}
|
|
|
if (partner != ""){
|
|
|
- self.rowsData = _.filter(self.rowsData, function(inv){
|
|
|
+ content = _.filter(content, function(inv){
|
|
|
return inv.partner_id == partner[0];
|
|
|
});
|
|
|
}
|
|
|
if (product != ""){
|
|
|
- self.rowsData = _.filter(self.rowsData, function(inv){
|
|
|
+ content = _.filter(content, function(inv){
|
|
|
return inv.id_product == product[0];
|
|
|
});
|
|
|
}
|
|
|
|
|
|
if(store != 9999999){
|
|
|
- self.rowsData =_.filter(self.rowsData, function (inv){
|
|
|
+ content =_.filter(content, function (inv){
|
|
|
return inv.store_id == store;
|
|
|
});
|
|
|
}
|
|
|
|
|
|
- var quantity_tot_total = _.reduce(_.map(self.rowsData,function(map){
|
|
|
+ var quantity_tot_total = _.reduce(_.map(content,function(map){
|
|
|
return(map.quantity_tot);
|
|
|
}),function(memo, num){
|
|
|
return memo + num;
|
|
|
},0);
|
|
|
|
|
|
- var price_total_total = _.reduce(_.map(self.rowsData,function(map){
|
|
|
+ var price_total_total = _.reduce(_.map(content,function(map){
|
|
|
return(map.price_tot_tot);
|
|
|
}),function(memo, num){
|
|
|
return memo + num;
|
|
|
},0);
|
|
|
|
|
|
- var standar_total_total = _.reduce(_.map(self.rowsData,function(map){
|
|
|
+ var standar_total_total = _.reduce(_.map(content,function(map){
|
|
|
return(map.standar_tot_tot);
|
|
|
}),function(memo, num){
|
|
|
return memo + num;
|
|
|
},0);
|
|
|
|
|
|
- var amount_total_total = _.reduce(_.map(self.rowsData,function(map){
|
|
|
+ var amount_total_total = _.reduce(_.map(content,function(map){
|
|
|
return(map.utility);
|
|
|
}),function(memo, num){
|
|
|
return memo + num;
|
|
|
},0);
|
|
|
|
|
|
- self.rowsData.push({
|
|
|
+ content.push({
|
|
|
number: "Totales:",
|
|
|
quantity: accounting.formatNumber((quantity_tot_total),0,".",","),
|
|
|
price_tot: accounting.formatNumber((price_total_total),0,".",","),
|
|
@@ -447,84 +507,35 @@ function report_sales_invoice_analysis (reporting){
|
|
|
utility: accounting.formatNumber((amount_total_total),0,".",","),
|
|
|
});
|
|
|
|
|
|
- self.loadTable(self.rowsData);
|
|
|
- },
|
|
|
-
|
|
|
- valorNull:function(dato){
|
|
|
- var valor ="";
|
|
|
- if (dato){
|
|
|
- valor=dato;
|
|
|
- }
|
|
|
- return valor;
|
|
|
+ self.loadTable(content)
|
|
|
},
|
|
|
|
|
|
- search: function () {
|
|
|
+ loadTable:function(rowsTable){
|
|
|
var self = this;
|
|
|
- var results = self.ResPartner;
|
|
|
- results = _.map(results, function (item) {
|
|
|
- return {
|
|
|
- label: item.id + '-'+ item.name + ' ' + self.valorNull(item.ruc),
|
|
|
- value: item.id + '-'+ item.name + ' ' + self.valorNull(item.ruc)
|
|
|
- }
|
|
|
- });
|
|
|
- self.$('#partner').autocomplete({
|
|
|
- source: results,
|
|
|
- minLength:0,
|
|
|
- search: function(event, ui) {
|
|
|
- if (!(self.$('#partner').val())){
|
|
|
- self.fectSearch();
|
|
|
- }
|
|
|
- },
|
|
|
- close: function( event, ui ) {
|
|
|
- self.fectSearch();
|
|
|
- },
|
|
|
- select: function(event, ui) {
|
|
|
- self.fectSearch();
|
|
|
- }
|
|
|
- });
|
|
|
+ self.rowsData = rowsTable;
|
|
|
+ var table = this.$el.find('#table');
|
|
|
+ table.bootstrapTable('load', rowsTable);
|
|
|
},
|
|
|
|
|
|
- searchProduct: function () {
|
|
|
+ getObjetPdf: function(rowsTable){
|
|
|
var self = this;
|
|
|
- var results = self.productProduct;
|
|
|
- results = _.map(results, function (item) {
|
|
|
- return {
|
|
|
- label: item.id + '- '+ ' [ ' + self.valorNull(item.default_code) + ' - ' + self.valorNull(item.ean13) + ' ] ' + item.name + ' ( ' + self.valorNull(item.attribute_str) + ' ) ' ,
|
|
|
- value: item.id + '- '+ ' [ ' + self.valorNull(item.default_code) + ' - ' + self.valorNull(item.ean13) + ' ] ' + item.name + ' ( ' + self.valorNull(item.attribute_str) + ' ) '
|
|
|
- }
|
|
|
- });
|
|
|
- self.$('#product').autocomplete({
|
|
|
- source: results,
|
|
|
- minLength:0,
|
|
|
- search: function(event, ui) {
|
|
|
- if (!(self.$('#product').val())){
|
|
|
- self.fectSearch();
|
|
|
- }
|
|
|
- },
|
|
|
- close: function( event, ui ) {
|
|
|
- self.fectSearch();
|
|
|
- },
|
|
|
- select: function(event, ui) {
|
|
|
- self.fectSearch();
|
|
|
- }
|
|
|
- });
|
|
|
- },
|
|
|
+ var rows=self.rowsData;
|
|
|
|
|
|
- loadTable:function(rowsTable){
|
|
|
- var table = this.$el.find('#table');
|
|
|
- table.bootstrapTable('load', rowsTable);
|
|
|
+ return rows;
|
|
|
},
|
|
|
|
|
|
clickOnAction: function (e) {
|
|
|
- var action = this.$el.find(e.target).val();
|
|
|
var self = this;
|
|
|
+ var rowsNew;
|
|
|
+ var action = this.$el.find(e.target).val();
|
|
|
var getColumns=[];
|
|
|
var rows=[];
|
|
|
+ rowsNew = self.getObjetPdf();
|
|
|
var table = this.$el.find("#table");
|
|
|
var data2 = table.bootstrapTable('getVisibleColumns');
|
|
|
if (action === 'pdf') {
|
|
|
var dataNEW = _.map(data2, function (val){ return val.field});
|
|
|
- _.each(this.rowsData,function (item){
|
|
|
+ _.each(rowsNew,function (item){
|
|
|
rows.push(_.pick(item, dataNEW));
|
|
|
});
|
|
|
// Obtener los nombre de la Cabezera
|
|
@@ -578,59 +589,15 @@ function report_sales_invoice_analysis (reporting){
|
|
|
var totalPagesExp = "{total_pages_count_string}";
|
|
|
var pdfDoc = new jsPDF('l');
|
|
|
|
|
|
- // rows=this.rowsData;
|
|
|
- var quantity=_.reduce(_.map(rows,function(item){
|
|
|
- var valor=0;
|
|
|
- if (item.quantity){valor = parseFloat(((item.quantity.replace(".","")).replace(",",".")))}return valor}), function(memo, num){ return memo + num; },0);
|
|
|
- var precio_unit=_.reduce(_.map(rows,function(item){
|
|
|
- var valor =0;
|
|
|
- if (item.price_unity){valor=parseFloat(((item.price_unity.replace(".","")).replace(",",".")))} return valor}), function(memo, num){ return memo + num; },0);
|
|
|
- var precio_cost=_.reduce(_.map(rows,function(item){
|
|
|
- var valor=0;
|
|
|
- if(item.standar_price){valor=parseFloat(((item.standar_price.replace(".","")).replace(",",".")))} return valor}), function(memo, num){ return memo + num;},0);
|
|
|
- var tot_unit=_.reduce(_.map(rows,function(item){
|
|
|
- var valor=0;
|
|
|
- if (item.price_tot){valor=parseFloat(((item.price_tot.replace(".","")).replace(",",".")))}return valor}), function(memo, num){ return memo + num; },0);
|
|
|
- var tol_cost=_.reduce(_.map(rows,function(item){
|
|
|
- var valor=0;
|
|
|
- if (item.standar_tot){valor=parseFloat(((item.standar_tot.replace(".","")).replace(",",".")))} return valor }), function(memo, num){ return memo + num; },0);
|
|
|
- var utility=_.reduce(_.map(rows,function(item){
|
|
|
- var valor=0;
|
|
|
- if (item.utility){valor=parseFloat(((item.utility.replace(".","")).replace(",",".")))}return valor }), function(memo, num){ return memo + num; },0);
|
|
|
-
|
|
|
- rowsPdf=rows;
|
|
|
-
|
|
|
var company = _.map(self.resCompany, function (map) {
|
|
|
return map.currency_id[1];
|
|
|
});
|
|
|
- rowsPdf.push({
|
|
|
- number : "TOTAL "+company,
|
|
|
- date_create : " ",
|
|
|
- name : " ",
|
|
|
- quantity: accounting.formatNumber(quantity,0, ".", ","),
|
|
|
- price_unity : accounting.formatNumber(precio_unit,2, ".", ","),
|
|
|
- standar_price : accounting.formatNumber(precio_cost,2, ".", ","),
|
|
|
- price_tot : accounting.formatNumber(tot_unit,2, ".", ","),
|
|
|
- standar_tot : accounting.formatNumber(tol_cost,2, ".", ","),
|
|
|
- utility : accounting.formatNumber(utility,2, ".", ",")
|
|
|
- });
|
|
|
|
|
|
- rowsPdf.unshift({
|
|
|
- number : "TOTAL "+company,
|
|
|
- date_create : " ",
|
|
|
- name : " ",
|
|
|
- quantity: accounting.formatNumber(quantity,0, ".", ","),
|
|
|
- price_unity : accounting.formatNumber(precio_unit,2, ".", ","),
|
|
|
- standar_price : accounting.formatNumber(precio_cost,2, ".", ","),
|
|
|
- price_tot : accounting.formatNumber(tot_unit,2, ".", ","),
|
|
|
- standar_tot : accounting.formatNumber(tol_cost,2, ".", ","),
|
|
|
- utility : accounting.formatNumber(utility,2, ".", ",")
|
|
|
- });
|
|
|
|
|
|
- pdfDoc.autoTable(getColumns, rowsPdf, {
|
|
|
+ pdfDoc.autoTable(getColumns, rows, {
|
|
|
styles: { overflow: 'linebreak', fontSize: 8, columnWidth: 'wrap'},
|
|
|
columnStyles: {
|
|
|
- number: {fontStyle: 'bold',columnWidth: '8px'},
|
|
|
+ number: {fontStyle: 'bold',columnWidth: '9px'},
|
|
|
date_create :{columnWidth: '14px'},
|
|
|
name :{columnWidth: '12px'},
|
|
|
quantity :{halign:'right',columnWidth: '8px'},
|