feat: update CashTransactionType enum and improve transaction labels; refactor EmployeeAdvanceService and PayrollPeriodService for consistency
This commit is contained in:
parent
6ebcbc24c0
commit
42e04673c6
@ -10,16 +10,16 @@ enum CashTransactionType: string
|
|||||||
|
|
||||||
case DEPOSIT = 'deposit';
|
case DEPOSIT = 'deposit';
|
||||||
case EXPENSE = 'expense';
|
case EXPENSE = 'expense';
|
||||||
case TRANSFER = 'transfer';
|
|
||||||
case WITHDRAWAL = 'withdrawal';
|
case WITHDRAWAL = 'withdrawal';
|
||||||
|
case EMPLOYEE_ADVANCE = 'employee_advance';
|
||||||
|
|
||||||
public function label(): string
|
public function label(): string
|
||||||
{
|
{
|
||||||
return match ($this) {
|
return match ($this) {
|
||||||
self::DEPOSIT => 'Setoran',
|
self::DEPOSIT => 'Deposit',
|
||||||
self::EXPENSE => 'Pengeluaran',
|
self::EXPENSE => 'Pengeluaran',
|
||||||
self::TRANSFER => 'Transfer',
|
self::WITHDRAWAL => 'Withdrawal',
|
||||||
self::WITHDRAWAL => 'Penarikan',
|
self::EMPLOYEE_ADVANCE => 'Kasbon',
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
namespace App\Services\Admin\Finance;
|
namespace App\Services\Admin\Finance;
|
||||||
|
|
||||||
|
use App\Enums\CashTransactionType;
|
||||||
use App\Enums\EmployeeAdvanceStatus;
|
use App\Enums\EmployeeAdvanceStatus;
|
||||||
use App\Models\EmployeeAdvance;
|
use App\Models\EmployeeAdvance;
|
||||||
use App\Models\EmployeeAdvancePayment;
|
use App\Models\EmployeeAdvancePayment;
|
||||||
@ -97,8 +98,9 @@ public function delete(EmployeeAdvance $employeeAdvance): bool
|
|||||||
public function approve(EmployeeAdvance $employeeAdvance): EmployeeAdvance
|
public function approve(EmployeeAdvance $employeeAdvance): EmployeeAdvance
|
||||||
{
|
{
|
||||||
$cashTransaction = $this->debitCash(
|
$cashTransaction = $this->debitCash(
|
||||||
amount: $employeeAdvance->amount,
|
$employeeAdvance->amount,
|
||||||
description: 'Kasbon: '.$employeeAdvance->description,
|
'Kasbon: '.$employeeAdvance->description,
|
||||||
|
CashTransactionType::EMPLOYEE_ADVANCE
|
||||||
);
|
);
|
||||||
|
|
||||||
$employeeAdvance->update([
|
$employeeAdvance->update([
|
||||||
@ -131,8 +133,9 @@ public function pay(EmployeeAdvance $employeeAdvance, int $amount): EmployeeAdva
|
|||||||
|
|
||||||
$employeeAdvance = DB::transaction(function () use ($employeeAdvance, $amount) {
|
$employeeAdvance = DB::transaction(function () use ($employeeAdvance, $amount) {
|
||||||
$cashTransaction = $this->creditCash(
|
$cashTransaction = $this->creditCash(
|
||||||
amount: $amount,
|
$amount,
|
||||||
description: 'Pembayaran kasbon: '.$employeeAdvance->description,
|
'Pembayaran kasbon: '.$employeeAdvance->description,
|
||||||
|
CashTransactionType::EMPLOYEE_ADVANCE
|
||||||
);
|
);
|
||||||
|
|
||||||
EmployeeAdvancePayment::create([
|
EmployeeAdvancePayment::create([
|
||||||
|
|||||||
@ -6,7 +6,6 @@
|
|||||||
use App\Enums\PayrollStatus;
|
use App\Enums\PayrollStatus;
|
||||||
use App\Models\Payroll;
|
use App\Models\Payroll;
|
||||||
use App\Models\PayrollPeriod;
|
use App\Models\PayrollPeriod;
|
||||||
use App\Services\Concerns\HandlesCashTransactions;
|
|
||||||
use App\Services\NotificationService;
|
use App\Services\NotificationService;
|
||||||
use Illuminate\Contracts\Pagination\LengthAwarePaginator;
|
use Illuminate\Contracts\Pagination\LengthAwarePaginator;
|
||||||
use Illuminate\Support\Collection;
|
use Illuminate\Support\Collection;
|
||||||
@ -15,8 +14,6 @@
|
|||||||
|
|
||||||
class PayrollPeriodService
|
class PayrollPeriodService
|
||||||
{
|
{
|
||||||
use HandlesCashTransactions;
|
|
||||||
|
|
||||||
private function canViewAll(): bool
|
private function canViewAll(): bool
|
||||||
{
|
{
|
||||||
return auth()->user()->hasAnyRole(['developer', 'owner', 'direktur', 'admin-toko']);
|
return auth()->user()->hasAnyRole(['developer', 'owner', 'direktur', 'admin-toko']);
|
||||||
|
|||||||
@ -77,11 +77,6 @@ export function createTransactionColumns(
|
|||||||
<span className="font-medium">
|
<span className="font-medium">
|
||||||
{getTypeLabel(transaction.type)}
|
{getTypeLabel(transaction.type)}
|
||||||
</span>
|
</span>
|
||||||
<span className="text-xs text-muted-foreground">
|
|
||||||
{getReferenceLabel(
|
|
||||||
transaction.reference?.type ?? '',
|
|
||||||
)}
|
|
||||||
</span>
|
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user