Prechádzať zdrojové kódy

[FIX] ajustes varios

Rodney Elpidio Enciso Arias 6 rokov pred
rodič
commit
8e5e39c2ff
41 zmenil súbory, kde vykonal 1578 pridanie a 3405 odobranie
  1. 16 30
      controller/helpers/__init__.py
  2. BIN
      controller/helpers/__init__.pyc
  3. 0 101
      controller/helpers/account_voucher.py
  4. BIN
      controller/helpers/account_voucher.pyc
  5. 0 15
      controller/helpers/company_logo.py
  6. BIN
      controller/helpers/product_category.pyc
  7. 53 7
      controller/helpers/product_product.py
  8. BIN
      controller/helpers/product_product.pyc
  9. 0 26
      controller/helpers/report_category.py
  10. BIN
      controller/helpers/report_category.pyc
  11. 0 28
      controller/helpers/report_report.py
  12. BIN
      controller/helpers/report_report.pyc
  13. 1 0
      controller/helpers/res_company.py
  14. BIN
      controller/helpers/res_company.pyc
  15. 29 0
      controller/helpers/res_currency.py
  16. BIN
      controller/helpers/res_currency.pyc
  17. 7 19
      controller/helpers/res_users.py
  18. BIN
      controller/helpers/res_users.pyc
  19. 9 1
      controller/main.py
  20. BIN
      controller/main.pyc
  21. 1 0
      models.py
  22. BIN
      models.pyc
  23. 1 383
      static/src/js/chart.js
  24. 25 10
      static/src/js/main.js
  25. 78 1099
      static/src/js/pdf.js
  26. 0 282
      static/src/js/reports/report_customer.js
  27. 21 3
      static/src/js/reports/report_customer_ranking.js
  28. 0 509
      static/src/js/reports/report_expense.js
  29. 287 589
      static/src/js/reports/report_product_list.js
  30. 1 1
      static/src/js/reports/report_sale.js
  31. 7 2
      static/src/js/reports/report_sale_analytic.js
  32. 941 0
      static/src/js/reports/report_sale_ranking_product.js
  33. 0 91
      static/src/reports/report_customer.xml
  34. 14 14
      static/src/reports/report_customer_ranking.xml
  35. 40 116
      static/src/reports/report_product_list.xml
  36. 10 12
      static/src/reports/report_sale.xml
  37. 12 14
      static/src/reports/report_sale_analytic.xml
  38. 18 18
      static/src/reports/report_sale_ranking_product.xml
  39. 2 7
      templates.xml
  40. 4 13
      views/actions.xml
  41. 1 15
      views/menus.xml

+ 16 - 30
controller/helpers/__init__.py

@@ -1,25 +1,24 @@
 # -*- coding: utf-8 -*-
-# REPORT CONFIG
-from report_report import get_report_report
-from report_category import get_report_category
-# RES USERS
-from res_users import get_res_users
-from res_partner import get_customers
-
-# ACCOUNT VOUCHER
-# from account_voucher import get_account_voucher_all
-from account_voucher import get_account_voucher_customer
-# from account_voucher import get_account_voucher_supplier
-
+# RES COMPANY
 from res_company import get_res_company
-# from res_company import get_company_logo
+# RES STORE
 from res_store import get_res_store
+# RES CURRENCY
+from res_currency import get_res_currency
+# ACCOUNT JOURNAL
 from account_journal import get_account_journal
-
+# RES USERS
+from res_users import get_res_users
+# POS ORDER
 from pos_order import get_pos_order
 from pos_order_line import get_pos_order_line
-# from account_period import get_account_period
-
+# ACCOUNT INVOICE
+from account_invoice import get_account_invoice_sale_type
+from account_invoice_line import get_account_invoice_line_out_invoice
+# ACCOUNT VOUCHER
+from account_voucher import get_account_voucher_customer
+# RES PARTNER
+from res_partner import get_customers
 # PRODUCT
 from product_category import get_product_category_all
 from product_category import get_product_category_expense
@@ -27,17 +26,4 @@ from product_brand import get_product_brand
 from product_attribute import get_product_attribute
 from product_attribute_value import get_product_attribute_value
 from product_product import get_product_product
-
-# ACCOUNT INVOICE
-# from account_invoice import get_account_invoice_all_type
-from account_invoice import get_account_invoice_sale_type
-# from account_invoice import get_account_invoice_sale_and_refund_type
-# from account_invoice import get_account_invoice_purchase_type
-# from account_invoice import get_account_invoice_expense_type
-
-# ACCOUNT INVOICE LINE
-# from account_invoice_line import get_account_invoice_line_all_type
-from account_invoice_line import get_account_invoice_line_out_invoice
-# from account_invoice_line import get_account_invoice_line_out_invoice_and_out_refund
-# from account_invoice_line import get_account_invoice_line_in_invoice_purchase
-# from account_invoice_line import get_account_invoice_line_in_invoice_expense
+# from product_product import get_product_product_image

BIN
controller/helpers/__init__.pyc


+ 0 - 101
controller/helpers/account_voucher.py

@@ -1,56 +1,6 @@
 # -*- coding: utf-8 -*-
 from openerp.http import request as r
 
-def get_account_voucher_all():
-    company_currency_rate = r.env.user.company_id.currency_id.rate
-    query = '''
-    SELECT  voucher.id,
-        	voucher.number,
-        	voucher.type,
-        	voucher.date,
-        	journal.currency,
-            voucher.amount,
-        	CASE
-        		WHEN journal.currency IS NULL
-        		THEN voucher.amount
-        		ELSE voucher.amount * (%s / (array_agg(rate.rate ORDER BY rate.name DESC))[1])
-        		END AS amount_currency,
-            voucher.journal_id,
-            voucher.reference
-        FROM account_voucher AS voucher
-        LEFT JOIN res_store_journal_rel AS journal_rel
-        ON voucher.journal_id = journal_rel.journal_id
-        LEFT JOIN account_journal AS journal
-        ON journal.id = voucher.journal_id
-        LEFT JOIN res_currency_rate AS rate
-        ON rate.currency_id = journal.currency
-        WHERE voucher.state = 'posted'
-        GROUP BY
-        	voucher.id,
-        	voucher.number,
-        	voucher.type,
-        	voucher.date,
-        	voucher.amount,
-        	journal.name,
-        	journal.currency
-    '''
-
-    r.cr.execute(query,(tuple([company_currency_rate])))
-
-    return [
-        {
-            'id': j[0],
-            'number': j[1],
-            'type': j[2],
-            'date': j[3],
-            'currency_id': j[4],
-            'amount': j[5],
-            'amount_currency': j[6],
-            'journal_id': j[7],
-            'reference': j[8],
-        } for j in r.cr.fetchall()
-    ]
-
 def get_account_voucher_customer():
     company_currency_rate = r.env.user.company_id.currency_id.rate
     query = '''
@@ -101,54 +51,3 @@ def get_account_voucher_customer():
             'reference': j[8],
         } for j in r.cr.fetchall()
     ]
-
-def get_account_voucher_supplier():
-    company_currency_rate = r.env.user.company_id.currency_id.rate
-    query = '''
-    SELECT  voucher.id,
-        	voucher.number,
-        	voucher.type,
-        	voucher.date,
-        	journal.currency,
-            voucher.amount,
-        	CASE
-        		WHEN journal.currency IS NULL
-        		THEN voucher.amount
-        		ELSE voucher.amount * (%s / (array_agg(rate.rate ORDER BY rate.name DESC))[1])
-        		END AS amount_currency,
-            voucher.journal_id,
-            voucher.reference
-        FROM account_voucher AS voucher
-        LEFT JOIN res_store_journal_rel AS journal_rel
-        ON voucher.journal_id = journal_rel.journal_id
-        LEFT JOIN account_journal AS journal
-        ON journal.id = voucher.journal_id
-        LEFT JOIN res_currency_rate AS rate
-        ON rate.currency_id = journal.currency
-        WHERE voucher.state = 'posted'
-        AND voucher.type = 'payment'
-        GROUP BY
-        	voucher.id,
-        	voucher.number,
-        	voucher.type,
-        	voucher.date,
-        	voucher.amount,
-        	journal.name,
-        	journal.currency
-    '''
-
-    r.cr.execute(query,(tuple([company_currency_rate])))
-
-    return [
-        {
-            'id': j[0],
-            'number': j[1],
-            'type': j[2],
-            'date': j[3],
-            'currency_id': j[4],
-            'amount': j[5],
-            'amount_currency': j[6],
-            'journal_id': j[7],
-            'reference': j[8],
-        } for j in r.cr.fetchall()
-    ]

BIN
controller/helpers/account_voucher.pyc


+ 0 - 15
controller/helpers/company_logo.py

@@ -1,15 +0,0 @@
-# -*- coding: utf-8 -*-
-from openerp.http import request as r
-
-_MODEL = 'res.company'
-
-def get_company_logo():
-    # domain = [
-    #     ('expense','=', True)
-    # ]
-    return [
-        {
-            'id': company.id,
-            'logo': company.image_medium,
-        } for company in r.env[_MODEL].search()
-    ]

BIN
controller/helpers/product_category.pyc


+ 53 - 7
controller/helpers/product_product.py

@@ -10,7 +10,7 @@ def get_product_product():
             SELECT table_name
             FROM information_schema.columns
             WHERE table_schema='public'
-                AND column_name='product_brand_id')
+                AND table_name='product_brand')
     '''
 
     query_with_brand = '''
@@ -26,7 +26,16 @@ def get_product_product():
         	(array_agg(attr_value.name)) AS attr_value,
         	(array_agg(attr.id)) AS attr,
         	template.product_brand_id,
-        	brand.name
+        	brand.name,
+            product.product_tmpl_id,
+            template.list_price,
+            product.default_code,
+            product.active,
+            template.sale_ok,
+            template.company_id,
+            template.store_id,
+            template.type,
+            product.ean13
         FROM product_product AS product
         LEFT JOIN product_template AS template
         ON template.id = product.product_tmpl_id
@@ -43,7 +52,12 @@ def get_product_product():
         	template.categ_id,
         	product.default_code,
         	template.product_brand_id,
-        	brand.name
+        	brand.name,
+            template.list_price,
+            template.sale_ok,
+            template.company_id,
+            template.store_id,
+            template.type
     '''
 
     query_without_brand = '''
@@ -57,7 +71,16 @@ def get_product_product():
         		END AS display_name,
         	(array_agg(attr_rel.att_id)) AS attr_rel,
         	(array_agg(attr_value.name)) AS attr_value,
-        	(array_agg(attr.id)) AS attr
+        	(array_agg(attr.id)) AS attr,
+            product.product_tmpl_id,
+            template.list_price,
+            product.default_code,
+            product.active,
+            template.sale_ok,
+            template.company_id,
+            template.store_id,
+            template.type,
+            product.ean13
         FROM product_product AS product
         LEFT JOIN product_template AS template
         ON template.id = product.product_tmpl_id
@@ -70,7 +93,12 @@ def get_product_product():
         GROUP BY
         	product.id,
         	template.categ_id,
-        	product.default_code
+        	product.default_code,
+            template.list_price,
+            template.sale_ok,
+            template.company_id,
+            template.store_id,
+            template.type
     '''
 
     r.cr.execute(validate_brand)
@@ -89,7 +117,16 @@ def get_product_product():
                 'attribute_values':j[4],
                 'attribute':j[5],
                 'product_brand_id':j[6],
-                'brand_name': j[7]
+                'brand_name': j[7],
+                'product_tmpl_id': j[8],
+                'list_price': j[9],
+                'default_code': j[10],
+                'active': j[11],
+                'sale_ok': j[12],
+                'company_id': j[13],
+                'store_id': j[14],
+                'type': j[15],
+                'ean13': j[16],
             } for j in r.cr.fetchall()
         ]
     else:
@@ -101,6 +138,15 @@ def get_product_product():
                 'product_name': j[2],
                 'attribute_value_ids':j[3],
                 'attribute_values':j[4],
-                'attribute':j[5]
+                'attribute':j[5],
+                'product_tmpl_id': j[6],
+                'list_price': j[7],
+                'default_code': j[8],
+                'active': j[9],
+                'sale_ok': j[10],
+                'company_id': j[11],
+                'store_id': j[12],
+                'type': j[13],
+                'ean13': j[14],
             } for j in r.cr.fetchall()
         ]

BIN
controller/helpers/product_product.pyc


+ 0 - 26
controller/helpers/report_category.py

@@ -1,26 +0,0 @@
-# -*- coding: utf-8 -*-
-from openerp.http import request as r
-
-def get_report_category():
-    query = '''
-        SELECT
-            category.id,
-            category.name,
-            category.name_template,
-            category.description,
-            category.icon_code
-        FROM report_category AS category
-        ORDER BY category.sequence
-    '''
-
-    r.cr.execute(query)
-
-    return [
-        {
-            'id': j[0],
-            'name': j[1],
-            'name_template': j[2],
-            'description': j[3],
-            'icon_code': j[4],
-        } for j in r.cr.fetchall()
-    ]

BIN
controller/helpers/report_category.pyc


+ 0 - 28
controller/helpers/report_report.py

@@ -1,28 +0,0 @@
-# -*- coding: utf-8 -*-
-from openerp.http import request as r
-
-def get_report_report():
-    query = '''
-        SELECT
-            report.id,
-            report.name,
-            report.name_template,
-            report.description,
-            report.icon_code,
-            report.category_id
-        FROM report_report AS report
-        ORDER BY report.sequence
-    '''
-
-    r.cr.execute(query)
-
-    return [
-        {
-            'id': j[0],
-            'name': j[1],
-            'name_template': j[2],
-            'description': j[3],
-            'icon_code': j[4],
-            'category_id': j[5],
-        } for j in r.cr.fetchall()
-    ]

BIN
controller/helpers/report_report.pyc


+ 1 - 0
controller/helpers/res_company.py

@@ -19,6 +19,7 @@ def get_res_company():
                 'decimal_separator':  company.currency_id.decimal_separator,
                 'thousands_separator':  company.currency_id.thousands_separator,
                 'symbol_position':  company.currency_id.symbol_position,
+                'rate_silent': company.currency_id.rate_silent
             }
         } for company in r.env[_MODEL].search(domain)
     ]

BIN
controller/helpers/res_company.pyc


+ 29 - 0
controller/helpers/res_currency.py

@@ -0,0 +1,29 @@
+from openerp.http import request as r
+
+def get_res_currency():
+
+    query = '''
+        SELECT
+            id,
+            name,
+            local_name,
+            symbol,
+            decimal_separator,
+            thousands_separator,
+            decimal_places
+        FROM res_currency
+        WHERE active = True
+    '''
+
+    r.cr.execute(query)
+    return [
+        {
+            'id': j[0],
+            'name': j[1],
+            'local_name': j[2],
+            'symbol': j[3],
+            'decimal_separator': j[4],
+            'thousands_separator': j[5],
+            'decimal_places': j[6],
+        } for j in r.cr.fetchall()
+    ]

BIN
controller/helpers/res_currency.pyc


+ 7 - 19
controller/helpers/res_users.py

@@ -1,27 +1,15 @@
 # -*- coding: utf-8 -*-
 from openerp.http import request as r
 
-def get_res_users():
-    query = '''
-        SELECT
-            users.id,
-            users.company_id,
-            users.store_id,
-            partner.name
-        FROM res_users AS users
-        LEFT JOIN res_partner AS partner
-        ON partner.id = users.partner_id
-        WHERE users.active = true
-    '''
+_MODEL = 'res.users'
 
-    r.cr.execute(query)
+def get_res_users():
 
     return [
         {
-            'id': j[0],
-            'company_id': j[1],
-            'store_id': j[2],
-            'name': j[3],
-
-        } for j in r.cr.fetchall()
+            'id': user.id,
+            'company_id': user.company_id.id,
+            'store_id': user.store_id.id,
+            'name': user.partner_id.name,
+        } for user in r.env[_MODEL].search([])
     ]

BIN
controller/helpers/res_users.pyc


+ 9 - 1
controller/main.py

@@ -60,13 +60,21 @@ class ReportController(http.Controller):
             'order_lines': hp.get_pos_order_line(),
         })
 
-    # Clientes
+    # CLIENTES
     @http.route('/report-customers', auth='user', methods=['GET', 'POST'])
     def getCustomers(self, **kw):
         return make_gzip_response({
             'customers': hp.get_customers(),
         })
 
+    # CATALOGO DE PRODUCTOS
+    @http.route('/report-product-list', auth='user', methods=['GET', 'POST'])
+    def getCustomers(self, **kw):
+        return make_gzip_response({
+            'products': hp.get_product_product(),
+            'currencies': hp.get_res_currency(),
+        })
+
     # # HISTORICO DE COMPRAS
     # @http.route('/report-purchase-history', auth='user', methods=['GET', 'POST'])
     # def getPurchaseHistory(self, **kw):

BIN
controller/main.pyc


+ 1 - 0
models.py

@@ -29,6 +29,7 @@ class ProductPriceList(models.Model):
 		            'id' : pricelist.currency_id.id,
 		            'name' : pricelist.currency_id.name,
 					'rate_silent': pricelist.currency_id.rate_silent,
+					'local_name':pricelist.currency_id.local_name
 		        },
 		    })
 

BIN
models.pyc


+ 1 - 383
static/src/js/chart.js

