|
@@ -0,0 +1,582 @@
|
|
|
|
+function report_supplier_details_payment (reporting){
|
|
|
|
+ "use strict";
|
|
|
|
+
|
|
|
|
+ var model = openerp;
|
|
|
|
+
|
|
|
|
+ reporting.ReportSupplierDetailsPaymentWidget = reporting.Base.extend({
|
|
|
|
+ template: 'ReportSupplierDetailsPayment',
|
|
|
|
+ AccountVoucher: [],
|
|
|
|
+ content:[],
|
|
|
|
+ rowsData :[],
|
|
|
|
+ events:{
|
|
|
|
+ 'click #toolbar > button' : 'clickOnAction',
|
|
|
|
+ 'click #generate' : 'fetchGenerate',
|
|
|
|
+ 'click-row.bs.table #table' : 'clickAnalysisDetail',
|
|
|
|
+ 'change #current-company' : 'updateSelections',
|
|
|
|
+ 'change #current-store' : 'updateJournalSelections',
|
|
|
|
+ 'change #current-date' : 'ShowDateRange',
|
|
|
|
+ 'change #current-period': 'updatePeriodSelections',
|
|
|
|
+ },
|
|
|
|
+
|
|
|
|
+ init : function(parent){
|
|
|
|
+ this._super(parent);
|
|
|
|
+ },
|
|
|
|
+
|
|
|
|
+ start: function () {
|
|
|
|
+ var table = this.$el.find('#table');
|
|
|
|
+ table.bootstrapTable({data : self.rowsData});
|
|
|
|
+ var date = new model.eiru_reports.ReportDatePickerWidget(self);
|
|
|
|
+ date.fecthFecha();
|
|
|
|
+ this.fetchInitial();
|
|
|
|
+ },
|
|
|
|
+
|
|
|
|
+ valorNull:function(dato){
|
|
|
|
+ var valor ="";
|
|
|
|
+ if (dato){
|
|
|
|
+ valor=dato;
|
|
|
|
+ }
|
|
|
|
+ return valor;
|
|
|
|
+ },
|
|
|
|
+
|
|
|
|
+ ShowDateRange : function(){
|
|
|
|
+ var self = this;
|
|
|
|
+ var date = self.$el.find('#current-date').val();
|
|
|
|
+ if(date == 'range'){
|
|
|
|
+ self.$el.find('.datepicker').css('display','block');
|
|
|
|
+ }
|
|
|
|
+ if(date != 'range'){
|
|
|
|
+ self.$el.find('.datepicker').css('display','none');
|
|
|
|
+ }
|
|
|
|
+ },
|
|
|
|
+
|
|
|
|
+ clickAnalysisDetail: function(e, row, $element, field){
|
|
|
|
+ // if (field == 'reference'){
|
|
|
|
+ // this.do_action({
|
|
|
|
+ // name:"Factura",
|
|
|
|
+ // type: 'ir.actions.act_window',
|
|
|
|
+ // res_model: "account.invoice",
|
|
|
|
+ // views: [[false,'form']],
|
|
|
|
+ // target: 'new',
|
|
|
|
+ // domain: [['id','=', row.invoice_id]],
|
|
|
|
+ // context: {},
|
|
|
|
+ // flags: {'form': {'action_buttons': false, 'options': {'mode': 'view'}}},
|
|
|
|
+ // res_id: row.invoice_id,
|
|
|
|
+ // });
|
|
|
|
+ // }
|
|
|
|
+ // if (field === 'partner'){
|
|
|
|
+ // this.do_action({
|
|
|
|
+ // name:"Registro",
|
|
|
|
+ // type: 'ir.actions.act_window',
|
|
|
|
+ // res_model: "res.partner",
|
|
|
|
+ // views: [[false,'form']],
|
|
|
|
+ // target: 'new',
|
|
|
|
+ // domain: [['id','=', row.partner_id]],
|
|
|
|
+ // context: {},
|
|
|
|
+ // flags: {'form': {'action_buttons': false, 'options': {'mode': 'view'}}},
|
|
|
|
+ // res_id: row.partner_id,
|
|
|
|
+ // });
|
|
|
|
+ // }
|
|
|
|
+ e.stopImmediatePropagation();
|
|
|
|
+ },
|
|
|
|
+
|
|
|
|
+ fetchInitial: function () {
|
|
|
|
+ var self = this;
|
|
|
|
+ self.fetchResCompany().then(function (ResCompany) {
|
|
|
|
+ return ResCompany;
|
|
|
|
+ }).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.fetchResCurrency();
|
|
|
|
+ }).then(function(ResCurrency){
|
|
|
|
+ self.ResCurrency = ResCurrency;
|
|
|
|
+ });
|
|
|
|
+ self.$el.find('#generate').css('display','inline');
|
|
|
|
+ return;
|
|
|
|
+ },
|
|
|
|
+
|
|
|
|
+ fetchGenerate: function () {
|
|
|
|
+ var self = this;
|
|
|
|
+ self.$el.find('.search-form').block({
|
|
|
|
+ message: null,
|
|
|
|
+ overlayCSS: {
|
|
|
|
+ backgroundColor: '#FAFAFA'
|
|
|
|
+ }
|
|
|
|
+ });
|
|
|
|
+ self.$el.find('.report-form').block({
|
|
|
|
+ message: null,
|
|
|
|
+ overlayCSS: {
|
|
|
|
+ backgroundColor: '#FAFAFA'
|
|
|
|
+ }
|
|
|
|
+ });
|
|
|
|
+
|
|
|
|
+ this.fetchAccountVoucher().then(function(AccountVoucher) {
|
|
|
|
+ return AccountVoucher;
|
|
|
|
+ }).then(function (AccountVoucher){
|
|
|
|
+ self.AccountVoucher = AccountVoucher;
|
|
|
|
+ return self.fetchAccountInvoice();
|
|
|
|
+ }).then(function(AccountInvoice){
|
|
|
|
+ self.AccountInvoice = AccountInvoice;
|
|
|
|
+ return self.fetchAccountInvoiceLine();
|
|
|
|
+ }).then(function (AccountInvoiceLine){
|
|
|
|
+ self.AccountInvoiceLine = AccountInvoiceLine;
|
|
|
|
+ return self.fecthProduct(AccountInvoiceLine);
|
|
|
|
+ }).then(function(productProduct){
|
|
|
|
+ self.productProduct = productProduct;
|
|
|
|
+ return self.fetchAccountJournal();
|
|
|
|
+ }).then(function (AccountJournal) {
|
|
|
|
+ self.AccountJournal = AccountJournal;
|
|
|
|
+ return self.BuildTable();
|
|
|
|
+ });
|
|
|
|
+ },
|
|
|
|
+
|
|
|
|
+ /*====================================================================
|
|
|
|
+ RES COMPANY
|
|
|
|
+ ====================================================================*/
|
|
|
|
+ fetchResCompany: function(){
|
|
|
|
+ var self = this;
|
|
|
|
+ var defer = $.Deferred();
|
|
|
|
+ var currency = new model.web.Model('res.company');
|
|
|
|
+ var field=['id','name','currency_id','logo'];
|
|
|
|
+ currency.query(field).filter().all().then(function(results){
|
|
|
|
+ defer.resolve(results);
|
|
|
|
+ });
|
|
|
|
+ return defer;
|
|
|
|
+ },
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ fetchAccountVoucher: function () {
|
|
|
|
+ var self = this;
|
|
|
|
+ var date = self.$el.find('#current-date').val();
|
|
|
|
+ var desde = self.$el.find('#from').val();
|
|
|
|
+ var hasta = self.$el.find('#to').val();
|
|
|
|
+
|
|
|
|
+ var domain = [
|
|
|
|
+ ['state', 'in',['posted']],
|
|
|
|
+ ];
|
|
|
|
+
|
|
|
|
+ if(date && date != 9999999){
|
|
|
|
+
|
|
|
|
+ if(desde){
|
|
|
|
+ var date = desde.split('/')
|
|
|
|
+ date = (date[2]+"-"+date[1]+"-"+date[0]);
|
|
|
|
+ domain.push(['date','>=',date]);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if(hasta){
|
|
|
|
+ var date = hasta.split('/')
|
|
|
|
+ date = (date[2]+"-"+date[1]+"-"+date[0]);
|
|
|
|
+ domain.push(['date','<=',date]);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if(date == 'today'){
|
|
|
|
+ var today = moment().format('YYYY-MM-DD');
|
|
|
|
+ domain.push(['date','=',today]);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if(date == 'yesterday'){
|
|
|
|
+ var yesterday = moment().add(-1,'days').format('YYYY-MM-DD');
|
|
|
|
+ domain.push(['date','=',yesterday]);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if(date == 'currentMonth'){
|
|
|
|
+ var currentMonth = moment().format('YYYY-MM');
|
|
|
|
+ domain.push(['date','like',currentMonth]);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if(date == 'lastMonth'){
|
|
|
|
+ var lastMonth = moment().add(-1,'months').format('YYYY-MM');
|
|
|
|
+ domain.push(['date','like',lastMonth]);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ var AccountVoucher = new model.web.Model('account.voucher');
|
|
|
|
+ return AccountVoucher.call('getAccountVoucherDental',[domain], {
|
|
|
|
+ context: new model.web.CompoundContext()
|
|
|
|
+ });
|
|
|
|
+ },
|
|
|
|
+
|
|
|
|
+ fetchResPartner: function () {
|
|
|
|
+ var self = this;
|
|
|
|
+ var defer = $.Deferred();
|
|
|
|
+ var ResPartner = new model.web.Model('res.partner');
|
|
|
|
+ ResPartner.query(['id','name','ruc']).filter([['active', '=', true]]).all().then(function(results){
|
|
|
|
+ defer.resolve(results);
|
|
|
|
+ });
|
|
|
|
+ return defer;
|
|
|
|
+ },
|
|
|
|
+ fetchAccountInvoice: function () {
|
|
|
|
+ var self = this;
|
|
|
|
+ var defer = $.Deferred();
|
|
|
|
+ var domain = [
|
|
|
|
+ ['state', 'in',['paid','open']],
|
|
|
|
+ ['type', 'in', ['in_invoice','in_refund']],
|
|
|
|
+ ];
|
|
|
|
+ var AccountInvoice = new model.web.Model('account.invoice');
|
|
|
|
+ AccountInvoice.query(['id','number','type']).filter(domain).all().then(function(results){
|
|
|
|
+ defer.resolve(results);
|
|
|
|
+ });
|
|
|
|
+ return defer;
|
|
|
|
+ },
|
|
|
|
+
|
|
|
|
+ fetchAccountJournal: function () {
|
|
|
|
+ var self = this;
|
|
|
|
+ var defer = $.Deferred();
|
|
|
|
+ var AccountJournal = new model.web.Model('account.journal');
|
|
|
|
+ AccountJournal.query(['id','name']).filter([['active','=',true],['type', 'in', ['bank','cash']]]).all().then(function(results){
|
|
|
|
+ defer.resolve(results);
|
|
|
|
+ });
|
|
|
|
+ return defer;
|
|
|
|
+ },
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ fetchAccountInvoiceLine: function () {
|
|
|
|
+ var self = this;
|
|
|
|
+ var invoice_ids = _.flatten(_.map(self.AccountInvoice, function (item) {
|
|
|
|
+ return item.id;
|
|
|
|
+ }));
|
|
|
|
+ var domain = [
|
|
|
|
+ ['invoice_id','in',invoice_ids],
|
|
|
|
+ ];
|
|
|
|
+
|
|
|
|
+ var AccountInvoiceLine = new model.web.Model('account.invoice.line');
|
|
|
|
+ return AccountInvoiceLine.call('getAccountInvoiceLineDental',[domain], {
|
|
|
|
+ context: new model.web.CompoundContext()
|
|
|
|
+ });
|
|
|
|
+ },
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ /*====================================================================
|
|
|
|
+ GET RES CURRENCY BASE
|
|
|
|
+ ====================================================================*/
|
|
|
|
+ getResCurrency: function (id) {
|
|
|
|
+ var self = this;
|
|
|
|
+ return _.filter(self.ResCurrency,function (item) {
|
|
|
|
+ return item.id === id;
|
|
|
|
+ })
|
|
|
|
+ },
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ // Product Product
|
|
|
|
+ fecthProduct: function(AccountInvoiceLine){
|
|
|
|
+ var defer = $.Deferred();
|
|
|
|
+ var porductIDS = _.flatten(_.map(AccountInvoiceLine, function (item) {
|
|
|
|
+ return item.product_id[0];
|
|
|
|
+ }));
|
|
|
|
+ var ProductProdcut = new model.web.Model('product.product');
|
|
|
|
+ var fields = ['id', 'default_code', 'name_template','ean13'];
|
|
|
|
+ ProductProdcut.query(fields).filter([['id', 'in', porductIDS]]).all().then(function (results) {
|
|
|
|
+ defer.resolve(results)
|
|
|
|
+ });
|
|
|
|
+ return defer;
|
|
|
|
+ },
|
|
|
|
+
|
|
|
|
+ /*====================================================================
|
|
|
|
+ RES CURRENCY
|
|
|
|
+ ====================================================================*/
|
|
|
|
+ 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 model.web.Model('res.currency');
|
|
|
|
+ ResCurrency.query(fields).filter(domain).all().then(function(results) {
|
|
|
|
+ defer.resolve(results);
|
|
|
|
+ });
|
|
|
|
+ return defer;
|
|
|
|
+ },
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ getAccountInvoice: function (number) {
|
|
|
|
+ var self = this;
|
|
|
|
+ return _.filter(self.AccountInvoice,function (item) {
|
|
|
|
+ return item.number == number;
|
|
|
|
+ });
|
|
|
|
+ },
|
|
|
|
+
|
|
|
|
+ /*====================================================================
|
|
|
|
+ GET ACCOUNT INVOICE LINE
|
|
|
|
+ ====================================================================*/
|
|
|
|
+ getAccountInvoiceLine: function (id) {
|
|
|
|
+ var self = this;
|
|
|
|
+ return _.filter(self.AccountInvoiceLine, function(item){
|
|
|
|
+ return item.invoice_id === id;
|
|
|
|
+ });
|
|
|
|
+ },
|
|
|
|
+
|
|
|
|
+ BuildTable: function(){
|
|
|
|
+ var self = this;
|
|
|
|
+ var AccountVoucher = self.AccountVoucher;
|
|
|
|
+ var data=[];
|
|
|
|
+ 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 invoice;
|
|
|
|
+ var amount_in;
|
|
|
|
+ _.each(AccountVoucher, function(item){
|
|
|
|
+
|
|
|
|
+ var total_price = 0;
|
|
|
|
+ var total_comision = 0;
|
|
|
|
+ var tcomision = 0;
|
|
|
|
+ var total_sale = 0;
|
|
|
|
+ var product_name = "";
|
|
|
|
+ var cobrado = 0;
|
|
|
|
+ cobrado = (item.amount);
|
|
|
|
+ var AccountInvoice = self.getAccountInvoice(item.reference);
|
|
|
|
+ _.each(AccountInvoice,function(item2) {
|
|
|
|
+
|
|
|
|
+ var AccountInvoiceLine = self.getAccountInvoiceLine(item2.id);
|
|
|
|
+ _.each(AccountInvoiceLine, function(line_item){
|
|
|
|
+ if(item2.type == 'in_invoice'){
|
|
|
|
+ product_name = line_item.name + " " +line_item.name,
|
|
|
|
+ total_comision = 5;
|
|
|
|
+ // total_price = total_sale * line_item.quantity;
|
|
|
|
+ // tcomision = (total_price*total_comision)/100;
|
|
|
|
+ }
|
|
|
|
+ if(item2.type == 'in_refund'){
|
|
|
|
+ product_name = line_item.name + " " +line_item.name,
|
|
|
|
+ total_comision = 5;
|
|
|
|
+ // total_price = -(total_sale * line_item.quantity);
|
|
|
|
+ // tcomision = - ((total_price*total_comision)/100);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ });
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ if(item2.type == 'in_invoice'){
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ tcomision = (cobrado *total_comision)/100;
|
|
|
|
+ }
|
|
|
|
+ if(item2.type == 'in_refund'){
|
|
|
|
+
|
|
|
|
+ tcomision = - ((cobrado *total_comision)/100);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ data.push({
|
|
|
|
+ id : item.id,
|
|
|
|
+ reference: item.reference,
|
|
|
|
+ number: item.number,
|
|
|
|
+ seq_invoice: self.valorNull(item.seq_invoice),
|
|
|
|
+ journal: item.journal_id[1],
|
|
|
|
+ date_voucher: moment(item.date).format('YYYY-MM-DD'),
|
|
|
|
+ partner: item.partner_id[1],
|
|
|
|
+ product_name : product_name,
|
|
|
|
+ amount_in: accounting.formatMoney(cobrado,'', CurrencyBase.decimal_places, CurrencyBase.thousands_separator, CurrencyBase.decimal_separator),
|
|
|
|
+ // total_comision: accounting.formatMoney(tcomision,'', CurrencyBase.decimal_places, CurrencyBase.thousands_separator, CurrencyBase.decimal_separator),
|
|
|
|
+ date: item.date,
|
|
|
|
+ journal_id: item.journal_id[0],
|
|
|
|
+ partner_id: item.partner_id[0],
|
|
|
|
+
|
|
|
|
+ in_amount: cobrado,
|
|
|
|
+ // tcomision: tcomision,
|
|
|
|
+
|
|
|
|
+ //TOTAL FOOTER CONFIGURATION
|
|
|
|
+ decimal_places : CurrencyBase.decimal_places,
|
|
|
|
+ thousands_separator: CurrencyBase.thousands_separator,
|
|
|
|
+ decimal_separator: CurrencyBase.decimal_separator,
|
|
|
|
+ });
|
|
|
|
+
|
|
|
|
+ });
|
|
|
|
+ });
|
|
|
|
+ self.content = data;
|
|
|
|
+ this.loadTable(data);
|
|
|
|
+
|
|
|
|
+ self.$el.find('.report-form').css('display','block');
|
|
|
|
+ self.$el.find('.search-form').unblock();
|
|
|
|
+ self.$el.find('.report-form').unblock();
|
|
|
|
+ },
|
|
|
|
+
|
|
|
|
+ loadTable:function(rowsTable){
|
|
|
|
+ var self = this;
|
|
|
|
+ self.rowsData = rowsTable;
|
|
|
|
+ var table = this.$el.find('#table');
|
|
|
|
+ table.bootstrapTable('load',rowsTable);
|
|
|
|
+ },
|
|
|
|
+
|
|
|
|
+ clickOnAction: function (e) {
|
|
|
|
+ var self = this;
|
|
|
|
+ var ResCompany;
|
|
|
|
+ var action = this.$el.find(e.target).val();
|
|
|
|
+ var company = $('#current-company').val();
|
|
|
|
+ if(company && company != 9999999){
|
|
|
|
+ ResCompany = self.getResCompany(company).shift();
|
|
|
|
+ var CurrencyBase = self.getResCurrency(ResCompany.currency_id[0]).shift();
|
|
|
|
+ }else{
|
|
|
|
+ ResCompany = self.ResCompany[0];
|
|
|
|
+ var CurrencyBase = self.getResCurrency(self.ResCompany[0].currency_id[0]).shift();
|
|
|
|
+ }
|
|
|
|
+ var getColumns=[];
|
|
|
|
+ var rows=[];
|
|
|
|
+ var table = this.$el.find("#table");
|
|
|
|
+ var column = table.bootstrapTable('getVisibleColumns');
|
|
|
|
+ var row = table.bootstrapTable('getData');
|
|
|
|
+
|
|
|
|
+ var total_price = totalPriceFormatter(row);
|
|
|
|
+
|
|
|
|
+ row.push({
|
|
|
|
+ date_voucher: 'Totales',
|
|
|
|
+ total_price: total_price,
|
|
|
|
+ })
|
|
|
|
+
|
|
|
|
+ if (action === 'pdf') {
|
|
|
|
+ var data = _.map(column, function (val){ return val.field});
|
|
|
|
+ _.each(_.map(column,function(val){
|
|
|
|
+ return val}), function(item){
|
|
|
|
+ getColumns.push([{
|
|
|
|
+ title: item.title,
|
|
|
|
+ dataKey: item.field
|
|
|
|
+ }]);
|
|
|
|
+ });
|
|
|
|
+ /*
|
|
|
|
+ ============================================================
|
|
|
|
+ CONFIGURACION DEL PDF
|
|
|
|
+ ============================================================
|
|
|
|
+ */
|
|
|
|
+ var pdf_title = 'Listado de pagos por detalles';
|
|
|
|
+ var pdf_type = '';
|
|
|
|
+ var pdf_name = 'listado_pagos_detalles';
|
|
|
|
+ var pdf_columnStyles = {
|
|
|
|
+ number: {columnWidth: 17, halign:'center'},
|
|
|
|
+ date_voucher: {columnWidth: 18, halign:'center'},
|
|
|
|
+ reference : {columnWidth: 12, halign:'center'},
|
|
|
|
+ seq_invoice : {columnWidth: 12, halign:'center'},
|
|
|
|
+ partner : {columnWidth: 21, halign:'left'},
|
|
|
|
+ product_name : {columnWidth: 20, halign:'left'},
|
|
|
|
+ amount_in : {columnWidth: 18, halign:'right'},
|
|
|
|
+ };
|
|
|
|
+ /*
|
|
|
|
+ ============================================================
|
|
|
|
+ LLAMAR FUNCION DE IMPRESION
|
|
|
|
+ ============================================================
|
|
|
|
+ */
|
|
|
|
+ var filter = self.getFilter();
|
|
|
|
+ var pdf = new reporting.ReportPdfWidget(self);
|
|
|
|
+ pdf.drawPDF(
|
|
|
|
+ _.flatten(getColumns),
|
|
|
|
+ row,
|
|
|
|
+ ResCompany,
|
|
|
|
+ pdf_title,
|
|
|
|
+ pdf_type,
|
|
|
|
+ pdf_name,
|
|
|
|
+ pdf_columnStyles,
|
|
|
|
+ filter,
|
|
|
|
+ );
|
|
|
|
+ }
|
|
|
|
+ },
|
|
|
|
+
|
|
|
|
+ getFilter: function(){
|
|
|
|
+ var self = this;
|
|
|
|
+ var company = self.$el.find('#current-company').val();
|
|
|
|
+ // var store = self.$el.find('#current-store').val();
|
|
|
|
+ // var journal = self.$el.find('#current-journal').val();
|
|
|
|
+ // var period = self.$el.find('#current-period').val();
|
|
|
|
+ var date = self.$el.find('#current-date').val();
|
|
|
|
+ var desde = self.$el.find('#from').val();
|
|
|
|
+ var hasta = self.$el.find('#to').val();
|
|
|
|
+
|
|
|
|
+ var filter = [];
|
|
|
|
+
|
|
|
|
+ if(company && company){
|
|
|
|
+ var ResCompany = _.filter(self.ResCompany, function(item){
|
|
|
|
+ return item.id == company;
|
|
|
|
+ });
|
|
|
|
+ filter.push({
|
|
|
|
+ title:'Empresa',
|
|
|
|
+ value: ResCompany[0].name,
|
|
|
|
+ });
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ // if(store && store != 9999999){
|
|
|
|
+ // var ResStore = _.filter(self.ResStore,function (item) {
|
|
|
|
+ // return item.id == store;
|
|
|
|
+ // });
|
|
|
|
+ //
|
|
|
|
+ // filter.push({
|
|
|
|
+ // title: 'Sucursal',
|
|
|
|
+ // value: ResStore[0].name,
|
|
|
|
+ // });
|
|
|
|
+ //
|
|
|
|
+ // }
|
|
|
|
+
|
|
|
|
+ // if(journal && journal != 9999999){
|
|
|
|
+ // var AccountJournal = _.filter(self.AccountJournal,function (item) {
|
|
|
|
+ // return item.id == journal;
|
|
|
|
+ // });
|
|
|
|
+ // filter.push({
|
|
|
|
+ // title: 'Vendedor',
|
|
|
|
+ // value: AccountJournal[0].name,
|
|
|
|
+ // });
|
|
|
|
+ // }
|
|
|
|
+
|
|
|
|
+ // if(category && category != 9999999){
|
|
|
|
+ // var ProductCategory = _.filter(self.ProductCategory, function(item){
|
|
|
|
+ // return item.id == category;
|
|
|
|
+ // })
|
|
|
|
+ // filter.push({
|
|
|
|
+ // title: 'Categoría',
|
|
|
|
+ // value: ProductCategory[0].name,
|
|
|
|
+ // });
|
|
|
|
+ // }
|
|
|
|
+
|
|
|
|
+ // if(period && period != 9999999){
|
|
|
|
+ //
|
|
|
|
+ // var AccountPeriod = _.filter(self.AccountPeriod,function (item) {
|
|
|
|
+ // return item.id == period;
|
|
|
|
+ // });
|
|
|
|
+ // filter.push({
|
|
|
|
+ // title: 'Periodo',
|
|
|
|
+ // value: AccountPeriod[0].name,
|
|
|
|
+ // });
|
|
|
|
+ // }
|
|
|
|
+
|
|
|
|
+ if(date && date != 9999999){
|
|
|
|
+ moment.locale('es', {
|
|
|
|
+ months: 'Enero_Febrero_Marzo_Abril_Mayo_Junio_Julio_Agosto_Septiembre_Octubre_Noviembre_Diciembre'.split('_'),
|
|
|
|
+ });
|
|
|
|
+
|
|
|
|
+ if(date == 'range'){
|
|
|
|
+ filter.push({
|
|
|
|
+ title: 'Fecha',
|
|
|
|
+ value: desde +' al '+hasta,
|
|
|
|
+ });
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+ else {
|
|
|
|
+ if(date == 'today'){
|
|
|
|
+ var fecha = moment().format('DD/MM/YYYY');
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if(date == 'yesterday'){
|
|
|
|
+ var fecha = moment().add(-1,'days').format('DD/MM/YYYY');
|
|
|
|
+ }
|
|
|
|
+ if(date == 'currentMonth'){
|
|
|
|
+ var fecha = moment().format('MMMM/YYYY');
|
|
|
|
+ }
|
|
|
|
+ if(date == 'lastMonth'){
|
|
|
|
+ var fecha = moment().add(-1,'months').format('MMMM/YYYY');
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ filter.push({
|
|
|
|
+ title: 'Fecha',
|
|
|
|
+ value: fecha,
|
|
|
|
+ });
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ return filter;
|
|
|
|
+ },
|
|
|
|
+ });
|
|
|
|
+}
|