feat: implement core ERP modules, multi-tenant architecture, and comprehensive system workflow documentation.

This commit is contained in:
Ajjj
2026-08-05 01:18:31 +08:00
parent 1fcb468dc1
commit c03de704e2
46 changed files with 1902 additions and 387 deletions

View File

@@ -8,6 +8,8 @@ use Illuminate\Http\Request;
use Inertia\Inertia;
use Modules\ApprovalWorkflow\Models\ApprovalChain;
use Modules\ApprovalWorkflow\Services\ApprovalService;
use Modules\FinancialManagement\Models\CashAdvance;
use Modules\ProjectManagement\Models\Project;
class ApprovalController extends Controller
{
@@ -51,9 +53,28 @@ class ApprovalController extends Controller
->paginate(15)
->withQueryString();
// Cash advances intentionally use their own direct pending -> approved
// workflow. They must still appear in the approvals workspace without
// creating an ApprovalChain record.
$cashAdvanceQuery = CashAdvance::withoutGlobalScopes()
->with(['project:id,name,code', 'requester:id,name,email']);
if ($tab === 'history') {
$cashAdvanceQuery->whereIn('status', ['approved', 'rejected']);
} else {
$cashAdvanceQuery->where('status', 'pending');
}
$cashAdvanceQuery->whereIn('project_id', Project::query()->select('projects.id'));
if (! $isAdmin) {
$cashAdvanceQuery->where('requested_by', '!=', $user->id);
}
return Inertia::render('ApprovalWorkflow::Approvals/Index', [
'approvals' => $chains,
'tab' => $tab,
'cashAdvances' => $cashAdvanceQuery->latest()->get(),
]);
}
@@ -104,9 +125,16 @@ class ApprovalController extends Controller
$breakdownData = [
'document_number' => $approvalChain->approvable->document_number
?? $approvalChain->approvable->po_number
?? ($approvalChain->approvable instanceof \Modules\FinancialManagement\Models\FinancialInvoice ? $approvalChain->approvable->invoice_number : null)
?? ($approvalChain->approvable instanceof \Modules\ProjectManagement\Models\Project ? $approvalChain->approvable->code : null),
'total_cost' => $totalCost,
'total_cost' => $approvalChain->approvable instanceof \Modules\FinancialManagement\Models\FinancialInvoice
? $approvalChain->approvable->total_amount
: $totalCost,
'retention_amount' => $approvalChain->approvable instanceof \Modules\FinancialManagement\Models\FinancialInvoice
? $approvalChain->approvable->retention_amount
: null,
'notes' => $approvalChain->approvable->notes
?? ($approvalChain->approvable instanceof \Modules\FinancialManagement\Models\FinancialInvoice ? $approvalChain->approvable->notes : null)
?? ($approvalChain->approvable instanceof \Modules\ProjectManagement\Models\Project ? $approvalChain->approvable->description : null),
];
}