PageSourceSearch

https://www.coar.es/coar/wp-content/plugins/visado/public/js/oficina-comercial/shared-facturas.js?ver=1.0.0

js coar.es collected 2026-10-05 03:43:03 UTC 21,619 bytes, 349 lines download raw bytes

1(function( $ ) {
2	'use strict';
3
4	/**
5	 * All of the code for your public-facing JavaScript source
6	 * should reside in this file.
7	 *
8	 * Note: It has been assumed you will write jQuery code here, so the
9	 * $ function reference has been prepared for usage within the scope
10	 * of this function.
11	 *
12	 * This enables you to define handlers, for when the DOM is ready:
13	 *
14	 * $(function() {
15	 *
16	 * });
17	 *
18	 * When the window is loaded:
19	 *
20	 * $( window ).load(function() {
21	 *
22	 * });
23	 *
24	 * ...and/or other possibilities.
25	 *
26	 * Ideally, it is not considered best practise to attach more than a
27	 * single DOM-ready or window-load handler for a particular page.
28	 * Although scripts in the WordPress core, Plugins and Themes may be
29	 * practising this, we should strive to set a better example in our own work.
30	 */
31$.extend( {
32
33		shared_facturas_api: {
34                       get_rest_api: function(){
35                           return OficinaComercialRESTAPI;
36                       },
37                       
38                       get_html_select_anyos_facturas: function(anyos){
39                            var select_anyos_facturas_html = "";
40        
41                            if(anyos !== null && anyos.length > 0){
42                                var list_html = '';
43                                $.each(anyos.reverse(), function(key, val) {
44                                    list_html +=""
45                                       + "<option data-anyo=\"" + val + "\">" + val + "</option>";         
46                                });
47
48                                list_html += "<option value=\"-1\">- Mostrar todos -</option>"; 
49
50                                select_anyos_facturas_html =""
51                                        + "<form>"
52                                            + "<fieldset>"                      
53                                              + "<div class=\"form-group\">"
54                                                + "<label for=\"select-anyos-facturas\">Año</label>"
55                                                + "<select id=\"select-anyos-facturas\" class=\"form-control\">"
56                                                    + "" 
57                                                    + list_html +
58                                                    + ""
59                                                + "</select>"
60                                              + "</div>"                
61                                            + "</fieldset>"
62                                          + "</form>" 
63                                        + "<br/>";
64                            }
65                            else{
66                                select_anyos_facturas_html += "<h4><small>No existen datos de facturación</small></h4>"; 
67                            }
68                            
69                            return select_anyos_facturas_html;
70                       },
71                       
72                       get_html_tabla_facturas: function(){
73                            var tabla_facturas_html = "";
74                            
75                            if(($('#facturas').length) === 0) {
76                                    var tabla_facturas_html =""        
77                                        + "<table id=\"facturas\" class=\"display\" style=\"width:100%\">"
78                                            + "<thead>"
79                                                + "<tr>"
80                                                    + "<th>Número</th>"
81                                                    + "<th>Fecha</th>"
82                                                    + "<th>Cliente</th>"
83                                                    + "<th>Base imponible</th>"
84                                                    + "<th>Iva</th>"
85                                                    + "<th>Importe</th>"
86                                                    + "<th>Total</th>"
87                                                + "</tr>"
88                                            + "</thead>"
89                                            + "<tfoot>"
90                                                + "<tr>"
91                                                    + "<th>Número</th>"
92                                                    + "<th>Fecha</th>"
93                                                    + "<th>Cliente</th>"
94                                                    + "<th>Base imponible</th>"
95                                                    + "<th>Iva</th>"
96                                                    + "<th>Importe</th>"
97                                                    + "<th>Total</th>"
98                                                + "</tr>"
99                                            + "</tfoot>"
100                                        + "</table>";                                    
101                            }
102                            
103                            return tabla_facturas_html;
104                       },
105                       
106                       create_tabla_facturas: function(facturas, callback){
107                            // Crear tabla
108                            var table = $('#facturas').DataTable( {
109                                destroy: true,
110                                responsive: true,
111                                data: (facturas !== null && facturas.length && facturas.length > 0 ? facturas : []),
112                                "order": [[ 1, "desc" ]],
113                                "pagingType": "full_numbers",
114                                "decimal": ",",
115                                "thousands": ".",
116                                "lengthMenu": [[10, 25, 50, 100, -1], [10, 25, 50, 100, "Todos"]],
117                                "language": {
118                                    "lengthMenu": "Mostrar _MENU_ registros por página",
119                                    "decimal": ",",
120                                    "thousands": ".",
121                                    "zeroRecords": "No hay registros",
122                                    "info": "Mostrando _START_ a _END_ de _TOTAL_ registros",
123                                    "infoEmpty": "No hay registros disponibles",
124                                    "infoFiltered": "(filtrados de _MAX_ registros totales)",
125                                    "loadingRecords": "Espere por favor - cargando...",
126                                    "search": "Filtrar registros:",
127                                    "paginate": {
128                                        "first": "Primera",
129                                        "last": "Última",
130                                        "previous": "Anterior", 
131                                        "next": "Siguiente"                                                                         
132                                    }
133                                },
134                                "fnDrawCallback": function( oSettings ) {
135                                         eval(callback);
136                                },
137                                "columns": [
138                                       { "data": null, 
139                                           render: function (data, type, row) {
140                                                   return row.NumFactura !== null ? row.NumFactura : "";
141                                               }
142                                       },
143                                       { "data": null, 
144                                           render: function (data, type, row) {
145                                                   return moment(row.Fecha
145).format('L');
146                                               }
147                                       },
148                                       { "data": null, 
149                                           render: function (data, type, row) {
150                                                   return row.NombreCliente !== null ? row.NombreCliente : "";
151                                               }
152                                       },
153                                       { "data": null, 
154                                           render: function (data, type, row) {
155                                                   return (row.BaseImponible !== null ? numeral(row.BaseImponible).format('0,0.00 $') : "0");
156                                               }
157                                       },
158                                       { "data": null, 
159                                           render: function (data, type, row) {
160                                                   return (row.Iva !== null ? numeral(row.Iva).format('0,0.00 $') : "0");
161                                               }
162                                       },
163                                       { "data": null, 
164                                           render: function (data, type, row) {
165                                                   return (row.ImporteReten !== null ? numeral(row.ImporteReten).format('0,0.00 $') : "0");
166                                               }
167                                       },
168                                       { "data": null, 
169                                           render: function (data, type, row) {
170                                                   var base_imponible, iva, importe, total;
171                                                   base_imponible = row.BaseImponible !== null ? parseFloat(row.BaseImponible) : 0;
172                                                   iva = row.Iva !== null ? parseFloat(row.Iva) : 0;
173                                                   importe = row.ImporteReten !== null ? parseFloat(row.ImporteReten) : 0;
174                                                   total = base_imponible + iva - importe;
175
176                                                   return numeral(total).format('0,0.00 $');
177                                               }
178                                       }
179                                   ],
180                                   columnDefs: [
181                                        { type: 'de_date', targets: 1, orderData: [ 1 ]}        
182                                    ]
183                            } );  
184                            
185                            return table;
186                       },
187                       
188                       get_detalle_factura: function(factura){
189                            // Datos factura
190                            var base_imponible, iva, total, importe;
191                            base_imponible = factura.BaseImponible !== null ? parseFloat(factura.BaseImponible) : 0;
192                            iva = factura.Iva !== null ? parseFloat(factura.Iva) : 0;
193                            importe = factura.ImporteReten !== null ? parseFloat(factura.ImporteReten) : 0;
194                            total = base_imponible + iva - importe;
195
196                            var detalle_factura_html = "<div class=\"container-fluid\">"
197                                    + "<!-- Datos expediente -->"                                     
198                                    + "<div class=\"row\">"
199                                      + "<div class=\"col-md-6\"><h4>Fecha: <small>" +  moment(factura.Fecha).format('L')  + "</small></h4></div>"
200                                      + "<div class=\"col-md-6\"><h4>Número Factura: <small>" + factura.NumFactura + "</small></h4></div>"
201                                    + "</div>"
202                                    + "<div class=\"row\">"
203                                      + "<div class=\"col-md-12\"><h4>Cliente: <small>" + factura.NombreCliente + "</small></h4></div>"
204                                    + "</div>"
205                                    + "<div class=\"row\">"
206                                      + "<div class=\"col-md-12\"><h4>Asunto: <small>" + (factura.Asunto !== null ? factura.Asunto : '') + "</small></h4></div>"
207                                    + "</div>" 
208                                    + "<div class=\"row\">"
209                                      + "<div class=\"col-md-12\"><h4>Domicilio: <small>" + (factura.Domicilio !== null ? factura.Domicilio : '') + "</small></h4></div>"
210                                    + "</div>"
211                                    + "<div class=\"row\">"
212                                      + "<div class=\"col-md-12\"><h4>Población: <small>" + (factura.Poblacion !== null ? factura.Poblacion : '') + "</small></h4></div>"
213                                    + "</div>"
214                                    + "<div class=\"row\">"
215                                      + "<div class=\"col-md-12\"><h4>Nif: <small>" + (factura.Nif !== null ? factura.Nif : '') + "</small></h4></div>"
216                                    + "</div>"
217
218                                     + "<table id=\"lineas-factura\" class=\"table table-condensed\">"      
219                                        + "<tbody>"
220                                         + "<tr class=\"info\">"
221                                             + "<td>TOTAL</td>"
222                                             + "<td>Base Imponible</td>"
223                                             + "<td>Iva</td>"
224                                             + "<td>Retenciones</td>"
225                                             + "<td>Total</td>"
226                                         + "</tr>"
227                                         + "<tr>"
228                                             + "<td></td>"
229                                             + "<td>" + numeral(base_imponible).format('0,0.00 $') + "</td>"
230                                             + "<td>" + numeral(iva).format('0,0.00 $') + "</td>"
231                                             + "<td>" + numeral(importe).format('0,0.00 $') + "</td>"
232                                             + "<td>" + numeral(total).format('0,0.00 $') + "</td>"
233                                         + "</tr>"
234                                        + "</tbody>"
235                                      + "</table>";        
236
237                            // líneas
238                            var conceptos_factura_html = '';
239                            if(factura.Lineas.length > 0){  
240                                var lineas_factura_html = '';
241                                $.each(factura.Lineas, function(key, val) {
242                                    // creating new table row per record
243                                    lineas_factura_html+=""
244                                        + "<tr>"
245                                            + "<td>" + (val.DescripcionLarga !== null ? val.DescripcionLarga : '') + "</td>"
246                                            + "<td>" + numeral(val.Subtotal).format('0,0.00 $') + "</td>"
247                                            + "<td>" + numeral(val.SubtotalIva).format('0,0.00 $')+ "</td>"
248                                            + "<td>" + numeral(val.Total).format('0,0.00 $') + "</td>"
249                                        + "</tr>";
250                                });
251
252                                conceptos_factura_html += ""
253                                        + "<table id=\"lineas-factura\" class=\"table table-condensed\">"      
254                                             + "<tbody>"
255                                                 + "<tr class=\"warning\">"
256                                                     + "<td>Descripción</td>"
257                                                     + "<td>Importe</td>"
258                                                     + "<td>Iva</td>"
259                                                     + "<td>Total</td>"
260                                                 + "</tr>" 
261                                                  + lineas_factura_html +
262                                                "</tbody>"                        
263                                         + "</table>";
264                            }
265                            else{
266                                conceptos_factura_html += "<h4><small>No existen líneas asociadas a la factura</small></h4>"; 
267                            } 
268
269                            // Datos líneas factura
270                            detalle_factura_html += ""
271                                   + "<!-- Datos líneas factura -->"
272                                   + "<div class=\"panel panel-default\">"
273                                     + "<div class=\"panel-heading\">Conceptos</div>"
274                                     + "<div class=\"panel-body\">" 
275                                            + "" +
276                                            conceptos_factura_html
277                                            + ""                 
278                                       + "</div>"
279                                   + "</div>";  
280                           
281                            // Enlace descarga factura
282                            detalle_factura_html += "<h4>La factura está disponible en el siguiente enlace: <strong><a data-id-factura=\"" + factura.IdFactura + "\" href=\"javascript:void(0)\" class=\"link-descargar-factura\">Descargar factura</a></strong>." +
283                                    " También puede descargarla en formato electrónico: <strong><a data-id-factura=\"" + factura.IdFactura + "\" href=\"javascript:void(0)\" class=\"link-descargar-facturae\">Descargar facturae</a></strong></h4>"; 
284                               
285                            // Mensaje carga
286                            detalle_factura_html += "<div id=\"load-doc-factura\" style=\"display:none\" class=\"row\">"
287                                 + "<div class=\"col-md-4\"><h4><small>Obteniendo factura...</small></h4></div>"
288                                 + "</div>";   
289
290                            // Mensaje error o no disponibilidad de factura
291                            detalle_factura_html += "<div id=\"error-descargar-factura\" style=\"display:none\" class=\"alert alert-danger\" role=\"alert\">La factura no se encuentra disponible</div>"; 
292                                                      
293                            return detalle_factura_html;
294                       },
295                       
296                       get_html_modal_detalle_factura : function(){
297                            var modal_detalle_factura_html = '';
298         
299                            if(($('#modal-form-detalle-factura').length) === 0) {
300                                modal_detalle_factura_html = ""
301                                     + "<!-- Modal -->"
302                                     + "<div class=\"modal fade\" id=\"modal-form-detalle-factura\" role=\"dialog\">"
303                                         + "<div class=\"modal-dialog\">"
304                                             + "<div class=\"modal-content\">"
305                                                 + "<!-- Modal Header -->"
306                                                 + "<div class=\"modal-header\">"
307                                                     + "<button type=\"button\" class=\"close\" data-dismiss=\"modal\">"
308                                                         + "<span aria-hidden=\"true\">&times;</span>"
309                                                         + "<span class=\"sr-only\">Close</span>"
310                                                     + "</button>"
311                                                     + "<h3 id=\"modal-title\" class=\"modal-title text-primary-2\">Detalle factura</h3>"
312                                                 + "</div>"
313
314                                                 + "<!-- Modal Body -->"
315                                                 + "<div id=\"detalle-factura\" class=\"modal-body\">"
316                                                     + "<p>Espere por favor - cargando...</p>"
317                                                 + "</div>"
318
319                                                 + "<!-- Modal Footer -->"
320                                                 + "<div class=\"modal-footer\">"
321                                                     + "<button type=\"button\" class=\"btn btn-default\" data-dismiss=\"modal\">Cerrar</button>"
322                                                 + "</div>"
323                                             + "</div>"
324                                         + "</div>"
325                                     + "</div>";   
326                            }
327                           
328                           return modal_detalle_factura_html;
329                       },
330                       
331                       show_loading_message : function(){
332                            $("#load-doc-factura").css("display", "block");
333                       },
334
335                       hide_loading_message : function(){
336                            $("#load-doc-factura").css("display", "none");
337                       },
338                       
339                       show_error_descargar_factura : function(){
340                            $("#error-descargar-factura").css("display", "block");
341                       },
342                       
343                       hide_error_descargar_factura : function(){
344                            $("#error-descargar-factura").css("display", "none");
345                       }
346		}
347	} );
348               
349})( jQuery );

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.