feat: complete cash advance workflow, stock transfer capitalization ledger sync, BOQ progress engine, and PM role scoping

This commit is contained in:
Ajjj
2026-07-31 15:36:31 +08:00
parent 32c3e3af69
commit 6cafa38478
11 changed files with 511 additions and 196 deletions

View File

@@ -318,6 +318,27 @@ class MaterialTransferController extends Controller
}
}
// Financial Capitalization Ledger Sync:
// Calculate total monetary value of received items and adjust project float
$totalMonetaryValue = 0;
foreach ($materialTransfer->items as $item) {
$unitCost = $item->material->unit_cost ?? 0;
$receivedQty = $item->received_quantity ?? 0;
$totalMonetaryValue += ($receivedQty * $unitCost);
}
if ($totalMonetaryValue > 0) {
$fromProject = Project::find($materialTransfer->from_project_id);
$toProject = Project::find($materialTransfer->to_project_id);
if ($fromProject) {
$fromProject->decrement('total_capitalization', $totalMonetaryValue);
}
if ($toProject) {
$toProject->increment('total_capitalization', $totalMonetaryValue);
}
}
$materialTransfer->update([
'status' => MaterialTransferStatus::Received,
'received_by' => $request->user()->id,