dgtlinf / payslip
Generate professional PDF payslips using salary data from dgtlinf/salary-calculator.
Installs: 0
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 0
Forks: 0
Open Issues: 0
Language:Blade
pkg:composer/dgtlinf/payslip
Requires
- php: ^8.2
- barryvdh/laravel-dompdf: ^3.1
- dgtlinf/salary-calculator: ^1.0.31
- illuminate/support: ^10.0|^11.0|^12.0
- spatie/laravel-package-tools: ^1.92
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.