Browse Source

Informe de producción con diferentes filtros

Sebas 6 years ago
parent
commit
7dac8eec9c
2 changed files with 65 additions and 5 deletions
  1. 19 5
      static/src/js/reports/report_mrp_mrp.js
  2. 46 0
      static/src/reports/report_mrp_mrp.xml

+ 19 - 5
static/src/js/reports/report_mrp_mrp.js

@@ -367,7 +367,7 @@ function report_mrp_mrp(reporting) {
    BuildTable: function() {
      var self = this;
      var data = [];
-
+     var CurrencyBase = self.ResCompany[0].currency_id;
      var ResMrp = self.ResMrp;
      _.each(ResMrp, function(item) {
          if (item.state == 'confirmed') {
@@ -390,9 +390,9 @@ function report_mrp_mrp(reporting) {
          id: item.id,
          name: self.valorNull(item.name),
          product: item.product_id[1],
-         prod_price_unit: item.prod_price_unit,
-         product_qty: item.product_qty,
-         product_price: item.product_price,
+         prod_price_unit: accounting.formatMoney(item.prod_price_unit, '', CurrencyBase.decimal_places, CurrencyBase.thousands_separator, CurrencyBase.decimal_separator),
+         product_qty: accounting.formatNumber(item.product_qty,2,'.',','),
+         product_price: accounting.formatMoney(item.product_price, '', CurrencyBase.decimal_places, CurrencyBase.thousands_separator, CurrencyBase.decimal_separator),
          date_planned: moment(item.date_planned).format("DD/MM/YYYY"),
          date_from: moment(item.date_from).format("DD/MM/YYYY"),
          date_to: moment(item.date_to).format("DD/MM/YYYY"),
@@ -400,6 +400,11 @@ function report_mrp_mrp(reporting) {
          user: item.user_id[1],
          state: state,
          product_id: item.product_id[0],
+         quantity_no_format:item.product_qty,
+         total_no_format:item.product_price,
+         decimal_places: CurrencyBase.decimal_places,
+         thousands_separator: CurrencyBase.thousands_separator,
+         decimal_separator: CurrencyBase.decimal_separator,
        });
      });
      self.content = data;
@@ -433,7 +438,16 @@ function report_mrp_mrp(reporting) {
      var column = table.bootstrapTable('getVisibleColumns');
      var row = table.bootstrapTable('getData');
 
-     row.push({});
+     var product_qty = QuantityFooter(row);
+     var product_price = TotalFooter(row);
+
+    row.push({
+        date_planned : 'Totales',
+        product_qty : product_qty,
+        product_price : product_price,
+    });
+
+
      if (action === 'pdf') {
        var data = _.map(column, function(val) {
          return val.field

+ 46 - 0
static/src/reports/report_mrp_mrp.xml

@@ -117,6 +117,52 @@
           </table>
         </div>
       </div>
+      <script>
+
+      <!--
+          QUANTITY
+      -->
+      function QuantityFooter(rowsTable) {
+          var total =  _.reduce(_.map(rowsTable,function(item){
+              return item.quantity_no_format;
+          }), function(memo, num){
+              return memo + num;
+          },0);
+          return accounting.formatNumber(total,2,'.',',');
+      }
+
+
+      <!--
+          TAX
+      -->
+      function TotalFooter(rowsTable) {
+          var decimal_places = 0;
+          var thousands_separator = '.';
+          var decimal_separator = ',';
+          if(rowsTable.length > 0){
+              decimal_places = rowsTable[0].decimal_places;
+              thousands_separator = rowsTable[0].thousands_separator;
+              decimal_separator = rowsTable[0].decimal_separator;
+          }
+          var total =  _.reduce(_.map(rowsTable,function(item){
+              return item.total_no_format;
+          }), function(memo, num){
+              return memo + num;
+          },0);
+          return accounting.formatNumber(total,decimal_places,thousands_separator,decimal_separator);
+      }
+
+      <!--
+          FOOTER STYLE
+      -->
+      function footerStyle(row, index) {
+          return {
+              css: {
+                "font-weight": "bold"
+              }
+          };
+      };
+  </script>
     </div>
   </t>
 </template>