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

+ 1 - 1
__openerp__.py

@@ -9,7 +9,7 @@
         'account',
         'eiru_assets',
         'eiru_reports',
-      	'eiru_inmobiliaria',
+        'eiru_inmobiliaria',
     ],
     'qweb': [
         'static/src/xml/*.xml',

+ 2 - 0
controller/helpers/__init__.py

@@ -5,11 +5,13 @@ from res_store import get_res_store_inmobiliaria
 from account_journal import get_account_journal_inmobiliaria
 from res_users import get_res_users_inmobiliaria
 from account_invoice import get_account_invoice_sale_type_inmobiliaria
+from account_invoice import get_account_invoice_sale_type_inmobiliaria2
 from account_invoice_line import get_account_invoice_line_out_invoice_inmobiliaria
 from pos_order import get_pos_order_inmobiliaria
 from res_partner import get_res_partner_inmobiliaria
 from res_partner import get_all_res_partner_inmobiliaria
 from res_partner import get_supplier_inmobiliaria
 from account_analytic_account import get_contracts_inmobiliaria
+from account_analytic_invoice_line import get_contract_line_inmobiliaria
 from product_template import get_product_template_inmobiliaria
 from product_template import get_property_state_inmobiliaria

+ 3 - 1
controller/helpers/account_analytic_account.py

@@ -15,7 +15,8 @@ def get_contracts_inmobiliaria():
             contract.recurring_rule_type,
             contract.nro_cuotas,
             contract.cuota_total,
-            partner.name
+            partner.name,
+            contract.date_start
         FROM account_analytic_account AS contract
         LEFT JOIN res_partner AS partner
         ON partner.id = contract.partner_id
@@ -37,5 +38,6 @@ def get_contracts_inmobiliaria():
             'nro_cuotas': j[9],
             'cuota_total': j[10],
             'partner_name': j[11],
+            'date_start':j[12],
         } for j in r.cr.fetchall()
     ]

+ 36 - 0
controller/helpers/account_analytic_invoice_line.py

@@ -0,0 +1,36 @@
+# -*- coding: utf-8 -*-
+from openerp.http import request as r
+
+def get_contract_line_inmobiliaria():
+    query = '''
+    SELECT
+    line.id,
+    line.analytic_account_id,
+    line.name,
+    line.quantity,
+    line.price_unit,
+    tmp.t_manzana,
+    tmp.t_lote,
+    tmp.t_nro
+    FROM account_analytic_invoice_line AS line
+    LEFT JOIN product_product AS product
+    ON line.product_id = product.id
+    LEFT JOIN product_template AS tmp
+    ON product.product_tmpl_id = tmp.id
+    '''
+
+    r.cr.execute(query)
+
+    return [
+        {
+            'id': j[0],
+            'analytic_account_id': j[1],
+            'name': j[2],
+            'quantity': j[3],
+            'price_unit': j[4],
+            't_manzana': j[5],
+            't_lote': j[6],
+            't_nro': j[7],
+
+        } for j in r.cr.fetchall()
+    ]

+ 33 - 0
controller/helpers/account_analytic_line.py

@@ -0,0 +1,33 @@
+# # -*- coding: utf-8 -*-
+# from openerp.http import request as r
+#
+# def get_contract_line_inmobiliaria():
+#     query = '''
+#     SELECT
+#     line.id,
+#     line.move_id,
+#     line.invoice_id,
+#     move_line.date_maturity
+#     FROM account_analytic_line AS line
+#     LEFT JOIN account_move_line AS move_line
+#     ON line.move_id = move_line.id
+#     LEFT JOIN account_move AS move
+#     ON move.id = move_line.move_id
+#     '''
+#
+#     r.cr.execute(query)
+#
+#     return [
+#         {
+#             'id': j[0],
+#             'analytic_account_id': j[1],
+#             'name': j[2],
+#             'quantity': j[3],
+#             'price_unit': j[4],
+#             't_manzana': j[5],
+#             't_lote': j[6],
+#             'move_line_id':j[7],
+#             'invoice_id':j[8],
+#
+#         } for j in r.cr.fetchall()
+#     ]

+ 211 - 2
controller/helpers/account_invoice.py

@@ -31,7 +31,8 @@ def get_account_invoice_sale_type_inmobiliaria(): #historico de venta
             customer.phone,
             customer.mobile,
             customer.email,
-            invoice.cuotas
+            invoice.cuotas,
+            invoice.move_id
         FROM account_invoice AS invoice
         LEFT JOIN res_store_journal_rel AS journal
         ON journal.journal_id = invoice.journal_id
@@ -98,7 +99,8 @@ def get_account_invoice_sale_type_inmobiliaria(): #historico de venta
             customer.phone,
             customer.mobile,
             customer.email,
