Browse Source

modify adjustements checks and display to switch from int to float quantity TG-47

SiM 5 years ago
parent
commit
905f834a85
2 changed files with 7 additions and 6 deletions
  1. 2 2
      apps/frontend/modules/katao/templates/_products.php
  2. 5 4
      lib/model/KataoProduct.php

+ 2 - 2
apps/frontend/modules/katao/templates/_products.php

@@ -9,8 +9,8 @@
 
     $display = false;
 if (!$url) {
-    if (preg_match('/(?P<colis>\\d+) \\((?P<incomplet>\\d+) \/ (?P<minimum>\\d+)\\)/', $order_details, $matches)) {
-        if (!empty($matches['incomplet']) && (int)$matches['incomplet'] != (int)$matches['minimum']) {
+    if (preg_match('/(?P<colis>\\d+) \\((?P<incomplet>\d+\.?\d*) \/ (?P<minimum>\\d+)\\)/', $order_details, $matches)) {
+        if ($matches['incomplet']>0 && (float)$matches['incomplet'] != (float)$matches['minimum']) {
             $display = true;
         }
     }

+ 5 - 4
lib/model/KataoProduct.php

@@ -75,7 +75,7 @@ class KataoProduct extends BaseKataoProduct {
 
         $rs = KataoProductPeer::doSelectRS($criteria);
         if ($rs->next()) {
-            $return = $rs->getInt(2);
+            $return = number_format($rs->getFloat(2), 3);
         }
 
         return $return;
@@ -174,7 +174,8 @@ class KataoProduct extends BaseKataoProduct {
     public function getOrderDetails($katao_period_id, $katao_node_id, $with_adjusted_quantity = false) {
         $completed_packages = $this->getCompletedPackages($katao_period_id, $katao_node_id, $with_adjusted_quantity);
         $last_incomplete_package = $this->getLastIncompletePackageQuantity($katao_period_id, $katao_node_id, $with_adjusted_quantity);
-        return sprintf('%d (%d / %d)%s', $completed_packages, $last_incomplete_package, $this->getMinOrderNumber(), ($completed_packages || $last_incomplete_package)?sprintf(' %s', image_tag($last_incomplete_package?'actions/bullet_red.png':'actions/bullet_green.png', array('alt' => $last_incomplete_package?'Colis incomplet':'Colis complet', 'align' => 'top'))):'');
+        $format_quantity = $this->getAuthorizeDecimal()?'%.3f':'%d';
+        return sprintf('%d ('.$format_quantity.' / %d)%s', $completed_packages, $last_incomplete_package, $this->getMinOrderNumber(), ($completed_packages || $last_incomplete_package)?sprintf(' %s', image_tag($last_incomplete_package?'actions/bullet_red.png':'actions/bullet_green.png', array('alt' => $last_incomplete_package?'Colis incomplet':'Colis complet', 'align' => 'top'))):'');
     }
 
     public function getUnitPriceEuroStr() {
@@ -307,7 +308,7 @@ L\'équipe KATAO', $this->getName(), $this->getReference(), Utils::formatCurrenc
 
         $rs = KataoOrderProductPeer::doSelectRS($criteria);
         if ($rs->next()) {
-            $return = $rs->getInt(1);
+            $return = number_format($rs->getFloat(1), 3);
         }
 
         return $return;
@@ -335,7 +336,7 @@ L\'équipe KATAO', $this->getName(), $this->getReference(), Utils::formatCurrenc
 
         $rs = KataoInvoiceProductPeer::doSelectRS($criteria);
         while ($rs->next()) {
-            $return += $rs->getInt(1);
+            $return += number_format($rs->getFloat(1), 3);
         }
 
         return $return;