deisy 5 роки тому
батько
коміт
dc5d793e7a

+ 3 - 1
controller/helpers/account_analytic_invoice_line.py

@@ -11,7 +11,8 @@ def get_contract_line_inmobiliaria():
     line.price_unit,
     tmp.t_manzana,
     tmp.t_lote,
-    tmp.t_nro
+    tmp.t_nro,
+    tmp.t_propietario
     FROM account_analytic_invoice_line AS line
     LEFT JOIN product_product AS product
     ON line.product_id = product.id
@@ -31,6 +32,7 @@ def get_contract_line_inmobiliaria():
             't_manzana': j[5],
             't_lote': j[6],
             't_nro': j[7],
+            't_propietario':j[8],
 
         } for j in r.cr.fetchall()
     ]

+ 1 - 1
controller/main.py

@@ -71,7 +71,7 @@ class ReportController(http.Controller):
 
         })
 
-    #VENTAS
+    #VENTAS MENSUAL
     @http.route('/report-sale-inmobiliaria', auth='user', methods=['GET', 'POST'])
     def getSale(self, **kw):
         return make_gzip_response({

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

@@ -11,6 +11,7 @@ openerp.eiru_reports_inmobiliaria = function(instance) {
     report_comision_inmobiliaria(reporting);
     report_propiedades_inmobiliaria(reporting);
     report_ventas_inmobiliaria(reporting);
+    report_liquidacion_mensual_inmobiliaria(reporting);
 
   } catch (e) {
     // ignorar error
@@ -21,6 +22,7 @@ openerp.eiru_reports_inmobiliaria = function(instance) {
   instance.web.client_actions.add('eiru_reports_inmobiliaria.comision_inmobiliaria_action', 'instance.eiru_reports_inmobiliaria.ReportComisionWidget');
   instance.web.client_actions.add('eiru_reports_inmobiliaria.propiedades_inmobiliaria_action', 'instance.eiru_reports_inmobiliaria.ReportPropiedadesInmobiliariaWidget');
   instance.web.client_actions.add('eiru_reports_inmobiliaria.ventas_inmobiliaria_action', 'instance.eiru_reports_inmobiliaria.ReportVentasWidget');
+  instance.web.client_actions.add('eiru_reports_inmobiliaria.liquidacion_inmobiliaria_action', 'instance.eiru_reports_inmobiliaria.ReportLiquidacionMensualWidget');
 
 
 }

+ 303 - 0
static/src/js/pdf_inmobiliaria.js

@@ -123,6 +123,309 @@ function pdf_inmobiliaria(reporting) {
         pdfDoc.save(pdf_name + hoy + '.pdf');
       },
 
+      drawPDFInmobiliaria2: 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;
+        var cuota_interes,suma_comision_vendedor,suma_comision_inmobiliaria,suma_comision_total = 0;
+        var iva_vendedor, iva_empresa, iva_total,total_desc,total_propietario = 0;
+        var total_letter;
+
+
+
+        //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: 7
+            },
+            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');
+                  cuota_interes = opts.row.raw.cuota_interes;
+                  suma_comision_vendedor = opts.row.raw.suma_comision_vendedor;
+                  suma_comision_inmobiliaria = opts.row.raw.suma_comision_inmobiliaria;
+                  suma_comision_total = opts.row.raw.suma_comision_total;
+                  iva_vendedor = opts.row.raw.iva_vendedor;
+                  iva_empresa = opts.row.raw.iva_empresa;
+                  iva_total = opts.row.raw.iva_total;
+                  total_desc = opts.row.raw.total_desc;
+                  total_propietario = opts.row.raw.total_propietario;
+                  total_letter = opts.row.raw.total_letter;
+                }
+            },
+
+
+            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'
+                });
+            }
+        });
+        // CUADRO DE RESUMEN
+        // Linea 1
+        pdfDoc.setFontSize(8);
+        pdfDoc.rect(7, pdfDoc.autoTable.previous.finalY + 5, 75, 8, 'S');
+        pdfDoc.autoTableText("TOTAL RECAUDADO (Imp. Cuota + Interés)", 10, pdfDoc.autoTable.previous.finalY + 5 + 5, {
+            halign: 'left',
+            valign: 'middle'
+        });
+
+        pdfDoc.rect(82, pdfDoc.autoTable.previous.finalY + 5, 30, 8, 'S');
+        pdfDoc.autoTableText(cuota_interes, 110, pdfDoc.autoTable.previous.finalY + 5 + 5, {
+            halign: 'right',
+            valign: 'middle'
+        });
+
+        // Linea 2
+        pdfDoc.setFontStyle('normal');
+        pdfDoc.setFontSize(8);
+        pdfDoc.rect(7, pdfDoc.autoTable.previous.finalY + 13, 75, 8, 'S');
+        pdfDoc.autoTableText("Comisión Vendedor", 10, pdfDoc.autoTable.previous.finalY + 13 + 5, {
+            halign: 'left',
+            valign: 'middle'
+        });
+
+        pdfDoc.rect(82, pdfDoc.autoTable.previous.finalY + 13, 30, 8, 'S');
+        pdfDoc.autoTableText(suma_comision_vendedor, 110, pdfDoc.autoTable.previous.finalY + 13 + 5, {
+            halign: 'right',
+            valign: 'middle'
+        });
+
+        // Linea 3
+        pdfDoc.setFontSize(8);
+        pdfDoc.rect(7, pdfDoc.autoTable.previous.finalY + 21, 75, 8, 'S');
+        pdfDoc.autoTableText("Comisión Empresa", 10, pdfDoc.autoTable.previous.finalY + 21 + 5, {
+            halign: 'left',
+            valign: 'middle'
+        });
+
+        pdfDoc.rect(82, pdfDoc.autoTable.previous.finalY + 21, 30, 8, 'S');
+        pdfDoc.autoTableText(suma_comision_inmobiliaria, 110, pdfDoc.autoTable.previous.finalY + 21 + 5, {
+            halign: 'right',
+            valign: 'middle'
+        });
+
+        // Linea 4
+        pdfDoc.setFontStyle('bold');
+        pdfDoc.setFontSize(8);
+        pdfDoc.rect(7, pdfDoc.autoTable.previous.finalY + 29, 75, 8, 'S');
+        pdfDoc.autoTableText("Total Comisión Desc", 10, pdfDoc.autoTable.previous.finalY + 29 + 5, {
+            halign: 'left',
+            valign: 'middle'
+        });
+
+        pdfDoc.rect(82, pdfDoc.autoTable.previous.finalY + 29, 30, 8, 'S');
+        pdfDoc.autoTableText(suma_comision_total, 110, pdfDoc.autoTable.previous.finalY + 29 + 5, {
+            halign: 'right',
+            valign: 'middle'
+        });
+
+        // Linea 5
+        pdfDoc.setFontStyle('normal');
+        pdfDoc.setFontSize(8);
+        pdfDoc.rect(7, pdfDoc.autoTable.previous.finalY + 37, 75, 8, 'S');
+        pdfDoc.autoTableText("Impuesto al valor agregado (IVA)", 10, pdfDoc.autoTable.previous.finalY + 37 + 5, {
+            halign: 'left',
+            valign: 'middle'
+        });
+
+        pdfDoc.rect(82, pdfDoc.autoTable.previous.finalY + 37, 30, 8, 'S');
+        pdfDoc.autoTableText("-", 110, pdfDoc.autoTable.previous.finalY + 37 + 5, {
+            halign: 'right',
+            valign: 'middle'
+        });
+
+        // Linea 6
+        pdfDoc.setFontSize(8);
+        pdfDoc.rect(7, pdfDoc.autoTable.previous.finalY + 45, 75, 8, 'S');
+        pdfDoc.autoTableText("10% comisión por vendedor", 10, pdfDoc.autoTable.previous.finalY + 45 + 5, {
+            halign: 'left',
+            valign: 'middle'
+        });
+
+        pdfDoc.rect(82, pdfDoc.autoTable.previous.finalY + 45, 30, 8, 'S');
+        pdfDoc.autoTableText(iva_vendedor, 110, pdfDoc.autoTable.previous.finalY + 45 + 5, {
+            halign: 'right',
+            valign: 'middle'
+        });
+
+        // Linea 7
+        pdfDoc.setFontSize(8);
+        pdfDoc.rect(7, pdfDoc.autoTable.previous.finalY + 53, 75, 8, 'S');
+        pdfDoc.autoTableText("10% comisión por empresa", 10, pdfDoc.autoTable.previous.finalY + 53 + 5, {
+            halign: 'left',
+            valign: 'middle'
+        });
+
+        pdfDoc.rect(82, pdfDoc.autoTable.previous.finalY + 53, 30, 8, 'S');
+        pdfDoc.autoTableText(iva_empresa, 110, pdfDoc.autoTable.previous.finalY + 53 + 5, {
+            halign: 'right',
+            valign: 'middle'
+        });
+
+        // Linea 8
+        pdfDoc.setFontStyle('bold');
+        pdfDoc.setFontSize(8);
+        pdfDoc.rect(7, pdfDoc.autoTable.previous.finalY + 61, 75, 8, 'S');
+        pdfDoc.autoTableText("Total desc por IVA", 10, pdfDoc.autoTable.previous.finalY + 61 + 5, {
+            halign: 'left',
+            valign: 'middle'
+        });
+
+        pdfDoc.rect(82, pdfDoc.autoTable.previous.finalY + 61, 30, 8, 'S');
+        pdfDoc.autoTableText(iva_total, 110, pdfDoc.autoTable.previous.finalY + 61 + 5, {
+            halign: 'right',
+            valign: 'middle'
+        });
+
+        // Linea 9
+        pdfDoc.setFontSize(8);
+        pdfDoc.rect(7, pdfDoc.autoTable.previous.finalY + 69, 75, 8, 'S');
+        pdfDoc.autoTableText("Total a descontar", 10, pdfDoc.autoTable.previous.finalY + 69 + 5, {
+            halign: 'left',
+            valign: 'middle'
+        });
+
+        pdfDoc.rect(82, pdfDoc.autoTable.previous.finalY + 69, 30, 8, 'S');
+        pdfDoc.autoTableText(total_desc, 110, pdfDoc.autoTable.previous.finalY + 69 + 5, {
+            halign: 'right',
+            valign: 'middle'
+        });
+
+        // Linea 10
+        pdfDoc.setFontSize(8);
+        pdfDoc.rect(7, pdfDoc.autoTable.previous.finalY + 77, 75, 8, 'S');
+        pdfDoc.autoTableText("Total a recibir por el propietario", 10, pdfDoc.autoTable.previous.finalY + 77 + 5, {
+            halign: 'left',
+            valign: 'middle'
+        });
+
+        pdfDoc.rect(82, pdfDoc.autoTable.previous.finalY + 77, 30, 8, 'S');
+        pdfDoc.autoTableText(total_propietario, 110, pdfDoc.autoTable.previous.finalY + 77 + 5, {
+            halign: 'right',
+            valign: 'middle'
+        });
+
+        var letter = String.fromCharCode(15000);
+        // Linea 11
+
+        pdfDoc.setFontStyle('normal');
+        pdfDoc.setFontSize(8);
+        pdfDoc.rect(7, pdfDoc.autoTable.previous.finalY + 85, 75, 8, 'S');
+        pdfDoc.autoTableText("Total en letras", 10, pdfDoc.autoTable.previous.finalY + 85 + 5, {
+            halign: 'left',
+            valign: 'middle'
+        });
+
+
+        // pdfDoc.rect(82, pdfDoc.autoTable.previous.finalY + 85, 30, 8,);
+        pdfDoc.autoTableText(total_letter, 90, pdfDoc.autoTable.previous.finalY + 85 + 5, {
+            halign: 'left',
+            valign: 'middle',
+        });
+
+
+        // FIN CUADRO DE RESUMEN
+
+
+        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');

