Functions and money-safe calculations
Make money calculations reusable
A function gives a calculation a name and a contract. Smart Ledger stores money as integer agorot, because decimal arithmetic can produce surprising results. Convert once, calculate with integers, and format only at the edge of the UI.
In this module you will create functions for agorot conversion, VAT, and ILS formatting.
Instruções
Create toAgorot(amount) and return rounded integer agorot.
Dica: Math.round(Number(amount) * 100)
Create calculateVat(netAgorot) using VAT_RATE.
Create formatIls(agorot) with Intl.NumberFormat.
Render net, VAT, and total in #result.
Seu Código
Descreva o que você quer construir para esta etapa e eu escrevo o código — depois clique em Aplicar para inseri-lo no seu editor. Esta etapa: Create toAgorot(amount) and return rounded integer agorot.