deisy 6 роки тому
батько
коміт
d96a0639fc

+ 6 - 0
models.py

@@ -63,6 +63,7 @@ class AccountInvoice(models.Model):
 				'residual_currency': invoice.residual * (invoice.company_id.currency_id.rate / invoice.currency_id.rate),
 				'amount_tax_currency': invoice.amount_tax * (invoice.company_id.currency_id.rate / invoice.currency_id.rate),
 				'amount_total_currency': invoice.amount_total * (invoice.company_id.currency_id.rate / invoice.currency_id.rate),
+				'comment' : invoice.comment,
 			})
 
 		return values
@@ -82,14 +83,19 @@ class AccountInvoiceLine(models.Model):
 		for line in AccountInvoiceLine:
 			values.append({
 				'id': line.id,
+				'name' : line.name,
 				'invoice_id':line.invoice_id.id,
 				'journal_id' : line.invoice_id.journal_id.id,
 				'product_id': {
 					'id' : line.product_id.id,
 					'name' : line.product_id.name,
 					'standard_price' : line.product_id.standard_price,
+					'default_code' : line.product_id.default_code,
+					'ean13' : line.product_id.ean13,
+					'categ_id' : line.product_id.categ_id.name,
 				},
 				'quantity' : line.quantity,
+				'price_unit' : line.price_unit,
 			})
 
 		return values


+ 99 - 0
static/src/css/custom.css

