소스 검색

[ADD] Nuevos Campos

Rodney Enciso Arias 7 년 전
부모
커밋
54296af577
5개의 변경된 파일81개의 추가작업 그리고 30개의 파일을 삭제
  1. 1 1
      __openerp__.py
  2. 18 11
      static/src/js/reports/report_purchases.js
  3. 47 16
      static/src/js/reports/report_sales.js
  4. 6 0
      static/src/reports/report_purchases.xml
  5. 9 2
      static/src/reports/report_sales.xml

+ 1 - 1
__openerp__.py

@@ -4,7 +4,7 @@
     'author': "Eiru Software",
     'category': 'Reporte',
     'version': '0.1',
-    'depends': ['base','eiru_assets','company_set_information','invoice_credit','attachments_views'],
+    'depends': ['base','eiru_assets','company_set_information','invoice_credit','attachments_views','account_timbrado'],
     'data': [
     'templates.xml',
     ],

+ 18 - 11
static/src/js/reports/report_purchases.js

@@ -96,7 +96,7 @@ function report_purchases (reporting){
                 return item.id;
             }));
             var filter =[['state', 'in',['open','paid']],['type', '=', ['in_invoice','in_refund']],['journal_id', 'in',journal_ids]];
-            var field =['id', 'type', 'number', 'origin', 'state', 'journal_id', 'currency_id', 'supplier_invoice_number','date_invoice','partner_id','amount_total','user_id','contado','credito','payment_term','period_id','amount_untaxed','amount_tax','attachment_ids'];
+            var field =['id', 'type', 'number', 'origin', 'state', 'journal_id', 'currency_id', 'supplier_invoice_number','date_invoice','partner_id','amount_total','user_id','contado','credito','payment_term','period_id','amount_untaxed','amount_tax','attachment_ids','timbrado'];
             var defer = $.Deferred();
             var Invoice = new instance.web.Model('account.invoice');
             Invoice.query(field).filter(filter).all().then(function (results) {
@@ -109,7 +109,7 @@ function report_purchases (reporting){
             var self = this;
             var defer = $.Deferred();
             var currency = new instance.web.Model('res.company');
-            var field=['id', 'currency_id','exportador','agent_ruc','legal_agent','company_ruc','name'];
+            var field=['id', 'currency_id','exportador','agent_ruc','legal_agent','company_ruc','name','juridico'];
             var domain=[['id','=',1]];
             currency.query(field).filter(domain).all().then(function(results){
                 defer.resolve(results);
@@ -204,7 +204,6 @@ function report_purchases (reporting){
                 return item.id === attachment_ids;
             }).shift();
         },
-        
         // Detalle del registro
         fect_generar: function(invoices){
             var self = this;
@@ -290,9 +289,9 @@ function report_purchases (reporting){
                     ruc_proveedor: ruc[0], 
                     dv: ruc[1],
                     partner : invoice.partner_id[1],
-                    supplier_invoice_number: self.valorNull(invoice.supplier_invoice_number), 
+                    supplier_invoice_number: self.valorNull(invoice.timbrado), 
                     tipo_documento : tipo,
-                    number: invoice.number,
+                    number: self.valorNull(invoice.supplier_invoice_number),
                     date: moment(invoice.date_invoice).format("DD/MM/YYYY"),
                     tasa_10 : tasa_10,
                     iva_10 : iva_10,
@@ -315,7 +314,6 @@ function report_purchases (reporting){
         // Informacion para el txt.
         fect_cabecera: function(resCompanys, invoices){
             var self = this;
-            
             // Cabecera
             var datos = [];
             var company_ruc;
@@ -325,11 +323,20 @@ function report_purchases (reporting){
             var cantidad = 0;
             var valor = 0;
             var periodo;
+            var ruc_agente = 0;
+            var dv_agente = 0;
+            var nombre_agente = 0;
             var period =this.$el.find('#current-period').val();
-
             _.each(resCompanys, function(resCompany){
+                // Obtener el RUC y el DV de la compania
                 company_ruc = resCompany.company_ruc.split("-");
-                agent_ruc = resCompany.agent_ruc.split("-");
+                // Determinar si la persona es fisica o juridica
+                if(resCompany.juridico == true){
+                    agent = resCompany.agent_ruc.split("-");
+                    ruc_agente = agent[0];
+                    dv_agente = agent[1];
+                    nombre_agente = resCompany.legal_agent;
+                }
                 // Tipo de registro
                 datos.push(1);
                 datos.push('\t');
@@ -356,13 +363,13 @@ function report_purchases (reporting){
                 datos.push(resCompany.name);
                 datos.push('\t');
                 // Ruc representante legal
-                datos.push(agent_ruc[0]);
+                datos.push(ruc_agente);
                 datos.push('\t');
                 // DV representante legal
-                datos.push(agent_ruc[1]);
+                datos.push(dv_agente);
                 datos.push('\t');
                 // Nombre y apellido de representante legal
-                datos.push(resCompany.legal_agent);
+                datos.push(nombre_agente);
                 datos.push('\t');
                 // Cantidad de registros
                 datos.push(50);

+ 47 - 16
static/src/js/reports/report_sales.js

@@ -72,7 +72,7 @@ function report_sales (reporting){
             var self = this;
             var defer = $.Deferred();
             var Journal = new instance.web.Model('account.journal');
-            Journal.query(['id', 'name']).filter([['type', '=', 'sale']]).all().then(function(results){
+            Journal.query(['id', 'name','timbrado']).filter([['type', '=', ['sale','sale_refund']]]).all().then(function(results){
                 defer.resolve(results);
             });
             return defer;
@@ -93,7 +93,7 @@ function report_sales (reporting){
             var journal_ids = _.flatten(_.map(this.accountJournal, function (item) {
                 return item.id;
             }));
-            var filter =[['state', 'in',['open','paid']],['type', '=', 'out_invoice'],['journal_id', 'in',journal_ids]];
+            var filter =[['state', 'in',['open','paid']],['type', '=', ['out_invoice','out_refund']],['journal_id', 'in',journal_ids]];
             var field =['id', 'type', 'number', 'origin', 'state', 'journal_id', 'currency_id', 'supplier_invoice_number','date_invoice','partner_id','amount_total','user_id','contado','credito','payment_term','period_id','amount_untaxed','amount_tax','attachment_ids'];
             var defer = $.Deferred();
             var Invoice = new instance.web.Model('account.invoice');
@@ -107,7 +107,7 @@ function report_sales (reporting){
             var self = this;
             var defer = $.Deferred();
             var currency = new instance.web.Model('res.company');
-            var field=['id', 'currency_id','exportador','agent_ruc','legal_agent','company_ruc','name'];
+            var field=['id', 'currency_id','exportador','agent_ruc','legal_agent','company_ruc','name','juridico'];
             var domain=[['id','=',1]];
             currency.query(field).filter(domain).all().then(function(results){
                 defer.resolve(results);
@@ -205,6 +205,14 @@ function report_sales (reporting){
                 return item.id === attachment_ids;
             }).shift();
         },
+
+        // Obtener el timbrado del diario
+        getJournal : function(journal_id){
+            var self = this;
+            return _.filter(self.accountJournal,function(item){
+                return item.id === journal_id;
+            }).shift();
+        },
         // unir los objetos
         fect_generar: function(invoices){
             var self = this;
@@ -213,7 +221,7 @@ function report_sales (reporting){
             var customer_ruc;
             var ruc;
             var cuota;
-            var cuotaII;
+            var tipo;
             var total;
             var tasa_10;
             var tasa_5;
@@ -227,7 +235,11 @@ function report_sales (reporting){
             var contador = 0;
             var icons = 0;
             var imagen;
+            var valor_timbrado;
             _.each(invoices, function(invoice){
+                // Obtener el timbrado desde el journal
+                valor_timbrado = self.getJournal(invoice.journal_id[0]);
+
                 // obtener el ruc y el DV del cliente
                 customer_ruc = self.getCustomer(invoice.partner_id[0]);
                 ruc = customer_ruc.ruc.split("-");
@@ -236,9 +248,14 @@ function report_sales (reporting){
                 if (invoice.credito == true){
                     condicion = 2;
                 }
+                // Determinar el tipo de factura.
+                if(invoice.type == 'out_invoice'){
+                    tipo = 1;
+                }else{
+                    tipo = 3;
+                }
                 // Determinar la cantidad de cuotas
                 cuota = _.flatten(self.getPaymentTerm(invoice.payment_term[0])).length - 2;
-                // cuotaII = (cuota.length - 2);
                 if (condicion == 1 || cuota < 1){
                     cuota = 0;
                 }
@@ -289,7 +306,7 @@ function report_sales (reporting){
                     ruc_cliente: ruc[0],
                     dv: ruc[1],
                     partner: invoice.partner_id[1],
-                    tipo_documento : 1,
+                    tipo_documento : tipo,
                     numero_documento : invoice.number,
                     date: moment(invoice.date_invoice).format("DD/MM/YYYY"),
                     tasa_10 : tasa_10,
@@ -300,14 +317,13 @@ function report_sales (reporting){
                     total : total,
                     condicion_venta : condicion,
                     cantidad_cuotas : cuota,
-                    number: invoice.number,
+                    number: self.valorNull(valor_timbrado.timbrado),
                     // informacion del periodo
                     period_id : invoice.period_id[0],
                     period_name : invoice.period_id[1],
                     attachment_ids : adjunto,
                     download_icon : icons,
-                });
-                
+                });      
             });
             self.newInvoice = data;
             this.loadTable(data);
@@ -319,16 +335,31 @@ function report_sales (reporting){
             var datos = [];
             var periodo;
             var company_ruc;
-            var agent_ruc;
+            var agent;
             var version = 2;
             var total = 0;
             var cantidad = 0;
             var valor = 0;
             var periodo;
-            var period =this.$el.find('#current-period').val();
+            var tipo = 1;
+            var ruc_agente = 0;
+            var dv_agente = 0;
+            var nombre_agente = 0;
+            var period = this.$el.find('#current-period').val();
+            var rectificativa = $('#rectificativa').is(":checked");
+            if(rectificativa){
+                tipo = 2;
+            }
             _.each(resCompanys, function(resCompany){
+                // Obtener el RUC y el DV de la compania
                 company_ruc = resCompany.company_ruc.split("-");
-                agent_ruc = resCompany.agent_ruc.split("-");
+                // Verificar si es una persona fisica o juridica
+                if(resCompany.juridico == true){
+                    agent = resCompany.agent_ruc.split("-");
+                    ruc_agente = agent[0];
+                    dv_agente = agent[1];
+                    nombre_agente = resCompany.legal_agent;
+                }
                 // Tipo de registro
                 datos.push(1);
                 datos.push('\t');
@@ -336,7 +367,7 @@ function report_sales (reporting){
                 datos.push(201708);
                 datos.push('\t');
                 // Tipo de reporte
-                datos.push(1);
+                datos.push(tipo);
                 datos.push('\t');
                 // Codigo Obligacion
                 datos.push(911);
@@ -354,13 +385,13 @@ function report_sales (reporting){
                 datos.push(resCompany.name);
                 datos.push('\t');
                 // Ruc representante legal
-                datos.push(agent_ruc[0]);
+                datos.push(ruc_agente);
                 datos.push('\t');
                 // DV representante legal
-                datos.push(agent_ruc[1]);
+                datos.push(dv_agente);
                 datos.push('\t');
                 // Nombre y apellido de representante legal
-                datos.push(resCompany.legal_agent);
+                datos.push(nombre_agente);
                 datos.push('\t');
                 // Cantidad de registros
                 datos.push(50);

+ 6 - 0
static/src/reports/report_purchases.xml

@@ -14,6 +14,12 @@
                                 <select id="current-period" class="ui-autocomplete-input form-control"  name="period"></select>
                             </th>
                         </tr>
+                        <tr>
+                            <th>
+                                <label for="rectificativa"> Rectificativa</label>
+                                <input type="checkbox" name="Rectificativa" id="rectificativa"/>     
+                            </th> 
+                        </tr>
                         <tr>
                             <th>
                                 <button class="oe_button oe_form_button oe_highlight btn btn-block btn-lg" value="txt" id="txt">Exportar <i class="fa fa-file-text fa-lg"></i></button>   

+ 9 - 2
static/src/reports/report_sales.xml

@@ -16,12 +16,19 @@
                                     <select id="current-period" class="ui-autocomplete-input form-control"  name="period"></select>
                                 </th>
                             </tr>
+                            <tr>
+                                <th>
+                                    <label for="rectificativa"> Rectificativa</label>
+                                    <input type="checkbox" name="Rectificativa" id="rectificativa"/>     
+                                </th> 
+                            </tr>
                             <tr>
                                 <th>
                                     <button class="oe_button oe_form_button oe_highlight btn btn-block btn-lg" value="txt" id="txt">Exportar <i class="fa fa-file-text fa-lg"></i></button> 
                                 </th>
                             </tr>
-                        </table> 
+                        </table>
+
                     </div>   
                 </div>
             <!-- </div> -->
@@ -32,7 +39,7 @@
                 data-toolbar="#toolbar"                
                 data-buttons-class="oe_button oe_form_button oe_highlight"
                 data-height="auto"
-                data-classes="table table-hover table-condensed"
+                data-classes="table table-hover table-condensed table-bordered"
                 data-row-style="rowStyle"
                 data-search="true"
                 value="bottom">