# Rupee formatting

> Format amounts as Pakistani rupees (Rs. 150,000) or in lakh and crore (25 Lakh, 1.25 Crore).

Source: https://pakdatakit.dev/docs/format/

`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.

## Examples

**TypeScript**

```ts
import { formatPKR, formatLakh } from 'pakdatakit';

formatPKR(150000.4);
// → 'Rs. 150,000'

formatLakh(2500000);
// → '25 Lakh'

formatLakh(125000000);
// → '12.5 Crore'
```

**Python**

```python
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'
```

**Dart**

```dart
import 'package:pakdatakit/pakdatakit.dart';

formatPKR(150000.4);
// → 'Rs. 150,000'

formatLakh(2500000);
// → '25 Lakh'

formatLakh(125000000);
// → '12.5 Crore'
```

**C#**

```csharp
using PakDataKit;

Currency.FormatPkr(150000.4);
// → "Rs. 150,000"

Currency.FormatLakh(2500000);
// → "25 Lakh"

Currency.FormatLakh(125000000);
// → "12.5 Crore"
```

**PHP**

```php
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

### formatPKR()

```ts
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).

### formatLakh()

```ts
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()`](#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()`](#formatpkr), [numbers in words](https://pakdatakit.dev/docs/words/) for cheques.

## Related

- [Reading amounts](https://pakdatakit.dev/docs/amount/): `parseAmount()` reads what people type, like `1,50,000`, `Rs. 5,000/-` or `1.5 lakh`

- [TypeScript API reference for `pakdatakit/format`](https://pakdatakit.dev/api/typescript/format/)
- [Numbers in words](https://pakdatakit.dev/docs/words/)