+ 772 - 0
static/src/js/reports/report_liquidacion_mensual_inmobiliaria.js

@@ -0,0 +1,772 @@
+function report_liquidacion_mensual_inmobiliaria(reporting){
+    "use strict";
+
+    var model = openerp;
+
+    reporting.ReportLiquidacionMensualWidget = reporting.Base.extend({
+        template: 'ReportLiquidacionMensual',
+        rowsData :[],
+        content :[],
+        modules: ['point_of_sale','eiru_account_interest'],
+
+        events:{
+            'click #generate' : 'fetchGenerate',
+            'change #current-company' : 'updateSelections',
+            'change #current-date' : 'ShowDateRange',
+            'click .print-report':'clickOnAction',
+        },
+
+        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();
+        },
+
+        checkModel : function(model){
+            var self = this;
+            return _.filter(self.IrModuleModule,function(item){
+                return item.name === model;
+            });
+        },
+
+        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');
+            }
+        },
+
+        fetchInitial: function () {
+            var self = this;
+            self.fetchInitialSQL().then(function (InitialSQL) {
+                return InitialSQL;
+            }).then(function(InitialSQL) {
+                /*
+                =================================
+                    RES COMPANY
+                =================================
+                */
+                self.ResCompany = InitialSQL.companies;
+                self.CompanyLogo = InitialSQL.logo;
+                if(self.ResCompany.length > 1){
+                    self.$el.find('#current-company').append('<option value="9999999">Todas las empresas</option>');
+                    _.each(self.ResCompany,function(item){
+                        self.$el.find('#current-company').append('<option value="' + item.id + '">' + item.name + '</option>');
+                    });
+                }else{
+                    self.$el.find('.company').css('display','none');
+                }
+                /*
+                =================================
+                    RES STORE
+                =================================
+                */
+                self.ResStore = InitialSQL.stores;
+                if(self.ResStore.length > 1){
+                    self.$el.find('#current-store').append('<option value="9999999">Todas las sucursales</option>');
+                    _.each(self.ResStore,function(item){
+                        self.$el.find('#current-store').append('<option value="' + item.id + '">' + item.name + '</option>');
+                    });
+                }else{
+                    self.$el.find('.store').css('display','none');
+                }
+                /*
+                =================================
+                    RES PARTNER
+                =================================
+                */
+                self.ResPartner = InitialSQL.supplier;
+                if(self.ResPartner.length > 0){
+                    self.$el.find('#current-supplier').append('<option value="9999999">Todas los propietarios</option>');
+                    _.each(self.ResPartner,function(item){
+                        self.$el.find('#current-supplier').append('<option value="' + item.id + '">' + item.name + '</option>');
+                    });
+                }else{
+                    self.$el.find('.supplier').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.fethIrModuleModule();
+            }).then(function(IrModuleModule) {
+                self.IrModuleModule = IrModuleModule;
+                return self.fethCheckType();
+            });
+            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.fetchDataSQL().then(function(DataSQL) {
+                return DataSQL;
+            }).then(function (DataSQL) {
+
+                self.AccountInvoice = DataSQL.invoices;
+                self.AccountInvoiceLine = DataSQL.invoice_line;
+                self.Contrato = DataSQL.contracts;
+                self.ContractLine = DataSQL.contract_line;
+
+                return self.fetchAccountMoveLine();
+            }).then(function(MoveLine){
+              self.MoveLine = MoveLine;
+              return self.fetchAccountInterest();
+          }).then(function(AccountInterest){
+              self.AccountInterest = AccountInterest;
+              return self.fetchAccountInterestLine();
+          }).then(function(AccountInterestLine){
+              self.AccountInterestLine = AccountInterestLine;
+              return self.BuildTable();
+            });
+        },
+
+        fetchInitialSQL: function() {
+            var self = this;
+            var data = $.get('/report-filter-data-inmobiliaria');
+            return data;
+        },
+
+        fetchDataSQL: function() {
+            var self = this;
+            var data = $.get('/report-sale-inmobiliaria');
+            return data;
+        },
+
+        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;
+        },
+
+        fetchAccountInterest: function () {
+            var self = this;
+            var defer = $.Deferred();
+            var domain = [];
+            var field =['id', 'name', 'reference','invoice_id','state','customer_id','date'];
+            var AccountInterest = new model.web.Model('account.interest');
+            AccountInterest.query(field).filter(domain).all().then(function (results) {
+                defer.resolve(results);
+            });
+            return defer;
+        },
+
+        fetchAccountInterestLine: function () {
+            var self = this;
+            var defer = $.Deferred();
+            var domain = [];
+            var field =['id', 'interest_id', 'amount_interest','state'];
+            var AccountInterestLine = new model.web.Model('account.interest.line');
+            AccountInterestLine.query(field).filter(domain).all().then(function (results) {
+                defer.resolve(results);
+            });
+            return defer;
+        },
+
+
+        fethIrModuleModule: function(){
+            var self = this;
+            var defer = $.Deferred();
+            var fields = ['name','id'];
+            var domain=[['state','=','installed'],['name','in',self.modules]];
+            var IrModuleModule = new model.web.Model('ir.module.module');
+            IrModuleModule.query(fields).filter(domain).all().then(function(results){
+                defer.resolve(results);
+            });
+            return defer;
+        },
+
+        /*=====================================================================
+            Check type
+        =====================================================================*/
+        fethCheckType: function(){
+            var self = this;
+            var modules = self.checkModel('point_of_sale');
+            if(modules.length == 0){
+                self.$el.find('.type').css('display','none');
+            }
+        },
+
+
+        fetchAccountMoveLine: function (){
+          var self = this;
+          var defer = $.Deferred();
+          var domain = [];
+          var field =['id', 'reconcile_ref', 'move_id','date','credit','invoice','period_id'];
+          var AccountMoveLine = new model.web.Model('account.move.line');
+          AccountMoveLine.query(field).filter(domain).all().then(function (results) {
+              defer.resolve(results);
+          });
+          return defer;
+        },
+
+        /*====================================================================
+            UPDATE SELECTIONS
+        ====================================================================*/
+        updateSelections: function () {
+            var self = this;
+            var store;
+            var company = self.$el.find('#current-company').val();
+            if(company != 9999999){
+                store = self.$el.find('#current-store').empty();
+                self.$el.find('#current-store').append('<option value="9999999">Todas las sucursales</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>');
+                    }
+                });
+            }else{
+                store = self.$el.find('#current-store').empty();
+                self.$el.find('#current-store').append('<option value="9999999">Todas las sucursales</option>');
+                _.each(self.ResStore,function(item){
+                    self.$el.find('#current-store').append('<option value="' + item.id + '">' + item.name + '</option>');
+                });
+            }
+        },
+
+        getAccountInvoice:function(origin) {
+            var self = this;
+            var content = self.AccountInvoice;
+            content = _.flatten(_.filter(content,function (item) {
+                return item.origin == origin;
+            }));
+
+            return content;
+        },
+
+        getStoreName:function(store_id){
+          var self = this;
+          var ResStore =  _.filter(self.ResStore,function (item) {
+                  return item.id == store_id;
+          });
+          return ResStore[0].name;
+        },
+
+        getAccountInvoiceLine:function(invoice_id){
+          var self = this;
+          var supplier = self.$el.find('#current-supplier').val();
+
+          var AccountInvoiceLine =  _.filter(self.AccountInvoiceLine,function (item) {
+                  return item.invoice_id == invoice_id;
+          });
+          if (supplier & supplier != 9999999){
+            AccountInvoiceLine = _.flatten(_.filter(AccountInvoiceLine,function (item) {
+                return item.t_propietario == supplier;
+            }));
+          }
+
+          return AccountInvoiceLine;
+        },
+
+
+        getContracts:function(){
+          var self = this;
+          var content = self.Contrato;
+          return content;
+        },
+
+        getContractLine:function(contract_id){
+          var self = this;
+          var ContractLine = _.filter(self.ContractLine,function (item) {
+              return item.analytic_account_id == contract_id;
+          });
+
+          return ContractLine;
+        },
+
+        getUltimoPago:function(move_ids){
+          var self = this;
+          var ref = [];
+          var fechas = [];
+
+          _.each(move_ids,function(item){
+            _.each(self.MoveLine, function(x){
+              if(x.move_id[0] == item && x.reconcile_ref != false){
+                ref.push(x.reconcile_ref)
+              }
+            })
+          });
+
+          _.each(ref,function(item){
+            _.each(self.MoveLine, function(x){
+              if(x.reconcile_ref == item && x.credit > 0){
+                fechas.push(x.date)
+              }
+            })
+          });
+
+          fechas.sort(function (a, b) {
+              if (a> b) {
+                  return -1;
+              }
+              if (a < b) {
+                  return 1;
+              }
+              return 0;
+          });
+
+          return fechas[0]
+        },
+
+        getFechaPago:function(move_id){
+          var self = this;
+          var ref = [];
+          var move = [];
+
+            _.each(self.MoveLine, function(x){
+              if(x.move_id[0] == move_id && x.reconcile_ref != false){
+                ref.push(x.reconcile_ref)
+              }
+            })
+
+          _.each(ref,function(item){
+            _.each(self.MoveLine, function(x){
+              if(x.reconcile_ref == item && x.credit > 0){
+                move.push(x)
+              }
+            })
+          });
+
+          return move
+        },
+
+        getInterest:function(invoice_id){
+
+          var self = this;
+          var suma = 0;
+          var Interes = _.filter(self.AccountInterest,function (item) {
+              return item.invoice_id[0] == invoice_id;
+          });
+
+          _.each(Interes, function(line){
+
+            var line_ids = _.filter(self.AccountInterestLine,function (item) {
+                return item.interest_id[0] == line.id;
+            });
+
+            _.each(line_ids, function(item){
+              suma = suma + item.amount_interest;
+            });
+          });
+
+          return suma
+        },
+
+
+        BuildTable: function(){
+            var self = this;
+            var data = [];
+            var CurrencyBase = self.ResCompany[0].currency_id;
+            var Contrato = self.getContracts();
+            var period = self.$el.find('#current-period').val();
+            var supplier = self.$el.find('#current-supplier').val();
+
+            _.each(Contrato, function(item){
+              if(item.state == "open"){ var estado = "En curso"};
+              if(item.state == "pending"){ var estado = "A renovar"};
+              if(item.state == "close"){ var estado = "Cerrado"};
+              if(item.state == "cancelled"){ var estado = "Cancelado"};
+
+              var AccountInvoice = self.getAccountInvoice(item.code)
+              var AccountInvoicePaid = _.filter(AccountInvoice,function(x){
+                return x.state == 'paid'
+              });
+
+
+                var cuotas_pagadas = 0;
+                var cuotas_pagadas_mes = 0;
+                var cuotas_atrasadas = 0;
+                var interes = 0;
+                var suma_interes = 0;
+
+
+                var paid_move_ids = _.flatten(_.map(_.filter(AccountInvoicePaid,function(item){
+                    return item.move_id != null;
+                }), function(map){
+                    return map.move_id;
+                }));
+
+                var ultimo_pago = self.getUltimoPago(paid_move_ids);
+
+                _.each(AccountInvoicePaid,function(x){
+                  cuotas_pagadas = cuotas_pagadas + 1;
+                });
+
+                _.each(_.filter(AccountInvoice,function(x){
+                  return x.state == 'open' || x.state == 'draft'
+                }),function(each){
+                  cuotas_atrasadas = cuotas_atrasadas + 1;
+                });
+
+                _.each(_.filter(AccountInvoicePaid,function(item){
+                  return item.move_id != null;
+                }), function(a){
+                  var fecha_pago = self.getFechaPago(a.move_id);
+                  a['fecha_pago'] = fecha_pago[0].date;
+                  a['period_fecha_pago'] = fecha_pago[0].period_id;
+                });
+
+
+                var suma_comision_inmobiliaria = 0;
+                var suma_comision_vendedor = 0;
+                var suma_comision_total = 0;
+                var owner;
+                var saldo = 0;
+
+                if(period && period != 9999999){
+                  AccountInvoicePaid = _.flatten(_.filter(AccountInvoicePaid,function (item) {
+                        return item.period_fecha_pago[0] == period;
+                    }));
+                }
+
+                _.each(AccountInvoicePaid, function(c){
+
+                  interes = self.getInterest(c.invoice_id);
+                  suma_interes = suma_interes + interes;
+                  cuotas_pagadas_mes = cuotas_pagadas_mes + 1;
+
+                  var AccountInvoiceLine = self.getAccountInvoiceLine(c.invoice_id);
+                  _.each(AccountInvoiceLine, function(line){
+                    suma_comision_inmobiliaria = suma_comision_inmobiliaria + ((line.subtotal * line.comision_inmobiliaria)/100)
+                    suma_comision_vendedor = suma_comision_vendedor + ((line.subtotal * line.comision_vendedor)/100)
+                    suma_comision_total = suma_comision_total + ((line.subtotal * line.comision_total)/100)
+                    owner = line.t_propietario;
+                    saldo = (line.price_unit * cuotas_pagadas_mes) + suma_interes - suma_comision_total;
+                  });
+                });
+
+
+              var contract_line = self.getContractLine(item.id)
+              if(item.cuota_total > 1){var plazo = item.cuota_total}
+              else{ var plazo = "Contado"}
+
+              _.each(contract_line, function(line){
+
+                if (supplier & supplier != 9999999){
+                  if(line.t_propietario == supplier){
+                    data.push({
+                        id:item.id,
+                        t_nro: line.t_nro,
+                        t_manzana: line.t_manzana,
+                        t_lote:line.t_lote,
+                        partner_name: item.partner_name,
+                        date_start: moment(item.date_start).format('DD/MM/YYYY'),
+                        precio_cuota:accounting.formatMoney(line.price_unit*cuotas_pagadas_mes, '', CurrencyBase.decimal_places, CurrencyBase.thousands_separator, CurrencyBase.decimal_separator),
+                        interes:accounting.formatMoney(suma_interes, '', CurrencyBase.decimal_places, CurrencyBase.thousands_separator, CurrencyBase.decimal_separator),
+
+                        cuota_total:plazo,
+                        ultimo_pago:ultimo_pago != null ? moment(ultimo_pago).format('DD/MM/YYYY') : "",
+                        cuotas_pagadas: cuotas_pagadas,
+                        cuotas_atrasadas: cuotas_atrasadas,
+                        state: estado,
+
+                        suma_comision_vendedor:accounting.formatMoney(suma_comision_vendedor, '', CurrencyBase.decimal_places, CurrencyBase.thousands_separator, CurrencyBase.decimal_separator),
+                        suma_comision_inmobiliaria:accounting.formatMoney(suma_comision_inmobiliaria, '', CurrencyBase.decimal_places, CurrencyBase.thousands_separator, CurrencyBase.decimal_separator),
+                        suma_comision_total:accounting.formatMoney(suma_comision_total, '', CurrencyBase.decimal_places, CurrencyBase.thousands_separator, CurrencyBase.decimal_separator),
+                        saldo:accounting.formatMoney(saldo, '', CurrencyBase.decimal_places, CurrencyBase.thousands_separator, CurrencyBase.decimal_separator),
+
+
+                        /*
+                        ===========================
+                            NO FORMAT
+                        ===========================
+                        */
+                        date_no_format: moment(ultimo_pago).format('YYYY-MM-DD'),
+                        precio_cuota_no_format: line.price_unit*cuotas_pagadas_mes,
+                        interes_no_format:suma_interes,
+                        suma_comision_vendedor_no_format: suma_comision_vendedor,
+                        suma_comision_inmobiliaria_no_format: suma_comision_inmobiliaria,
+                        suma_comision_total_no_format: suma_comision_total,
+                        saldo_no_format: saldo,
+
+                        /*
+                        ===========================
+                            FOOTER
+                        ===========================
+                        */
+                        decimal_places:CurrencyBase.decimal_places,
+                        thousands_separator:CurrencyBase.thousands_separator,
+                        decimal_separator:CurrencyBase.decimal_separator,
+                    });
+                  }
+                  }else {
+                    data.push({
+                        id:item.id,
+                        t_nro: line.t_nro,
+                        t_manzana: line.t_manzana,
+                        t_lote:line.t_lote,
+                        partner_name: item.partner_name,
+                        date_start: moment(item.date_start).format('DD/MM/YYYY'),
+                        precio_cuota:accounting.formatMoney(line.price_unit*cuotas_pagadas_mes, '', CurrencyBase.decimal_places, CurrencyBase.thousands_separator, CurrencyBase.decimal_separator),
+                        interes:accounting.formatMoney(suma_interes, '', CurrencyBase.decimal_places, CurrencyBase.thousands_separator, CurrencyBase.decimal_separator),
+
+                        cuota_total:plazo,
+                        ultimo_pago:ultimo_pago != null ? moment(ultimo_pago).format('DD/MM/YYYY') : "",
+                        cuotas_pagadas: cuotas_pagadas,
+                        cuotas_atrasadas: cuotas_atrasadas,
+                        state: estado,
+
+                        suma_comision_vendedor:accounting.formatMoney(suma_comision_vendedor, '', CurrencyBase.decimal_places, CurrencyBase.thousands_separator, CurrencyBase.decimal_separator),
+                        suma_comision_inmobiliaria:accounting.formatMoney(suma_comision_inmobiliaria, '', CurrencyBase.decimal_places, CurrencyBase.thousands_separator, CurrencyBase.decimal_separator),
+                        suma_comision_total:accounting.formatMoney(suma_comision_total, '', CurrencyBase.decimal_places, CurrencyBase.thousands_separator, CurrencyBase.decimal_separator),
+                        saldo:accounting.formatMoney(saldo, '', CurrencyBase.decimal_places, CurrencyBase.thousands_separator, CurrencyBase.decimal_separator),
+
+
+                        /*
+                        ===========================
+                            NO FORMAT
+                        ===========================
+                        */
+                        date_no_format: moment(ultimo_pago).format('YYYY-MM-DD'),
+                        precio_cuota_no_format: line.price_unit*cuotas_pagadas_mes,
+                        interes_no_format:suma_interes,
+                        suma_comision_vendedor_no_format: suma_comision_vendedor,
+                        suma_comision_inmobiliaria_no_format: suma_comision_inmobiliaria,
+                        suma_comision_total_no_format: suma_comision_total,
+                        saldo_no_format: saldo,
+
+                        /*
+                        ===========================
+                            FOOTER
+                        ===========================
+                        */
+                        decimal_places:CurrencyBase.decimal_places,
+                        thousands_separator:CurrencyBase.thousands_separator,
+                        decimal_separator:CurrencyBase.decimal_separator,
+                    });
+
+                }
+
+              });
+            });
+
+
+            data.sort(function (a, b) {
+                if (a.date_no_format > b.date_no_format) {
+                    return -1;
+                }
+                if (a.date_no_format < b.date_no_format) {
+                    return 1;
+                }
+                return 0;
+            });
+
+
+            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();
+        },
+
+        loadTable:function(rowsTable){
+            var self = this;
+            self.rowsData = rowsTable;
+            var table = this.$el.find('#table');
+            table.bootstrapTable('load', rowsTable);
+        },
+
+        clickOnAction: function (e) {
+            var self = this;
+            var ResCompany;
+            var CurrencyBase;
+            var action = this.$el.find(e.target).val();
+            var company = $('#current-company').val();
+            if(company && company != 9999999){
+                ResCompany = _.flatten(_.filter(self.ResCompany,function (inv) {
+                    return inv.id == company;
+                }));
+                ResCompany = CompanyLogo[0];
+                CurrencyBase = ResCompany[0].currency_id;
+            }else{
+                ResCompany = self.CompanyLogo[0];
+                CurrencyBase = self.ResCompany[0].currency_id;
+            }
+
+            var getColumns=[];
+            var rows=[];
+            var table = this.$el.find("#table");
+            var column = table.bootstrapTable('getVisibleColumns');
+            var row = table.bootstrapTable('getData');
+
+            var price_unit = TotalCuota(row);
+            var interes = TotalInteres(row);
+            var suma_comision_vendedor = TotalComisionVendedor(row);
+            var suma_comision_inmobiliaria = TotalComisionEmpresa(row);
+            var suma_comision_total = TotalComision(row);
+            var saldo = TotalSaldo(row);
+            var cuota_interes = TotalCuotaInteres(row);
+            var iva_vendedor = TotalIvaVendedor(row);
+            var iva_empresa = TotalIvaEmpresa(row);
+            var iva_total = TotalIva(row);
+            var total_desc = TotalDescontar(row);
+            var total_propietario = TotalPropietario(row);
+
+            row.push({
+              t_nro:"Total",
+              precio_cuota:price_unit,
+              cuota_interes:cuota_interes,
+              interes:interes,
+              suma_comision_vendedor:suma_comision_vendedor,
+              suma_comision_inmobiliaria:suma_comision_inmobiliaria,
+              suma_comision_total:suma_comision_total,
+              saldo:saldo,
+              iva_vendedor: iva_vendedor,
+              iva_empresa: iva_empresa,
+              iva_total: iva_total,
+              total_desc:total_desc,
+              total_propietario:total_propietario[0],
+              total_letter:total_propietario[1],
+
+
+            });
+
+            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 = 'Liquidación Mensual de Cuotas Cobradas.';
+                var pdf_type = 'l';
+                var pdf_name = 'liquidacion_mensual_';
+
+                var pdf_columnStyles = {
+                    t_nro:{columnWidth: 10, halign:'center'},
+                    t_manzana:{columnWidth:11, halign:'center'},
+                    t_lote:{columnWidth: 10, halign:'center'},
+                    date_start:{columnWidth: 16,halign:'center'},
+                    ultimo_pago:{columnWidth: 16,halign:'center'},
+                    cuota_total:{columnWidth:18,align:'center'},
+                    cuotas_pagadas:{columnWidth: 16, halign:'center'},
+                    cuotas_atrasadas:{columnWidth: 16, halign:'center'},
+                    precio_cuota:{columnWidth: 16, halign:'right'},
+                    precio_cuota:{columnWidth: 16, halign:'right'},
+                    suma_comision_vendedor:{columnWidth: 18, halign:'right'},
+                    suma_comision_inmobiliaria:{columnWidth: 18, halign:'right'},
+                    suma_comision_total:{columnWidth: 18, halign:'right'},
+                    saldo:{columnWidth: 16, halign:'right'},
+                };
+                /*
+                ============================================================
+                    LLAMAR FUNCION DE IMPRESION
+                ============================================================
+                */
+                var filter = self.getFilter();
+                var pdf = new reporting.ReportPdfWidgetInmobiliaria(self);
+                pdf.drawPDFInmobiliaria2(
+                    _.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 supplier = self.$el.find('#current-supplier').val();
+            var period = self.$el.find('#current-period').val();
+
+            var filter = [];
+            if(company && company != 9999999){
+                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(supplier && supplier != 9999999){
+                var ResPartner = _.filter(self.ResPartner, function(item){
+                    return item.id == supplier;
+                });
+
+                filter.push({
+                    title:'Propietario',
+                    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,
+                });
+            }
+
+            return filter;
+        },
+    });
+}

