承接 dgtlinf/salary-calculator 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

dgtlinf/salary-calculator

Composer 安装命令:

composer require dgtlinf/salary-calculator

包简介

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

README 文档

README

Latest Version on Packagist GitHub Tests Action Status License

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

Install the package via Composer:

composer require dgtlinf/salary-calculator

⚙️ 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

{
  "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

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

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

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

Option Description
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

composer test

🧱 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

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

🪪 License

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

👤 Author

Digital Infinity DOO
Bulevar Kralja Petra I 89, Novi Sad, Serbia
www.digitalinfinity.rs

dgtlinf/salary-calculator 适用场景与选型建议

dgtlinf/salary-calculator 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 7 次下载、GitHub Stars 达 0, 最近一次更新时间为 2025 年 10 月 05 日, 在 PHP 生态内属于活跃度较高的组件。

它主要适用于以下技术方向: 「net」 「tax」 「laravel」 「calculator」 「payroll」 「salary」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。

我们在过去多个企业项目中使用过 dgtlinf/salary-calculator 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 dgtlinf/salary-calculator 我们能提供哪些服务?
定制开发 / 二次开发

基于 dgtlinf/salary-calculator 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

  • 总下载量: 7
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 29
  • 依赖项目数: 1
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 0
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2025-10-05