feat: update CashTransactionType enum and improve transaction labels; refactor EmployeeAdvanceService and PayrollPeriodService for consistency

This commit is contained in:
Yoga Pangestu 2026-08-06 15:26:46 +07:00
parent 6ebcbc24c0
commit 42e04673c6
8 changed files with 50 additions and 55 deletions

View File

@ -10,16 +10,16 @@ enum CashTransactionType: string
case DEPOSIT = 'deposit';
case EXPENSE = 'expense';
case TRANSFER = 'transfer';
case WITHDRAWAL = 'withdrawal';
case EMPLOYEE_ADVANCE = 'employee_advance';
public function label(): string
{
return match ($this) {
self::DEPOSIT => 'Setoran',
self::DEPOSIT => 'Deposit',
self::EXPENSE => 'Pengeluaran',
self::TRANSFER => 'Transfer',
self::WITHDRAWAL => 'Penarikan',
self::WITHDRAWAL => 'Withdrawal',
self::EMPLOYEE_ADVANCE => 'Kasbon',
};
}
}

View File

@ -2,6 +2,7 @@
namespace App\Services\Admin\Finance;
use App\Enums\CashTransactionType;
use App\Enums\EmployeeAdvanceStatus;
use App\Models\EmployeeAdvance;
use App\Models\EmployeeAdvancePayment;
@ -97,8 +98,9 @@ public function delete(EmployeeAdvance $employeeAdvance): bool
public function approve(EmployeeAdvance $employeeAdvance): EmployeeAdvance
{
$cashTransaction = $this->debitCash(
amount: $employeeAdvance->amount,
description: 'Kasbon: '.$employeeAdvance->description,
$employeeAdvance->amount,
'Kasbon: '.$employeeAdvance->description,
CashTransactionType::EMPLOYEE_ADVANCE
);
$employeeAdvance->update([
@ -131,8 +133,9 @@ public function pay(EmployeeAdvance $employeeAdvance, int $amount): EmployeeAdva
$employeeAdvance = DB::transaction(function () use ($employeeAdvance, $amount) {
$cashTransaction = $this->creditCash(
amount: $amount,
description: 'Pembayaran kasbon: '.$employeeAdvance->description,
$amount,
'Pembayaran kasbon: '.$employeeAdvance->description,
CashTransactionType::EMPLOYEE_ADVANCE
);
EmployeeAdvancePayment::create([

View File

@ -6,7 +6,6 @@
use App\Enums\PayrollStatus;
use App\Models\Payroll;
use App\Models\PayrollPeriod;
use App\Services\Concerns\HandlesCashTransactions;
use App\Services\NotificationService;
use Illuminate\Contracts\Pagination\LengthAwarePaginator;
use Illuminate\Support\Collection;
@ -15,8 +14,6 @@
class PayrollPeriodService
{
use HandlesCashTransactions;
private function canViewAll(): bool
{
return auth()->user()->hasAnyRole(['developer', 'owner', 'direktur', 'admin-toko']);

View File

@ -77,11 +77,6 @@ export function createTransactionColumns(
<span className="font-medium">
{getTypeLabel(transaction.type)}
</span>
<span className="text-xs text-muted-foreground">
{getReferenceLabel(
transaction.reference?.type ?? '',
)}
</span>
</div>
);
},