-            invoice.cuotas
+            invoice.cuotas,
+            invoice.move_id
         FROM account_invoice AS invoice
         LEFT JOIN res_store_journal_rel AS journal
         ON journal.journal_id = invoice.journal_id
@@ -172,6 +174,7 @@ def get_account_invoice_sale_type_inmobiliaria(): #historico de venta
             'mobile':j[22],
             'email':j[23],
             'cuotas':j[24],
+            'move_id':j[25],
         } for j in r.cr.fetchall()]
     else:
         r.cr.execute(query1,(tuple([company_currency_rate,company_currency_rate])))
@@ -199,4 +202,210 @@ def get_account_invoice_sale_type_inmobiliaria(): #historico de venta
             'mobile':j[20],
             'email':j[21],
             'cuotas':j[22],
+            'move_id':j[23],
+        } for j in r.cr.fetchall()]
+
+
+def get_account_invoice_sale_type_inmobiliaria2(): #incluye facturas en borrador
+    company_currency_rate = r.env.user.company_id.currency_id.rate
+    validate_columns = '''
+        SELECT EXISTS (SELECT 1 FROM information_schema.columns
+        WHERE table_name='account_invoice' AND column_name in ('contado','credito'))'''
+
+    query1 = '''
+        SELECT
+        	invoice.id,
+        	rate.currency_id,
+        	invoice.date_invoice,
+        	invoice.type,
+        	invoice.origin,
+        	invoice.partner_id,
+        	invoice.user_id,
+        	invoice.amount_total * (%s / (array_agg(rate.rate ORDER BY rate.id DESC))[1]),
+            invoice.number,
+            partner.name,
+            customer.name,
+            invoice.amount_tax * (%s / (array_agg(rate.rate ORDER BY rate.id DESC))[1]),
+            invoice.state,
+            journal.store_id,
+            invoice.journal_id,
+            invoice.state,
+            invoice.company_id,
+            customer.ruc,
+            invoice.supplier_invoice_number,
+            customer.phone,
+            customer.mobile,
+            customer.email,
+            invoice.cuotas,
+            invoice.move_id
+        FROM account_invoice AS invoice
+        LEFT JOIN res_store_journal_rel AS journal
+        ON journal.journal_id = invoice.journal_id
+        LEFT JOIN res_currency_rate AS rate
+        ON rate.currency_id = invoice.currency_id
+        LEFT JOIN res_company AS company
+        ON company.id = invoice.company_id
+        LEFT JOIN res_users AS users
+        ON users.id = invoice.user_id
+        LEFT JOIN res_partner AS partner
+        ON partner.id = users.partner_id
+        LEFT JOIN res_partner AS customer
+        ON customer.id = invoice.partner_id
+        WHERE invoice.state NOT IN ('cancel')
+        AND invoice.type IN ('out_invoice')
+        GROUP BY
+        	invoice.id,
+        	rate.currency_id,
+        	invoice.date_invoice,
+        	invoice.type,
+        	invoice.origin,
+        	invoice.amount_total,
+        	invoice.partner_id,
+        	invoice.user_id,
+            invoice.amount_total,
+            partner.name,
+            customer.name,
+            invoice.amount_tax,
+            invoice.state,
+            journal.store_id,
+            invoice.journal_id,
+            invoice.state,
+            invoice.company_id,
+            customer.ruc,
+            invoice.supplier_invoice_number,
+            customer.phone,
+            customer.mobile,
+            customer.email
+    '''
+
+    query2 = '''
+        SELECT
+        	invoice.id,
+        	rate.currency_id,
+        	invoice.date_invoice,
+        	invoice.type,
+        	invoice.origin,
+        	invoice.partner_id,
+        	invoice.user_id,
+        	invoice.amount_total * (%s / (array_agg(rate.rate ORDER BY rate.id DESC))[1]),
+            invoice.number,
+            partner.name,
+            customer.name,
+            invoice.amount_tax * (%s / (array_agg(rate.rate ORDER BY rate.id DESC))[1]),
+            invoice.state,
+            journal.store_id,
+            invoice.journal_id,
+            invoice.state,
+            invoice.company_id,
+            customer.ruc,
+            invoice.supplier_invoice_number,
+            invoice.contado,
+            invoice.credito,
+            customer.phone,
+            customer.mobile,
+            customer.email,
+            invoice.cuotas,
+            invoice.move_id
+        FROM account_invoice AS invoice
+        LEFT JOIN res_store_journal_rel AS journal
+        ON journal.journal_id = invoice.journal_id
+        LEFT JOIN res_currency_rate AS rate
+        ON rate.currency_id = invoice.currency_id
+        LEFT JOIN res_company AS company
+        ON company.id = invoice.company_id
+        LEFT JOIN res_users AS users
+        ON users.id = invoice.user_id
+        LEFT JOIN res_partner AS partner
+        ON partner.id = users.partner_id
+        LEFT JOIN res_partner AS customer
+        ON customer.id = invoice.partner_id
+        WHERE invoice.state NOT IN ('cancel')
+        AND invoice.type IN ('out_invoice')
+        GROUP BY
+        	invoice.id,
+        	rate.currency_id,
+        	invoice.date_invoice,
+        	invoice.type,
+        	invoice.origin,
+        	invoice.amount_total,
+        	invoice.partner_id,
+        	invoice.user_id,
+            invoice.amount_total,
+            partner.name,
+            customer.name,
+            invoice.amount_tax,
+            invoice.state,
+            journal.store_id,
+            invoice.journal_id,
+            invoice.state,
+            invoice.company_id,
+            customer.ruc,
+            invoice.supplier_invoice_number,
+            customer.phone,
+            customer.mobile,
+            customer.email
+    '''
+
+    r.cr.execute(validate_columns)
+
+    for j in r.cr.fetchall():
+        column = j[0]
+
+    if column == True:
+        r.cr.execute(query2,(tuple([company_currency_rate,company_currency_rate])))
+        return [{
+            'invoice_id': j[0],
+            'currency_id': j[1],
+            'date': j[2],
+            'type': j[3],
+            'origin': j[4],
+            'customer_id':j[5],
+            'user_id':j[6],
+            'amount':j[7],
+            'number':j[8],
+            'user_name':j[9],
+            'customer_name':j[10],
+            'amount_tax':j[11],
+            'state':j[12],
+            'store_id':j[13],
+            'journal_id':j[14],
+            'state':j[15],
+            'company_id':j[16],
+            'customer_ruc':j[17],
+            'supplier_invoice_number':j[18],
+            'contado':j[19],
+            'credito':j[20],
+            'phone':j[21],
+            'mobile':j[22],
+            'email':j[23],
+            'cuotas':j[24],
+            'move_id':j[25],
+        } for j in r.cr.fetchall()]
+    else:
+        r.cr.execute(query1,(tuple([company_currency_rate,company_currency_rate])))
+        return [{
+            'invoice_id': j[0],
+            'currency_id': j[1],
+            'date': j[2],
+            'type': j[3],
+            'origin': j[4],
+            'customer_id':j[5],
+            'user_id':j[6],
+            'amount':j[7],
+            'number':j[8],
+            'user_name':j[9],
+            'customer_name':j[10],
+            'amount_tax':j[11],
+            'state':j[12],
+            'store_id':j[13],
+            'journal_id':j[14],
+            'state':j[15],
+            'company_id':j[16],
+            'customer_ruc':j[17],
+            'supplier_invoice_number':j[18],
+            'phone':j[19],
+            'mobile':j[20],
+            'email':j[21],
+            'cuotas':j[22],
+            'move_id':j[23],
         } for j in r.cr.fetchall()]