@@ -0,0 +1,99 @@
+.bootstrap-table .table > tbody > tr.groupBy {
+    cursor: pointer;
+    background: #ff0000;
+}
+
+.bootstrap-table .table > tbody > tr.groupBy.expanded {
+    background: #ff0000;
+
+}
+
+.bootstrap-table .table > tbody > tr.hidden + tr.detail-view {
+    display: none;
+      background: #ff0000;
+}
+
+.myButton{
+    background: #0288d1 !important;
+    color: white !important;
+    height: 34px !important;
+    border: 1px solid #0288d1 !important;
+    background-image: -webkit-linear-gradient(top, #0288d1, #084B8A) !important;
+}
+.myButton{
+    background: #d9534f !important;
+    /* background: #d9534f !important; */
+    /* color: #37474f !important; */
+    color: #fff !important;
+    height: 34px !important;
+    /* border: 1px solid #bdbdbd !important; */
+    /* border: 1px solid #428bca !important; */
+    border: none !important;
+}
+
+.dropdown-menu > li > a {
+    color: #37474f !important;
+}
+
+.dropdown-menu > .active > a {
+    color:#fff !important;
+    background-color: #d9534f !important;
+}
+
+.detail-icon {
+    color: #e57373 !important;
+}
+
+.pagination > .active > a{
+    color:#fff !important;
+    background-color: #d9534f !important;
+    border-color: #d9534f !important;
+}
+
+.filter-style {
+    padding-top: 10px;
+}
+
+.sale-button {
+    color: #fff !important;
+    background: #81c784;
+    border-color: #81c784;
+}
+.sale-button:hover{
+    color: #fff !important;
+    background: #81c784;
+    border-color: #81c784;
+}
+
+.purchase-button {
+    color: #fff !important;
+    background: #ffb74d;
+    border-color: #ffb74d;
+}
+.purchase-button:hover{
+    color: #fff !important;
+    background: #ffb74d;
+    border-color: #ffb74d;
+}
+
+.expense-button {
+    color: #fff !important;
+    background: #e57373;
+    border-color: #e57373;
+}
+.expense-button:hover{
+    color: #fff !important;
+    background: #e57373;
+    border-color: #e57373;
+}
+
+.balance-button {
+    color: #fff !important;
+    background: #0288d1;
+    border-color: #0288d1;
+}
+.balance-button:hover{
+    color: #fff !important;
+    background: #0288d1;
+    border-color: #0288d1;
+}

+ 196 - 0
static/src/js/group_by.js

@@ -0,0 +1,196 @@
+!function($) {
+  window.handler = new Handler();
+
+  function Handler(){
+    'use strict';
+
+    var initBodyCaller;
+    var  tableGroups = [];
+
+
+
+    // it only does '%s', and return '' when arguments are undefined
+    var sprintf = function (str) {
+        var args = arguments,
+            flag = true,
+            i = 1;
+
+        str = str.replace(/%s/g, function () {
+            var arg = args[i++];
+
+            if (typeof arg === 'undefined') {
+                flag = false;
+                return '';
+            }
+            return arg;
+        });
+        return flag ? str : '';
+    };
+
+    var groupBy = function (array , f) {
+		var groups = {};
+		array.forEach(function(o) {
+			var group = f(o);
+			groups[group] = groups[group] || [];
+			groups[group].push(o);
+		});
+
+		return groups;
+    };
+
+    $.extend($.fn.bootstrapTable.defaults, {
+        groupBy: false,
+        groupByField: ''
+    });
+
+    var BootstrapTable = $.fn.bootstrapTable.Constructor,
+        _initSort = BootstrapTable.prototype.initSort,
+        _initBody = BootstrapTable.prototype.initBody;
+
+
+    BootstrapTable.prototype.initSort = function () {
+        _initSort.apply(this, Array.prototype.slice.apply(arguments));
+
+        var that = this;
+
+        if ((this.options.groupBy) && (this.options.groupByField !== '')) {
+
+            if ((this.options.sortName != this.options.groupByField)) {
+            	this.data.sort(function(a, b) {
+                    return a[that.options.groupByField].localeCompare(b[that.options.groupByField]);
+                });
+            }
+
+            var that = this;
+            var groups = groupBy(that.data, function (item) {
+                return [item[that.options.groupByField]];
+            });
+
+            var index = 0;
+            var count;
+
+
+            $.each(groups, function(key, value) {
+                tableGroups.push({
+                    id: index,
+                    name: key
+                });
+
+
+                value.forEach(function(item) {
+                    if (!item._data) {
+                        item._data = {};
+                    }
+
+                    item._data['parent-index'] = index;
+                });
+
+                index++;
+            });
+
+
+      }
+    }
+
+    BootstrapTable.prototype.initBody = function () {
+        initBodyCaller = true;
+        _initBody.apply(this, Array.prototype.slice.apply(arguments));
+
+        if ((this.options.groupBy) && (this.options.groupByField !== '')) {
+            var that = this,
+                checkBox = false,
+                visibleColumns = 0;
+
+            this.columns.forEach(function(column) {
+                if (column.checkbox) {
+                	checkBox = true;
+                } else {
+                    if (column.visible) {
+                        visibleColumns++;
+                    }
+                }
+            });
+
+
+        	tableGroups.forEach(function(item){
+                var html = [];
+
+                html.push(sprintf('<tr class="info groupBy" data-group-index="%s">', item.id));
+
+
+                html.push('<td style="font-weight: bold; text-align: center;"',
+                	sprintf(' colspan="%s"', visibleColumns),
+                    '>', item.name, '</td>'
+                );
+
+                html.push('</tr>');
+
+                that.$body.find('tr[data-parent-index='+item.id+']:first').before($(html.join('')));
+            });
+
+
+            this.$body.find('[name="btSelectGroup"]').each(function() {
+                var self = $(this);
+            });
+
+            this.$container.off('click', '.groupBy')
+                .on('click', '.groupBy', function() {
+                    $(this).toggleClass('expanded');
+                	that.$body.find('tr[data-parent-index='+$(this).closest('tr').data('group-index')+']').toggleClass('hidden');
+                });
+
+            this.$container.off('click', '[name="btSelectGroup"]')
+                .on('click', '[name="btSelectGroup"]', function (event) {
+                	event.stopImmediatePropagation();
+
+                	var self = $(this);
+                    var checked = self.prop('checked');
+                    that[checked ? 'checkGroup' : 'uncheckGroup']($(this).closest('tr').data('group-index'));
+                });
+        }
+
+        initBodyCaller = false;
+        this.updateSelected();
+    };
+
+    BootstrapTable.prototype.getGroupSelections = function (index) {
+        var that = this;
+
+        return $.grep(this.data, function (row) {
+            return (row[that.header.stateField] && (row._data['parent-index'] === index));
+        });
+    };
+
+    BootstrapTable.prototype.checkGroup = function (index) {
+        this.checkGroup_(index, true);
+    };
+
+    BootstrapTable.prototype.uncheckGroup = function (index) {
+        this.checkGroup_(index, false);
+    };
+
+    BootstrapTable.prototype.checkGroup_ = function (index, checked) {
+        var rows;
+        var filter = function() {
+            return ($(this).closest('tr').data('parent-index') === index);
+        };
+
+        if (!checked) {
+            rows = this.getGroupSelections(index);
+        }
+
+        this.$selectItem.filter(filter).prop('checked', checked);
+
+
+        this.updateRows();
+
+        if (checked) {
+            rows = this.getGroupSelections(index);
+        }
+        this.trigger(checked ? 'check-all' : 'uncheck-all', rows);
+    };
+  }
+
+
+
+}(jQuery);

+ 11 - 0
static/src/js/main.js

@@ -6,10 +6,13 @@ openerp.eiru_reports_g6= function (instance) {
     reporting_base(instance,reporting);
 
     try {
+        group_by_pdf(reporting);
         report_seller(reporting);
         report_type_income(reporting);
         report_receipt_dental(reporting);
         report_expenses_dental(reporting);
+        report_sale_dental(reporting);
+        report_account_state(reporting);
     } catch (e) {
         // ignorar error
     }
@@ -30,5 +33,13 @@ openerp.eiru_reports_g6= function (instance) {
 
     instance.web.client_actions.add('eiru_reports_g6.expenses_dental_action', 'instance.eiru_reports_g6.ReportExpensesDentalWidget');
 
+    // Rendicion de venta por vendedor
+
+    instance.web.client_actions.add('eiru_reports_g6.sale_dental_action', 'instance.eiru_reports_g6.ReportSaleDentalWidget');
+
+    // Estado de cuenta por vendedor por cliente
+
+    instance.web.client_actions.add('eiru_reports_g6.account_state_dental_action', 'instance.eiru_reports_g6.ReportAccountStateWidget');
+
 
 }

+ 148 - 0
static/src/js/pdf.js

@@ -0,0 +1,148 @@
+function group_by_pdf(reporting) {
+    "use strict";
+
+    var model = openerp;
+
+    reporting.ReportPdfWidget = reporting.Base.extend({
+      drawPDF: function (getColumns,row,ResCompany,pdf_title,pdf_type,pdf_name,pdf_columnStyles,filter) {
+      var self = this;
+      var base64Img = 'data:image/png;base64,' + ResCompany.logo;
+      var hoy = moment().format('DD/MM/YYYY');
+      var totalPagesExp = "{total_pages_count_string}";
+      var pdfDoc = new jsPDF(pdf_type);
+      var y_position = 27;
+      var y_position2 = 27;
+
+      //LOGO
+      pdfDoc.addImage(base64Img, 'png', 7, 2, 0, 15);
+
+      //FECHA
+      pdfDoc.setFontSize(13);
+      pdfDoc.setFontStyle('normal');
+      pdfDoc.setTextColor(40)
+      pdfDoc.text(pdfDoc.internal.pageSize.getWidth() - 35, 12,hoy);
+
+      //TITULO
+      pdfDoc.setFontSize(15);
+      pdfDoc.setFontStyle('bold');
+      pdfDoc.setTextColor('#0288d1');
+      pdfDoc.autoTableText(pdf_title, pdfDoc.internal.pageSize.getWidth() - 12, 18, {
+        halign: 'right',
+        valign: 'middle'
+      });
+      pdfDoc.setLineWidth(0.5);
+      pdfDoc.setDrawColor('#424242');
+      pdfDoc.line(10, 22, pdfDoc.internal.pageSize.getWidth() - 10 , 22);
+
+      var i=0;
+      if(pdf_type == 'l'){
+        var col1_title = 15;
+        var col1_value = 55;
+        var col2_title = 150;
+        var col2_value = 190;
+      }
+      else{
+        var col1_title = 10;
+        var col1_value = 50;
+        var col2_title = 110;
+        var col2_value = 150;
+      }
+      if(filter.length >0){
+        _.each(filter,function(item){
+          if(i<4){
+            self.addFilter(pdfDoc,item.title,item.value,col1_title,col1_value,y_position);
+            y_position = y_position + 5;
+          }else{
+            self.addFilter(pdfDoc,item.title,item.value,col2_title,col2_value,y_position2);
+            y_position2 = y_position2 + 5;
+          }
+            i++;
+        });
+        pdfDoc.setLineWidth(0.5);
+        pdfDoc.setDrawColor('#424242');
+
+        if(y_position >= y_position2){
+          y_position = y_position;
+          pdfDoc.line(10, y_position, pdfDoc.internal.pageSize.getWidth() - 10 , y_position);
+        }else{
+          y_position = y_position2;
+          pdfDoc.line(10, y_position2, pdfDoc.internal.pageSize.getWidth() - 10 , y_position2);
+        }
+      }
+
+
+      pdfDoc.autoTable(getColumns, row, {
+          showHeader: 'firstPage',
+          startY: y_position + 5,
+          theme: 'grid',
+          styles: {
+              overflow: 'linebreak',
+              columnWidth: 'auto',
+              fontSize: 7,
+          },
+          headerStyles: {
+              fillColor: [76, 133, 248],
+              fontSize: 8
+          },
+          columnStyles: pdf_columnStyles,
+          margin: { horizontal: 7},
+
+          drawCell: function(cell, opts) {
+              var rows = opts.table.rows;
+              if (opts.row.index == rows.length - 1) {
+                pdfDoc.setFontStyle('bold');
+              }
+              if(opts.row.raw.key == 'categoria'){
+                pdfDoc.setFontStyle('bold');
+                pdfDoc.setFillColor(204, 204, 204);
+              }
+          },
+
+          addPageContent: function (data) {
+
+          //FOOTER
+              var str = "Página " + data.pageCount;
+              if (typeof pdfDoc.putTotalPages === 'function') {
+                  str = str + " de " + totalPagesExp;
+              }
+              pdfDoc.setFontSize(9);
+              pdfDoc.setFontStyle('bold');
+              pdfDoc.setTextColor(40);
+              var pageHeight = pdfDoc.internal.pageSize.height || pdfDoc.internal.pageSize.getHeight();
+              pdfDoc.autoTableText(str, pdfDoc.internal.pageSize.getWidth() - 35, pageHeight - 5, {
+                halign: 'rigth',
+                valign: 'middle'
+              });
+          }
+      });
+      if (typeof pdfDoc.putTotalPages === 'function') {
+          pdfDoc.putTotalPages(totalPagesExp);
+      }
+      row.pop();
+      if(model.printer_bridge){
+          var data = pdfDoc.output('datauristring');
+          model.printer_bridge.print(data);
+          return;
+      }
+      pdfDoc.save(pdf_name + hoy + '.pdf');
+    },
+
+    addFilter: function(pdfDoc,title,value,x_position_title,x_position_value,y_position){
+      pdfDoc.setFontSize(10);
+      pdfDoc.setTextColor('#424242');
+      pdfDoc.setFontStyle('bold');
+      pdfDoc.autoTableText(title+':', x_position_title, y_position, {
+        halign: 'left',
+        valign: 'middle'
+      });
+      pdfDoc.setFontSize(10);
+      pdfDoc.setTextColor('#424242');
+      pdfDoc.setFontStyle('normal');
+      pdfDoc.autoTableText(value, x_position_value, y_position, {
+        halign: 'left',
+        valign: 'middle'
+      });
+    },
+        //end test
+    });
+}

+ 685 - 0
static/src/js/reports/report_account_state.js

@@ -0,0 +1,685 @@
+function report_account_state(reporting){
+    "use strict";
+
+    var model = openerp;
+
+    reporting.ReportAccountStateWidget = reporting.Base.extend({
+        template: 'ReportAccountState',
+        rowsData :[],
+        content :[],
+
+        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',
+        },
+
+        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 == 'partner_name'){
+                this.do_action({
+                    name:"Cliente",
+                    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,
+                });
+            }
+
+            if (field == 'invoice_name'){
+                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,
+                });
+            }
+            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.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;
+                if(AccountJournal.length > 0){
+                    self.$el.find('#current-journal').append('<option value="9999999">Todos los vendedores</option>');
+                    _.each(AccountJournal,function(item){
+                        self.$el.find('#current-journal').append('<option value="' + item.id + '">' + item.name + '</option>');
+                    });
+                }else{
+                    self.$el.find('.journal').css('display','none');
+                }
+                return self.fetchAccountPeriod();
+            }).then(function(AccountPeriod){
+                self.AccountPeriod = AccountPeriod;
+                self.$el.find('#current-period').append('<option value="9999999">Todos los periodos</option>');
+                _.each(AccountPeriod,function(item){
+                    self.$el.find('#current-period').append('<option value="' +  item.id + '">' + item.name + '</option>');
+                });
+                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.fetchAccountJournal().then(function(AccountJournal) {
+                return AccountJournal;
+            }).then(function (AccountJournal){
+                self.AccountJournal = AccountJournal;
+                return self.fetchAccountInvoice();
+            }).then(function (AccountInvoice){
+                self.AccountInvoice = AccountInvoice;
+                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;
+        },
+
+
+        /*====================================================================
+            RES STORE
+        ====================================================================*/
+        fetchResStore: function(){
+            var self = this;
+            var defer = $.Deferred();
+            var field = ['id','name','company_id'];
+            var ResStore = new model.web.Model('res.store');
+            ResStore.query(field).all().then(function(results){
+                defer.resolve(results);
+            });
+            return defer;
+        },
+
+        /*====================================================================
+            ACCOUNT JOURNAL
+        ====================================================================*/
+        fetchAccountJournal: function(){
+            var self = this;
+            var journal = self.$el.find('#current-journal').val();
+            var domain = [['active','=',true],['type','=','sale']];
+            if(journal && journal != 9999999){
+                domain.push(['id','=',parseInt(journal)]);
+            }
+            var AccountJournal = new model.web.Model('account.journal');
+            return AccountJournal.call('getAccountJournal',[domain], {
+                context: new model.web.CompoundContext()
+            });
+        },
+
+        /*=====================================================================
+            ACCOUNT PERIOD
+        =====================================================================*/
+        fetchAccountPeriod: function () {
+            var self = this;
+            var defer = $.Deferred();
+            var domain = [['special','=',false]];
+            var field =['id', 'name', 'date_start','date_stop','company_id'];
+            var AccountPeriod = new model.web.Model('account.period');
+            AccountPeriod.query(field).filter(domain).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;
+        },
+
+        /*====================================================================
+            ACCOUNT INVOICE
+        ====================================================================*/
+        fetchAccountInvoice: function () {
+            var self = this;
+            var store = self.$el.find('#current-store').val();
+            var state = self.$el.find('#current-state').val();
+            var period = self.$el.find('#current-period').val();
+            var company = self.$el.find('#current-company').val();
+            var date = self.$el.find('#current-date').val();
+            var desde = self.$el.find('#from').val();
+            var hasta = self.$el.find('#to').val();
+
+            if(store && store != 9999999){
+                var journal_ids = _.map(_.filter(self.AccountJournal,function (item) {
+                    return item.store_ids == store;
+                }), function(map){
+                    return map.id;
+                });
+            }else{
+                var journal_ids = _.flatten(_.map(self.AccountJournal, function (item) {
+                    return item.id;
+                }));
+            }
+
+            var domain = [
+                ['state','in',['open','paid']],
+                ['type', '=', 'out_invoice'],
+                ['journal_id','in',journal_ids],
+            ];
+
+            if(company && company != 9999999){
+                domain.push(['company_id','=',parseInt(company)]);
+            }
+
+            if(period && period != 9999999){
+                domain.push(['period_id','=',parseInt(period)]);
+            }
+
+            if(state && state != 9999999){
+                domain.push(['state','=',state]);
+            }
+
+
+            if(date && date != 9999999){
+
+                if(desde){
+                    var date = desde.split('/')
+                    date = (date[2]+"-"+date[1]+"-"+date[0]);
+                    domain.push(['date_invoice','>=',date]);
+                }
+
+                if(hasta){
+                    var date = hasta.split('/')
+                    date = (date[2]+"-"+date[1]+"-"+date[0]);
+                    domain.push(['date_invoice','<=',date]);
+                }
+
+                if(date == 'today'){
+                    var today = moment().format('YYYY-MM-DD');
+                    domain.push(['date_invoice','=',today]);
+                }
+
+                if(date == 'yesterday'){
+                    var yesterday = moment().add(-1,'days').format('YYYY-MM-DD');
+                    domain.push(['date_invoice','=',yesterday]);
+                }
+
+                if(date == 'currentMonth'){
+                    var currentMonth = moment().format('YYYY-MM');
+                    domain.push(['date_invoice','like',currentMonth]);
+                }
+
+                if(date == 'lastMonth'){
+                    var lastMonth = moment().add(-1,'months').format('YYYY-MM');
+                    domain.push(['date_invoice','like',lastMonth]);
+                }
+            }
+
+            var AccountInvoice = new model.web.Model('account.invoice');
+            return AccountInvoice.call('getAccountInvoiceDental',[domain], {
+                context: new model.web.CompoundContext()
+            });
+        },
+
+        /*====================================================================
+            UPDATE SELECTIONS
+        ====================================================================*/
+        updateSelections: function () {
+            var self = this;
+            var company = self.$el.find('#current-company').val();
+            if(company != 9999999){
+                /*===================
+                    STORE SELECTION
+                ===================*/
+                var store = self.$el.find('#current-store').empty();
+                self.$el.find('#current-store').append('<option value="9999999">Todas las sucursellers</option>');
+                _.each(self.ResStore,function(item){
+                    if(parseFloat(company) == item.company_id[0]){
+                        self.$el.find('#current-store').append('<option value="' + item.id + '">' + item.name + '</option>');
+                    }
+                });
+                /*====================
+                    PERIOD SELECTION
+                ====================*/
+                var period = self.$el.find('#current-period').empty();
+                self.$el.find('#current-period').append('<option value="9999999">Todos los periodos</option>');
+                _.each(self.AccountPeriod,function(item){
+                    if(parseFloat(company) == item.company_id[0]){
+                        self.$el.find('#current-period').append('<option value="' + item.id + '">' + item.name + '</option>');
+                    }
+                });
+            }else{
+                /*===================
+                    STORE SELECTION
+                ===================*/
+                var store = self.$el.find('#current-store').empty();
+                self.$el.find('#current-store').append('<option value="9999999">Todas las sucursellers</option>');
+                _.each(self.ResStore,function(item){
+                    self.$el.find('#current-store').append('<option value="' + item.id + '">' + item.name + '</option>');
+                });
+                /*====================
+                    PERIOD SELECTION
+                ====================*/
+                var period = self.$el.find('#current-period').empty();
+                self.$el.find('#current-period').append('<option value="9999999">Todas los periodos</option>');
+                _.each(self.AccountPeriod,function(item){
+                    self.$el.find('#current-period').append('<option value="' + item.id + '">' + item.name + '</option>');
+                });
+            }
+        },
+
+        updateJournalSelections: function () {
+            var self = this;
+            var store = self.$el.find('#current-store').val();
+            if(store != 9999999){
+                /*=============================
+                    ACCOUNT JOURNAL SELECTION
+                =============================*/
+                var journal = self.$el.find('#current-journal').empty();
+                self.$el.find('#current-journal').append('<option value="9999999">Todas las facturas</option>');
+                _.each(self.AccountJournal,function(item){
+                    if(parseFloat(store) == item.store_ids){
+                        self.$el.find('#current-journal').append('<option value="' + item.id + '">' + item.name + '</option>');
+                    }
+                });
+            }else{
+                /*=============================
+                    ACCOUNT JOURNAL SELECTION
+                =============================*/
+                var journal = self.$el.find('#current-journal').empty();
+                self.$el.find('#current-journal').append('<option value="9999999">Todas las facturas</option>');
+                _.each(self.AccountJournal,function(item){
+                    self.$el.find('#current-journal').append('<option value="' + item.id + '">' + item.name + '</option>');
+                });
+            }
+        },
+
+        /*====================================================================
+            GET RES COMPANY
+        ====================================================================*/
+        getResCompany: function (id) {
+            var self = this;
+            return _.filter(self.ResCompany,function (item) {
+                return item.id == id;
+            })
+        },
+
+        /*====================================================================
+            GET RES CURRENCY BASE
+        ====================================================================*/
+        getResCurrency: function (id) {
+            var self = this;
+            return _.filter(self.ResCurrency,function (item) {
+                return item.id === id;
+            })
+        },
+
+
+        /*====================================================================
+            GET ACCOUNT INVOICE
+        ====================================================================*/
+        getAccountInvoice: function (id) {
+          var self = this;
+          return _.filter(self.AccountInvoice,function (item) {
+            return item.journal_id[0] === id;
+          });
+        },
+
+
+        /*====================================================================
+            BUILD
+        ====================================================================*/
+        BuildTable: function(){
+          var self = this;
+          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 AccountJournal = self.AccountJournal;
+          _.each(AccountJournal,function(item) {
+
+
+            var AccountInvoice = self.getAccountInvoice(item.id);
+            _.each(AccountInvoice,function(item2) {
+              var paid = 0;
+              paid = item2.amount_total - item2.residual;
+
+              data.push({
+
+                /*=======================
+                      IDS
+                    =======================*/
+
+                id: item.id,
+                invoice_id: item2.id,
+                partner_id: item2.partner_id[0],
+
+                /*=======================
+                        DATAS
+                    =======================*/
+                seller_name: item.name,
+                date_invoice: item2.date_invoice,
+                invoice_name: item2.number,
+                partner_name: item2.partner_id[1],
+                residual : accounting.formatMoney(item2.residual,'', CurrencyBase.decimal_places, CurrencyBase.thousands_separator, CurrencyBase.decimal_separator),
+                paid : accounting.formatMoney(paid,'', CurrencyBase.decimal_places, CurrencyBase.thousands_separator, CurrencyBase.decimal_separator),
+                amount : accounting.formatMoney(item2.amount_total,'', CurrencyBase.decimal_places, CurrencyBase.thousands_separator, CurrencyBase.decimal_separator),
+
+                /*=======================
+                        VALORES SIN FORMATEAR
+                    =======================*/
+                total_residual_no_format : item2.residual,
+                total_paid_no_format : paid,
+                total_amount_no_format : item2.amount_total,
+
+                /*==============================
+                      TOTAL FOOTER CONFIGURATION
+                  ==============================*/
+                decimal_places : CurrencyBase.decimal_places,
+                thousands_separator: CurrencyBase.thousands_separator,
+                decimal_separator: CurrencyBase.decimal_separator,
+
+              });
+
+
+          });
+        });
+
+          self.content = data;
+          self.loadTable(data);
+          self.$el.find('.report-form').css('display','block');
+          self.$el.find('.search-form').unblock();
+          self.$el.find('.report-form').unblock();
+        },
+
+        /*====================================================================
+            LOAD BOOTSTRAP TABLE
+        ====================================================================*/
+        loadTable:function(rowsTable){
+            var self = this;
+            self.rowsData = rowsTable;
+            var table = this.$el.find('#table');
+            table.bootstrapTable('load', rowsTable);
+        },
+
+        /*====================================================================
+            PRINT PDF
+        ====================================================================*/
+        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 footer=[];
+            var table = this.$el.find("#table");
+            var column = table.bootstrapTable('getVisibleColumns');
+            var row = table.bootstrapTable('getData');
+
+
+            var total_amount = totalFormatter(row);
+            var total_paid = totalPaidFormatter(row);
+            var total_residual = totalResidualFormatter(row);
+
+            row.push({
+              seller_name: 'Totales',
+              amount: total_amount,
+              paid: total_paid,
+              residual: total_residual,
+            })
+
+            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 = 'Estado de cuentas de clientes por vendedores';
+                var pdf_type = '';
+                var pdf_name = 'estado_de_cuentas_de_clientes_por_vendedor_';
+                var pdf_columnStyles =  {
+                  seller_name: {columnWidth: 41, halign:'left'},
+                  date_invoice: {columnWidth: 17, halign:'center'},
+                  invoice_name: {columnWidth: 24, halign:'center'},
+                  partner_name: {columnWidth: 41, halign:'left'},
+                  residual : {columnWidth: 24, halign:'right'},
+                  paid : {columnWidth: 24, halign:'right'},
+                  amount : {columnWidth: 24, halign:'right'},
+
+                };
+                /*
+                ============================================================
+                    LLAMAR FUNCION DE IMPRESION
+                ============================================================
+                */
+                var filter = self.getFilter();
+                var pdf = new model.eiru_reports.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 state = self.$el.find('#current-state').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(state && state != 9999999){
+            filter.push({
+                title: 'Estado',
+                value:  $("#current-state option:selected").text(),
+            });
+          }
+
+          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;
+        },
+});
+}

