Advertisement
Guest User

Monzo £5 Round Up

a guest
Jan 20th, 2021
1,732
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.60 KB | None | 0 0
  1. // grab the value of the purchase (eg. 4.3)
  2. var costRaw = Monzo.cardPurchase.AmountInAccountCurrency;
  3.  
  4. // convert it to a number value
  5. var cost = parseFloat(costRaw);
  6.  
  7. // round it up to the nearest full integer (eg. 5)
  8. var costRounded = Math.ceil(cost / 5) * 5;
  9.  
  10. // work out the difference in the rounding up (eg. 5 - 4.3 = 0.7)
  11. var costDiff = costRounded - cost;
  12.  
  13. // some form of round up accelorator
  14. var costDiffMult = costDiff * 1;
  15.  
  16. // convert to string
  17. var totalRoundup = costDiffMult.toFixed(2);
  18.  
  19. // set the rounded up value to be moved to the pot
  20. Monzo.potDeposit.setAmount(totalRoundup)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement