|
@@ -6,7 +6,14 @@ function report_ventas_pos_orders(reporting){
|
|
|
reporting.ReportVentasPosOrdersWidget = reporting.Base.extend({
|
|
|
template: 'ReportVentasPosOrders',
|
|
|
rowsData :[],
|
|
|
+ modules:[],
|
|
|
PosOrderLine: [],
|
|
|
+ accountJournal:[],
|
|
|
+ productProduct:[],
|
|
|
+ productInvoice:[],
|
|
|
+ invoices: [],
|
|
|
+ invoiceLines: [],
|
|
|
+ PosOrder: [],
|
|
|
content:[],
|
|
|
|
|
|
events:{
|
|
@@ -17,12 +24,9 @@ function report_ventas_pos_orders(reporting){
|
|
|
'click #C' : 'fectSearch',
|
|
|
'click #D' : 'fectSearch',
|
|
|
'click #Z' : 'fectSearch',
|
|
|
+ 'change #current-store': 'fectSearch',
|
|
|
'change #from' : 'fectSearch',
|
|
|
'change #to': 'fectSearch',
|
|
|
- 'change #current-category' : 'fectSearch',
|
|
|
- 'change #current-floor': 'fectSearch',
|
|
|
- 'change #current-table': 'fectSearch',
|
|
|
- 'change #current-store': 'fectSearch',
|
|
|
'click-row.bs.table #table' : 'clickAnalysisDetail',
|
|
|
},
|
|
|
|
|
@@ -37,18 +41,79 @@ function report_ventas_pos_orders(reporting){
|
|
|
this.submitForm();
|
|
|
},
|
|
|
|
|
|
+ // Redirecionar
|
|
|
+ renderReport: function () {
|
|
|
+ var self = this;
|
|
|
+
|
|
|
+ var container = this.$el.closest('.oe_form_sheet.oe_form_sheet_width');
|
|
|
+ this.$el.closest('.report_view').remove();
|
|
|
+ container.find('.report_view').show({
|
|
|
+ effect: 'fade',
|
|
|
+ duration: 200,
|
|
|
+ });
|
|
|
+ },
|
|
|
+
|
|
|
+ // Verificar el modelo
|
|
|
+ checkModel : function(model){
|
|
|
+ var self = this;
|
|
|
+ return _.filter(self.modules,function(item){return item.name === model});
|
|
|
+ },
|
|
|
+
|
|
|
+ // Lanzar el mensaje
|
|
|
+ showMensaje : function(modelos){
|
|
|
+ var self = this;
|
|
|
+ $("#dialog" ).dialog({
|
|
|
+ autoOpen: true,
|
|
|
+ resizable: false,
|
|
|
+ modal: true,
|
|
|
+ title: 'Atención',
|
|
|
+ width: 500,
|
|
|
+ open: function() {
|
|
|
+ $(this).html('Reporte in-disponible, contacte con el administrador del sistema ref : '+modelos);
|
|
|
+ },
|
|
|
+ show: {
|
|
|
+ effect: "fade",
|
|
|
+ duration: 200
|
|
|
+ },
|
|
|
+ hide: {
|
|
|
+ effect: "fade",
|
|
|
+ duration: 200
|
|
|
+ },
|
|
|
+ buttons: {
|
|
|
+ Aceptar: function() {
|
|
|
+ $(this).dialog('close');
|
|
|
+ self.renderReport()
|
|
|
+ }
|
|
|
+ }
|
|
|
+ });
|
|
|
+ return
|
|
|
+ },
|
|
|
+
|
|
|
clickAnalysisDetail: function(e, row, $element, field){
|
|
|
+ if (field == 'ref'){
|
|
|
+ this.do_action({
|
|
|
+ name:"Factura de cliente",
|
|
|
+ type: 'ir.actions.act_window',
|
|
|
+ res_model: "account.invoice",
|
|
|
+ views: [[false,'form']],
|
|
|
+ target: 'new',
|
|
|
+ domain: [['type', '=', 'out_invoice'],['id','=', row.order_id]],
|
|
|
+ context: {},
|
|
|
+ flags: {'form': {'action_buttons': false, 'options': {'mode': 'view'}}},
|
|
|
+ res_id: row.order_id,
|
|
|
+ });
|
|
|
+ }
|
|
|
if (field == 'order_name'){
|
|
|
this.do_action({
|
|
|
- name : "Pedido",
|
|
|
- type : 'ir.actions.act_window',
|
|
|
- res_model : "pos.order",
|
|
|
- views : [[false,'form']],
|
|
|
- target : 'new',
|
|
|
- domain : [['id','=', row.order_id]],
|
|
|
- context : {},
|
|
|
- flags : {'form': {'action_buttons': false, 'options': {'mode': 'view'}}},
|
|
|
- res_id : row.order_id,
|
|
|
+ name:"Pos",
|
|
|
+ type: 'ir.actions.act_window',
|
|
|
+ res_model: "pos.order",
|
|
|
+ views: [[false,'form']],
|
|
|
+ target: 'new',
|
|
|
+ domain: [['id','=', row.id]],
|
|
|
+ context: {},
|
|
|
+ flags: {'form': {'action_buttons': false, 'options': {'mode': 'view'}}},
|
|
|
+ res_id: row.id,
|
|
|
});
|
|
|
}
|
|
|
if (field == 'product_name'){
|
|
@@ -111,22 +176,40 @@ function report_ventas_pos_orders(reporting){
|
|
|
// Consultar
|
|
|
submitForm: function () {
|
|
|
var self = this;
|
|
|
- this.fetchPosOrder().then(function(PosOrder) {
|
|
|
+ self.fecthIrModuleModule().then(function(modules){
|
|
|
+ self.modules = modules;
|
|
|
+ return modules;
|
|
|
+ }).then(function(modules){
|
|
|
+ return self.fetchPosOrder();
|
|
|
+ }).then(function(PosOrder) {
|
|
|
self.PosOrder = PosOrder;
|
|
|
return PosOrder;
|
|
|
}).then(function (PosOrder) {
|
|
|
- return self.fetchPosOrderLine(PosOrder);
|
|
|
+ return self.fetchPosOrderLine();
|
|
|
}).then(function (PosOrderLine) {
|
|
|
self.PosOrderLine = PosOrderLine;
|
|
|
- return self.fetchProductProduct(PosOrderLine);
|
|
|
+ return self.fetchProductProduct();
|
|
|
}).then(function (ProductProduct) {
|
|
|
self.ProductProduct = ProductProduct;
|
|
|
- return self.fecthSalesOrder();
|
|
|
- }).then(function (SalesOrder) {
|
|
|
- self.SalesOrder = SalesOrder;
|
|
|
- return self.fecthSalesOrderLine(SalesOrder);
|
|
|
- }).then(function (SalesOrderLine) {
|
|
|
- self.SalesOrderLine = SalesOrderLine;
|
|
|
+ return self.fecthResStore();
|
|
|
+ }).then(function(ResStore){
|
|
|
+ self.ResStore = ResStore;
|
|
|
+ self.$el.find('#current-store').append('<option value="9999999">Todas las SUC.</option>');
|
|
|
+ _.each(ResStore,function(item){
|
|
|
+ self.$el.find('#current-store').append('<option value="' + item.id + '">' + item.name + '</option>');
|
|
|
+ });
|
|
|
+ return self.fecthAccountJournal();
|
|
|
+ }).then(function(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.fetchResPartner();
|
|
|
}).then(function (ResPartner){
|
|
|
self.ResPartner = ResPartner;
|
|
@@ -135,33 +218,105 @@ function report_ventas_pos_orders(reporting){
|
|
|
});
|
|
|
},
|
|
|
|
|
|
- // 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(){
|
|
|
- // var self = this;
|
|
|
- // var defer = $.Deferred();
|
|
|
- // var field = ['id', 'name','store_ids'];
|
|
|
- // var domain = [['active','=',true],['type','in',['sale','purchase']]];
|
|
|
- // var AccountJournal = new model.web.Model('account.journal');
|
|
|
- // AccountJournal.query(field).filter(domain).all().then(function(results){
|
|
|
- // defer.resolve(results);
|
|
|
- // });
|
|
|
- // return defer;
|
|
|
- // },
|
|
|
+ // Modelos instalados
|
|
|
+ fecthIrModuleModule: function(){
|
|
|
+ var self = this;
|
|
|
+ var defer = $.Deferred();
|
|
|
+ var fields = ['name','id'];
|
|
|
+ var domain=[['state','=','installed']];
|
|
|
+ var irModule = new model.web.Model('ir.module.module');
|
|
|
+
|
|
|
+ irModule.query(fields).filter(domain).all().then(function(results){
|
|
|
+ defer.resolve(results);
|
|
|
+ });
|
|
|
+ return defer;
|
|
|
+ },
|
|
|
+
|
|
|
+ fecthAccountJournal: function(){
|
|
|
+ var self = this;
|
|
|
+ var defer = $.Deferred();
|
|
|
+ var field = ['id', 'name','store_ids'];
|
|
|
+ var domain = [['active','=',true],['type','in',['sale','purchase']]];
|
|
|
+ var AccountJournal = new model.web.Model('account.journal');
|
|
|
+ AccountJournal.query(field).filter(domain).all().then(function(results){
|
|
|
+ defer.resolve(results);
|
|
|
+ });
|
|
|
+ return defer;
|
|
|
+ },
|
|
|
+
|
|
|
+ // Invoice (FACTURAS)
|
|
|
+ fetchInvoiceV2: function () {
|
|
|
+ var self = this;
|
|
|
+ var filter ="[['state', 'in',['open','paid']],['type', '=', 'out_invoice']";
|
|
|
+ var journal_ids = _.flatten(_.map(self.AccountJournal, function (item) {
|
|
|
+ return item.id;
|
|
|
+ }));
|
|
|
+ if (journal_ids){
|
|
|
+ filter=filter.concat(",['journal_id', 'in',["+journal_ids+"]]");
|
|
|
+ }
|
|
|
+ filter=filter.concat("]");
|
|
|
+ var field =['id', 'type', 'number', 'origin', 'state', 'journal_id', 'currency_id', 'invoice_line','date_invoice','partner_id'];
|
|
|
+ var defer = $.Deferred();
|
|
|
+ var Invoice = new model.web.Model('account.invoice');
|
|
|
+ Invoice.query(field).filter(filter).all().then(function (results) {
|
|
|
+ defer.resolve(results);
|
|
|
+ });
|
|
|
+ return defer;
|
|
|
+ },
|
|
|
+
|
|
|
+ // Invoice line (Linea de Factura)
|
|
|
+ fetchInvoiceLine: function (invoices) {
|
|
|
+ var self = this;
|
|
|
+ var defer = $.Deferred();
|
|
|
+ var linesIds = _.flatten(_.map(self.invoices, function (item) {
|
|
|
+ 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) {
|
|
|
+ defer.resolve(results)
|
|
|
+ });
|
|
|
+ return defer;
|
|
|
+ },
|
|
|
+
|
|
|
+ // clientes
|
|
|
+ fetchResPartner: function () {
|
|
|
+ var self = this;
|
|
|
+ var defer = $.Deferred();
|
|
|
+ var fields = ['id','name','ruc'];
|
|
|
+ var domain = [['active', '=', true],['customer', '=', true]];
|
|
|
+ var ResPartner = new model.web.Model('res.partner');
|
|
|
+ ResPartner.query(fields).filter(domain).all().then(function(results){
|
|
|
+ defer.resolve(results);
|
|
|
+ });
|
|
|
+ return defer;
|
|
|
+ },
|
|
|
+
|
|
|
+ // Product Product
|
|
|
+ fecthProduct: function(invoiceLines){
|
|
|
+ var self = this;
|
|
|
+ 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)
|
|
|
+ });
|
|
|
+ return defer;
|
|
|
+ },
|
|
|
|
|
|
// Ventas (Point Of Sale)
|
|
|
fetchPosOrder: function () {
|
|
|
var self = this;
|
|
|
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','date_order','lines','table_id','sale_journal'];
|
|
|
var domain = [['state', 'not in', ['draft','cancel']]];
|
|
|
var PosOrder = new model.web.Model('pos.order');
|
|
@@ -182,19 +337,6 @@ function report_ventas_pos_orders(reporting){
|
|
|
var domain = [['order_id', 'in', ids]];
|
|
|
var PosOrderLine = new model.web.Model('pos.order.line');
|
|
|
PosOrderLine.query().filter(domain).all().then(function (results) {
|
|
|
- defer.resolve(results)
|
|
|
- });
|
|
|
- return defer;
|
|
|
- },
|
|
|
-
|
|
|
- // clientes
|
|
|
- fetchResPartner: function () {
|
|
|
- var self = this;
|
|
|
- var defer = $.Deferred();
|
|
|
- var fields = ['id','name','ruc'];
|
|
|
- var domain = [['active', '=', true],['customer', '=', true]];
|
|
|
- var ResPartner = new model.web.Model('res.partner');
|
|
|
- ResPartner.query(fields).filter(domain).all().then(function(results){
|
|
|
defer.resolve(results);
|
|
|
});
|
|
|
return defer;
|
|
@@ -216,41 +358,6 @@ function report_ventas_pos_orders(reporting){
|
|
|
return defer;
|
|
|
},
|
|
|
|
|
|
- // fecthPosCategory: function(){
|
|
|
- // var self = this;
|
|
|
- // var defer = $.Deferred();
|
|
|
- // var fields = ['id','name'];
|
|
|
- // var PosCategory = new model.web.Model('pos.category');
|
|
|
- // PosCategory.query(fields).filter().all().then(function (results) {
|
|
|
- // defer.resolve(results)
|
|
|
- // });
|
|
|
- // return defer;
|
|
|
- // },
|
|
|
-
|
|
|
- // Mesa o delivery
|
|
|
- // fetchPosTable: function(){
|
|
|
- // var self = this;
|
|
|
- // var defer = $.Deferred();
|
|
|
- // var fields = ['id','name', 'floor_id'];
|
|
|
- // var ProductProduct = new model.web.Model('pos.table');
|
|
|
- // ProductProduct.query(fields).filter().all().then(function (results) {
|
|
|
- // defer.resolve(results);
|
|
|
- // });
|
|
|
- // return defer;
|
|
|
- // },
|
|
|
-
|
|
|
- // Salon o Delivery
|
|
|
- // fetchPosFloor: function(){
|
|
|
- // var self = this;
|
|
|
- // var defer = $.Deferred();
|
|
|
- // var fields = ['id','name', 'table_ids'];
|
|
|
- // var ProductProduct = new model.web.Model('pos.floor');
|
|
|
- // ProductProduct.query(fields).filter().all().then(function (results) {
|
|
|
- // defer.resolve(results);
|
|
|
- // });
|
|
|
- // return defer;
|
|
|
- // },
|
|
|
-
|
|
|
getPosOrder: function(id){
|
|
|
var self = this;
|
|
|
return _.filter(self.PosOrder,function (item) {
|
|
@@ -258,81 +365,54 @@ function report_ventas_pos_orders(reporting){
|
|
|
});
|
|
|
},
|
|
|
|
|
|
- getSaleOrder: function(id){
|
|
|
+ // Obtener las lineas de las Facturas
|
|
|
+ getProductProduct: function(id){
|
|
|
var self = this;
|
|
|
- return _.filter(self.SaleOrder,function (item) {
|
|
|
- return item.id == id;
|
|
|
+
|
|
|
+ return _.filter(self.ProductProduct, function(item){
|
|
|
+ return item.id === id;
|
|
|
});
|
|
|
},
|
|
|
|
|
|
- // getPosTable: function(id){
|
|
|
- // var self = this;
|
|
|
- // return _.filter(self.PosTable,function (item) {
|
|
|
- // return item.id == id;
|
|
|
- // });
|
|
|
- // },
|
|
|
-
|
|
|
// Obtener las lineas de las Facturas
|
|
|
- getProductProduct: function(id){
|
|
|
+ getProductInvoice: function(id){
|
|
|
var self = this;
|
|
|
- //return _.find(self.ProductProduct, function(item){
|
|
|
- // return item.id == id;
|
|
|
- //});
|
|
|
- return _.filter(self.ProductProduct, function(item){
|
|
|
+ return _.filter(self.ProductInvoice, function(item){
|
|
|
return item.id === id;
|
|
|
});
|
|
|
},
|
|
|
|
|
|
- // getPosCategory: function(id){
|
|
|
- // var self = this;
|
|
|
- // return _.filter(self.PosCategory, function(item){
|
|
|
- // return item.id == id;
|
|
|
- // });
|
|
|
- // },
|
|
|
-
|
|
|
- // getAccountJournal: function (id) {
|
|
|
- // var self = this;
|
|
|
- // return _.filter(self.AccountJournal,function (item) {
|
|
|
- // return item.id === id;
|
|
|
- // });
|
|
|
- // },
|
|
|
+ getAccountJournal: function (id) {
|
|
|
+ var self = this;
|
|
|
+ return _.filter(self.AccountJournal,function (item) {
|
|
|
+ return item.id === id;
|
|
|
+ });
|
|
|
+ },
|
|
|
|
|
|
// Obtener Pedido
|
|
|
- fecthSalesOrder: function() {
|
|
|
+ fecthResStore: function(){
|
|
|
var self = this;
|
|
|
var defer = $.Deferred();
|
|
|
- var modules = self.checkModel('sale');
|
|
|
-
|
|
|
- if (modules.length <= 0){
|
|
|
- self.showMensaje('sale');
|
|
|
- return defer;
|
|
|
- }
|
|
|
-
|
|
|
- var fields = ['id', 'order_line', 'date_order'];
|
|
|
- // var domain = [['date_order', '>=', desde], ['date_order', '<', hasta], ['state', 'in', ['paid','done','invoiced']]];
|
|
|
- var domain = [ ['state', 'in', ['done', 'progress']]];
|
|
|
- var SalesOrder = new instance.web.Model('sale.order');
|
|
|
- SalesOrder.query(fields).filter(domain).all().then(function (results) {
|
|
|
+ var field=['id', 'name'];
|
|
|
+ var ResStore = new model.web.Model('res.store');
|
|
|
+ ResStore.query(field).all().then(function(results){
|
|
|
defer.resolve(results);
|
|
|
});
|
|
|
-
|
|
|
return defer;
|
|
|
},
|
|
|
- // Obtener linea de la factura
|
|
|
- fecthSalesOrderLine: function(SalesOrder) {
|
|
|
- var self = this;
|
|
|
- var defer = $.Deferred();
|
|
|
- var order_line = _.flatten(_.map(SalesOrder, function (item) {
|
|
|
- return item.order_line;
|
|
|
- }));
|
|
|
- var fields = ['id', 'product_id', 'create_date', 'product_uom_qty', 'price_unit'];
|
|
|
- var domain = [['id','in', order_line]];
|
|
|
- var SalesOrderLine = new instance.web.Model('sale.order.line');
|
|
|
- SalesOrderLine.query(fields).filter(domain).all().then(function (results) {
|
|
|
- defer.resolve(results);
|
|
|
+
|
|
|
+ // Obtener la Detalles de la Factura
|
|
|
+ getInvoice: function (id_line){
|
|
|
+ return _.find(this.invoices, function (inv) {
|
|
|
+ return _.contains(inv.invoice_line, id_line);
|
|
|
});
|
|
|
+ },
|
|
|
|
|
|
- return defer;
|
|
|
+ getAccountJournalVentas: function (id) {
|
|
|
+ var self = this;
|
|
|
+ return _.filter(self.AccountJournal,function (item) {
|
|
|
+ return item.id === id;
|
|
|
+ });
|
|
|
},
|
|
|
|
|
|
BuildTable: function(){
|
|
@@ -343,20 +423,20 @@ function report_ventas_pos_orders(reporting){
|
|
|
var itemsale;
|
|
|
var producto = [];
|
|
|
var saleproducto = [];
|
|
|
- var category;
|
|
|
var item;
|
|
|
- var category_name;
|
|
|
- var category_id;
|
|
|
- var store;
|
|
|
|
|
|
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();
|
|
|
- if(producto.length > 0){
|
|
|
+
|
|
|
+ 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 : order.date_order,
|
|
|
date_order : moment(order.date_order).format("DD/MM/YYYY"),
|
|
@@ -372,56 +452,53 @@ function report_ventas_pos_orders(reporting){
|
|
|
price_tot_tot : ((item.qty * item.price_unit)),
|
|
|
standar_tot_tot : ((item.qty * producto[0].standard_price)),
|
|
|
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.SaleOrderLine.length; k++) {
|
|
|
- // itemsale = this.SaleOrderLine[k];
|
|
|
- // console.log(itemsale);
|
|
|
- // saleproducto = self.getProductProduct(itemsale.product_id[0]);
|
|
|
- // sale = self.getSaleOrder(itemsale.order_id[0]).shift();
|
|
|
- // store = self.getAccountJournal(order.sale_journal[0]);
|
|
|
- // category = self.getPosCategory(item.product_id[0]);
|
|
|
- // if(category.length > 0){
|
|
|
- // category_name = category[0].name;
|
|
|
- // category_id = category[0].id;
|
|
|
- // }else {
|
|
|
- // category_name = '';
|
|
|
- // category_id = '';
|
|
|
- // }
|
|
|
- // var place_id;
|
|
|
- // var place_name;
|
|
|
- // var floor;
|
|
|
- // if(order.table_id){
|
|
|
- // floor = self.getPosTable(order.table_id[0]).shift();
|
|
|
- // floor = floor.floor_id[0];
|
|
|
- // place_id = order.table_id[0];
|
|
|
- // place_name = order.table_id[1];
|
|
|
- // }
|
|
|
- // }
|
|
|
- // if(saleproducto.length > 0){
|
|
|
- // data.push({
|
|
|
- // id : itemsale.id,
|
|
|
- // order_id : itemsale.order_id[0],
|
|
|
- // order_name : itemsale.order_id[1],
|
|
|
- // date : sale.create_date,
|
|
|
- // date_order : moment(sale.create_date).format("DD/MM/YYYY"),
|
|
|
- // product_id : itemsale.product_id[0],
|
|
|
- // product_name : itemsale.product_id[1],
|
|
|
- // qty : accounting.formatNumber(itemsale.product_uom_qty,0,".",","),
|
|
|
- // price_unit : accounting.formatNumber(itemsale.price_unit,0,".",","),
|
|
|
- // standard_price : accounting.formatNumber((saleproducto[0].standard_price),0, ".", ","),
|
|
|
- // price_tot : accounting.formatNumber((itemsale.product_uom_qty * itemsale.price_unit),0, ".", ","),
|
|
|
- // standar_tot : accounting.formatNumber((itemsale.product_uom_qty * saleproducto[0].standard_price),0, ".", ","),
|
|
|
- // utility : accounting.formatNumber(((itemsale.product_uom_qty * itemsale.price_unit) - (itemsale.product_uom_qty * saleproducto[0].standard_price)),0, ".", ","),
|
|
|
- // qty_total : itemsale.product_uom_qty,
|
|
|
- // price_tot_tot : ((itemsale.product_uom_qty * itemsale.price_unit)),
|
|
|
- // standar_tot_tot : ((itemsale.product_uom_qty * saleproducto[0].standard_price)),
|
|
|
- // utility_tot : (((itemsale.product_uom_qty * itemsale.price_unit) - (itemsale.product_uom_qty * saleproducto[0].standard_price))),
|
|
|
- // });
|
|
|
- // }
|
|
|
- // }
|
|
|
+ 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"),
|
|
|
+ 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)),
|
|
|
+ utility_tot : (((itemsale.quantity * itemsale.price_unit) - (itemsale.quantity * saleproducto[0].standard_price))),
|
|
|
+ store_id : storeVenta[0].store_ids[0],
|
|
|
+ });
|
|
|
+ }
|
|
|
+ }
|
|
|
this.rowsData=data;
|
|
|
self.content=data;
|
|
|
this.loadTable(data)
|
|
@@ -429,58 +506,35 @@ function report_ventas_pos_orders(reporting){
|
|
|
|
|
|
fectSearch: function(){
|
|
|
var self = this;
|
|
|
- var hoy = moment().format('YYYY-MM-DD');
|
|
|
- var floor =this.$el.find('#current-floor').val();
|
|
|
- var table =this.$el.find('#current-table').val();
|
|
|
- var category = this.$el.find('#current-category').val();
|
|
|
- var store =this.$el.find('#current-store').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 store = this.$el.find('#current-store').val();
|
|
|
var product = this.$el.find('#product').val().split('-');
|
|
|
var content = self.content;
|
|
|
|
|
|
// Hoy
|
|
|
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);
|
|
|
- date[2] = '0'+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 = 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;
|
|
|
- }
|
|
|
- }
|
|
|
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') == last_month;
|
|
|
});
|
|
|
}
|
|
|
if ($('#Z').is(":checked")){
|
|
@@ -501,20 +555,6 @@ function report_ventas_pos_orders(reporting){
|
|
|
$('#datepicker').css('display','none');
|
|
|
}
|
|
|
|
|
|
- // Filtrar por piso o delivery
|
|
|
- // if (floor != 9999999){
|
|
|
- // content=_.filter(content, function (inv){
|
|
|
- // return inv.floor_id == floor;
|
|
|
- // });
|
|
|
- // }
|
|
|
-
|
|
|
- // Filtrar por mesa o delivery
|
|
|
- // if (table != 9999999){
|
|
|
- // content=_.filter(content, function (inv){
|
|
|
- // return inv.table_id == table;
|
|
|
- // });
|
|
|
- // }
|
|
|
-
|
|
|
// Buscar Producto
|
|
|
if (product != ""){
|
|
|
content = _.filter(content, function(inv){
|
|
@@ -528,11 +568,11 @@ function report_ventas_pos_orders(reporting){
|
|
|
// });
|
|
|
// }
|
|
|
|
|
|
- // if (store != 9999999){
|
|
|
- // content=_.filter(content, function (inv){
|
|
|
- // return inv.store_id == store;
|
|
|
- // });
|
|
|
- // }
|
|
|
+ if (store != 9999999){
|
|
|
+ content=_.filter(content, function (inv){
|
|
|
+ return inv.store_id == store;
|
|
|
+ });
|
|
|
+ }
|
|
|
|
|
|
var qty_total_total = _.reduce(_.map(content,function(map){
|
|
|
return(map.qty_total);
|
|
@@ -682,6 +722,7 @@ function report_ventas_pos_orders(reporting){
|
|
|
styles: { overflow: 'linebreak', fontSize: 8, columnWidth: 'wrap'},
|
|
|
columnStyles: {
|
|
|
order_name: {halign:'left', fontStyle: 'bold'},
|
|
|
+ ref: {halign:'left', fontStyle: 'bold'},
|
|
|
date_order :{halign:'left'},
|
|
|
product_name :{halign:'left' },
|
|
|
qty :{halign:'right' },
|