|
@@ -10,6 +10,7 @@ function report_refund_invoice_supplier (reporting){
|
|
|
productProduct:[],
|
|
|
Currency:[],
|
|
|
rowsData :[],
|
|
|
+ content :[],
|
|
|
rowOrigin:[],
|
|
|
accountJournal:[],
|
|
|
resCompany:[],
|
|
@@ -37,8 +38,9 @@ function report_refund_invoice_supplier (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();
|
|
|
},
|
|
@@ -165,12 +167,12 @@ function report_refund_invoice_supplier (reporting){
|
|
|
return defer;
|
|
|
},
|
|
|
fetchAccountInvoice: function () {
|
|
|
+ var defer = $.Deferred();
|
|
|
var filter = [['state', 'in',['open','paid']],['type', '=', 'in_refund']];
|
|
|
var journal_ids = _.flatten(_.map(this.AccountJournal, function (item) {
|
|
|
return item.id;
|
|
|
}));
|
|
|
var field =['id', 'type', 'number', 'origin', 'state', 'journal_id', 'currency_id', 'invoice_line','date_invoice','partner_id'];
|
|
|
- var defer = $.Deferred();
|
|
|
var AccountInvoice = new model.web.Model('account.invoice');
|
|
|
AccountInvoice.query(field).filter(filter).all().then(function (results) {
|
|
|
defer.resolve(results);
|
|
@@ -258,7 +260,7 @@ function report_refund_invoice_supplier (reporting){
|
|
|
BuildTable: function(){
|
|
|
var self = this;
|
|
|
var data=[];
|
|
|
- var AccountInvoiceLine = self.AccountInvoiceLine
|
|
|
+ var AccountInvoiceLine = self.AccountInvoiceLine;
|
|
|
var invoice;
|
|
|
var producto;
|
|
|
var invoice_type;
|
|
@@ -276,7 +278,7 @@ function report_refund_invoice_supplier (reporting){
|
|
|
}
|
|
|
data.push({
|
|
|
id : invoice.id,
|
|
|
- number : (invoice.number),
|
|
|
+ number : self.valorNull(invoice.number),
|
|
|
id_product : producto.id,
|
|
|
name : (item.name),
|
|
|
quantity : accounting.formatNumber((item.quantity),0, ".", ","),
|
|
@@ -289,77 +291,57 @@ function report_refund_invoice_supplier (reporting){
|
|
|
date_create :moment(invoice.date_invoice).format("DD/MM/YYYY"),
|
|
|
amount : (item.quantity * item.price_unit),
|
|
|
partner_name : invoice.partner_id[1],
|
|
|
- invoice_type : invoice_type
|
|
|
+ invoice_type : invoice_type,
|
|
|
});
|
|
|
});
|
|
|
|
|
|
- self.rowsData=data;
|
|
|
- self.rowOrigin=data;
|
|
|
- self.loadTable(data)
|
|
|
+ self.content=data;
|
|
|
+ self.loadTable(data);
|
|
|
},
|
|
|
factSearch: function(){
|
|
|
var self = this;
|
|
|
- var hoy = moment().format('YYYY-MM-DD');
|
|
|
+ var today = moment().format('YYYY-MM-DD');
|
|
|
+ var yesterday = moment().add(-1, 'days').format('YYYY-MM-DD');
|
|
|
+ var month = moment().format('YYYY-MM');
|
|
|
+ var last_month = moment().add(-1, 'months').format('YYYY-MM');
|
|
|
var partner = this.$el.find('#partner').val().split('-');
|
|
|
var product = this.$el.find('#product').val().split('-');
|
|
|
var desde =this.$el.find('#from').val();
|
|
|
var hasta =this.$el.find('#to').val();
|
|
|
- self.rowsData=self.rowOrigin;
|
|
|
+ var content = self.content;
|
|
|
|
|
|
if ($('#A').is(":checked")){
|
|
|
- self.rowsData = _.filter(self.rowsData, function (inv){
|
|
|
- return inv.date_invoice == hoy;
|
|
|
+ content = _.filter(content, function (inv){
|
|
|
+ return moment(inv.date_invoice).format('YYYY-MM-DD') == today;
|
|
|
});
|
|
|
}
|
|
|
if ($('#B').is(":checked")){
|
|
|
- var date = hoy.split('-');
|
|
|
- var ayer = date[2] - 1;
|
|
|
- date.splice(2,0);
|
|
|
- date[2] = '0'+ayer;
|
|
|
- self.rowsData = _.filter(self.rowsData, function (inv){
|
|
|
- return inv.date_invoice == date[0]+'-'+date[1]+'-'+date[2];
|
|
|
+ content = _.filter(content, function (inv){
|
|
|
+ return moment(inv.date_invoice).format('YYYY-MM-DD') == yesterday;
|
|
|
});
|
|
|
}
|
|
|
if ($('#C').is(":checked")){
|
|
|
- var date = hoy.split('-');
|
|
|
- self.rowsData = _.filter(self.rowsData, function (inv){
|
|
|
- var mes = inv.date_invoice.split('-');
|
|
|
- return mes[0]+'-'+mes[1] == date[0]+'-'+date[1];
|
|
|
+ content = _.filter(content, function (inv){
|
|
|
+ return moment(inv.date_invoice).format('YYYY-MM') == month;
|
|
|
});
|
|
|
}
|
|
|
if ($('#D').is(":checked")){
|
|
|
- var date = hoy.split('-');
|
|
|
- var mes = date[1] - 1;
|
|
|
- var year;
|
|
|
- date.splice(1,0);
|
|
|
- if(date[1] == 1){
|
|
|
- date[1] = '12';
|
|
|
- year = date[0] - 1;
|
|
|
- date[0] = year;
|
|
|
- }else{
|
|
|
-
|
|
|
- if(date[1] < 10){
|
|
|
- date[1] = '0'+mes;
|
|
|
- }else{
|
|
|
- date[1] = mes;
|
|
|
- }
|
|
|
- }
|
|
|
- self.rowsData = _.filter(self.rowsData, function (inv){
|
|
|
- var mes = inv.date.split('-');
|
|
|
- return mes[0]+'-'+mes[1] == date[0]+'-'+date[1];
|
|
|
+ content = _.filter(content, function (inv){
|
|
|
+ return moment(inv.date_invoice).format('YYYY-MM') == last_month;
|
|
|
});
|
|
|
}
|
|
|
+
|
|
|
if ($('#Z').is(":checked")){
|
|
|
$('#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]);
|
|
|
});
|
|
|
}
|
|
@@ -368,40 +350,46 @@ function report_refund_invoice_supplier (reporting){
|
|
|
}
|
|
|
|
|
|
if ($('#purchase').is(":checked")){
|
|
|
- self.rowsData = _.filter(self.rowsData, function (inv){
|
|
|
+ content = _.filter(content, function (inv){
|
|
|
return inv.invoice_type == 'purchase';
|
|
|
});
|
|
|
}
|
|
|
if ($('#expense').is(":checked")){
|
|
|
- self.rowsData = _.filter(self.rowsData, function (inv){
|
|
|
+ content = _.filter(content, function (inv){
|
|
|
return inv.invoice_type == 'expense';
|
|
|
});
|
|
|
}
|
|
|
|
|
|
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];
|
|
|
});
|
|
|
}
|
|
|
|
|
|
- var amount_total_total = _.reduce(_.map(self.rowsData,function(map){
|
|
|
+ var amount_total_total = _.reduce(_.map(content,function(map){
|
|
|
return(map.amount);
|
|
|
}),function(memo, num){
|
|
|
return memo + num;
|
|
|
},0);
|
|
|
|
|
|
- self.rowsData.push({
|
|
|
+ content.push({
|
|
|
number: "Total",
|
|
|
standar_tot: accounting.formatNumber((amount_total_total),2,".",","),
|
|
|
});
|
|
|
|
|
|
- self.loadTable(self.rowsData);
|
|
|
+ self.loadTable(content);
|
|
|
+ },
|
|
|
+ valorNull:function(dato){
|
|
|
+ var valor ="";
|
|
|
+ if (dato){
|
|
|
+ valor=dato;
|
|
|
+ }
|
|
|
+ return valor;
|
|
|
},
|
|
|
search: function () {
|
|
|
var self = this;
|
|
@@ -454,19 +442,31 @@ function report_refund_invoice_supplier (reporting){
|
|
|
});
|
|
|
},
|
|
|
loadTable:function(rowsTable){
|
|
|
+ var self = this;
|
|
|
+ self.rowsData = rowsTable;
|
|
|
var table = this.$el.find('#table');
|
|
|
table.bootstrapTable('load', rowsTable);
|
|
|
},
|
|
|
+
|
|
|
+ getObjetPdf: function(rowsTable){
|
|
|
+ var self = this;
|
|
|
+ var rows=self.rowsData;
|
|
|
+
|
|
|
+ return rows;
|
|
|
+ },
|
|
|
+
|
|
|
clickOnAction: function (e) {
|
|
|
- var action = this.$el.find(e.target).val();
|
|
|
var self = this;
|
|
|
+ var action = this.$el.find(e.target).val();
|
|
|
var getColumns=[];
|
|
|
+ var rowsNew;
|
|
|
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));
|
|
|
});
|
|
|
_.each(_.map(data2,function(val){
|
|
@@ -486,35 +486,16 @@ function report_refund_invoice_supplier (reporting){
|
|
|
var desde =(this.$el.find('#from').val());
|
|
|
var hasta =(this.$el.find('#to').val());
|
|
|
var totalPagesExp = "{total_pages_count_string}";
|
|
|
+ var pdfDoc = new jsPDF();
|
|
|
var company = _.map(self.ResCompany, function (map) {
|
|
|
return map.currency_id[1];
|
|
|
});
|
|
|
|
|
|
- var pdfDoc = new jsPDF();
|
|
|
-
|
|
|
- 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 price_unity=_.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 standar_tot=_.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);
|
|
|
-
|
|
|
- rowsPdf=rows;
|
|
|
-
|
|
|
- rowsPdf.push({
|
|
|
- number : "TOTAL "+ company,
|
|
|
- quantity: accounting.formatNumber(quantity,0, ".", ","),
|
|
|
- standar_tot : accounting.formatNumber(standar_tot,2, ".", ","),
|
|
|
- });
|
|
|
-
|
|
|
- pdfDoc.autoTable(getColumns, rowsPdf, {
|
|
|
- styles: { overflow: 'linebreak', fontSize: 8, columnWidth: 'wrap'},
|
|
|
+ pdfDoc.autoTable(getColumns, rows, {
|
|
|
+ styles: { overflow: 'linebreak', fontSize: 7.5, columnWidth: 'wrap'},
|
|
|
columnStyles: {
|
|
|
- number: {fontStyle: 'bold'},
|
|
|
- date_create :{columnWidth: '12px'},
|
|
|
+ number: {columnWidth: 23},
|
|
|
+ date_create :{columnWidth: 18},
|
|
|
partner_name :{columnWidth: '10px'},
|
|
|
name :{columnWidth: '10px'},
|
|
|
quantity :{halign:'right' },
|