|
@@ -12,7 +12,7 @@ function widget_balance(widget) {
|
|
today: 0,
|
|
today: 0,
|
|
data: 0,
|
|
data: 0,
|
|
objective: 0,
|
|
objective: 0,
|
|
- percentage: 0,
|
|
|
|
|
|
+ percentage: 0,
|
|
|
|
|
|
events: {
|
|
events: {
|
|
'click .number': 'showModal',
|
|
'click .number': 'showModal',
|
|
@@ -68,10 +68,10 @@ function widget_balance(widget) {
|
|
});
|
|
});
|
|
},
|
|
},
|
|
|
|
|
|
- /*
|
|
|
|
|
|
+ /*
|
|
IR MODULES
|
|
IR MODULES
|
|
*/
|
|
*/
|
|
-
|
|
|
|
|
|
+
|
|
fecthIrModuleModule: function(){
|
|
fecthIrModuleModule: function(){
|
|
var self = this;
|
|
var self = this;
|
|
var defer = $.Deferred();
|
|
var defer = $.Deferred();
|
|
@@ -80,11 +80,11 @@ function widget_balance(widget) {
|
|
var IrModuleModule = new model.web.Model('ir.module.module');
|
|
var IrModuleModule = new model.web.Model('ir.module.module');
|
|
IrModuleModule.query(fields).filter(domain).all().then(function(results){
|
|
IrModuleModule.query(fields).filter(domain).all().then(function(results){
|
|
defer.resolve(results);
|
|
defer.resolve(results);
|
|
- })
|
|
|
|
|
|
+ })
|
|
return defer;
|
|
return defer;
|
|
},
|
|
},
|
|
|
|
|
|
- /*
|
|
|
|
|
|
+ /*
|
|
USER
|
|
USER
|
|
*/
|
|
*/
|
|
|
|
|
|
@@ -120,9 +120,9 @@ function widget_balance(widget) {
|
|
var journal_ids = _.flatten(_.map(this.AccountJournal, function (item) {
|
|
var journal_ids = _.flatten(_.map(this.AccountJournal, function (item) {
|
|
return item.id;
|
|
return item.id;
|
|
}));
|
|
}));
|
|
- var date = moment().format('YYYY-MM-01');
|
|
|
|
|
|
+ var date = moment().format('YYYY-MM');
|
|
var fields = ['id','type','date_invoice','amount_total','currency_id','journal_id'];
|
|
var fields = ['id','type','date_invoice','amount_total','currency_id','journal_id'];
|
|
- var domain = [['state', 'not in', ['draft','cancel']],['journal_id','in',journal_ids],['date_invoice','>',date]];
|
|
|
|
|
|
+ var domain = [['state', 'not in', ['draft','cancel']],['journal_id','in',journal_ids],['date_invoice','like',date]];
|
|
var AccountInvoice = new model.web.Model('account.invoice');
|
|
var AccountInvoice = new model.web.Model('account.invoice');
|
|
AccountInvoice.query(fields).filter(domain).all().then(function(results) {
|
|
AccountInvoice.query(fields).filter(domain).all().then(function(results) {
|
|
defer.resolve(results);
|
|
defer.resolve(results);
|
|
@@ -198,7 +198,7 @@ function widget_balance(widget) {
|
|
})
|
|
})
|
|
},
|
|
},
|
|
|
|
|
|
- /*===================
|
|
|
|
|
|
+ /*===================
|
|
ACCOUNT INVOICE
|
|
ACCOUNT INVOICE
|
|
===================*/
|
|
===================*/
|
|
|
|
|
|
@@ -249,10 +249,10 @@ function widget_balance(widget) {
|
|
}
|
|
}
|
|
},
|
|
},
|
|
|
|
|
|
- /*=============
|
|
|
|
|
|
+ /*=============
|
|
POS ORDER
|
|
POS ORDER
|
|
=============*/
|
|
=============*/
|
|
-
|
|
|
|
|
|
+
|
|
getTodayPosOrder:function() {
|
|
getTodayPosOrder:function() {
|
|
var self = this;
|
|
var self = this;
|
|
var date = moment().format('YYYY-MM-DD');
|
|
var date = moment().format('YYYY-MM-DD');
|
|
@@ -278,9 +278,9 @@ function widget_balance(widget) {
|
|
var utc = moment.utc(inv.date_order,'YYYY-MM-DD h:mm:ss A');
|
|
var utc = moment.utc(inv.date_order,'YYYY-MM-DD h:mm:ss A');
|
|
return moment(utc._d).format('YYYY-MM') === moment().format('YYYY-MM');
|
|
return moment(utc._d).format('YYYY-MM') === moment().format('YYYY-MM');
|
|
}));
|
|
}));
|
|
- },
|
|
|
|
|
|
+ },
|
|
|
|
|
|
- /*
|
|
|
|
|
|
+ /*
|
|
TODAY
|
|
TODAY
|
|
*/
|
|
*/
|
|
|
|
|
|
@@ -297,11 +297,11 @@ function widget_balance(widget) {
|
|
var sale_invoice_refund = self.getTodayAccountInvoice('sale_refund');
|
|
var sale_invoice_refund = self.getTodayAccountInvoice('sale_refund');
|
|
var purchase_invoice = self.getTodayAccountInvoice('purchase');
|
|
var purchase_invoice = self.getTodayAccountInvoice('purchase');
|
|
var CurrencyBase = self.getResCurrency(self.ResCompany[0].currency_id[0]).shift();
|
|
var CurrencyBase = self.getResCurrency(self.ResCompany[0].currency_id[0]).shift();
|
|
-
|
|
|
|
- /*
|
|
|
|
|
|
+
|
|
|
|
+ /*
|
|
SALE INVOICE
|
|
SALE INVOICE
|
|
*/
|
|
*/
|
|
-
|
|
|
|
|
|
+
|
|
if(order.length > 0){
|
|
if(order.length > 0){
|
|
amount_order = _.reduce(_.map(order, function (map) {
|
|
amount_order = _.reduce(_.map(order, function (map) {
|
|
return map.amount_total;
|
|
return map.amount_total;
|
|
@@ -309,11 +309,11 @@ function widget_balance(widget) {
|
|
return memo + num;
|
|
return memo + num;
|
|
});
|
|
});
|
|
}
|
|
}
|
|
-
|
|
|
|
- /*
|
|
|
|
|
|
+
|
|
|
|
+ /*
|
|
SALE INVOICE
|
|
SALE INVOICE
|
|
*/
|
|
*/
|
|
-
|
|
|
|
|
|
+
|
|
if(sale_invoice.length > 0){
|
|
if(sale_invoice.length > 0){
|
|
array = [];
|
|
array = [];
|
|
_.each(sale_invoice, function (item) {
|
|
_.each(sale_invoice, function (item) {
|
|
@@ -329,7 +329,7 @@ function widget_balance(widget) {
|
|
});
|
|
});
|
|
}
|
|
}
|
|
|
|
|
|
- /*
|
|
|
|
|
|
+ /*
|
|
SALE INVOICE REFUND
|
|
SALE INVOICE REFUND
|
|
*/
|
|
*/
|
|
|
|
|
|
@@ -348,10 +348,10 @@ function widget_balance(widget) {
|
|
});
|
|
});
|
|
}
|
|
}
|
|
|
|
|
|
- /*
|
|
|
|
|
|
+ /*
|
|
PURCHASE INVOICE
|
|
PURCHASE INVOICE
|
|
*/
|
|
*/
|
|
-
|
|
|
|
|
|
+
|
|
if(purchase_invoice.length > 0){
|
|
if(purchase_invoice.length > 0){
|
|
array = [];
|
|
array = [];
|
|
_.each(purchase_invoice, function (item) {
|
|
_.each(purchase_invoice, function (item) {
|
|
@@ -367,12 +367,12 @@ function widget_balance(widget) {
|
|
});
|
|
});
|
|
}
|
|
}
|
|
|
|
|
|
- balance = (sale_invoice_amount + amount_order) - (sale_invoice_refund_amount + purchase_invoice_amount);
|
|
|
|
-
|
|
|
|
|
|
+ balance = (sale_invoice_amount + amount_order) - (sale_invoice_refund_amount + purchase_invoice_amount);
|
|
|
|
+
|
|
self.today = balance;
|
|
self.today = balance;
|
|
},
|
|
},
|
|
|
|
|
|
- /*
|
|
|
|
|
|
+ /*
|
|
WEEK
|
|
WEEK
|
|
*/
|
|
*/
|
|
|
|
|
|
@@ -385,11 +385,11 @@ function widget_balance(widget) {
|
|
var balance = 0;
|
|
var balance = 0;
|
|
var array = [];
|
|
var array = [];
|
|
var order = self.getThisWeekPosOrder();
|
|
var order = self.getThisWeekPosOrder();
|
|
-
|
|
|
|
|
|
+
|
|
var sale_invoice = self.getThisWeekAccountInvoice('sale');
|
|
var sale_invoice = self.getThisWeekAccountInvoice('sale');
|
|
var sale_invoice_refund = self.getThisWeekAccountInvoice('sale_refund');
|
|
var sale_invoice_refund = self.getThisWeekAccountInvoice('sale_refund');
|
|
var purchase_invoice = self.getThisWeekAccountInvoice('purchase');
|
|
var purchase_invoice = self.getThisWeekAccountInvoice('purchase');
|
|
-
|
|
|
|
|
|
+
|
|
var CurrencyBase = self.getResCurrency(self.ResCompany[0].currency_id[0]).shift();
|
|
var CurrencyBase = self.getResCurrency(self.ResCompany[0].currency_id[0]).shift();
|
|
if(order.length > 0){
|
|
if(order.length > 0){
|
|
amount_order = _.reduce(_.map(order, function (map) {
|
|
amount_order = _.reduce(_.map(order, function (map) {
|
|
@@ -399,10 +399,10 @@ function widget_balance(widget) {
|
|
});
|
|
});
|
|
}
|
|
}
|
|
|
|
|
|
- /*
|
|
|
|
|
|
+ /*
|
|
SALE INVOICE
|
|
SALE INVOICE
|
|
*/
|
|
*/
|
|
-
|
|
|
|
|
|
+
|
|
if(sale_invoice.length > 0){
|
|
if(sale_invoice.length > 0){
|
|
array = [];
|
|
array = [];
|
|
_.each(sale_invoice, function (item) {
|
|
_.each(sale_invoice, function (item) {
|
|
@@ -418,10 +418,10 @@ function widget_balance(widget) {
|
|
});
|
|
});
|
|
}
|
|
}
|
|
|
|
|
|
- /*
|
|
|
|
|
|
+ /*
|
|
SALE INVOICE REFUND
|
|
SALE INVOICE REFUND
|
|
*/
|
|
*/
|
|
-
|
|
|
|
|
|
+
|
|
if(sale_invoice_refund.length > 0){
|
|
if(sale_invoice_refund.length > 0){
|
|
array = [];
|
|
array = [];
|
|
_.each(sale_invoice_refund, function (item) {
|
|
_.each(sale_invoice_refund, function (item) {
|
|
@@ -437,10 +437,10 @@ function widget_balance(widget) {
|
|
});
|
|
});
|
|
}
|
|
}
|
|
|
|
|
|
- /*
|
|
|
|
|
|
+ /*
|
|
PURCHASE INVOICE
|
|
PURCHASE INVOICE
|
|
*/
|
|
*/
|
|
-
|
|
|
|
|
|
+
|
|
if(purchase_invoice.length > 0){
|
|
if(purchase_invoice.length > 0){
|
|
array = [];
|
|
array = [];
|
|
_.each(purchase_invoice, function (item) {
|
|
_.each(purchase_invoice, function (item) {
|
|
@@ -456,20 +456,20 @@ function widget_balance(widget) {
|
|
});
|
|
});
|
|
}
|
|
}
|
|
|
|
|
|
- balance = (sale_invoice_amount + amount_order) - (sale_invoice_refund_amount + purchase_invoice_amount);
|
|
|
|
|
|
+ balance = (sale_invoice_amount + amount_order) - (sale_invoice_refund_amount + purchase_invoice_amount);
|
|
self.week = balance;
|
|
self.week = balance;
|
|
},
|
|
},
|
|
|
|
|
|
- /*
|
|
|
|
|
|
+ /*
|
|
MONTH
|
|
MONTH
|
|
*/
|
|
*/
|
|
|
|
|
|
showThisMonth: function () {
|
|
showThisMonth: function () {
|
|
var self = this;
|
|
var self = this;
|
|
if(self.DashboardObjetive.length > 0){
|
|
if(self.DashboardObjetive.length > 0){
|
|
- self.objective = self.DashboardObjetive.shift().expected_profit;
|
|
|
|
|
|
+ self.objective = self.DashboardObjetive.shift().expected_profit;
|
|
}else{
|
|
}else{
|
|
- self.objective = 0;
|
|
|
|
|
|
+ self.objective = 0;
|
|
}
|
|
}
|
|
|
|
|
|
var amount_order = 0;
|
|
var amount_order = 0;
|
|
@@ -480,13 +480,13 @@ function widget_balance(widget) {
|
|
var array = [];
|
|
var array = [];
|
|
var out_array = [];
|
|
var out_array = [];
|
|
var order = self.getThisMonthPosOrder();
|
|
var order = self.getThisMonthPosOrder();
|
|
-
|
|
|
|
|
|
+
|
|
var sale_invoice = self.getThisMonthAccountInvoice('sale');
|
|
var sale_invoice = self.getThisMonthAccountInvoice('sale');
|
|
var sale_invoice_refund = self.getThisMonthAccountInvoice('sale_refund');
|
|
var sale_invoice_refund = self.getThisMonthAccountInvoice('sale_refund');
|
|
var purchase_invoice = self.getThisMonthAccountInvoice('purchase');
|
|
var purchase_invoice = self.getThisMonthAccountInvoice('purchase');
|
|
|
|
|
|
var CurrencyBase = self.getResCurrency(self.ResCompany[0].currency_id[0]).shift();
|
|
var CurrencyBase = self.getResCurrency(self.ResCompany[0].currency_id[0]).shift();
|
|
-
|
|
|
|
|
|
+
|
|
if(order.length > 0){
|
|
if(order.length > 0){
|
|
amount_order = _.reduce(_.map(order, function (map) {
|
|
amount_order = _.reduce(_.map(order, function (map) {
|
|
return map.amount_total;
|
|
return map.amount_total;
|
|
@@ -494,11 +494,11 @@ function widget_balance(widget) {
|
|
return memo + num;
|
|
return memo + num;
|
|
});
|
|
});
|
|
}
|
|
}
|
|
-
|
|
|
|
- /*
|
|
|
|
|
|
+
|
|
|
|
+ /*
|
|
SALE INVOICE
|
|
SALE INVOICE
|
|
*/
|
|
*/
|
|
-
|
|
|
|
|
|
+
|
|
if(sale_invoice.length > 0){
|
|
if(sale_invoice.length > 0){
|
|
array = [];
|
|
array = [];
|
|
_.each(sale_invoice, function (item) {
|
|
_.each(sale_invoice, function (item) {
|
|
@@ -514,10 +514,10 @@ function widget_balance(widget) {
|
|
});
|
|
});
|
|
}
|
|
}
|
|
|
|
|
|
- /*
|
|
|
|
|
|
+ /*
|
|
SALE INVOICE REFUND
|
|
SALE INVOICE REFUND
|
|
*/
|
|
*/
|
|
-
|
|
|
|
|
|
+
|
|
if(sale_invoice_refund.length > 0){
|
|
if(sale_invoice_refund.length > 0){
|
|
array = [];
|
|
array = [];
|
|
_.each(sale_invoice_refund, function (item) {
|
|
_.each(sale_invoice_refund, function (item) {
|
|
@@ -533,10 +533,10 @@ function widget_balance(widget) {
|
|
});
|
|
});
|
|
}
|
|
}
|
|
|
|
|
|
- /*
|
|
|
|
|
|
+ /*
|
|
PURCHASE INVOICE
|
|
PURCHASE INVOICE
|
|
*/
|
|
*/
|
|
-
|
|
|
|
|
|
+
|
|
if(purchase_invoice.length > 0){
|
|
if(purchase_invoice.length > 0){
|
|
_.each(purchase_invoice, function (item) {
|
|
_.each(purchase_invoice, function (item) {
|
|
var currency = self.getResCurrency(item.currency_id[0]).shift();
|
|
var currency = self.getResCurrency(item.currency_id[0]).shift();
|
|
@@ -551,10 +551,10 @@ function widget_balance(widget) {
|
|
});
|
|
});
|
|
}
|
|
}
|
|
|
|
|
|
- balance = (sale_invoice_amount + amount_order) - (sale_invoice_refund_amount + purchase_invoice_amount);
|
|
|
|
|
|
+ balance = (sale_invoice_amount + amount_order) - (sale_invoice_refund_amount + purchase_invoice_amount);
|
|
self.month = balance;
|
|
self.month = balance;
|
|
- if(self.objective > 0){
|
|
|
|
- var percentage = (balance*100)/self.objective;
|
|
|
|
|
|
+ if(self.objective > 0){
|
|
|
|
+ var percentage = (balance*100)/self.objective;
|
|
}else{
|
|
}else{
|
|
var percentage = 0;
|
|
var percentage = 0;
|
|
}
|
|
}
|
|
@@ -568,11 +568,11 @@ function widget_balance(widget) {
|
|
percentageTextSize: 35,
|
|
percentageTextSize: 35,
|
|
});
|
|
});
|
|
self.percentage = percentage;
|
|
self.percentage = percentage;
|
|
-
|
|
|
|
|
|
+
|
|
self.$el.find('.widget-content').find('a').text(accounting.formatMoney(balance, CurrencyBase.symbol, CurrencyBase.decimal_places, CurrencyBase.thousands_separator, CurrencyBase.decimal_separator))
|
|
self.$el.find('.widget-content').find('a').text(accounting.formatMoney(balance, CurrencyBase.symbol, CurrencyBase.decimal_places, CurrencyBase.thousands_separator, CurrencyBase.decimal_separator))
|
|
},
|
|
},
|
|
|
|
|
|
- /*
|
|
|
|
|
|
+ /*
|
|
MODAL
|
|
MODAL
|
|
*/
|
|
*/
|
|
|
|
|
|
@@ -616,4 +616,4 @@ function widget_balance(widget) {
|
|
},
|
|
},
|
|
|
|
|
|
});
|
|
});
|
|
-}
|
|
|
|
|
|
+}
|