feat: complete cash advance workflow, stock transfer capitalization ledger sync, BOQ progress engine, and PM role scoping
This commit is contained in:
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user