helpers.js 614B

12345678910111213141516171819202122232425262728293031
  1. export function ppn(price, percent) {
  2. return price + price * (percent / 100)
  3. }
  4. export function profit(price, percent) {
  5. return ppn(price, percent)
  6. }
  7. export function discount(price, percent) {
  8. return price - price * (percent / 100)
  9. }
  10. export const IDRCurrencyFormat = (number, decimal = false) => {
  11. if (number === null) {
  12. return
  13. }
  14. if (decimal) {
  15. return 'Rp' + number.toLocaleString('id') + ',00'
  16. } else {
  17. return 'Rp' + number.toLocaleString('id')
  18. }
  19. }
  20. export class FormValidationError extends Error {
  21. constructor(message, errors) {
  22. super(message)
  23. this.errors = errors
  24. }
  25. }