Bug 39796 - Format discount and tax rate code should be moved out of the vue component
Summary: Format discount and tax rate code should be moved out of the vue component
Status: NEW
Alias: None
Product: Koha
Classification: Unclassified
Component: Acquisitions (show other bugs)
Version: 24.11
Hardware: All All
: P5 - low normal
Assignee: Bugs List
QA Contact: Testopia
URL:
Keywords:
Depends on: 38010
Blocks:
  Show dependency treegraph
 
Reported: 2025-04-30 19:38 UTC by Jonathan Druart
Modified: 2025-04-30 19:38 UTC (History)
0 users

See Also:
GIT URL:
Change sponsored?: ---
Patch complexity: ---
Documentation contact:
Documentation submission:
Text to go in the release notes:
Version(s) released in:
Circulation function:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Jonathan Druart 2025-04-30 19:38:47 UTC
vue/components/Vendors/VendorOrderingInformation.vue

+        formatTaxRate(taxRate) {
+            if (!taxRate) return 0;
+            const decimalPlaces = taxRate.toString().split(".")[1]?.length || 0;
+            const multiplier = 10 ** decimalPlaces;
+            return Math.round(taxRate * multiplier) / (multiplier / 100);
+        },
+        formatDiscount() {
+            if (!this.vendor.discount) return 0.0;
+            const decimalPlaces =
+                this.vendor.discount.toString().split(".")[1]?.length || 0;
+            if (decimalPlaces) {
+                return this.vendor.discount;
+            } else {
+                return this.vendor.discount.toFixed(1);
+            }
+        },

This should not be there. Ideally it should be in a js file that would be reusable from outside vue.