Skip to content

Commit

Permalink
Fix discount in billing UI (papercups-io#497)
Browse files Browse the repository at this point in the history
* Fix discount in billing UI

* Remove npm test workflow for now
  • Loading branch information
reichert621 authored Jan 1, 2021
1 parent 4c9fb08 commit fa08c57
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
6 changes: 3 additions & 3 deletions assets/src/components/billing/support.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -202,12 +202,12 @@ describe('calculateSubscriptionDiscount', () => {
discount: {
duration: 'forever',
name: 'Early Adopter',
percent_off: 50,
percent_off: 40,
valid: true,
},
});

expect(calculateSubscriptionDiscount(subscription)).toEqual(2000);
expect(calculateSubscriptionDiscount(subscription)).toEqual(1600);
});

test('handles amount_off discounts', () => {
Expand All @@ -230,6 +230,6 @@ describe('calculateSubscriptionDiscount', () => {
},
});

expect(calculateSubscriptionDiscount(subscription)).toEqual(3000);
expect(calculateSubscriptionDiscount(subscription)).toEqual(1000);
});
});
2 changes: 1 addition & 1 deletion assets/src/components/billing/support.ts
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ export const calculateSubscriptionDiscount = (
}

if (amountOff) {
return total - amountOff;
return amountOff;
} else if (percentOff) {
return total * (percentOff / 100);
} else {
Expand Down

0 comments on commit fa08c57

Please sign in to comment.