+ 110 - 19
static/src/js/reports/report_expenses_dental.js

@@ -15,6 +15,7 @@ function report_expenses_dental(reporting){
             'change #current-company' : 'updateSelections',
             'change #current-store' : 'updateStoreSelections',
             'change #current-date' : 'ShowDateRange',
+            'change #current-period' : 'updatePeriodSelections',
         },
 
         init : function(parent){
@@ -364,6 +365,18 @@ function report_expenses_dental(reporting){
             }
         },
 
+        updatePeriodSelections: function () {
+            var self = this;
+            var period = self.$el.find('#current-period').val();
+            if(period != 9999999){
+                self.$el.find('#current-date').val(9999999);
+                self.$el.find('#current-date').prop('disabled','disabled');
+                self.$el.find('.datepicker').css('display','none');
+            }else{
+                self.$el.find('#current-date').prop('disabled',false);
+            }
+        },
+
         /*====================================================================
             GET RES COMPANY
         ====================================================================*/
@@ -479,28 +492,15 @@ function report_expenses_dental(reporting){
             var row = table.bootstrapTable('getData');
 
 
-            var amount_untaxed = _.reduce(_.map(row, function (map) {
-                return map.amount_untaxed;
-            }), function (memo, num) {
-                return memo + num;
-            });
-
-            var amount_tax = _.reduce(_.map(row, function (map) {
-                return map.amount_tax;
-            }), function (memo, num) {
-                return memo + num;
-            });
+            var amount_untaxed = totalUntaxedFormatter(row);
+            var amount_tax = totalTaxFormatter(row);
+            var total = totalFormatter(row);
 
-            var total = _.reduce(_.map(row, function (map) {
-                return map.amount;
-            }), function (memo, num) {
-                return memo + num;
-            });
             row.push({
                 partner_id : 'Totales',
-                amount_untaxed_total : accounting.formatMoney(amount_untaxed, '', CurrencyBase.decimal_places, CurrencyBase.thousands_separator, CurrencyBase.decimal_separator),
-                amount_tax_total : accounting.formatMoney(amount_tax, '', CurrencyBase.decimal_places, CurrencyBase.thousands_separator, CurrencyBase.decimal_separator),
-                amount_total : accounting.formatMoney(total, '', CurrencyBase.decimal_places, CurrencyBase.thousands_separator, CurrencyBase.decimal_separator),
+                amount_untaxed_total : amount_untaxed,
+                amount_tax_total : amount_tax,
+                amount_total : total,
             });
             if (action === 'pdf') {
                 var data = _.map(column, function (val){ return val.field});
@@ -533,6 +533,7 @@ function report_expenses_dental(reporting){
                     LLAMAR FUNCION DE IMPRESION
                 ============================================================
                 */
+                var filter = self.getFilter();
                 var pdf = new model.eiru_reports.ReportPdfWidget(self);
                 pdf.drawPDF(
                     _.flatten(getColumns),
@@ -542,8 +543,98 @@ function report_expenses_dental(reporting){
                     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 partner = self.$el.find('#current-partner').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(partner && partner != 9999999){
+            var ResPartner = _.filter(self.ResPartner, function(item){
+              return item.id == partner;
+            })
+            filter.push({
+                title: 'Gastos',
+                value:  ResPartner[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;
+        },
     });
 }

+ 231 - 41
static/src/js/reports/report_receipt_dental.js

@@ -14,6 +14,7 @@ function report_receipt_dental(reporting){
             'change #current-company' : 'updateSelections',
             'change #current-store' : 'updateJournalSelections',
             'change #current-date' : 'ShowDateRange',
+            'change #current-period': 'updatePeriodSelections',
         },
 
         init : function(parent){
@@ -300,23 +301,6 @@ function report_receipt_dental(reporting){
         },
 
 
-        /*====================================================================
-                  ACCOUNT INVOICE LINE
-              ====================================================================*/
-              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()
-                  });
-              },
-
 
         /*====================================================================
             UPDATE SELECTIONS
@@ -390,6 +374,17 @@ function report_receipt_dental(reporting){
                 });
             }
         },
+        updatePeriodSelections: function () {
+            var self = this;
+            var period = self.$el.find('#current-period').val();
+            if(period != 9999999){
+                self.$el.find('#current-date').val(9999999);
+                self.$el.find('#current-date').prop('disabled','disabled');
+                self.$el.find('.datepicker').css('display','none');
+            }else{
+                self.$el.find('#current-date').prop('disabled',false);
+            }
+        },
 
         /*====================================================================
             GET RES COMPANY
@@ -450,13 +445,13 @@ function report_receipt_dental(reporting){
           };
 
           var AccountJournal = self.AccountJournal;
+          var AccountVoucher = self.AccountVoucher;
+
           _.each(AccountJournal,function(item) {
             var total_cash = 0;
             var total_credit = 0;
             var total_amount = 0;
 
-
-            var AccountVoucher = self.AccountVoucher;
             _.each(AccountVoucher, function(item2){
 
                 var AccountInvoice = self.getAccountInvoice(item.id, item2.reference);
@@ -503,13 +498,131 @@ function report_receipt_dental(reporting){
             }
           });
 
+          data.sort(function(a, b) {
+            return b.total_amount_no_format - a.total_amount_no_format
+          });
+
           self.content = data;
           self.loadTable(data);
+          self.CallCharts(data,CurrencyBase);
+
           self.$el.find('.report-form').css('display','block');
           self.$el.find('.search-form').unblock();
           self.$el.find('.report-form').unblock();
         },
 
+        /*==============================
+              BARCHART
+          ==============================*/
+        CallCharts: function(data,CurrencyBase){
+           var self = this;
+
+           var names = _.flatten(_.map(data, function (item) {
+               return item.name;
+           }));
+
+           var cash = _.flatten(_.map(data, function (item) {
+               return item.total_cash_no_format;
+           }));
+
+           var credit = _.flatten(_.map(data, function (item) {
+               return item.total_credit_no_format;
+            }));
+
+           var total = _.flatten(_.map(data, function (item) {
+                return item.total_amount_no_format;
+             }));
+
+           var receiptCanvas = document.getElementById("reporting-chart");
+
+           Chart.defaults.global.defaultFontFamily = "Lato";
+           Chart.defaults.global.defaultFontSize = 18;
+
+           var cashData = {
+                label: 'Ingreso Contado',
+                data: cash,
+                backgroundColor: '#BCCEF4',
+                borderWidth: 0,
+            };
+
+            var creditData = {
+                label: 'Ingreso Crédito',
+                data: credit,
+                backgroundColor: '#A9E5E3',
+                borderWidth: 0,
+            };
+
+            var totalData = {
+                label: 'Ingreso Total',
+                data: total,
+                backgroundColor: '#A0D995',
+                borderWidth: 0,
+            };
+
+            var receiptData = {
+                labels: names,
+                datasets: [cashData, creditData, totalData]
+            };
+
+            var chartOptions = {
+                responsive: true,
+                responsiveAnimationDuration:10,
+                maintainAspectRatio:false,
+                scales: {
+                    yAxes: [{
+                      barPercentage: 0.5,
+                      gridLines: {
+                        display: true
+                      },
+                      ticks: {
+                        callback: function(label, index, labels) {
+                          label = accounting.formatMoney(label, '', CurrencyBase.decimal_places, CurrencyBase.thousands_separator, CurrencyBase.decimal_separator);
+                          return label;
+                        }
+                      }
+                    }],
+                    xAxes: [{
+                      gridLines: {
+                        zeroLineColor: "black",
+                        zeroLineWidth: 2
+                      },
+                      ticks: {
+                        min: 0,
+                        max: 6500,
+                        stepSize: 1300,
+                        maxRotation: 15,
+
+                      },
+                    }]
+                },
+                elements: {
+                  rectangle: {
+                    borderSkipped: 'left',
+                  }
+                },
+                tooltips: {
+                    callbacks: {
+                        label: function(tooltipItem, data) {
+                            var label = data.datasets[tooltipItem.datasetIndex].label || '';
+
+                            if (label) {
+                                label += ': ';
+                            }
+                            label += accounting.formatMoney(tooltipItem.yLabel, '', CurrencyBase.decimal_places, CurrencyBase.thousands_separator, CurrencyBase.decimal_separator);
+                            return label;
+                        }
+                    }
+                }
+            };
+
+            var barChart = new Chart(receiptCanvas, {
+              type: 'bar',
+              data: receiptData,
+              options: chartOptions
+            });
+        },
+// end barchart
+
         /*====================================================================
             LOAD BOOTSTRAP TABLE
         ====================================================================*/
@@ -541,29 +654,15 @@ function report_receipt_dental(reporting){
             var column = table.bootstrapTable('getVisibleColumns');
             var row = table.bootstrapTable('getData');
 
-            var cash_total = _.reduce(_.map(row, function (map) {
-                return map.total_cash_no_format;
-            }), function (memo, num) {
-                return memo + num;
-            });
-
-            var credit_total = _.reduce(_.map(row, function (map) {
-                return map.total_credit_no_format;
-            }), function (memo, num) {
-                return memo + num;
-            });
-
-            var total_amount = _.reduce(_.map(row, function (map) {
-                return map.total_amount_no_format;
-            }), function (memo, num) {
-                return memo + num;
-            });
+            var cash_total = totalCashFormatter(row);
+            var credit_total = totalCreditFormatter(row);
+            var total_amount = totalAmountFormatter(row);
 
             row.push({
                 name: 'Totales',
-                total_cash: accounting.formatMoney(cash_total, '', CurrencyBase.decimal_places, CurrencyBase.thousands_separator, CurrencyBase.decimal_separator),
-                total_credit: accounting.formatMoney(credit_total, '', CurrencyBase.decimal_places, CurrencyBase.thousands_separator, CurrencyBase.decimal_separator),
-                total_amount: accounting.formatMoney(total_amount, '', CurrencyBase.decimal_places, CurrencyBase.thousands_separator, CurrencyBase.decimal_separator),
+                total_cash: cash_total,
+                total_credit: credit_total,
+                total_amount: total_amount,
 
             })
 
@@ -581,9 +680,9 @@ function report_receipt_dental(reporting){
                     CONFIGURACION DEL PDF
                 ============================================================
                 */
-                var pdf_title = 'Cobro por vendedor';
+                var pdf_title = 'Ingreso por vendedores';
                 var pdf_type = '';
-                var pdf_name = 'cobro_por_vendedor_';
+                var pdf_name = 'ingreso_por_vendedores_';
                 var pdf_columnStyles =  {
                   name : {columnWidth: '25%', halign:'left'},
                   total_cash : {columnWidth: '25%', halign:'right'},
@@ -595,6 +694,7 @@ function report_receipt_dental(reporting){
                     LLAMAR FUNCION DE IMPRESION
                 ============================================================
                 */
+                var filter = self.getFilter();
                 var pdf = new model.eiru_reports.ReportPdfWidget(self);
                 pdf.drawPDF(
                     _.flatten(getColumns),
@@ -604,8 +704,98 @@ function report_receipt_dental(reporting){
                     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(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;
+        },
     });
 }

+ 827 - 0
static/src/js/reports/report_sale_dental.js

@@ -0,0 +1,827 @@
+function report_sale_dental(reporting){
+    "use strict";
+
+    var model = openerp;
+
+    reporting.ReportSaleDentalWidget = reporting.Base.extend({
+        template: 'ReportSaleDental',
+        rowsData :[],
+        content :[],
+
+        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 == 'product_name'){
+                this.do_action({
+                    name:"Producto",
+                    type: 'ir.actions.act_window',
+                    res_model: "product.product",
+                    views: [[false,'form']],
+                    target: 'new',
+                    domain: [['id','=', row.product_id]],
+                    context: {},
+                    flags: {'form': {'action_buttons': false, 'options': {'mode': 'view'}}},
+                    res_id: row.product_id,
+                });
+            }
+
+            if (field == 'invoice_name'){
+                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,
+                });
+            }
+            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.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;
+                if(AccountJournal.length > 0){
+                    self.$el.find('#current-journal').append('<option value="9999999">Todos los vendedores</option>');
+                    _.each(AccountJournal,function(item){
+                        self.$el.find('#current-journal').append('<option value="' + item.id + '">' + item.name + '</option>');
+                    });
+                }else{
+                    self.$el.find('.journal').css('display','none');
+                }
+                return self.fetchAccountPeriod();
+            }).then(function(AccountPeriod){
+                self.AccountPeriod = AccountPeriod;
+                self.$el.find('#current-period').append('<option value="9999999">Todos los periodos</option>');
+                _.each(AccountPeriod,function(item){
+                    self.$el.find('#current-period').append('<option value="' +  item.id + '">' + item.name + '</option>');
+                });
+                return self.fetchProductCategory();
+          }).then(function(ProductCategory){
+              self.ProductCategory = ProductCategory;
+              if(ProductCategory.length > 1){
+                  self.$el.find('#current-category').append('<option value="9999999">Todas las categorias</option>');
+                  _.each(ProductCategory,function(item){
+                      self.$el.find('#current-category').append('<option value="' + item.id + '">' + item.name + '</option>');
+                  });
+              }else{
+                  self.$el.find('.category').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.fetchAccountInvoice().then(function(AccountInvoice) {
+                return AccountInvoice;
+            }).then(function (AccountInvoice){
+                self.AccountInvoice = AccountInvoice;
+                return self.fetchAccountInvoiceLine();
+            }).then(function (AccountInvoiceLine){
+                self.AccountInvoiceLine = AccountInvoiceLine;
+                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;
+        },
+
+        /*====================================================================
+            RES STORE
+        ====================================================================*/
+        fetchResStore: function(){
+            var self = this;
+            var defer = $.Deferred();
+            var field = ['id','name','company_id'];
+            var ResStore = new model.web.Model('res.store');
+            ResStore.query(field).all().then(function(results){
+                defer.resolve(results);
+            });
+            return defer;
+        },
+
+        /*====================================================================
+            ACCOUNT JOURNAL
+        ====================================================================*/
+        fetchAccountJournal: function(){
+            var self = this;
+            var domain = [['active','=',true],['type','=','sale']];
+            var AccountJournal = new model.web.Model('account.journal');
+            return AccountJournal.call('getAccountJournal',[domain], {
+                context: new model.web.CompoundContext()
+            });
+        },
+
+        /*=====================================================================
+            ACCOUNT PERIOD
+        =====================================================================*/
+        fetchAccountPeriod: function () {
+            var self = this;
+            var defer = $.Deferred();
+            var domain = [['special','=',false]];
+            var field =['id', 'name', 'date_start','date_stop','company_id'];
+            var AccountPeriod = new model.web.Model('account.period');
+            AccountPeriod.query(field).filter(domain).all().then(function (results) {
+                defer.resolve(results);
+            });
+            return defer;
+        },
+
+        /*====================================================================
+        PRODUCT CATEGORY
+    ====================================================================*/
+    fetchProductCategory: function () {
+        var self = this;
+        var domain = [];
+        var ProductCategory = new model.web.Model('product.category');
+        return ProductCategory.call('getProductCategory',[domain], {
+            context: new model.web.CompoundContext()
+        });
+    },
+
+
+        /*====================================================================
+            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;
+        },
+
+        /*====================================================================
+            ACCOUNT INVOICE
+        ====================================================================*/
+        fetchAccountInvoice: function () {
+            var self = this;
+            var store = self.$el.find('#current-store').val();
+            var period = self.$el.find('#current-period').val();
+            var company = self.$el.find('#current-company').val();
+            var journal = self.$el.find('#current-journal').val();
+            var date = self.$el.find('#current-date').val();
+            var desde = self.$el.find('#from').val();
+            var hasta = self.$el.find('#to').val();
+
+            if(store && store != 9999999){
+                var journal_ids = _.map(_.filter(self.AccountJournal,function (item) {
+                    return item.store_ids == store;
+                }), function(map){
+                    return map.id;
+                });
+            }else{
+                var journal_ids = _.flatten(_.map(self.AccountJournal, function (item) {
+                    return item.id;
+                }));
+            }
+
+            var domain = [
+                ['state', 'in',['open','paid']],
+                ['type', '=', 'out_invoice'],
+                ['journal_id','in',journal_ids],
+            ];
+
+            if(journal && journal != 9999999){
+                domain.push(['journal_id','=',parseInt(journal)]);
+            }
+
+            if(company && company != 9999999){
+                domain.push(['company_id','=',parseInt(company)]);
+            }
+
+            if(period && period != 9999999){
+                domain.push(['period_id','=',parseInt(period)]);
+            }
+
+            if(date && date != 9999999){
+
+                if(desde){
+                    var date = desde.split('/')
+                    date = (date[2]+"-"+date[1]+"-"+date[0]);
+                    domain.push(['date_invoice','>=',date]);
+                }
+
+                if(hasta){
+                    var date = hasta.split('/')
+                    date = (date[2]+"-"+date[1]+"-"+date[0]);
+                    domain.push(['date_invoice','<=',date]);
+                }
+
+                if(date == 'today'){
+                    var today = moment().format('YYYY-MM-DD');
+                    domain.push(['date_invoice','=',today]);
+                }
+
+                if(date == 'yesterday'){
+                    var yesterday = moment().add(-1,'days').format('YYYY-MM-DD');
+                    domain.push(['date_invoice','=',yesterday]);
+                }
+
+                if(date == 'currentMonth'){
+                    var currentMonth = moment().format('YYYY-MM');
+                    domain.push(['date_invoice','like',currentMonth]);
+                }
+
+                if(date == 'lastMonth'){
+                    var lastMonth = moment().add(-1,'months').format('YYYY-MM');
+                    domain.push(['date_invoice','like',lastMonth]);
+                }
+            }
+
+            var AccountInvoice = new model.web.Model('account.invoice');
+            return AccountInvoice.call('getAccountInvoiceDental',[domain], {
+                context: new model.web.CompoundContext()
+            });
+        },
+
+
+        /*====================================================================
+                  ACCOUNT INVOICE LINE
+              ====================================================================*/
+              fetchAccountInvoiceLine: function () {
+                  var self = this;
+                  var categ_ids = [];
+                  var category = self.$el.find('#current-category').val();
+                  var invoice_ids = _.flatten(_.map(self.AccountInvoice, function (item) {
+                      return item.id;
+                  }));
+                  var domain = [
+                      ['invoice_id','in',invoice_ids],
+                  ];
+
+                  if(category){
+                      var category_ids = _.map(_.filter(self.ProductCategory,function (item) {
+                          return item.id == category;
+                      }), function(map){
+                          return map.id;
+                      });
+
+
+                      categ_ids =  _.map(_.filter(self.ProductCategory,function (item) {
+                          return _.contains(category_ids, item.parent_id[0]) || item.id == category;
+                      }), function(map){
+                          return map.id;
+                      });
+                  };
+
+                  if(category && category != 9999999){
+                      domain.push(['product_id.categ_id','in',categ_ids]);
+                  }
+
+                  var AccountInvoiceLine = new model.web.Model('account.invoice.line');
+                  return AccountInvoiceLine.call('getAccountInvoiceLineDental',[domain], {
+                      context: new model.web.CompoundContext()
+                  });
+              },
+
+
+        /*====================================================================
+            UPDATE SELECTIONS
+        ====================================================================*/
+        updateSelections: function () {
+            var self = this;
+            var company = self.$el.find('#current-company').val();
+            if(company != 9999999){
+                /*===================
+                    STORE SELECTION
+                ===================*/
+                var store = self.$el.find('#current-store').empty();
+                self.$el.find('#current-store').append('<option value="9999999">Todas las sucursellers</option>');
+                _.each(self.ResStore,function(item){
+                    if(parseFloat(company) == item.company_id[0]){
+                        self.$el.find('#current-store').append('<option value="' + item.id + '">' + item.name + '</option>');
+                    }
+                });
+                /*====================
+                    PERIOD SELECTION
+                ====================*/
+                var period = self.$el.find('#current-period').empty();
+                self.$el.find('#current-period').append('<option value="9999999">Todos los periodos</option>');
+                _.each(self.AccountPeriod,function(item){
+                    if(parseFloat(company) == item.company_id[0]){
+                        self.$el.find('#current-period').append('<option value="' + item.id + '">' + item.name + '</option>');
+                    }
+                });
+            }else{
+                /*===================
+                    STORE SELECTION
+                ===================*/
+                var store = self.$el.find('#current-store').empty();
+                self.$el.find('#current-store').append('<option value="9999999">Todas las sucursellers</option>');
+                _.each(self.ResStore,function(item){
+                    self.$el.find('#current-store').append('<option value="' + item.id + '">' + item.name + '</option>');
+                });
+                /*====================
+                    PERIOD SELECTION
+                ====================*/
+                var period = self.$el.find('#current-period').empty();
+                self.$el.find('#current-period').append('<option value="9999999">Todas los periodos</option>');
+                _.each(self.AccountPeriod,function(item){
+                    self.$el.find('#current-period').append('<option value="' + item.id + '">' + item.name + '</option>');
+                });
+            }
+        },
+
+        updateJournalSelections: function () {
+            var self = this;
+            var store = self.$el.find('#current-store').val();
+            if(store != 9999999){
+                /*=============================
+                    ACCOUNT JOURNAL SELECTION
+                =============================*/
+                var journal = self.$el.find('#current-journal').empty();
+                self.$el.find('#current-journal').append('<option value="9999999">Todas las facturas</option>');
+                _.each(self.AccountJournal,function(item){
+                    if(parseFloat(store) == item.store_ids){
+                        self.$el.find('#current-journal').append('<option value="' + item.id + '">' + item.name + '</option>');
+                    }
+                });
+            }else{
+                /*=============================
+                    ACCOUNT JOURNAL SELECTION
+                =============================*/
+                var journal = self.$el.find('#current-journal').empty();
+                self.$el.find('#current-journal').append('<option value="9999999">Todas las facturas</option>');
+                _.each(self.AccountJournal,function(item){
+                    self.$el.find('#current-journal').append('<option value="' + item.id + '">' + item.name + '</option>');
+                });
+            }
+        },
+
+        updatePeriodSelections: function () {
+            var self = this;
+            var period = self.$el.find('#current-period').val();
+            if(period != 9999999){
+                self.$el.find('#current-date').val(9999999);
+                self.$el.find('#current-date').prop('disabled','disabled');
+                self.$el.find('.datepicker').css('display','none');
+            }else{
+                self.$el.find('#current-date').prop('disabled',false);
+            }
+        },
+
+        /*====================================================================
+            GET RES COMPANY
+        ====================================================================*/
+        getResCompany: function (id) {
+            var self = this;
+            return _.filter(self.ResCompany,function (item) {
+                return item.id == id;
+            })
+        },
+
+        /*====================================================================
+            GET RES CURRENCY BASE
+        ====================================================================*/
+        getResCurrency: function (id) {
+            var self = this;
+            return _.filter(self.ResCurrency,function (item) {
+                return item.id === id;
+            })
+        },
+
+
+        /*====================================================================
+            GET ACCOUNT INVOICE
+        ====================================================================*/
+        getAccountInvoice: function (id) {
+          var self = this;
+          return _.filter(self.AccountInvoice,function (item) {
+            return item.journal_id[0] === id;
+          });
+        },
+
+      /*====================================================================
+           GET ACCOUNT INVOICE LINE
+       ====================================================================*/
+       getAccountInvoiceLine: function (id) {
+         var self = this;
+         return _.filter(self.AccountInvoiceLine, function(item){
+             return item.invoice_id === id;
+         });
+       },
+
+        /*====================================================================
+            BUILD
+        ====================================================================*/
+        BuildTable: function(){
+          var self = this;
+          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 AccountJournal = self.AccountJournal;
+          _.each(AccountJournal,function(item) {
+
+            var total_price = 0;
+            var total_cost = 0;
+            var utility = 0;
+            var payment_type = '';
+
+            var AccountInvoice = self.getAccountInvoice(item.id);
+            _.each(AccountInvoice,function(item2) {
+
+              if(item2.payment_term.id && item2.payment_term.check_credit == true){
+                payment_type = 'Crédito';
+              }
+              else{
+                payment_type = 'Contado';
+              }
+
+              var AccountInvoiceLine = self.getAccountInvoiceLine(item2.id);
+              _.each(AccountInvoiceLine, function(line_item){
+                total_cost = line_item.product_id.standard_price * line_item.quantity;
+                total_price = line_item.price_unit * line_item.quantity;
+                utility = total_price - total_cost;
+
+                data.push({
+                  //IDS
+                  id: line_item.id,
+                  product_id : line_item.product_id.id,
+                  invoice_id : item2.id,
+
+                  //DATAS
+                  categ_id : line_item.product_id.categ_id,
+
+                  date_invoice: moment(item2.date_invoice).format('YYYY-MM-DD'),
+                  invoice_name : item2.number,
+                  payment_type : payment_type,
+                  product_code : self.valorNull(line_item.product_id.default_code),
+                  barcode : self.valorNull(line_item.product_id.ean13),
+                  product_name : line_item.product_id.name,
+                  item_cost : accounting.formatMoney(line_item.product_id.standard_price,'', CurrencyBase.decimal_places, CurrencyBase.thousands_separator, CurrencyBase.decimal_separator),
+                  item_price : accounting.formatMoney(line_item.price_unit,'', CurrencyBase.decimal_places, CurrencyBase.thousands_separator, CurrencyBase.decimal_separator),
+                  qty : line_item.quantity,
+                  total_price : accounting.formatMoney(total_price,'', CurrencyBase.decimal_places, CurrencyBase.thousands_separator, CurrencyBase.decimal_separator),
+                  total_cost : accounting.formatMoney(total_cost,'', CurrencyBase.decimal_places, CurrencyBase.thousands_separator, CurrencyBase.decimal_separator),
+                  utility : accounting.formatMoney(utility,'', CurrencyBase.decimal_places, CurrencyBase.thousands_separator, CurrencyBase.decimal_separator),
+                  comment : self.valorNull(item2.comment),
+
+                  //VALORES SIN FORMATEAR
+                  item_cost_no_format : line_item.product_id.standard_price,
+                  item_price_no_format : line_item.price_unit,
+                  total_price_no_format : total_price,
+                  total_cost_no_format : total_cost,
+                  utility_no_format : utility,
+
+                  //TOTAL FOOTER CONFIGURATION
+                  decimal_places : CurrencyBase.decimal_places,
+                  thousands_separator: CurrencyBase.thousands_separator,
+                  decimal_separator: CurrencyBase.decimal_separator,
+
+                });
+              });
+            });
+          });
+
+          self.content = data;
+          var group_data = self.groupBy(data);
+          var x = [];
+          group_data.forEach((item,key) => {
+            x.push({
+              key:'categoria',
+              product_name:key,
+              total_price_no_format : 0,
+              total_cost_no_format : 0,
+              utility_no_format : 0,
+
+              decimal_places : CurrencyBase.decimal_places,
+              thousands_separator: CurrencyBase.thousands_separator,
+              decimal_separator: CurrencyBase.decimal_separator,
+            });
+            _.each(item,function(row){
+
+              x.push(row);
+
+            })
+          });
+
+          self.loadTable(x);
+
+          self.$el.find('.report-form').css('display','block');
+          self.$el.find('.search-form').unblock();
+          self.$el.find('.report-form').unblock();
+        },
+
+        groupBy: function(list) {
+          const map = new Map();
+          list.forEach((item) => {
+            const key = item.categ_id;
+            const collection = map.get(key);
+            if (!collection) {
+              map.set(key, [item]);
+            } else {
+              collection.push(item);
+            }
+          });
+          return map;
+        },
+        /*====================================================================
+            LOAD BOOTSTRAP TABLE
+        ====================================================================*/
+        loadTable:function(rowsTable){
+            var self = this;
+            self.rowsData = rowsTable;
+            var table = this.$el.find('#table');
+            table.bootstrapTable('load', rowsTable);
+        },
+
+        /*====================================================================
+            PRINT PDF
+        ====================================================================*/
+        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);
+            var total_cost = totalCostFormatter(row);
+            var utility = totalUtilityFormatter(row);
+
+            row.push({
+                date_invoice: 'Totales',
+                total_price: total_price,
+                total_cost: total_cost,
+                utility:utility,
+            })
+
+            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 = 'Venta por vendedor por categoría de producto';
+                var pdf_type = 'l';
+                var pdf_name = 'venta_por_vendedor_por_categoria_de_producto_';
+                var pdf_columnStyles =  {
+
+                  date_invoice: {columnWidth: 16, halign:'center'},
+                  invoice_name : {columnWidth: 24, halign:'center'},
+                  payment_type : {columnWidth: 15, halign:'center'},
+                  product_code : {columnWidth: 21, halign:'center'},
+                  barcode : {columnWidth: 21, halign:'center'},
+                  product_name : {columnWidth: 38, halign:'center'},
+                  item_cost : {columnWidth: 21, halign:'right'},
+                  item_price : {columnWidth: 21, halign:'right'},
+                  qty : {columnWidth: 16, halign:'center'},
+                  total_price : {columnWidth: 21, halign:'right'},
+                  total_cost : {columnWidth: 21, halign:'right'},
+                  utility : {columnWidth: 21, halign:'right'},
+                  comment : {columnWidth: 25, halign:'left'},
+
+                };
+                /*
+                ============================================================
+                    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 category = self.$el.find('#current-category').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;
+        },
+
+    });
+}

+ 117 - 39
static/src/js/reports/report_seller.js

@@ -14,6 +14,7 @@ function report_seller(reporting){
             'change #current-company' : 'updateSelections',
             'change #current-store' : 'updateJournalSelections',
             'change #current-date' : 'ShowDateRange',
+            'change #current-period': 'updatePeriodSelections',
         },
 
         init : function(parent){
@@ -375,6 +376,17 @@ function report_seller(reporting){
                 });
             }
         },
+        updatePeriodSelections: function () {
+            var self = this;
+            var period = self.$el.find('#current-period').val();
+            if(period != 9999999){
+                self.$el.find('#current-date').val(9999999);
+                self.$el.find('#current-date').prop('disabled','disabled');
+                self.$el.find('.datepicker').css('display','none');
+            }else{
+                self.$el.find('#current-date').prop('disabled',false);
+            }
+        },
 
         /*====================================================================
             GET RES COMPANY
@@ -539,48 +551,23 @@ function report_seller(reporting){
             var column = table.bootstrapTable('getVisibleColumns');
             var row = table.bootstrapTable('getData');
 
-            var cash_total = _.reduce(_.map(row, function (map) {
-                return map.total_cash_no_format;
-            }), function (memo, num) {
-                return memo + num;
-            });
-
-            var credit_total = _.reduce(_.map(row, function (map) {
-                return map.total_credit_no_format;
-            }), function (memo, num) {
-                return memo + num;
-            });
-
-            var total_amount = _.reduce(_.map(row, function (map) {
-                return map.total_amount_no_format;
-            }), function (memo, num) {
-                return memo + num;
-            });
-
-            var total_cost = _.reduce(_.map(row, function (map) {
-                return map.total_cost_no_format;
-            }), function (memo, num) {
-                return memo + num;
-            });
-
-            var total_utility = _.reduce(_.map(row, function (map) {
-                return map.utility_no_format;
-            }), function (memo, num) {
-                return memo + num;
-            });
-
-            var total_cost_percent = total_utility * 100 / total_cost;
-            var total_sale_percent = total_utility * 100 / total_amount;
+            var cash_total = totalCashFormatter(row);
+            var credit_total = totalCreditFormatter(row);
+            var total_amount = totalAmountFormatter(row);
+            var total_cost = totalCostFormatter(row);
+            var total_utility = totalUtilityFormatter(row);
+            var total_cost_percent = totalCostPercentFormatter(row);
+            var total_sale_percent = totalSalePercentFormatter(row);
 
             row.push({
                 name: 'Totales',
-                total_cash: accounting.formatMoney(cash_total, '', CurrencyBase.decimal_places, CurrencyBase.thousands_separator, CurrencyBase.decimal_separator),
-                total_credit: accounting.formatMoney(credit_total, '', CurrencyBase.decimal_places, CurrencyBase.thousands_separator, CurrencyBase.decimal_separator),
-                total_amount: accounting.formatMoney(total_amount, '', CurrencyBase.decimal_places, CurrencyBase.thousands_separator, CurrencyBase.decimal_separator),
-                total_cost: accounting.formatMoney(total_cost, '', CurrencyBase.decimal_places, CurrencyBase.thousands_separator, CurrencyBase.decimal_separator),
-                utility: accounting.formatMoney(total_utility, '', CurrencyBase.decimal_places, CurrencyBase.thousands_separator, CurrencyBase.decimal_separator),
-                cost_percent: accounting.formatNumber(total_cost_percent,2,CurrencyBase.thousands_separator, CurrencyBase.decimal_separator) + ' %',
-                sale_percent: accounting.formatNumber(total_sale_percent,2,CurrencyBase.thousands_separator, CurrencyBase.decimal_separator) + ' %',
+                total_cash: cash_total,
+                total_credit: credit_total,
+                total_amount: total_amount,
+                total_cost: total_cost,
+                utility: total_utility,
+                cost_percent: total_cost_percent,
+                sale_percent: total_sale_percent,
 
             })
 
@@ -617,6 +604,7 @@ function report_seller(reporting){
                     LLAMAR FUNCION DE IMPRESION
                 ============================================================
                 */
+                var filter = self.getFilter();
                 var pdf = new model.eiru_reports.ReportPdfWidget(self);
                 pdf.drawPDF(
                     _.flatten(getColumns),
@@ -626,8 +614,98 @@ function report_seller(reporting){
                     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(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;
+        },
     });
 }

+ 121 - 21
static/src/js/reports/report_type_income.js

@@ -14,6 +14,7 @@ function report_type_income(reporting){
             'change #current-company' : 'updateSelections',
             'change #current-store' : 'updateJournalSelections',
             'change #current-date' : 'ShowDateRange',
+            'change #current-period' : 'updatePeriodSelections',
         },
 
         init : function(parent){
@@ -233,7 +234,6 @@ function report_type_income(reporting){
             var domain = [
                 ['state', '=','posted'],
                 ['type', '=', 'receipt'],
-
             ];
 
             if(company && company != 9999999){
@@ -358,6 +358,17 @@ function report_type_income(reporting){
                 });
             }
         },
+        updatePeriodSelections: function () {
+            var self = this;
+            var period = self.$el.find('#current-period').val();
+            if(period != 9999999){
+                self.$el.find('#current-date').val(9999999);
+                self.$el.find('#current-date').prop('disabled','disabled');
+                self.$el.find('.datepicker').css('display','none');
+            }else{
+                self.$el.find('#current-date').prop('disabled',false);
+            }
+        },
 
         /*====================================================================
             GET RES COMPANY
@@ -417,25 +428,27 @@ function report_type_income(reporting){
               amount = amount + item2.amount;
             });
 
-            data.push({
+            if(amount > 0){
+              data.push({
 
-                id: item.id,
-                name: item.name,
-                amount: accounting.formatMoney(amount,'', CurrencyBase.decimal_places, CurrencyBase.thousands_separator, CurrencyBase.decimal_separator),
+                  id: item.id,
+                  name: item.name,
+                  amount: accounting.formatMoney(amount,'', CurrencyBase.decimal_places, CurrencyBase.thousands_separator, CurrencyBase.decimal_separator),
 
-                /*=======================
-                        VALORES SIN FORMATEAR
-                    =======================*/
-                amount_no_format : amount,
+                  /*=======================
+                          VALORES SIN FORMATEAR
+                      =======================*/
+                  amount_no_format : amount,
 
-                /*==============================
-                      TOTAL FOOTER CONFIGURATION
-                  ==============================*/
-                decimal_places : CurrencyBase.decimal_places,
-                thousands_separator: CurrencyBase.thousands_separator,
-                decimal_separator: CurrencyBase.decimal_separator,
+                  /*==============================
+                        TOTAL FOOTER CONFIGURATION
+                    ==============================*/
+                  decimal_places : CurrencyBase.decimal_places,
+                  thousands_separator: CurrencyBase.thousands_separator,
+                  decimal_separator: CurrencyBase.decimal_separator,
 
               });
+            }
         });
 
           self.content = data;
@@ -477,15 +490,11 @@ function report_type_income(reporting){
             var row = table.bootstrapTable('getData');
 
 
-            var amount = _.reduce(_.map(row, function (map) {
-                return map.amount_no_format;
-            }), function (memo, num) {
-                return memo + num;
-            });
+            var amount = totalAmountFormatter(row);
 
             row.push({
                 name: 'Totales',
-                amount: accounting.formatMoney(amount, '', CurrencyBase.decimal_places, CurrencyBase.thousands_separator, CurrencyBase.decimal_separator),
+                amount: amount,
             })
 
             if (action === 'pdf') {
@@ -514,6 +523,7 @@ function report_type_income(reporting){
                     LLAMAR FUNCION DE IMPRESION
                 ============================================================
                 */
+                var filter = self.getFilter();
                 var pdf = new model.eiru_reports.ReportPdfWidget(self);
                 pdf.drawPDF(
                     _.flatten(getColumns),
@@ -523,8 +533,98 @@ function report_type_income(reporting){
                     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: 'Tipo de Ingreso',
+                value:  AccountJournal[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;
+        },
     });
 }

+ 193 - 0
static/src/reports/report_account_state.xml

@@ -0,0 +1,193 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<template xml:space="preserve">
+    <t t-name="ReportAccountState">
+        <div class="report_view">
+            <div class="reporting_page_header">
+                <h1 class="report_title">Estado de cuentas de clientes por vendedores</h1>
+            </div>
+            <div class="container search-form" style="border-bottom:1px solid #eee; width:90%;">
+                <div class="row">
+                    <div class="col-lg-3 company filter-style">
+                        <label>Empresa</label>
+                        <select id="current-company" class="form-control form-control-sm"></select>
+                    </div>
+                    <div class="col-lg-3 store filter-style">
+                        <label>Sucursal</label>
+                        <select id="current-store" class="form-control form-control-sm">
+                        </select>
+                    </div>
+
+                    <div class="col-lg-3 journal filter-style">
+                       <label>Vendedor</label>
+                       <select id="current-journal" class="form-control form-control-sm">
+                       </select>
+                    </div>
+
+                    <div class="col-lg-3 filter-style">
+                         <label>Estado</label>
+                         <select id="current-state" class="form-control form-control-sm">
+                             <option value="9999999">Todos los estados</option>
+                             <option value="open">Abierto</option>
+                             <option value="paid">Pagado</option>
+                         </select>
+                     </div>
+
+                    <div class="col-lg-3 filter-style">
+                        <label>Periodo</label>
+                        <select id="current-period" class="form-control form-control-sm">
+                        </select>
+                    </div>
+
+                    <div class="col-lg-3 filter-style">
+                        <label>Fechas</label>
+                        <select id="current-date" class="form-control form-control-sm">
+                            <option value="9999999">Sin fechas</option>
+                            <option value="today">Hoy</option>
+                            <option value="yesterday">Ayer</option>
+                            <option value="currentMonth">Mes Actual</option>
+                            <option value="lastMonth">Mes Pasado</option>
+                            <option value="range">Busqueda Avanzada</option>
+                        </select>
+                    </div>
+                </div>
+                <div class="row" >
+                    <div class="datepicker" style="display:none;">
+                        <div class="col-lg-3 filter-style col-md-offset-3">
+                            <div class="input-group">
+                                <span class="input-group-addon" id="basic-addon1">Desde</span>
+                                <input type="text" id="from" class="form-control" aria-describedby="basic-addon1"/>
+                            </div>
+                        </div>
+                        <div class="col-lg-3 filter-style">
+                            <div class="input-group">
+                                <span class="input-group-addon" id="basic-addon1">Hasta</span>
+                                <input type="text" id="to" class="form-control" aria-describedby="basic-addon1"/>
+                            </div>
+                        </div>
+                    </div>
+                </div>
+
+                <div class="row">
+                  <div class="text-center" style="padding-top:20px;">
+                      <button id="generate" class="myButton" aria-label="Left Align" style="color:#fff;display:none;">
+                        Generar
+                    </button>
+                  </div>
+                  <br/>
+                </div>
+            </div>
+
+            <div class="report-form" style="display:none;">
+
+                <div id="toolbar">
+                    <button class="oe_button oe_form_button myButton" value="pdf">Imprimir Informe</button>
+                </div>
+                <div class="container" style="width:95%;">
+                    <table id="table"
+                        data-pagination="true"
+                        data-toggle="table"
+                        data-toolbar="#toolbar"
+                        data-show-columns="true"
+                        data-height="auto"
+                        data-classes="table table-hover table-condensed  table-no-bordered"
+                        data-row-style="rowStyle"
+                        data-search="true"
+                        data-show-export="true"
+                        data-show-toggle="true"
+                        data-pagination-detail-h-align="left"
+                        data-show-footer="true"
+                        data-footer-style="footerStyle"
+                        data-buttons-class="oe_button oe_form_button myButton"
+                        data-show-pagination-switch="true"
+                        data-page-size="10"
+                        data-search-on-enter-key="true"
+                        data-undefined-text=" "
+                        >
+                        <thead style="background:none;">
+                            <tr>
+                                <th data-field="seller_name" data-width="25px" data-align="left" data-footer-formatter="Totales">Vendedor</th>
+                                <th data-field="date_invoice" data-align="center">Fecha</th>
+                                <th data-field="invoice_name" data-align="left">N° Factura</th>
+                                <th data-field="partner_name" data-align="left">Cliente</th>
+                                <th data-field="amount" data-align="right" data-footer-formatter="totalFormatter" data-width="12%">Total</th>
+                                <th data-field="paid" data-align="right" data-footer-formatter="totalPaidFormatter" data-width="12%">Entregado</th>
+                                <th data-field="residual" data-align="right" data-footer-formatter="totalResidualFormatter" data-width="12%">Saldo Final</th>
+                            </tr>
+                        </thead>
+                    </table>
+                </div>
+            </div>
+
+
+            <script>
+
+                <!--
+                    RESIDUAL TOTAL
+                -->
+                function totalResidualFormatter(rowsTable) {
+                    var decimal_places = 0;
+                    var thousands_separator = '.';
+                    var decimal_separator = ',';
+                    if(rowsTable.length > 0){
+                        decimal_places = rowsTable[0].decimal_places;
+                        thousands_separator = rowsTable[0].thousands_separator;
+                        decimal_separator = rowsTable[0].decimal_separator;
+                    }
+                    var total =  _.reduce(_.map(rowsTable,function(item){
+                        return (item.total_residual_no_format);
+                    }), function(memo, num){
+                    return memo + num; },0)
+                    return accounting.formatNumber(total,decimal_places,thousands_separator,decimal_separator);
+                }
+
+                <!--
+                    PAID TOTAL
+                -->
+                function totalPaidFormatter(rowsTable) {
+                    var decimal_places = 0;
+                    var thousands_separator = '.';
+                    var decimal_separator = ',';
+                    if(rowsTable.length > 0){
+                        decimal_places = rowsTable[0].decimal_places;
+                        thousands_separator = rowsTable[0].thousands_separator;
+                        decimal_separator = rowsTable[0].decimal_separator;
+                    }
+                    var total =  _.reduce(_.map(rowsTable,function(item){
+                        return (item.total_paid_no_format);
+                    }), function(memo, num){
+                    return memo + num; },0)
+                    return accounting.formatNumber(total,decimal_places,thousands_separator,decimal_separator);
+                }
+                <!--
+                    TOTAL
+                -->
+                function totalFormatter(rowsTable) {
+                    var decimal_places = 0;
+                    var thousands_separator = '.';
+                    var decimal_separator = ',';
+                    if(rowsTable.length > 0){
+                        decimal_places = rowsTable[0].decimal_places;
+                        thousands_separator = rowsTable[0].thousands_separator;
+                        decimal_separator = rowsTable[0].decimal_separator;
+                    }
+                    var total =  _.reduce(_.map(rowsTable,function(item){
+                        return (item.total_amount_no_format);
+                    }), function(memo, num){
+                    return memo + num; },0)
+                    return accounting.formatNumber(total,decimal_places,thousands_separator,decimal_separator);
+                }
+                <!--
+                    FOOTER STYLE
+                -->
+                function footerStyle(row, index) {
+                    return {
+                        css: {
+                          "font-weight": "bold"
+                        }
+                    };
+                };
+
+            </script>
+        </div>
+    </t>
+</template>

+ 9 - 9
static/src/reports/report_expenses_dental.xml

@@ -3,7 +3,7 @@
     <t t-name="ReportExpensesDental">
         <div class="report_view">
             <div class="reporting_page_header">
-                <h1 class="report_title"> Gastos</h1>
+                <h1 class="report_title">Gastos</h1>
             </div>
             <div class="container search-form" style="border-bottom:1px solid #eee; width:90%;">
                 <div class="row">
@@ -59,19 +59,19 @@
                 </div>
 
                 <div class="row">
-                    <div class="text-center" style="padding-top:20px;">
-                        <a id="generate" type="button" class="btn btn-danger" aria-label="Left Align" style="color:#fff;display:none;">
-                          Generar
-                        </a>
-                    </div>
-                    <br/>
+                  <div class="text-center" style="padding-top:20px;">
+                      <button id="generate" class="myButton" aria-label="Left Align" style="color:#fff;display:none;">
+                        Generar
+                    </button>
+                  </div>
+                  <br/>
                 </div>
             </div>
 
             <div class="report-form" style="display:none;">
 
                 <div id="toolbar">
-                    <button class="oe_button oe_form_button oe_highlight" value="pdf">PDF</button>
+                    <button class="oe_button oe_form_button myButton" value="pdf">Imprimir Informe</button>
                 </div>
                 <div class="container" style="width:90%;">
                     <table id="table"
@@ -88,7 +88,7 @@
                         data-pagination-detail-h-align="left"
                         data-show-footer="true"
                         data-footer-style="footerStyle"
-                        data-buttons-class="oe_button oe_form_button oe_highlight"
+                        data-buttons-class="oe_button oe_form_button myButton"
                         data-show-pagination-switch="true"
                         data-page-size="10"
                         data-search-on-enter-key="true"

+ 16 - 12
static/src/reports/report_receipt_dental.xml

@@ -3,7 +3,7 @@
     <t t-name="ReportPaymentDental">
         <div class="report_view">
             <div class="reporting_page_header">
-                <h1 class="report_title">Cobro por Vendedores</h1>
+                <h1 class="report_title">Ingreso por Vendedores</h1>
             </div>
             <div class="container search-form" style="border-bottom:1px solid #eee; width:95%;">
                 <div class="row">
@@ -56,18 +56,22 @@
                     </div>
                 </div>
                 <div class="row">
-                    <div class="text-center" style="padding-top:20px;">
-                        <a id="generate" type="button" class="btn btn-danger" aria-label="Left Align" style="color:#fff;display:none;">
-                          Generar
-                        </a>
-                    </div>
-                    <br/>
+                  <div class="text-center" style="padding-top:20px;">
+                      <button id="generate" class="myButton" aria-label="Left Align" style="color:#fff;display:none;">
+                        Generar
+                    </button>
+                  </div>
+                  <br/>
                 </div>
             </div>
 
             <div class="report-form" style="display:none;">
+
+              <div class="chart-container center-block" style="padding-top:20px; height:350px; padding-bottom:20px;">
+                          <canvas id="reporting-chart" class="reporting-chart"></canvas>
+                      </div>
                 <div id="toolbar">
-                    <button class="oe_button oe_form_button oe_highlight" value="pdf">PDF</button>
+                    <button class="oe_button oe_form_button myButton" value="pdf">Imprimir Informe</button>
                 </div>
                 <div class="container" style="width:95%;">
                     <table id="table"
@@ -84,7 +88,7 @@
                         data-pagination-detail-h-align="left"
                         data-show-footer="true"
                         data-footer-style="footerStyle"
-                        data-buttons-class="oe_button oe_form_button oe_highlight"
+                        data-buttons-class="oe_button oe_form_button myButton"
                         data-show-pagination-switch="true"
                         data-page-size="10"
                         data-search-on-enter-key="true"
@@ -93,9 +97,9 @@
                         <thead style="background:none;">
                             <tr>
                                 <th data-field="name" data-footer-formatter="Totales" data-align="left">Nombre</th>
-                                <th data-field="total_cash" data-footer-formatter="totalCashFormatter" data-align="right">Total Contado</th>
-                                <th data-field="total_credit" data-footer-formatter="totalCreditFormatter" data-align="right">Total Credito</th>
-                                <th data-field="total_amount" data-footer-formatter="totalAmountFormatter" data-align="right">Total Cobro</th>
+                                <th data-field="total_cash"  data-footer-formatter="totalCashFormatter" data-align="right">Total Contado</th>
+                                <th data-field="total_credit"  data-footer-formatter="totalCreditFormatter" data-align="right">Total Crédito</th>
+                                <th data-field="total_amount"  data-footer-formatter="totalAmountFormatter" data-align="right">Total Ingreso</th>
                             </tr>
                         </thead>
                     </table>

+ 212 - 0
static/src/reports/report_sale_dental.xml

@@ -0,0 +1,212 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<template xml:space="preserve">
+    <t t-name="ReportSaleDental">
+        <div class="report_view">
+            <div class="reporting_page_header">
+                <h1 class="report_title">Venta por Vendedores agrupado por Categoría de Producto</h1>
+            </div>
+            <div class="container search-form" style="border-bottom:1px solid #eee; width:95%;">
+                <div class="row">
+                    <div class="col-lg-3 company filter-style">
+                        <label>Empresa</label>
+                        <select id="current-company" class="form-control form-control-sm"></select>
+                    </div>
+                    <div class="col-lg-3 store filter-style">
+                        <label>Sucursal</label>
+                        <select id="current-store" class="form-control form-control-sm">
+                        </select>
+                    </div>
+                    <div class="col-lg-3 journal filter-style">
+                        <label>Vendedor</label>
+                        <select id="current-journal" class="form-control form-control-sm">
+                        </select>
+                    </div>
+                    <div class="col-lg-3 category filter-style">
+                        <label>Categoría</label>
+                        <select id="current-category" class="form-control form-control-sm">
+                        </select>
+                    </div>
+
+                    <div class="col-lg-3 filter-style">
+                        <label>Periodo</label>
+                        <select id="current-period" class="form-control form-control-sm">
+                        </select>
+                    </div>
+                    <div class="col-lg-3 filter-style">
+                        <label>Fechas</label>
+                        <select id="current-date" class="form-control form-control-sm">
+                            <option value="9999999">Sin fechas</option>
+                            <option value="today">Hoy</option>
+                            <option value="yesterday">Ayer</option>
+                            <option value="currentMonth">Mes Actual</option>
+                            <option value="lastMonth">Mes Pasado</option>
+                            <option value="range">Busqueda Avanzada</option>
+                        </select>
+                    </div>
+                </div>
+                <div class="row" >
+                    <div class="datepicker" style="display:none;">
+                        <div class="col-lg-3 filter-style col-md-offset-3">
+                            <div class="input-group">
+                                <span class="input-group-addon" id="basic-addon1">Desde</span>
+                                <input type="text" id="from" class="form-control" aria-describedby="basic-addon1"/>
+                            </div>
+                        </div>
+                        <div class="col-lg-3 filter-style">
+                            <div class="input-group">
+                                <span class="input-group-addon" id="basic-addon1">Hasta</span>
+                                <input type="text" id="to" class="form-control" aria-describedby="basic-addon1"/>
+                            </div>
+                        </div>
+                    </div>
+                </div>
+                <div class="row">
+                  <div class="text-center" style="padding-top:20px;">
+                      <button id="generate" class="myButton" aria-label="Left Align" style="color:#fff;display:none;">
+                        Generar
+                    </button>
+                  </div>
+                  <br/>
+                </div>
+            </div>
+
+            <div class="report-form" style="display:none;">
+                <div id="toolbar">
+                    <button class="oe_button oe_form_button myButton" value="pdf">Imprimir Informe</button>
+                </div>
+                <div class="container" style="width:100%;">
+                  <table id="table"
+                    data-search="true"
+                    data-show-columns="true"
+                    data-pagination="true"
+                    data-page-size="10"
+                    data-toggle="table"
+                    data-toolbar="#toolbar"
+                    data-classes="table table-condensed table-no-bordered"
+                    data-row-style="rowStyle"
+                    data-show-export="true"
+                    data-show-toggle="true"
+                    data-pagination-detail-h-align="left"
+                    data-show-footer="true"
+                    data-footer-style="footerStyle"
+                    data-buttons-class="oe_button oe_form_button myButton"
+                    data-show-pagination-switch="true"
+                    data-search-on-enter-key="true"
+                    data-undefined-text=" "
+                    >
+                    <thead style="background:none;">
+                       <tr>
+                          <th data-field="date_invoice" data-align="center" data-footer-formatter="Totales">Fecha</th>
+                          <th data-field="invoice_name" data-align="center">Factura</th>
+                          <th data-field="payment_type" data-align="center">Forma de Pago</th>
+                          <th data-field="product_code" data-align="center">Cod. Producto</th>
+                          <th data-field="barcode" data-align="center">Cod. de Barra</th>
+                          <th data-field="product_name" data-align="center" data-cell-style="cellStyle" data-row-style="rowStyle">Producto</th>
+                          <th data-field="item_cost" data-align="right">Costo Unitario</th>
+                          <th data-field="item_price" data-align="right">Venta Unitario</th>
+                          <th data-field="qty" data-align="center">Cantidad</th>
+                          <th data-field="total_price" data-footer-formatter="totalPriceFormatter" data-align="right">Total Venta</th>
+                          <th data-field="total_cost" data-footer-formatter="totalCostFormatter" data-align="right">Total Costo</th>
+                          <th data-field="utility" data-footer-formatter="totalUtilityFormatter" data-align="right">Perdida o Ganancia</th>
+                          <th data-field="comment" data-align="left">Observación</th>
+                        </tr>
+                      </thead>
+
+                    </table>
+                </div>
+            </div>
+            <script>
+              function cellStyle(value, row, index,field) {
+                  if (row.key === 'categoria') {
+                      return {
+                          css: {"background": "#bbdefb",  "font-weight": "bold",},
+                      };
+                  }
+                  return false;
+              }
+
+              function rowStyle(row, index) {
+                  if (row.key === 'categoria') {
+                      return {
+                          css: {"background": "#bbdefb",  "font-weight": "bold",},
+                      };
+                  }
+                  return false;
+              }
+
+                <!--
+                    TOTAL PRICE
+                -->
+                function totalPriceFormatter(rowsTable) {
+                    var decimal_places = 0;
+                    var thousands_separator = '.';
+                    var decimal_separator = ',';
+                    if(rowsTable.length > 0){
+                        decimal_places = rowsTable[0].decimal_places;
+                        thousands_separator = rowsTable[0].thousands_separator;
+                        decimal_separator = rowsTable[0].decimal_separator;
+                    }
+                    var amount =  _.reduce(_.map(rowsTable,function(item){
+                        return (item.total_price_no_format);
+                    }), function(memo, num){
+                    return memo + num; },0)
+
+                    return accounting.formatNumber(amount,decimal_places,thousands_separator,decimal_separator);
+                }
+
+                <!--
+                    TOTAL COST
+                -->
+                function totalCostFormatter(rowsTable) {
+                    var decimal_places = 0;
+                    var thousands_separator = '.';
+                    var decimal_separator = ',';
+                    if(rowsTable.length > 0){
+                        decimal_places = rowsTable[0].decimal_places;
+                        thousands_separator = rowsTable[0].thousands_separator;
+                        decimal_separator = rowsTable[0].decimal_separator;
+                    }
+                    var amount =  _.reduce(_.map(rowsTable,function(item){
+                        return (item.total_cost_no_format);
+                    }), function(memo, num){
+                    return memo + num; },0)
+                    return accounting.formatNumber(amount,decimal_places,thousands_separator,decimal_separator);
+                }
+
+
+                <!--
+                    TOTAL UTILITY
+                -->
+                function totalUtilityFormatter(rowsTable) {
+                    var decimal_places = 0;
+                    var thousands_separator = '.';
+                    var decimal_separator = ',';
+                    if(rowsTable.length > 0){
+                        decimal_places = rowsTable[0].decimal_places;
+                        thousands_separator = rowsTable[0].thousands_separator;
+                        decimal_separator = rowsTable[0].decimal_separator;
+                    }
+                    var amount =  _.reduce(_.map(rowsTable,function(item){
+                        return (item.utility_no_format);
+                    }), function(memo, num){
+                    return memo + num; },0)
+                    return accounting.formatNumber(amount,decimal_places,thousands_separator,decimal_separator);
+                }
+
+
+                <!--
+                    FOOTER STYLE
+                -->
+                function footerStyle(row, index) {
+                    return {
+                        css: {
+                          "font-weight": "bold",
+                        }
+                    };
+                };
+
+
+            </script>
+        </div>
+    </t>
+</template>

+ 8 - 8
static/src/reports/report_seller.xml

@@ -56,18 +56,18 @@
                     </div>
                 </div>
                 <div class="row">
-                    <div class="text-center" style="padding-top:20px;">
-                        <a id="generate" type="button" class="btn btn-danger" aria-label="Left Align" style="color:#fff;display:none;">
-                          Generar
-                        </a>
-                    </div>
-                    <br/>
+                  <div class="text-center" style="padding-top:20px;">
+                      <button id="generate" class="myButton" aria-label="Left Align" style="color:#fff;display:none;">
+                        Generar
+                    </button>
+                  </div>
+                  <br/>
                 </div>
             </div>
 
             <div class="report-form" style="display:none;">
                 <div id="toolbar">
-                    <button class="oe_button oe_form_button oe_highlight" value="pdf">PDF</button>
+                    <button class="oe_button oe_form_button myButton" value="pdf">Imprimir Informe</button>
                 </div>
                 <div class="container" style="width:95%;">
                     <table id="table"
@@ -84,7 +84,7 @@
                         data-pagination-detail-h-align="left"
                         data-show-footer="true"
                         data-footer-style="footerStyle"
-                        data-buttons-class="oe_button oe_form_button oe_highlight"
+                        data-buttons-class="oe_button oe_form_button myButton"
                         data-show-pagination-switch="true"
                         data-page-size="10"
                         data-search-on-enter-key="true"

+ 8 - 8
static/src/reports/report_type_income.xml

@@ -57,18 +57,18 @@
                     </div>
                 </div>
                 <div class="row">
-                    <div class="text-center" style="padding-top:20px;">
-                        <a id="generate" type="button" class="btn btn-danger" aria-label="Left Align" style="color:#fff;display:none;">
-                          Generar
-                        </a>
-                    </div>
-                    <br/>
+                  <div class="text-center" style="padding-top:20px;">
+                      <button id="generate" class="myButton" aria-label="Left Align" style="color:#fff;display:none;">
+                        Generar
+                    </button>
+                  </div>
+                  <br/>
                 </div>
             </div>
 
             <div class="report-form" style="display:none;">
                 <div id="toolbar">
-                    <button class="oe_button oe_form_button oe_highlight" value="pdf">PDF</button>
+                    <button class="oe_button oe_form_button myButton" value="pdf">Imprimir Informe</button>
                 </div>
                 <div class="container" style="width:95%;">
                     <table id="table"
@@ -85,7 +85,7 @@
                         data-pagination-detail-h-align="left"
                         data-show-footer="true"
                         data-footer-style="footerStyle"
-                        data-buttons-class="oe_button oe_form_button oe_highlight"
+                        data-buttons-class="oe_button oe_form_button myButton"
                         data-show-pagination-switch="true"
                         data-page-size="10"
                         data-search-on-enter-key="true"

+ 7 - 0
templates.xml

@@ -7,6 +7,7 @@
                 <!-- configuration < main > -->
                 <script type="text/javascript" src="/eiru_reports_g6/static/src/js/main.js" />
                 <script type="text/javascript" src="/eiru_reports_g6/static/src/js/reporting_base.js" />
+                <script type="text/javascript" src="/eiru_reports_g6/static/src/js/pdf.js" />
 
                 <!-- venta_costo_utilidad_por_vendedor -->
                 <script type="text/javascript" src="/eiru_reports_g6/static/src/js/reports/report_seller.js"/>
@@ -20,6 +21,12 @@
                 <!-- gastos -->
                 <script type="text/javascript" src="/eiru_reports_g6/static/src/js/reports/report_expenses_dental.js"/>
 
+                <!-- rendicion de venta por vendedor -->
+                <script type="text/javascript" src="/eiru_reports_g6/static/src/js/reports/report_sale_dental.js"/>
+
+                <!-- estado de cuentas por cliente por vendedor -->
+                <script type="text/javascript" src="/eiru_reports_g6/static/src/js/reports/report_account_state.js"/>
+
             </xpath>
         </template>
     </data>

+ 8 - 0
views/actions.xml

@@ -18,6 +18,14 @@
 						<field name="name">Gastos</field>
 						<field name="tag">eiru_reports_g6.expenses_dental_action</field>
 		</record>
+		<record id="sale_dental_action" model="ir.actions.client">
+						<field name="name">Venta por Vendedores por Producto</field>
+						<field name="tag">eiru_reports_g6.sale_dental_action</field>
+		</record>
+		<record id="account_state_dental_action" model="ir.actions.client">
+						<field name="name">Estado de cuentas de clientes por vendedor</field>
+						<field name="tag">eiru_reports_g6.account_state_dental_action</field>
+		</record>
 
     </data>
 </openerp>

+ 20 - 8
views/menus.xml

@@ -6,31 +6,43 @@
            Dental G6
        =======================================================================
        -->
-       <menuitem id="dental_parent_menu" name="Dental G6" parent="eiru_reports.eiru_reports_main_menu" sequence="4"/>
+       <menuitem id="dental_parent_menu" name="Dental G6" parent="eiru_reports.eiru_reports_main_menu" sequence="10"/>
 
        <menuitem id="seller_menu"
             parent="dental_parent_menu"
             name="Venta/Costo/Utilidad por Vendedores"
             action="seller_action"
-            sequence="5"/>
+            sequence="1"/>
 
         <menuitem id="type_income_menu"
             parent="dental_parent_menu"
             name="Ingreso por Método de Pago"
             action="type_income_action"
-            sequence="6"/>
+            sequence="2"/>
 
         <menuitem id="receipt_dental_menu"
             parent="dental_parent_menu"
-             name="Cobro por Vendedores"
+            name="Ingreso por Vendedores"
             action="receipt_dental_action"
-            sequence="7"/>
+            sequence="3"/>
 
         <menuitem id="expenses_dental_menu"
-             parent="dental_parent_menu"
-             name="Gastos"
+            parent="dental_parent_menu"
+            name="Gastos"
             action="expenses_dental_action"
-            sequence="8"/>
+            sequence="4"/>
+
+        <menuitem id="sale_dental_menu"
+             parent="dental_parent_menu"
+             name="Venta por Vendedores por Producto"
+             action="sale_dental_action"
+             sequence="5"/>
+
+        <menuitem id="account_state_dental_menu"
+             parent="dental_parent_menu"
+             name="Estado de cuentas de clientes por vendedor"
+             action="account_state_dental_action"
+             sequence="6"/>
 
     </data>
 </openerp>