|
@@ -1,397 +0,0 @@
|
|
|
-function pdf(reporting) {
|
|
|
- "use strict";
|
|
|
-
|
|
|
- var model = openerp;
|
|
|
-
|
|
|
- reporting.ReportPdfWidget = reporting.Base.extend({
|
|
|
- drawPDF: function (getColumns,row,ResCompany,pdf_title,pdf_type,pdf_name,pdf_columnStyles) {
|
|
|
- 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);
|
|
|
- console.log(getColumns);
|
|
|
- pdfDoc.autoTable(getColumns, row, {
|
|
|
- // showHeader: 'firstPage',
|
|
|
- theme: 'grid',
|
|
|
- styles: {
|
|
|
- overflow: 'linebreak',
|
|
|
- columnWidth: 'auto',
|
|
|
- fontSize: 7,
|
|
|
- },
|
|
|
- headerStyles: {
|
|
|
- fillColor: [76, 133, 248],
|
|
|
- fontSize: 9
|
|
|
- },
|
|
|
- columnStyles: pdf_columnStyles,
|
|
|
- margin: { top: 20, horizontal: 7},
|
|
|
- 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);
|
|
|
- }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);
|
|
|
- }
|
|
|
- });
|
|
|
- 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',
|
|
|
- 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',
|
|
|
- fontSize: 7,
|
|
|
- },
|
|
|
- headerStyles: {
|
|
|
- fillColor: [76, 133, 248],
|
|
|
- fontSize: 9
|
|
|
- },
|
|
|
-
|
|
|
- columnStyles: pdf_columnStyles,
|
|
|
- margin: { top: 28, horizontal: 7},
|
|
|
-
|
|
|
- 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);
|
|
|
- }
|
|
|
- });
|
|
|
-
|
|
|
- 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);
|
|
|
- }
|
|
|
- row.pop();
|
|
|
- if(model.printer_bridge){
|
|
|
- var data = pdfDoc.output('datauristring');
|
|
|
- model.printer_bridge.print(data);
|
|
|
- return;
|
|
|
- }
|
|
|
- pdfDoc.save(pdf_name + hoy + '.pdf');
|
|
|
- },
|
|
|
- });
|
|
|
-}
|