File tree Expand file tree Collapse file tree 2 files changed +8
-14
lines changed
functions/src/domain/surcharge Expand file tree Collapse file tree 2 files changed +8
-14
lines changed Original file line number Diff line number Diff line change 11export function rateCalculatorHelper (
2- rate : number | undefined ,
32 totalAmount : number ,
43 surchargeAmount : number
54) : number {
6- if ( typeof rate === 'undefined' || rate <= 0 ) {
7- throw new Error ( 'Invalid input: rate amount must be greater than 0.' ) ;
8- } else {
9- if ( surchargeAmount <= 0 || totalAmount <= 0 ) {
10- throw new Error ( 'Invalid input: surchargeAmount and totalAmount must be greater than 0.' ) ;
11- }
12- const purchaseAmount = totalAmount - surchargeAmount
13- if ( purchaseAmount <= 0 ) {
14- throw new Error ( 'Invalid input: purchaseAmount amount must be greater than 0.' ) ;
15- }
16- const rate = ( surchargeAmount / purchaseAmount ) * 100
17- return Number ( rate . toFixed ( 1 ) )
5+ if ( surchargeAmount <= 0 || totalAmount <= 0 ) {
6+ throw new Error ( 'Invalid input: surchargeAmount and totalAmount must be greater than 0.' ) ;
187 }
8+ const purchaseAmount = totalAmount - surchargeAmount
9+ if ( purchaseAmount <= 0 ) {
10+ throw new Error ( 'Invalid input: purchaseAmount amount must be greater than 0.' ) ;
11+ }
12+ const rate = ( surchargeAmount / purchaseAmount ) * 100
13+ return Number ( rate . toFixed ( 1 ) )
1914}
Original file line number Diff line number Diff line change @@ -11,7 +11,6 @@ export const putSurchargeUsecase = async (
1111
1212 if ( request . totalAmount && request . surchargeAmount ) {
1313 newRate = rateCalculatorHelper (
14- undefined ,
1514 request . totalAmount ,
1615 request . surchargeAmount
1716 ) ;
You can’t perform that action at this time.
0 commit comments