Align seeded transactions to approved status and add approvals menu
This commit is contained in:
@@ -5,6 +5,7 @@ namespace Database\Seeders;
|
||||
use App\Models\Asset;
|
||||
use App\Models\AssetLocation;
|
||||
use App\Models\Department;
|
||||
use App\Models\User;
|
||||
use App\Services\Asset\AssetService;
|
||||
use Illuminate\Database\Seeder;
|
||||
|
||||
@@ -12,26 +13,43 @@ class AssetTransactionSeeder extends Seeder
|
||||
{
|
||||
public function run(): void
|
||||
{
|
||||
// Pastikan seeding transaksi menghasilkan data berstatus approved (tidak menggantung di approval).
|
||||
config(['system.workflow.require_approval.movement' => false]);
|
||||
config(['system.workflow.require_approval.disposal' => false]);
|
||||
|
||||
$service = app(AssetService::class);
|
||||
$assets = Asset::take(10)->get();
|
||||
$locations = AssetLocation::take(2)->pluck('id')->toArray();
|
||||
$departments = Department::take(2)->pluck('id')->toArray();
|
||||
$approver = User::first();
|
||||
|
||||
foreach ($assets as $asset) {
|
||||
if (!empty($locations)) {
|
||||
$service->move($asset, [
|
||||
$movement = $service->move($asset, [
|
||||
'to_location_id' => $locations[array_rand($locations)],
|
||||
'to_department_id' => $departments[array_rand($departments)] ?? null,
|
||||
'notes' => 'Seed movement',
|
||||
'notes' => 'Seeder movement (approved)',
|
||||
]);
|
||||
// Pastikan status approved (jika ada default/pending)
|
||||
$movement->update([
|
||||
'status' => 'approved',
|
||||
'approved_by' => $approver?->id,
|
||||
'approved_at' => now(),
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
// Dispose satu aset untuk contoh reverse
|
||||
if ($assets->isNotEmpty()) {
|
||||
$disposal = $service->dispose($assets->first(), [
|
||||
$asset = $assets->first();
|
||||
$disposal = $service->dispose($asset, [
|
||||
'reason' => 'Rusak berat',
|
||||
'notes' => 'Sample disposal',
|
||||
'notes' => 'Sample disposal (approved)',
|
||||
]);
|
||||
$disposal->update([
|
||||
'status' => 'approved',
|
||||
'approved_by' => $approver?->id,
|
||||
'approved_at' => now(),
|
||||
]);
|
||||
$service->reverseDisposal($disposal, 'Sample reverse');
|
||||
}
|
||||
|
||||
@@ -207,6 +207,17 @@
|
||||
<span class="side-menu__label">Audit Aset</span>
|
||||
</a>
|
||||
</li>
|
||||
<li class="slide">
|
||||
<a href="{{ route('approvals.index') }}"
|
||||
class="side-menu__item {{ request()->routeIs('approvals.*') ? 'active' : '' }}">
|
||||
<svg xmlns="http://www.w3.org/2000/svg" class="side-menu__icon" viewBox="0 0 256 256">
|
||||
<rect width="256" height="256" fill="none" />
|
||||
<path d="M40,48H216a8,8,0,0,1,8,8V200a8,8,0,0,1-8,8H40a8,8,0,0,1-8-8V56A8,8,0,0,1,40,48Z" fill="none" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="16"/>
|
||||
<polyline points="88 104 128 144 168 104" fill="none" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="16"/>
|
||||
</svg>
|
||||
<span class="side-menu__label">Approval</span>
|
||||
</a>
|
||||
</li>
|
||||
|
||||
<!-- Start::slide__category -->
|
||||
<li class="slide__category"><span class="category-name">Laporan</span></li>
|
||||
|
||||
Reference in New Issue
Block a user