PHPackages                             jinomdeveloper/helpers - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. jinomdeveloper/helpers

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

jinomdeveloper/helpers
======================

Laravel package for Indonesian financial calculations including PPN tax (11%) and Rupiah currency formatting

1.0.0(6mo ago)2479—8.3%[4 PRs](https://github.com/jinomdeveloper/helpers/pulls)MITPHPPHP ^8.1CI passing

Since Nov 3Pushed 2mo agoCompare

[ Source](https://github.com/jinomdeveloper/helpers)[ Packagist](https://packagist.org/packages/jinomdeveloper/helpers)[ Docs](https://github.com/jinomdeveloper/helpers)[ GitHub Sponsors](https://github.com/rupadana)[ RSS](/packages/jinomdeveloper-helpers/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (1)Dependencies (12)Versions (7)Used By (0)

Jinom Helpers
=============

[](#jinom-helpers)

[![Latest Version on Packagist](https://camo.githubusercontent.com/6ae88b329f1c8b8cde70477931fb1350c454811aac020a80522cc998a88f337d/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6a696e6f6d646576656c6f7065722f68656c706572732e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/jinomdeveloper/helpers)[![GitHub Tests Action Status](https://camo.githubusercontent.com/7fd86fcf1dc1f4168e7ad31050ff3e6906e0d6a51c6be416176f13c540dc375f/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f6a696e6f6d646576656c6f7065722f68656c706572732f72756e2d74657374732e796d6c3f6272616e63683d6d61696e266c6162656c3d7465737473267374796c653d666c61742d737175617265)](https://github.com/jinomdeveloper/helpers/actions?query=workflow%3Arun-tests+branch%3Amain)[![GitHub Code Style Action Status](https://camo.githubusercontent.com/f16dd098a2b642fdcbef8dc05b32710f56547d57e27a54183feee282313f983f/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f6a696e6f6d646576656c6f7065722f68656c706572732f6669782d7068702d636f64652d7374796c652d6973737565732e796d6c3f6272616e63683d6d61696e266c6162656c3d636f64652532307374796c65267374796c653d666c61742d737175617265)](https://github.com/jinomdeveloper/helpers/actions?query=workflow%3A%22Fix+PHP+code+style+issues%22+branch%3Amain)[![Total Downloads](https://camo.githubusercontent.com/42e665bdd0bda4b27709860fceedba0c768093bf9882f7e855afa4ce9499deea/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f6a696e6f6d646576656c6f7065722f68656c706572732e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/jinomdeveloper/helpers)

A Laravel package that provides useful utility functions for Indonesian developers. This package includes tax calculation services and Indonesian Rupiah currency formatting helpers, making it easier to handle financial calculations in Indonesian web applications.

Perfect for e-commerce applications, invoicing systems, or any Laravel project that needs to handle Indonesian tax calculations and currency formatting.

Features
--------

[](#features)

- **Tax Calculator**: Calculate Indonesian tax (PPN 11%) with support for both inclusive and exclusive tax calculations
- **Currency Formatter**: Format numbers to Indonesian Rupiah (IDR) currency format
- **Number to Words**: Convert numbers to Indonesian text (terbilang)
- **Currency Parser**: Parse Indonesian currency strings back to numbers
- **Phone Number Formatter**: Format Indonesian phone numbers to E.164 international format
- **Easy Integration**: Simple Laravel facade and service provider integration
- **Clean API**: Intuitive and chainable methods for common operations

Installation
------------

[](#installation)

You can install the package via composer:

```
composer require jinomdeveloper/helpers
```

The package will automatically register itself via Laravel's package discovery feature.

Usage
-----

[](#usage)

### Tax Calculations

[](#tax-calculations)

The package provides a comprehensive tax calculation service that handles Indonesian PPN (11% tax rate).

#### Tax Inclusive Calculations (Price includes tax)

[](#tax-inclusive-calculations-price-includes-tax)

When you have a price that already includes tax and want to break it down:

```
use Jinom\Helpers\Facades\Helpers;

// Price includes tax (e.g., customer sees Rp 111,000)
$taxService = Helpers::tax(111000, true);

echo $taxService->basePrice;    // 100000 (original price before tax)
echo $taxService->tax;          // 11000 (tax amount)
echo $taxService->taxedPrice;   // 111000 (total price with tax)
```

#### Tax Exclusive Calculations (Price excludes tax)

[](#tax-exclusive-calculations-price-excludes-tax)

When you have a base price and want to add tax:

```
use Jinom\Helpers\Facades\Helpers;

// Base price without tax
$taxService = Helpers::tax(100000, false);

echo $taxService->basePrice;    // 100000 (original price)
echo $taxService->tax;          // 11000 (calculated tax)
echo $taxService->taxedPrice;   // 111000 (total price with tax)
```

### Currency Formatting

[](#currency-formatting)

Format numbers to Indonesian Rupiah currency format:

```
use Jinom\Helpers\Facades\Helpers;

echo Helpers::rupiah(1000000);     // "Rp 1.000.000"
echo Helpers::rupiah(150000);      // "Rp 150.000"
echo Helpers::rupiah(1500.75);     // "Rp 1.501" (rounded to nearest integer)
```

### Number to Words (Terbilang)

[](#number-to-words-terbilang)

Convert numbers to Indonesian words:

```
use Jinom\Helpers\Facades\Helpers;

echo Helpers::terbilang(1000000);  // "Satu Juta Rupiah"
echo Helpers::terbilang(150000);   // "Seratus Lima Puluh Ribu Rupiah"
echo Helpers::terbilang(25);       // "Dua Puluh Lima Rupiah"
```

### Currency String to Number

[](#currency-string-to-number)

Parse Indonesian currency strings back to numbers:

```
use Jinom\Helpers\Facades\Helpers;

echo Helpers::rupiah_to_number("Rp 1.000.000");    // 1000000
echo Helpers::rupiah_to_number("Rp 150.000");      // 150000
echo Helpers::rupiah_to_number("1.500,75");        // 1500.75
echo Helpers::rupiah_to_number("(Rp 50.000)");     // -50000 (negative)
```

### Phone Number Formatting

[](#phone-number-formatting)

Format Indonesian phone numbers to E.164 international format:

```
use Jinom\Helpers\Facades\Helpers;

echo Helpers::to_e164("081234567890");      // "+6281234567890"
echo Helpers::to_e164("0812-3456-7890");    // "+6281234567890"
echo Helpers::to_e164("62812345678");       // "+62812345678"
echo Helpers::to_e164("+6281234567890");    // "+6281234567890"

// With custom country code
echo Helpers::to_e164("081234567890", "1"); // "+181234567890"
```

### Using Without Facade

[](#using-without-facade)

You can also use the classes directly:

```
use Jinom\Helpers\Helpers;
use Jinom\Helpers\Services\TaxService;

// Direct tax calculation
$taxService = new TaxService(111000, true);

// Using the main class
$helpers = new Helpers();
$taxService = $helpers::tax(111000, true);

// Currency formatting
echo $helpers::rupiah(1000000);
```

### Practical Examples

[](#practical-examples)

#### E-commerce Product Pricing

[](#e-commerce-product-pricing)

```
use Jinom\Helpers\Facades\Helpers;

// Product price displayed to customer (includes tax)
$displayPrice = 555000;

$tax = Helpers::tax($displayPrice, true);

echo "Product Price: " . Helpers::rupiah($tax->basePrice);     // "Rp 500.000"
echo "Tax (PPN 11%): " . Helpers::rupiah($tax->tax);          // "Rp 55.000"
echo "Total Price: " . Helpers::rupiah($tax->taxedPrice);     // "Rp 555.000"
echo "Amount in Words: " . Helpers::terbilang($tax->taxedPrice); // "Lima Ratus Lima Puluh Lima Ribu rupiah"
```

#### Customer Form Processing

[](#customer-form-processing)

```
use Jinom\Helpers\Facades\Helpers;

// Customer input from form
$customerInput = [
    'amount' => 'Rp 1.500.000',
    'phone' => '0812-3456-7890'
];

// Parse and process
$amount = Helpers::rupiah_to_number($customerInput['amount']);  // 1500000
$phone = Helpers::to_e164($customerInput['phone']);           // "+6281234567890"

// Calculate with tax
$tax = Helpers::tax($amount, false);
echo "Final amount: " . Helpers::rupiah($tax->taxedPrice);    // "Rp 1.665.000"
echo "Amount in words: " . Helpers::terbilang($tax->taxedPrice);
echo "Contact: " . $phone;
```

#### Invoice Generation

[](#invoice-generation)

```
use Jinom\Helpers\Facades\Helpers;

$items = [
    ['name' => 'Product A', 'price' => 100000],
    ['name' => 'Product B', 'price' => 250000],
];

$subtotal = 0;
$totalTax = 0;

foreach ($items as $item) {
    $tax = Helpers::tax($item['price'], false);

    echo $item['name'] . ": " . Helpers::rupiah($tax->basePrice) . "\n";

    $subtotal += $tax->basePrice;
    $totalTax += $tax->tax;
}

echo "Subtotal: " . Helpers::rupiah($subtotal) . "\n";        // "Rp 350.000"
echo "Tax (PPN 11%): " . Helpers::rupiah($totalTax) . "\n";   // "Rp 38.500"
echo "Total: " . Helpers::rupiah($subtotal + $totalTax) . "\n"; // "Rp 388.500"
```

API Reference
-------------

[](#api-reference)

### Helpers Class

[](#helpers-class)

The main entry point for all helper functions.

#### Methods

[](#methods)

##### `tax(float|int $total, bool $includedTax = true): TaxService`

[](#taxfloatint-total-bool-includedtax--true-taxservice)

Creates a tax calculation service for Indonesian PPN (11%).

**Parameters:**

- `$total` - The amount to calculate tax for
- `$includedTax` - Whether the total includes tax (default: `true`)

**Returns:** `TaxService` instance with calculated values

##### `rupiah(float|int $amount): string`

[](#rupiahfloatint-amount-string)

Formats a number as Indonesian Rupiah currency.

**Parameters:**

- `$amount` - The amount to format

**Returns:** Formatted currency string with "Rp " prefix

##### `terbilang(float|int $amount): string`

[](#terbilangfloatint-amount-string)

Converts a number to Indonesian words (terbilang).

**Parameters:**

- `$amount` - The number to convert to words

**Returns:** Indonesian text representation with "rupiah" suffix

##### `rupiah_to_number(string|int|float $value): int|float`

[](#rupiah_to_numberstringintfloat-value-intfloat)

Parses Indonesian currency strings back to numbers.

**Parameters:**

- `$value` - Currency string, number, or numeric value to parse

**Returns:** Numeric value (int or float based on decimal presence)

##### `to_e164(string $phone, string $countryCode = '62'): string`

[](#to_e164string-phone-string-countrycode--62-string)

Formats phone numbers to E.164 international format.

**Parameters:**

- `$phone` - Phone number to format
- `$countryCode` - Country code (default: '62' for Indonesia)

**Returns:** E.164 formatted phone number with "+" prefix

### TaxService Class

[](#taxservice-class)

Handles tax calculations with the following public properties:

- `$basePrice` - The original price before tax
- `$tax` - The calculated tax amount
- `$taxedPrice` - The final price including tax

### Facade Usage

[](#facade-usage)

```
use Jinom\Helpers\Facades\Helpers;

// All methods available statically
$taxService = Helpers::tax(100000, false);
$formatted = Helpers::rupiah(100000);
```

Configuration
-------------

[](#configuration)

The package uses a fixed 11% tax rate for Indonesian PPN. This rate is hardcoded in the `TaxService` class and reflects the current Indonesian tax law.

Error Handling
--------------

[](#error-handling)

The package handles common edge cases:

- **Negative amounts**: Supported for refunds and adjustments
- **Decimal precision**: Amounts are rounded to nearest integer for IDR
- **Zero amounts**: Properly handled in both tax and currency formatting
- **Large numbers**: No arbitrary limits on calculation amounts

Performance Considerations
--------------------------

[](#performance-considerations)

- Tax calculations use simple arithmetic operations (very fast)
- Currency formatting uses PHP's built-in `number_format()` function
- No external API calls or database queries
- Suitable for high-traffic applications

Compatibility
-------------

[](#compatibility)

- **PHP**: 8.3+
- **Laravel**: 10.x, 11.x, 12.x
- **Framework**: Laravel package, but core classes can work standalone

Testing
-------

[](#testing)

```
composer test
```

Changelog
---------

[](#changelog)

Please see [CHANGELOG](CHANGELOG.md) for more information on what has changed recently.

Contributing
------------

[](#contributing)

Please see [CONTRIBUTING](CONTRIBUTING.md) for details.

Security Vulnerabilities
------------------------

[](#security-vulnerabilities)

Please review [our security policy](../../security/policy) on how to report security vulnerabilities.

Credits
-------

[](#credits)

- [Rupadana](https://github.com/rupadana)
- [All Contributors](../../contributors)

License
-------

[](#license)

The MIT License (MIT). Please see [License File](LICENSE.md) for more information.

###  Health Score

41

—

FairBetter than 89% of packages

Maintenance78

Regular maintenance activity

Popularity20

Limited adoption so far

Community10

Small or concentrated contributor base

Maturity48

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 61.1% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Unknown

Total

1

Last Release

196d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/29f8343484c8567d8f24dcf1e4fb4978f2ac8442e90448c6405a32ba511ee246?d=identicon)[rupadana](/maintainers/rupadana)

---

Top Contributors

[![rupadana](https://avatars.githubusercontent.com/u/34137674?v=4)](https://github.com/rupadana "rupadana (22 commits)")[![Copilot](https://avatars.githubusercontent.com/in/1143301?v=4)](https://github.com/Copilot "Copilot (7 commits)")[![dependabot[bot]](https://avatars.githubusercontent.com/in/29110?v=4)](https://github.com/dependabot[bot] "dependabot[bot] (4 commits)")[![github-actions[bot]](https://avatars.githubusercontent.com/in/15368?v=4)](https://github.com/github-actions[bot] "github-actions[bot] (3 commits)")

---

Tags

laravelcurrencyhelperscalculationparsingformattingfinanceindonesiataxphone-numberterbilangnumber to wordsindonesianrupiahE164Jinomppn

###  Code Quality

TestsPest

Static AnalysisPHPStan

Code StyleLaravel Pint

### Embed Badge

![Health badge](/badges/jinomdeveloper-helpers/health.svg)

```
[![Health](https://phpackages.com/badges/jinomdeveloper-helpers/health.svg)](https://phpackages.com/packages/jinomdeveloper-helpers)
```

###  Alternatives

[spatie/laravel-data

Create unified resources and data transfer objects

1.8k28.9M627](/packages/spatie-laravel-data)[hirethunk/verbs

An event sourcing package that feels nice.

513162.9k6](/packages/hirethunk-verbs)[riskihajar/terbilang

Number to words conversion support multi language.

134159.5k](/packages/riskihajar-terbilang)[worksome/exchange

Check Exchange Rates for any currency in Laravel.

123544.7k](/packages/worksome-exchange)[ralphjsmit/livewire-urls

Get the previous and current url in Livewire.

82270.3k4](/packages/ralphjsmit-livewire-urls)[hydrat/filament-table-layout-toggle

Filament plugin adding a toggle button to tables, allowing user to switch between Grid and Table layouts.

6292.3k1](/packages/hydrat-filament-table-layout-toggle)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
