|
@@ -6,9 +6,11 @@ function report_sale_vendor (reporting){
|
|
template :'ReportSaleVendor',
|
|
template :'ReportSaleVendor',
|
|
accountVoucher:[],
|
|
accountVoucher:[],
|
|
resCurrency:[],
|
|
resCurrency:[],
|
|
- accountJournal:[],
|
|
|
|
|
|
+ invoices:[],
|
|
|
|
+ Journal:[],
|
|
dataVoucher:[],
|
|
dataVoucher:[],
|
|
- currencyRate:[],
|
|
|
|
|
|
+ rowsData :[],
|
|
|
|
+ content :[],
|
|
resCompany:[],
|
|
resCompany:[],
|
|
modules:[],
|
|
modules:[],
|
|
|
|
|
|
@@ -27,19 +29,28 @@ function report_sale_vendor (reporting){
|
|
'change #current-currency': 'fectSearch',
|
|
'change #current-currency': 'fectSearch',
|
|
'change #from' : 'fectSearch',
|
|
'change #from' : 'fectSearch',
|
|
'change #to': 'fectSearch',
|
|
'change #to': 'fectSearch',
|
|
- 'click #volver_btn': 'volver',
|
|
|
|
},
|
|
},
|
|
|
|
|
|
- init:function(parent){
|
|
|
|
|
|
+ init : function(parent){
|
|
this._super(parent);
|
|
this._super(parent);
|
|
},
|
|
},
|
|
- start: function(){
|
|
|
|
|
|
+
|
|
|
|
+ start: function () {
|
|
var self = this;
|
|
var self = this;
|
|
var table = this.$el.find('#table');
|
|
var table = this.$el.find('#table');
|
|
table.bootstrapTable({data : self.dataVoucher});
|
|
table.bootstrapTable({data : self.dataVoucher});
|
|
- self.fecthFecha();
|
|
|
|
- self.fecthInitial();
|
|
|
|
|
|
+ this.fecthFecha();
|
|
|
|
+ this.fetchInitial();
|
|
},
|
|
},
|
|
|
|
+
|
|
|
|
+ valorNull:function(dato){
|
|
|
|
+ var valor = "";
|
|
|
|
+ if (dato){
|
|
|
|
+ valor = dato;
|
|
|
|
+ }
|
|
|
|
+ return valor;
|
|
|
|
+ },
|
|
|
|
+
|
|
// Redirecionar
|
|
// Redirecionar
|
|
renderReport: function () {
|
|
renderReport: function () {
|
|
var self = this;
|
|
var self = this;
|
|
@@ -51,78 +62,59 @@ function report_sale_vendor (reporting){
|
|
duration: 200,
|
|
duration: 200,
|
|
});
|
|
});
|
|
},
|
|
},
|
|
- // Verificar el modelo
|
|
|
|
|
|
+
|
|
checkModel : function(model){
|
|
checkModel : function(model){
|
|
var self = this;
|
|
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 _.filter(self.IrModuleModule,function(item){
|
|
|
|
+ return item.name === model
|
|
});
|
|
});
|
|
- return
|
|
|
|
},
|
|
},
|
|
|
|
|
|
- // Metodo inicial
|
|
|
|
- fecthInitial: function(){
|
|
|
|
|
|
+ fetchInitial: function () {
|
|
var self = this;
|
|
var self = this;
|
|
- self.fecthIrModuleModule().then(function(modules){
|
|
|
|
- self.modules = modules;
|
|
|
|
- return modules;
|
|
|
|
- }).then(function(modules){
|
|
|
|
- return self.fecthJournalStore();
|
|
|
|
- }).then(function(accountJournal){
|
|
|
|
- self.accountJournal=accountJournal;
|
|
|
|
- self.$el.find('#current-journal').append('<option value="9999999">Todas las SUC.</option>');
|
|
|
|
- _.each(accountJournal,function(item){
|
|
|
|
|
|
+ self.fecthIrModuleModule().then(function (IrModuleModule) {
|
|
|
|
+ return IrModuleModule;
|
|
|
|
+ }).then(function(IrModuleModule) {
|
|
|
|
+ self.IrModuleModule = IrModuleModule;
|
|
|
|
+ return self.fetchResUser();
|
|
|
|
+ }).then(function (ResUser) {
|
|
|
|
+ self.ResUser = ResUser;
|
|
|
|
+ return self.fetchResCompany();
|
|
|
|
+ }).then(function(ResCompany){
|
|
|
|
+ self.ResCompany = ResCompany;
|
|
|
|
+ if(ResCompany.length > 1){
|
|
|
|
+ self.$el.find('#current-company').append('<option value="9999999">Todas las empresas</option>');
|
|
|
|
+ _.each(ResCompany,function(item){
|
|
|
|
+ self.$el.find('#current-company').append('<option value="' + item.id + '">' + item.name + '</option>');
|
|
|
|
+ });
|
|
|
|
+ }else{
|
|
|
|
+ self.$el.find('.company').css('display','none');
|
|
|
|
+ }
|
|
|
|
+ return self.fetchResStore();
|
|
|
|
+ }).then(function(ResStore){
|
|
|
|
+ self.ResStore = ResStore;
|
|
|
|
+ if(ResStore.length > 1){
|
|
|
|
+ self.$el.find('#current-store').append('<option value="9999999">Todas las sucursales</option>');
|
|
|
|
+ _.each(ResStore,function(item){
|
|
|
|
+ self.$el.find('#current-store').append('<option value="' + item.id + '">' + item.name + '</option>');
|
|
|
|
+ });
|
|
|
|
+ }else{
|
|
|
|
+ self.$el.find('.store').css('display','none');
|
|
|
|
+ }
|
|
|
|
+ return self.fetchAccountJournal();
|
|
|
|
+ }).then(function(AccountJournal){
|
|
|
|
+ self.AccountJournal = AccountJournal;
|
|
|
|
+ self.$el.find('#current-journal').append('<option value="9999999">Todas las facturas</option>');
|
|
|
|
+ _.each(AccountJournal,function(item){
|
|
self.$el.find('#current-journal').append('<option value="' + item.id + '">' + item.name + '</option>');
|
|
self.$el.find('#current-journal').append('<option value="' + item.id + '">' + item.name + '</option>');
|
|
});
|
|
});
|
|
return self.fetchResCurrency();
|
|
return self.fetchResCurrency();
|
|
- }).then(function(ResCurrency){
|
|
|
|
|
|
+ }).then(function(ResCurrency){
|
|
self.ResCurrency = ResCurrency;
|
|
self.ResCurrency = ResCurrency;
|
|
- return self.fecthCompanyCurrency();
|
|
|
|
- }).then(function(ResCompany){
|
|
|
|
- self.ResCompany = ResCompany;
|
|
|
|
- return self.fecthCurrencyRate();
|
|
|
|
- }).then(function(currencyRate){
|
|
|
|
- self.currencyRate =currencyRate;
|
|
|
|
- return self.fecthVoucher();
|
|
|
|
- }).then(function(accountVoucher){
|
|
|
|
- self.accountVoucher=accountVoucher;
|
|
|
|
- return self.fetchInvoiceV2();
|
|
|
|
- }).then(function (invoices){
|
|
|
|
- self.invoices = invoices;
|
|
|
|
- return self.fetchWarehouse();
|
|
|
|
- }).then(function(WareHouse){
|
|
|
|
- self.WareHouse=WareHouse;
|
|
|
|
- self.$el.find('#current-warehouse').append('<option value="9999999">Todos los vendedores</option>');
|
|
|
|
- _.each(WareHouse,function(item){
|
|
|
|
- self.$el.find('#current-warehouse').append('<option value="' + item.id + '">' + item.name + '</option>');
|
|
|
|
- });
|
|
|
|
- return self.fecthDataVoucher(self.accountVoucher,self.accountJournal);
|
|
|
|
|
|
+ return self.fetchAccountInvoice();
|
|
|
|
+ }).then(function (AccountInvoice) {
|
|
|
|
+ self.AccountInvoice = AccountInvoice;
|
|
|
|
+ return self.BuildTable(self.AccountInvoice,self.ResStore);
|
|
});
|
|
});
|
|
},
|
|
},
|
|
|
|
|
|
@@ -167,34 +159,51 @@ function report_sale_vendor (reporting){
|
|
var defer = $.Deferred();
|
|
var defer = $.Deferred();
|
|
var fields = ['name','id'];
|
|
var fields = ['name','id'];
|
|
var domain=[['state','=','installed']];
|
|
var domain=[['state','=','installed']];
|
|
- var irModule = new instance.web.Model('ir.module.module');
|
|
|
|
|
|
+ var IrModuleModule = new instance.web.Model('ir.module.module');
|
|
|
|
|
|
- irModule.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;
|
|
},
|
|
},
|
|
- // Journal
|
|
|
|
- fecthJournalStore: function(){
|
|
|
|
|
|
+
|
|
|
|
+ fetchResUser: function() {
|
|
var self = this;
|
|
var self = this;
|
|
var defer = $.Deferred();
|
|
var defer = $.Deferred();
|
|
- var modules = _.flatten(self.checkModel('multi_store'));
|
|
|
|
-
|
|
|
|
- if (modules.length <= 0){
|
|
|
|
- self.showMensaje('multi_store');
|
|
|
|
- return defer;
|
|
|
|
- }
|
|
|
|
|
|
+ var fields = ['id','name','store_id'];
|
|
|
|
+ var domain = [['id','=',self.session.uid]];
|
|
|
|
+ var ResUser = new instance.web.Model('res.users');
|
|
|
|
+ ResUser.query(fields).filter(domain).all().then(function (results) {
|
|
|
|
+ defer.resolve(results);
|
|
|
|
+ });
|
|
|
|
+ return defer;
|
|
|
|
+ },
|
|
|
|
|
|
- var journal = new instance.web.Model('res.store');
|
|
|
|
|
|
+ fetchResStore: function(){
|
|
|
|
+ var self = this;
|
|
|
|
+ var defer = $.Deferred();
|
|
var field=['id', 'name','journal_ids'];
|
|
var field=['id', 'name','journal_ids'];
|
|
|
|
+ var ResStore = new instance.web.Model('res.store');
|
|
|
|
+ ResStore.query(field).all().then(function(results){
|
|
|
|
+ defer.resolve(results);
|
|
|
|
+ });
|
|
|
|
+ return defer;
|
|
|
|
+ },
|
|
|
|
|
|
- journal.query(field).order_by('id').all().then(function(results){
|
|
|
|
|
|
+ fetchAccountJournal: function(){
|
|
|
|
+ var self = this;
|
|
|
|
+ var defer = $.Deferred();
|
|
|
|
+ var field = ['id', 'name','store_ids','type'];
|
|
|
|
+ var domain = [['active','=',true],['type', '=', 'sale']];
|
|
|
|
+ var AccountJournal = new instance.web.Model('account.journal');
|
|
|
|
+ AccountJournal.query(field).filter(domain).all().then(function(results){
|
|
defer.resolve(results);
|
|
defer.resolve(results);
|
|
});
|
|
});
|
|
return defer;
|
|
return defer;
|
|
},
|
|
},
|
|
|
|
+
|
|
// company_curency
|
|
// company_curency
|
|
- fecthCompanyCurrency: function(){
|
|
|
|
|
|
+ fetchResCompany: function(){
|
|
var self = this;
|
|
var self = this;
|
|
var defer = $.Deferred();
|
|
var defer = $.Deferred();
|
|
var field=['id','name', 'currency_id', 'vat'];
|
|
var field=['id','name', 'currency_id', 'vat'];
|
|
@@ -205,7 +214,6 @@ function report_sale_vendor (reporting){
|
|
});
|
|
});
|
|
return defer;
|
|
return defer;
|
|
},
|
|
},
|
|
- // Moneda
|
|
|
|
fetchResCurrency:function(){
|
|
fetchResCurrency:function(){
|
|
var self = this;
|
|
var self = this;
|
|
var defer = $.Deferred();
|
|
var defer = $.Deferred();
|
|
@@ -217,82 +225,20 @@ function report_sale_vendor (reporting){
|
|
});
|
|
});
|
|
return defer;
|
|
return defer;
|
|
},
|
|
},
|
|
- // Cambio de la moneda
|
|
|
|
- fecthCurrencyRate:function(){
|
|
|
|
- var defer = $.Deferred();
|
|
|
|
- var currency_Rate = new instance.web.Model('res.currency.rate');
|
|
|
|
- var fields = ['id', 'name', 'currency_id', 'rate', 'create_date'];
|
|
|
|
- var domain = [['currency_id', 'in', [166 , 20, 7, 3]]];
|
|
|
|
- currency_Rate.query(fields).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', 'reference', 'state', 'journal_id', 'currency_id', 'user_id','date_invoice','amount_total','amount_tax','amount_untaxed','partner_id'];
|
|
|
|
- var defer = $.Deferred();
|
|
|
|
- var invoices = new instance.web.Model('account.invoice');
|
|
|
|
- invoices.query(field).filter(filter).all().then(function (results) {
|
|
|
|
- defer.resolve(results);
|
|
|
|
- });
|
|
|
|
- return defer;
|
|
|
|
- },
|
|
|
|
|
|
|
|
- // Voucher -
|
|
|
|
- fecthVoucher: function () {
|
|
|
|
- var self = this;
|
|
|
|
- var defer = $.Deferred();
|
|
|
|
- var voucher = new instance.web.Model('sale.order');
|
|
|
|
- var filter = [['state', 'in', ['progress','done']],['shipped', '=', true]];
|
|
|
|
- // var warehouse_ids = _.flatten(_.map(self.WareHouse, function (item) {
|
|
|
|
- // return item.id;
|
|
|
|
- // }));
|
|
|
|
- // if (warehouse_ids){
|
|
|
|
- // filter=filter.concat(",['warehouse_id', 'in',["+ warehouse_ids+"]]");
|
|
|
|
- // }
|
|
|
|
- // filter=filter.concat("]");
|
|
|
|
- var field =['id', 'number', 'name','origin', 'state', 'type_id', 'warehouse_id', 'currency_id', 'amount_total', 'date_order', 'shipped'];
|
|
|
|
- voucher.query(field).filter(filter).all().then(function (results) {
|
|
|
|
- defer.resolve(results);
|
|
|
|
- });
|
|
|
|
- return defer;
|
|
|
|
- },
|
|
|
|
-
|
|
|
|
- fetchWarehouse: function(){
|
|
|
|
|
|
+ fetchAccountInvoice: function () {
|
|
var self = this;
|
|
var self = this;
|
|
var defer = $.Deferred();
|
|
var defer = $.Deferred();
|
|
- var field=['id', 'name'];
|
|
|
|
- var WareHouse = new instance.web.Model('stock.warehouse');
|
|
|
|
- WareHouse.query(field).all().then(function(results){
|
|
|
|
|
|
+ var AccountInvoice = new instance.web.Model('account.invoice');
|
|
|
|
+ var filter =[['state', 'in',['open','paid']],['type', '=', 'out_invoice']];
|
|
|
|
+
|
|
|
|
+ var fields =['id', 'type', 'number', 'origin', 'reference', 'state', 'journal_id', 'currency_id', 'user_id','date_invoice','amount_total','amount_tax','amount_untaxed','partner_id'];
|
|
|
|
+
|
|
|
|
+ AccountInvoice.query(fields).filter(filter).all().then(function (results) {
|
|
defer.resolve(results);
|
|
defer.resolve(results);
|
|
});
|
|
});
|
|
return defer;
|
|
return defer;
|
|
- },
|
|
|
|
-
|
|
|
|
- getResCurrency: function (id) {
|
|
|
|
- var self = this;
|
|
|
|
- return _.filter(self.ResCurrency,function (item) {
|
|
|
|
- return item.id === id;
|
|
|
|
- })
|
|
|
|
- },
|
|
|
|
-
|
|
|
|
- getSaleOrder: function (id) {
|
|
|
|
- var self = this;
|
|
|
|
- return _.filter(self.accountVoucher,function (item) {
|
|
|
|
- return item.number === id;
|
|
|
|
- });
|
|
|
|
- },
|
|
|
|
-
|
|
|
|
|
|
+ },
|
|
// Verificar Valor null
|
|
// Verificar Valor null
|
|
valorNull:function(dato){
|
|
valorNull:function(dato){
|
|
var valor ="";
|
|
var valor ="";
|
|
@@ -302,110 +248,135 @@ function report_sale_vendor (reporting){
|
|
return valor;
|
|
return valor;
|
|
},
|
|
},
|
|
|
|
|
|
|
|
+ getAccountInvoice: function (id) {
|
|
|
|
+ var self = this;
|
|
|
|
+ return _.filter(self.AccountInvoice,function (item) {
|
|
|
|
+ return item.journal_id[0] === id;
|
|
|
|
+ });
|
|
|
|
+ },
|
|
|
|
+
|
|
|
|
+ getStore: function (id) {
|
|
|
|
+ var self = this;
|
|
|
|
+ return _.filter(self.ResStore,function (item) {
|
|
|
|
+ return item.id === id;
|
|
|
|
+ });
|
|
|
|
+ },
|
|
|
|
+
|
|
|
|
+ getResCurrency: function (id) {
|
|
|
|
+ var self = this;
|
|
|
|
+ return _.filter(self.ResCurrency,function (item) {
|
|
|
|
+ return item.id === id;
|
|
|
|
+ })
|
|
|
|
+ },
|
|
|
|
+
|
|
// Join object
|
|
// Join object
|
|
- fecthDataVoucher:function(objVoucher,objJournal){
|
|
|
|
|
|
+ BuildTable:function(objVoucher,objJournal){
|
|
var self=this;
|
|
var self=this;
|
|
var CurrencyBase = self.getResCurrency(self.ResCompany[0].currency_id[0]).shift();
|
|
var CurrencyBase = self.getResCurrency(self.ResCompany[0].currency_id[0]).shift();
|
|
var item;
|
|
var item;
|
|
- var journal;
|
|
|
|
|
|
+ //var journal=self.AccountJournal;
|
|
|
|
+
|
|
|
|
+ var company = $('#current-company').val();
|
|
|
|
+ if(company && company != 9999999){
|
|
|
|
+ var ResCompany = self.getResCompany(company).shift();
|
|
|
|
+ var CurrencyBase = self.getResCurrency(ResCompany.currency_id[0]).shift();
|
|
|
|
+ }else{
|
|
|
|
+ var CurrencyBase = self.getResCurrency(self.ResCompany[0].currency_id[0]).shift();
|
|
|
|
+ };
|
|
var voucherLine;
|
|
var voucherLine;
|
|
var voucherItem;//Contenido del voucher
|
|
var voucherItem;//Contenido del voucher
|
|
var sumaAmount; //Guardar la suma de los pagos
|
|
var sumaAmount; //Guardar la suma de los pagos
|
|
var voucherObject=[];
|
|
var voucherObject=[];
|
|
|
|
+ var invoice=[];
|
|
|
|
+ var cabjournal;
|
|
var voucherObjectItem=[];
|
|
var voucherObjectItem=[];
|
|
- var sale = [];
|
|
|
|
- var cutrrencyRate; //Valor del cambio
|
|
|
|
|
|
+ var currency;
|
|
|
|
+ var store;
|
|
|
|
+ var store_id="";
|
|
|
|
+ var store_name="";
|
|
var total=0;
|
|
var total=0;
|
|
var sumaAmountTot=0;
|
|
var sumaAmountTot=0;
|
|
var itemVoucher;
|
|
var itemVoucher;
|
|
|
|
+ var itemjournal;
|
|
|
|
|
|
for (var i = 0; i < objJournal.length; i++) {
|
|
for (var i = 0; i < objJournal.length; i++) {
|
|
|
|
+
|
|
voucherObjectItem=[];
|
|
voucherObjectItem=[];
|
|
- journal=objJournal[i];
|
|
|
|
|
|
+ cabjournal=objJournal[i];
|
|
|
|
+
|
|
|
|
+ for (var f = 0; f < cabjournal.journal_ids.length; f++) { //este
|
|
|
|
+ voucherLine = cabjournal.journal_ids[f];
|
|
|
|
|
|
- for (var f = 0; f < journal.journal_ids.length; f++) {
|
|
|
|
- voucherLine = journal.journal_ids[f];
|
|
|
|
voucherItem = self.getVoucherjournal(objVoucher,voucherLine)
|
|
voucherItem = self.getVoucherjournal(objVoucher,voucherLine)
|
|
|
|
|
|
- // sale = self.getSaleOrder(voucherItem.name);
|
|
|
|
- // console.log(sale);
|
|
|
|
|
|
+ // invoice = self.getAccountInvoice(cabjournal.id);
|
|
|
|
|
|
if (voucherItem.length > 0){
|
|
if (voucherItem.length > 0){
|
|
- sumaAmount=_.reduce(_.map(voucherItem,function(item){return item.amount_total}), function(memo, num){ return memo + num; },0);
|
|
|
|
- itemVoucher = voucherItem.shift();
|
|
|
|
- var currency = self.getResCurrency(itemVoucher.currency_id[0]).shift();
|
|
|
|
-
|
|
|
|
- // Guardar item
|
|
|
|
- voucherObjectItem.push({journal : " ",
|
|
|
|
- method :self.valorNull(itemVoucher.warehouse_id[1]),
|
|
|
|
- amount : accounting.formatNumber(self.valorNull(sumaAmount * (CurrencyBase.rate_silent/currency.rate_silent)),0, ".", ","),
|
|
|
|
- currency_name : self.valorNull(itemVoucher.currency_id[0]),
|
|
|
|
- currency_id : self.valorNull(itemVoucher.currency_id[1]),
|
|
|
|
- amountBase : self.valorNull(sumaAmount * (CurrencyBase.rate_silent/currency.rate_silent)),
|
|
|
|
- journal_id: journal.id,
|
|
|
|
- journal_name: journal.name,
|
|
|
|
- warehouse_id: itemVoucher.warehouse_id[0],
|
|
|
|
- graficar: false
|
|
|
|
- })
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- if (voucherObjectItem.length > 0){
|
|
|
|
- var company = _.map(self.ResCompany, function (map) {
|
|
|
|
- return map.currency_id[1];
|
|
|
|
- });
|
|
|
|
-
|
|
|
|
- sumaAmountTot=_.reduce(_.map(voucherObjectItem,function(item){return (item.amountBase)}), function(memo, num){ return memo + num; },0);
|
|
|
|
- total=total+sumaAmountTot;
|
|
|
|
- voucherObjectItem.push({journal : " ",
|
|
|
|
- method :"Total " + company,
|
|
|
|
- amount : accounting.formatNumber(self.valorNull(sumaAmountTot),0, ".", ","),
|
|
|
|
- currency_name : "",
|
|
|
|
- currency_id : "",
|
|
|
|
- rate : "cutrrencyRate.rate",
|
|
|
|
- amountBase:"",
|
|
|
|
- journal_id: journal.id,
|
|
|
|
- journal_name: journal.name,
|
|
|
|
- graficar: true
|
|
|
|
- });
|
|
|
|
-
|
|
|
|
- // General la Cabezera
|
|
|
|
- voucherObjectItem.unshift({ journal : journal.name, method :"", amount :"", voucherLine_name :"", voucherLine_id :"",rate :"",amountBase :"", warehouse_id:"",journal_id:journal.id, journal_name:journal.name, graficar:false});
|
|
|
|
|
|
+ sumaAmount=_.reduce(_.map(voucherItem,function(item){return item.amount_total}), function(memo, num){ return memo + num; },0);
|
|
|
|
+
|
|
|
|
+ itemVoucher = voucherItem.shift();
|
|
|
|
+ var currency = self.getResCurrency(itemVoucher.currency_id[0]).shift();
|
|
|
|
+
|
|
|
|
+ // Guardar item
|
|
|
|
+ voucherObjectItem.push({ journal : " ",
|
|
|
|
+ method :self.valorNull(itemVoucher.journal_id[1]),
|
|
|
|
+ amount : accounting.formatNumber(self.valorNull(sumaAmount* (CurrencyBase.rate_silent/currency.rate_silent)),0, ".", ","),
|
|
|
|
+ amountBase : self.valorNull(sumaAmount* (CurrencyBase.rate_silent/currency.rate_silent)),
|
|
|
|
+ journal_id: cabjournal.id,
|
|
|
|
+ journal_name: cabjournal.name,
|
|
|
|
+ graficar: false
|
|
|
|
+ })
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ if (voucherObjectItem.length > 0){
|
|
|
|
+ var company = _.map(self.ResCompany, function (map) {
|
|
|
|
+ return map.currency_id[1];
|
|
|
|
+ });
|
|
|
|
+
|
|
|
|
+ sumaAmountTot=_.reduce(_.map(voucherObjectItem,function(item){return (item.amountBase)}), function(memo, num){ return memo + num; },0);
|
|
|
|
+ total=total+sumaAmountTot;
|
|
|
|
+ voucherObjectItem.push({journal : " ",
|
|
|
|
+ method :"Total "+ company,
|
|
|
|
+ amount : accounting.formatNumber(self.valorNull(sumaAmountTot),0, ".", ","),
|
|
|
|
+ amountBase:"",
|
|
|
|
+ journal_id: cabjournal.id,
|
|
|
|
+ journal_name: cabjournal.name,
|
|
|
|
+ graficar: true
|
|
|
|
+ });
|
|
|
|
+ // Generar la Cabecera
|
|
|
|
+ voucherObjectItem.unshift({ journal : cabjournal.name, method :"", amount :"", voucherLine_name :"", voucherLine_id :"",rate :"",amountBase :"",journal_id:cabjournal.id, journal_name:cabjournal.name, graficar:false});
|
|
// Generar Objeto Principal
|
|
// Generar Objeto Principal
|
|
voucherObject=voucherObject.concat(voucherObjectItem);
|
|
voucherObject=voucherObject.concat(voucherObjectItem);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
- if (voucherObject.length >0){
|
|
|
|
- voucherObject.push({journal : " Total de Egreso",
|
|
|
|
- method :"",
|
|
|
|
- amount : accounting.formatNumber(self.valorNull(total),0, ".", ","),
|
|
|
|
- currency_name : "",
|
|
|
|
- currency_id : "",
|
|
|
|
- rate : "",
|
|
|
|
- amountBase:"",
|
|
|
|
- journal_id: journal.id,
|
|
|
|
- journal_name: journal.name,
|
|
|
|
- warehouse_id:"",
|
|
|
|
- graficar: false
|
|
|
|
- });
|
|
|
|
|
|
+ if (voucherObject.length > 0){
|
|
|
|
+ voucherObject.push({journal : " Total de Ingreso",
|
|
|
|
+ method :"",
|
|
|
|
+ amount : accounting.formatNumber(self.valorNull(total),0, ".", ","),
|
|
|
|
+ amountBase:"",
|
|
|
|
+ journal_id: cabjournal.id,
|
|
|
|
+ journal_name: cabjournal.name,
|
|
|
|
+ graficar: false
|
|
|
|
+ });
|
|
}
|
|
}
|
|
|
|
+ // voucherObjectItem.sort(function (a, b) {
|
|
|
|
+ // return b.amountBase - a.amountBase
|
|
|
|
+ // });
|
|
self.loadTable(voucherObject);
|
|
self.loadTable(voucherObject);
|
|
- self.content = voucherObject;
|
|
|
|
},
|
|
},
|
|
|
|
+
|
|
// Obtener Voucher
|
|
// Obtener Voucher
|
|
getVoucherjournal:function(objVoucher,journal_id){
|
|
getVoucherjournal:function(objVoucher,journal_id){
|
|
- return _.map(_.filter(objVoucher, function (inv){return inv.warehouse_id[0] === journal_id}),function(item){return item});
|
|
|
|
|
|
+ return _.map(_.filter(objVoucher, function (inv){return inv.journal_id[0] === journal_id}),function(item){return item});
|
|
},
|
|
},
|
|
- // Obtener Cambio
|
|
|
|
- // getCutrrencyRate: function(currency_id){
|
|
|
|
- // return _.filter(this.currencyRate, function(rate){return rate.currency_id[0] === currency_id}).shift();
|
|
|
|
- // },
|
|
|
|
- // Generar la tabla
|
|
|
|
|
|
+
|
|
loadTable:function(rowsTable){
|
|
loadTable:function(rowsTable){
|
|
- this.dataVoucher=rowsTable;
|
|
|
|
|
|
+ var self = this;
|
|
|
|
+ self.dataVoucher = rowsTable;
|
|
var table = this.$el.find('#table');
|
|
var table = this.$el.find('#table');
|
|
- table.bootstrapTable('load' ,rowsTable);
|
|
|
|
|
|
+ table.bootstrapTable('load',rowsTable);
|
|
},
|
|
},
|
|
- // Buscar
|
|
|
|
|
|
+
|
|
fectSearch: function(){
|
|
fectSearch: function(){
|
|
var self = this;
|
|
var self = this;
|
|
var today = moment().format('YYYY-MM-DD');
|
|
var today = moment().format('YYYY-MM-DD');
|
|
@@ -415,28 +386,27 @@ function report_sale_vendor (reporting){
|
|
var desde =this.$el.find('#from').val();
|
|
var desde =this.$el.find('#from').val();
|
|
var hasta =this.$el.find('#to').val();
|
|
var hasta =this.$el.find('#to').val();
|
|
var journal =this.$el.find('#current-journal').val();
|
|
var journal =this.$el.find('#current-journal').val();
|
|
- var currency =this.$el.find('#current-currency').val();
|
|
|
|
- var newJournal= self.accountJournal; //copia del Diario
|
|
|
|
- var newVoucher= self.accountVoucher; //copia del Vouacher
|
|
|
|
|
|
+ var newJournal= self.ResStore; //copia del Diario
|
|
|
|
+ var newVoucher= self.AccountInvoice; //copia del Vouacher
|
|
|
|
|
|
if ($('#A').is(":checked")){
|
|
if ($('#A').is(":checked")){
|
|
newVoucher = _.filter(newVoucher, function (inv){
|
|
newVoucher = _.filter(newVoucher, function (inv){
|
|
- return inv.date_order == today;
|
|
|
|
|
|
+ return inv.date_invoice == today;
|
|
});
|
|
});
|
|
}
|
|
}
|
|
if ($('#B').is(":checked")){
|
|
if ($('#B').is(":checked")){
|
|
newVoucher = _.filter(newVoucher, function (inv){
|
|
newVoucher = _.filter(newVoucher, function (inv){
|
|
- return moment(inv.date_order).format('YYYY-MM-DD') == yesterday;
|
|
|
|
|
|
+ return moment(inv.date_invoice).format('YYYY-MM-DD') == yesterday;
|
|
});
|
|
});
|
|
}
|
|
}
|
|
if ($('#C').is(":checked")){
|
|
if ($('#C').is(":checked")){
|
|
newVoucher = _.filter(newVoucher, function (inv){
|
|
newVoucher = _.filter(newVoucher, function (inv){
|
|
- return moment(inv.date_order).format('YYYY-MM') == month;
|
|
|
|
|
|
+ return moment(inv.date_invoice).format('YYYY-MM') == month;
|
|
});
|
|
});
|
|
}
|
|
}
|
|
if ($('#D').is(":checked")){
|
|
if ($('#D').is(":checked")){
|
|
newVoucher = _.filter(newVoucher, function (inv){
|
|
newVoucher = _.filter(newVoucher, function (inv){
|
|
- return moment(inv.date_order).format('YYYY-MM') == last_month;
|
|
|
|
|
|
+ return moment(inv.date_invoice).format('YYYY-MM') == last_month;
|
|
});
|
|
});
|
|
}
|
|
}
|
|
|
|
|
|
@@ -445,13 +415,13 @@ function report_sale_vendor (reporting){
|
|
if (desde.length > 0){
|
|
if (desde.length > 0){
|
|
var date= desde.split('/');
|
|
var date= desde.split('/');
|
|
newVoucher = _.filter(newVoucher, function (inv){
|
|
newVoucher = _.filter(newVoucher, function (inv){
|
|
- return inv.date_order >= (date[2]+"-"+date[1]+"-"+date[0]);
|
|
|
|
|
|
+ return inv.date_invoice >= (date[2]+"-"+date[1]+"-"+date[0]);
|
|
});
|
|
});
|
|
}
|
|
}
|
|
if (hasta.length > 0){
|
|
if (hasta.length > 0){
|
|
var date= hasta.split('/');
|
|
var date= hasta.split('/');
|
|
- newVoucher = _.filter(newVoucher, function (inv){
|
|
|
|
- return inv.date_order <= (date[2]+"-"+date[1]+"-"+date[0]);
|
|
|
|
|
|
+ newVoucher= _.filter(newVoucher, function (inv){
|
|
|
|
+ return inv.date_invoice <= (date[2]+"-"+date[1]+"-"+date[0]);
|
|
});
|
|
});
|
|
}
|
|
}
|
|
}else{
|
|
}else{
|
|
@@ -464,7 +434,8 @@ function report_sale_vendor (reporting){
|
|
}else {
|
|
}else {
|
|
var botonChart =this.$el.find('#chart').attr("disabled", false);
|
|
var botonChart =this.$el.find('#chart').attr("disabled", false);
|
|
}
|
|
}
|
|
- self.fecthDataVoucher(newVoucher,newJournal);
|
|
|
|
|
|
+ self.BuildTable(newVoucher,newJournal);
|
|
|
|
+ // self.loadTable(content)
|
|
},
|
|
},
|
|
// volver
|
|
// volver
|
|
volver: function(){
|
|
volver: function(){
|
|
@@ -529,7 +500,7 @@ function report_sale_vendor (reporting){
|
|
pdfDoc.setFontSize(12);
|
|
pdfDoc.setFontSize(12);
|
|
pdfDoc.setFontStyle('bold');
|
|
pdfDoc.setFontStyle('bold');
|
|
pdfDoc.setTextColor(40);
|
|
pdfDoc.setTextColor(40);
|
|
- pdfDoc.text('Resumen de Egreso de '+ sucusal, data.settings.margin.left, 10);
|
|
|
|
|
|
+ pdfDoc.text('Resumen de Ventas por Vendedores '+ sucusal, data.settings.margin.left, 10);
|
|
if(desde.length > 0 || hasta.length > 0){
|
|
if(desde.length > 0 || hasta.length > 0){
|
|
var fecha='';
|
|
var fecha='';
|
|
if(desde){
|
|
if(desde){
|
|
@@ -558,74 +529,66 @@ function report_sale_vendor (reporting){
|
|
if (typeof pdfDoc.putTotalPages === 'function') {
|
|
if (typeof pdfDoc.putTotalPages === 'function') {
|
|
pdfDoc.putTotalPages(totalPagesExp);
|
|
pdfDoc.putTotalPages(totalPagesExp);
|
|
}
|
|
}
|
|
- pdfDoc.save('Resumen de Egreso.pdf');
|
|
|
|
|
|
+ pdfDoc.save('Resumen de Ventas por Vendedores.pdf');
|
|
},
|
|
},
|
|
- // // Char filter
|
|
|
|
- // fectCharFilter: function(objetChar){
|
|
|
|
- // var self = this;
|
|
|
|
- // var dataBody=[];
|
|
|
|
- // var dataHeader=[];
|
|
|
|
- // // objetChar
|
|
|
|
- // var canvas="<canvas id='graf_resume'></canvas>";
|
|
|
|
- // this.$el.find('#grafico').append(canvas);
|
|
|
|
- // _.each(objetChar,function(voucher){
|
|
|
|
- // dataHeader.push(voucher.journal_name);
|
|
|
|
- // dataBody.push(parseFloat(((voucher.amount.replace(".","")).replace(",","."))));
|
|
|
|
- // });
|
|
|
|
- // var selector ="<button type='button' class='oe_button oe_form_button oe_highlight' id='volver_btn' name='volver_btn'><span>Atras</span></button>";
|
|
|
|
- // this.$el.find('#volver').append(selector);
|
|
|
|
- // this.$el.find('.bootstrap-table').hide({
|
|
|
|
- // effect: 'drop',
|
|
|
|
- // direction: 'up',
|
|
|
|
- // duration: 200,
|
|
|
|
- // complete: function () {
|
|
|
|
- // self.drawChart(dataHeader,dataBody);
|
|
|
|
- // }
|
|
|
|
- // });
|
|
|
|
- // this.$el.find('#toolbar').hide({
|
|
|
|
- // effect: 'drop',
|
|
|
|
- // direction: 'up',
|
|
|
|
- // duration: 200,
|
|
|
|
- // complete: function () {
|
|
|
|
- // self.drawChart(dataHeader,dataBody);
|
|
|
|
- // }
|
|
|
|
- // });
|
|
|
|
- // },
|
|
|
|
- // //Chart
|
|
|
|
- // drawChart: function (dataHeader,dataBody) {
|
|
|
|
- // var barChart = new Chart(this.$el.find('#graf_resume'), {
|
|
|
|
- // type: 'doughnut',//bar, doughnut
|
|
|
|
- // data: {
|
|
|
|
- // labels: dataHeader,
|
|
|
|
- // datasets: [
|
|
|
|
- // {
|
|
|
|
- // labels: dataHeader,
|
|
|
|
- // backgroundColor: [
|
|
|
|
- // 'rgba(255, 99, 132, 0.2)',
|
|
|
|
- // 'rgba(54, 162, 235, 0.2)',
|
|
|
|
- // 'rgba(255, 206, 86, 0.2)',
|
|
|
|
- // 'rgba(75, 192, 192, 0.2)',
|
|
|
|
- // 'rgba(153, 102, 255, 0.2)',
|
|
|
|
- // ],
|
|
|
|
- // borderColor: [
|
|
|
|
- // 'rgba(255,99,132,1)',
|
|
|
|
- // 'rgba(54, 162, 235, 1)',
|
|
|
|
- // 'rgba(255, 206, 86, 1)',
|
|
|
|
- // 'rgba(75, 192, 192, 1)',
|
|
|
|
- // 'rgba(153, 102, 255, 1)',
|
|
|
|
- // ],
|
|
|
|
- // borderWidth: 1,
|
|
|
|
- // data: dataBody,
|
|
|
|
- // }
|
|
|
|
- // ]
|
|
|
|
- // },
|
|
|
|
- // options: {
|
|
|
|
- // maintainAspectRatio: false,
|
|
|
|
- // layout: {
|
|
|
|
- // padding: 30
|
|
|
|
- // }
|
|
|
|
- // },
|
|
|
|
- // });
|
|
|
|
- // },
|
|
|
|
|
|
+ // Char filter
|
|
|
|
+ // fectCharFilter: function(objetChar){
|
|
|
|
+ // var self = this;
|
|
|
|
+ // var dataBody=[];
|
|
|
|
+ // var dataHeader=[];
|
|
|
|
+ // // objetChar
|
|
|
|
+ // var canvas="<canvas id='graf_resume'></canvas>";
|
|
|
|
+ // this.$el.find('#grafico').append(canvas);
|
|
|
|
+ // _.each(objetChar,function(voucher){
|
|
|
|
+ // dataHeader.push(voucher.journal_name);
|
|
|
|
+ // dataBody.push(parseFloat(((voucher.amount.replace(".","")).replace(",","."))));
|
|
|
|
+ // });
|
|
|
|
+ // var selector ="<button type='button' class='oe_button oe_form_button oe_highlight' id='volver_btn' name='volver_btn'><span>Atras</span></button>";
|
|
|
|
+ // this.$el.find('#volver').append(selector);
|
|
|
|
+ // this.$el.find('.bootstrap-table').hide({
|
|
|
|
+ // effect: 'drop',
|
|
|
|
+ // direction: 'up',
|
|
|
|
+ // duration: 200,
|
|
|
|
+ // complete: function () {
|
|
|
|
+ // self.drawChart(dataHeader,dataBody);
|
|
|
|
+ // }
|
|
|
|
+ // });
|
|
|
|
+ // },
|
|
|
|
+ // //Chart
|
|
|
|
+ // drawChart: function (dataHeader,dataBody) {
|
|
|
|
+ // var barChart = new Chart(this.$el.find('#graf_resume'), {
|
|
|
|
+ // type: 'doughnut',//bar, doughnut
|
|
|
|
+ // data: {
|
|
|
|
+ // labels: dataHeader,
|
|
|
|
+ // datasets: [
|
|
|
|
+ // {
|
|
|
|
+ // labels: dataHeader,
|
|
|
|
+ // backgroundColor: [
|
|
|
|
+ // 'rgba(255, 99, 132, 0.2)',
|
|
|
|
+ // 'rgba(54, 162, 235, 0.2)',
|
|
|
|
+ // 'rgba(255, 206, 86, 0.2)',
|
|
|
|
+ // 'rgba(75, 192, 192, 0.2)',
|
|
|
|
+ // 'rgba(153, 102, 255, 0.2)',
|
|
|
|
+ // ],
|
|
|
|
+ // borderColor: [
|
|
|
|
+ // 'rgba(255,99,132,1)',
|
|
|
|
+ // 'rgba(54, 162, 235, 1)',
|
|
|
|
+ // 'rgba(255, 206, 86, 1)',
|
|
|
|
+ // 'rgba(75, 192, 192, 1)',
|
|
|
|
+ // 'rgba(153, 102, 255, 1)',
|
|
|
|
+ // ],
|
|
|
|
+ // borderWidth: 1,
|
|
|
|
+ // data: dataBody,
|
|
|
|
+ // }
|
|
|
|
+ // ]
|
|
|
|
+ // },
|
|
|
|
+ // options: {
|
|
|
|
+ // maintainAspectRatio: false,
|
|
|
|
+ // layout: {
|
|
|
|
+ // padding: 30
|
|
|
|
+ // }
|
|
|
|
+ // },
|
|
|
|
+ // });
|
|
|
|
+ // },
|
|
});
|
|
});
|
|
}
|
|
}
|