+ 509 - 0
static/src/reports/report_liquidacion_mensual_inmobiliaria.xml

@@ -0,0 +1,509 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<template xml:space="preserve">
+    <t t-name="ReportLiquidacionMensual">
+        <div class="report_view">
+            <div class="reporting_page_header">
+                <h1 class="report_title"> Liquidación Mensual de Cuotas Cobradas </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 supplier filter-style">
+                        <label>Propietario</label>
+                        <select id="current-supplier" class="form-control form-control-sm">
+                        </select>
+                    </div>
+
+                    <div class="col-lg-3 period filter-style">
+                       <label>Fecha</label>
+                       <select id="current-period" class="form-control form-control-sm">
+                       </select>
+                   </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="myButton print-report" value="pdf">Imprimir Informe</button>
+                </div>
+                <div class="container"  style="width:90%;">
+                    <table id="table"
+                        data-pagination="true"
+                        data-toggle="table"
+                        data-toolbar="#toolbar"
+                        data-show-columns="true"
+                        data-classes="table"
+                        data-search="true"
+                        data-show-export="true"
+                        data-show-toggle="true"
+                        data-pagination-detail-h-align="left"
+                        data-buttons-class="oe_button myButton"
+                        data-show-pagination-switch="true"
+                        data-page-size="10"
+                        data-search-on-enter-key="true"
+                        data-undefined-text=" "
+                        data-pagination-v-align="top"
+                        data-show-footer="true"
+                        data-footer-style="footerStyle"
+                        >
+                        <thead style="background:none;">
+                            <tr>
+                                <th data-field="t_nro" data-align="left" data-width="40" data-footer-formatter="Totales">Nº</th>
+                                <th data-field="t_manzana" data-align="left" data-width="40">Manz.</th>
+                                <th data-field="t_lote" data-align="left" data-width="40">Lote</th>
+                                <th data-field="date_start" data-align="center" data-width="90">Fecha Inicial</th>
+                                <th data-field="ultimo_pago" data-align="center" data-width="90">Último Pago</th>
+                                <th data-field="cuota_total" data-align="center" data-width="70">Plazo</th>
+                                <th data-field="cuotas_pagadas" data-align="center" data-width="70">Cuotas Pagadas</th>
+                                <th data-field="cuotas_atrasadas" data-align="center" data-width="70">Cuotas Atrasadas</th>
+                                <th data-field="precio_cuota" data-align="right" data-width="70" data-footer-formatter="TotalCuota">Monto Cuota</th>
+                                <th data-field="interes" data-align="right" data-width="70" data-footer-formatter="TotalInteres">Interés</th>
+                                <th data-field="suma_comision_vendedor" data-align="center" data-width="70" data-footer-formatter="TotalComisionVendedor">Comisión Vendedor</th>
+                                <th data-field="suma_comision_inmobiliaria" data-align="center" data-width="70" data-footer-formatter="TotalComisionEmpresa">Comisión Empresa</th>
+                                <th data-field="suma_comision_total" data-align="center" data-width="70" data-footer-formatter="TotalComision">Desc Comisiones</th>
+                                <th data-field="saldo" data-align="center" data-width="70" data-footer-formatter="TotalSaldo">Saldo</th>
+                            </tr>
+                        </thead>
+                    </table>
+                </div>
+            </div>
+            <script>
+
+                <!--
+                    TOTAL
+                -->
+                function TotalCuota(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.precio_cuota_no_format;
+                    }), function(memo, num){
+                        return memo + num;
+                    },0);
+                    return accounting.formatNumber(total,decimal_places,thousands_separator,decimal_separator);
+                }
+
+                function TotalInteres(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.interes_no_format;
+                    }), function(memo, num){
+                        return memo + num;
+                    },0);
+                    return accounting.formatNumber(total,decimal_places,thousands_separator,decimal_separator);
+                }
+
+                function TotalComisionVendedor(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.suma_comision_vendedor_no_format;
+                    }), function(memo, num){
+                        return memo + num;
+                    },0);
+                    return accounting.formatNumber(total,decimal_places,thousands_separator,decimal_separator);
+                }
+
+                function TotalComisionEmpresa(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.suma_comision_inmobiliaria_no_format;
+                    }), function(memo, num){
+                        return memo + num;
+                    },0);
+                    return accounting.formatNumber(total,decimal_places,thousands_separator,decimal_separator);
+                }
+
+                function TotalComision(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.suma_comision_total_no_format;
+                    }), function(memo, num){
+                        return memo + num;
+                    },0);
+                    return accounting.formatNumber(total,decimal_places,thousands_separator,decimal_separator);
+                }
+
+                function TotalSaldo(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.saldo_no_format;
+                    }), function(memo, num){
+                        return memo + num;
+                    },0);
+                    return accounting.formatNumber(total,decimal_places,thousands_separator,decimal_separator);
+                }
+
+                function TotalCuotaInteres(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 total1 =  _.reduce(_.map(rowsTable,function(item){
+                        return item.precio_cuota_no_format;
+                    }), function(memo, num){
+                        return memo + num;
+                    },0);
+
+                    var total2 =  _.reduce(_.map(rowsTable,function(item){
+                        return item.interes_no_format;
+                    }), function(memo, num){
+                        return memo + num;
+                    },0);
+                    return accounting.formatNumber(total1+total2,decimal_places,thousands_separator,decimal_separator);
+                }
+
+                function TotalIvaVendedor(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.suma_comision_vendedor_no_format;
+                    }), function(memo, num){
+                        return memo + num;
+                    },0);
+
+                    return accounting.formatNumber(total*10/100,decimal_places,thousands_separator,decimal_separator);
+                }
+
+                function TotalIvaEmpresa(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.suma_comision_inmobiliaria_no_format;
+                    }), function(memo, num){
+                        return memo + num;
+                    },0);
+
+                    return accounting.formatNumber(total*10/100,decimal_places,thousands_separator,decimal_separator);
+                }
+
+                function TotalIva(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 total1 =  _.reduce(_.map(rowsTable,function(item){
+                        return item.suma_comision_vendedor_no_format;
+                    }), function(memo, num){
+                        return memo + num;
+                    },0);
+
+                    var total2 =  _.reduce(_.map(rowsTable,function(item){
+                        return item.suma_comision_inmobiliaria_no_format;
+                    }), function(memo, num){
+                        return memo + num;
+                    },0);
+
+                    var total3 = total1+total2;
+
+                    return accounting.formatNumber(total3*10/100,decimal_places,thousands_separator,decimal_separator);
+                }
+
+                function TotalDescontar(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 total1 =  _.reduce(_.map(rowsTable,function(item){
+                        return item.suma_comision_total_no_format;
+                    }), function(memo, num){
+                        return memo + num;
+                    },0);
+
+                    var total2 = total1*10/100;
+
+                    var total3 = total1+total2;
+                    return accounting.formatNumber(total3,decimal_places,thousands_separator,decimal_separator);
+                }
+
+                function TotalPropietario(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 total1 =  _.reduce(_.map(rowsTable,function(item){
+                        return item.precio_cuota_no_format;
+                    }), function(memo, num){
+                        return memo + num;
+                    },0);
+
+                    var total2 =  _.reduce(_.map(rowsTable,function(item){
+                        return item.interes_no_format;
+                    }), function(memo, num){
+                        return memo + num;
+                    },0);
+
+                    var total3 =  _.reduce(_.map(rowsTable,function(item){
+                        return item.suma_comision_total_no_format;
+                    }), function(memo, num){
+                        return memo + num;
+                    },0);
+
+                    var total4 = total3*10/100;
+
+                    var total5 = total1+total2-total3-total4;
+                    var letras = NumeroALetras(total5)
+
+                    return [accounting.formatNumber(total5,decimal_places,thousands_separator,decimal_separator), letras];
+                }
+                <!--
+                    FOOTER STYLE
+                -->
+                function footerStyle(row, index) {
+                    return {
+                        css: {
+                          "font-weight": "bold"
+                        }
+                    };
+                }
+
+                <!-- numero a letras -->
+                function Unidades(num){
+
+                  switch(num)
+                  {
+                    case 1: return "UN";
+                    case 2: return "DOS";
+                    case 3: return "TRES";
+                    case 4: return "CUATRO";
+                    case 5: return "CINCO";
+                    case 6: return "SEIS";
+                    case 7: return "SIETE";
+                    case 8: return "OCHO";
+                    case 9: return "NUEVE";
+                  }
+
+                  return "";
+                }
+
+                function Decenas(num){
+
+                  decena = Math.floor(num/10);
+                  unidad = num - (decena * 10);
+
+                  switch(decena)
+                  {
+                    case 1:
+                      switch(unidad)
+                      {
+                        case 0: return "DIEZ";
+                        case 1: return "ONCE";
+                        case 2: return "DOCE";
+                        case 3: return "TRECE";
+                        case 4: return "CATORCE";
+                        case 5: return "QUINCE";
+                        default: return "DIECI" + Unidades(unidad);
+                      }
+                    case 2:
+                      switch(unidad)
+                      {
+                        case 0: return "VEINTE";
+                        default: return "VEINTI" + Unidades(unidad);
+                      }
+                    case 3: return DecenasY("TREINTA", unidad);
+                    case 4: return DecenasY("CUARENTA", unidad);
+                    case 5: return DecenasY("CINCUENTA", unidad);
+                    case 6: return DecenasY("SESENTA", unidad);
+                    case 7: return DecenasY("SETENTA", unidad);
+                    case 8: return DecenasY("OCHENTA", unidad);
+                    case 9: return DecenasY("NOVENTA", unidad);
+                    case 0: return Unidades(unidad);
+                  }
+                }//Unidades()
+
+                function DecenasY(strSin, numUnidades){
+                  if (numUnidades > 0)
+                    return strSin + " Y " + Unidades(numUnidades)
+
+                  return strSin;
+                }//DecenasY()
+
+                function Centenas(num){
+
+                  centenas = Math.floor(num / 100);
+                  decenas = num - (centenas * 100);
+
+                  switch(centenas)
+                  {
+                    case 1:
+                      if (decenas > 0)
+                        return "CIENTO " + Decenas(decenas);
+                      return "CIEN";
+                    case 2: return "DOSCIENTOS " + Decenas(decenas);
+                    case 3: return "TRESCIENTOS " + Decenas(decenas);
+                    case 4: return "CUATROCIENTOS " + Decenas(decenas);
+                    case 5: return "QUINIENTOS " + Decenas(decenas);
+                    case 6: return "SEISCIENTOS " + Decenas(decenas);
+                    case 7: return "SETECIENTOS " + Decenas(decenas);
+                    case 8: return "OCHOCIENTOS " + Decenas(decenas);
+                    case 9: return "NOVECIENTOS " + Decenas(decenas);
+                  }
+
+                  return Decenas(decenas);
+                }//Centenas()
+
+                function Seccion(num, divisor, strSingular, strPlural){
+                  cientos = Math.floor(num / divisor)
+                  resto = num - (cientos * divisor)
+
+                  letras = "";
+
+                  if (cientos > 0)
+                    if (cientos > 1)
+                      letras = Centenas(cientos) + " " + strPlural;
+                    else
+                      letras = strSingular;
+
+                  if (resto > 0)
+                    letras += "";
+
+                  return letras;
+                }//Seccion()
+
+                function Miles(num){
+                  divisor = 1000;
+                  cientos = Math.floor(num / divisor)
+                  resto = num - (cientos * divisor)
+
+                  strMiles = Seccion(num, divisor, "MIL", "MIL");
+                  strCentenas = Centenas(resto);
+
+                  if(strMiles == "")
+                    return strCentenas;
+
+                  return strMiles + " " + strCentenas;
+
+                  //return Seccion(num, divisor, "UN MIL", "MIL") + " " + Centenas(resto);
+                }//Miles()
+
+                function Millones(num){
+                  divisor = 1000000;
+                  cientos = Math.floor(num / divisor)
+                  resto = num - (cientos * divisor)
+
+                  strMillones = Seccion(num, divisor, "UN MILLON", "MILLONES");
+                  strMiles = Miles(resto);
+
+                  if(strMillones == "")
+                    return strMiles;
+
+                  return strMillones + " " + strMiles;
+
+                  //return Seccion(num, divisor, "UN MILLON", "MILLONES") + " " + Miles(resto);
+                }//Millones()
+
+                function NumeroALetras(num,centavos){
+                  var data = {
+                    numero: num,
+                    enteros: Math.floor(num),
+                    centavos: (((Math.round(num * 100)) - (Math.floor(num) * 100))),
+                    letrasCentavos: "",
+                  };
+                  if(centavos == undefined || centavos==false) {
+                    data.letrasMonedaPlural="GUARANIES";
+                    data.letrasMonedaSingular="GUARANI";
+                  }else{
+                    data.letrasMonedaPlural="GUARANIES";
+                    data.letrasMonedaSingular="GUARANI";
+                  }
+
+                  if (data.centavos > 0)
+                    data.letrasCentavos = "CON " + NumeroALetras(data.centavos,true);
+
+                  if(data.enteros == 0)
+                    return "CERO " + data.letrasMonedaPlural + " " + data.letrasCentavos;
+                  if (data.enteros == 1)
+                    return Millones(data.enteros) + " " + data.letrasMonedaSingular + " " + data.letrasCentavos;
+                  else
+                    return Millones(data.enteros) + " " + data.letrasMonedaPlural + " " + data.letrasCentavos;
+                }
+
+            </script>
+        </div>
+    </t>
+</template>

