]> _ Git - fluidbook-html5.git/commitdiff
wip #6875 @2
authorVincent Vanwaelscappel <vincent@cubedesigners.com>
Tue, 23 Apr 2024 05:12:50 +0000 (07:12 +0200)
committerVincent Vanwaelscappel <vincent@cubedesigners.com>
Tue, 23 Apr 2024 05:12:50 +0000 (07:12 +0200)
js/libs/fluidbook/cart/fluidbook.cart.bastide-resah.js
js/libs/fluidbook/fluidbook.menu.js

index e328558e8b0f37b3509be53d6d912631225797d2..cf6c38380ff932beb1c08a23e98f6933bacc66b3 100644 (file)
@@ -33,7 +33,7 @@ FluidbookCartBastideResah.prototype = {
 
             $.ajax('https://bastide-resah.fluidbook.com/fluidbook/order', {
                 method: 'POST',
-                data: {details:$this.getItems()},
+                data: {details: $this.getItems()},
             });
 
             $this.fluidbook.menu.quickCloseView();
@@ -63,7 +63,7 @@ FluidbookCartBastideResah.prototype = {
 
         // If this item has already been added to the cart, increment the quantity instead of adding a new item
         if (existingIndex >= 0) {
-            this.items[existingIndex].quantity += 1;
+            this.items[existingIndex].quantity = parseInt(this.items[existingIndex].quantity) + 1;
         } else {
             let item = {};
             item.reference = reference;
@@ -180,10 +180,10 @@ FluidbookCartBastideResah.prototype = {
             return `<div class="cart-empty">${this.fluidbook.l10n.__('your cart is empty')}</div>`;
         }
 
-        let total_ht;
-        let tva;
-        let eco_taxe;
-        let total_ttc = total_ht = tva = eco_taxe = 0;
+        let total_ht=0;
+        let tva=0;
+        let eco_taxe=0;
+        let total_ttc = 0;
 
         let $this = this;
         let columns = this.getColumns();
@@ -204,20 +204,19 @@ FluidbookCartBastideResah.prototype = {
 
             content += '<tr>';
 
-            $.each(columns, function (key, title) {
+            let et = $this.parseFloat($this.data[item.reference]['ECOTAXE']);
+            let ht = $this.parseFloat($this.data[item.reference]['PV RESAH HT']) + et;
+            let tht = parseInt(item.quantity) * ht;
+
+            total_ht += tht;
+            eco_taxe += item.quantity * et;
+            tva += $this.parseFloat($this.data[item.reference]['TVA']) * tht * 0.01;
 
+            $.each(columns, function (key, title) {
                 let data = $this.data[item.reference];
                 let value = data[key] || '&mdash;'; // Fallback for missing values
                 let output = '';
 
-                let et = $this.parseFloat($this.data[item.reference]['ECOTAXE']);
-                let ht = $this.parseFloat($this.data[item.reference]['PV RESAH HT']) + et;
-                let tht = item.quantity * ht;
-
-                total_ht += tht;
-                eco_taxe += item.quantity * et;
-                tva += $this.parseFloat($this.data[item.reference]['TVA']) * tht * 0.01;
-
                 switch (key) {
                     case 'PV RESAH HT':
                     case 'ECOTAXE':
@@ -267,7 +266,7 @@ FluidbookCartBastideResah.prototype = {
             content += '</tr>';
         });
 
-        total_ttc = tva + eco_taxe + total_ht;
+        total_ttc = tva + total_ht;
 
         content += '</tbody>';
         content += '</table>';
index 3708eea59dd228ce8685ef85b5eb3fdb03dec8cc..5d68fb62ff0db01102418afb4deffd089ebf19d9 100644 (file)
@@ -891,7 +891,7 @@ FluidbookMenu.prototype = {
                 break;
             case 'cart':
                 w = this.fluidbook.cart.getMenuWidth();
-                h=this.fluidbook.cart.getMenuHeight();
+                h = this.fluidbook.cart.getMenuHeight();
                 if (ww < w) {
                     fullscreen = true;
                 }