feat: updates

This commit is contained in:
JP
2024-08-15 20:11:21 +08:00
parent 52431a2c61
commit 3af7207ec3
61 changed files with 1674 additions and 480 deletions

View File

@@ -0,0 +1,23 @@
<?php
namespace App\Commands\Expenses;
use App\Models\Branch;
use App\Models\Expense;
class GenerateVoucher
{
public static function execute(Branch $branch): string
{
$year = now()->format('y');
$lastVoucher = Expense::query()->where('branch_id', $branch->id)->orderBy('created_at', 'desc')->first();
if (! $lastVoucher) {
return $year.'-'.str_pad(1, 6, '0', STR_PAD_LEFT);
}
$voucherNumber = (int) explode('-', $lastVoucher->voucher_number)[1];
return $year.'-'.str_pad($voucherNumber + 1, 6, '0', STR_PAD_LEFT);
}
}