+ 3 - 1
controller/helpers/product_template.py

@@ -18,7 +18,8 @@ def get_product_template_inmobiliaria():
         tpt.list_price,
         tpt.categ_id,
         tpt.t_estado,
-        estado.name
+        estado.name,
+        tpt.t_nro
         FROM product_template AS tpt
         LEFT JOIN res_partner AS partner
         ON partner.id = tpt.t_propietario
@@ -46,6 +47,7 @@ def get_product_template_inmobiliaria():
             'categoria': j[12],
             'estado_id': j[13],
             'estado_name': j[14],
+            't_nro': j[15],
 
         } for j in r.cr.fetchall()
     ]

+ 12 - 0
controller/main.py

@@ -70,3 +70,15 @@ class ReportController(http.Controller):
             'supplier':hp.get_supplier_inmobiliaria(),
 
         })
+
+    #VENTAS
+    @http.route('/report-sale-inmobiliaria', auth='user', methods=['GET', 'POST'])
+    def getSale(self, **kw):
+        return make_gzip_response({
+            'invoices': hp.get_account_invoice_sale_type_inmobiliaria2(),
+            'invoice_line': hp.get_account_invoice_line_out_invoice_inmobiliaria(),
+            'orders': hp.get_pos_order_inmobiliaria(),
+            'partners': hp.get_res_partner_inmobiliaria(),
+            'contracts': hp.get_contracts_inmobiliaria(),
+            'contract_line': hp.get_contract_line_inmobiliaria(),
+        })

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

