|
@@ -180,54 +180,121 @@ openerp.report_invoice_utility = function (instance, local) {
|
|
|
}
|
|
|
// console.log(producto);
|
|
|
// console.log(data);
|
|
|
- data.push([(invoice.number),
|
|
|
- (item.name),
|
|
|
- (item.quantity),
|
|
|
- (item.price_unit.toFixed(2) / invoice.rate.toFixed(2)),
|
|
|
- (producto.standard_price.toFixed(2)),
|
|
|
- (item.quantity * (item.price_unit.toFixed(2) / invoice.rate.toFixed(2))),
|
|
|
- (item.quantity * producto.standard_price.toFixed(2)),
|
|
|
- ((item.quantity * (item.price_unit.toFixed(2) / invoice.rate.toFixed(2))) - (item.quantity * producto.standard_price)).toFixed(2)]);
|
|
|
+ data.push({number : (invoice.number),
|
|
|
+ name : (item.name),
|
|
|
+ quantity : (item.quantity),
|
|
|
+ price_unity : (item.price_unit.toFixed(2) / invoice.rate.toFixed(2)),
|
|
|
+ standar_price : (producto.standard_price.toFixed(2)),
|
|
|
+ price_tot : (item.quantity * (item.price_unit.toFixed(2) / invoice.rate.toFixed(2))),
|
|
|
+ standar_tot : (item.quantity * producto.standard_price.toFixed(2)),
|
|
|
+ utility : ((item.quantity * (item.price_unit.toFixed(2) / invoice.rate.toFixed(2))) - (item.quantity * producto.standard_price)).toFixed(2)});
|
|
|
+
|
|
|
+ // : dato[1],
|
|
|
+ // : dato[2],
|
|
|
+ // : dato[3],
|
|
|
+ // : dato[4],
|
|
|
+ // : dato[5],
|
|
|
+ // : dato[6],
|
|
|
+ // : dato[7]});
|
|
|
+ // data.push([(invoice.number),
|
|
|
+ // (item.name),
|
|
|
+ // (item.quantity),
|
|
|
+ // (item.price_unit.toFixed(2) / invoice.rate.toFixed(2)),
|
|
|
+ // (producto.standard_price.toFixed(2)),
|
|
|
+ // (item.quantity * (item.price_unit.toFixed(2) / invoice.rate.toFixed(2))),
|
|
|
+ // (item.quantity * producto.standard_price.toFixed(2)),
|
|
|
+ // ((item.quantity * (item.price_unit.toFixed(2) / invoice.rate.toFixed(2))) - (item.quantity * producto.standard_price)).toFixed(2)]);
|
|
|
}
|
|
|
// console.log(data);
|
|
|
// console.log(data.length);
|
|
|
this.drawPDF(data);
|
|
|
},
|
|
|
|
|
|
-
|
|
|
drawPDF: function (rows) {
|
|
|
- var columns = ['Factura', 'Producto', 'Cantidad', 'Precio Unitario', 'Precio Costo', 'Totla Venta', 'Total Costo', 'Utilidad'];
|
|
|
+
|
|
|
+ getColumns = [
|
|
|
+ {title: "Factura", dataKey: "number"},
|
|
|
+ {title: "Producto", dataKey: "name"},
|
|
|
+ {title: "Cantidad", dataKey: "quantity"},
|
|
|
+ {title: "Precio Unitario", dataKey: "price_unity"},
|
|
|
+ {title: "Precio Costo", dataKey: "standar_price"},
|
|
|
+ {title: "Totla Venta", dataKey: "price_tot"},
|
|
|
+ {title: "Total Costo", dataKey: "standar_tot"},
|
|
|
+ {title: "Utilidad", dataKey: "utility"}
|
|
|
+ ];
|
|
|
+
|
|
|
var pdfDoc = new window.jsPDF();
|
|
|
- // alert(columns);
|
|
|
- pdfDoc.autoTable(columns, rows, {
|
|
|
- theme: 'plain', // 'striped', 'grid' or 'plain',
|
|
|
- styles: {
|
|
|
- fontSize: 8,
|
|
|
- overflow: 'linebreak' // visible, hidden, ellipsize or linebreak
|
|
|
- },
|
|
|
+ var quantity=precio_cost=precio_unit=tol_cost=tot_unit=utility=0;
|
|
|
+ _.each(rows, function (datos) {
|
|
|
+ quantity += datos.quantity;
|
|
|
+ precio_unit += datos.price_unity;
|
|
|
+ precio_cost += parseFloat(datos.standar_price);
|
|
|
+ tot_unit += datos.price_tot;
|
|
|
+ tol_cost += datos.standar_tot;
|
|
|
+ utility += parseFloat(datos.utility);
|
|
|
+ });
|
|
|
+
|
|
|
+ rows.push({ number : " ",
|
|
|
+ name : "TOTAL ",
|
|
|
+ quantity: quantity,
|
|
|
+ price_unity : precio_unit.toFixed(2),
|
|
|
+ standar_price : precio_cost.toFixed(2),
|
|
|
+ price_tot : tot_unit.toFixed(2),
|
|
|
+ standar_tot : tol_cost.toFixed(2),
|
|
|
+ utility : utility.toFixed(2)});
|
|
|
+
|
|
|
+ rows.unshift({ number : " ",
|
|
|
+ name : "TOTAL ",
|
|
|
+ quantity: quantity,
|
|
|
+ price_unity : precio_unit.toFixed(2),
|
|
|
+ standar_price : precio_cost.toFixed(2),
|
|
|
+ price_tot : tot_unit.toFixed(2),
|
|
|
+ standar_tot : tol_cost.toFixed(2),
|
|
|
+ utility : utility.toFixed(2)});
|
|
|
+
|
|
|
+ // console.log(this.formatear(123456789.5));
|
|
|
+ pdfDoc.autoTable(getColumns, rows, {
|
|
|
+
|
|
|
+ theme: 'striped', // 'striped', 'grid' or 'plain',
|
|
|
+
|
|
|
+ // startY: pdfDoc.autoTable.previous.finalY + 15,
|
|
|
+ // margin: {},
|
|
|
+ // tableLineWidth: 0.75,
|
|
|
+ styles: { overflow: 'hidden',
|
|
|
+ fontSize: 7,
|
|
|
+ columnWidth: 'wrap'},
|
|
|
+ columnStyles: {
|
|
|
+ // text: {columnWidth: 'auto'},
|
|
|
+ number: {fontStyle: 'bold'},
|
|
|
+ name :{columnWidth: '10px'},
|
|
|
+ quantity :{halign:'right' },
|
|
|
+ price_unity : {halign:'right' },
|
|
|
+ standar_price : {halign:'right' },
|
|
|
+ price_tot : {halign:'right' },
|
|
|
+ standar_tot : {halign:'right' },
|
|
|
+ utility : {halign:'right' },
|
|
|
+ },
|
|
|
+ // styles: {
|
|
|
+ //
|
|
|
+ // overflow: 'linebreak' // visible, hidden, ellipsize or linebreak
|
|
|
+ // },
|
|
|
// showHeader: 'firstPage', // 'everyPage', 'firstPage', 'never',
|
|
|
// headerStyles: {
|
|
|
- // fontStyle: 'bold',
|
|
|
- // fillColor: '#000000'
|
|
|
+ // // // fontStyle: 'bold',
|
|
|
+ // // // fillColor: '#000000'
|
|
|
+ // // // columnWidth: 'relative',
|
|
|
// },
|
|
|
- margin: {
|
|
|
- top: 15
|
|
|
- },
|
|
|
+ margin: { top: 15, horizontal: 7},
|
|
|
+
|
|
|
addPageContent: function (data) {
|
|
|
pdfDoc.text('Facturas de SUC.', 10, 10);
|
|
|
- // pdfDoc.addpage();
|
|
|
}
|
|
|
|
|
|
-
|
|
|
-
|
|
|
});
|
|
|
- // pdfDoc.text('Informe loco.', 10, 10);
|
|
|
- // pdfDoc.internal.getNumberOfPages();
|
|
|
|
|
|
pdfDoc.save('Analisis de utilidad.pdf')
|
|
|
-
|
|
|
// pdfDoc.output('dataurlnewwindow');
|
|
|
- }
|
|
|
+ },
|
|
|
|
|
|
});
|
|
|
instance.web.client_actions.add('report_invoice_utility.action_report', 'instance.report_invoice_utility.ReportWidget');
|