|
@@ -8,9 +8,11 @@ function reporting_accountpending (reporting){
|
|
|
AccountVoucher: [],
|
|
|
content:[],
|
|
|
rowsData :[],
|
|
|
+ ResUser:[],
|
|
|
moveLine: [],
|
|
|
resCompany: [],
|
|
|
resCurrecy: [],
|
|
|
+ AccountJournal: [],
|
|
|
content: [],
|
|
|
modelId: [],
|
|
|
accountInvoice: [],
|
|
@@ -27,6 +29,10 @@ function reporting_accountpending (reporting){
|
|
|
|
|
|
'click #Y' : 'factSearch',
|
|
|
|
|
|
+ 'click #W' : 'factSearch',
|
|
|
+ 'click #vencidos' : 'factSearch',
|
|
|
+ 'click #novencidos' : 'factSearch',
|
|
|
+
|
|
|
'change #current-journal' : 'factSearch',
|
|
|
|
|
|
'change #from' : 'factSearch',
|
|
@@ -82,8 +88,11 @@ function reporting_accountpending (reporting){
|
|
|
},
|
|
|
submitForm: function () {
|
|
|
var self = this;
|
|
|
- self.fetchMoveLine().then(function(moveLine) {
|
|
|
- return moveLine;
|
|
|
+ self.fetchAccountJournal().then(function(AccountJournal) {
|
|
|
+ return AccountJournal;
|
|
|
+ }).then(function(AccountJournal) {
|
|
|
+ self.AccountJournal = AccountJournal;
|
|
|
+ return self.fetchMoveLine();
|
|
|
}).then(function (moveLine) {
|
|
|
self.moveLine = _.filter(moveLine, function(item) {
|
|
|
return item.amount_residual > 0;
|
|
@@ -157,13 +166,29 @@ function reporting_accountpending (reporting){
|
|
|
return date;
|
|
|
}
|
|
|
},
|
|
|
- // Move line
|
|
|
+
|
|
|
+ fetchAccountJournal: function() {
|
|
|
+ var self = this;
|
|
|
+ var defer = $.Deferred();
|
|
|
+ var fields = ['id', 'name'];
|
|
|
+ var AccountJournal = new instance.web.Model('account.journal');
|
|
|
+ AccountJournal.query(fields).filter().all().then(function(results) {
|
|
|
+ defer.resolve(results);
|
|
|
+ });
|
|
|
+
|
|
|
+ return defer;
|
|
|
+ },
|
|
|
+
|
|
|
+ // Move line , ['date_maturity', '>=', hoy]
|
|
|
fetchMoveLine: function () {
|
|
|
var self = this;
|
|
|
var hoy = moment().format('YYYY-MM-DD');
|
|
|
var defer = $.Deferred();
|
|
|
+ var journal_ids = _.flatten(_.map(this.AccountJournal, function (item) {
|
|
|
+ return item.id;
|
|
|
+ }));
|
|
|
var field = ['id', 'partner_id', 'amount_residual', 'credit', 'debit', 'date_maturity', 'ref', 'invoice', 'amount_residual_currency','state'];
|
|
|
- var domain = [['credit', '<=', 0], ['date_maturity', '>=', hoy]];
|
|
|
+ var domain = [['credit', '<=', 0],['date_maturity', '!=', false],['journal_id','in',journal_ids]];
|
|
|
var moveLine = new instance.web.Model('account.move.line');
|
|
|
|
|
|
moveLine.query(field).filter(domain).all().then(function(results) {
|
|
@@ -257,49 +282,32 @@ function reporting_accountpending (reporting){
|
|
|
},
|
|
|
factSearch: function(){
|
|
|
var self = this;
|
|
|
- var hoy = moment().format('YYYY-MM-DD');
|
|
|
- //var journal = this.$el.find('#current-journal').val();
|
|
|
+ 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 desde = this.$el.find('#from').val();
|
|
|
var hasta = this.$el.find('#to').val();
|
|
|
var partner= this.$el.find('#partner').val().split('-');
|
|
|
var content = self.content;
|
|
|
if ($('#A').is(":checked")){
|
|
|
content = _.filter(content, function (inv){
|
|
|
- return inv.date == hoy;
|
|
|
+ return moment(inv.date).format('YYYY-MM-DD') == today;
|
|
|
});
|
|
|
}
|
|
|
if ($('#B').is(":checked")){
|
|
|
- var date = hoy.split('-');
|
|
|
- var ayer = date[2] + 1;
|
|
|
- date.splice(2,0);
|
|
|
- if(date[2] < 10){
|
|
|
- date[2] = '0'+ayer;
|
|
|
- }else{
|
|
|
- date[2] = ayer;
|
|
|
- }
|
|
|
content = _.filter(content, function (inv){
|
|
|
- return inv.date == date[0]+'-'+date[1]+'-'+date[2];
|
|
|
+ return moment(inv.date).format('YYYY-MM-DD') == yesterday;
|
|
|
});
|
|
|
}
|
|
|
if ($('#C').is(":checked")){
|
|
|
- var date = hoy.split('-');
|
|
|
content = _.filter(content, function (inv){
|
|
|
- var mes = inv.date.split('-');
|
|
|
- return mes[0]+'-'+mes[1] == date[0]+'-'+date[1];
|
|
|
+ return moment(inv.date).format('YYYY-MM') == month;
|
|
|
});
|
|
|
}
|
|
|
if ($('#D').is(":checked")){
|
|
|
- var date = moment(hoy).add(1,'months').format('YYYY-MM-DD');
|
|
|
- var date1 = date.split('-');
|
|
|
- var mes = date1[1];
|
|
|
- var year;
|
|
|
- date1.splice(1,0);
|
|
|
-
|
|
|
- date1[1] = mes;
|
|
|
-
|
|
|
content = _.filter(content, function (inv){
|
|
|
- var mes = inv.date.split('-');
|
|
|
- return mes[0]+'-'+mes[1] == date1[0]+'-'+date1[1];
|
|
|
+ return moment(inv.date).format('YYYY-MM') == last_month;
|
|
|
});
|
|
|
}
|
|
|
if ($('#Z').is(":checked")){
|
|
@@ -324,6 +332,16 @@ function reporting_accountpending (reporting){
|
|
|
return inv.partner_id == partner[0];
|
|
|
});
|
|
|
}
|
|
|
+ if ($('#vencidos').is(":checked")){
|
|
|
+ content = _.filter(content, function (inv){
|
|
|
+ return inv.date_maturity < today;
|
|
|
+ });
|
|
|
+ }
|
|
|
+ if ($('#novencidos').is(":checked")){
|
|
|
+ content = _.filter(content, function (inv){
|
|
|
+ return inv.date_maturity >= today;
|
|
|
+ });
|
|
|
+ }
|
|
|
|
|
|
var amount_total_amount = _.reduce(_.map(content,function(map){
|
|
|
return(map.total_residual);
|
|
@@ -335,7 +353,7 @@ function reporting_accountpending (reporting){
|
|
|
reference: "Total",
|
|
|
amount_residual: accounting.formatNumber((amount_total_amount),0,".",","),
|
|
|
});
|
|
|
-
|
|
|
+
|
|
|
self.loadTable(content)
|
|
|
},
|
|
|
loadTable:function(rowsTable){
|
|
@@ -418,7 +436,7 @@ function reporting_accountpending (reporting){
|
|
|
pdfDoc.setFontSize(12);
|
|
|
pdfDoc.setFontStyle('bold');
|
|
|
pdfDoc.setTextColor(40);
|
|
|
- pdfDoc.text('Listado de cuentas a cobrar no vencidas', data.settings.margin.left, 10);
|
|
|
+ pdfDoc.text('Listado de cuentas a cobrar', data.settings.margin.left, 10);
|
|
|
|
|
|
if(desde.length > 0 || hasta.length > 0){
|
|
|
var fecha='';
|
|
@@ -449,7 +467,7 @@ function reporting_accountpending (reporting){
|
|
|
if (typeof pdfDoc.putTotalPages === 'function') {
|
|
|
pdfDoc.putTotalPages(totalPagesExp);
|
|
|
}
|
|
|
- pdfDoc.save('Listado de cuentas a cobrar no vencidas.pdf')
|
|
|
+ pdfDoc.save('Listado de cuentas a cobrar.pdf')
|
|
|
},
|
|
|
});
|
|
|
}
|