dgtlinf/payslip
最新稳定版本:v1.0.0
Composer 安装命令:
composer require dgtlinf/payslip
包简介
Generate professional PDF payslips using salary data from dgtlinf/salary-calculator.
README 文档
README
Professional Laravel package for generating multilingual PDF payslips.
Built on top of dgtlinf/salary-calculator, this package provides an elegant way to render, stream, or download payslips directly from salary calculator data arrays.
🚀 Features
- 🇷🇸 Country-specific providers (currently: Serbia)
- 🧾 PDF generation via barryvdh/laravel-dompdf
- 🌍 Multilingual templates (English & Serbian)
- ⚙️ Stream, download, or preview as HTML
- 🧩 Simple integration with
dgtlinf/salary-calculator - 🎨 Easily extendable with custom providers and templates
📦 Installation
composer require dgtlinf/payslip
This will also install dependencies like dgtlinf/salary-calculator and barryvdh/laravel-dompdf.
🧩 Configuration
Publish the configuration and templates if you want to customize them:
php artisan vendor:publish --provider="Dgtlinf\Payslip\PayslipServiceProvider"
This will publish:
config/payslip.php- Blade templates under
resources/views/vendor/payslip/ - Translations under
lang/vendor/payslip/
⚙️ Usage Example
A typical usage example integrating with dgtlinf/salary-calculator:
use Dgtlinf\SalaryCalculator\Facades\SalaryCalculator; use Dgtlinf\Payslip\Facades\Payslip; $months = [ ['date' => '2025-01-01', 'gross' => 420000], ['date' => '2025-02-01', 'gross' => 410000], ['date' => '2025-03-01', 'gross' => 435000], ]; $rate = \Dgtlinf\SalaryCalculator\Facades\AverageHourlyRate::calculate($months, 'RS'); $employee = new \Dgtlinf\SalaryCalculator\Models\EmployeeProfile( firstName: 'Milan', lastName: 'Jovanović', address: 'Kralja Petra 10, Beograd', idNumber: '0101990123456', bankAccount: '160-123456789-01', position: 'Software Engineer', ); $employer = new \Dgtlinf\SalaryCalculator\Models\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 \Dgtlinf\SalaryCalculator\Models\SalaryContext( 2025, 9, 'RS', vacationDays: 0, sickDays: 0, sickLeaveFullPay: false, yearsInService: 8, avgHourlyRateLast12Months: null, employee: $employee, employer: $employer ); // Create a calculator instance $calc = SalaryCalculator::for($context); // Generate a payslip from net salary $result = $calc->fromNet(80000); // Render as HTML (useful for previews) return Payslip::for($result)->toHtml(); // Or download as PDF return Payslip::for($result)->download(); // Or stream directly to browser return Payslip::for($result)->locale('en')->setPaymentDate(now())->stream();
⚙️ Config Overview
config/payslip.php
return [ 'default_country' => 'RS', 'providers' => [ 'RS' => \Dgtlinf\Payslip\Providers\RS\RSPayslipProvider::class, ], 'default_template' => 'default', 'filename_format' => '{slug}_{year}_{month}_payslip.pdf', ];
🧩 How It Works
- Payslip::for($salaryData) — accepts a salary result array from
SalaryCalculator - locale('en'|'sr') — sets the output language
- setPaymentDate(Carbon $date) — defines the payment date shown on the slip
- toHtml() / download() / stream() — output options
All salary data is taken directly from the SalaryCalculator array — no additional DTOs or models are required.
🧠 Extending
To add a new country provider, extend the BasePayslipProvider class and register it in the config:
'providers' => [ 'DE' => \App\Payslip\Providers\GermanyPayslipProvider::class, ]
Then place your template under:
resources/views/vendor/payslip/DE/default.blade.php
and translations under:
lang/vendor/payslip/de/{locale}/payslip.php
📂 Directory Structure
src/
├── PayslipServiceProvider.php
├── PayslipGenerator.php
├── Facades/Payslip.php
├── Providers/
│ ├── BasePayslipProvider.php
│ └── RS/RSPayslipProvider.php
└── resources/
├── views/RS/default.blade.php
└── lang/rs/{en,sr}/payslip.php
🏷 License
This package is open-sourced under the MIT License.
🧑💻 Author
Digital Infinity d.o.o. Novi Sad
Bulevar Kralja Petra I 89, 21000 Novi Sad, Serbia
www.digitalinfinity.rs
© 2025 Digital Infinity. All rights reserved.
统计信息
- 总下载量: 5
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 4
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2025-10-06