|
@@ -25,6 +25,9 @@ function report_ventas_pos_orders(reporting){
|
|
'click #D' : 'fectSearch',
|
|
'click #D' : 'fectSearch',
|
|
'click #Z' : 'fectSearch',
|
|
'click #Z' : 'fectSearch',
|
|
'change #current-store': 'fectSearch',
|
|
'change #current-store': 'fectSearch',
|
|
|
|
+ 'change #current-category' : 'fectSearch',
|
|
|
|
+ 'change #current-attribute': 'fectSearch',
|
|
|
|
+ 'change #current-attribute-value': 'fectSearch',
|
|
'change #from' : 'fectSearch',
|
|
'change #from' : 'fectSearch',
|
|
'change #to': 'fectSearch',
|
|
'change #to': 'fectSearch',
|
|
'click-row.bs.table #table' : 'clickAnalysisDetail',
|
|
'click-row.bs.table #table' : 'clickAnalysisDetail',
|
|
@@ -97,10 +100,10 @@ function report_ventas_pos_orders(reporting){
|
|
res_model: "account.invoice",
|
|
res_model: "account.invoice",
|
|
views: [[false,'form']],
|
|
views: [[false,'form']],
|
|
target: 'new',
|
|
target: 'new',
|
|
- domain: [['type', '=', 'out_invoice'],['id','=', row.order_id]],
|
|
|
|
|
|
+ domain: [['type', '=', 'out_invoice'],['id','=', row.id]],
|
|
context: {},
|
|
context: {},
|
|
flags: {'form': {'action_buttons': false, 'options': {'mode': 'view'}}},
|
|
flags: {'form': {'action_buttons': false, 'options': {'mode': 'view'}}},
|
|
- res_id: row.order_id,
|
|
|
|
|
|
+ res_id: row.id,
|
|
});
|
|
});
|
|
}
|
|
}
|
|
if (field == 'order_name'){
|
|
if (field == 'order_name'){
|
|
@@ -191,6 +194,35 @@ function report_ventas_pos_orders(reporting){
|
|
return self.fetchProductProduct();
|
|
return self.fetchProductProduct();
|
|
}).then(function (ProductProduct) {
|
|
}).then(function (ProductProduct) {
|
|
self.ProductProduct = ProductProduct;
|
|
self.ProductProduct = ProductProduct;
|
|
|
|
+ return self.fetchProductAttribute();
|
|
|
|
+ }).then(function (ProductAttribute) {
|
|
|
|
+ self.ProductAttribute = ProductAttribute;
|
|
|
|
+ if(ProductAttribute.length > 0){
|
|
|
|
+ self.$el.find('#current-attribute').append('<option value="9999999">Todos los atributos</option>');
|
|
|
|
+ _.each(ProductAttribute,function(item){
|
|
|
|
+ self.$el.find('#current-attribute').append('<option value="' + item.id + '">' + item.name + '</option>');
|
|
|
|
+ });
|
|
|
|
+ }else{
|
|
|
|
+ self.$el.find('.attribute').css('display','none');
|
|
|
|
+ }
|
|
|
|
+ return self.fetchProductAttributeValue();
|
|
|
|
+ }).then(function(ProductAttributeValue){
|
|
|
|
+ self.ProductAttributeValue = ProductAttributeValue;
|
|
|
|
+ if(ProductAttributeValue.length > 0){
|
|
|
|
+ self.$el.find('#current-attribute-value').append('<option value="9999999">Todos los valores de atributos</option>');
|
|
|
|
+ _.each(ProductAttributeValue,function(item){
|
|
|
|
+ self.$el.find('#current-attribute-value').append('<option value="' + item.id + '">' + item.name + '</option>');
|
|
|
|
+ });
|
|
|
|
+ }else{
|
|
|
|
+ self.$el.find('.attribute-value').css('display','none');
|
|
|
|
+ }
|
|
|
|
+ return self.fetchProductCategory();
|
|
|
|
+ }).then(function(ProductCategory){
|
|
|
|
+ self.ProductCategory= ProductCategory;
|
|
|
|
+ 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.complete_name + '</option>');
|
|
|
|
+ });
|
|
return self.fecthResStore();
|
|
return self.fecthResStore();
|
|
}).then(function(ResStore){
|
|
}).then(function(ResStore){
|
|
self.ResStore = ResStore;
|
|
self.ResStore = ResStore;
|
|
@@ -201,18 +233,24 @@ function report_ventas_pos_orders(reporting){
|
|
return self.fecthAccountJournal();
|
|
return self.fecthAccountJournal();
|
|
}).then(function(AccountJournal){
|
|
}).then(function(AccountJournal){
|
|
self.AccountJournal = AccountJournal;
|
|
self.AccountJournal = AccountJournal;
|
|
- return self.fetchInvoiceV2();
|
|
|
|
- }).then(function (invoices){
|
|
|
|
- self.invoices = invoices;
|
|
|
|
- return self.fetchInvoiceLine(invoices);
|
|
|
|
- }).then(function (invoiceLines) {
|
|
|
|
- self.invoiceLines = invoiceLines;
|
|
|
|
- return self.fecthProduct(invoiceLines);
|
|
|
|
- }).then(function(ProductInvoice){
|
|
|
|
- self.ProductInvoice = ProductInvoice;
|
|
|
|
|
|
+ return self.fetchAccountInvoice();
|
|
|
|
+ }).then(function (AccountInvoice){
|
|
|
|
+ self.AccountInvoice = AccountInvoice;
|
|
|
|
+ return self.fetchAccountInvoiceLine();
|
|
|
|
+ }).then(function (AccountInvoiceLine) {
|
|
|
|
+ self.AccountInvoiceLine = AccountInvoiceLine;
|
|
|
|
+ return self.fetchResCurrency();
|
|
|
|
+ }).then(function(ResCurrency){
|
|
|
|
+ self.ResCurrency = ResCurrency;
|
|
return self.fetchResPartner();
|
|
return self.fetchResPartner();
|
|
}).then(function (ResPartner){
|
|
}).then(function (ResPartner){
|
|
self.ResPartner = ResPartner;
|
|
self.ResPartner = ResPartner;
|
|
|
|
+ return self.fetchProductPricelist();
|
|
|
|
+ }).then(function(ProductPricelist){
|
|
|
|
+ self.ProductPricelist = ProductPricelist;
|
|
|
|
+ return self.fecthCompanyCurrency();
|
|
|
|
+ }).then(function(resCompany){
|
|
|
|
+ self.resCompany = resCompany;
|
|
self.search();
|
|
self.search();
|
|
self.searchProduct();
|
|
self.searchProduct();
|
|
return self.BuildTable();
|
|
return self.BuildTable();
|
|
@@ -233,11 +271,23 @@ function report_ventas_pos_orders(reporting){
|
|
return defer;
|
|
return defer;
|
|
},
|
|
},
|
|
|
|
|
|
|
|
+ // Obtener Pedido
|
|
|
|
+ fecthResStore: function(){
|
|
|
|
+ var self = this;
|
|
|
|
+ var defer = $.Deferred();
|
|
|
|
+ var field=['id', 'name'];
|
|
|
|
+ var ResStore = new model.web.Model('res.store');
|
|
|
|
+ ResStore.query(field).all().then(function(results){
|
|
|
|
+ defer.resolve(results);
|
|
|
|
+ });
|
|
|
|
+ return defer;
|
|
|
|
+ },
|
|
|
|
+
|
|
fecthAccountJournal: function(){
|
|
fecthAccountJournal: function(){
|
|
var self = this;
|
|
var self = this;
|
|
var defer = $.Deferred();
|
|
var defer = $.Deferred();
|
|
var field = ['id', 'name','store_ids'];
|
|
var field = ['id', 'name','store_ids'];
|
|
- var domain = [['active','=',true],['type','in',['sale','purchase']]];
|
|
|
|
|
|
+ var domain = [['active','=',true],['type','in',['sale']]];
|
|
var AccountJournal = new model.web.Model('account.journal');
|
|
var AccountJournal = new model.web.Model('account.journal');
|
|
AccountJournal.query(field).filter(domain).all().then(function(results){
|
|
AccountJournal.query(field).filter(domain).all().then(function(results){
|
|
defer.resolve(results);
|
|
defer.resolve(results);
|
|
@@ -245,8 +295,32 @@ function report_ventas_pos_orders(reporting){
|
|
return defer;
|
|
return defer;
|
|
},
|
|
},
|
|
|
|
|
|
|
|
+ fecthCompanyCurrency: function(){
|
|
|
|
+ var self = this;
|
|
|
|
+ var defer = $.Deferred();
|
|
|
|
+ var field=['id','name', 'currency_id'];
|
|
|
|
+ var domain = [['id', '=', self.session.company_id]];
|
|
|
|
+ var ResCompany = new model.web.Model('res.company');
|
|
|
|
+ ResCompany.query(field).filter(domain).all().then(function(results){
|
|
|
|
+ defer.resolve(results);
|
|
|
|
+ });
|
|
|
|
+ return defer;
|
|
|
|
+ },
|
|
|
|
+
|
|
|
|
+ fetchProductPricelist : function(){
|
|
|
|
+ var self = this;
|
|
|
|
+ var defer = $.Deferred();
|
|
|
|
+ var fields = ['id','name','currency_id'];
|
|
|
|
+ var domain = [['active', '=', true],['type', '=', 'sale']];
|
|
|
|
+ var ProductPricelist = new model.web.Model('product.pricelist');
|
|
|
|
+ ProductPricelist.query(fields).filter(domain).all().then(function(results) {
|
|
|
|
+ defer.resolve(results);
|
|
|
|
+ });
|
|
|
|
+ return defer;
|
|
|
|
+ },
|
|
|
|
+
|
|
// Invoice (FACTURAS)
|
|
// Invoice (FACTURAS)
|
|
- fetchInvoiceV2: function () {
|
|
|
|
|
|
+ fetchAccountInvoice: function () {
|
|
var self = this;
|
|
var self = this;
|
|
var filter ="[['state', 'in',['open','paid']],['type', '=', 'out_invoice']";
|
|
var filter ="[['state', 'in',['open','paid']],['type', '=', 'out_invoice']";
|
|
var journal_ids = _.flatten(_.map(self.AccountJournal, function (item) {
|
|
var journal_ids = _.flatten(_.map(self.AccountJournal, function (item) {
|
|
@@ -258,22 +332,22 @@ function report_ventas_pos_orders(reporting){
|
|
filter=filter.concat("]");
|
|
filter=filter.concat("]");
|
|
var field =['id', 'type', 'number', 'origin', 'state', 'journal_id', 'currency_id', 'invoice_line','date_invoice','partner_id'];
|
|
var field =['id', 'type', 'number', 'origin', 'state', 'journal_id', 'currency_id', 'invoice_line','date_invoice','partner_id'];
|
|
var defer = $.Deferred();
|
|
var defer = $.Deferred();
|
|
- var Invoice = new model.web.Model('account.invoice');
|
|
|
|
- Invoice.query(field).filter(filter).all().then(function (results) {
|
|
|
|
|
|
+ var AccountInvoice = new model.web.Model('account.invoice');
|
|
|
|
+ AccountInvoice.query(field).filter(filter).all().then(function (results) {
|
|
defer.resolve(results);
|
|
defer.resolve(results);
|
|
});
|
|
});
|
|
return defer;
|
|
return defer;
|
|
},
|
|
},
|
|
|
|
|
|
// Invoice line (Linea de Factura)
|
|
// Invoice line (Linea de Factura)
|
|
- fetchInvoiceLine: function (invoices) {
|
|
|
|
|
|
+ fetchAccountInvoiceLine: function () {
|
|
var self = this;
|
|
var self = this;
|
|
var defer = $.Deferred();
|
|
var defer = $.Deferred();
|
|
- var linesIds = _.flatten(_.map(self.invoices, function (item) {
|
|
|
|
|
|
+ var linesIds = _.flatten(_.map(self.AccountInvoice, function (item) {
|
|
return item.invoice_line;
|
|
return item.invoice_line;
|
|
}));
|
|
}));
|
|
- var InvoiceLine = new model.web.Model('account.invoice.line');
|
|
|
|
- InvoiceLine.query(['id', 'quantity', 'price_unit', 'discount', 'name', 'product_id', 'origin','invoice_id']).filter([['id', 'in', linesIds]]).all().then(function (results) {
|
|
|
|
|
|
+ var AccountInvoiceLine = new model.web.Model('account.invoice.line');
|
|
|
|
+ AccountInvoiceLine.query(['id', 'quantity', 'price_unit', 'discount', 'name', 'product_id', 'origin','invoice_id']).filter([['id', 'in', linesIds]]).all().then(function (results) {
|
|
defer.resolve(results)
|
|
defer.resolve(results)
|
|
});
|
|
});
|
|
return defer;
|
|
return defer;
|
|
@@ -292,17 +366,26 @@ function report_ventas_pos_orders(reporting){
|
|
return defer;
|
|
return defer;
|
|
},
|
|
},
|
|
|
|
|
|
- // Product Product
|
|
|
|
- fecthProduct: function(invoiceLines){
|
|
|
|
|
|
+ fetchResCurrency : function(){
|
|
var self = this;
|
|
var self = this;
|
|
var defer = $.Deferred();
|
|
var defer = $.Deferred();
|
|
- var porductIDS = _.flatten(_.map(self.invoiceLines, function (item) {
|
|
|
|
- return item.product_id[0];
|
|
|
|
- }));
|
|
|
|
- var ProductInvoice = new model.web.Model('product.product');
|
|
|
|
- var fields = ['id','name', 'default_code', 'name_template','ean13', 'standard_price','type','attribute_str'];
|
|
|
|
- ProductInvoice.query(fields).filter([['id', 'in', porductIDS]]).all().then(function (results) {
|
|
|
|
- defer.resolve(results)
|
|
|
|
|
|
+ var fields = ['id','name', 'symbol', 'rate_silent', 'base', 'decimal_separator', 'decimal_places', 'thousands_separator', 'symbol_position'];
|
|
|
|
+ var domain = [['active', '=', true]];
|
|
|
|
+ var ResCurrency = new model.web.Model('res.currency');
|
|
|
|
+ ResCurrency.query(fields).filter(domain).all().then(function(results) {
|
|
|
|
+ defer.resolve(results);
|
|
|
|
+ });
|
|
|
|
+ return defer;
|
|
|
|
+ },
|
|
|
|
+
|
|
|
|
+ // Buscar Category
|
|
|
|
+ fetchProductCategory : function(){
|
|
|
|
+ var self = this;
|
|
|
|
+ var defer = $.Deferred();
|
|
|
|
+ var fields = ['id','name','parent_id','complete_name'];
|
|
|
|
+ var ProductCategory = new model.web.Model('product.category');
|
|
|
|
+ ProductCategory.query(fields).filter().all().then(function(results) {
|
|
|
|
+ defer.resolve(results);
|
|
});
|
|
});
|
|
return defer;
|
|
return defer;
|
|
},
|
|
},
|
|
@@ -311,14 +394,8 @@ function report_ventas_pos_orders(reporting){
|
|
fetchPosOrder: function () {
|
|
fetchPosOrder: function () {
|
|
var self = this;
|
|
var self = this;
|
|
var defer = $.Deferred();
|
|
var defer = $.Deferred();
|
|
- // var modules = self.checkModel('point_of_sale');
|
|
|
|
- //
|
|
|
|
- // if (modules.length <= 0){
|
|
|
|
- // self.showMensaje('point_of_sale');
|
|
|
|
- // return defer;
|
|
|
|
- // }
|
|
|
|
-
|
|
|
|
- var fields = ['id','name','partner_id','create_date','lines','table_id','sale_journal'];
|
|
|
|
|
|
+
|
|
|
|
+ var fields = ['id','number', 'name','partner_id','create_date','lines','table_id','sale_journal','pricelist_id'];
|
|
var domain = [['state', 'not in', ['draft','cancel']]];
|
|
var domain = [['state', 'not in', ['draft','cancel']]];
|
|
var PosOrder = new model.web.Model('pos.order');
|
|
var PosOrder = new model.web.Model('pos.order');
|
|
PosOrder.query(fields).filter(domain).all().then(function(results){
|
|
PosOrder.query(fields).filter(domain).all().then(function(results){
|
|
@@ -343,46 +420,65 @@ function report_ventas_pos_orders(reporting){
|
|
return defer;
|
|
return defer;
|
|
},
|
|
},
|
|
|
|
|
|
- // Productos
|
|
|
|
|
|
+ // Product Product
|
|
fetchProductProduct: function(){
|
|
fetchProductProduct: function(){
|
|
var self = this;
|
|
var self = this;
|
|
- var defer = $.Deferred();
|
|
|
|
- var porduct_ids = _.flatten(_.map(self.PosOrderLine, function (item) {
|
|
|
|
|
|
+ var product_ids = _.flatten(_.map(self.AccountInvoiceLine, function (item) {
|
|
return item.product_id[0];
|
|
return item.product_id[0];
|
|
}));
|
|
}));
|
|
- var fields = ['id','name', 'default_code', 'name_template','ean13','lst_price','pos_categ_id', 'standard_price','type','attribute_str'];
|
|
|
|
- var domain = [['id', 'in', porduct_ids]];
|
|
|
|
- var ProductProduct = new model.web.Model('product.product');
|
|
|
|
- ProductProduct.query(fields).filter(domain).all().then(function (results) {
|
|
|
|
|
|
+ var modules = self.checkModel('point_of_sale');
|
|
|
|
+ if (modules.length > 0){
|
|
|
|
+ var product_order_ids = _.flatten(_.map(self.PosOrderLine, function (item) {
|
|
|
|
+ return item.product_id[0];
|
|
|
|
+ }));
|
|
|
|
+ product_ids = product_ids.concat(product_order_ids);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ var domain = [['id','in',product_ids]];
|
|
|
|
+ var ProductProduct = new model.web.Model('product.product');
|
|
|
|
+ return ProductProduct.call('getProductProduct',[domain], {
|
|
|
|
+ context: new model.web.CompoundContext()
|
|
|
|
+ });
|
|
|
|
+ },
|
|
|
|
+
|
|
|
|
+ fetchProductAttribute : function(){
|
|
|
|
+ var self = this;
|
|
|
|
+ var defer = $.Deferred();
|
|
|
|
+ var fields = ['id','name'];
|
|
|
|
+ var ProductAttribute = new model.web.Model('product.attribute');
|
|
|
|
+ ProductAttribute.query(fields).filter().all().then(function(results) {
|
|
defer.resolve(results);
|
|
defer.resolve(results);
|
|
});
|
|
});
|
|
return defer;
|
|
return defer;
|
|
},
|
|
},
|
|
|
|
|
|
- getPosOrder: function(id){
|
|
|
|
|
|
+ fetchProductAttributeValue : function(){
|
|
var self = this;
|
|
var self = this;
|
|
- return _.filter(self.PosOrder,function (item) {
|
|
|
|
- return item.id == id;
|
|
|
|
|
|
+ var defer = $.Deferred();
|
|
|
|
+ var fields = ['id','name','attribute_id'];
|
|
|
|
+ var ProductAttributeValue = new model.web.Model('product.attribute.value');
|
|
|
|
+ ProductAttributeValue.query(fields).filter().all().then(function(results) {
|
|
|
|
+ defer.resolve(results);
|
|
});
|
|
});
|
|
|
|
+ return defer;
|
|
},
|
|
},
|
|
|
|
|
|
- // Obtener las lineas de las Facturas
|
|
|
|
- getProductProduct: function(id){
|
|
|
|
|
|
+ getPosOrder: function (id) {
|
|
var self = this;
|
|
var self = this;
|
|
-
|
|
|
|
- return _.filter(self.ProductProduct, function(item){
|
|
|
|
|
|
+ return _.filter(self.PosOrder,function (item) {
|
|
return item.id === id;
|
|
return item.id === id;
|
|
- });
|
|
|
|
|
|
+ })
|
|
},
|
|
},
|
|
|
|
|
|
// Obtener las lineas de las Facturas
|
|
// Obtener las lineas de las Facturas
|
|
- getProductInvoice: function(id){
|
|
|
|
|
|
+ getProductProduct: function(pro_id){
|
|
var self = this;
|
|
var self = this;
|
|
- return _.filter(self.ProductInvoice, function(item){
|
|
|
|
- return item.id === id;
|
|
|
|
|
|
+ return _.find(self.ProductProduct, function(item){
|
|
|
|
+ return _.contains(pro_id, item.id);
|
|
});
|
|
});
|
|
},
|
|
},
|
|
|
|
|
|
|
|
+
|
|
getAccountJournal: function (id) {
|
|
getAccountJournal: function (id) {
|
|
var self = this;
|
|
var self = this;
|
|
return _.filter(self.AccountJournal,function (item) {
|
|
return _.filter(self.AccountJournal,function (item) {
|
|
@@ -416,126 +512,136 @@ function report_ventas_pos_orders(reporting){
|
|
});
|
|
});
|
|
},
|
|
},
|
|
|
|
|
|
-
|
|
|
|
- // Obtener Pedido
|
|
|
|
- fecthResStore: function(){
|
|
|
|
|
|
+ getAccountInvoice: function (id) {
|
|
var self = this;
|
|
var self = this;
|
|
- var defer = $.Deferred();
|
|
|
|
- var field=['id', 'name'];
|
|
|
|
- var ResStore = new model.web.Model('res.store');
|
|
|
|
- ResStore.query(field).all().then(function(results){
|
|
|
|
- defer.resolve(results);
|
|
|
|
- });
|
|
|
|
- return defer;
|
|
|
|
|
|
+ return _.filter(self.AccountInvoice,function (item) {
|
|
|
|
+ return item.id === id;
|
|
|
|
+ })
|
|
},
|
|
},
|
|
|
|
|
|
- // Obtener la Detalles de la Factura
|
|
|
|
- getInvoice: function (id_line){
|
|
|
|
- return _.find(this.invoices, function (inv) {
|
|
|
|
- return _.contains(inv.invoice_line, id_line);
|
|
|
|
- });
|
|
|
|
|
|
+ getProductPricelist: function (id) {
|
|
|
|
+ var self = this;
|
|
|
|
+ return _.filter(self.ProductPricelist,function (item) {
|
|
|
|
+ return item.id === id;
|
|
|
|
+ })
|
|
},
|
|
},
|
|
|
|
|
|
- getAccountJournalVentas: function (id) {
|
|
|
|
|
|
+ getResCurrency: function (id) {
|
|
var self = this;
|
|
var self = this;
|
|
- return _.filter(self.AccountJournal,function (item) {
|
|
|
|
|
|
+ return _.filter(self.ResCurrency,function (item) {
|
|
return item.id === id;
|
|
return item.id === id;
|
|
- });
|
|
|
|
|
|
+ })
|
|
},
|
|
},
|
|
|
|
|
|
BuildTable: function(){
|
|
BuildTable: function(){
|
|
var self = this;
|
|
var self = this;
|
|
|
|
+ var CurrencyBase = self.getResCurrency(self.resCompany[0].currency_id[0]).shift();
|
|
var data = [];
|
|
var data = [];
|
|
- var order;
|
|
|
|
var sale;
|
|
var sale;
|
|
var itemsale;
|
|
var itemsale;
|
|
- var producto = [];
|
|
|
|
var saleproducto = [];
|
|
var saleproducto = [];
|
|
var item;
|
|
var item;
|
|
|
|
|
|
- for (var i = 0; i < this.PosOrderLine.length; i++) {
|
|
|
|
-
|
|
|
|
-
|
|
|
|
- item = this.PosOrderLine[i];
|
|
|
|
- producto = self.getProductProduct(item.product_id[0]);
|
|
|
|
- order = self.getPosOrder(item.order_id[0]).shift();
|
|
|
|
- var utc = moment.utc(item.create_date,'YYYY-MM-DD h:mm:ss A');
|
|
|
|
- var date = moment(utc._d).format('DD/MM/YYYY h:mm A');
|
|
|
|
- var date_aux=moment(utc._d).format('YYYY-MM-DD');
|
|
|
|
- var store = self.getAccountJournal(order.sale_journal[0]);
|
|
|
|
-
|
|
|
|
- if(store.length > 0 && producto.length > 0){
|
|
|
|
-
|
|
|
|
- data.push({
|
|
|
|
- id : item.id,
|
|
|
|
- order_id : item.order_id[0],
|
|
|
|
- ref: "",
|
|
|
|
- order_name : item.order_id[1],
|
|
|
|
- date : date_aux,
|
|
|
|
- date_order : date,
|
|
|
|
- partner: order.partner_id[1],
|
|
|
|
- product_id : item.product_id[0],
|
|
|
|
- product_name : item.product_id[1],
|
|
|
|
- qty : accounting.formatNumber(item.qty,0,".",","),
|
|
|
|
- price_unit : accounting.formatNumber(item.price_unit,0,".",","),
|
|
|
|
- standard_price : accounting.formatNumber((producto[0].standard_price),0, ".", ","),
|
|
|
|
- price_tot : accounting.formatNumber((item.qty * item.price_unit),0, ".", ","),
|
|
|
|
- standar_tot : accounting.formatNumber((item.qty * producto[0].standard_price),0, ".", ","),
|
|
|
|
- utility : accounting.formatNumber(((item.qty * item.price_unit) - (item.qty * producto[0].standard_price)),0, ".", ","),
|
|
|
|
- qty_total : item.qty,
|
|
|
|
- price_tot_tot : ((item.qty * item.price_unit)),
|
|
|
|
- standar_tot_tot : ((item.qty * producto[0].standard_price)),
|
|
|
|
- partner_id : order.partner_id[0],
|
|
|
|
- utility_tot : (((item.qty * item.price_unit) - (item.qty * producto[0].standard_price))),
|
|
|
|
- store_id : store[0].store_ids[0],
|
|
|
|
- });
|
|
|
|
|
|
+ for (var k = 0; k < this.PosOrderLine.length; k++) {
|
|
|
|
+ item = this.PosOrderLine[k];
|
|
|
|
+ var order = self.getPosOrder(item.order_id[0]).shift();
|
|
|
|
+ var utc = moment.utc(item.create_date,'YYYY-MM-DD h:mm:ss A');
|
|
|
|
+ var date = moment(utc._d).format('DD/MM/YYYY h:mm A');
|
|
|
|
+ var date_aux=moment(utc._d).format('YYYY-MM-DD');
|
|
|
|
+ var pricelist = self.getProductPricelist(order.pricelist_id[0]).shift();
|
|
|
|
+ var currency = self.getResCurrency(pricelist.currency_id[0]).shift();
|
|
|
|
+ var product = this.getProductProduct(item.product_id);
|
|
|
|
+
|
|
|
|
+ if (product != undefined){
|
|
|
|
+ var store = self.getAccountJournal(order.sale_journal[0]);
|
|
|
|
+ if(store.length > 0){
|
|
|
|
+ data.push({
|
|
|
|
+ id : item.id,
|
|
|
|
+ order_id : item.order_id[0],
|
|
|
|
+ order_name: item.order_id[1],
|
|
|
|
+ ref : "",
|
|
|
|
+ partner_id : order.partner_id[0],
|
|
|
|
+ product_id : item.product_id[0],
|
|
|
|
+ number : order.name,
|
|
|
|
+ date : date_aux,
|
|
|
|
+ date_order : date,
|
|
|
|
+ partner : order.partner_id[1],
|
|
|
|
+ product_name : item.product_id[1],
|
|
|
|
+ price_unit_total : accounting.formatMoney(item.price_unit * (CurrencyBase.rate_silent / currency.rate_silent), '', CurrencyBase.decimal_places, CurrencyBase.thousands_separator, CurrencyBase.decimal_separator),
|
|
|
|
+ price_subtotal_total : accounting.formatMoney(item.price_subtotal * (CurrencyBase.rate_silent / currency.rate_silent), '', CurrencyBase.decimal_places, CurrencyBase.thousands_separator, CurrencyBase.decimal_separator),
|
|
|
|
+ amount_total : accounting.formatMoney((item.price_unit * item.qty) * (CurrencyBase.rate_silent / currency.rate_silent), '', CurrencyBase.decimal_places, CurrencyBase.thousands_separator, CurrencyBase.decimal_separator),
|
|
|
|
+ price_unit : accounting.formatNumber(item.price_unit * (CurrencyBase.rate_silent / currency.rate_silent),0,".",","),
|
|
|
|
+ qty : accounting.formatNumber(item.qty,0,".",","),
|
|
|
|
+ standard_price : accounting.formatNumber((product.standard_price),0, ".", ","),
|
|
|
|
+ price_tot : accounting.formatNumber((item.qty * item.price_unit),0, ".", ","),
|
|
|
|
+ standar_tot : accounting.formatNumber((item.qty * product.standard_price),0, ".", ","),
|
|
|
|
+ utility : accounting.formatNumber(((item.qty * item.price_unit) - (item.qty * product.standard_price)),0, ".", ","),
|
|
|
|
+ qty_total : item.qty,
|
|
|
|
+ price_tot_tot : ((item.qty * item.price_unit)),
|
|
|
|
+ standar_tot_tot : ((item.qty * product.standard_price)),
|
|
|
|
+ price_subtotal : item.price_subtotal * (CurrencyBase.rate_silent / currency.rate_silent),
|
|
|
|
+ category_name : product.categ_id.complete_name,
|
|
|
|
+ category_id : product.categ_id.id,
|
|
|
|
+ utility : accounting.formatNumber((((item.qty * item.price_unit)* (CurrencyBase.rate_silent / currency.rate_silent)) - (item.qty * product.standard_price)),0, ".", ","),
|
|
|
|
+ attribute_ids : product.attribute_ids,
|
|
|
|
+ attribute_value_ids : product.atribute_value_ids,
|
|
|
|
+ utility_tot : ((((item.qty * item.price_unit) * (CurrencyBase.rate_silent / currency.rate_silent)) - (item.qty * product.standard_price))),
|
|
|
|
+ store_id : store[0].store_ids[0],
|
|
|
|
+ });
|
|
|
|
+ }
|
|
|
|
+ }
|
|
}
|
|
}
|
|
- }
|
|
|
|
-
|
|
|
|
- for (var k = 0; k < this.invoiceLines.length; k++) {
|
|
|
|
- itemsale = this.invoiceLines[k];
|
|
|
|
-
|
|
|
|
- sale = this.getInvoice(itemsale.id);
|
|
|
|
-
|
|
|
|
- saleproducto = this.getProductInvoice(itemsale.product_id[0]);
|
|
|
|
|
|
|
|
|
|
|
|
- if (!saleproducto){
|
|
|
|
- saleproducto={};
|
|
|
|
- saleproducto.standard_price=0;
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- var storeVenta = self.getAccountJournalVentas(sale.journal_id[0]);
|
|
|
|
- if (!storeVenta){
|
|
|
|
- storeVenta={};
|
|
|
|
- storeVenta.standard_price=0;
|
|
|
|
- }
|
|
|
|
- if(storeVenta.length > 0 && saleproducto.length > 0){
|
|
|
|
- data.push({
|
|
|
|
- id : itemsale.id,
|
|
|
|
- order_id : itemsale.invoice_id[0],
|
|
|
|
- ref: itemsale.invoice_id[1],
|
|
|
|
- order_name : "",
|
|
|
|
- date : sale.create_date,
|
|
|
|
- date_order : moment(sale.create_date).format("DD/MM/YYYY"),
|
|
|
|
- partner: sale.partner_id[1],
|
|
|
|
- product_id : itemsale.product_id[0],
|
|
|
|
- product_name : itemsale.product_id[1],
|
|
|
|
- qty : accounting.formatNumber(itemsale.quantity,0,".",","),
|
|
|
|
- price_unit : accounting.formatNumber(itemsale.price_unit,0,".",","),
|
|
|
|
- standard_price : accounting.formatNumber((saleproducto[0].standard_price),0, ".", ","),
|
|
|
|
- price_tot : accounting.formatNumber((itemsale.quantity * itemsale.price_unit),0, ".", ","),
|
|
|
|
- standar_tot : accounting.formatNumber((itemsale.quantity * saleproducto[0].standard_price),0, ".", ","),
|
|
|
|
- utility : accounting.formatNumber(((itemsale.quantity * itemsale.price_unit) - (itemsale.quantity * saleproducto[0].standard_price)),0, ".", ","),
|
|
|
|
- qty_total : itemsale.quantity,
|
|
|
|
- price_tot_tot : ((itemsale.quantity * itemsale.price_unit)),
|
|
|
|
- standar_tot_tot : ((itemsale.quantity * saleproducto[0].standard_price)),
|
|
|
|
- partner_id : sale.partner_id[0],
|
|
|
|
- utility_tot : (((itemsale.quantity * itemsale.price_unit) - (itemsale.quantity * saleproducto[0].standard_price))),
|
|
|
|
- store_id : storeVenta[0].store_ids[0],
|
|
|
|
- });
|
|
|
|
|
|
+ for (var i = 0; i < this.AccountInvoiceLine.length; i++) {
|
|
|
|
+ item = this.AccountInvoiceLine[i];
|
|
|
|
+ var invoice = self.getAccountInvoice(item.invoice_id[0]).shift();
|
|
|
|
+ var currency = self.getResCurrency(invoice.currency_id[0]).shift();
|
|
|
|
+ var product = this.getProductProduct(item.product_id);
|
|
|
|
+ if (!product){
|
|
|
|
+ product={};
|
|
|
|
+ product.standard_price=0;
|
|
|
|
+ product.categ_id="";
|
|
|
|
+ }
|
|
|
|
+ if (product != undefined){
|
|
|
|
+ var storeVenta = self.getAccountJournal(invoice.journal_id[0]);
|
|
|
|
+ if(storeVenta.length > 0){
|
|
|
|
+ data.push({
|
|
|
|
+ id : item.id,
|
|
|
|
+ order_id : "",
|
|
|
|
+ ref : item.invoice_id[1],
|
|
|
|
+ partner_id : invoice.partner_id[0],
|
|
|
|
+ product_id : item.product_id[0],
|
|
|
|
+ number : invoice.number,
|
|
|
|
+ date : date_aux,
|
|
|
|
+ date_order : date,
|
|
|
|
+ partner : invoice.partner_id[1],
|
|
|
|
+ product_name : item.product_id[1],
|
|
|
|
+ price_unit_total : accounting.formatMoney(item.price_unit * (CurrencyBase.rate_silent / currency.rate_silent), '', CurrencyBase.decimal_places, CurrencyBase.thousands_separator, CurrencyBase.decimal_separator),
|
|
|
|
+ price_subtotal_total : accounting.formatMoney(item.price_subtotal * (CurrencyBase.rate_silent / currency.rate_silent), '', CurrencyBase.decimal_places, CurrencyBase.thousands_separator, CurrencyBase.decimal_separator),
|
|
|
|
+ amount_total : accounting.formatMoney((item.price_unit * item.quantity) * (CurrencyBase.rate_silent / currency.rate_silent), '', CurrencyBase.decimal_places, CurrencyBase.thousands_separator, CurrencyBase.decimal_separator),
|
|
|
|
+ price_unit : accounting.formatNumber(item.price_unit * (CurrencyBase.rate_silent / currency.rate_silent),0,".",","),
|
|
|
|
+ qty : accounting.formatNumber(item.quantity,0,".",","),
|
|
|
|
+ standard_price : accounting.formatNumber((product.standard_price),0, ".", ","),
|
|
|
|
+ price_tot : accounting.formatNumber((item.quantity * item.price_unit),0, ".", ","),
|
|
|
|
+ standar_tot : accounting.formatNumber((item.quantity * product.standard_price),0, ".", ","),
|
|
|
|
+ utility : accounting.formatNumber(((item.quantity * item.price_unit) - (item.quantity * product.standard_price)),0, ".", ","),
|
|
|
|
+ qty_total : item.quantity,
|
|
|
|
+ price_tot_tot : ((item.quantity * item.price_unit)),
|
|
|
|
+ standar_tot_tot : ((item.quantity * product.standard_price)),
|
|
|
|
+ price_subtotal : item.price_subtotal * (CurrencyBase.rate_silent / currency.rate_silent),
|
|
|
|
+ category_name : product.categ_id.complete_name,
|
|
|
|
+ category_id : product.categ_id.id,
|
|
|
|
+ utility : accounting.formatNumber((((item.quantity * item.price_unit)* (CurrencyBase.rate_silent / currency.rate_silent)) - (item.quantity * product.standard_price)),0, ".", ","),
|
|
|
|
+ attribute_ids : product.attribute_ids,
|
|
|
|
+ attribute_value_ids : product.atribute_value_ids,
|
|
|
|
+ utility_tot : ((((item.quantity * item.price_unit) * (CurrencyBase.rate_silent / currency.rate_silent)) - (item.quantity * product.standard_price))),
|
|
|
|
+ store_id : storeVenta[0].store_ids[0],
|
|
|
|
+ });
|
|
|
|
+ }
|
|
|
|
+ }
|
|
}
|
|
}
|
|
- }
|
|
|
|
|
|
+
|
|
this.rowsData=data;
|
|
this.rowsData=data;
|
|
self.content=data;
|
|
self.content=data;
|
|
this.loadTable(data)
|
|
this.loadTable(data)
|
|
@@ -550,6 +656,10 @@ function report_ventas_pos_orders(reporting){
|
|
var desde =this.$el.find('#from').val();
|
|
var desde =this.$el.find('#from').val();
|
|
var hasta =this.$el.find('#to').val();
|
|
var hasta =this.$el.find('#to').val();
|
|
var store = this.$el.find('#current-store').val();
|
|
var store = this.$el.find('#current-store').val();
|
|
|
|
+ var categ_ids = [];
|
|
|
|
+ var category = self.$el.find('#current-category').val();
|
|
|
|
+ var attribute = self.$el.find('#current-attribute').val();
|
|
|
|
+ var attribute_value = self.$el.find('#current-attribute-value').val();
|
|
var partner= this.$el.find('#partner').val().split('-');
|
|
var partner= this.$el.find('#partner').val().split('-');
|
|
var product = this.$el.find('#product').val().split('-');
|
|
var product = this.$el.find('#product').val().split('-');
|
|
var content = self.content;
|
|
var content = self.content;
|
|
@@ -600,6 +710,52 @@ function report_ventas_pos_orders(reporting){
|
|
});
|
|
});
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ if(category){
|
|
|
|
+ // Nivel 0, nivel 1
|
|
|
|
+ var category_ids = _.map(_.filter(self.ProductCategory,function (item) {
|
|
|
|
+ return item.id == category || item.parent_id[0] == category;
|
|
|
|
+ }), function(map){
|
|
|
|
+ return map.id;
|
|
|
|
+ });
|
|
|
|
+
|
|
|
|
+ // Nivel 0, nivel 1, nivel 2
|
|
|
|
+ var category_children_ids = _.map(_.filter(self.ProductCategory,function (item) {
|
|
|
|
+ return _.contains(category_ids, item.parent_id[0]) || item.id == category;
|
|
|
|
+ }), function(map){
|
|
|
|
+ return map.id;
|
|
|
|
+ });
|
|
|
|
+
|
|
|
|
+ var category_grandchildren_ids = _.map(_.filter(self.ProductCategory,function (item) {
|
|
|
|
+ return _.contains(category_children_ids, item.parent_id[0]) || item.id == category;
|
|
|
|
+ }), function(map){
|
|
|
|
+ return map.id;
|
|
|
|
+ }) ;
|
|
|
|
+
|
|
|
|
+ categ_ids = _.map(_.filter(self.ProductCategory,function (item) {
|
|
|
|
+ return _.contains(category_grandchildren_ids, item.parent_id[0]) || item.id == category;
|
|
|
|
+ }), function(map){
|
|
|
|
+ return map.id;
|
|
|
|
+ });
|
|
|
|
+ };
|
|
|
|
+
|
|
|
|
+ if(category && category != 9999999){
|
|
|
|
+ content = _.filter(content,function (inv) {
|
|
|
|
+ return _.contains(categ_ids, inv.category_id);
|
|
|
|
+ });
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if(attribute && attribute != 9999999 && attribute_value == 9999999){
|
|
|
|
+ content = _.filter(content,function (inv) {
|
|
|
|
+ return _.contains(inv.attribute_ids, parseInt(attribute));
|
|
|
|
+ });
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if(attribute_value && attribute_value != 9999999){
|
|
|
|
+ content = _.filter(content,function (inv) {
|
|
|
|
+ return _.contains(inv.attribute_value_ids, parseFloat(attribute_value));
|
|
|
|
+ });
|
|
|
|
+ }
|
|
|
|
+
|
|
if (partner != ""){
|
|
if (partner != ""){
|
|
content = _.filter(content, function(inv){
|
|
content = _.filter(content, function(inv){
|
|
return inv.partner_id == partner[0];
|
|
return inv.partner_id == partner[0];
|
|
@@ -685,39 +841,6 @@ function report_ventas_pos_orders(reporting){
|
|
var rows=[];
|
|
var rows=[];
|
|
var rows = self.rowsData;
|
|
var rows = self.rowsData;
|
|
|
|
|
|
- // var qty =_.reduce(_.map(rows,function(map){
|
|
|
|
- // return(map.qty_total);
|
|
|
|
- // }),function(memo, num){
|
|
|
|
- // return memo + num;
|
|
|
|
- // },0);
|
|
|
|
- //
|
|
|
|
- // var price_tot =_.reduce(_.map(rows,function(map){
|
|
|
|
- // return(map.price_tot_tot);
|
|
|
|
- // }),function(memo, num){
|
|
|
|
- // return memo + num;
|
|
|
|
- // },0);
|
|
|
|
- //
|
|
|
|
- // var standar_tot =_.reduce(_.map(rows,function(map){
|
|
|
|
- // return(map.standar_tot_tot);
|
|
|
|
- // }),function(memo, num){
|
|
|
|
- // return memo + num;
|
|
|
|
- // },0);
|
|
|
|
- //
|
|
|
|
- // var utility =_.reduce(_.map(rows,function(map){
|
|
|
|
- // return(map.utility_tot);
|
|
|
|
- // }),function(memo, num){
|
|
|
|
- // return memo + num;
|
|
|
|
- // },0);
|
|
|
|
- //
|
|
|
|
- // if (rows.length > 0){
|
|
|
|
- // rows.push({
|
|
|
|
- // order_name : "Totales ",
|
|
|
|
- // qty : accounting.formatNumber(qty,0,".",","),
|
|
|
|
- // price_tot : accounting.formatNumber(price_tot,0,".",","),
|
|
|
|
- // standar_tot : accounting.formatNumber(standar_tot,0,".",","),
|
|
|
|
- // utility : accounting.formatNumber(utility,0,".",","),
|
|
|
|
- // });
|
|
|
|
- // }
|
|
|
|
return rows;
|
|
return rows;
|
|
},
|
|
},
|
|
|
|
|