Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions app/Http/Controllers/CostCentreController.php
Original file line number Diff line number Diff line change
Expand Up @@ -192,9 +192,14 @@ public function transferEditor(Request $request, FinancePlanner $planner): View
$from = $data['from'] ?? null;
$categories = DB::table('finance_categories')->where('kind', 'cost')->orderBy('name')->get();

$remunerationAvailable = $planner->remunerationTransferAvailable();
$cash = $planner->cash();
foreach ($categories as $category) {
$category->balance = $cash['reserves'][$category->id] ?? 0;
}
$availableBusinessCash = $cash['available'];
$remunerationAvailable = $planner->remunerationTransferAvailable($cash);

return view('admin.cost-centre.transfer', compact('categories', 'from', 'remunerationAvailable'));
return view('admin.cost-centre.transfer', compact('categories', 'from', 'remunerationAvailable', 'availableBusinessCash'));
}

public function transfer(Request $request, FinancePlanner $planner): JsonResponse|RedirectResponse
Expand Down
5 changes: 2 additions & 3 deletions resources/views/admin/cost-centre/transfer.blade.php
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
<x-layout><x-mast title="Transfer funds" backRoute="admin.cost-centre.index" backTitle="Cost centres" /><x-container class="py-5">
<form x-data="{ source: @js(old('from_category_id', $from) ?? '') }" method="POST" action="{{ route('admin.cost-centre.transfer') }}" data-record-form>@csrf
<input type="hidden" name="token" value="{{ old('token', (string) \Illuminate\Support\Str::uuid()) }}">
<x-ui.select name="from_category_id" label="From" x-model="source"><option value="">Available business cash</option><option value="remuneration">Owner remuneration — {{ money($remunerationAvailable / 100) }} available to forgo</option>@foreach($categories as $category)<option value="{{ $category->id }}" @selected((string) old('from_category_id', $from) === (string) $category->id)>{{ $category->name }}{{ !$category->active ? ' (archived)' : '' }}</option>@endforeach</x-ui.select>
<p x-show="source === 'remuneration'" x-cloak class="mb-4 text-sm text-slate-600">You are giving up this amount from the owner remuneration fund and allocating it to the selected cost centre. The amount is recorded against your name as remuneration forgone. It will no longer be available to draw as pay. No bank payment is recorded. Availability is based on the allocated fund balance, less pending remuneration drawings; timesheet hours are not required.</p>
<x-ui.select name="category_id" label="To cost centre"><option value="">Choose a cost centre</option>@foreach($categories->where('active', true) as $category)<option value="{{ $category->id }}">{{ $category->name }}</option>@endforeach</x-ui.select>
<x-ui.select name="from_category_id" label="From" x-model="source"><option value="">Available business cash — {{ money($availableBusinessCash / 100) }}</option><option value="remuneration">Owner remuneration — {{ money($remunerationAvailable / 100) }} available to forgo</option>@foreach($categories as $category)<option value="{{ $category->id }}" @selected((string) old('from_category_id', $from) === (string) $category->id)>{{ $category->name }}{{ !$category->active ? ' (archived)' : '' }} — {{ money($category->balance / 100) }}</option>@endforeach</x-ui.select>
<x-ui.select name="category_id" label="To cost centre"><option value="">Choose a cost centre</option>@foreach($categories->where('active', true) as $category)<option value="{{ $category->id }}">{{ $category->name }} — {{ money($category->balance / 100) }}</option>@endforeach</x-ui.select>
<x-ui.input name="amount" label="Amount" type="number" step="0.01" min="0.01" required />
<x-ui.input name="reason" label="Reason" maxlength="255" required />
<p class="text-sm text-slate-600">Moves allocated funds and records a transfer. Original invoices, expenses and allocations retain their history.</p>
Expand Down