PHPackages                             dgtlinf/salary-calculator - 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. dgtlinf/salary-calculator

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

dgtlinf/salary-calculator
=========================

Multi-country salary calculator for Laravel, with modular country providers

v1.0.31(7mo ago)071MITPHPPHP ^8.2CI passing

Since Oct 5Pushed 7mo agoCompare

[ Source](https://github.com/dgtlinf/salary-calculator)[ Packagist](https://packagist.org/packages/dgtlinf/salary-calculator)[ RSS](/packages/dgtlinf-salary-calculator/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (5)Dependencies (6)Versions (6)Used By (1)

Salary Calculator for Laravel
=============================

[](#salary-calculator-for-laravel)

[![Latest Version on Packagist](https://camo.githubusercontent.com/429c602eb93aff820fe5fcd30787fcf0a31f4979aea5642bb847e19042ae08c1/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6467746c696e662f73616c6172792d63616c63756c61746f722e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/dgtlinf/salary-calculator)[![GitHub Tests Action Status](https://github.com/dgtlinf/salary-calculator/actions/workflows/run-tests.yml/badge.svg)](https://github.com/dgtlinf/salary-calculator/actions/workflows/run-tests.yml)[![License](https://camo.githubusercontent.com/17108ccd34f9897d2d3ae8914dc6b8a0a8c4b2e38b42dccc82f317bddecf954d/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6c6963656e73652f6467746c696e662f73616c6172792d63616c63756c61746f722e7376673f7374796c653d666c61742d737175617265)](https://github.com/dgtlinf/salary-calculator/blob/main/LICENSE.md)

A modern, extensible Laravel package for standardized salary calculations across multiple countries.
Supports detailed breakdowns for gross, net, contributions, and total employer costs — starting with Serbia (RS).

---

📦 Installation
--------------

[](#-installation)

Install the package via Composer:

```
composer require dgtlinf/salary-calculator
```

---

⚙️ Usage Example
----------------

[](#️-usage-example)

```
use Dgtlinf\SalaryCalculator\Facades\SalaryCalculator;
use Dgtlinf\SalaryCalculator\Models\{
    SalaryContext,
    EmployeeProfile,
    EmployerProfile
};

$employee = new EmployeeProfile(
    firstName: 'Milan',
    lastName: 'Jovanović',
    address: 'Kralja Petra 10, Beograd',
    idNumber: '0101990123456',
    bankAccount: '160-123456789-01',
    position: 'Software Engineer'
);

$employer = new EmployerProfile(
    name: 'Digital Infinity DOO',
    taxId: '110217311',
    registrationNumber: '21318507',
    address: 'Bulevar Kralja Petra I 89, Novi Sad',
    bankName: 'Raiffeisen Bank',
    bankAccount: '265-0001234567890-00'
);

$context = new SalaryContext(
    2025,
    9,
    'RS',
    vacationDays: 0,
    sickDays: 0,
    sickLeaveFullPay: false,
    yearsInService: 2,
    avgHourlyRateLast12Months: null,
    employee: $employee,
    employer: $employer
);

// Create the calculator
$calc = SalaryCalculator::for($context);

// Run calculation from gross
$result = $calc->fromGross(790729.64);

// Optionally validate output structure before use
$calc->validateOutput($result);

return response()->json($result);
```

---

📊 Example JSON Response
-----------------------

[](#-example-json-response)

```
{
  "salary": {
    "gross": {
      "items": {
        "regular_work": { "units": 176, "unit": "_hours", "per_unit": 4441.04, "basis": 1, "amount": 781623.59 },
        "seniority_allowance": { "units": 176, "unit": "_hours", "per_unit": 4441.04, "basis": 0.008, "amount": 6252.99 },
        "meal_allowance": { "units": 22, "unit": "_days", "per_unit": 64.84, "basis": 1, "amount": 1426.53 }
      },
      "total": 790729.64
    },
    "contributions_base": 656425,
    "income_tax": { "base": 762306.64, "amount": 76230.66 },
    "employee_contributions": { "total": 130628.58 },
    "net_salary": 583870.4,
    "employer_contributions": { "total": 99448.39 },
    "total_salary_cost": 890178.03
  },
  "context": { "employee": { "firstName": "Milan" }, "employer": { "name": "Digital Infinity DOO" }, "country": "RS" },
  "tax_table": { "year": 2025, "tax_rate": 0.1, "currency_code": "RSD" }
}
```

---

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

[](#️-configuration)

The package publishes a config file `config/salary-calculator.php` allowing full control over:

- Country providers and validators
- Default rounding precision
- Validation behavior and output structure
- Optional external tax table directory

```
php artisan vendor:publish --tag="salary-calculator-config"
```

---

🧩 Validation Behavior
---------------------

[](#-validation-behavior)

`SalaryCalculator::validateOutput($result)` uses the config-defined validators to ensure data structure integrity.

Behavior can be customized in `config/salary-calculator.php`:

OptionDescription`strict_validation`Throw exception if validator missing`fallback_to_base_validator`Use BaseOutputValidator if no country-specific validator`include_context_in_output`Whether to include the `context` block in output---

🧪 Testing
---------

[](#-testing)

```
composer test
```

---

🧱 Architecture Overview
-----------------------

[](#-architecture-overview)

- **SalaryCalculatorManager** — Resolves and loads the correct provider based on country and year.
- **Country Providers** — Contain tax rules and salary logic for each country (e.g., `RSCountryProvider`).
- **Output Validators** — Verify structure of salary data before use (Payslip integration-ready).
- **Tax Tables** — Organized per country and year under `/SalaryProviders/{Country}/TaxTables/{Year}.php`.
- **Traits** — Shared helpers such as `RoundingTrait` for precision and numeric consistency.

---

🧾 Changelog
-----------

[](#-changelog)

All notable changes are automatically documented in [CHANGELOG.md](CHANGELOG.md).
Changelog updates automatically on each GitHub release.

---

🪪 License
---------

[](#-license)

The MIT License (MIT).
See [LICENSE.md](LICENSE.md) for more information.

---

👤 Author
--------

[](#-author)

**Digital Infinity DOO**
Bulevar Kralja Petra I 89, Novi Sad, Serbia
[www.digitalinfinity.rs](https://www.digitalinfinity.rs)

###  Health Score

34

—

LowBetter than 77% of packages

Maintenance64

Regular maintenance activity

Popularity4

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity52

Maturing project, gaining track record

 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 ~0 days

Total

5

Last Release

218d ago

### Community

Maintainers

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

---

Top Contributors

[![gorankrgovic](https://avatars.githubusercontent.com/u/12137730?v=4)](https://github.com/gorankrgovic "gorankrgovic (6 commits)")

---

Tags

laravelcalculatornettaxpayrollserbiasalarygrosseor

###  Code Quality

TestsPest

### Embed Badge

![Health badge](/badges/dgtlinf-salary-calculator/health.svg)

```
[![Health](https://phpackages.com/badges/dgtlinf-salary-calculator/health.svg)](https://phpackages.com/packages/dgtlinf-salary-calculator)
```

###  Alternatives

[spatie/laravel-livewire-wizard

Build wizards using Livewire

4061.0M4](/packages/spatie-laravel-livewire-wizard)[nativephp/mobile

NativePHP for Mobile

82724.0k43](/packages/nativephp-mobile)[tonysm/importmap-laravel

Use ESM with importmap to manage modern JavaScript in Laravel without transpiling or bundling.

148399.8k1](/packages/tonysm-importmap-laravel)[bezhansalleh/filament-google-analytics

Google Analytics integration for FilamentPHP

205144.8k5](/packages/bezhansalleh-filament-google-analytics)[laracraft-tech/laravel-useful-additions

A collection of useful Laravel additions!

58109.4k](/packages/laracraft-tech-laravel-useful-additions)[glhd/hooks

1726.6k](/packages/glhd-hooks)

PHPackages © 2026

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