Browse Source

[ADD] valoracion de stock

Rodney Enciso Arias 7 years ago
parent
commit
df25360bd6

BIN
__init__.pyc


BIN
controllers.pyc


BIN
models.pyc


+ 64 - 20
static/src/js/reports/report_stock_product.js

@@ -9,6 +9,7 @@ function report_stock_product (reporting){
         stockQuant : [],
         productProduct : [],
         prodcut:[],
+        newStock:[],
 
         events : {
             'click #toolbar > button' : 'clickOnAction',
@@ -110,6 +111,7 @@ function report_stock_product (reporting){
             var productProduct;
             var cat = 0;
             var quant;
+            var total=0;
 
             productProduct = self.getProdcutoProduct(self.productProduct,stockQuant);
             for (var f = 0; f < productProduct.length; f++) {
@@ -122,14 +124,17 @@ function report_stock_product (reporting){
                         return mamo + num;
                     },0);
                     quant=itemQuant.shift();
+                    total = parseInt(cat * itemProduct.standard_price);
                     stock.push({ id : quant.product_id[0],
                                 product : quant.product_id[1],
                                 qty : cat,
-                                standard_price : accounting.formatNumber(itemProduct.standard_price,2, ".", ","),
-                                lst_price : accounting.formatNumber(itemProduct.lst_price,2, ".", ","),
+                                standard_price : accounting.formatNumber(itemProduct.standard_price,0, ".", ","),
+                                lst_price : accounting.formatNumber(itemProduct.lst_price,0, ".", ","),
+                                total: accounting.formatNumber(total,0,".",",")
                             });
                 }
             }
+            self.newStock = stock;
             self.loadTable(stock);
         },
         // Obtener Producto Por quant y locations
@@ -159,31 +164,67 @@ function report_stock_product (reporting){
             var table = this.$el.find('#table');
             table.bootstrapTable('load' ,rowsTable);
         },
-        // Click pdf -Grafic
+
+        // Cambiar la impresion del pdf
+
+        // Crear el objeto PDF
+        getObjetPdf: function(){
+            var self = this;
+            var rows=[];
+            var newStock = self.newStock;
+            var amount_total = 0;
+            var qty = 0;
+            for (var i = 0; i < newStock.length; i++) {
+                rows.push({
+                    product : newStock[i].product,
+                    qty : newStock[i].qty,
+                    standard_price : newStock[i].standard_price,
+                    lst_price : newStock[i].lst_price,
+                    total: newStock[i].total
+                });
+                qty+=parseInt(newStock[i].qty);
+                amount_total+=parseInt(newStock[i].total.replace(".",""));
+            }
+            rows.push({
+                product : 'Totales',
+                qty : accounting.formatNumber(qty,0,".",","),
+                standard_price : '',
+                lst_price : '',
+                total: accounting.formatNumber(amount_total,0,".",","),
+            });
+            return rows;
+        },
+
+        // imprimir PDF
         clickOnAction: function (e) {
             var self = this;
+            var rowsNew;
             var action = self.$el.find(e.target).val();
-            var getColumns=[];
-            var rows=[];
             var table = self.$el.find("#table");
             var data2 = table.bootstrapTable('getVisibleColumns');
+            var getColumns=[];
+            var rows=[];
+            rowsNew = self.getObjetPdf();
             if (action === 'pdf') {
                 var dataNEW = _.map(data2, function (val){
                     return val.field;
                 });
-                _.each(self.prodcut,function (item){
+                _.each(rowsNew,function (item){
                     rows.push(_.pick(item, dataNEW));
                 });
-              // Obtener los nombre de la Cabezera
-                _.each(_.map(data2,function(val){return val}), function(item){
-                    getColumns.push([{
-                                    title: item.title,
-                                    dataKey: item.field
-                                }]);
+                // Obtener los nombre de la Cabezera
+                _.each(_.map(data2,function(val){
+                        return val;
+                    }), function(item){
+                            getColumns.push([{
+                                        title: item.title,
+                                        dataKey: item.field
+                                    }]);
                 });
-                self.drawPDF(_.flatten(getColumns),rows)
+                this.drawPDF(_.flatten(getColumns),rows);
             }
         },
+
         // pdfDoc
         drawPDF:function(getColumns,rows){
             var self = this;
@@ -193,13 +234,14 @@ function report_stock_product (reporting){
             var pdfDoc = new jsPDF();
             pdfDoc.autoTable(getColumns, rows, {
                     styles: { overflow: 'linebreak', fontSize:8 , columnWidth: 'wrap'},
-                   columnStyles:{
+                    columnStyles:{
                                     product :{columnWidth: '8px'},
-                                   qty : {halign:'center'},
-                                   standard_price : {halign:'right'},
-                                   lst_price : {halign:'right'},
+                                    qty : {halign:'center'},
+                                    standard_price : {halign:'right'},
+                                    lst_price : {halign:'right'},
+                                    total : {halign:'right'},
                                 },
-                   margin: { top: 16, horizontal: 7},
+                    margin: { top: 16, horizontal: 7},
                 addPageContent: function (data) {
                     pdfDoc.setFontSize(12);
                     pdfDoc.setFontStyle('bold');
@@ -208,7 +250,8 @@ function report_stock_product (reporting){
                     // FOOTER
                     var str = "Pagina  " + data.pageCount;
                     if (typeof pdfDoc.putTotalPages === 'function') {
-                        str = str + " de " + totalPagesExp +"\n  Día de Expedición  "+fechaActu.getDate()+"/"+fechaActu.getMonth()+"/"+fechaActu.getFullYear();
+                        str = str + " de " + totalPagesExp;
+                        // +"\n  Día de Expedición  "+fechaActu.getDate()+"/"+fechaActu.getMonth()+"/"+fechaActu.getFullYear();
                     }
                     pdfDoc.setFontSize(9);
                     pdfDoc.setFontStyle('bold');
@@ -219,7 +262,8 @@ function report_stock_product (reporting){
             if (typeof pdfDoc.putTotalPages === 'function') {
                 pdfDoc.putTotalPages(totalPagesExp);
             }
-           pdfDoc.save('Listado de productos de '+location+'.pdf');
+            pdfDoc.save('Listado de productos.pdf');
         }
+
     });
 }

+ 2 - 1
static/src/reports/report_stock_product.xml

@@ -7,7 +7,7 @@
                     <div id="volver"></div>
                 </div>
                 <div id="toolbar">
-                    <button class="oe_button oe_form_button oe_highlight" value="pdf" id="pdf">Exportar a PDF</button>
+                    <button class="oe_button oe_form_button oe_highlight" value="pdf" id="pdf">Exportar</button>
                 </div>
                 <table id="table" class="table_paint_first_row"
                        data-pagination="true"
@@ -27,6 +27,7 @@
                             <th data-field="qty" data-sortable="true" data-align="center">Cantidad</th>
                             <th data-field="standard_price" data-sortable="true" data-align="right">Precio de compra</th>
                             <th data-field="lst_price" data-sortable="true" data-align="right">Precio de venta </th>
+                            <th data-field="total" data-sortable="true" data-align="right">Valoración de stock</th>
                         </tr>
                     </thead>
                 </table>