@@ -3,146 +3,7 @@ function chart(reporting) {
 
     var model = openerp;
 
-    reporting.ReportChartWidget = reporting.Base.extend({
-
-        BuildDemoChart: function (label,data,CurrencyBase) {
-            var self = this;
-            Chart.scaleService.updateScaleDefaults('linear', {
-                ticks: {
-                    callback: function(tick) {
-                        return tick.toLocaleString('de-DE');
-                    }
-                }
-            });
-            Chart.defaults.global.tooltips.callbacks.label = function(tooltipItem, data) {
-                var dataset = data.datasets[tooltipItem.datasetIndex];
-                var datasetLabel = dataset.label || '';
-                return datasetLabel +  dataset.data[tooltipItem.index].toLocaleString('de-DE');
-            };
-
-            var chartData = {
-    			labels: label,
-    			datasets: [{
-    				type: 'line',
-    				label: 'Balance',
-    				borderColor: '#0288d1',
-                    fill:false,
-    				data: [
-                        '10500',
-                        '5000',
-                        '3000',
-                        '19000',
-                        '4000',
-                        '70000',
-                        '8000',
-                        '43000',
-                        '25000',
-                        '39000',
-                        '36000',
-                        '47000',
-    				],
-    				borderWidth: 2
-    			}, {
-    				type: 'bar',
-    				label: 'Ventas',
-                    backgroundColor: '#81c784',
-    				borderWidth: 1,
-    				data: [
-                        '10000',
-                        '5000',
-                        '3000',
-                        '15000',
-                        '45000',
-                        '70000',
-                        '90000',
-                        '40000',
-                        '25000',
-                        '70000',
-                        '30000',
-                        '50000',
-    				]
-    			}, {
-    				type: 'bar',
-    				label: 'Compras',
-    				backgroundColor: '#ffb74d',
-    				data: [
-                        '10000',
-                        '5000',
-                        '3000',
-                        '15000',
-                        '4000',
-                        '70000',
-                        '8000',
-                        '40000',
-                        '25000',
-                        '35000',
-                        '30000',
-                        '40000',
-    				],
-    				borderWidth: 1
-    			}, {
-    				type: 'bar',
-    				label: 'Gastos',
-    				backgroundColor: '#e57373',
-    				data: [
-                        '10500',
-                        '5000',
-                        '3000',
-                        '19000',
-                        '4000',
-                        '70000',
-                        '8000',
-                        '43000',
-                        '25000',
-                        '39000',
-                        '36000',
-                        '47000',
-    				],
-    				borderWidth: 1
-    			}]
-    		};
-            var chart = new Chart($(".reporting-chart"), {
-                type: 'bar',
-                data: chartData,
-                options: {
-                    responsive: true,
-                    responsiveAnimationDuration:10,
-                    maintainAspectRatio:false,
-                    title: {
-                        display: false,
-                    },
-                    hover: {
-                        mode: 'nearest',
-                        intersect: true
-                    },
-                    legend: {
-                       display: false,
-                    },
-                    layout: {
-                        padding: {
-                            top: 0,
-                            bottom: 0,
-                            left : 0,
-                            rigth: 0,
-                        }
-                    },
-                    // events: ['click'],
-                    tooltips: {
-                        callbacks: {
-                            label: function(tooltipItem, data) {
-                                var label = data.datasets[tooltipItem.datasetIndex].label || '';
-
-                                if (label) {
-                                    label += ': ';
-                                }
-                                label += accounting.formatMoney(tooltipItem.yLabel, CurrencyBase.symbol, CurrencyBase.decimal_places, CurrencyBase.thousands_separator, CurrencyBase.decimal_separator);
-                                return label;
-                            }
-                        }
-                    }
-                }
-            });
-        },
+    reporting.ReportSaleChartWidget = reporting.Base.extend({
 
         BuildLineChart: function (label,data,CurrencyBase) {
             var self = this;
@@ -333,7 +194,6 @@ function chart(reporting) {
                     },
                     legend: {
                         position: 'right',
-                        // position: 'none',
                     },
                     layout: {
                         padding: {
@@ -405,7 +265,6 @@ function chart(reporting) {
                     },
                     legend: {
                         position: 'left',
-                        // position: 'none',
                     },
                     layout: {
                         padding: {
@@ -437,246 +296,5 @@ function chart(reporting) {
                 }
             });
         },
-
-        BuildMultipleChart: function (CurrencyBase,label,body_subtotal,body_tax,body_cost,body_total,body_profit) {
-            var self = this;
-            Chart.scaleService.updateScaleDefaults('linear', {
-                ticks: {
-                    callback: function(tick) {
-                        return tick.toLocaleString('de-DE');
-                    }
-                }
-            });
-            Chart.defaults.global.tooltips.callbacks.label = function(tooltipItem, data) {
-                var dataset = data.datasets[tooltipItem.datasetIndex];
-                var datasetLabel = dataset.label || '';
-                return datasetLabel +  dataset.data[tooltipItem.index].toLocaleString('de-DE');
-            };
-
-            var chartData = {
-    			labels: label,
-    			datasets: [
-                    /*
-                    ================
-                        BENEFICIO
-                    ================
-                    */
-                    {
-    				type: 'line',
-    				label: 'Beneficio',
-                    borderColor: '#03a9f4',
-                    fill: false,
-                    borderWidth: 2,
-    				data: body_profit,
-
-                    },
-                    /*
-                    ================
-                        TOTAL
-                    ================
-                    */
-                    {
-    				type: 'bar',
-    				label: 'Total',
-                    borderColor: '#BCCEF4',
-    				backgroundColor: '#BCCEF4',
-                    borderWidth: 1,
-    				data: body_total,
-                    },
-                    /*
-                    ================
-                        SUB TOTAL
-                    ================
-                    */
-                    {
-    				type: 'bar',
-    				label: 'Sub-Total',
-    				borderColor: '#A9E5E3',
-                    backgroundColor: '#A9E5E3',
-    				borderWidth: 1,
-    				data: body_subtotal,
-    			    },
-                    /*
-                    ================
-                        IMPUESTOS
-                    ================
-                    */
-                    {
-    				type: 'bar',
-    				label: 'Impuestos',
-                    borderColor: '#A0D995',
-    				backgroundColor: '#A0D995',
-                    borderWidth: 1,
-    				data:body_tax,
-    			    },
-                    /*
-                    ================
-                        COSTE
-                    ================
-                    */
-                    {
-    				type: 'bar',
-    				label: 'Coste',
-                    borderColor: '#C5D084',
-    				backgroundColor: '#C5D084',
-                    borderWidth: 1,
-    				data: body_cost,
-                    },
-                ]
-    		};
-            var chart = new Chart($(".reporting-chart"), {
-                type: 'bar',
-                data: chartData,
-                options: {
-                    responsive: true,
-                    responsiveAnimationDuration:20,
-                    maintainAspectRatio:false,
-                    title: {
-                        display: false,
-                    },
-                    hover: {
-                        mode: 'nearest',
-                        intersect: true
-                    },
-                    legend: {
-                       display: false,
-                    },
-                    layout: {
-                        padding: {
-                            top: 15,
-                            bottom: 0,
-                            left : 0,
-                            rigth: 0,
-                        }
-                    },
-                    events: ['click'],
-                    tooltips: {
-                        callbacks: {
-                            label: function(tooltipItem, data) {
-                                var label = data.datasets[tooltipItem.datasetIndex].label || '';
-
-                                if (label) {
-                                    label += ': ';
-                                }
-                                label += accounting.formatMoney(tooltipItem.yLabel, CurrencyBase.symbol, CurrencyBase.decimal_places, CurrencyBase.thousands_separator, CurrencyBase.decimal_separator);
-                                return label;
-                            }
-                        }
-                    }
-                }
-            });
-        },
-
-        BuildMultipleBarChart: function (
-            data,
-            CurrencyBase,
-            first_label,
-            first_body,
-            second_label,
-            second_body,
-            third_label,
-            third_body,
-            fourth_label,
-            fourth_body,
-            label
-            ) {
-            var self = this;
-            Chart.scaleService.updateScaleDefaults('linear', {
-                ticks: {
-                    callback: function(tick) {
-                        return tick.toLocaleString('de-DE');
-                    }
-                }
-            });
-            Chart.defaults.global.tooltips.callbacks.label = function(tooltipItem, data) {
-                var dataset = data.datasets[tooltipItem.datasetIndex];
-                var datasetLabel = dataset.label || '';
-                return datasetLabel +  dataset.data[tooltipItem.index].toLocaleString('de-DE');
-            };
-
-            var chartData = {
-    			labels: label,
-    			datasets: [
-
-                    {
-    				type: 'bar',
-    				label: first_label,
-                    borderColor: '#BCCEF4',
-    				backgroundColor: '#BCCEF4',
-                    borderWidth: 1,
-    				data: first_body,
-                    },
-
-                    {
-    				type: 'bar',
-    				label: second_label,
-    				borderColor: '#A9E5E3',
-                    backgroundColor: '#A9E5E3',
-    				borderWidth: 1,
-    				data: second_body,
-    			    },
-
-                    {
-    				type: 'bar',
-    				label: third_label,
-                    borderColor: '#A0D995',
-    				backgroundColor: '#A0D995',
-                    borderWidth: 1,
-    				data: third_body,
-    			    },
-
-                    {
-    				type: 'bar',
-    				label: fourth_label,
-                    borderColor: '#0288d1',
-    				backgroundColor: '#0288d1',
-                    borderWidth: 1,
-    				data: fourth_body,
-    			    },
-                ]
-    		};
-
-            var chart = new Chart($(".reporting-chart"), {
-                type: 'bar',
-                data: chartData,
-                options: {
-                    responsive: true,
-                    responsiveAnimationDuration:10,
-                    maintainAspectRatio:false,
-                    title: {
-                        display: false,
-                    },
-                    hover: {
-                        mode: 'nearest',
-                        intersect: true
-                    },
-                    legend: {
-                       display: false,
-                    },
-                    layout: {
-                        padding: {
-                            top: 0,
-                            bottom: 0,
-                            left : 0,
-                            rigth: 0,
-                        }
-                    },
-                    tooltips: {
-                        callbacks: {
-                            label: function(tooltipItem, data) {
-                                var label = data.datasets[tooltipItem.datasetIndex].label || '';
-
-                                if (label) {
-                                    label += ': ';
-                                }
-                                label += accounting.formatMoney(tooltipItem.yLabel, CurrencyBase.symbol, CurrencyBase.decimal_places, CurrencyBase.thousands_separator, CurrencyBase.decimal_separator);
-                                return label;
-                            }
-                        }
-                    },
-                    events: ['click'],
-                }
-            });
-        },
     });
 }

+ 25 - 10
static/src/js/main.js

@@ -22,7 +22,6 @@ openerp.eiru_reports_sales = function (instance) {
         */
         report_sale(reporting);
         report_sale_analytic(reporting);
-        report_customer(reporting);
         report_customer_ranking(reporting);
         report_sale_ranking_product(reporting);
         report_product_list(reporting);
@@ -35,29 +34,37 @@ openerp.eiru_reports_sales = function (instance) {
         HISTORICO DE VENTAS
     ================================================================================
     */
-    instance.web.client_actions.add('eiru_reports_sales.sale_action', 'instance.eiru_reports_sales.ReportSaleWidget');
-
+    instance.web.client_actions.add(
+        'eiru_reports_sales.sale_action',
+        'instance.eiru_reports_sales.ReportSaleWidget'
+    );
     /*
     ================================================================================
         ANALISIS DE VENTAS
     ================================================================================
      */
-    instance.web.client_actions.add('eiru_reports_sales.sale_analytic_action', 'instance.eiru_reports_sales.ReportSaleAnalyticWidget');
-
+    instance.web.client_actions.add(
+        'eiru_reports_sales.sale_analytic_action',
+        'instance.eiru_reports_sales.ReportSaleAnalyticWidget'
+    );
     /*
     ================================================================================
         CLIENTES
     ================================================================================
      */
-    instance.web.client_actions.add('eiru_reports_sales.customer_action', 'instance.eiru_reports_sales.ReportCustomerWidget');
-
+    instance.web.client_actions.add(
+        'eiru_reports_sales.customer_action',
+        'instance.eiru_reports_sales.ReportCustomerWidget'
+    );
     /*
     ================================================================================
         RANKING DE CLIENTES
     ================================================================================
     */
-    instance.web.client_actions.add('eiru_reports_sales.customer_ranking_action', 'instance.eiru_reports_sales.ReportCustomerRankingWidget');
-
+    instance.web.client_actions.add(
+        'eiru_reports_sales.customer_ranking_action',
+        'instance.eiru_reports_sales.ReportCustomerRankingWidget'
+    );
     /*
     ================================================================================
         RANKING DE PRODUCTOS MAS VENDIDOS
@@ -67,5 +74,13 @@ openerp.eiru_reports_sales = function (instance) {
         'eiru_reports_sales.sale_ranking_product_action',
         'instance.eiru_reports_sales.ReportSaleRankingProductWidget'
     );
-
+    /*
+    ================================================================================
+        CATALOGO DE PRODUCTOS
+    ================================================================================
+    */
+    instance.web.client_actions.add(
+        'eiru_reports_sales.product_list_action',
+        'instance.eiru_reports_sales.ReportProductListWidget'
+    );
 };

+ 78 - 1099
static/src/js/pdf.js

@@ -3,509 +3,74 @@ function pdf(reporting) {
 
     var model = openerp;
 
-    reporting.ReportPdfWidget = reporting.Base.extend({
-      drawPDF: function (getColumns,row,ResCompany,pdf_title,pdf_type,pdf_name,pdf_columnStyles,filter) {
-        var self = this;
-        var base64Img = 'data:image/png;base64,' + ResCompany.logo;
-        var hoy = moment().format('DD/MM/YYYY');
-        var totalPagesExp = "{total_pages_count_string}";
-        var pdfDoc = new jsPDF(pdf_type);
-        var y_position = 27;
-        var y_position2 = 27;
-
-        //LOGO
-        pdfDoc.addImage(base64Img, 'png', 7, 2, 0, 15);
-
-        //FECHA
-        pdfDoc.setFontSize(13);
-        pdfDoc.setFontStyle('normal');
-        pdfDoc.setTextColor(40)
-        pdfDoc.text(pdfDoc.internal.pageSize.getWidth() - 35, 12,hoy);
-
-        //TITULO
-        pdfDoc.setFontSize(15);
-        pdfDoc.setFontStyle('bold');
-        pdfDoc.setTextColor('#0288d1');
-        pdfDoc.autoTableText(pdf_title, pdfDoc.internal.pageSize.getWidth() - 12, 18, {
-          halign: 'right',
-          valign: 'middle'
-        });
-        pdfDoc.setLineWidth(0.5);
-        pdfDoc.setDrawColor('#424242');
-        pdfDoc.line(10, 22, pdfDoc.internal.pageSize.getWidth() - 10 , 22);
-
-        var i=0;
-        if(pdf_type == 'l'){
-          var col1_title = 15;
-          var col1_value = 55;
-          var col2_title = 150;
-          var col2_value = 190;
-        }
-        else{
-          var col1_title = 10;
-          var col1_value = 50;
-          var col2_title = 110;
-          var col2_value = 150;
-        }
-        if(filter.length >0){
-          _.each(filter,function(item){
-            if(i<4){
-              self.addFilter(pdfDoc,item.title,item.value,col1_title,col1_value,y_position);
-              y_position = y_position + 5;
-            }else{
-              self.addFilter(pdfDoc,item.title,item.value,col2_title,col2_value,y_position2);
-              y_position2 = y_position2 + 5;
-            }
-              i++;
-          });
-          pdfDoc.setLineWidth(0.5);
-          pdfDoc.setDrawColor('#424242');
-
-          if(y_position >= y_position2){
-            y_position = y_position;
-            pdfDoc.line(10, y_position, pdfDoc.internal.pageSize.getWidth() - 10 , y_position);
-          }else{
-            y_position = y_position2;
-            pdfDoc.line(10, y_position2, pdfDoc.internal.pageSize.getWidth() - 10 , y_position2);
-          }
-        }
-
-
-        pdfDoc.autoTable(getColumns, row, {
-            // showHeader: 'firstPage',
-            startY: y_position + 5,
-            theme: 'grid',
-            styles: {
-                overflow: 'linebreak',
-                columnWidth: 'auto',
-                fontSize: 7,
-            },
-            headerStyles: {
-                fillColor: [76, 133, 248],
-                fontSize: 9
-            },
-            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'
-        });
-      },
-
-        drawStockPDF: function (
-            index,
-            getColumns,
-            row,
-            ResCompany,
-            pdf_title,
-            pdf_type,
-            pdf_name,
-            pdf_columnStyles,
-            current_location) {
+    reporting.ReportSalePdfWidget = reporting.Base.extend({
+        drawPDF: function (getColumns,row,ResCompany,pdf_title,pdf_type,pdf_name,pdf_columnStyles,filter) {
             var self = this;
             var base64Img = 'data:image/png;base64,' + ResCompany.logo;
             var hoy = moment().format('DD/MM/YYYY');
             var totalPagesExp = "{total_pages_count_string}";
             var pdfDoc = new jsPDF(pdf_type);
-            getColumns.shift();
-            pdfDoc.autoTable(getColumns, row, {
-                theme: 'grid',
-                styles: {
-                    overflow: 'linebreak',
-                    columnWidth: 'auto',
-                    fontSize: 7,
-                },
-                headerStyles: {
-                    fillColor: [76, 133, 248],
-                    fontSize: 8
-                },
-                columnStyles: pdf_columnStyles,
-                margin: { top: 20, horizontal: 7, bottom: 40,},
-
-                drawCell: function(cell, data) {
-                    var rows = data.table.rows;
-                    if (data.row.index == rows.length - 1) {
-                        pdfDoc.setFontStyle('bold');
-                    };
-                },
-
-                addPageContent: function (data) {
-                    pdfDoc.addImage(base64Img, 'png', 7, 2, 0, 15);
-                    if(pdf_type == 'l'){
-                        pdfDoc.setFontSize(12);
-                        pdfDoc.setFontStyle('bold');
-                        pdfDoc.setTextColor(40);
-                        pdfDoc.text(pdf_title,130,10);
+            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;
+            var col1_title;
+            var col1_value;
+            var col2_title;
+            var col2_value;
+            if(pdf_type == 'l'){
+                col1_title = 15;
+                col1_value = 55;
+                col2_title = 150;
+                col2_value = 190;
+            }
+            else{
+                col1_title = 10;
+                col1_value = 50;
+                col2_title = 110;
+                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{
-                        pdfDoc.setFontSize(12);
-                        pdfDoc.setFontStyle('bold');
-                        pdfDoc.setTextColor(40);
-                        pdfDoc.text(pdf_title,80,10);
-                    }
-                    if(current_location.length > 0){
-                        pdfDoc.setFontSize(9);
-                        pdfDoc.setFontStyle('normal');
-                        pdfDoc.setTextColor(40)
-                        pdfDoc.text(pdfDoc.internal.pageSize.getWidth() - 54, 18,"Ubicación: " + current_location[0].parent_name);
-                    }
-                    pdfDoc.setFontSize(9);
-                    pdfDoc.setFontStyle('normal');
-                    pdfDoc.setTextColor(40)
-                    pdfDoc.text(pdfDoc.internal.pageSize.getWidth() - 55, 14," Fecha de Expedición: " + hoy);
-
-                    /*===========
-                        FOOTER
-                    ===========*/
-                    var str = "Página " + data.pageCount;
-                    if (typeof pdfDoc.putTotalPages === 'function') {
-                        str = str + " de " + totalPagesExp;
+                        self.addFilter(pdfDoc,item.title,item.value,col2_title,col2_value,y_position2);
+                        y_position2 = y_position2 + 5;
                     }
-                    pdfDoc.setFontSize(9);
-                    pdfDoc.setFontStyle('bold');
-                    pdfDoc.setTextColor(40);
-                    var pageHeight = pdfDoc.internal.pageSize.height || pdfDoc.internal.pageSize.getHeight();
-                    pdfDoc.text(str, pdfDoc.internal.pageSize.getWidth() - 55, pageHeight - 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);
                 }
-            });
-            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');
-        },
-
-        drawSaleJournalPDF: function (getColumns,row,ResCompany,pdf_title,pdf_type,pdf_name,pdf_columnStyles,desde,hasta) {
-            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);
-
-            /*
-            ==============================================
-                PRIMERA COLUMNA
-            ==============================================
-            */
-
-            // Title
-            pdfDoc.setFontSize(15);
-            pdfDoc.setFontStyle('bold');
-            pdfDoc.setTextColor(40);
-            pdfDoc.text(pdf_title,7,10);
-
-            // DEL
-            pdfDoc.setFontSize(10);
-            pdfDoc.setFontStyle('normal');
-            pdfDoc.setTextColor(40);
-            pdfDoc.text('DEL: ' + desde,7,20);
-
-            // AL
-            pdfDoc.setFontSize(10);
-            pdfDoc.setFontStyle('normal');
-            pdfDoc.setTextColor(40);
-            pdfDoc.text('AL: ' + hasta ,7,24);
-
-            /*
-            ==============================================
-                SEGUNDA COLUMNA
-            ==============================================
-            */
-
-            // CODIGO DESDE
-            pdfDoc.setFontSize(10);
-            pdfDoc.setFontStyle('normal');
-            pdfDoc.setTextColor(40);
-            pdfDoc.text('Código Desde: ' + 1 ,50,20);
-
-            // CODIGO HASTA
-            pdfDoc.setFontSize(10);
-            pdfDoc.setFontStyle('normal');
-            pdfDoc.setTextColor(40);
-            pdfDoc.text('Código Hasta: ' + (row.length - 1),50,24);
-
-            /*
-            ==============================================
-                QUINTA COLUMNA
-            ==============================================
-            */
-
-            // Empresa
-            pdfDoc.setFontSize(10);
-            pdfDoc.setFontStyle('normal');
-            pdfDoc.setTextColor(40);
-            pdfDoc.text('Empresa: ' + ResCompany.name ,100,20);
-
-            // RUC
-            pdfDoc.setFontSize(10);
-            pdfDoc.setFontStyle('normal');
-            pdfDoc.setTextColor(40);
-            pdfDoc.text('R.U.C: ' + ResCompany.company_ruc ,100,24);
-
-            /*
-            ==============================================
-                CREACION DEL PDF
-            ==============================================
-            */
-
             pdfDoc.autoTable(getColumns, row, {
-                showHeader: 'false',
+                startY: y_position + 5,
                 theme: 'grid',
-
-                drawRow: function (row, data) {
-                    if(pdf_type == "l"){
-                        if (row.index === 0) {
-                            pdfDoc.setTextColor(40);
-                            pdfDoc.setFontSize(8);
-                            pdfDoc.setFontStyle('bold');
-                            // Documento
-                            pdfDoc.rect(data.settings.margin.left, row.y, 52, 8, 'S');
-                            // Clientes
-                            pdfDoc.rect(59, row.y, 72, 8, 'S');
-                            // Total de Ventas
-                            pdfDoc.rect(131, row.y, 162, 8, 'S');
-                            pdfDoc.autoTableText("DOCUMENTO", 33, row.y + row.height / 2, {
-                                halign: 'center',
-                                valign: 'middle'
-                            });
-                            pdfDoc.autoTableText("CLIENTES", 95, row.y + row.height / 2, {
-                                halign: 'center',
-                                valign: 'middle'
-                            });
-                            pdfDoc.autoTableText("TOTAL DE VENTAS", 210, row.y + row.height / 2, {
-                                halign: 'center',
-                                valign: 'middle'
-                            });
-                            // NUM
-                            pdfDoc.rect(data.settings.margin.left, row.y + 8, 31, 8, 'S');
-                            pdfDoc.autoTableText("NUM", 22, row.y + row.height / 2 + 8, {
-                                halign: 'center',
-                                valign: 'middle'
-                            });
-                            // FECHA
-                            pdfDoc.rect(38, row.y + 8, 21, 8, 'S');
-                            pdfDoc.autoTableText("FECHA", 47, row.y + row.height / 2 + 8, {
-                                halign: 'center',
-                                valign: 'middle'
-                            });
-                            // RAZON SOCIAL
-                            pdfDoc.rect(59, row.y + 8, 52, 8, 'S');
-                            pdfDoc.autoTableText("RAZON SOCIAL", 83, row.y + row.height / 2 + 8, {
-                                halign: 'center',
-                                valign: 'middle'
-                            });
-                            // RUC
-                            pdfDoc.rect(111, row.y + 8, 20, 8, 'S');
-                            pdfDoc.autoTableText("RUC", 120, row.y + row.height / 2 + 8, {
-                                halign: 'center',
-                                valign: 'middle'
-                            });
-                            // GRAVADAS
-                            pdfDoc.rect(131, row.y + 8, 28, 8, 'S');
-                            pdfDoc.autoTableText("GRAVADAS", 145, row.y + row.height / 2 + 8, {
-                                halign: 'center',
-                                valign: 'middle'
-                            });
-                            // %
-                            pdfDoc.rect(159, row.y + 8, 9, 8, 'S');
-                            pdfDoc.autoTableText("%", 163, row.y + row.height / 2 + 8, {
-                                halign: 'center',
-                                valign: 'middle'
-                            });
-                            // IMPUESTOS
-                            pdfDoc.rect(168, row.y + 8, 25, 8, 'S');
-                            pdfDoc.autoTableText("IMPUESTOS", 180, row.y + row.height / 2 + 8, {
-                                halign: 'center',
-                                valign: 'middle'
-                            });
-                            // EXENTAS
-                            pdfDoc.rect(193, row.y + 8, 30, 8, 'S');
-                            pdfDoc.autoTableText("EXENTAS", 209, row.y + row.height / 2 + 8, {
-                                halign: 'center',
-                                valign: 'middle'
-                            });
-                            // Ret IVA
-                            pdfDoc.rect(223, row.y + 8, 20, 8, 'S');
-                            pdfDoc.autoTableText("Ret IVA", 232, row.y + row.height / 2 + 8, {
-                                halign: 'center',
-                                valign: 'middle'
-                            });
-                            // Ret Renta
-                            pdfDoc.rect(243, row.y + 8, 20, 8, 'S');
-                            pdfDoc.autoTableText("Ret RENTA", 253, row.y + row.height / 2 + 8, {
-                                halign: 'center',
-                                valign: 'middle'
-                            });
-                            // TOTAL
-                            pdfDoc.rect(263, row.y + 8, 30, 8, 'S');
-                            pdfDoc.autoTableText("TOTAL", 276, row.y + row.height / 2 + 8, {
-                                halign: 'center',
-                                valign: 'middle'
-                            });
-                            data.cursor.y += 16;
-                        };
-                    }else{
-                        if (row.index === 0) {
-                            pdfDoc.setTextColor(40);
-                            pdfDoc.setFontSize(8);
-                            pdfDoc.setFontStyle('bold');
-                            // Documento
-                            pdfDoc.rect(data.settings.margin.left, row.y, 43, 8, 'S');
-                            // Clientes
-                            pdfDoc.rect(50, row.y, 53, 8, 'S');
-                            // Total de Ventas
-                            pdfDoc.rect(103, row.y, 100, 8, 'S');
-                            pdfDoc.autoTableText("DOCUMENTO", 29, row.y + row.height / 2, {
-                                halign: 'center',
-                                valign: 'middle'
-                            });
-                            pdfDoc.autoTableText("CLIENTES", 77, row.y + row.height / 2, {
-                                halign: 'center',
-                                valign: 'middle'
-                            });
-                            pdfDoc.autoTableText("TOTAL DE VENTAS",148, row.y + row.height / 2, {
-                                halign: 'center',
-                                valign: 'middle'
-                            });
-                            // NUM
-                            pdfDoc.setFontSize(6);
-                            pdfDoc.rect(data.settings.margin.left, row.y + 8, 27, 8, 'S');
-                            pdfDoc.autoTableText("NUM", 21, row.y + row.height / 2 + 8, {
-                                halign: 'center',
-                                valign: 'middle'
-                            });
-                            // FECHA
-                            pdfDoc.rect(34, row.y + 8, 16, 8, 'S');
-                            pdfDoc.autoTableText("FECHA", 42, row.y + row.height / 2 + 8, {
-                                halign: 'center',
-                                valign: 'middle'
-                            });
-                            // RAZON SOCIAL
-                            pdfDoc.rect(50, row.y + 8, 35, 8, 'S');
-                            pdfDoc.autoTableText("RAZON SOCIAL", 68, row.y + row.height / 2 + 8, {
-                                halign: 'center',
-                                valign: 'middle'
-                            });
-                            // RUC
-                            pdfDoc.rect(85, row.y + 8, 18, 8, 'S');
-                            pdfDoc.autoTableText("RUC", 95, row.y + row.height / 2 + 8, {
-                                halign: 'center',
-                                valign: 'middle'
-                            });
-                            // GRAVADAS
-                            pdfDoc.rect(103, row.y + 8, 20, 8, 'S');
-                            pdfDoc.autoTableText("GRAVADAS", 113, row.y + row.height / 2 + 8, {
-                                halign: 'center',
-                                valign: 'middle'
-                            });
-                            // %
-                            pdfDoc.rect(123, row.y + 8, 5, 8, 'S');
-                            pdfDoc.autoTableText("%", 126, row.y + row.height / 2 + 8, {
-                                halign: 'center',
-                                valign: 'middle'
-                            });
-                            // IMPUESTOS
-                            pdfDoc.rect(128, row.y + 8, 15, 8, 'S');
-                            pdfDoc.autoTableText("IMPUESTOS", 136, row.y + row.height / 2 + 8, {
-                                halign: 'center',
-                                valign: 'middle'
-                            });
-                            // EXENTAS
-                            pdfDoc.rect(143, row.y + 8, 20, 8, 'S');
-                            pdfDoc.autoTableText("EXENTAS", 152, row.y + row.height / 2 + 8, {
-                                halign: 'center',
-                                valign: 'middle'
-                            });
-                            // Ret IVA
-                            pdfDoc.rect(163, row.y + 8, 10, 8, 'S');
-                            pdfDoc.autoTableText("Ret", 168, row.y + row.height / 2 + 8, {
-                                halign: 'center',
-                                valign: 'middle'
-                            });
-                            pdfDoc.autoTableText("IVA", 168, row.y + row.height / 2 + 10, {
-                                halign: 'center',
-                                valign: 'middle'
-                            });
-                            // Ret Renta
-                            pdfDoc.rect(173, row.y + 8, 10, 8, 'S');
-                            pdfDoc.autoTableText("Ret", 179, row.y + row.height / 2 + 8, {
-                                halign: 'center',
-                                valign: 'middle'
-                            });
-                            pdfDoc.autoTableText("RENTA", 178, row.y + row.height / 2 + 10, {
-                                halign: 'center',
-                                valign: 'middle'
-                            });
-                            // TOTAL
-                            pdfDoc.rect(183, row.y + 8, 20, 8, 'S');
-                            pdfDoc.autoTableText("TOTAL", 192, row.y + row.height / 2 + 8, {
-                                halign: 'center',
-                                valign: 'middle'
-                            });
-                            data.cursor.y += 16;
-                        };
-                    }
-                },
-
-                drawCell: function(cell, data) {
-                    var rows = data.table.rows;
-                    if (data.row.index == rows.length - 1) {
-                        pdfDoc.setFillColor(200, 200, 255);
-                    }
-                },
-
                 styles: {
                     overflow: 'linebreak',
                     columnWidth: 'auto',
@@ -515,14 +80,17 @@ function pdf(reporting) {
                     fillColor: [76, 133, 248],
                     fontSize: 9
                 },
-
                 columnStyles: pdf_columnStyles,
-                margin: { top: 28, horizontal: 7},
-
+                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
-                    ===========*/
+
+                //FOOTER
                     var str = "Página " + data.pageCount;
                     if (typeof pdfDoc.putTotalPages === 'function') {
                         str = str + " de " + totalPagesExp;
@@ -531,15 +99,12 @@ function pdf(reporting) {
                     pdfDoc.setFontStyle('bold');
                     pdfDoc.setTextColor(40);
                     var pageHeight = pdfDoc.internal.pageSize.height || pdfDoc.internal.pageSize.getHeight();
-                    pdfDoc.text(str, pdfDoc.internal.pageSize.getWidth() - 55, pageHeight - 5);
+                    pdfDoc.autoTableText(str, pdfDoc.internal.pageSize.getWidth() - 35, pageHeight - 5, {
+                      halign: 'rigth',
+                      valign: 'middle'
+                    });
                 }
             });
-
-            pdfDoc.setFontSize(9);
-            pdfDoc.setFontStyle('bold');
-            pdfDoc.setTextColor(40);
-            pdfDoc.text('Listado concluido', 7, pdfDoc.autoTable.previous.finalY + 5);
-
             if (typeof pdfDoc.putTotalPages === 'function') {
                 pdfDoc.putTotalPages(totalPagesExp);
             }
@@ -552,607 +117,21 @@ function pdf(reporting) {
             pdfDoc.save(pdf_name + hoy + '.pdf');
         },
 
-        drawWithDetails: function (getColumns,row,ResCompany,pdf_title,pdf_type,pdf_name,pdf_columnStyles,amount) {
-            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 title = [];
-            title.push({
-                title : 'Metodo de Pago',
-                dataKey: 'name',
-                align: 'left',
-            });
-            title.push({
-                title : 'Monto',
-                dataKey: 'amount',
-                align: 'right',
-            });
-            var i = 0;
-            var position = 25;
-            _.each(row, function(item){
-                var docItem = [];
-                if(item.info != 'undefined'){
-                    _.each(item.info, function(index){
-                        docItem.push({
-                            name: index.journal,
-                            amount: index.amount_total
-                        });
-                    });
-                };
-                docItem.push({
-                    name: 'Total',
-                    amount: item.amount_total
-                });
-
-                if(row.length <= 2 & row.length == i+1){
-                    return false;
-                };
-
-                if(i > 0){
-                    let first = pdfDoc.autoTable.previous;
-                    position = first.finalY + 7;
-                    pdfDoc.rect(7, position - 7, 196, 10, 'S');
-                };
-                pdfDoc.setFontSize(10);
-                pdfDoc.autoTableText(item.store, 102, position - 3, {
-                    halign: 'center',
-                    valign: 'middle'
-                });
-                pdfDoc.autoTable(title, docItem, {
-                    showHeader: false,
-                    startY: position,
-                    theme: 'grid',
-                    styles: {
-                        overflow: 'linebreak',
-                        columnWidth: 'auto',
-                        fontSize: 7,
-                    },
-                    headerStyles: {
-                        fillColor: [76, 133, 248],
-                        fontSize: 9
-                    },
-                    columnStyles: {
-                        name:{halign:'left'},
-                        amount:{columnWidth: 50, halign:'right'},
-                    },
-                    margin: { horizontal: 7},
-                    drawCell: function(cell, data) {
-                        var rows = data.table.rows;
-                        if (data.row.index == rows.length - 1) {
-                            pdfDoc.setFontStyle('bold');
-                        }
-                    },
-                    addPageContent: function (data) {
-                        if(i == 0){
-                            pdfDoc.addImage(base64Img, 'png', 7, 2, 0, 15);
-                            if(pdf_type == 'l'){
-                                pdfDoc.setFontSize(12);
-                                pdfDoc.setFontStyle('bold');
-                                pdfDoc.setTextColor(40);
-                                pdfDoc.text(pdf_title,130,10);
-                            }else{
-                                pdfDoc.setFontSize(12);
-                                pdfDoc.setFontStyle('bold');
-                                pdfDoc.setTextColor(40);
-                                pdfDoc.text(pdf_title,80,10);
-                            }
-                            pdfDoc.setFontSize(9);
-                            pdfDoc.setFontStyle('normal');
-                            pdfDoc.setTextColor(40)
-                            pdfDoc.text(pdfDoc.internal.pageSize.getWidth() - 55, 14," Fecha de Expedición: " + hoy);
-
-                            /*===========
-                                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.text(str, pdfDoc.internal.pageSize.getWidth() - 55, pageHeight - 5);
-                        }
-                    }
-                });
-                i++;
-            });
-
-            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');
-        },
-
-        drawProfitAndLossPDF: function (
-            getColumns,
-            row,
-            ResCompany,
-            pdf_title,
-            pdf_type,
-            pdf_name,
-            amount
-            ) {
-            var self = this;
-            var sale = [];
-            var expense = [];
-            var column = [];
-            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);
-
-            /*
-            ============================
-                VENTAS
-            ============================
-            */
-            var coste = 0;
-            var profit = 0;
-            _.each(row, function(item){
-                if(item.type == 'sale'){
-                    sale.push({
-                        name : item.store,
-                        total : item.amount_total,
-                    });
-                };
-                if(item.expense == true){
-                    coste = item.amount_total;
-                };
-                if(item.profit == true){
-                    profit = item.amount_total;
-                };
-                if(item.expense_detail == true){
-                    expense.push({
-                        name : item.store,
-                        total : item.amount_total,
-                    });
-                };
-            });
-            column.push({
-                title : 'Name',
-                dataKey: 'name',
-                align: 'left',
-            });
-            column.push({
-                title : 'total',
-                dataKey: 'total',
-                align: 'right',
-            });
-
-            /*
-            ==============================
-                LOGO
-            ==============================
-            */
-            pdfDoc.addImage(base64Img, 'png', 10, 10, 0, 20);
-            /*
-            ==============================
-                FECHA
-            ==============================
-            */
-            pdfDoc.setFontSize(13);
-            pdfDoc.setFontStyle('normal');
-            pdfDoc.setTextColor(40)
-            pdfDoc.text(pdfDoc.internal.pageSize.getWidth() - 32, 12,hoy);
-            /*
-            ==============================
-                TITULO
-            ==============================
-            */
-            pdfDoc.setFontSize(15);
-            pdfDoc.setFontStyle('bold');
-            pdfDoc.setTextColor('#0288d1');
-            pdfDoc.text(pdfDoc.internal.pageSize.getWidth() - 75, 18, pdf_title);
-            /*
-            ==============================
-                DESCRIPCION
-            ==============================
-            */
+        addFilter: function(pdfDoc,title,value,x_position_title,x_position_value,y_position){
             pdfDoc.setFontSize(10);
-            pdfDoc.setFontStyle('bold');
             pdfDoc.setTextColor('#424242');
-            pdfDoc.text(10, 38, 'Descripción');
-            /*
-            ==============================
-                LINEA
-            ==============================
-            */
-            pdfDoc.setLineWidth(0.5);
-            pdfDoc.setDrawColor('#424242');
-            pdfDoc.line(10, 40, pdfDoc.internal.pageSize.getWidth() - 10 , 40);
-            /*
-            ==============================
-                VENTAS
-            ==============================
-            */
-            pdfDoc.setFontSize(10);
             pdfDoc.setFontStyle('bold');
-            pdfDoc.setTextColor('#424242');
-            pdfDoc.text(10, 45, 'VENTAS');
-
-            /*
-            ==============================
-                PRIMERA TABLA
-            ==============================
-            */
-            pdfDoc.autoTable(column, sale, {
-                showHeader: false,
-                theme: 'plain',
-                styles: {
-                    overflow: 'linebreak',
-                    columnWidth: 'auto',
-                    fontSize: 9,
-                },
-                columnStyles: {
-                    amount:{halign:'left'},
-                    total:{columnWidth: 50, halign:'right'},
-                },
-                margin: { top: 48, horizontal: 20},
-                drawCell: function(cell, data) {
-                    var rows = data.table.rows;
-                    if (data.row.index == rows.length - 1) {
-                        pdfDoc.setTextColor('#0288d1');
-                        pdfDoc.setFontStyle('bold');
-                    };
-                },
+            pdfDoc.autoTableText(title+':', x_position_title, y_position, {
+                halign: 'left',
+                valign: 'middle'
             });
-            /*
-            ==============================
-                LINEA
-            ==============================
-            */
-            pdfDoc.setLineWidth(0.5);
-            pdfDoc.setDrawColor('#424242');
-            pdfDoc.line(10, pdfDoc.autoTable.previous.finalY + 1, pdfDoc.internal.pageSize.getWidth() - 10 , pdfDoc.autoTable.previous.finalY + 1);
-            /*
-            ==============================
-                COSTE DE VENTAS
-            ==============================
-            */
-            pdfDoc.setFontSize(10);
-            pdfDoc.setFontStyle('bold');
-            pdfDoc.setTextColor('#424242');
-            pdfDoc.text(10, pdfDoc.autoTable.previous.finalY + 7, 'Coste de ventas');
-            /*
-            ==============================
-                COSTE DE VENTAS - valor
-            ==============================
-            */
             pdfDoc.setFontSize(10);
-            pdfDoc.setFontStyle('bold');
             pdfDoc.setTextColor('#424242');
-            pdfDoc.text(pdfDoc.internal.pageSize.getWidth() - 35, pdfDoc.autoTable.previous.finalY + 7, coste);
-            /*
-            ==============================
-                LINEA
-            ==============================
-            */
-            pdfDoc.setLineWidth(0.5);
-            pdfDoc.setDrawColor('#424242');
-            pdfDoc.line(10, pdfDoc.autoTable.previous.finalY + 10, pdfDoc.internal.pageSize.getWidth() - 10 , pdfDoc.autoTable.previous.finalY + 10);
-            /*
-            ==============================
-                BENEFICIO
-            ==============================
-            */
-            pdfDoc.setFontSize(10);
-            pdfDoc.setFontStyle('bold');
-            pdfDoc.setTextColor(40);
-            pdfDoc.text(10, pdfDoc.autoTable.previous.finalY + 15, 'BENEFICIO BRUTO');
-            /*
-            ==============================
-                BENEFICIO - valor
-            ==============================
-            */
-            pdfDoc.setFontSize(10);
-            pdfDoc.setFontStyle('bold');
-            pdfDoc.setTextColor('#0288d1');
-            pdfDoc.text(pdfDoc.internal.pageSize.getWidth() - 35, pdfDoc.autoTable.previous.finalY + 15, profit);
-            /*
-            ==============================
-                SEGUNDA TABLA
-            ==============================
-            */
-            var dynamic_top = pdfDoc.autoTable.previous.finalY + 25;
-            pdfDoc.autoTable(column, expense, {
-                showHeader: false,
-                theme: 'plain',
-                styles: {
-                    overflow: 'linebreak',
-                    columnWidth: 'auto',
-                    fontSize: 9,
-                },
-                columnStyles: {
-                    amount:{halign:'left'},
-                    total:{columnWidth: 50, halign:'right'},
-                },
-                startY: pdfDoc.autoTable.previous.finalY + 25,
-                margin: {
-                    horizontal: 20
-                },
-                drawCell: function(cell, data) {
-                    var rows = data.table.rows;
-                    if (data.row.index == rows.length - 1) {
-                        pdfDoc.setTextColor('#0288d1');
-                        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.text(str, pdfDoc.internal.pageSize.getWidth() - 55, pageHeight - 5);
-                },
-            });
-
-            /*
-            ==============================
-                LINEA
-            ==============================
-            */
-            pdfDoc.setLineWidth(0.5);
-            pdfDoc.setDrawColor('#424242');
-            pdfDoc.line(10, pdfDoc.autoTable.previous.finalY + 10, pdfDoc.internal.pageSize.getWidth() - 10 , pdfDoc.autoTable.previous.finalY + 10);
-            /*
-            ==============================
-                RESULTADO
-            ==============================
-            */
-            pdfDoc.setFontSize(10);
-            pdfDoc.setFontStyle('bold');
-            pdfDoc.setTextColor(40);
-            pdfDoc.text(10, pdfDoc.autoTable.previous.finalY + 15, 'RESULTADO');
-            /*
-            ==============================
-                VALOR FINAL
-            ==============================
-            */
-            pdfDoc.setFontSize(10);
-            pdfDoc.setFontStyle('bold');
-            pdfDoc.setTextColor('#0288d1');
-            pdfDoc.text(pdfDoc.internal.pageSize.getWidth() - 35, pdfDoc.autoTable.previous.finalY + 15, amount);
-
-            if (typeof pdfDoc.putTotalPages === 'function') {
-                pdfDoc.putTotalPages(totalPagesExp);
-            }
-
-            if(model.printer_bridge){
-                var data = pdfDoc.output('datauristring');
-                model.printer_bridge.print(data);
-                return;
-            };
-            pdfDoc.save(pdf_name + hoy + '.pdf');
-        },
-
-        getPDFFileButton: function  () {
-            var canvas = $(".reporting-chart").get(0);
-            var dataURL = canvas.toDataURL();
-            var pdf = new jsPDF();
-            pdf.addImage(dataURL, 'JPEG', 10, 10, 190, 70);
-            pdf.save("chart.pdf");
-        },
-
-        // pdf resumen de ventas diarias cod:3
-        drawPdf3: function (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 title = [];
-          var currentpage = 0;
-          var i = 0;
-          var position = 27;
-          var y_position2 = 27;
-
-          title.push({
-            title : 'Fecha',
-            dataKey: 'date',
-            align: 'center',
-          });
-          title.push({
-            title : 'Sucursal',
-            dataKey: 'store',
-            align: 'center',
-          });
-          title.push({
-            title : 'Cantidad',
-            dataKey: 'qty',
-            align: 'center',
-          });
-          title.push({
-            title : 'Monto de Venta',
-            dataKey: 'price',
-            align: 'right',
-          });
-          title.push({
-            title : 'Promedio de Venta Total',
-            dataKey: 'average',
-            align: 'right',
-          });
-
-          //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 ii=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(ii<4){
-                self.addFilter(pdfDoc,item.title,item.value,col1_title,col1_value,position);
-                position = position + 5;
-              }else{
-                self.addFilter(pdfDoc,item.title,item.value,col2_title,col2_value,y_position2);
-                y_position2 = y_position2 + 5;
-              }
-                ii++;
-            });
-            pdfDoc.setLineWidth(0.5);
-            pdfDoc.setDrawColor('#424242');
-
-            if(position >= y_position2){
-              position = position;
-              pdfDoc.line(10, position, pdfDoc.internal.pageSize.getWidth() - 10 , position);
-            }else{
-              position = y_position2;
-              pdfDoc.line(10, y_position2, pdfDoc.internal.pageSize.getWidth() - 10 , y_position2);
-            }
-          }
-
-          _.each(row, function(item){
-            if(i > 0){
-              let first = pdfDoc.autoTable.previous;
-              position = first.finalY + 5;
-            };
-
-            var docItem = [];
-            if(item.info != 'undefined'){
-              _.each(item.info, function(index){
-                docItem.push({
-                  date: index.date,
-                  store: index.store,
-                  qty: index.qty,
-                  price: index.price,
-                  average: index.average,
-                })
-              });
-            }
-
-            pdfDoc.setDrawColor(0);
-            pdfDoc.setFillColor(76, 133, 248);
-            pdfDoc.rect(7, position+5, 196, 8, 'F');
-
-            pdfDoc.setFontSize(9);
-            pdfDoc.setTextColor(255,255,255)
-            pdfDoc.setFontStyle('bold');
-
-            pdfDoc.autoTableText('Vendedor: ', 15, position+9, {
-              halign: 'left',
-              valign: 'middle'
-            });
-
-            pdfDoc.autoTableText(item.user, 33, position+9, {
-              halign: 'left',
-              valign: 'middle'
-            });
-
-            pdfDoc.autoTableText('Cantidad: ', 110, position+9, {
-              halign: 'left',
-              valign: 'middle'
-            });
-
-            pdfDoc.autoTableText(item.qty, 126, position+9, {
-              halign: 'left',
-              valign: 'middle'
-            });
-
-            pdfDoc.autoTableText('Monto Total: ', 145, position+9, {
-              halign: 'left',
-              valign: 'middle'
-            });
-
-            pdfDoc.autoTableText(item.price, 165, position+9, {
-              halign: 'left',
-              valign: 'middle'
-            });
-
-            pdfDoc.autoTable(title, docItem, {
-              //  showHeader: false,
-              startY: position+15,
-              theme: 'grid',
-              styles: {
-                overflow: 'linebreak',
-                fontSize: 8,
-                margin: 50,
-                lineWidth: 0.3,
-                lineColor: [132,132,132]
-              },
-              headerStyles: {
-                fillColor: [255,255,255],
-                fontSize: 9,
-                textColor: [0,0,0],
-                lineWidth: 0.3,
-                lineColor: [132,132,132]
-              },
-              columnStyles: pdf_columnStyles,
-              margin: 'auto',
-              tableWidth: 'auto',
-
-              addPageContent: function (data) {
-                // FOOTER
-                if (currentpage < pdfDoc.internal.getNumberOfPages()) {
-                  var str = "Página " + pdfDoc.internal.getNumberOfPages();
-                  str = str + " de " + totalPagesExp;
-                  pdfDoc.setFontSize(9);
-                  pdfDoc.setFontStyle('bold');
-                  pdfDoc.setTextColor(40);
-                  var pageHeight = pdfDoc.internal.pageSize.height || pdfDoc.internal.pageSize.getHeight();
-                  pdfDoc.text(str, pdfDoc.internal.pageSize.getWidth() - 55, pageHeight - 5);
-                  currentpage = pdfDoc.internal.getNumberOfPages();
-                }
-              }
+            pdfDoc.setFontStyle('normal');
+            pdfDoc.autoTableText(value, x_position_value, y_position, {
+                halign: 'left',
+                valign: 'middle'
             });
-            i++;
-          });
-          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');
         },
-        //end cod:3
-
     });
 }

+ 0 - 282
static/src/js/reports/report_customer.js

@@ -1,282 +0,0 @@
-function report_customer(reporting){
-    "use strict";
-
-    var model = openerp;
-
-    reporting.ReportCustomerWidget = reporting.Base.extend({
-        template: 'ReportCustomer',
-        rowsData :[],
-        content :[],
-
-        events:{
-            'click #toolbar > button' : 'clickOnAction',
-            'click #generate' : 'fetchGenerate',
-        },
-
-        init : function(parent){
-            this._super(parent);
-        },
-
-        start: function () {
-            var table = this.$el.find('#table');
-            table.bootstrapTable({data : self.rowsData});
-            var date = new reporting.ReportDatePickerWidget(self);
-            date.fecthFecha();
-            this.fetchInitial();
-        },
-
-        valorNull:function(dato){
-            var valor = "";
-            if (dato){
-                valor = dato;
-            }
-            return valor;
-        },
-
-        fetchInitial: function () {
-            var self = this;
-            self.fetchIntialSQL().then(function (IntialSQL) {
-                return IntialSQL;
-            }).then(function(IntialSQL) {
-                /*
-                =================================
-                    RES COMPANY
-                =================================
-                */
-                self.ResCompany = IntialSQL.companies;
-                self.CompanyLogo = IntialSQL.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 = IntialSQL.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');
-                // }
-            });
-            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.customers;
-                return self.BuildTable();
-            });
-        },
-
-        fetchIntialSQL: function() {
-            var self = this;
-            var data = $.get('/report-filter-data');
-            return data;
-        },
-
-        fetchDataSQL: function() {
-            var self = this;
-            var data = $.get('/report-customers');
-            return data;
-        },
-
-        getResPartner: function(){
-            var self = this;
-            var content = self.ResPartner;
-            var company = self.$el.find('#current-company').val();
-            var store = self.$el.find('#current-store').val();
-
-            var company_ids = _.flatten(_.map(self.ResCompany, function (item) {
-                return item.id;
-            }));
-            company_ids.push(null);
-
-            var store_ids = _.flatten(_.map(self.ResStore, function (item) {
-                return item.id;
-            }));
-            store_ids.push(null);
-
-            content = _.flatten(_.filter(content,function (item) {
-                return _.contains(store_ids, item.store_id);
-            }));
-
-            content = _.flatten(_.filter(content,function (item) {
-                return _.contains(company_ids, item.company_id);
-            }));
-
-            if(company && company != 9999999){
-                content = _.flatten(_.filter(content,function (item) {
-                    return item.company_id == company;
-                }));
-            }
-
-            if(store && store != 9999999){
-                content = _.flatten(_.filter(content,function (item) {
-                    return item.store_id == store;
-                }));
-            }
-
-            return content;
-        },
-
-        BuildTable: function(){
-            var self = this;
-            var data = [];
-            console.log(self);
-            var ResPartner = self.getResPartner();
-            _.each(ResPartner, function(item){
-                data.push({
-                    id : item.id,
-                    ruc : self.valorNull(item.ruc),
-                    name : item.name,
-                    street : self.valorNull(item.street) + ' ' + self.valorNull(item.street2),
-                    phone : self.valorNull(item.phone),
-                    mobile : self.valorNull(item.mobile),
-                    email : self.valorNull(item.email),
-                    country : self.valorNull(item.country),
-                    state : self.valorNull(item.state),
-                });
-            });
-
-            self.content = data;
-            self.loadTable(data);
-            self.$el.find('.report-form').css('display','block');
-            self.$el.find('.search-form').unblock();
-            self.$el.find('.report-form').unblock();
-        },
-
-        /*====================================================================
-            LOAD BOOTSTRAP TABLE
-        ====================================================================*/
-        loadTable:function(rowsTable){
-            var self = this;
-            self.rowsData = rowsTable;
-            var table = this.$el.find('#table');
-            table.bootstrapTable('load', rowsTable);
-        },
-
-        /*====================================================================
-            PRINT PDF
-        ====================================================================*/
-        clickOnAction: function (e) {
-            var self = this;
-            var ResCompany;
-            var 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 = ResCompany[0];
-                CurrencyBase = ResCompany[0].currency_id;
-            }else{
-                ResCompany = self.ResCompany[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');
-
-            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 = 'Clientes.';
-                var pdf_type = 'l';
-                var pdf_name = 'clientes_';
-                var pdf_columnStyles = {
-                    ruc : {columnWidth: 20, halign:'left'},
-                    name : {halign:'left'},
-                    street : {columnWidth: 30, halign:'left'},
-                    state : {columnWidth: 30, halign:'left'},
-                    country : {columnWidth: 30, halign:'left'},
-                    phone : {columnWidth: 30, halign:'left'},
-                    mobile : {columnWidth: 30, halign:'left'},
-                    email : {columnWidth: 40, halign:'left'},
-                };
-                /*
-                ============================================================
-                    LLAMAR FUNCION DE IMPRESION
-                ============================================================
-                */
-                var filter = self.getFilter();
-                var pdf = new reporting.ReportPdfWidget(self);
-                pdf.drawPDF(
-                    _.flatten(getColumns),
-                    row,
-                    ResCompany,
-                    pdf_title,
-                    pdf_type,
-                    pdf_name,
-                    pdf_columnStyles,
-                    filter
-                );
-            }
-        },
-        getFilter: function(){
-            var self = this;
-            var company = self.$el.find('#current-company').val();
-            var type = self.$el.find('#current-type').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(type && type != 9999999){
-                filter.push({
-                    title: 'Tipo de Cliente',
-                    value: $('#current-type option:selected').text(),
-                });
-            }
-            return filter;
-        },
-    });
-}

+ 21 - 3
static/src/js/reports/report_customer_ranking.js

@@ -253,6 +253,15 @@ function report_customer_ranking(reporting){
             var date = self.$el.find('#current-date').val();
             var desde = self.$el.find('#from').val();
             var hasta = self.$el.find('#to').val();
+            var store_ids = _.flatten(_.map(self.ResStore, function (item) {
+                return item.id;
+            }));
+            var company_ids = _.flatten(_.map(self.ResCompany, function (item) {
+                return item.id;
+            }));
+            content = _.flatten(_.filter(content,function (item) {
+                return _.contains(store_ids, item.store_id) && _.contains(company_ids, item.company_id);
+            }));
             if(company && company != 9999999){
                 content = _.flatten(_.filter(content,function (item) {
                     return item.company_id == company;
@@ -384,6 +393,15 @@ function report_customer_ranking(reporting){
             var date = self.$el.find('#current-date').val();
             var desde = self.$el.find('#from').val();
             var hasta = self.$el.find('#to').val();
+            var store_ids = _.flatten(_.map(self.ResStore, function (item) {
+                return item.id;
+            }));
+            var company_ids = _.flatten(_.map(self.ResCompany, function (item) {
+                return item.id;
+            }));
+            content = _.flatten(_.filter(content,function (item) {
+                return _.contains(store_ids, item.store_id) && _.contains(company_ids, item.company_id);
+            }));
             if(company && company != 9999999){
                 content = _.flatten(_.filter(content,function (item) {
                     return item.company_id == company;
@@ -589,13 +607,13 @@ function report_customer_ranking(reporting){
             var action = this.$el.find(e.target).val();
             var company = $('#current-company').val();
             if(company && company != 9999999){
-                ResCompany = _.flatten(_.filter(self.CompanyLogo,function (inv) {
+                ResCompany = _.flatten(_.filter(self.ResCompany,function (inv) {
                     return inv.id == company;
                 }));
                 ResCompany = ResCompany[0];
                 CurrencyBase = ResCompany[0].currency_id;
             }else{
-                ResCompany = self.CompanyLogo[0];
+                ResCompany = self.ResCompany[0];
                 CurrencyBase = self.ResCompany[0].currency_id;
             }
             var getColumns=[];
@@ -642,7 +660,7 @@ function report_customer_ranking(reporting){
                 ============================================================
                 */
                 var filter = self.getFilter();
-                var pdf = new reporting.ReportPdfWidget(self);
+                var pdf = new reporting.ReportSalePdfWidget(self);
                 pdf.drawPDF(
                     _.flatten(getColumns),
                     row,

+ 0 - 509
static/src/js/reports/report_expense.js

@@ -1,509 +0,0 @@
-function report_expense(reporting){
-    "use strict";
-
-    var model = openerp;
-
-    reporting.ReportExpenseWidget = reporting.Base.extend({
-        template: 'ReportExpense',
-        rowsData :[],
-        content :[],
-
-        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 reporting.ReportDatePickerWidget(self);
-            date.fecthFecha();
-            this.fetchInitial();
-        },
-
-        valorNull:function(dato){
-            var valor = "";
-            if (dato){
-                valor = dato;
-            }
-            return valor;
-        },
-
-        ShowDateRange : function(){
-            var self = this;
-            var date = self.$el.find('#current-date').val();
-            if(date == 'range'){
-                self.$el.find('.datepicker').css('display','block');
-            }
-            if(date != 'range'){
-                self.$el.find('.datepicker').css('display','none');
-            }
-        },
-
-        fetchInitial: function () {
-            var self = this;
-            self.fetchIntialSQL().then(function (IntialSQL) {
-                return IntialSQL;
-            }).then(function(IntialSQL) {
-                /*
-                =================================
-                    RES COMPANY
-                =================================
-                */
-                self.ResCompany = IntialSQL.companies;
-                self.CompanyLogo = IntialSQL.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 = IntialSQL.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');
-                }
-                /*
-                =================================
-                    ACCOUNT JOURNAL
-                =================================
-                */
-                self.AccountJournal = IntialSQL.journals;
-                if(self.AccountJournal.length > 1){
-                    self.$el.find('#current-journal').append('<option value="9999999">Todas las facturas</option>');
-                    _.each(self.AccountJournal,function(item){
-                        if(item.type == 'sale'){
-                            self.$el.find('#current-journal').append('<option value="' + item.id + '">' + item.name + '</option>');
-                        }
-                    });
-                }else{
-                    self.$el.find('.journal').css('display','none');
-                }
-                /*
-                =================================
-                    RES USERS
-                =================================
-                */
-                self.ResUsers = IntialSQL.users;
-                var store_ids = _.flatten(_.map(self.ResStore, function (item) {
-                    return item.id;
-                }));
-                var ResUsers = _.flatten(_.filter(self.ResUsers,function (item) {
-                    return _.contains(store_ids, item.store_id);
-                }));
-                if(ResUsers.length > 1){
-                    self.$el.find('#current-user').append('<option value="9999999">Todos los Responsables</option>');
-                    _.each(ResUsers,function(item){
-                        self.$el.find('#current-user').append('<option value="' + item.id + '">' + item.name + '</option>');
-                    });
-                }
-            });
-            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.PosOrder = DataSQL.orders;
-                self.AccountVoucher = DataSQL.vouchers;
-                return self.BuildTable();
-            });
-        },
-
-        fetchIntialSQL: function() {
-            var self = this;
-            var data = $.get('/report-filter-data');
-            return data;
-        },
-
-        fetchDataSQL: function() {
-            var self = this;
-            var data = $.get('/report-expense-history');
-            return data;
-        },
-
-        /*====================================================================
-            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() {
-            var self = this;
-            var content = self.AccountInvoice;
-            var company = self.$el.find('#current-company').val();
-            var store = self.$el.find('#current-store').val();
-            var state = self.$el.find('#current-state').val();
-            var user = self.$el.find('#current-user').val();
-            var date = self.$el.find('#current-date').val();
-            var desde = self.$el.find('#from').val();
-            var hasta = self.$el.find('#to').val();
-
-            var store_ids = _.flatten(_.map(self.ResStore, function (item) {
-                return item.id;
-            }));
-
-            var company_ids = _.flatten(_.map(self.ResCompany, function (item) {
-                return item.id;
-            }));
-
-            content = _.flatten(_.filter(content,function (item) {
-                return _.contains(store_ids, item.store_id) && _.contains(company_ids, item.company_id);
-            }));
-
-            if(company && company != 9999999){
-                content = _.flatten(_.filter(content,function (item) {
-                    return item.company_id == company;
-                }));
-            }
-            if(store && store != 9999999){
-                content = _.flatten(_.filter(content,function (item) {
-                    return item.store_id == store;
-                }));
-            }
-            if(state && state != 9999999){
-                content = _.flatten(_.filter(content,function (item) {
-                    return item.state == state;
-                }));
-            }
-            if(user && user != 9999999){
-                content = _.flatten(_.filter(content,function (item) {
-                    return item.user_id == user;
-                }));
-            }
-            if(date && date != 9999999){
-                if(date == 'range'){
-                    if(desde){
-                        date = desde.split('/');
-                        date = (date[2]+"-"+date[1]+"-"+date[0]);
-                        content = _.flatten(_.filter(content,function (inv) {
-                            return moment(inv.date).format('YYYY-MM-DD') >= date;
-                        }));
-                    }
-                    if(hasta){
-                        date = hasta.split('/');
-                        date = (date[2]+"-"+date[1]+"-"+date[0]);
-                        content = _.flatten(_.filter(content,function (inv) {
-                            return moment(inv.date).format('YYYY-MM-DD') <= date;
-                        }));
-                    }
-                }
-                if(date == 'today'){
-                    var today = moment().format('YYYY-MM-DD');
-                    content = _.flatten(_.filter(content,function (inv) {
-                        return moment(inv.date).format('YYYY-MM-DD') === today;
-                    }));
-                }
-                if(date == 'yesterday'){
-                    var yesterday = moment().add(-1,'days').format('YYYY-MM-DD');
-                    content = _.flatten(_.filter(content,function (inv) {
-                        return moment(inv.date).format('YYYY-MM-DD') === yesterday;
-                    }));
-                }
-                if(date == 'currentMonth'){
-                    var currentMonth = moment().format('YYYY-MM');
-                    content = _.flatten(_.filter(content,function (inv) {
-                        return moment(inv.date).format('YYYY-MM') === currentMonth;
-                    }));
-                }
-                if(date == 'lastMonth'){
-                    var lastMonth = moment().add(-1,'months').format('YYYY-MM');
-                    content = _.flatten(_.filter(content,function (inv) {
-                        return moment(inv.date).format('YYYY-MM') === lastMonth;
-                    }));
-                }
-            }
-            return content;
-        },
-
-        getAccountVoucher: function (number) {
-            var self = this;
-            return _.filter(self.AccountVoucher,function (item) {
-                return item.reference == number;
-            });
-        },
-
-        BuildTable: function(){
-            var self = this;
-            console.log(self);
-            var data = [];
-            var residual = 0;
-            var CurrencyBase = self.ResCompany[0].currency_id;
-            var AccountInvoice = self.getAccountInvoice();
-            _.each(AccountInvoice, function(item){
-                residual = 0;
-                if(item.state == 'open'){
-                    residual = self.getAccountVoucher(item.number);
-                    residual =  _.reduce(_.map(residual,function(item){
-                        return item.amount_currency;
-                    }), function(memo, num){
-                        return memo + num;
-                    },0);
-                    residual = item.amount - residual;
-                }
-                data.push({
-                    /*
-                    =======================
-                        IDS
-                    =======================
-                    */
-                    id:item.id,
-                    /*
-                    =======================
-                        INFO
-                    =======================
-                    */
-                    origin:item.origin,
-                    number:item.number,
-                    date:moment(item.date).format('DD/MM/YYYY'),
-                    user_name:item.user_name,
-                    user_id:item.user_id,
-                    supplier_name:self.valorNull(item.supplier_name),
-                    residual:accounting.formatMoney(residual,'',CurrencyBase.decimal_places,CurrencyBase.thousands_separator,CurrencyBase.decimal_separator),
-                    untaxed:accounting.formatMoney(item.amount - item.amount_tax,'',CurrencyBase.decimal_places,CurrencyBase.thousands_separator,CurrencyBase.decimal_separator),
-                    tax:accounting.formatMoney(item.amount_tax,'',CurrencyBase.decimal_places,CurrencyBase.thousands_separator,CurrencyBase.decimal_separator),
-                    total:accounting.formatMoney(item.amount,'',CurrencyBase.decimal_places,CurrencyBase.thousands_separator,CurrencyBase.decimal_separator),
-                    /*
-                    =======================
-                        NO FORMAT
-                    =======================
-                    */
-                    date_no_format: moment(item.date).format('YYYY-MM-DD'),
-                    residual_no_format:residual,
-                    untaxed_no_format:item.amount - item.amount_tax,
-                    tax_no_format:item.amount_tax,
-                    total_no_format:item.amount,
-                    /*
-                    =======================
-                        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.CompanyLogo,function (inv) {
-                    return inv.id == company;
-                }));
-                ResCompany = ResCompany[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 residual = ResidualFooter(row);
-            var untaxed = UntaxedFooter(row);
-            var tax = TaxFooter(row);
-            var total = TotalFooter(row);
-
-            row.push({
-                number:'Totales',
-                residual:residual,
-                untaxed:untaxed,
-                tax:tax,
-                total:total,
-            });
-
-            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 = 'Facturas de Gastos.';
-                var pdf_type = '';
-                var pdf_name = 'facturas_de_gastos_';
-                var pdf_columnStyles = {
-                    number:{columnWidth: 30,halign:'left'},
-                    date:{halign:'center'},
-                    user_name:{ halign:'left'},
-                    supplier_name:{columnWidth: 30, halign:'left'},
-                    residual:{columnWidth: 20, halign:'right'},
-                    untaxed:{columnWidth: 20, halign:'right'},
-                    tax:{columnWidth: 20, halign:'right'},
-                    total:{columnWidth: 20, halign:'right'},
-                };
-                /*
-                ============================================================
-                    LLAMAR FUNCION DE IMPRESION
-                ============================================================
-                */
-                var filter = self.getFilter();
-                var pdf = new reporting.ReportPdfWidget(self);
-                pdf.drawPDF(
-                    _.flatten(getColumns),
-                    row,
-                    ResCompany,
-                    pdf_title,
-                    pdf_type,
-                    pdf_name,
-                    pdf_columnStyles,
-                    filter
-                );
-            }
-        },
-        getFilter: function(){
-            var self = this;
-            var company = self.$el.find('#current-company').val();
-            var store = self.$el.find('#current-store').val();
-            var state = self.$el.find('#current-state').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(state && state != 9999999){
-                filter.push({
-                    title: 'Estado',
-                    value: $('#current-state 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;
-        },
-    });
-}

Rozdielové dáta súboru neboli zobrazené, pretože súbor je príliš veľký
+ 287 - 589
static/src/js/reports/report_product_list.js


+ 1 - 1
static/src/js/reports/report_sale.js

@@ -660,7 +660,7 @@ function report_sale(reporting){
                 ============================================================
                 */
                 var filter = self.getFilter();
-                var pdf = new reporting.ReportPdfWidget(self);
+                var pdf = new reporting.ReportSalePdfWidget(self);
                 pdf.drawPDF(
                     _.flatten(getColumns),
                     row,

+ 7 - 2
static/src/js/reports/report_sale_analytic.js

@@ -121,6 +121,11 @@ function report_sale_analytic(reporting){
                         self.$el.find('#current-category').append('<option value="' + item.id + '">' + item.name + '</option>');
                     });
                 }
+                /*
+                =================================
+                    PRODUCT BRAND
+                =================================
+                */
                 self.ProductBrand = IntialSQL.brands;
                 if(self.ProductBrand.length > 1){
                     self.$el.find('#current-brand').append('<option value="9999999">Todas las Marcas</option>');
@@ -178,7 +183,7 @@ function report_sale_analytic(reporting){
                 self.PosOrderLine = DataSQL.order_lines;
                 return self.BuildTable();
             });
-       },
+        },
 
         fetchIntialSQL: function() {
             var self = this;
@@ -779,7 +784,7 @@ function report_sale_analytic(reporting){
                 ============================================================
                 */
                 var filter = self.getFilter();
-                var pdf = new reporting.ReportPdfWidget(self);
+                var pdf = new reporting.ReportSalePdfWidget(self);
                 pdf.drawPDF(
                     _.flatten(getColumns),
                     row,

+ 941 - 0
static/src/js/reports/report_sale_ranking_product.js

@@ -0,0 +1,941 @@
+function report_sale_ranking_product(reporting) {
+    "use strict";
+
+    var model = openerp;
+
+    reporting.ReportSaleRankingProductWidget = reporting.Base.extend({
+        template: 'ReportSaleRankingProduct',
+        rowsData: [],
+        content: [],
+        modules: ['product_brand', 'point_of_sale'],
+
+        events: {
+            'click #generate': 'fetchGenerate',
+            'change #current-company': 'updateSelections',
+            'change #current-attribute': 'updateAttributeSelections',
+            'change #current-store': 'updateJournalSelections',
+            'change #current-date': 'ShowDateRange',
+            'click .build-chart':'CallChart',
+            '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 reporting.ReportDatePickerWidget(self);
+            date.fecthFecha();
+            this.fetchInitial();
+        },
+
+        valorNull: function(dato) {
+            var valor = "";
+            if (dato) {
+                valor = dato;
+            }
+            return valor;
+        },
+
+        checkModule: function(module) {
+            var self = this;
+            return _.filter(self.session.module_list, function(item) {
+                return item == module;
+            });
+        },
+
+        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.fetchIntialSQL().then(function (IntialSQL) {
+                return IntialSQL;
+            }).then(function(IntialSQL) {
+                /*
+                =================================
+                    RES COMPANY
+                =================================
+                */
+                self.ResCompany = IntialSQL.companies;
+                self.CompanyLogo = IntialSQL.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 = IntialSQL.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');
+                }
+                /*
+                =================================
+                    ACCOUNT JOURNAL
+                =================================
+                */
+                self.AccountJournal = IntialSQL.journals;
+                var journal = _.flatten(_.filter(self.AccountJournal,function (item) {
+                    return item.type == 'sale';
+                }));
+                if(journal.length > 1){
+                    self.$el.find('#current-journal').append('<option value="9999999">Todas las facturas</option>');
+                    _.each(journal,function(item){
+                        if(item.type == 'sale'){
+                            self.$el.find('#current-journal').append('<option value="' + item.id + '">' + item.name + '</option>');
+                        }
+                    });
+                }else{
+                    self.$el.find('.journal').css('display','none');
+                }
+                /*
+                =================================
+                    PRODUCT CATEGORY
+                =================================
+                */
+                self.ProductCategory = IntialSQL.categories;
+                if(self.ProductCategory.length > 1){
+                    self.$el.find('#current-category').append('<option value="9999999">Todas las Categorias</option>');
+                    _.each(self.ProductCategory,function(item){
+                        self.$el.find('#current-category').append('<option value="' + item.id + '">' + item.name + '</option>');
+                    });
+                }
+                self.ProductBrand = IntialSQL.brands;
+                if(self.ProductBrand.length > 1){
+                    self.$el.find('#current-brand').append('<option value="9999999">Todas las Marcas</option>');
+                    _.each(self.ProductBrand,function(item){
+                        self.$el.find('#current-brand').append('<option value="' + item.id + '">' + item.name + '</option>');
+                    });
+                }else{
+                    self.$el.find('.brand').css('display','none');
+                }
+                self.ProductAttribute = IntialSQL.attributes;
+                if(self.ProductAttribute.length > 1){
+                    self.$el.find('#current-attribute').append('<option value="9999999">Todas los atributos</option>');
+                    _.each(self.ProductAttribute,function(item){
+                        self.$el.find('#current-attribute').append('<option value="' + item.id + '">' + item.name + '</option>');
+                    });
+                }else{
+                    self.$el.find('.attribute').css('display','none');
+                }
+                self.ProductAttributeValue = IntialSQL.attribute_values;
+                if(self.ProductAttributeValue.length > 1){
+                    self.$el.find('#current-attribute-value').append('<option value="9999999">Todas los valores de atributos</option>');
+                    _.each(self.ProductAttributeValue,function(item){
+                        self.$el.find('#current-attribute-value').append('<option value="' + item.id + '">' + item.name + '</option>');
+                    });
+                }else{
+                    self.$el.find('.attribute-value').css('display','none');
+                }
+            }).then(function(IrModuleModule) {
+                self.IrModuleModule = IrModuleModule;
+                return self.fetchCheckType();
+            });
+            self.$el.find('#generate').css('display','inline');
+            return;
+        },
+
+
+        fetchGenerate: function () {
+            var self = this;
+            self.$el.find('.chart-container').css('display', 'none');
+            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.AccountInvoiceLine = DataSQL.invoice_lines;
+                self.PosOrderLine = DataSQL.order_lines;
+                self.ProductProduct = DataSQL.products;
+                return self.BuildTable();
+            });
+        },
+
+        fetchIntialSQL: function() {
+            var self = this;
+            var data = $.get('/report-filter-data');
+            return data;
+        },
+
+        fetchDataSQL: function() {
+            var self = this;
+            var data = $.get('/report-sale-product-ranking');
+            return data;
+        },
+
+        fetchCheckType: function() {
+            var self = this;
+            var modules = self.checkModule('point_of_sale');
+            if (modules.length == 0) {
+                self.$el.find('.type').css('display', 'none');
+            }
+        },
+
+        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){
+                        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>');
+                });
+            }
+        },
+
+        updateAttributeSelections: function () {
+            var self = this;
+            var attribute_value;
+            var attribute = self.$el.find('#current-attribute').val();
+            if(attribute != 9999999){
+                attribute_value = self.$el.find('#current-attribute-value').empty();
+                self.$el.find('#current-attribute-value').append('<option value="9999999">Todos los valores de atributos</option>');
+                _.each(self.ProductAttributeValue,function(item){
+                    if(parseFloat(attribute) == item.attribute_id){
+                        self.$el.find('#current-attribute-value').append('<option value="' + item.id + '">' + item.name + '</option>');
+                    }
+                });
+            }else{
+                attribute_value = self.$el.find('#current-attribute-value').empty();
+                self.$el.find('#current-attribute-value').append('<option value="9999999">Todos los valores de atributos</option>');
+                _.each(self.ProductAttributeValue,function(item){
+                    self.$el.find('#current-attribute-value').append('<option value="' + item.id + '">' + item.name + '</option>');
+                });
+            }
+        },
+
+        updateJournalSelections: function () {
+            var self = this;
+            var journal;
+            var store = self.$el.find('#current-store').val();
+            if(store != 9999999){
+                journal = self.$el.find('#current-journal').empty();
+                self.$el.find('#current-journal').append('<option value="9999999">Todas las facturas</option>');
+                _.each(self.AccountJournal,function(item){
+                    if(parseFloat(store) == item.store_id){
+                        self.$el.find('#current-journal').append('<option value="' + item.id + '">' + item.name + '</option>');
+                    }
+                });
+            }else{
+                journal = self.$el.find('#current-journal').empty();
+                self.$el.find('#current-journal').append('<option value="9999999">Todas las facturas</option>');
+                _.each(self.AccountJournal,function(item){
+                    self.$el.find('#current-journal').append('<option value="' + item.id + '">' + item.name + '</option>');
+                });
+            }
+        },
+
+        getPosOrderLine:function() {
+            var self = this;
+            var content = self.PosOrderLine;
+            var company = self.$el.find('#current-company').val();
+            var store = self.$el.find('#current-store').val();
+            var type = self.$el.find('#current-type').val();
+            var journal = self.$el.find('#current-journal').val();
+            var category = self.$el.find('#current-category').val();
+            var brand = self.$el.find('#current-brand').val();
+            var attribute = self.$el.find('#current-attribute').val();
+            var attribute_value = self.$el.find('#current-attribute-value').val();
+            var date = self.$el.find('#current-date').val();
+            var desde = self.$el.find('#from').val();
+            var hasta = self.$el.find('#to').val();
+            var store_ids = _.flatten(_.map(self.ResStore, function (item) {
+                return item.id;
+            }));
+            var company_ids = _.flatten(_.map(self.ResCompany, function (item) {
+                return item.id;
+            }));
+            content = _.flatten(_.filter(content,function (item) {
+                return _.contains(store_ids, item.store_id) && _.contains(company_ids, item.company_id);
+            }));
+            if(company && company != 9999999){
+                content = _.flatten(_.filter(content,function (item) {
+                    return item.company_id == company;
+                }));
+            }
+            if(store && store != 9999999){
+                content = _.flatten(_.filter(content,function (item) {
+                    return item.store_id == store;
+                }));
+            }
+            if(type && type != 9999999){
+                if(type == 'sale'){
+                    content = [];
+                }
+            }
+            if(journal && journal != 9999999){
+                content = _.flatten(_.filter(content,function (item) {
+                    return item.journal_id == journal;
+                }));
+            }
+            if(date && date != 9999999){
+                if(date == 'range'){
+                    if(desde){
+                        date = desde.split('/');
+                        date = (date[2]+"-"+date[1]+"-"+date[0]);
+                        content = _.flatten(_.filter(content,function (inv) {
+                            var utc = moment.utc(inv.date,'YYYY-MM-DD h:mm:ss A');
+                            utc = moment(utc._d).format('YYYY-MM-DD');
+                            return moment(utc).format('YYYY-MM-DD') >= date;
+                        }));
+                    }
+                    if(hasta){
+                        date = hasta.split('/');
+                        date = (date[2]+"-"+date[1]+"-"+date[0]);
+                        content = _.flatten(_.filter(content,function (inv) {
+                            var utc = moment.utc(inv.date,'YYYY-MM-DD h:mm:ss A');
+                            utc = moment(utc._d).format('YYYY-MM-DD');
+                            return moment(utc).format('YYYY-MM-DD') <= date;
+                        }));
+                    }
+                }
+                if(date == 'today'){
+                    var today = moment().format('YYYY-MM-DD');
+                    content = _.flatten(_.filter(content,function (inv) {
+                        var utc = moment.utc(inv.date,'YYYY-MM-DD h:mm:ss A');
+                        utc = moment(utc._d).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');
+                    content = _.flatten(_.filter(content,function (inv) {
+                        var utc = moment.utc(inv.date,'YYYY-MM-DD h:mm:ss A');
+                        utc = moment(utc._d).format('YYYY-MM-DD');
+                        return moment(utc).format('YYYY-MM-DD') === yesterday;
+                    }));
+                }
+                if(date == 'currentMonth'){
+                    var currentMonth = moment().format('YYYY-MM');
+                    content = _.flatten(_.filter(content,function (inv) {
+                        var utc = moment.utc(inv.date,'YYYY-MM-DD h:mm:ss A');
+                        utc = moment(utc._d).format('YYYY-MM-DD');
+                        return moment(utc).format('YYYY-MM') === currentMonth;
+                    }));
+                }
+                if(date == 'lastMonth'){
+                    var lastMonth = moment().add(-1,'months').format('YYYY-MM');
+                    content = _.flatten(_.filter(content,function (inv) {
+                        var utc = moment.utc(inv.date,'YYYY-MM-DD h:mm:ss A');
+                        utc = moment(utc._d).format('YYYY-MM-DD');
+                        return moment(utc).format('YYYY-MM') === lastMonth;
+                    }));
+                }
+            }
+            if(category && category != 9999999){
+                var category_ids = _.map(_.filter(self.ProductCategory,function (item) {
+                    return item.id == category || item.parent_id == category;
+                }), function(map){
+                    return map.id;
+                });
+                var category_children_ids = _.map(_.filter(self.ProductCategory,function (item) {
+                    return _.contains(category_ids, item.parent_id) || item.id == category;
+                }), function(map){
+                    return map.id;
+                });
+                var category_grandchildren_ids = _.map(_.filter(self.ProductCategory,function (item) {
+                    return _.contains(category_children_ids, item.parent_id) || item.id == category;
+                }), function(map){
+                    return map.id;
+                });
+                var categ_ids =  _.map(_.filter(self.ProductCategory,function (item) {
+                    return _.contains(category_grandchildren_ids, item.parent_id) || item.id == category;
+                }), function(map){
+                    return map.id;
+                });
+                content = _.flatten(_.filter(content,function (inv) {
+                    return _.contains(categ_ids, inv.categ_id);
+                }));
+            }
+            if(brand && brand != 9999999){
+                content = _.filter(content,function (item) {
+                    return item.product_brand_id == parseInt(brand);
+                });
+            }
+            if(attribute && attribute != 9999999){
+                content = _.filter(content,function (item) {
+                    return _.contains(item.attribute_ids, parseInt(attribute));
+                });
+            }
+            if(attribute_value && attribute_value != 9999999){
+                content = _.filter(content,function (item) {
+                    return _.contains(item.attribute_value_ids, parseInt(attribute_value));
+                });
+            }
+            return content;
+        },
+
+        getAccountInvoiceLine:function() {
+            var self = this;
+            var content = self.AccountInvoiceLine;
+            var company = self.$el.find('#current-company').val();
+            var store = self.$el.find('#current-store').val();
+            var type = self.$el.find('#current-type').val();
+            var journal = self.$el.find('#current-journal').val();
+            var category = self.$el.find('#current-category').val();
+            var brand = self.$el.find('#current-brand').val();
+            var attribute = self.$el.find('#current-attribute').val();
+            var attribute_value = self.$el.find('#current-attribute-value').val();
+            var date = self.$el.find('#current-date').val();
+            var desde = self.$el.find('#from').val();
+            var hasta = self.$el.find('#to').val();
+            var store_ids = _.flatten(_.map(self.ResStore, function (item) {
+                return item.id;
+            }));
+            var company_ids = _.flatten(_.map(self.ResCompany, function (item) {
+                return item.id;
+            }));
+            content = _.flatten(_.filter(content,function (item) {
+                return _.contains(store_ids, item.store_id) && _.contains(company_ids, item.company_id);
+            }));
+            if(company && company != 9999999){
+                content = _.flatten(_.filter(content,function (item) {
+                    return item.company_id == company;
+                }));
+            }
+            if(store && store != 9999999){
+                content = _.flatten(_.filter(content,function (item) {
+                    return item.store_id == store;
+                }));
+            }
+            if(type && type != 9999999){
+                if(type == 'tpv'){
+                    content = [];
+                }
+            }
+            if(journal && journal != 9999999){
+                content = _.flatten(_.filter(content,function (item) {
+                    return item.journal_id == journal;
+                }));
+            }
+            if(date && date != 9999999){
+                if(date == 'range'){
+                    if(desde){
+                        date = desde.split('/');
+                        date = (date[2]+"-"+date[1]+"-"+date[0]);
+                        content = _.flatten(_.filter(content,function (inv) {
+                            return moment(inv.date).format('YYYY-MM-DD') >= date;
+                        }));
+                    }
+                    if(hasta){
+                        date = hasta.split('/');
+                        date = (date[2]+"-"+date[1]+"-"+date[0]);
+                        content = _.flatten(_.filter(content,function (inv) {
+                            return moment(inv.date).format('YYYY-MM-DD') <= date;
+                        }));
+                    }
+                }
+                if(date == 'today'){
+                    var today = moment().format('YYYY-MM-DD');
+                    content = _.flatten(_.filter(content,function (inv) {
+                        return moment(inv.date).format('YYYY-MM-DD') === today;
+                    }));
+                }
+                if(date == 'yesterday'){
+                    var yesterday = moment().add(-1,'days').format('YYYY-MM-DD');
+                    content = _.flatten(_.filter(content,function (inv) {
+                        return moment(inv.date).format('YYYY-MM-DD') === yesterday;
+                    }));
+                }
+                if(date == 'currentMonth'){
+                    var currentMonth = moment().format('YYYY-MM');
+                    content = _.flatten(_.filter(content,function (inv) {
+                        return moment(inv.date).format('YYYY-MM') === currentMonth;
+                    }));
+                }
+                if(date == 'lastMonth'){
+                    var lastMonth = moment().add(-1,'months').format('YYYY-MM');
+                    content = _.flatten(_.filter(content,function (inv) {
+                        return moment(inv.date).format('YYYY-MM') === lastMonth;
+                    }));
+                }
+            }
+            if(category && category != 9999999){
+                var category_ids = _.map(_.filter(self.ProductCategory,function (item) {
+                    return item.id == category || item.parent_id == category;
+                }), function(map){
+                    return map.id;
+                });
+                var category_children_ids = _.map(_.filter(self.ProductCategory,function (item) {
+                    return _.contains(category_ids, item.parent_id) || item.id == category;
+                }), function(map){
+                    return map.id;
+                });
+                var category_grandchildren_ids = _.map(_.filter(self.ProductCategory,function (item) {
+                    return _.contains(category_children_ids, item.parent_id) || item.id == category;
+                }), function(map){
+                    return map.id;
+                });
+                var categ_ids =  _.map(_.filter(self.ProductCategory,function (item) {
+                    return _.contains(category_grandchildren_ids, item.parent_id) || item.id == category;
+                }), function(map){
+                    return map.id;
+                });
+                content = _.flatten(_.filter(content,function (inv) {
+                    return _.contains(categ_ids, inv.categ_id);
+                }));
+            }
+            if(brand && brand != 9999999){
+                content = _.filter(content,function (item) {
+                    return item.product_brand_id == parseInt(brand);
+                });
+            }
+            if(attribute && attribute != 9999999){
+                content = _.filter(content,function (item) {
+                    return _.contains(item.attribute_ids, parseInt(attribute));
+                });
+            }
+            if(attribute_value && attribute_value != 9999999){
+                content = _.filter(content,function (item) {
+                    return _.contains(item.attribute_value_ids, parseInt(attribute_value));
+                });
+            }
+            return content;
+        },
+
+        getAccountInvoiceLineByProduct:function(product_id,type) {
+            var self = this;
+            return  _.filter(self.AccountInvoiceLine,function (item) {
+                return item.product_id == product_id && item.type == type;
+            });
+        },
+
+        getPosOrderLineByProduct:function(product_id) {
+            var self = this;
+            return  _.filter(self.PosOrderLine,function (item) {
+                return item.product_id == product_id;
+            });
+        },
+
+        BuildTable: function() {
+            var self = this;
+            var data = [];
+            var display_name;
+            var modules = self.checkModule('product_brand');
+            var CurrencyBase = self.ResCompany[0].currency_id;
+            self.AccountInvoiceLine = self.getAccountInvoiceLine();
+            self.PosOrderLine = self.getPosOrderLine();
+            var ProductProduct = self.ProductProduct;
+            _.each(ProductProduct, function(item) {
+                if(item.attribute_values[0] == null){
+                    display_name = item.product_name;
+                }else{
+                    display_name = item.product_name + ' (' + _.uniq(item.attribute_values) + ')';
+                }
+                if(modules.length > 0){
+                    if(item.product_brand_id != null){
+                        display_name = display_name + ' ( ' + item.brand_name + ')';
+                    }
+                }
+                /*
+                    INVOICE
+                */
+                var AccountInvoiceLine = self.getAccountInvoiceLineByProduct(item.product_id,'out_invoice');
+                var InvoiceLineQuantity = _.reduce(_.map(AccountInvoiceLine, function(map) {
+                    return map.quantity;
+                }), function(meno, num) {
+                    return meno + num;
+                }, 0);
+                var InvoiceLineAmount = _.reduce(_.map(AccountInvoiceLine, function(map) {
+                    return map.subtotal + map.tax;
+                }), function(meno, num) {
+                    return meno + num;
+                }, 0);
+                /*
+                    INVOICE REFUND
+                */
+                var AccountInvoiceLineRefund = self.getAccountInvoiceLineByProduct(item.product_id,'out_refund');
+                var InvoiceLineRefundQuantity = _.reduce(_.map(AccountInvoiceLineRefund, function(map) {
+                    return map.quantity;
+                }), function(meno, num) {
+                    return meno + num;
+                }, 0);
+                var InvoiceLineRefundAmount = _.reduce(_.map(AccountInvoiceLineRefund, function(map) {
+                    return map.subtotal + map.tax;
+                }), function(meno, num) {
+                    return meno + num;
+                }, 0);
+                /*
+                    POSORDER
+                */
+                var PosOrderLine = self.getPosOrderLineByProduct(item.product_id);
+                var PosOrderQuantity = _.reduce(_.map(PosOrderLine, function(map) {
+                    return map.quantity;
+                }), function(meno, num) {
+                    return meno + num;
+                }, 0);
+                var PosOrderAmount = _.reduce(_.map(PosOrderLine, function(map) {
+                    return map.subtotal + map.tax;
+                }), function(meno, num) {
+                    return meno + num;
+                }, 0);
+
+                var quantity = PosOrderQuantity + InvoiceLineQuantity - InvoiceLineRefundQuantity;
+                var amount = PosOrderAmount + InvoiceLineAmount - InvoiceLineRefundAmount;
+
+                if(quantity != 0 || amount != 0){
+                    if(amount < 0 && quantity > 0){
+                        quantity = quantity * -1;
+                    }
+                    data.push({
+                        id:item.product_id,
+                        name:display_name,
+                        attribute_value_ids:item.attribute_value_ids,
+                        quantity:accounting.formatNumber(quantity,2,'.',','),
+                        amount:accounting.formatMoney(amount,'',CurrencyBase.decimal_places,CurrencyBase.thousands_separator,CurrencyBase.decimal_separator),
+                        /*
+                            NO FORMAT
+                        */
+                        quantity_no_format:quantity,
+                        amount_no_format:amount,
+                        /*
+                            FOOTER
+                        */
+                        decimal_places: CurrencyBase.decimal_places,
+                        thousands_separator: CurrencyBase.thousands_separator,
+                        decimal_separator: CurrencyBase.decimal_separator,
+                    });
+                }
+            });
+            // console.log(InvoiceLineAmount + PosOrderAmount);
+            data.sort(function(a, b) {
+                return b.amount_no_format - a.amount_no_format;
+            });
+            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();
+        },
+        /*
+        ======================================================================
+            LLAMAR LOS GRAFICOS
+        ======================================================================
+        */
+        CallChart: function() {
+            var self = this;
+            var data = self.content;
+            var i,item,num,amount_total;
+            var rank = 10;
+            var label = [];
+            var body = [];
+            var CurrencyBase = self.ResCompany[0].currency_id;
+            /*
+            ================================================
+                BAR CHART
+            ================================================
+            */
+            var BarChart = new reporting.ReportSaleChartWidget(self);
+            for (i = 0; i < rank; i++) {
+                if (data[i]) {
+                    item = data[i];
+                }else {
+                    item = {};
+                    item.name = "N/A";
+                    item.amount_no_format = 0;
+                }
+                label.push(item.name.trim());
+                body.push(item.amount_no_format);
+            }
+            BarChart.BuildBarChart(data, CurrencyBase, label, body);
+            /*
+            ================================================
+                PIE CHART
+            ================================================
+            */
+            var PieChart = new reporting.ReportSaleChartWidget(self);
+            label = [];
+            body = [];
+            amount_total = _.reduce(_.map(data, function(map) {
+                return map.amount_no_format;
+            }), function(meno, num) {
+                return meno + num;
+            }, 0);
+            for (i = 0; i < rank; i++) {
+                if (data[i]) {
+                    item = data[i];
+                } else {
+                    item = {};
+                    item.name = "N/A";
+                    item.amount_no_format = 0;
+                }
+                label.push(item.name.trim());
+                body.push((item.amount_no_format / amount_total) * 100);
+            }
+            num = 0;
+            for (i = 9; i < data.length; i++) {
+                num += data[i].amount_no_format;
+            }
+            if (num > 0) {
+                label.push('Otros Productos');
+                body.push((num / amount_total) * 100);
+            }
+            PieChart.BuildPieChart(data, CurrencyBase, label, body);
+            /*
+            ================================================
+                DOUGHNUT CHART
+            ================================================
+            */
+            var DoughnutChart = new reporting.ReportSaleChartWidget(self);
+            var info = [];
+            var content = [];
+            var ProductAttributeValue = self.ProductAttributeValue;
+            if (ProductAttributeValue.length > 0) {
+                _.each(ProductAttributeValue, function(item) {
+                    content = _.filter(data, function(index) {
+                        return _.contains(index.attribute_value_ids, item.id);
+                    });
+
+                    var amount = _.reduce(_.map(content, function(map) {
+                        return map.amount_no_format;
+                    }), function(meno, num) {
+                        return meno + num;
+                    }, 0);
+                    if (amount > 0) {
+                        info.push({
+                            name: item.attribute_name + ' - ' + item.name + ' - ' + accounting.formatMoney(amount, CurrencyBase.symbol, CurrencyBase.decimal_places, CurrencyBase.thousands_separator, CurrencyBase.decimal_separator),
+                            amount_no_format: amount
+                        });
+                    }
+                });
+                info.sort(function(a, b) {
+                    return b.amount_no_format - a.amount_no_format;
+                });
+
+                rank = 9;
+                label = [];
+                body = [];
+
+                amount_total = _.reduce(_.map(data, function(map) {
+                    return map.amount_no_format;
+                }), function(meno, num) {
+                  return meno + num;
+                }, 0);
+
+                for (i = 0; i < rank; i++) {
+                    if (info[i]) {
+                        item = info[i];
+                    } else {
+                        item = {};
+                        item.name = "N/A";
+                        item.amount_no_format = 0;
+                    }
+                    label.push(item.name.trim());
+                    body.push((item.amount_no_format / amount_total) * 100);
+                }
+                num = 0;
+                for (i = 9; i < info.length; i++) {
+                    num += info[i].amount_no_format;
+                }
+                if (num > 0) {
+                    label.push('Otros Atributos');
+                    body.push((num / amount_total) * 100);
+                }
+                DoughnutChart.BuildDoughnutChart(data, CurrencyBase, label, body);
+                self.$el.find('.doughnut-chart').css('display', 'block');
+            }
+            self.$el.find('.chart-container').css('display', 'block');
+        },
+        /*====================================================================
+            LOAD BOOTSTRAP TABLE
+        ====================================================================*/
+        loadTable: function(rowsTable) {
+            var self = this;
+            self.rowsData = rowsTable;
+            var table = this.$el.find('#table');
+            table.bootstrapTable('load', rowsTable);
+        },
+
+        /*====================================================================
+            PRINT PDF
+        ====================================================================*/
+        clickOnAction: function(e) {
+            var self = this;
+            var ResCompany;
+            var 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 = ResCompany[0];
+                CurrencyBase = ResCompany[0].currency_id;
+            }else{
+                ResCompany = self.ResCompany[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 quantity = QuantityFooter(row);
+            var amount = TotalFooter(row);
+            row.push({
+                name:'Totales',
+                quantity:quantity,
+                amount:amount,
+            });
+
+            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 = 'Ranking de productos (+Vendidos).';
+                var pdf_type = '';
+                var pdf_name = 'ranking_productos_';
+                var pdf_columnStyles = {
+                    name: {halign: 'left'},
+                    quantity: {columnWidth: 30, halign: 'right'},
+                    amount: {columnWidth: 30, halign: 'right'},
+                };
+                /*
+                ============================================================
+                    LLAMAR FUNCION DE IMPRESION
+                ============================================================
+                */
+                var filter = self.getFilter();
+                var pdf = new reporting.ReportSalePdfWidget(self);
+                pdf.drawPDF(
+                    _.flatten(getColumns),
+                    row,
+                    ResCompany,
+                    pdf_title,
+                    pdf_type,
+                    pdf_name,
+                    pdf_columnStyles,
+                    filter
+                );
+            }
+        },
+        getFilter: function() {
+            var self = this;
+            var company = self.$el.find('#current-company').val();
+            var store = self.$el.find('#current-store').val();
+            var type = self.$el.find('#current-type').val();
+            var category = self.$el.find('#current-category').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 (type && type != 9999999) {
+                filter.push({
+                    title: 'Tipo de Venta',
+                    value: $("#current-type option:selected").text(),
+                });
+            }
+            if (category && category != 9999999) {
+                var categ = _.filter(self.ProductCategory, function(item) {
+                    return item.id == category;
+                });
+                filter.push({
+                    title: 'Categoría',
+                    value: categ[0].name,
+                });
+            }
+            if (date && date != 9999999) {
+                moment.locale('es', {
+                    months: 'Enero_Febrero_Marzo_Abril_Mayo_Junio_Julio_Agosto_Septiembre_Octubre_Noviembre_Diciembre'.split('_'),
+                });
+                if (date == 'range') {
+                    filter.push({
+                        title: 'Fecha',
+                        value: desde + ' al ' + hasta,
+                    });
+                } else {
+                    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;
+        },
+    });
+}

+ 0 - 91
static/src/reports/report_customer.xml

@@ -1,91 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<template xml:space="preserve">
-    <t t-name="ReportCustomer">
-        <div class="report_view">
-            <div class="container search-form">
-                <div class="page-header">
-                    <h1><small>Clientes</small></h1>
-                </div>
-                <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>Tipo</label>
-                        <select id="current-type" class="form-control form-control-sm">
-                            <option value="9999999">Todos los tipos</option>
-                            <option value="company">Empresa</option>
-                            <option value="people">Persona</option>
-                        </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="oe_button myButton" value="pdf">Imprimir Informe</button>
-                </div>
-                <div class="container" style="width:95%;">
-                    <table id="table"
-                        data-pagination="true"
-                        data-toggle="table"
-                        data-toolbar="#toolbar"
-                        data-classes="table table-condensed"
-                        data-search="true"
-                        data-show-export="true"
-                        data-show-toggle="true"
-                        data-show-columns="true"
-                        data-show-pagination-switch="true"
-                        data-pagination-v-align="top"
-                        data-buttons-class="oe_button myButton"
-                        data-search-on-enter-key="true"
-                        data-undefined-text=" "
-                        >
-                        <thead style="background:none;">
-                            <tr>
-                                <th data-field="ruc"
-                                    data-align="left"
-                                    >RUC</th>
-                                <th data-field="name"
-                                    data-align="left"
-                                    >Nombre y Apellido</th>
-                                <th data-field="street"
-                                    data-align="left"
-                                    >Dirección</th>
-                                <th data-field="state"
-                                    data-align="left"
-                                    >Depart./Ciudad</th>
-                                <th data-field="country"
-                                    data-align="left"
-                                    >Pais</th>
-                                <th data-field="phone"
-                                    data-align="left"
-                                    >Teléfono</th>
-                                <th data-field="mobile"
-                                    data-align="left"
-                                    >Celular</th>
-                                <th data-field="email"
-                                    data-align="left"
-                                    >Email</th>
-                            </tr>
-                        </thead>
-                    </table>
-                </div>
-            </div>
-            <br/>
-        </div>
-    </t>
-</template>

+ 14 - 14
static/src/reports/report_customer_ranking.xml

@@ -7,16 +7,16 @@
                     <h1><small>Ranking de Clientes</small></h1>
                 </div>
                 <div class="row">
-                    <div class="col-lg-3 company filter-style">
+                    <div class="col-lg-3 col-md-3 col-sm-6 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">
+                    <div class="col-lg-3 col-md-3 col-sm-6 store filter-style">
                         <label>Sucursal</label>
                         <select id="current-store" class="form-control form-control-sm">
                         </select>
                     </div>
-                    <div class="col-lg-3 type filter-style">
+                    <div class="col-lg-3 col-md-3 col-sm-6 type filter-style">
                         <label>Tipo de Venta</label>
                         <select id="current-type" class="form-control form-control-sm">
                             <option value="9999999">Todos los tipos</option>
@@ -24,27 +24,27 @@
                             <option value="sale">Normal</option>
                         </select>
                     </div>
-                    <div class="col-lg-3 category filter-style">
+                    <div class="col-lg-3 col-md-3 col-sm-6 category filter-style">
                         <label>Categoría</label>
                         <select id="current-category" class="form-control form-control-sm">
                         </select>
                     </div>
-                    <div class="col-lg-3 brand filter-style">
+                    <div class="col-lg-3 col-md-3 col-sm-6 brand filter-style">
                         <label>Marca</label>
                         <select id="current-brand" class="form-control form-control-sm">
                         </select>
                     </div>
-                    <div class="col-lg-3 attribute filter-style">
+                    <div class="col-lg-3 col-md-3 col-sm-6 attribute filter-style">
                         <label>Atributo</label>
                         <select id="current-attribute" class="form-control form-control-sm">
                         </select>
                     </div>
-                    <div class="col-lg-3 attribute-value filter-style">
+                    <div class="col-lg-3 col-md-3 col-sm-6 attribute-value filter-style">
                         <label>Valor del Atributo</label>
                         <select id="current-attribute-value" class="form-control form-control-sm">
                         </select>
                     </div>
-                    <div class="col-lg-3 filter-style">
+                    <div class="col-lg-3 col-md-3 col-sm-6 filter-style">
                         <label>Fechas</label>
                         <select id="current-date" class="form-control form-control-sm">
                             <option value="9999999">Sin fechas</option>
@@ -58,13 +58,13 @@
                 </div>
                 <div class="row" >
                     <div class="datepicker" style="display:none;">
-                        <div class="col-lg-3 filter-style col-md-offset-3">
+                        <div class="col-lg-3 col-md-3 col-sm-6 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="col-lg-3 col-md-3 col-sm-6 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"/>
@@ -73,10 +73,10 @@
                     </div>
                 </div>
                 <div class="row">
-                  <div class="text-center" style="padding-top:20px;">
-                      <button id="generate" class="oe_button oe_form_button myButton">Generar</button>
-                  </div>
-                  <br/>
+                    <div class="text-center" style="padding-top:20px;">
+                        <button id="generate" class="myButton">Generar</button>
+                    </div>
+                    <br/>
                 </div>
             </div>
 

+ 40 - 116
static/src/reports/report_product_list.xml

@@ -1,33 +1,25 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <template xml:space="preserve">
     <t t-name="ReportProductList">
-      <head>
+      <!-- <head>
         <script src="//cdnjs.cloudflare.com/ajax/libs/holder/2.6.0/holder.js"></script>
-      </head>
+      </head> -->
         <div class="report_view">
-            <div class="reporting_page_header">
-                <h1 class="report_title">Lista de Productos</h1>
-            </div>
-            <div class="container search-form" style="border-bottom:1px solid #eee; width:95%;">
+            <div class="container search-form">
+                <div class="page-header">
+                    <h1><small>Catálogo de productos</small></h1>
+                </div>
                 <div class="row">
-                    <div class="col-lg-3 company filter-style">
+                    <div class="col-lg-3 col-md-3 col-sm-6 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">
+                    <div class="col-lg-3 col-md-3 col-sm-6 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="available">Disponible</option>
-                            <option value="unavailable">No Disponible</option>
-                        </select>
-                    </div>
-                    <div class="col-lg-3 filter-style">
+                    <div class="col-lg-3 col-md-3 col-sm-6 filter-style">
                         <label>Tipo</label>
                         <select id="current-type" class="form-control form-control-sm">
                             <option value="9999999">Todos los tipos</option>
@@ -35,32 +27,27 @@
                             <option value="service">Servicio</option>
                         </select>
                     </div>
-                    <div class="col-lg-3 salePrice filter-style">
+                    <div class="col-lg-3 col-md-3 col-sm-6 salePrice filter-style">
                         <label>Precio de Venta</label>
                         <select id="current-sale-price" class="form-control form-control-sm">
                         </select>
                     </div>
-                    <div class="col-lg-3 purchasePrice filter-style">
-                        <label>Precio de Costo </label>
-                        <select id="current-purchase-price" class="form-control form-control-sm">
-                        </select>
-                    </div>
-                    <div class="col-lg-3 filter-style">
+                    <div class="col-lg-3 col-md-3 col-sm-6 filter-style">
                         <label>Categoria</label>
                         <select id="current-category" class="form-control form-control-sm">
                         </select>
                     </div>
-                    <div class="col-lg-3 brand filter-style">
+                    <div class="col-lg-3 col-md-3 col-sm-6 brand filter-style">
                         <label>Marca</label>
                         <select id="current-brand" class="form-control form-control-sm">
                         </select>
                     </div>
-                    <div class="col-lg-3 attribute filter-style">
+                    <div class="col-lg-3 col-md-3 col-sm-6 attribute filter-style">
                         <label>Atributo</label>
                         <select id="current-attribute" class="form-control form-control-sm">
                         </select>
                     </div>
-                    <div class="col-lg-3 attribute-value filter-style">
+                    <div class="col-lg-3 col-md-3 col-sm-6 attribute-value filter-style">
                         <label>Valor del Atributo</label>
                         <select id="current-attribute-value" class="form-control form-control-sm">
                         </select>
@@ -68,7 +55,7 @@
                 </div>
                 <div class="row">
                     <div class="text-center" style="padding-top:20px;">
-                        <button id="generate" class="oe_button oe_form_button myButton">Generar</button>
+                        <button id="generate" class="myButton">Generar</button>
                     </div>
                     <br/>
                 </div>
@@ -76,7 +63,7 @@
 
             <div class="report-form" style="display:none;">
                 <div id="toolbar">
-                    <button class="oe_button oe_form_button myButton" value="pdf">Imprimir Informe</button>
+                    <button class="myButton" value="pdf">Imprimir Informe</button>
                 </div>
                 <div class="container" style="width:95%;">
                     <table id="table"
@@ -84,107 +71,44 @@
                         data-toggle="table"
                         data-toolbar="#toolbar"
                         data-show-columns="true"
-                        data-height="auto"
-                        data-classes="table table-hover table-condensed  table-no-bordered"
-                        data-row-style="rowStyle"
+                        data-classes="table table-condensed"
                         data-search="true"
                         data-show-export="true"
                         data-show-toggle="true"
-                        data-pagination-detail-h-align="left"
-                        data-show-footer="true"
-                        data-footer-style="footerStyle"
-                        data-buttons-class="oe_button oe_form_button myButton"
+                        data-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="image_medium" data-formatter="imageFormatter" data-footer-formatter="Totales">Imagen</th>
-                                <th data-field="default_code" data-align="left" >Referencia Interna</th>
-                                <th data-field="name" data-align="left">Producto</th>
-                                <th data-field="brand" data-align="left">Marca</th>
-                                <th data-field="categ_id" data-align="left">Categoría</th>
-                                <th data-field="standard_price" data-align="right" data-footer-formatter="purchaseTotalFormatter">Precio Costo</th>
-                                <th data-field="lst_price" data-align="right" data-footer-formatter="saleTotalFormatter">Precio Venta </th>
-                                <th data-field="qty_available" data-align="center" data-footer-formatter="qtyTotalFormatter">Cantidad Disponible</th>
+                                <th data-field="default_code"
+                                    data-align="left"
+                                    >Referencia Interna</th>
+                                <th data-field="name"
+                                    data-align="left"
+                                    >Producto</th>
+                                <th data-field="ean13"
+                                    data-align="left"
+                                    data-visible="false"
+                                    >Ean13</th>
+                                <th data-field="brand_name"
+                                    data-align="left"
+                                    >Marca</th>
+                                <th data-field="category_name"
+                                    data-align="left"
+                                    >Categoría</th>
+                                <th data-field="lst_price"
+                                    data-align="right"
+                                    data-footer-formatter="saleTotalFormatter"
+                                    >Precio Venta </th>
                             </tr>
                         </thead>
                     </table>
                 </div>
             </div>
-            <script>
-
-              function imageFormatter(value) {
-              return '<img style="width:60px; height:60px" src="'+ value +'"></img>';
-
-              }
-                <!--
-                    TOTAL
-                -->
-                function purchaseTotalFormatter(rowsTable) {
-                    var decimal_places = 0;
-                    var thousands_separator = '.';
-                    var decimal_separator = ',';
-                    var symbol;
-                    if(rowsTable.length > 0){
-                        decimal_places = rowsTable[0].decimal_places_purchase;
-                        thousands_separator = rowsTable[0].thousands_separator_purchase;
-                        decimal_separator = rowsTable[0].decimal_separator_purchase;
-                        symbol=rowsTable[0].symbol_purchase;
-                    }
-                    var amount =  _.reduce(_.map(rowsTable,function(item){
-                        return (item.standard_price_no_format);
-                    }), function(memo, num){
-                    return memo + num; },0)
-                    return accounting.formatMoney(amount,symbol,decimal_places,thousands_separator,decimal_separator,'%s %v');
-                }
-
-                function saleTotalFormatter(rowsTable) {
-                    var decimal_places = 0;
-                    var thousands_separator = '.';
-                    var decimal_separator = ',';
-                    var symbol;
-                    if(rowsTable.length > 0){
-                        decimal_places = rowsTable[0].decimal_places_sale;
-                        thousands_separator = rowsTable[0].thousands_separator_sale;
-                        decimal_separator = rowsTable[0].decimal_separator_sale;
-                        symbol = rowsTable[0].symbol_sale;
-                    }
-                    var amount =  _.reduce(_.map(rowsTable,function(item){
-                        return (item.lst_price_no_formart);
-                    }), function(memo, num){
-                    return memo + num; },0)
-                    return accounting.formatMoney(amount,symbol,decimal_places,thousands_separator,decimal_separator,'%s %v');
-                }
-
-                function qtyTotalFormatter(rowsTable) {
-                    var decimal_places = 0;
-                    var thousands_separator = '.';
-                    var decimal_separator = ',';
-                    if(rowsTable.length > 0){
-                        decimal_places = rowsTable[0].decimal_places;
-                        thousands_separator = rowsTable[0].thousands_separator;
-                        decimal_separator = rowsTable[0].decimal_separator;
-                    }
-                    var amount =  _.reduce(_.map(rowsTable,function(item){
-                        return (item.qty_no_formart);
-                    }), function(memo, num){
-                    return memo + num; },0)
-                    return accounting.formatNumber(amount,'',thousands_separator,decimal_separator);
-                }
-                <!--
-                    FOOTER STYLE
-                -->
-                function footerStyle(row, index) {
-                    return {
-                        css: {
-                          "font-weight": "bold"
-                        }
-                    };
-                };
-            </script>
+            <br/>
         </div>
     </t>
 </template>

+ 10 - 12
static/src/reports/report_sale.xml

@@ -7,16 +7,16 @@
                     <h1><small>Historico de Ventas</small></h1>
                 </div>
                 <div class="row">
-                    <div class="col-lg-3 company filter-style">
+                    <div class="col-lg-3 col-md-3 col-sm-6 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">
+                    <div class="col-lg-3 col-md-3 col-sm-6 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">
+                    <div class="col-lg-3 col-md-3 col-sm-6 filter-style">
                         <label>Estado</label>
                         <select id="current-state" class="form-control form-control-sm">
                             <option value="9999999">Todos los estados</option>
@@ -24,17 +24,17 @@
                             <option value="paid">Pagado</option>
                         </select>
                     </div>
-                    <div class="col-lg-3 journal filter-style">
+                    <div class="col-lg-3 col-md-3 col-sm-6 journal filter-style">
                         <label>Factura</label>
                         <select id="current-journal" class="form-control form-control-sm">
                         </select>
                     </div>
-                    <div class="col-lg-3 users filter-style">
+                    <div class="col-lg-3 col-md-3 col-sm-6 users filter-style">
                         <label>Vendedor</label>
                         <select id="current-user" class="form-control form-control-sm">
                         </select>
                     </div>
-                    <div class="col-lg-3 type filter-style">
+                    <div class="col-lg-3 col-md-3 col-sm-6 type filter-style">
                         <label>Tipo de Venta</label>
                         <select id="current-type" class="form-control form-control-sm">
                             <option value="9999999">Todos los Tipos</option>
@@ -42,7 +42,7 @@
                             <option value="sale">Normal</option>
                         </select>
                     </div>
-                    <div class="col-lg-3 filter-style">
+                    <div class="col-lg-3 col-md-3 col-sm-6 filter-style">
                        <label>Fechas</label>
                        <select id="current-date" class="form-control form-control-sm">
                            <option value="9999999">Sin fechas</option>
@@ -56,13 +56,13 @@
                 </div>
                 <div class="row" >
                     <div class="datepicker" style="display:none;">
-                        <div class="col-lg-3 filter-style col-md-offset-3">
+                        <div class="col-lg-3 col-md-3 col-sm-6 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="col-lg-3 col-md-3 col-sm-6 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"/>
@@ -73,9 +73,7 @@
 
                 <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>
+                        <button id="generate" class="myButton">Generar</button>
                     </div>
                     <br/>
                 </div>

+ 12 - 14
static/src/reports/report_sale_analytic.xml

@@ -7,21 +7,21 @@
                     <h1><small>Análisis de Ventas</small></h1>
                 </div>
                 <div class="row">
-                    <div class="col-lg-3 company filter-style">
+                    <div class="col-lg-3 col-md-3 col-sm-6 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">
+                    <div class="col-lg-3 col-md-3 col-sm-6 store filter-style">
                         <label>Sucursal</label>
                         <select id="current-store" class="form-control form-control-sm">
                         </select>
                     </div>
-                    <div class="col-lg-3 journal filter-style">
+                    <div class="col-lg-3 col-md-3 col-sm-6 journal filter-style">
                         <label>Factura</label>
                         <select id="current-journal" class="form-control form-control-sm">
                         </select>
                     </div>
-                    <div class="col-lg-3 type filter-style">
+                    <div class="col-lg-3 col-md-3 col-sm-6 type filter-style">
                         <label>Tipo de Venta</label>
                         <select id="current-type" class="form-control form-control-sm">
                             <option value="9999999">Todos los Tipos</option>
@@ -29,27 +29,27 @@
                             <option value="sale">Normal</option>
                         </select>
                     </div>
-                    <div class="col-lg-3 filter-style">
+                    <div class="col-lg-3 col-md-3 col-sm-6 filter-style">
                         <label>Categoria</label>
                         <select id="current-category" class="form-control form-control-sm">
                         </select>
                     </div>
-                    <div class="col-lg-3 brand filter-style">
+                    <div class="col-lg-3 col-md-3 col-sm-6 brand filter-style">
                         <label>Marca</label>
                         <select id="current-brand" class="form-control form-control-sm">
                         </select>
                     </div>
-                    <div class="col-lg-3 attribute filter-style">
+                    <div class="col-lg-3 col-md-3 col-sm-6 attribute filter-style">
                         <label>Atributo</label>
                         <select id="current-attribute" class="form-control form-control-sm">
                         </select>
                     </div>
-                    <div class="col-lg-3 attribute-value filter-style">
+                    <div class="col-lg-3 col-md-3 col-sm-6 attribute-value filter-style">
                         <label>Valor del Atributo</label>
                         <select id="current-attribute-value" class="form-control form-control-sm">
                         </select>
                     </div>
-                    <div class="col-lg-3 filter-style">
+                    <div class="col-lg-3 col-md-3 col-sm-6 filter-style">
                         <label>Fechas</label>
                         <select id="current-date" class="form-control form-control-sm">
                             <option value="9999999">Sin fechas</option>
@@ -63,13 +63,13 @@
                 </div>
                 <div class="row" >
                     <div class="datepicker" style="display:none;">
-                        <div class="col-lg-3 filter-style col-md-offset-3">
+                        <div class="col-lg-3 col-md-3 col-sm-6 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="col-lg-3 col-md-3 col-sm-6 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"/>
@@ -79,9 +79,7 @@
                 </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>
+                        <button id="generate" class="myButton">Generar</button>
                     </div>
                     <br/>
                 </div>

+ 18 - 18
static/src/reports/report_sale_ranking_product.xml

@@ -2,26 +2,26 @@
 <template xml:space="preserve">
     <t t-name="ReportSaleRankingProduct">
         <div class="report_view">
-            <div class="reporting_page_header">
-                <h1 class="report_title">Ranking de productos (+ Vendidos)</h1>
-            </div>
-            <div class="container search-form" style="border-bottom:1px solid #eee; width:95%;">
+            <div class="container search-form">
+                <div class="page-header">
+                    <h1><small>Ranking de productos (+ Vendidos)</small></h1>
+                </div>
                 <div class="row">
-                    <div class="col-lg-3 company filter-style">
+                    <div class="col-lg-3 col-md-3 col-sm-6 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">
+                    <div class="col-lg-3 col-md-3 col-sm-6 store filter-style">
                         <label>Sucursal</label>
                         <select id="current-store" class="form-control form-control-sm">
                         </select>
                     </div>
-                    <div class="col-lg-3 journal filter-style">
+                    <div class="col-lg-3 col-md-3 col-sm-6 journal filter-style">
                         <label>Factura</label>
                         <select id="current-journal" class="form-control form-control-sm">
                         </select>
                     </div>
-                    <div class="col-lg-3 type filter-style">
+                    <div class="col-lg-3 col-md-3 col-sm-6 type filter-style">
                         <label>Tipo de Venta</label>
                         <select id="current-type" class="form-control form-control-sm">
                             <option value="9999999">Todos los Tipos</option>
@@ -29,27 +29,27 @@
                             <option value="sale">Normal</option>
                         </select>
                     </div>
-                    <div class="col-lg-3 filter-style">
+                    <div class="col-lg-3 col-md-3 col-sm-6 filter-style">
                         <label>Categoria</label>
                         <select id="current-category" class="form-control form-control-sm">
                         </select>
                     </div>
-                    <div class="col-lg-3 brand filter-style">
+                    <div class="col-lg-3 col-md-3 col-sm-6 brand filter-style">
                         <label>Marca</label>
                         <select id="current-brand" class="form-control form-control-sm">
                         </select>
                     </div>
-                    <div class="col-lg-3 attribute filter-style">
+                    <div class="col-lg-3 col-md-3 col-sm-6 attribute filter-style">
                         <label>Atributo</label>
                         <select id="current-attribute" class="form-control form-control-sm">
                         </select>
                     </div>
-                    <div class="col-lg-3 attribute-value filter-style">
+                    <div class="col-lg-3 col-md-3 col-sm-6 attribute-value filter-style">
                         <label>Valor del Atributo</label>
                         <select id="current-attribute-value" class="form-control form-control-sm">
                         </select>
                     </div>
-                    <div class="col-lg-3 filter-style">
+                    <div class="col-lg-3 col-md-3 col-sm-6 filter-style">
                         <label>Fechas</label>
                         <select id="current-date" class="form-control form-control-sm">
                             <option value="9999999">Sin fechas</option>
@@ -63,13 +63,13 @@
                 </div>
                 <div class="row" >
                     <div class="datepicker" style="display:none;">
-                        <div class="col-lg-3 filter-style col-md-offset-3">
+                        <div class="col-lg-3 col-md-3 col-sm-6 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="col-lg-3 col-md-3 col-sm-6 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"/>
@@ -79,9 +79,7 @@
                 </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>
+                        <button id="generate" class="myButton">Generar</button>
                     </div>
                     <br/>
                 </div>
@@ -134,12 +132,14 @@
                                 <th data-field="amount"
                                     data-align="right"
                                     data-footer-formatter="TotalFooter"
+                                    data-width="200"
                                     >Monto</th>
                             </tr>
                         </thead>
                     </table>
                 </div>
             </div>
+            <br/>
             <script>
                 <!--
                     CANTIDAD

+ 2 - 7
templates.xml

@@ -30,20 +30,15 @@
                     ==============================-->
                     <script type="text/javascript" src="/eiru_reports_sales/static/src/js/reports/report_sale_analytic.js"/>
 
-                    <!--=============================
-                        Clientes
-                    ==============================-->
-                    <script type="text/javascript" src="/eiru_reports_sales/static/src/js/reports/report_customer.js"/>
-
                     <!--=============================
                         Ranking de Clientes
                     ==============================-->
                     <script type="text/javascript" src="/eiru_reports_sales/static/src/js/reports/report_customer_ranking.js"/>
 
                     <!--=============================
-                        Ranking de productos mas vendidos
+                        Ranking de productos
                     ==============================-->
-                    <!-- <script type="text/javascript" src="/eiru_reports_sales/static/src/js/reports/report_sale_ranking_product.js"/> -->
+                    <script type="text/javascript" src="/eiru_reports_sales/static/src/js/reports/report_sale_ranking_product.js"/>
 
                     <!--=============================
                         Lista de productos

+ 4 - 13
views/actions.xml

@@ -18,15 +18,6 @@
         <record id="sale_analytic_action" model="ir.actions.client">
             <field name="name">Análisis de Ventas</field>
             <field name="tag">eiru_reports_sales.sale_analytic_action</field>
-        </record>
-        <!--
-		==========================
-            CLIENTES
-        ==========================
-		-->
-        <record id="customer_action" model="ir.actions.client">
-            <field name="name">Clientes</field>
-            <field name="tag">eiru_reports_sales.customer_action</field>
         </record>
 		<!--
 		==========================
@@ -34,8 +25,8 @@
 		==========================
 		-->
 		<record id="customer_ranking_action" model="ir.actions.client">
-				<field name="name">Ranking de Clientes</field>
-				<field name="tag">eiru_reports_sales.customer_ranking_action</field>
+			<field name="name">Ranking de Clientes</field>
+			<field name="tag">eiru_reports_sales.customer_ranking_action</field>
 		</record>
 		<!--
 		==========================
@@ -52,8 +43,8 @@
 		==========================
 		-->
 		<record id="product_list_action" model="ir.actions.client">
-				<field name="name">Lista de Productos</field>
-				<field name="tag">eiru_reports_sales.product_list_action</field>
+			<field name="name">Catálogo de productos</field>
+			<field name="tag">eiru_reports_sales.product_list_action</field>
 		</record>
     </data>
 </openerp>

+ 1 - 15
views/menus.xml

@@ -10,7 +10,6 @@
             name="Informes"
             id="eiru_reports_main_menu"
             sequence="175"/>
-
         <!--
         ===========================
             VENTAS
@@ -45,19 +44,6 @@
                 parent="sale_parent_menu"
                 action="sale_analytic_action"
                 sequence="2"/>
-
-            <!--
-            ===========================
-               CLIENTES
-            ===========================
-            -->
-            <menuitem
-                name="Clientes"
-                id="customer_menu"
-                parent="sale_parent_menu"
-                action="customer_action"
-                sequence="3"/>
-
             <!--
             ===========================
                 RANKING DE CLIENTES
@@ -87,7 +73,7 @@
             ===========================
             -->
             <menuitem
-                name="Lista de Productos"
+                name="Catálogo de productos"
                 id="product_list_menu"
                 parent="sale_parent_menu"
                 action="product_list_action"

Niektoré súbory nie sú zobrazené, pretože je v týchto rozdielových dátach zmenené mnoho súborov