PHP code example of tourze / salary-manage-bundle

1. Go to this page and download the library: Download tourze/salary-manage-bundle library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

tourze / salary-manage-bundle example snippets


// config/bundles.php
return [
    // ...
    Tourze\SalaryManageBundle\SalaryManageBundle::class => ['all' => true],
];

use Tourze\SalaryManageBundle\Service\SalaryCalculatorService;
use Tourze\SalaryManageBundle\Entity\Employee;
use Tourze\SalaryManageBundle\Entity\PayrollPeriod;

// Get the salary calculator service
$calculator = $container->get(SalaryCalculatorService::class);

// Create employee and payroll period
$employee = new Employee();
$employee->setEmployeeNumber('EMP001');
$employee->setName('John Doe');
$employee->setBaseSalary('5000.00');

$period = new PayrollPeriod();
$period->setStartDate(new DateTime('2024-01-01'));
$period->setEndDate(new DateTime('2024-01-31'));

// Calculate salary
$calculation = $calculator->calculate($employee, $period);

// Get calculation results
$grossSalary = $calculation->getGrossSalary();
$netSalary = $calculation->getNetSalary();
$totalDeductions = $calculation->getTotalDeductions();

use Tourze\SalaryManageBundle\Service\TaxCalculatorService;

$taxCalculator = $container->get(TaxCalculatorService::class);

$taxResult = $taxCalculator->calculateTax($employee, $grossSalary);

$incomeTax = $taxResult->getIncomeTax();
$socialInsuranceTax = $taxResult->getSocialInsuranceTax();
$totalTax = $taxResult->getTotalTax();

use Tourze\SalaryManageBundle\Service\SocialInsuranceCalculatorService;

$insuranceCalculator = $container->get(SocialInsuranceCalculatorService::class);

$insuranceResult = $insuranceCalculator->calculate($employee, $grossSalary);

$pensionInsurance = $insuranceResult->getPensionInsurance();
$medicalInsurance = $insuranceResult->getMedicalInsurance();
$unemploymentInsurance = $insuranceResult->getUnemploymentInsurance();

use Tourze\SalaryManageBundle\Service\ReportGeneratorService;

$reportGenerator = $container->get(ReportGeneratorService::class);

// Generate monthly salary report
$report = $reportGenerator->generateReport([
    'type' => 'monthly_salary',
    'period' => $period,
    'department' => 'IT'
]);

// Export to Excel
$excelFile = $reportGenerator->exportToExcel($report, 'salary_report.xlsx');

use Tourze\SalaryManageBundle\Service\DataImportExportService;

$dataService = $container->get(DataImportExportService::class);

// Import employee data from CSV
$result = $dataService->importEmployees('employees.csv', [
    'employee_number' => 0,
    'name' => 1,
    'department' => 2,
    'base_salary' => 3
]);

// config/packages/easy_admin.yaml
easy_admin:
    entities:
        - Tourze\SalaryManageBundle\Entity\Employee
        - Tourze\SalaryManageBundle\Entity\SalaryCalculation
        - Tourze\SalaryManageBundle\Entity\PayrollPeriod

use Tourze\SalaryManageBundle\Interface\ExternalSystemInterface;

class CustomERPSystem implements ExternalSystemInterface
{
    public function syncEmployeeData(Employee $employee): bool
    {
        // Sync employee data to external ERP system
        return true;
    }

    public function getAttendanceData(Employee $employee, \DateTime $startDate, \DateTime $endDate): array
    {
        // Get attendance data from external system
        return [];
    }
}
bash
# Run all tests
php vendor/bin/phpunit

# Run specific test suites
php vendor/bin/phpunit tests/Service/
php vendor/bin/phpunit tests/Entity/
php vendor/bin/phpunit tests/Exception/