|
@@ -56,6 +56,9 @@ function report_purchases (reporting){
|
|
|
return self.fetchPaymentTerm();
|
|
|
}).then(function (paymentTerm){
|
|
|
self.paymentTerm=paymentTerm;
|
|
|
+ return self.fetchPaymentTermLine();
|
|
|
+ }).then(function (paymentTermLine){
|
|
|
+ self.paymentTermLine=paymentTermLine;
|
|
|
return self.fetchAttachment();
|
|
|
}).then(function(attachment){
|
|
|
self.attachment=attachment;
|
|
@@ -70,7 +73,7 @@ function report_purchases (reporting){
|
|
|
var self = this;
|
|
|
var defer = $.Deferred();
|
|
|
var Journal = new instance.web.Model('account.journal');
|
|
|
- Journal.query(['id', 'name']).filter([['type', '=', ['purchase','purchase_refund']]]).all().then(function(results){
|
|
|
+ Journal.query(['id', 'name']).filter([['type', 'in', ['purchase','purchase_refund']]]).all().then(function(results){
|
|
|
defer.resolve(results);
|
|
|
});
|
|
|
return defer;
|
|
@@ -91,7 +94,7 @@ function report_purchases (reporting){
|
|
|
var journal_ids = _.flatten(_.map(this.accountJournal, function (item) {
|
|
|
return item.id;
|
|
|
}));
|
|
|
- var filter =[['state', 'in',['open','paid']],['type', '=', ['in_invoice','in_refund']],['journal_id', 'in',journal_ids]];
|
|
|
+ var filter =[['state', 'in',['open','paid']],['type', 'in', ['in_invoice','in_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','timbrado'];
|
|
|
var defer = $.Deferred();
|
|
|
var Invoice = new instance.web.Model('account.invoice');
|
|
@@ -143,7 +146,17 @@ function report_purchases (reporting){
|
|
|
return map.payment_term[0];
|
|
|
}));
|
|
|
var paymentTerm = new instance.web.Model('account.payment.term');
|
|
|
- paymentTerm.query(['id','name','line_ids']).filter([['id', '=', payment_term]]).all().then(function(results){
|
|
|
+ paymentTerm.query(['id','name','line_ids']).filter([['id', 'in', payment_term]]).all().then(function(results){
|
|
|
+ defer.resolve(results);
|
|
|
+ });
|
|
|
+ return defer;
|
|
|
+ },
|
|
|
+ // Linea de plazos de pago
|
|
|
+ fetchPaymentTermLine: function () {
|
|
|
+ var self = this;
|
|
|
+ var defer = $.Deferred();
|
|
|
+ var paymentTermLine = new instance.web.Model('account.payment.term.line');
|
|
|
+ paymentTermLine.query(['id']).filter().all().then(function(results){
|
|
|
defer.resolve(results);
|
|
|
});
|
|
|
return defer;
|
|
@@ -199,15 +212,18 @@ function report_purchases (reporting){
|
|
|
// Obtener el ruc y el DV del proveedor
|
|
|
supplier_ruc = self.getSupplier(invoice.partner_id[0]);
|
|
|
ruc = supplier_ruc.ruc.split("-");
|
|
|
+
|
|
|
+ // Determinar la cantidad de cuotas.
|
|
|
+ cuota = _.flatten(self.getPaymentTerm(invoice.payment_term[0])).length - 2;
|
|
|
+
|
|
|
// Determinar si la factura es a credito o al contado.
|
|
|
condicion = 1;
|
|
|
- if (invoice.credito == true){
|
|
|
+ if (cuota > 1){
|
|
|
condicion = 2;
|
|
|
}
|
|
|
- // Determinar la cantidad de cuotas.
|
|
|
- cuota = _.flatten(self.getPaymentTerm(invoice.payment_term[0])).length - 2;
|
|
|
+
|
|
|
// Validar. Si la factura es al contado, la cuota debe ser cero.
|
|
|
- if (condicion == 1 || cuota < 1){
|
|
|
+ if (condicion == 1){
|
|
|
cuota = 0;
|
|
|
}
|
|
|
// Determinar el tipo de factura.
|