Rupee formatting
import { formatPKR, formatLakh } from 'pakdatakit/format'
Two ways to show a rupee amount: with comma separators and the Rs. prefix, or in the lakh and crore units used for prices and salaries in Pakistan.
Rs. 12,500,000, 1.25 Crore
- formatPKR()
- Rs. 12,500,000
- formatLakh()
- 1.25 Crore
Examples
Section titled “Examples”import { formatPKR, formatLakh } from 'pakdatakit';
formatPKR(150000.4);// → 'Rs. 150,000'
formatLakh(2500000);// → '25 Lakh'
formatLakh(125000000);// → '12.5 Crore'from pakdatakit import format_pkr, format_lakh
format_pkr(150000.4)# → 'Rs. 150,000'
format_lakh(2_500_000)# → '25 Lakh'
format_lakh(125_000_000)# → '12.5 Crore'import 'package:pakdatakit/pakdatakit.dart';
formatPKR(150000.4);// → 'Rs. 150,000'
formatLakh(2500000);// → '25 Lakh'
formatLakh(125000000);// → '12.5 Crore'using PakDataKit;
Currency.FormatPkr(150000.4);// → "Rs. 150,000"
Currency.FormatLakh(2500000);// → "25 Lakh"
Currency.FormatLakh(125000000);// → "12.5 Crore"use PakDataKit\Currency;
Currency::formatPkr(150000.4);// → 'Rs. 150,000'
Currency::formatLakh(2_500_000);// → '25 Lakh'
Currency::formatLakh(125_000_000);// → '12.5 Crore'Reference
Section titled “Reference”formatPKR()
Section titled “formatPKR()”function formatPKR(amount: number): string;Parameters. amount: in PKR.
Returns the amount with comma separators, rounded to whole rupees, such as "Rs. 150,000". Negative amounts are prefixed with -: "-Rs. 500".
Caveats. Throws a RangeError if amount is NaN or infinite.
Related: formatLakh().
formatLakh()
Section titled “formatLakh()”function formatLakh(amount: number): string;Parameters. amount: in PKR.
Returns amounts of 1 crore or more as "N Crore" (10000000 → "1 Crore"), amounts of 1 lakh or more as "N Lakh" (2500000 → "25 Lakh"), and smaller amounts as formatPKR() does. Negative amounts are prefixed with -.
Caveats. Values are rounded to two decimals before the unit is chosen, so 9999999 is "1 Crore", not "100 Lakh". Throws a RangeError if amount is NaN or infinite.
Related: formatPKR(), numbers in words for cheques.
Related
Section titled “Related”-
Reading amounts:
parseAmount()reads what people type, like1,50,000,Rs. 5,000/-or1.5 lakh