+ 1 - 0
templates.xml

@@ -17,6 +17,7 @@
         <script type="text/javascript" src="/eiru_reports_inmobiliaria/static/src/js/reports/report_comision_inmobiliaria.js"/>
         <script type="text/javascript" src="/eiru_reports_inmobiliaria/static/src/js/reports/report_propiedades_inmobiliaria.js"/>
         <script type="text/javascript" src="/eiru_reports_inmobiliaria/static/src/js/reports/report_ventas_inmobiliaria.js"/>
+        <script type="text/javascript" src="/eiru_reports_inmobiliaria/static/src/js/reports/report_liquidacion_mensual_inmobiliaria.js"/>
 
 
       </xpath>

+ 5 - 0
views/actions.xml

@@ -21,5 +21,10 @@
 			<field name="name">Situación General de Ventas</field>
 			<field name="tag">eiru_reports_inmobiliaria.ventas_inmobiliaria_action</field>
 		</record>
+
+		<record id="liquidacion_inmobiliaria_action" model="ir.actions.client">
+			<field name="name">Liquidación Mensual de Cuotas Cobradas</field>
+			<field name="tag">eiru_reports_inmobiliaria.liquidacion_inmobiliaria_action</field>
+		</record>
 	</data>
 </openerp>

+ 1 - 0
views/menus.xml

@@ -10,6 +10,7 @@
     <menuitem id="comision" parent="inmobiliaria_parent_menu" name="Comisión sobre ventas" action="comision_inmobiliaria_action" sequence="2"/>
     <menuitem id="propiedades" parent="inmobiliaria_parent_menu" name="Propiedades" action="propiedades_inmobiliaria_action" sequence="3"/>
     <menuitem id="situacion_ventas" parent="inmobiliaria_parent_menu" name="Situación General de Ventas" action="ventas_inmobiliaria_action" sequence="4"/>
+    <menuitem id="liquidacion_mensual" parent="inmobiliaria_parent_menu" name="Liquidación Mensual de Cuotas Cobradas" action="liquidacion_inmobiliaria_action" sequence="5"/>
 
 
   </data>