|
@@ -121,7 +121,7 @@ function widget_sale(widget) {
|
|
|
var journal_ids = _.flatten(_.map(self.AccountJournal, function (item) {
|
|
|
return item.id;
|
|
|
}));
|
|
|
- var date = moment().format('YYYY-01-01 00:00:00');
|
|
|
+ var date = moment().format('YYYY-MM-01 00:00:00');
|
|
|
var fields = ['id', 'name', 'date_order', 'amount_total','sale_journal'];
|
|
|
var domain = [['sale_journal','in',journal_ids],['state', 'not in', ['draft','cancel']],['date_order','>=',date]];
|
|
|
var PosOrder = new model.web.Model('pos.order');
|
|
@@ -141,7 +141,7 @@ function widget_sale(widget) {
|
|
|
var journal_ids = _.flatten(_.map(this.AccountJournal, function (item) {
|
|
|
return item.id;
|
|
|
}));
|
|
|
- var date = moment().format('YYYY-01-01');
|
|
|
+ var date = moment().format('YYYY-MM-01');
|
|
|
var fields = ['id','name','amount_total','date_invoice','currency_id','journal_id'];
|
|
|
var domain = [['state', 'not in', ['draft','cancel']],['type','in',['out_invoice','out_refund']],['journal_id','in',journal_ids],['date_invoice','>=',date]];
|
|
|
var AccountInvoice = new model.web.Model('account.invoice');
|
|
@@ -232,18 +232,18 @@ function widget_sale(widget) {
|
|
|
POS ORDER BY MONTH
|
|
|
======================*/
|
|
|
|
|
|
- getMonthPosOrder:function(mes) {
|
|
|
- var self = this;
|
|
|
- if (mes < 10){
|
|
|
- var fecha = moment().format('YYYY')+'-'+'0'+mes;
|
|
|
- }else{
|
|
|
- var fecha = moment().format('YYYY')+'-'+mes;
|
|
|
- }
|
|
|
- return _.flatten(_.filter(self.PosOrder,function (inv) {
|
|
|
- var utc = moment.utc(inv.date_order,'YYYY-MM-DD h:mm:ss A');
|
|
|
- return moment(utc._d).format('YYYY-MM') === fecha;
|
|
|
- }));
|
|
|
- },
|
|
|
+ // getMonthPosOrder:function(mes) {
|
|
|
+ // var self = this;
|
|
|
+ // if (mes < 10){
|
|
|
+ // var fecha = moment().format('YYYY')+'-'+'0'+mes;
|
|
|
+ // }else{
|
|
|
+ // var fecha = moment().format('YYYY')+'-'+mes;
|
|
|
+ // }
|
|
|
+ // return _.flatten(_.filter(self.PosOrder,function (inv) {
|
|
|
+ // var utc = moment.utc(inv.date_order,'YYYY-MM-DD h:mm:ss A');
|
|
|
+ // return moment(utc._d).format('YYYY-MM') === fecha;
|
|
|
+ // }));
|
|
|
+ // },
|
|
|
|
|
|
/*===================
|
|
|
ACCOUNT INVOICE
|
|
@@ -300,26 +300,26 @@ function widget_sale(widget) {
|
|
|
ACCOUNT INVOICE BY MONTH
|
|
|
============================*/
|
|
|
|
|
|
- getMonthAccountInvoice:function(mes, type) {
|
|
|
- var self = this;
|
|
|
+ // getMonthAccountInvoice:function(mes, type) {
|
|
|
+ // var self = this;
|
|
|
|
|
|
- if (mes < 10){
|
|
|
- var fecha = moment().format('YYYY')+'-'+'0'+mes;
|
|
|
- }else{
|
|
|
- var fecha = moment().format('YYYY')+'-'+mes;
|
|
|
- }
|
|
|
- var journals = _.filter(self.AccountJournal,function (inv) {
|
|
|
- return inv.type == type;
|
|
|
- });
|
|
|
- if(journals.length > 0){
|
|
|
- var journal_ids = _.flatten(_.map(journals, function (item) {
|
|
|
- return item.id;
|
|
|
- }));
|
|
|
- return _.flatten(_.filter(self.AccountInvoice,function (inv) {
|
|
|
- return moment(inv.date_invoice).format('YYYY-MM') === fecha & _.contains(journal_ids, inv.journal_id[0]);
|
|
|
- }));
|
|
|
- }
|
|
|
- },
|
|
|
+ // if (mes < 10){
|
|
|
+ // var fecha = moment().format('YYYY')+'-'+'0'+mes;
|
|
|
+ // }else{
|
|
|
+ // var fecha = moment().format('YYYY')+'-'+mes;
|
|
|
+ // }
|
|
|
+ // var journals = _.filter(self.AccountJournal,function (inv) {
|
|
|
+ // return inv.type == type;
|
|
|
+ // });
|
|
|
+ // if(journals.length > 0){
|
|
|
+ // var journal_ids = _.flatten(_.map(journals, function (item) {
|
|
|
+ // return item.id;
|
|
|
+ // }));
|
|
|
+ // return _.flatten(_.filter(self.AccountInvoice,function (inv) {
|
|
|
+ // return moment(inv.date_invoice).format('YYYY-MM') === fecha & _.contains(journal_ids, inv.journal_id[0]);
|
|
|
+ // }));
|
|
|
+ // }
|
|
|
+ // },
|
|
|
|
|
|
/*
|
|
|
TODAY
|
|
@@ -435,6 +435,7 @@ function widget_sale(widget) {
|
|
|
|
|
|
showThisMonth: function () {
|
|
|
var self = this;
|
|
|
+ // console.log(self);
|
|
|
if(self.DashboardObjetive.length > 0){
|
|
|
self.objective = self.DashboardObjetive.shift().sale_objetive;
|
|
|
}else{
|
|
@@ -510,72 +511,72 @@ function widget_sale(widget) {
|
|
|
self.$el.find('.widget-content').find('a').text(accounting.formatMoney(amount, CurrencyBase.symbol, CurrencyBase.decimal_places, CurrencyBase.thousands_separator, CurrencyBase.decimal_separator))
|
|
|
},
|
|
|
|
|
|
- showMonth: function() {
|
|
|
- var self = this;
|
|
|
- var order;
|
|
|
- var invoice;
|
|
|
- var invoice_refund;
|
|
|
- var title = ['Ene', 'Feb', 'Mar','Abr','May','Jun','Jul','Ago','Sep','Oct','Nov','Dic'];
|
|
|
- var data = [];
|
|
|
- var array = [];
|
|
|
- var CurrencyBase = self.getResCurrency(self.ResCompany[0].currency_id[0]).shift();
|
|
|
- for (var i = 1; i <= 12; i++) {
|
|
|
+ // showMonth: function() {
|
|
|
+ // var self = this;
|
|
|
+ // var order;
|
|
|
+ // var invoice;
|
|
|
+ // var invoice_refund;
|
|
|
+ // var title = ['Ene', 'Feb', 'Mar','Abr','May','Jun','Jul','Ago','Sep','Oct','Nov','Dic'];
|
|
|
+ // var data = [];
|
|
|
+ // var array = [];
|
|
|
+ // var CurrencyBase = self.getResCurrency(self.ResCompany[0].currency_id[0]).shift();
|
|
|
+ // for (var i = 1; i <= 12; i++) {
|
|
|
|
|
|
- order = self.getMonthPosOrder(i);
|
|
|
- invoice = self.getMonthAccountInvoice(i, 'sale');
|
|
|
- invoice_refund = self.getMonthAccountInvoice(i, 'sale_refund');
|
|
|
-
|
|
|
- var order_total = _.reduce(_.map(order,function(item) {
|
|
|
- return item.amount_total;
|
|
|
- }),function(memo, num) {
|
|
|
- return memo + num;
|
|
|
- },0);
|
|
|
+ // order = self.getMonthPosOrder(i);
|
|
|
+ // invoice = self.getMonthAccountInvoice(i, 'sale');
|
|
|
+ // invoice_refund = self.getMonthAccountInvoice(i, 'sale_refund');
|
|
|
+
|
|
|
+ // var order_total = _.reduce(_.map(order,function(item) {
|
|
|
+ // return item.amount_total;
|
|
|
+ // }),function(memo, num) {
|
|
|
+ // return memo + num;
|
|
|
+ // },0);
|
|
|
|
|
|
- /*
|
|
|
- SALE INVOICE
|
|
|
- */
|
|
|
+ // /*
|
|
|
+ // SALE INVOICE
|
|
|
+ // */
|
|
|
|
|
|
- array = [];
|
|
|
- _.each(invoice, function (item) {
|
|
|
- var currency = self.getResCurrency(item.currency_id[0]).shift();
|
|
|
- array.push({
|
|
|
- amount: item.amount_total * (CurrencyBase.rate_silent / currency.rate_silent),
|
|
|
- })
|
|
|
- });
|
|
|
- var invoice_total = 0;
|
|
|
- if(array.length > 0){
|
|
|
- invoice_total = _.reduce(_.map(array, function (map) {
|
|
|
- return map.amount;
|
|
|
- }), function (memo, num) {
|
|
|
- return memo + num;
|
|
|
- });
|
|
|
- }
|
|
|
-
|
|
|
- /*
|
|
|
- SALE REFUND
|
|
|
- */
|
|
|
-
|
|
|
- array = [];
|
|
|
- _.each(invoice_refund, function (item) {
|
|
|
- var currency = self.getResCurrency(item.currency_id[0]).shift();
|
|
|
- array.push({
|
|
|
- amount: item.amount_total * (CurrencyBase.rate_silent / currency.rate_silent),
|
|
|
- })
|
|
|
- });
|
|
|
- var invoice_total_refund = 0;
|
|
|
- if(array.length > 0){
|
|
|
- invoice_total_refund = _.reduce(_.map(array, function (map) {
|
|
|
- return map.amount;
|
|
|
- }), function (memo, num) {
|
|
|
- return memo + num;
|
|
|
- });
|
|
|
- }
|
|
|
-
|
|
|
- var total = order_total + invoice_total - invoice_total_refund;
|
|
|
- data.push(total);
|
|
|
- }
|
|
|
- self.data = data;
|
|
|
- },
|
|
|
+ // array = [];
|
|
|
+ // _.each(invoice, function (item) {
|
|
|
+ // var currency = self.getResCurrency(item.currency_id[0]).shift();
|
|
|
+ // array.push({
|
|
|
+ // amount: item.amount_total * (CurrencyBase.rate_silent / currency.rate_silent),
|
|
|
+ // })
|
|
|
+ // });
|
|
|
+ // var invoice_total = 0;
|
|
|
+ // if(array.length > 0){
|
|
|
+ // invoice_total = _.reduce(_.map(array, function (map) {
|
|
|
+ // return map.amount;
|
|
|
+ // }), function (memo, num) {
|
|
|
+ // return memo + num;
|
|
|
+ // });
|
|
|
+ // }
|
|
|
+
|
|
|
+ // /*
|
|
|
+ // SALE REFUND
|
|
|
+ // */
|
|
|
+
|
|
|
+ // array = [];
|
|
|
+ // _.each(invoice_refund, function (item) {
|
|
|
+ // var currency = self.getResCurrency(item.currency_id[0]).shift();
|
|
|
+ // array.push({
|
|
|
+ // amount: item.amount_total * (CurrencyBase.rate_silent / currency.rate_silent),
|
|
|
+ // })
|
|
|
+ // });
|
|
|
+ // var invoice_total_refund = 0;
|
|
|
+ // if(array.length > 0){
|
|
|
+ // invoice_total_refund = _.reduce(_.map(array, function (map) {
|
|
|
+ // return map.amount;
|
|
|
+ // }), function (memo, num) {
|
|
|
+ // return memo + num;
|
|
|
+ // });
|
|
|
+ // }
|
|
|
+
|
|
|
+ // var total = order_total + invoice_total - invoice_total_refund;
|
|
|
+ // data.push(total);
|
|
|
+ // }
|
|
|
+ // self.data = data;
|
|
|
+ // },
|
|
|
|
|
|
/*=========
|
|
|
MODAL
|
|
@@ -585,7 +586,7 @@ function widget_sale(widget) {
|
|
|
var self = this;
|
|
|
self.showThisWeek();
|
|
|
self.showToday();
|
|
|
- self.showMonth();
|
|
|
+ // self.showMonth();
|
|
|
var titleData = [
|
|
|
{
|
|
|
title: "Ventas"
|
|
@@ -616,7 +617,7 @@ function widget_sale(widget) {
|
|
|
percentageTextSize: 35,
|
|
|
});
|
|
|
|
|
|
- self.fetchChart(self.data);
|
|
|
+ // self.fetchChart(self.data);
|
|
|
},
|
|
|
|
|
|
removeModal: function (e) {
|
|
@@ -628,67 +629,67 @@ function widget_sale(widget) {
|
|
|
BUILD A CHART
|
|
|
*/
|
|
|
|
|
|
- fetchChart: function (data) {
|
|
|
- var self = this;
|
|
|
- var label = ['Ene', 'Feb', 'Mar','Abr','May','Jun','Jul','Ago','Sep','Oct','Nov','Dic'];
|
|
|
- var body = data;
|
|
|
-
|
|
|
- Chart.scaleService.updateScaleDefaults('linear', {
|
|
|
- ticks: {
|
|
|
- callback: function(tick) {
|
|
|
- return tick.toLocaleString('de-DE');
|
|
|
- }
|
|
|
- }
|
|
|
- });
|
|
|
- Chart.defaults.global.tooltips.callbacks.label = function(tooltipItem, data) {
|
|
|
- var dataset = data.datasets[tooltipItem.datasetIndex];
|
|
|
- var datasetLabel = dataset.label || '';
|
|
|
- return datasetLabel + dataset.data[tooltipItem.index].toLocaleString('de-DE');
|
|
|
- };
|
|
|
-
|
|
|
- var chart = new Chart($("#prueba"), {
|
|
|
- type: 'line',
|
|
|
- data: {
|
|
|
- labels: label,
|
|
|
- datasets: [
|
|
|
- {
|
|
|
- label: false,
|
|
|
- data: body,
|
|
|
- backgroundColor: '#e3f2fd',
|
|
|
- borderColor: '#43a047',
|
|
|
- borderWidth: 2,
|
|
|
- fill: false,
|
|
|
- }
|
|
|
- ]
|
|
|
- },
|
|
|
- options: {
|
|
|
- responsive: true,
|
|
|
- title: {
|
|
|
- display: false,
|
|
|
- },
|
|
|
- hover: {
|
|
|
- mode: 'nearest',
|
|
|
- intersect: true
|
|
|
- },
|
|
|
- legend: {
|
|
|
- display: false,
|
|
|
- },
|
|
|
- layout: {
|
|
|
- padding: {
|
|
|
- top: 45,
|
|
|
- bottom: 40,
|
|
|
- left : 10,
|
|
|
- rigth: 10,
|
|
|
- }
|
|
|
- },
|
|
|
- elements: {
|
|
|
- line: {
|
|
|
- tension: 0.000001
|
|
|
- }
|
|
|
- },
|
|
|
- }
|
|
|
- });
|
|
|
- },
|
|
|
+ // fetchChart: function (data) {
|
|
|
+ // var self = this;
|
|
|
+ // var label = ['Ene', 'Feb', 'Mar','Abr','May','Jun','Jul','Ago','Sep','Oct','Nov','Dic'];
|
|
|
+ // var body = data;
|
|
|
+
|
|
|
+ // Chart.scaleService.updateScaleDefaults('linear', {
|
|
|
+ // ticks: {
|
|
|
+ // callback: function(tick) {
|
|
|
+ // return tick.toLocaleString('de-DE');
|
|
|
+ // }
|
|
|
+ // }
|
|
|
+ // });
|
|
|
+ // Chart.defaults.global.tooltips.callbacks.label = function(tooltipItem, data) {
|
|
|
+ // var dataset = data.datasets[tooltipItem.datasetIndex];
|
|
|
+ // var datasetLabel = dataset.label || '';
|
|
|
+ // return datasetLabel + dataset.data[tooltipItem.index].toLocaleString('de-DE');
|
|
|
+ // };
|
|
|
+
|
|
|
+ // var chart = new Chart($("#prueba"), {
|
|
|
+ // type: 'line',
|
|
|
+ // data: {
|
|
|
+ // labels: label,
|
|
|
+ // datasets: [
|
|
|
+ // {
|
|
|
+ // label: false,
|
|
|
+ // data: body,
|
|
|
+ // backgroundColor: '#e3f2fd',
|
|
|
+ // borderColor: '#43a047',
|
|
|
+ // borderWidth: 2,
|
|
|
+ // fill: false,
|
|
|
+ // }
|
|
|
+ // ]
|
|
|
+ // },
|
|
|
+ // options: {
|
|
|
+ // responsive: true,
|
|
|
+ // title: {
|
|
|
+ // display: false,
|
|
|
+ // },
|
|
|
+ // hover: {
|
|
|
+ // mode: 'nearest',
|
|
|
+ // intersect: true
|
|
|
+ // },
|
|
|
+ // legend: {
|
|
|
+ // display: false,
|
|
|
+ // },
|
|
|
+ // layout: {
|
|
|
+ // padding: {
|
|
|
+ // top: 45,
|
|
|
+ // bottom: 40,
|
|
|
+ // left : 10,
|
|
|
+ // rigth: 10,
|
|
|
+ // }
|
|
|
+ // },
|
|
|
+ // elements: {
|
|
|
+ // line: {
|
|
|
+ // tension: 0.000001
|
|
|
+ // }
|
|
|
+ // },
|
|
|
+ // }
|
|
|
+ // });
|
|
|
+ // },
|
|
|
|
|
|
});
|
|
|
}
|