From 2306ec163ce26a2c80906dfb6255f485b9734e12 Mon Sep 17 00:00:00 2001 From: Vincent Vanwaelscappel Date: Tue, 23 Apr 2024 07:12:50 +0200 Subject: [PATCH] wip #6875 @2 --- .../cart/fluidbook.cart.bastide-resah.js | 31 +++++++++---------- js/libs/fluidbook/fluidbook.menu.js | 2 +- 2 files changed, 16 insertions(+), 17 deletions(-) diff --git a/js/libs/fluidbook/cart/fluidbook.cart.bastide-resah.js b/js/libs/fluidbook/cart/fluidbook.cart.bastide-resah.js index e328558e..cf6c3838 100644 --- a/js/libs/fluidbook/cart/fluidbook.cart.bastide-resah.js +++ b/js/libs/fluidbook/cart/fluidbook.cart.bastide-resah.js @@ -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 `
${this.fluidbook.l10n.__('your cart is empty')}
`; } - 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 += ''; - $.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] || '—'; // 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 += ''; }); - total_ttc = tva + eco_taxe + total_ht; + total_ttc = tva + total_ht; content += ''; content += ''; diff --git a/js/libs/fluidbook/fluidbook.menu.js b/js/libs/fluidbook/fluidbook.menu.js index 3708eea5..5d68fb62 100644 --- a/js/libs/fluidbook/fluidbook.menu.js +++ b/js/libs/fluidbook/fluidbook.menu.js @@ -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; } -- 2.39.5