jeffersongoncalves/laravel-erp-core

ERP core — companies, currencies, units, and submittable-document foundation for the Laravel ERP ecosystem

Maintainers

Package info

github.com/jeffersongoncalves/laravel-erp-core

pkg:composer/jeffersongoncalves/laravel-erp-core

Statistics

Installs: 179

Dependents: 13

Suggesters: 0

Stars: 1

Open Issues: 0

dev-main 2026-06-27 20:49 UTC

This package is auto-updated.

Last update: 2026-06-28 01:31:39 UTC


README

ERP core — companies, currencies, units, and the submittable-document foundation for the Laravel ERP ecosystem.

This package is the foundation of an ERPNext-native rebuild. It ships the master-data Eloquent models, migrations, enums, and the reusable "submittable document" concerns (IsSubmittable, HasNamingSeries, HasCompany) that every other erp-* package builds upon.

Features

  • Master Data Models — Companies, currencies, currency exchange rates, units of measure, UOM conversions, fiscal years, departments, designations, brands, terms & conditions, addresses, and contacts
  • Submittable Documents — ERPNext-style Draft → Submitted → Cancelled lifecycle via the IsSubmittable concern, with immutability guarantees and ledger-posting hooks
  • Naming Series — Pattern-based document identifiers (SINV-.YYYY.-) with safe, per-series incrementing counters
  • Polymorphic Addresses & Contacts — Attach addresses and contacts to any model
  • Customizable Models — Override any model via config while maintaining contract compliance (ModelResolver pattern)
  • Table Prefix — Configurable table prefix to avoid naming collisions (default: erp_)
  • Contracts & EventsPostsToLedger, SubmittableDocument, DocumentSubmitted, DocumentCancelled
  • Translations — English and Brazilian Portuguese

Compatibility

Package PHP Laravel
^1.0 ^8.2 ^11.0 | ^12.0 | ^13.0

Installation

composer require jeffersongoncalves/laravel-erp-core

Publish and run the migrations:

php artisan vendor:publish --tag="erp-core-migrations"
php artisan migrate

Publish the config (optional):

php artisan vendor:publish --tag="erp-core-config"

Submittable Documents

Add the IsSubmittable concern to any model with a docstatus column cast to DocStatus:

use Illuminate\Database\Eloquent\Model;
use JeffersonGoncalves\Erp\Core\Concerns\IsSubmittable;
use JeffersonGoncalves\Erp\Core\Contracts\SubmittableDocument;
use JeffersonGoncalves\Erp\Core\Enums\DocStatus;

class SalesInvoice extends Model implements SubmittableDocument
{
    use IsSubmittable;

    protected $casts = ['docstatus' => DocStatus::class];
}

$invoice->submit();   // Draft → Submitted, dispatches DocumentSubmitted
$invoice->cancel();   // Submitted → Cancelled, dispatches DocumentCancelled

A submitted document is immutable: any update (other than the controlled transition to cancelled) or delete throws a DomainException. If the model also implements PostsToLedger, postLedgerEntries() is called on submit and reverseLedgerEntries() on cancel.

Naming Series

use JeffersonGoncalves\Erp\Core\Concerns\HasNamingSeries;

class SalesInvoice extends Model
{
    use HasNamingSeries;

    protected function namingSeriesPattern(): ?string
    {
        return 'SINV-.YYYY.-';
    }
}

// On create with an empty `name`: SINV-2026-00001, SINV-2026-00002, ...

Database Tables

All tables use the configured prefix (default: erp_):

Table Description
erp_companies Companies (with group hierarchy)
erp_currencies Currencies
erp_currency_exchanges Currency exchange rates
erp_uoms Units of measure
erp_uom_conversions UOM conversion factors
erp_fiscal_years Fiscal years
erp_departments Departments (with hierarchy)
erp_designations Designations
erp_brands Brands
erp_terms_and_conditions Terms & conditions templates
erp_addresses Polymorphic addresses
erp_contacts Polymorphic contacts
erp_naming_series Naming-series counters

Testing

composer test

License

The MIT License (MIT). Please see License File for more information.