فهرست منبع

[FIX] correccion de codigo, agregado ventas normales junto con las ventas del pos en le widget

Rodney Elpidio Enciso Arias 7 سال پیش
والد
کامیت
fb6fe66d95

+ 6 - 6
static/src/css/dashboard.css

@@ -19,14 +19,14 @@
 }
 
 
-/*Compras*/
+/*Dark Orange*/
 
-.grid-stack-item-content.reporting-dashboard.purchase {
-    color: #4caf50;
-    border-bottom: 3px solid #4caf50;
+.grid-stack-item-content.reporting-dashboard.darkorange {
+    color: #e65100;
+    border-bottom: 3px solid #e65100;
 }
-.grid-stack-item-content.reporting-dashboard.purchase > .widget-content > a {
-    color: #4caf50;
+.grid-stack-item-content.reporting-dashboard.darkorange > .widget-content > a {
+    color: #e65100;
 }
 
 /*Orange*/

+ 7 - 30
static/src/js/widgets/chart_ingreso_egreso.js

@@ -45,8 +45,7 @@ function chart_ingreso_egreso (widget) {
         fecthAccountBankStatementLine: function() {
             var self = this;
             var defer = $.Deferred();
-            var fields = ['id','date','partner_id','amount'];
-            // var domain = [['state','in',['paid','open']]];
+            var fields = ['id','date','amount'];
             var AccountBankStatementLine = new model.web.Model('account.bank.statement.line');
             AccountBankStatementLine.query(fields).filter().all().then(function (results) {
                 defer.resolve(results);
@@ -157,7 +156,7 @@ function chart_ingreso_egreso (widget) {
             var mes = 0;
             var dataIn = [];
             var dataOut = [];
-            for (var i = 1; i <= 12; i++) {
+            for (var i = 1; i <= 7; i++) {
                 inStatement = self.getInWeekAccountBankStatementLine(i);
                 var total = _.reduce(_.map(inStatement,function(item) {
                     return item.amount;
@@ -166,7 +165,7 @@ function chart_ingreso_egreso (widget) {
                 },0);
                 dataIn.push(total);
             }
-            for (var i = 1; i <= 12; i++) {
+            for (var i = 1; i <= 7; i++) {
                 OutStatement = self.getOutWeekAccountBankStatementLine(i);
                 var total = _.reduce(_.map(OutStatement,function(item) {
                     return item.amount;
@@ -248,43 +247,21 @@ function chart_ingreso_egreso (widget) {
                             fill: false,
                         },
                         {
-                            label: 'Egreso  ',  
-                            borderDash: [5, 5],                          
+                            label: 'Egreso  ',                       
                             data: bodyOut,
-                            backgroundColor: '#c8e6c9',
-                            borderColor: '#66bb6a',
+                            backgroundColor: '#ef6c00',
+                            borderColor: '#ef6c00',
                             borderWidth: 2,
                             fill: false,
                         }
                     ]
                 },
                 options: {
-                    responsive: true,
+                    // responsive: true,
                     title: {
                         display: true,
                     },
-                    tooltips: {
-                        mode: 'index',
-                        callbacks: {
-                            // Use the footer callback to display the sum of the items showing in the tooltip
-                            footer: function(tooltipItems, data) {
-                                var sum = 0;
-                                tooltipItems.forEach(function(tooltipItem) {
-                                    if(sum == 0){
-                                        sum = data.datasets[tooltipItem.datasetIndex].data[tooltipItem.index];    
-                                    }else{
-                                        sum = sum - data.datasets[tooltipItem.datasetIndex].data[tooltipItem.index];
-                                    }
-                                    
-                                });
-                                return 'Balance  ' + accounting.formatNumber(sum,0,".",",");
-                            },
-                        },
-                        intersect: false,
-                        footerFontStyle: 'normal'
-                    },
                     hover: {
-                        // mode: 'nearest',
                         mode: 'nearest',
                         intersect: true
                     },

+ 1 - 0
static/src/js/widgets/chart_pos_order_customer.js

@@ -159,6 +159,7 @@ function chart_pos_order_customer (widget) {
                             borderColor: '#64b5f6',
                             borderWidth: 2,
                             data: body,
+                            fill: false,
                         }
                     ]
                 },

+ 73 - 23
static/src/js/widgets/widget_balance.js

@@ -54,8 +54,8 @@ function widget_balance(widget) {
         fetchAccountInvoice: function() {
             var self = this;
             var defer = $.Deferred();
-            var fields = ['id', 'name', 'date_invoice', 'amount_total'];
-            var domain = [['state', 'not in', ['draft','cancel']],['type','=','in_invoice']];
+            var fields = ['id','type','date_invoice','amount_total'];
+            var domain = [['state', 'not in', ['draft','cancel']],['type','in',['in_invoice','out_invoice']]];
             var AccountInvoice = new model.web.Model('account.invoice');
             AccountInvoice.query(fields).filter(domain).all().then(function(results) {
                 defer.resolve(results);
@@ -109,26 +109,49 @@ function widget_balance(widget) {
             })
         },
 
-        getTodayAccountInvoice:function() {
+        getTodayInAccountInvoice:function() {
             var self = this;
             var date = moment().format('YYYY-MM-DD');
             return _.flatten(_.filter(self.AccountInvoice,function (inv) {
-                return moment(inv.date_invoice).format('YYYY-MM-DD') === date;
+                return moment(inv.date_invoice).format('YYYY-MM-DD') === date & inv.type == 'in_invoice';
             }));
         },
 
-        getThisWeekAccountInvoice:function() {
+        getTodayOutAccountInvoice:function() {
+            var self = this;
+            var date = moment().format('YYYY-MM-DD');
+            return _.flatten(_.filter(self.AccountInvoice,function (inv) {
+                return moment(inv.date_invoice).format('YYYY-MM-DD') === date & inv.type == 'out_invoice';
+            }));
+        },
+
+        getThisWeekInAccountInvoice:function() {
+            var self = this;
+            var week = moment().week();
+            return _.flatten(_.filter(self.AccountInvoice,function (inv) {
+                return moment(inv.date_invoice).week() === week & moment(inv.date_invoice).format('YYYY')=== moment().format('YYYY') & inv.type == 'in_invoice';
+            }));
+        },
+
+        getThisWeekOutAccountInvoice:function() {
             var self = this;
             var week = moment().week();
             return _.flatten(_.filter(self.AccountInvoice,function (inv) {
-                return moment(inv.date_invoice).week() === week & moment(inv.date_invoice).format('YYYY')=== moment().format('YYYY');
+                return moment(inv.date_invoice).week() === week & moment(inv.date_invoice).format('YYYY')=== moment().format('YYYY') & inv.type == 'out_invoice';
+            }));
+        },
+
+        getThisMonthInAccountInvoice:function() {
+            var self = this;
+            return _.flatten(_.filter(self.AccountInvoice,function (inv) {
+                return moment(inv.date_invoice).format('YYYY-MM')=== moment().format('YYYY-MM') & inv.type == 'in_invoice';
             }));
         },
 
-        getThisMonthAccountInvoice:function() {
+        getThisMonthOutAccountInvoice:function() {
             var self = this;
             return _.flatten(_.filter(self.AccountInvoice,function (inv) {
-                return moment(inv.date_invoice).format('YYYY-MM')=== moment().format('YYYY-MM');
+                return moment(inv.date_invoice).format('YYYY-MM')=== moment().format('YYYY-MM') & inv.type == 'out_invoice';
             }));
         },
         
@@ -158,11 +181,13 @@ function widget_balance(widget) {
         showToday: function () {
             var self = this;
             var amount_order = 0;
-            var amount_invoice = 0;
+            var invoice_in_amount = 0;
+            var invoice_out_amount = 0;
             var balance = 0;
             var data = [];
             var order = self.getTodayPosOrder();
-            var invoice = self.getTodayAccountInvoice();
+            var in_invoice = self.getTodayInAccountInvoice();
+            var out_invoice = self.getTodayOutAccountInvoice();
             var CurrencyBase = self.getResCurrency(self.ResCompany[0].currency_id[0]).shift();
             if(order.length > 0){
                 amount_order = _.reduce(_.map(order, function (map) {
@@ -171,14 +196,21 @@ function widget_balance(widget) {
                     return memo + num;
                 });
             }
-            if(invoice.length > 0){
-                amount_invoice = _.reduce(_.map(invoice, function (map) {
+            if(in_invoice.length > 0){
+                invoice_in_amount = _.reduce(_.map(in_invoice, function (map) {
+                    return map.amount_total;
+                }), function (memo, num) {
+                    return memo + num;
+                });
+            }
+            if(out_invoice.length > 0){
+                invoice_out_amount = _.reduce(_.map(out_invoice, function (map) {
                     return map.amount_total;
                 }), function (memo, num) {
                     return memo + num;
                 });
             }
-            balance = amount_order - amount_invoice;
+            balance = (invoice_out_amount + amount_order) - invoice_in_amount;
             self.$el.find('.widget-content.widget-loading').css('display','none');
             self.$el.find('.widget-content').find('a').text(accounting.formatMoney(balance, CurrencyBase.symbol, CurrencyBase.decimal_places, CurrencyBase.thousands_separator, CurrencyBase.decimal_separator))
         },
@@ -186,11 +218,13 @@ function widget_balance(widget) {
         showThisWeek: function () {
             var self = this;
             var amount_order = 0;
-            var amount_invoice = 0;
+            var invoice_in_amount = 0;
+            var invoice_out_amount = 0;
             var balance = 0;
             var data = [];
             var order = self.getThisWeekPosOrder();
-            var invoice = self.getThisWeekAccountInvoice();
+            var in_invoice = self.getThisWeekInAccountInvoice();
+            var out_invoice = self.getThisWeekOutAccountInvoice();
             var CurrencyBase = self.getResCurrency(self.ResCompany[0].currency_id[0]).shift();
             if(order.length > 0){
                 amount_order = _.reduce(_.map(order, function (map) {
@@ -199,14 +233,21 @@ function widget_balance(widget) {
                     return memo + num;
                 });
             }
-            if(invoice.length > 0){
-                amount_invoice = _.reduce(_.map(invoice, function (map) {
+            if(in_invoice.length > 0){
+                invoice_in_amount = _.reduce(_.map(in_invoice, function (map) {
+                    return map.amount_total;
+                }), function (memo, num) {
+                    return memo + num;
+                });
+            }
+            if(out_invoice.length > 0){
+                invoice_out_amount = _.reduce(_.map(out_invoice, function (map) {
                     return map.amount_total;
                 }), function (memo, num) {
                     return memo + num;
                 });
             }
-            balance = amount_order - amount_invoice;
+            balance = (invoice_out_amount + amount_order) - invoice_in_amount;
             self.$el.find('.widget-content.widget-loading').css('display','none');
             self.$el.find('.widget-content').find('a').text(accounting.formatMoney(balance, CurrencyBase.symbol, CurrencyBase.decimal_places, CurrencyBase.thousands_separator, CurrencyBase.decimal_separator))
         },
@@ -214,11 +255,13 @@ function widget_balance(widget) {
         showThisMonth: function () {
             var self = this;
             var amount_order = 0;
-            var amount_invoice = 0;
+            var invoice_in_amount = 0;
+            var invoice_out_amount = 0;
             var balance = 0;
             var data = [];
             var order = self.getThisMonthPosOrder();
-            var invoice = self.getThisMonthAccountInvoice();
+            var in_invoice = self.getThisMonthInAccountInvoice();
+            var out_invoice = self.getThisMonthOutAccountInvoice();
             var CurrencyBase = self.getResCurrency(self.ResCompany[0].currency_id[0]).shift();
             if(order.length > 0){
                 amount_order = _.reduce(_.map(order, function (map) {
@@ -227,14 +270,21 @@ function widget_balance(widget) {
                     return memo + num;
                 });
             }
-            if(invoice.length > 0){
-                amount_invoice = _.reduce(_.map(invoice, function (map) {
+            if(in_invoice.length > 0){
+                invoice_in_amount = _.reduce(_.map(in_invoice, function (map) {
+                    return map.amount_total;
+                }), function (memo, num) {
+                    return memo + num;
+                });
+            }
+            if(out_invoice.length > 0){
+                invoice_out_amount = _.reduce(_.map(out_invoice, function (map) {
                     return map.amount_total;
                 }), function (memo, num) {
                     return memo + num;
                 });
             }
-            balance = amount_order - amount_invoice;
+            balance = (invoice_out_amount + amount_order) - invoice_in_amount;
             self.$el.find('.widget-content.widget-loading').css('display','none');
             self.$el.find('.widget-content').find('a').text(accounting.formatMoney(balance, CurrencyBase.symbol, CurrencyBase.decimal_places, CurrencyBase.thousands_separator, CurrencyBase.decimal_separator))
         },

+ 77 - 4
static/src/js/widgets/widget_pos_order.js

@@ -38,7 +38,10 @@ function widget_pos_order(widget) {
                 return PosOrder;
             }).then(function (PosOrder) {
                 self.PosOrder = PosOrder;
-                return self.fetchResCompany();
+                return self.fetchAccountInvoice();
+            }).then(function(AccountInvoice) {
+                self.AccountInvoice = AccountInvoice;
+            return self.fetchResCompany();
             }).then(function(ResCompany) {
                 self.ResCompany = ResCompany;
                 return self.fetchResCurrecy();
@@ -61,6 +64,20 @@ function widget_pos_order(widget) {
             return defer;
         },
 
+        fetchAccountInvoice: function() {
+            var self = this;
+            var defer = $.Deferred();
+            var month = moment().format('YYYY-MM');
+            var fields = ['id','name','amount_total','date_invoice'];
+            var domain = [['state', 'not in', ['draft','cancel']],['type','=','out_invoice']];
+            var AccountInvoice = new model.web.Model('account.invoice');
+            AccountInvoice.query(fields).filter(domain).all().then(function(results) {
+                defer.resolve(results);
+            });
+
+            return defer;
+        },
+
         fetchResCompany: function() {
             var self = this;
             var defer = $.Deferred();
@@ -101,6 +118,14 @@ function widget_pos_order(widget) {
             }));
         },
 
+        getTodayAccountInvoice:function() {
+            var self = this;
+            var date = moment().format('YYYY-MM-DD');
+            return _.flatten(_.filter(self.AccountInvoice,function (inv) {
+                return moment(inv.date_invoice).format('YYYY-MM-DD') === date;
+            }));
+        },
+
         getThisWeekPosOrder:function() {
             var self = this;
             var week = moment().week();
@@ -109,6 +134,14 @@ function widget_pos_order(widget) {
             }));
         },
 
+        getThisWeekAccountInvoice:function() {
+            var self = this;
+            var week = moment().week();
+            return _.flatten(_.filter(self.AccountInvoice,function (inv) {
+                return moment(inv.date_invoice).week() === week & moment(inv.date_invoice).format('YYYY')=== moment().format('YYYY');
+            }));
+        },
+
         getThisMonthPosOrder:function() {
             var self = this;
             return _.flatten(_.filter(self.PosOrder,function (inv) {
@@ -116,19 +149,37 @@ function widget_pos_order(widget) {
             }));
         },
 
+        getThisMonthAccountInvoice:function() {
+            var self = this;
+            return _.flatten(_.filter(self.AccountInvoice,function (inv) {
+                return moment(inv.date_invoice).format('YYYY-MM')=== moment().format('YYYY-MM');
+            }));
+        },
+
         showToday: function () {
             var self = this;
             var amount = 0;
+            var pos_amount = 0;
+            var invoice_amount = 0;
             var data = [];
             var pos_order = self.getTodayPosOrder();
+            var account_invoice = self.getTodayAccountInvoice();
             var CurrencyBase = self.getResCurrency(self.ResCompany[0].currency_id[0]).shift();
             if(pos_order.length > 0){
-                amount = _.reduce(_.map(pos_order, function (map) {
+                pos_amount = _.reduce(_.map(pos_order, function (map) {
                     return map.amount_total;
                 }), function (memo, num) {
                     return memo + num;
                 });
             }
+            if(account_invoice.length > 0){
+                invoice_amount = _.reduce(_.map(account_invoice, function (map) {
+                    return map.amount_total;
+                }), function (memo, num) {
+                    return memo + num;
+                });
+            }
+            amount = pos_amount + invoice_amount;
             self.$el.find('.widget-content.widget-loading').css('display','none');
             self.$el.find('.widget-content').find('a').text(accounting.formatMoney(amount, CurrencyBase.symbol, CurrencyBase.decimal_places, CurrencyBase.thousands_separator, CurrencyBase.decimal_separator))
         },
@@ -136,33 +187,55 @@ function widget_pos_order(widget) {
         showThisWeek: function () {
             var self = this;
             var amount = 0;
+            var pos_amount = 0;
+            var invoice_amount = 0;
             var data = [];
             var pos_order = self.getThisWeekPosOrder();
+            var account_invoice = self.getThisWeekAccountInvoice();
             var CurrencyBase = self.getResCurrency(self.ResCompany[0].currency_id[0]).shift();
             if(pos_order.length > 0){
-                amount = _.reduce(_.map(pos_order, function (map) {
+                pos_amount = _.reduce(_.map(pos_order, function (map) {
+                    return map.amount_total;
+                }), function (memo, num) {
+                    return memo + num;
+                });
+            }
+            if(account_invoice.length > 0){
+                invoice_amount = _.reduce(_.map(account_invoice, function (map) {
                     return map.amount_total;
                 }), function (memo, num) {
                     return memo + num;
                 });
             }
+            amount = pos_amount + invoice_amount;
             self.$el.find('.widget-content.widget-loading').css('display','none');
             self.$el.find('.widget-content').find('a').text(accounting.formatMoney(amount, CurrencyBase.symbol, CurrencyBase.decimal_places, CurrencyBase.thousands_separator, CurrencyBase.decimal_separator))
         },
 
         showThisMonth: function () {
             var self = this;
+            var pos_amount = 0;
+            var invoice_amount = 0;
             var amount = 0;
             var data = [];
             var pos_order = self.getThisMonthPosOrder();
+            var account_invoice = self.getThisMonthAccountInvoice();
             var CurrencyBase = self.getResCurrency(self.ResCompany[0].currency_id[0]).shift();
             if(pos_order.length > 0){
-                amount = _.reduce(_.map(pos_order, function (map) {
+                pos_amount = _.reduce(_.map(pos_order, function (map) {
+                    return map.amount_total;
+                }), function (memo, num) {
+                    return memo + num;
+                });
+            }
+            if(account_invoice.length > 0){
+                invoice_amount = _.reduce(_.map(account_invoice, function (map) {
                     return map.amount_total;
                 }), function (memo, num) {
                     return memo + num;
                 });
             }
+            amount = pos_amount + invoice_amount;
             self.$el.find('.widget-content.widget-loading').css('display','none');
             self.$el.find('.widget-content').find('a').text(accounting.formatMoney(amount, CurrencyBase.symbol, CurrencyBase.decimal_places, CurrencyBase.thousands_separator, CurrencyBase.decimal_separator))
         },

+ 1 - 1
static/src/xml/widgets/widget_expense.xml

@@ -2,7 +2,7 @@
 <template xml:space="preserve">
     <t t-name="WidgetExpense">
         <div>
-            <div class="grid-stack-item-content reporting-dashboard orange">
+            <div class="grid-stack-item-content reporting-dashboard darkorange">
                 <h2 class="widget-title">
                     <div class="row">
                         <div class="col-xs-6">

+ 1 - 1
static/src/xml/widgets/widget_purchase.xml

@@ -2,7 +2,7 @@
 <template xml:space="preserve">
     <t t-name="WidgetPurchase">
         <div>
-            <div class="grid-stack-item-content reporting-dashboard purchase">
+            <div class="grid-stack-item-content reporting-dashboard orange">
                 <h2 class="widget-title">
                     <div class="row">
                         <div class="col-xs-6">