|
@@ -7,6 +7,7 @@ function report_cuenta_resumen_dna(reporting){
|
|
|
template: 'ReportCuentaResumenDna',
|
|
|
rowsData :[],
|
|
|
content :[],
|
|
|
+ modules: ['product_brand'],
|
|
|
|
|
|
events:{
|
|
|
'click #toolbar > button' : 'clickOnAction',
|
|
@@ -127,6 +128,17 @@ function report_cuenta_resumen_dna(reporting){
|
|
|
return self.fetchResPartner();
|
|
|
}).then(function(ResPartner){
|
|
|
self.ResPartner = ResPartner;
|
|
|
+ return self.fetchProductCategory();
|
|
|
+ }).then(function(ProductCategory){
|
|
|
+ self.ProductCategory = ProductCategory;
|
|
|
+ if(ProductCategory.length > 1){
|
|
|
+ self.$el.find('#current-category').append('<option value="9999999">Todas las categorias</option>');
|
|
|
+ _.each(ProductCategory,function(item){
|
|
|
+ self.$el.find('#current-category').append('<option value="' + item.id + '">' + item.name + '</option>');
|
|
|
+ });
|
|
|
+ }else{
|
|
|
+ self.$el.find('.category').css('display','none');
|
|
|
+ }
|
|
|
return self.fetchResCurrency();
|
|
|
}).then(function(ResCurrency){
|
|
|
self.ResCurrency = ResCurrency;
|
|
@@ -154,6 +166,9 @@ function report_cuenta_resumen_dna(reporting){
|
|
|
return AccountInvoice;
|
|
|
}).then(function (AccountInvoice){
|
|
|
self.AccountInvoice = AccountInvoice;
|
|
|
+ return self.fetchAccountInvoiceLine();
|
|
|
+ }).then(function (AccountInvoiceLine){
|
|
|
+ self.AccountInvoiceLine = AccountInvoiceLine;
|
|
|
return self.BuildTable();
|
|
|
});
|
|
|
},
|
|
@@ -226,6 +241,18 @@ function report_cuenta_resumen_dna(reporting){
|
|
|
return defer;
|
|
|
},
|
|
|
|
|
|
+ /*====================================================================
|
|
|
+ PRODUCT CATEGORY
|
|
|
+ ====================================================================*/
|
|
|
+ fetchProductCategory: function () {
|
|
|
+ var self = this;
|
|
|
+ var domain = [];
|
|
|
+ var ProductCategory = new model.web.Model('product.category');
|
|
|
+ return ProductCategory.call('getProductCategory',[domain], {
|
|
|
+ context: new model.web.CompoundContext()
|
|
|
+ });
|
|
|
+ },
|
|
|
+
|
|
|
|
|
|
/*====================================================================
|
|
|
RES CURRENCY
|
|
@@ -242,6 +269,7 @@ function report_cuenta_resumen_dna(reporting){
|
|
|
return defer;
|
|
|
},
|
|
|
|
|
|
+
|
|
|
/*====================================================================
|
|
|
ACCOUNT INVOICE
|
|
|
====================================================================*/
|
|
@@ -327,6 +355,47 @@ function report_cuenta_resumen_dna(reporting){
|
|
|
},
|
|
|
|
|
|
|
|
|
+
|
|
|
+ /*====================================================================
|
|
|
+ ACCOUNT INVOICE LINE
|
|
|
+ ====================================================================*/
|
|
|
+ fetchAccountInvoiceLine: function () {
|
|
|
+ var self = this;
|
|
|
+ var categ_ids = [];
|
|
|
+ var category = self.$el.find('#current-category').val();
|
|
|
+ var invoice_ids = _.flatten(_.map(self.AccountInvoice, function (item) {
|
|
|
+ return item.id;
|
|
|
+ }));
|
|
|
+ var domain = [
|
|
|
+ ['invoice_id','in',invoice_ids],
|
|
|
+ ];
|
|
|
+
|
|
|
+ if(category){
|
|
|
+ var category_ids = _.map(_.filter(self.ProductCategory,function (item) {
|
|
|
+ return item.id == category;
|
|
|
+ }), function(map){
|
|
|
+ return map.id;
|
|
|
+ });
|
|
|
+
|
|
|
+
|
|
|
+ categ_ids = _.map(_.filter(self.ProductCategory,function (item) {
|
|
|
+ return _.contains(category_ids, item.parent_id[0]) || item.id == category;
|
|
|
+ }), function(map){
|
|
|
+ return map.id;
|
|
|
+ });
|
|
|
+ };
|
|
|
+
|
|
|
+ if(category && category != 9999999){
|
|
|
+ domain.push(['product_id.categ_id','in',categ_ids]);
|
|
|
+ }
|
|
|
+
|
|
|
+ var AccountInvoiceLine = new model.web.Model('account.invoice.line');
|
|
|
+ return AccountInvoiceLine.call('getAccountInvoiceLineDental',[domain], {
|
|
|
+ context: new model.web.CompoundContext()
|
|
|
+ });
|
|
|
+ },
|
|
|
+
|
|
|
+
|
|
|
/*====================================================================
|
|
|
UPDATE SELECTIONS
|
|
|
====================================================================*/
|
|
@@ -465,7 +534,9 @@ function report_cuenta_resumen_dna(reporting){
|
|
|
====================================================================*/
|
|
|
BuildTable: function(){
|
|
|
var self = this;
|
|
|
+
|
|
|
var data = [];
|
|
|
+
|
|
|
var company = $('#current-company').val();
|
|
|
|
|
|
if(company && company != 9999999){
|
|
@@ -480,6 +551,7 @@ function report_cuenta_resumen_dna(reporting){
|
|
|
|
|
|
var AccountInvoice = self.getAccountInvoice(item.id);
|
|
|
_.each(AccountInvoice,function(item2) {
|
|
|
+ var description_product = '';
|
|
|
if(item2.is_anticipo == false){
|
|
|
var total_sale = 0;
|
|
|
var forma = 'Contado';
|
|
@@ -489,49 +561,55 @@ function report_cuenta_resumen_dna(reporting){
|
|
|
if (item2.credito == true){
|
|
|
forma = 'Credito'
|
|
|
};
|
|
|
- var partner= self.getResPartner(item2.partner_id[0]);
|
|
|
- var currency = self.getResCurrency(item2.company_currency[0]).shift();
|
|
|
- data.push({
|
|
|
- //IDS
|
|
|
- invoice_id : item2.id,
|
|
|
-
|
|
|
- //DATAS
|
|
|
- date_invoice: moment(item2.date_invoice).format('DD/MM/YYYY'),
|
|
|
- partner_id : item2.partner_id[0],
|
|
|
- partner_name : item2.partner_id[1],
|
|
|
- ruc: self.valorNull(item2.partner_id[2]),
|
|
|
- partner_email: self.valorNull(item2.partner_id[3]),
|
|
|
- partner_mobile: self.valorNull(item2.partner_id[4]),
|
|
|
- invoice_name : self.valorNull(item2.number),
|
|
|
- supplier_invoice_number: self.valorNull(item2.supplier_invoice_number),
|
|
|
- forma: forma,
|
|
|
- date_due: moment(item2.date_due).format('DD/MM/YYYY'),
|
|
|
- amount_total: accounting.formatMoney(item2.amount_total_currency, '', CurrencyBase.decimal_places, CurrencyBase.thousands_separator, CurrencyBase.decimal_separator),
|
|
|
- amount_pagado:accounting.formatMoney(item2.amount_total - item2.residual,'',CurrencyBase.decimal_places,CurrencyBase.thousands_separator,CurrencyBase.decimal_separator),
|
|
|
- amount_residual: accounting.formatMoney((item2.residual * (CurrencyBase.rate_silent/currency.rate_silent)), '', CurrencyBase.decimal_places, CurrencyBase.thousands_separator, CurrencyBase.decimal_separator),
|
|
|
- date: item2.date_invoice,
|
|
|
- amount : (item2.amount_total),
|
|
|
- residual: (item2.residual),
|
|
|
- pagado: item2.amount_total - item2.residual,
|
|
|
- user_id : self.valorNull(item2.user_id[0]),
|
|
|
- user_name : item2.user_id[1],
|
|
|
-
|
|
|
- //VALORES SIN FORMATEAR
|
|
|
-
|
|
|
-
|
|
|
- //TOTAL FOOTER CONFIGURATION
|
|
|
- decimal_places : CurrencyBase.decimal_places,
|
|
|
- thousands_separator: CurrencyBase.thousands_separator,
|
|
|
- decimal_separator: CurrencyBase.decimal_separator,
|
|
|
+ var AccountInvoiceLine = self.getAccountInvoiceLine(item2.id);
|
|
|
+ _.each(AccountInvoiceLine, function(line_item){
|
|
|
+ description_product = description_product + " " + line_item.product_id.name
|
|
|
+ });
|
|
|
|
|
|
- });
|
|
|
+ var partner= self.getResPartner(item2.partner_id[0]);
|
|
|
+ var currency = self.getResCurrency(item2.company_currency[0]).shift();
|
|
|
+ data.push({
|
|
|
+ //IDS
|
|
|
+ invoice_id : item2.id,
|
|
|
+
|
|
|
+ //DATAS
|
|
|
+ date_invoice: moment(item2.date_invoice).format('DD/MM/YYYY'),
|
|
|
+ partner_id : item2.partner_id[0],
|
|
|
+ partner_name : item2.partner_id[1],
|
|
|
+ ruc: self.valorNull(item2.partner_id[2]),
|
|
|
+ partner_email: self.valorNull(item2.partner_id[3]),
|
|
|
+ partner_mobile: self.valorNull(item2.partner_id[4]),
|
|
|
+ invoice_name : self.valorNull(item2.number),
|
|
|
+ supplier_invoice_number: self.valorNull(item2.supplier_invoice_number),
|
|
|
+ forma: forma,
|
|
|
+ date_due: moment(item2.date_due).format('DD/MM/YYYY'),
|
|
|
+ product_name: description_product,
|
|
|
+ amount_total: accounting.formatMoney(item2.amount_total_currency, '', CurrencyBase.decimal_places, CurrencyBase.thousands_separator, CurrencyBase.decimal_separator),
|
|
|
+ amount_pagado:accounting.formatMoney(item2.amount_total - item2.residual,'',CurrencyBase.decimal_places,CurrencyBase.thousands_separator,CurrencyBase.decimal_separator),
|
|
|
+ amount_residual: accounting.formatMoney((item2.residual * (CurrencyBase.rate_silent/currency.rate_silent)), '', CurrencyBase.decimal_places, CurrencyBase.thousands_separator, CurrencyBase.decimal_separator),
|
|
|
+ date: item2.date_invoice,
|
|
|
+ amount : (item2.amount_total),
|
|
|
+ residual: (item2.residual),
|
|
|
+ pagado: item2.amount_total - item2.residual,
|
|
|
+ user_id : self.valorNull(item2.user_id[0]),
|
|
|
+ user_name : item2.user_id[1],
|
|
|
+
|
|
|
+ //VALORES SIN FORMATEAR
|
|
|
+
|
|
|
+
|
|
|
+ //TOTAL FOOTER CONFIGURATION
|
|
|
+ decimal_places : CurrencyBase.decimal_places,
|
|
|
+ thousands_separator: CurrencyBase.thousands_separator,
|
|
|
+ decimal_separator: CurrencyBase.decimal_separator,
|
|
|
+
|
|
|
+ });
|
|
|
}
|
|
|
});
|
|
|
});
|
|
|
|
|
|
self.content = data;
|
|
|
self.loadTable(data);
|
|
|
-
|
|
|
+ console.log(data);
|
|
|
self.$el.find('.report-form').css('display','block');
|
|
|
self.$el.find('.search-form').unblock();
|
|
|
self.$el.find('.report-form').unblock();
|
|
@@ -601,15 +679,16 @@ function report_cuenta_resumen_dna(reporting){
|
|
|
date_invoice: {columnWidth: 18, halign:'center'},
|
|
|
partner_name : {columnWidth: 36, halign:'left'},
|
|
|
partner_mobile : {columnWidth: 22, halign:'left'},
|
|
|
- partner_email: {columnWidth: 37, halign:'left'},
|
|
|
+ partner_email: {columnWidth: 34, halign:'left'},
|
|
|
invoice_name : {columnWidth: 25, halign:'center'},
|
|
|
supplier_invoice_number : {columnWidth: 24, halign:'center'},
|
|
|
forma: forma,
|
|
|
date_due: {columnWidth: 23, halign:'center'},
|
|
|
+ product_name: {columnWidth: 23, halign:'left'},
|
|
|
amount_total: {columnWidth: 20, halign:'right'},
|
|
|
amount_pagado : {columnWidth: 20, halign:'right'},
|
|
|
amount_residual : {columnWidth: 18, halign:'right'},
|
|
|
- user_name : {columnWidth: 21, halign:'center'},
|
|
|
+ user_name : {columnWidth: 19, halign:'center'},
|
|
|
|
|
|
};
|
|
|
/*
|