|
@@ -6,6 +6,8 @@ function report_invoice_balance (reporting){
|
|
|
reporting.ReportInvoiceBalanceWidget = reporting.Base.extend({
|
|
|
template: 'ReportInvoiceBalance',
|
|
|
content:[],
|
|
|
+ resCompany:[],
|
|
|
+ ResCurrency:[],
|
|
|
rowsData :[],
|
|
|
events:{
|
|
|
'click #toolbar > button' : 'clickOnAction',
|
|
@@ -92,6 +94,12 @@ function report_invoice_balance (reporting){
|
|
|
return self.fetchResPartner();
|
|
|
}).then(function(ResPartner){
|
|
|
self.ResPartner = ResPartner;
|
|
|
+ return self.fetchResCurrency();
|
|
|
+ }).then(function(ResCurrency){
|
|
|
+ self.ResCurrency = ResCurrency;
|
|
|
+ return self.fecthCompanyCurrency();
|
|
|
+ }).then(function(resCompany){
|
|
|
+ self.resCompany = resCompany;
|
|
|
self.search();
|
|
|
return self.BuildTable();
|
|
|
});
|
|
@@ -142,6 +150,31 @@ function report_invoice_balance (reporting){
|
|
|
return defer;
|
|
|
},
|
|
|
|
|
|
+ fetchResCurrency : function(){
|
|
|
+ var self = this;
|
|
|
+ var defer = $.Deferred();
|
|
|
+ var fields = ['id','name', 'symbol', 'rate_silent', 'base', 'decimal_separator', 'decimal_places', 'thousands_separator', 'symbol_position'];
|
|
|
+ var domain = [['active', '=', true]];
|
|
|
+ var ResCurrency = new instance.web.Model('res.currency');
|
|
|
+ ResCurrency.query(fields).filter(domain).all().then(function(results) {
|
|
|
+ defer.resolve(results);
|
|
|
+ });
|
|
|
+ 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 instance.web.Model('res.company');
|
|
|
+ ResCompany.query(field).filter(domain).all().then(function(results){
|
|
|
+ defer.resolve(results);
|
|
|
+ });
|
|
|
+ return defer;
|
|
|
+ },
|
|
|
+
|
|
|
+
|
|
|
fecthAccountJournal: function(){
|
|
|
var self = this;
|
|
|
var defer = $.Deferred();
|
|
@@ -217,10 +250,19 @@ function report_invoice_balance (reporting){
|
|
|
});
|
|
|
},
|
|
|
|
|
|
+ getResCurrency: function (id) {
|
|
|
+ var self = this;
|
|
|
+ return _.filter(self.ResCurrency,function (item) {
|
|
|
+ return item.id === id;
|
|
|
+ })
|
|
|
+ },
|
|
|
+
|
|
|
+
|
|
|
BuildTable: function(){
|
|
|
var self = this;
|
|
|
var data = [];
|
|
|
var AccountInvoice = self.AccountInvoice;
|
|
|
+ var CurrencyBase = self.getResCurrency(self.resCompany[0].currency_id[0]).shift();
|
|
|
var amount_total_num;
|
|
|
var entry;
|
|
|
var egress;
|
|
@@ -232,6 +274,7 @@ function report_invoice_balance (reporting){
|
|
|
var to_pay_num;
|
|
|
var invoice_type;
|
|
|
_.each(AccountInvoice, function(item){
|
|
|
+ var currency = self.getResCurrency(item.currency_id[0]).shift();
|
|
|
if (item.type == 'out_invoice') {
|
|
|
entry = item.amount_total - item.residual;
|
|
|
egress = 0;
|
|
@@ -257,22 +300,22 @@ function report_invoice_balance (reporting){
|
|
|
partner: item.partner_id[1],
|
|
|
date_invoice: moment(item.date_invoice).format("DD/MM/YYYY"),
|
|
|
user: item.user_id[1],
|
|
|
- amount_total: accounting.formatNumber(item.amount_total,0,".",","),
|
|
|
- entry: accounting.formatNumber(entry,0,".",","),
|
|
|
- egress: accounting.formatNumber(egress,0,".",","),
|
|
|
- to_receive: accounting.formatNumber(to_receive,0,".",","),
|
|
|
- to_pay: accounting.formatNumber(to_pay,0,".",","),
|
|
|
+ amount_total: accounting.formatNumber((item.amount_total * (CurrencyBase.rate_silent/currency.rate_silent)),0,".",","),
|
|
|
+ entry: accounting.formatNumber((entry * (CurrencyBase.rate_silent/currency.rate_silent)),0,".",","),
|
|
|
+ egress: accounting.formatNumber((egress * (CurrencyBase.rate_silent/currency.rate_silent)),0,".",","),
|
|
|
+ to_receive: accounting.formatNumber((to_receive * (CurrencyBase.rate_silent/currency.rate_silent)),0,".",","),
|
|
|
+ to_pay: accounting.formatNumber((to_pay * (CurrencyBase.rate_silent/currency.rate_silent)),0,".",","),
|
|
|
state: item.state,
|
|
|
invoice_type: invoice_type,
|
|
|
date: item.date_invoice,
|
|
|
journal_id : item.journal_id[0],
|
|
|
currency_id : item.currency_id[0],
|
|
|
partner_id : item.partner_id[0],
|
|
|
- amount_total_num: item.amount_total,
|
|
|
- entry_num: entry,
|
|
|
- egress_num: egress,
|
|
|
- to_receive_num: to_receive,
|
|
|
- to_pay_num: to_pay,
|
|
|
+ amount_total_num: (item.amount_total * (CurrencyBase.rate_silent/currency.rate_silent)),
|
|
|
+ entry_num: (entry * (CurrencyBase.rate_silent/currency.rate_silent)),
|
|
|
+ egress_num: (egress * (CurrencyBase.rate_silent/currency.rate_silent)),
|
|
|
+ to_receive_num: (to_receive * (CurrencyBase.rate_silent/currency.rate_silent)),
|
|
|
+ to_pay_num: (to_pay * (CurrencyBase.rate_silent/currency.rate_silent)),
|
|
|
store_id: store_id[0].store_ids[0],
|
|
|
});
|
|
|
}
|