PHPackages                             turahe/ledger - 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. [Database &amp; ORM](/categories/database)
4. /
5. turahe/ledger

ActiveLibrary[Database &amp; ORM](/categories/database)

turahe/ledger
=============

A ledger management system for handling vouchers and invoices.

v1.3.5(8mo ago)142MITPHPPHP ^8.4CI passing

Since Sep 10Pushed 8mo ago1 watchersCompare

[ Source](https://github.com/turahe/ledger)[ Packagist](https://packagist.org/packages/turahe/ledger)[ RSS](/packages/turahe-ledger/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (3)Dependencies (4)Versions (14)Used By (0)

Turahe Ledger Package
=====================

[](#turahe-ledger-package)

A comprehensive Laravel package for managing financial ledgers, invoices, vouchers, and payment tracking with PHP 8.4 support.

🚀 Features
----------

[](#-features)

- **Invoice Management** - Create, update, and track invoices with items and payments
- **Voucher System** - Manage vouchers with expiration dates and status tracking
- **Payment Processing** - Support for multiple payment methods including QRIS, e-wallets, and traditional methods
- **Multi-currency Support** - Built-in currency handling with configurable defaults
- **User Tracking** - Comprehensive audit trail with user stamps
- **Business Logic** - Built-in methods for financial calculations and status checks
- **Modern PHP** - Full PHP 8.4 compatibility with enums and modern syntax
- **Laravel Integration** - Seamless integration with Laravel's ecosystem

📋 Requirements
--------------

[](#-requirements)

- PHP 8.4+
- Laravel 12+
- MySQL/PostgreSQL/SQLite

🔧 Installation
--------------

[](#-installation)

1. Install the package via composer:

    ```
    composer require turahe/ledger
    ```
2. Publish resources (migrations and config files):

    ```
    php artisan vendor:publish --provider="Turahe\\Ledger\\Providers\\LedgerServiceProvider"
    ```
3. Execute migrations via the following command:

    ```
    php artisan migrate
    ```
4. Done!

⚙️ Configuration
----------------

[](#️-configuration)

The package configuration is located in `config/ledger.php`. You can customize:

- Default currency
- Payment method settings
- Model class mappings
- Database table names

📚 Usage
-------

[](#-usage)

### Creating an Invoice

[](#creating-an-invoice)

```
use Turahe\Ledger\Models\Invoice;
use Turahe\Ledger\Services\LedgerService;

// Using the model directly
$invoice = Invoice::create([
    'model_id' => $user->id,
    'model_type' => User::class,
    'code' => 'INV-001',
    'total_invoice' => 1000.00,
    'due_date' => now()->addDays(30),
    'status' => 'pending',
    'currency' => 'IDR'
]);

// Using the service layer
$ledgerService = app(LedgerService::class);
$invoice = $ledgerService->createInvoice([
    'model_id' => $user->id,
    'model_type' => User::class,
    'code' => 'INV-001',
    'total_invoice' => 1000.00,
    'due_date' => now()->addDays(30)
]);
```

### Adding Invoice Items

[](#adding-invoice-items)

```
use Turahe\Ledger\Models\Invoice\Item;

$item = $invoice->items()->create([
    'name' => 'Product Name',
    'quantity' => 2,
    'unit_price' => 500.00,
    'total_price' => 1000.00,
    'description' => 'Product description'
]);

// Business logic methods
$subtotal = $item->getSubtotal();
$totalAmount = $item->getTotalAmount();
$discountPercentage = $item->getDiscountPercentage();
```

### Processing Payments

[](#processing-payments)

```
use Turahe\Ledger\Models\Invoice\Payment;
use Turahe\Ledger\Enums\PaymentMethods;

$payment = $invoice->payments()->create([
    'amount' => 500.00,
    'payment_method' => PaymentMethods::E_WALLET_GOPAY,
    'payment_date' => now(),
    'status' => 'completed'
]);

// Check payment status
if ($payment->isCompleted()) {
    echo "Payment processed successfully";
}
```

### Managing Vouchers

[](#managing-vouchers)

```
use Turahe\Ledger\Models\Voucher;

$voucher = Voucher::create([
    'model_id' => $user->id,
    'model_type' => User::class,
    'code' => 'VOUCHER-001',
    'total_value' => 500.00,
    'due_date' => now()->addDays(15),
    'status' => 'active',
    'currency' => 'IDR'
]);

// Business logic methods
if ($voucher->isExpired()) {
    echo "Voucher has expired";
}

$daysUntilExpiry = $voucher->getDaysUntilExpiry();
$formattedValue = $voucher->getTotalValueFormatted();
```

### Using Query Scopes

[](#using-query-scopes)

```
use Turahe\Ledger\Models\Invoice;

// Find by code
$invoice = Invoice::byCode('INV-001')->first();

// Find by date range
$recentInvoices = Invoice::byDateRange(
    now()->subDays(30),
    now()
)->get();

// Find by status
$pendingInvoices = Invoice::byStatus('pending')->get();

// Find by model
$userInvoices = Invoice::byModelType(User::class)
    ->byModelId($user->id)
    ->get();
```

### Payment Methods

[](#payment-methods)

```
use Turahe\Ledger\Enums\PaymentMethods;

// Get methods by category
$qrisMethods = PaymentMethods::getByCategory('qris');
$eWalletMethods = PaymentMethods::getByCategory('e_wallet');

// Check method properties
if (PaymentMethods::E_WALLET_GOPAY->isDigital()) {
    echo "This is a digital payment method";
}

if (PaymentMethods::CASH->isInstant()) {
    echo "This is an instant payment method";
}
```

🧪 Testing
---------

[](#-testing)

The package includes comprehensive test coverage. To run the tests:

```
# Run all tests
./vendor/bin/phpunit --testdox

# Run specific test suite
./vendor/bin/phpunit --testdox --filter=InvoiceTest

# Run with coverage
./vendor/bin/phpunit --coverage-text
```

### Test Coverage

[](#test-coverage)

- **Unit Tests** - Model methods, business logic, and enums
- **Feature Tests** - Complete workflow testing
- **Business Logic Tests** - Financial calculations and validations

🔄 Recent Optimizations
----------------------

[](#-recent-optimizations)

The package has been recently optimized with:

- **PHP 8.4 Enum Support** - Modern enum syntax and utility methods
- **Enhanced Models** - Improved relationships, casting, and business logic
- **Service Layer** - Centralized business logic in `LedgerService`
- **Trait System** - Reusable `HasLedgerAttributes` trait for common functionality
- **Interface Contracts** - `LedgerModelInterface` for consistent model behavior
- **Custom Exceptions** - Specific error handling for ledger operations
- **Improved Migrations** - Fixed schema issues and added missing columns
- **Better Testing** - Comprehensive test coverage with proper setup

📁 Package Structure
-------------------

[](#-package-structure)

```
src/
├── Enums/                 # Payment methods and transaction types
├── Exceptions/            # Custom exception classes
├── Models/                # Eloquent models
│   ├── Concerns/          # Reusable traits
│   ├── Contracts/         # Interface definitions
│   ├── Invoice/           # Invoice-related models
│   └── Voucher/           # Voucher-related models
├── Providers/             # Service providers
└── Services/              # Business logic services

```

🤝 Contributing
--------------

[](#-contributing)

1. Fork the repository
2. Create a feature branch
3. Make your changes
4. Add tests for new functionality
5. Ensure all tests pass
6. Submit a pull request

📄 License
---------

[](#-license)

This package is open-sourced software licensed under the [MIT license](LICENSE).

🆘 Support
---------

[](#-support)

If you encounter any issues or have questions:

- Check the [issues page](https://github.com/turahe/ledger/issues)
- Create a new issue with detailed information
- Ensure you're using the latest version

🔗 Related Packages
------------------

[](#-related-packages)

- [UserStamps](https://github.com/turahe/userstamps) - User tracking for models
- [ULID](https://github.com/robsontenorio/laravel-ulid) - ULID support for Laravel

###  Health Score

38

—

LowBetter than 85% of packages

Maintenance60

Regular maintenance activity

Popularity9

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity64

Established project with proven stability

 Bus Factor1

Top contributor holds 100% 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

Every ~30 days

Recently: every ~3 days

Total

13

Last Release

256d ago

PHP version history (4 changes)v1.0.0PHP ^8.1

v1.0.2PHP ^8.3

v1.0.3PHP ^8.2

v1.2.0PHP ^8.4

### Community

Maintainers

![](https://www.gravatar.com/avatar/f3513bd6100438bcb8c6b1a7e241a66e1ddaf1c11ee33883e06ef4a2784120db?d=identicon)[turahe](/maintainers/turahe)

---

Top Contributors

[![turahe](https://avatars.githubusercontent.com/u/6832622?v=4)](https://github.com/turahe "turahe (48 commits)")

###  Code Quality

Code StyleLaravel Pint

### Embed Badge

![Health badge](/badges/turahe-ledger/health.svg)

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

###  Alternatives

[doctrine/orm

Object-Relational-Mapper for PHP

10.2k285.3M6.2k](/packages/doctrine-orm)[jdorn/sql-formatter

a PHP SQL highlighting library

3.9k115.1M102](/packages/jdorn-sql-formatter)[illuminate/database

The Illuminate Database package.

2.8k52.4M9.4k](/packages/illuminate-database)[mongodb/mongodb

MongoDB driver library

1.6k64.0M546](/packages/mongodb-mongodb)[ramsey/uuid-doctrine

Use ramsey/uuid as a Doctrine field type.

90340.3M211](/packages/ramsey-uuid-doctrine)[reliese/laravel

Reliese Components for Laravel Framework code generation.

1.7k3.4M16](/packages/reliese-laravel)

PHPackages © 2026

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