refactor: use switch case instead
This commit is contained in:
parent
93c54c0dd1
commit
05f7c886d6
1 changed files with 8 additions and 5 deletions
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue