From 7591ccb984fb98d3f1d0aad02c41412433f75ce9 Mon Sep 17 00:00:00 2001 From: Methapon2001 <61303214+Methapon2001@users.noreply.github.com> Date: Fri, 12 Sep 2025 09:30:24 +0700 Subject: [PATCH] refactor: use switch case instead --- src/utils/arithmetic.ts | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/src/utils/arithmetic.ts b/src/utils/arithmetic.ts index 0864fd3b..912b3d0b 100644 --- a/src/utils/arithmetic.ts +++ b/src/utils/arithmetic.ts @@ -55,9 +55,12 @@ export function calculatePrice( // Calculate before VAT const beforeVat = vatIncluded ? precisionRound(price / (1 + vat)) : price; - // Return based on output selection - if (output === 'vat') return calculatedVat; - if (output === 'total') return total; - if (output === 'beforeVat') return beforeVat; - return 0; + switch (output) { + case 'vat': + return calculatedVat; + case 'total': + return total; + case 'beforeVat': + return beforeVat; + } }