@@ -6,9 +6,11 @@ openerp.eiru_reports_inmobiliaria = function(instance) {
   reporting_base(instance, reporting);
 
   try {
+    pdf_inmobiliaria(reporting);
     report_contrato_inmobiliaria(reporting);
     report_comision_inmobiliaria(reporting);
     report_propiedades_inmobiliaria(reporting);
+    report_ventas_inmobiliaria(reporting);
 
   } catch (e) {
     // ignorar error
@@ -18,6 +20,7 @@ openerp.eiru_reports_inmobiliaria = function(instance) {
   instance.web.client_actions.add('eiru_reports_inmobiliaria.contrato_inmobiliaria_action', 'instance.eiru_reports_inmobiliaria.ReportInmobiliariaWidget');
   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');
 
 
 }

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

@@ -0,0 +1,144 @@
+function pdf_inmobiliaria(reporting) {
+    "use strict";
+
+    var model = openerp;
+
+    reporting.ReportPdfWidgetInmobiliaria = reporting.Base.extend({
+      drawPDFInmobiliaria: 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');
+                }
+            },
+
+            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'
+        });
+      },
+
+    })
+  }

+ 0 - 3
static/src/js/reports/report_comision_inmobiliaria.js

@@ -500,11 +500,8 @@ function report_comision_inmobiliaria(reporting){
                   supplier_invoice_number:self.valorNull(item.supplier_invoice_number),
                   origin:self.valorNull(item.origin),
                   number:item.number,
-                  type:'Pedido de venta',
                   date:moment(item.date).format('DD/MM/YYYY'),
                   seller_name:item.user_name,
-                  user_id:item.user_id,
-                  customer_ruc:self.valorNull(item.customer_ruc),
                   customer_name:self.valorNull(item.customer_name),
                   owner_name: self.getOwnerName(owner),
                   cuota: self.valorNull(item.cuotas),

+ 51 - 57
static/src/js/reports/report_contrato_inmobiliaria.js

@@ -195,18 +195,9 @@ function report_contrato_inmobiliaria(reporting){
             var hasta = self.$el.find('#to').val();
 
             if(state && state != 9999999){
-              var today = moment().format('YYYY-MM-DD');
-
-              if(state == 'open'){
                 content = _.flatten(_.filter(content,function (inv) {
-                    return inv.date > today || inv.date == null;
+                    return inv.state == state;
                 }));
-              }
-              if(state == 'pending'){
-                content = _.flatten(_.filter(content,function (inv) {
-                    return inv.date <= today;
-                }));
-              }
             }
 
             if(date && date != 9999999){
@@ -311,16 +302,22 @@ function report_contrato_inmobiliaria(reporting){
               if(item.recurring_rule_type == "monthly"){ var frecuencia = "Mensual"};
               if(item.recurring_rule_type == "yearly"){ var frecuencia = "Anual"};
 
+              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"};
+
               data.push({
                   id:item.id,
                   name: item.name,
                   code: item.code,
                   partner_name: item.partner_name,
-                  cuota_total:item.cuota_total,
-                  nro_cuotas: item.nro_cuotas,
+                  cuota_total: self.valorNull(item.cuota_total),
+                  nro_cuotas: self.valorNull(item.nro_cuotas),
                   recurring_next_date: item.recurring_next_date != null ? moment(item.recurring_next_date).format('DD/MM/YYYY'): "",
                   recurring_rule_type: frecuencia,
                   date: item.date != null ? moment(item.date).format('DD/MM/YYYY') : "",
+                  state: estado,
 
 
                   /*
@@ -381,11 +378,7 @@ function report_contrato_inmobiliaria(reporting){
             var column = table.bootstrapTable('getVisibleColumns');
             var row = table.bootstrapTable('getData');
 
-            var total = TotalFooter(row);
-            var sale_amount = TotalSaleAmount(row);
             row.push({
-                store:'Totales',
-                total:total,
             });
 
             if (action === 'pdf') {
@@ -405,26 +398,19 @@ function report_contrato_inmobiliaria(reporting){
                     CONFIGURACION DEL PDF
                 ============================================================
                 */
-                var pdf_title = 'Fidelización de Ventas.';
+                var pdf_title = 'Contratos';
                 var pdf_type = 'l';
-                var pdf_name = 'fidelizacion_de_ventas_';
+                var pdf_name = 'contratos_';
                 var pdf_columnStyles = {
-                    store:{columnWidth:17, halign:'left'},
-                    date:{columnWidth: 16, halign:'center'},
-                    type:{columnWidth: 16,halign:'left'},
-                    number:{halign:'left'},
-                    supplier_invoice_number:{halign:'left'},
-                    origin:{columnWidth: 15, halign:'left'},
-                    customer_name:{columnWidth: 25, halign:'left'},
-                    customer_ruc:{columnWidth: 15, halign:'left'},
-                    phone:{columnWidth: 19, halign:'right'},
-                    mobile:{columnWidth: 20, halign:'right'},
-                    email:{ halign:'right'},
-                    total:{columnWidth: 22, halign:'right'},
-                    sale_type:{columnWidth: 15, halign:'center'},
-                    pos:{columnWidth: 10,halign:'center'},
-                    sale:{columnWidth: 14, halign:'center'},
-                    sale_amount:{columnWidth: 22, halign:'right'},
+                    code:{columnWidth:18, halign:'left'},
+                    name:{halign:'left'},
+                    partner_name:{halign:'left'},
+                    nro_cuotas:{columnWidth:15, align:'center'},
+                    cuota_total:{columnWidth:15, align:'center'},
+                    recurring_next_date:{columnWidth: 18, halign:'left'},
+                    recurring_rule_type:{columnWidth: 20, halign:'left'},
+                    date:{columnWidth: 18, halign:'left'},
+                    state:{columnWidth: 19, halign:'left'},
                 };
                 /*
                 ============================================================
@@ -449,14 +435,13 @@ function report_contrato_inmobiliaria(reporting){
             var self = this;
             var company = self.$el.find('#current-company').val();
             var store = self.$el.find('#current-store').val();
-            var customer = self.$el.find('#current-customer').val();
             var state = self.$el.find('#current-state').val();
-            var type = self.$el.find('#current-type').val();
-            var sale_type = self.$el.find('#current-sale-type').val();
+            var next_date = self.$el.find('#current-next-date').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 != 9999999){
                 var ResCompany = _.filter(self.ResCompany, function(item){
                     return item.id == company;
@@ -476,15 +461,6 @@ function report_contrato_inmobiliaria(reporting){
                 });
             }
 
-            if(customer && customer != 9999999){
-                var ResPartner = _.filter(self.ResPartner, function(item){
-                    return item.id == customer;
-                });
-                filter.push({
-                    title:'Cliente',
-                    value: ResPartner[0].name,
-                });
-            }
             if(state && state != 9999999){
                 filter.push({
                     title: 'Estado',
@@ -492,18 +468,36 @@ function report_contrato_inmobiliaria(reporting){
                 });
             }
 
-            if(type && type != 9999999){
-                filter.push({
-                    title: 'Tipo de Factura',
-                    value: $('#current-type option:selected').text(),
-                });
-            }
 
-            if(sale_type && sale_type != 9999999){
-                filter.push({
-                    title: 'Tipo de Venta',
-                    value: $('#current-sale-type option:selected').text(),
+            if(next_date && next_date != 9999999){
+                moment.locale('es', {
+                    months: 'Enero_Febrero_Marzo_Abril_Mayo_Junio_Julio_Agosto_Septiembre_Octubre_Noviembre_Diciembre'.split('_'),
                 });
+
+                if(next_date == 'range'){
+                    filter.push({
+                        title: 'Fecha',
+                        value:  desde +' al '+hasta,
+                    });
+                }else {
+                    var fecha;
+                    if(next_date == 'today'){
+                        fecha = moment().format('DD/MM/YYYY');
+                    }
+                    if(next_date == 'yesterday'){
+                        fecha = moment().add(-1,'days').format('DD/MM/YYYY');
+                    }
+                    if(next_date == 'currentMonth'){
+                        fecha = moment().format('MMMM/YYYY');
+                    }
+                    if(next_date == 'lastMonth'){
+                        fecha = moment().add(-1,'months').format('MMMM/YYYY');
+                    }
+                    filter.push({
+                        title: 'Fecha Próx Factura',
+                        value:  fecha,
+                    });
+                }
             }
 
             if(date && date != 9999999){
@@ -531,7 +525,7 @@ function report_contrato_inmobiliaria(reporting){
                         fecha = moment().add(-1,'months').format('MMMM/YYYY');
                     }
                     filter.push({
-                        title: 'Fecha',
+                        title: 'Fecha Fin Contrato',
                         value:  fecha,
                     });
                 }

+ 661 - 0
static/src/js/reports/report_ventas_inmobiliaria.js

@@ -0,0 +1,661 @@
+function report_ventas_inmobiliaria(reporting){
+    "use strict";
+
+    var model = openerp;
+
+    reporting.ReportVentasWidget = reporting.Base.extend({
+        template: 'ReportVentasInmobiliaria',
+        rowsData :[],
+        content :[],
+        modules: ['point_of_sale'],
+
+        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.partner;
+                if(self.ResPartner.length > 0){
+                    self.$el.find('#current-customer').append('<option value="9999999">Todas los compradores</option>');
+                    _.each(self.ResPartner,function(item){
+                        self.$el.find('#current-customer').append('<option value="' + item.id + '">' + item.name + '</option>');
+                    });
+                }else{
+                    self.$el.find('.customer').css('display','none');
+                }
+
+                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.ResPartner = DataSQL.partners;
+                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.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;
+        },
+
+        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 domain = [];
+
+            var AccountMoveLine = new model.web.Model('account.move.line');
+            return AccountMoveLine.call('getAccountMoveLine',[domain], {
+                context: new model.web.CompoundContext()
+            });
+        },
+
+        /*====================================================================
+            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 AccountInvoiceLine =  _.filter(self.AccountInvoiceLine,function (item) {
+                  return item.invoice_id == invoice_id;
+          });
+          return AccountInvoiceLine;
+        },
+
+        getOwnerName:function(partner_id){
+          var self = this;
+          var ResPartners = _.filter(self.ResPartner,function (item) {
+              return item.id == partner_id;
+          });
+
+          if (ResPartners.length > 0){
+            return ResPartners[0].name;
+          }
+          else{
+            return ""
+          }
+        },
+
+        getContracts:function(){
+          var self = this;
+          var content = self.Contrato;
+          var state = self.$el.find('#current-state').val();
+          var customer = self.$el.find('#current-customer').val();
+
+
+          if(state && state != 9999999){
+                content = _.flatten(_.filter(content,function (item) {
+                    return item.state == state;
+                }));
+            }
+          if(customer && customer != 9999999){
+                content = _.flatten(_.filter(content,function (item) {
+                    return item.partner_id == customer;
+                }));
+            }
+
+          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]
+        },
+
+
+        BuildTable: function(){
+            var self = this;
+            var data = [];
+            var CurrencyBase = self.ResCompany[0].currency_id;
+            var date = self.$el.find('#current-date').val();
+            var desde = self.$el.find('#from').val();
+            var hasta = self.$el.find('#to').val();
+
+            var Contrato = self.getContracts();
+
+            _.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 cuotas_pagadas = 0;
+                var cuotas_atrasadas = 0;
+
+                var move_ids = _.flatten(_.map(_.filter(AccountInvoice,function(item){
+                    return item.move_id != null;
+                }), function(map){
+                    return map.move_id;
+                }));
+
+                var ultimo_pago = self.getUltimoPago(move_ids);
+
+                _.each(_.filter(AccountInvoice,function(x){
+                  return x.state == 'paid'
+                }),function(each){
+                  cuotas_pagadas = cuotas_pagadas + 1;
+                });
+
+                _.each(_.filter(AccountInvoice,function(x){
+                  return x.state == 'open' || x.state == 'draft'
+                }),function(each){
+                  cuotas_atrasadas = cuotas_atrasadas + 1;
+                });
+
+              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){
+
+
+                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, '', 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,
+
+
+                    /*
+                    ===========================
+                        NO FORMAT
+                    ===========================
+                    */
+                    date_no_format: moment(ultimo_pago).format('YYYY-MM-DD'),
+
+                    /*
+                    ===========================
+                        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;
+            });
+
+            if(date && date != 9999999){
+                if(date == 'range'){
+                    if(desde){
+                        date = desde.split('/');
+                        date = (date[2]+"-"+date[1]+"-"+date[0]);
+                        data = _.flatten(_.filter(data,function (inv) {
+                            var utc = moment.utc(inv.date_no_format,'YYYY-MM-DD h:mm:ss A');
+                            utc = moment(utc).format('YYYY-MM-DD');
+                            return moment(utc).format('YYYY-MM-DD') >= date;
+                        }));
+                    }
+                    if(hasta){
+                        date = hasta.split('/');
+                        date = (date[2]+"-"+date[1]+"-"+date[0]);
+                        data = _.flatten(_.filter(data,function (inv) {
+                            var utc = moment.utc(inv.date_no_format,'YYYY-MM-DD h:mm:ss A');
+                            utc = moment(utc).format('YYYY-MM-DD');
+                            return moment(utc).format('YYYY-MM-DD') <= date;
+                        }));
+                    }
+                }
+                if(date == 'today'){
+                    var today = moment().format('YYYY-MM-DD');
+                    data = _.flatten(_.filter(data,function (inv) {
+                        var utc = moment.utc(inv.date_no_format,'YYYY-MM-DD h:mm:ss A');
+                        utc = moment(utc).format('YYYY-MM-DD');
+                        return moment(utc).format('YYYY-MM-DD') === today;
+                    }));
+                }
+                if(date == 'yesterday'){
+                    var yesterday = moment().add(-1,'days').format('YYYY-MM-DD');
+                    data = _.flatten(_.filter(data,function (inv) {
+                        var utc = moment.utc(inv.date_no_format,'YYYY-MM-DD h:mm:ss A');
+                        utc = moment(utc).format('YYYY-MM-DD');
+                        return moment(utc).format('YYYY-MM-DD') === yesterday;
+                    }));
+                }
+                if(date == 'currentMonth'){
+                    var currentMonth = moment().format('YYYY-MM');
+                    data = _.flatten(_.filter(data,function (inv) {
+                        var utc = moment.utc(inv.date_no_format,'YYYY-MM-DD h:mm:ss A');
+                        utc = moment(utc).format('YYYY-MM-DD');
+                        return moment(utc).format('YYYY-MM') === currentMonth;
+                    }));
+                }
+                if(date == 'lastMonth'){
+                    var lastMonth = moment().add(-1,'months').format('YYYY-MM');
+                    data = _.flatten(_.filter(data,function (inv) {
+                        var utc = moment.utc(inv.date_no_format,'YYYY-MM-DD h:mm:ss A');
+                        utc = moment(utc).format('YYYY-MM-DD');
+                        return moment(utc).format('YYYY-MM') === lastMonth;
+                    }));
+                }
+            }
+
+            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');
+
+
+            row.push({
+
+            });
+
+            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 = 'Situación General de ventas.';
+                var pdf_type = 'l';
+                var pdf_name = 'situacion_general_ventas_';
+
+                var pdf_columnStyles = {
+                    t_nro:{columnWidth: 15, halign:'center'},
+                    t_manzana:{columnWidth:18, halign:'center'},
+                    t_lote:{columnWidth: 15, halign:'center'},
+                    partner_name:{ halign:'left'},
+                    date_start:{columnWidth: 18,halign:'center'},
+                    ultimo_pago:{columnWidth: 18,halign:'center'},
+                    cuota_total:{columnWidth:18,align:'center'},
+                    cuotas_pagadas:{columnWidth: 20, halign:'center'},
+                    cuotas_atrasadas:{columnWidth: 20, halign:'center'},
+                    precio_cuota:{columnWidth: 20, halign:'right'},
+                    state:{columnWidth: 18, halign:'center'},
+                };
+                /*
+                ============================================================
+                    LLAMAR FUNCION DE IMPRESION
+                ============================================================
+                */
+                var filter = self.getFilter();
+                var pdf = new reporting.ReportPdfWidgetInmobiliaria(self);
+                pdf.drawPDFInmobiliaria(
+                    _.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 user = self.$el.find('#current-user').val();
+            var customer = self.$el.find('#current-customer').val();
+            var state = self.$el.find('#current-state').val();
+            var type = self.$el.find('#current-type').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 != 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(user && user != 9999999){
+                var ResUser = _.filter(self.ResUsers, function(item){
+                    return item.id == user;
+                });
+                filter.push({
+                    title:'Vendedor',
+                    value: ResUser[0].name,
+                });
+            }
+            if(customer && customer != 9999999){
+                var ResPartner = _.filter(self.ResPartner, function(item){
+                    return item.id == customer;
+                });
+                filter.push({
+                    title:'Cliente',
+                    value: ResPartner[0].name,
+                });
+            }
+            if(state && state != 9999999){
+                filter.push({
+                    title: 'Estado',
+                    value: $('#current-state option:selected').text(),
+                });
+            }
+
+            if(type && type != 9999999){
+                filter.push({
+                    title: 'Tipo de Factura',
+                    value: $('#current-type option:selected').text(),
+                });
+            }
+
+
+            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 {
+                    var fecha;
+                    if(date == 'today'){
+                        fecha = moment().format('DD/MM/YYYY');
+                    }
+                    if(date == 'yesterday'){
+                        fecha = moment().add(-1,'days').format('DD/MM/YYYY');
+                    }
+                    if(date == 'currentMonth'){
+                        fecha = moment().format('MMMM/YYYY');
+                    }
+                    if(date == 'lastMonth'){
+                        fecha = moment().add(-1,'months').format('MMMM/YYYY');
+                    }
+                    filter.push({
+                        title: 'Fecha',
+                        value:  fecha,
+                    });
+                }
+            }
+            return filter;
+        },
+    });
+}

+ 5 - 38
static/src/reports/report_contrato_inmobiliaria.xml

@@ -22,6 +22,8 @@
                             <option value="9999999">Todos los estados</option>
                             <option value="open">En curso</option>
                             <option value="pending">A renovar</option>
+                            <option value="cancelled">Cancelado</option>
+                            <option value="close">Cerrado</option>
                         </select>
                     </div>
                     <div class="col-lg-3 filter-style">
@@ -76,7 +78,7 @@
 
             <div class="report-form" style="display:none;">
                 <div id="toolbar">
-                    <button class="oe_button myButton" value="pdf">Imprimir Informe</button>
+                    <button class="myButton print-report" value="pdf">Imprimir Informe</button>
 
                 </div>
                 <div class="container" style="width:95%;">
@@ -106,52 +108,17 @@
                                 <th data-field="name" data-align="left">Contrato</th>
                                 <th data-field="partner_name" data-align="center">Cliente</th>
                                 <th data-field="nro_cuotas" data-align="center">Cuota actual</th>
-                                <th data-field="cuota_total" data-align="center">Total de cuotas</th>
+                                <th data-field="cuota_total" data-align="center">Total cuotas</th>
                                 <th data-field="recurring_next_date" data-align="center" data-sortable="true">Próxima factura</th>
                                 <th data-field="recurring_rule_type" data-align="center">Frecuencia</th>
                                 <th data-field="date" data-align="center" data-sortable="true" data-sorter="dateSorter">Final del contrato</th>
-
+                                <th data-field="state" data-align="center">Estado</th>
                             </tr>
                         </thead>
                     </table>
                 </div>
             </div>
-            <script>
-                <!--
-                    TOTAL CANTIDAD LOCAL
-                -->
-                function localFormatter(rowsTable) {
-                  var amount = 0;
-
-                  amount =  _.reduce(_.map(rowsTable,function(item){
-                        return (item.suma_local);
-                    }), function(memo, num){
-                    return memo + num; },0)
-
-                    return amount;
-                }
-
-                function dateSorter(a,b) {
-
-                <!-- rowsTable.sort(function(a, b) { -->
-                console.log(b)
-                  <!-- a = new Date(moment(a.date).format('DD/MM/YYYY'));
-                  b = new Date(moment(b.date).format('DD/MM/YYYY'));
-                  return a>b ? -1 : a< b ? 1 : 0; -->
-                <!-- }); -->
-}
 
-                <!--
-                    FOOTER STYLE
-                -->
-                function footerStyle(row, index) {
-                    return {
-                        css: {
-                          "font-weight": "bold"
-                        }
-                    };
-                };
-            </script>
         </div>
     </t>
 </template>

+ 119 - 0
static/src/reports/report_ventas_inmobiliaria.xml

@@ -0,0 +1,119 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<template xml:space="preserve">
+    <t t-name="ReportVentasInmobiliaria">
+        <div class="report_view">
+            <div class="reporting_page_header">
+                <h1 class="report_title"> Situación General de Ventas </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 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">En curso</option>
+                            <option value="pending">A renovar</option>
+                            <option value="close">Cerrado</option>
+                            <option value="cancelled">Cancelado</option>
+                        </select>
+                    </div>
+
+                    <div class="col-lg-3 customer filter-style">
+                        <label>Comprador</label>
+                        <select id="current-customer" class="form-control form-control-sm">
+                        </select>
+                    </div>
+
+
+                    <div class="col-lg-3 filter-style">
+                       <label>Fecha Último Pago</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="myButton print-report" value="pdf">Imprimir Informe</button>
+                </div>
+                <div class="container" style="width:100%;">
+                    <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"
+                        >
+                        <thead style="background:none;">
+                            <tr>
+                                <th data-field="t_nro" data-align="left" data-width="40">Nº</th>
+                                <th data-field="t_manzana" data-align="left" data-width="70">Manzana</th>
+                                <th data-field="t_lote" data-align="left" data-width="40">Lote</th>
+                                <th data-field="partner_name" data-align="center">Comprador</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="cuota_total" data-align="center" data-width="70">Cuotas Adelantadas</th> -->
+                                <th data-field="precio_cuota" data-align="right" data-width="70">Monto Cuota</th>
+                                <th data-field="state" data-align="center" data-width="70">Estado Contrato</th>
+
+                            </tr>
+                        </thead>
+                    </table>
+                </div>
+            </div>
+        </div>
+    </t>
+</template>

+ 2 - 0
templates.xml

@@ -8,6 +8,7 @@
         <!-- configuration < main > -->
         <script type="text/javascript" src="/eiru_reports_inmobiliaria/static/src/js/main.js"/>
         <script type="text/javascript" src="/eiru_reports_inmobiliaria/static/src/js/reporting_base.js"/>
+        <script type="text/javascript" src="/eiru_reports_inmobiliaria/static/src/js/pdf_inmobiliaria.js" />
 
         <!-- ================================= inmobiliaria ========================================= -->
 
@@ -15,6 +16,7 @@
         <script type="text/javascript" src="/eiru_reports_inmobiliaria/static/src/js/reports/report_contrato_inmobiliaria.js"/>
         <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"/>
 
 
       </xpath>

+ 5 - 0
views/actions.xml

@@ -16,5 +16,10 @@
 			<field name="name">Propiedades</field>
 			<field name="tag">eiru_reports_inmobiliaria.propiedades_inmobiliaria_action</field>
 		</record>
+
+		<record id="ventas_inmobiliaria_action" model="ir.actions.client">
+			<field name="name">Situación General de Ventas</field>
+			<field name="tag">eiru_reports_inmobiliaria.ventas_inmobiliaria_action</field>
+		</record>
 	</data>
 </openerp>

+ 1 - 0
views/menus.xml

@@ -9,6 +9,7 @@
     <menuitem id="contrato" parent="inmobiliaria_parent_menu" name="Contratos" action="contrato_inmobiliaria_action" sequence="1"/>
     <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"/>
 
 
   </data>