Differentiate Billing from Wallet with storage usage breakdown.
Deploy Ladill Transfer / deploy (push) Successful in 27s

Billing lists per-transfer storage costs and monthly estimates; Wallet stays focused on balance and top-up.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
isaacclad
2026-06-08 10:43:56 +00:00
co-authored by Cursor
parent c0c95c4bc8
commit 45ccd04163
6 changed files with 184 additions and 7 deletions
@@ -4,6 +4,7 @@ namespace App\Http\Controllers\Qr;
use App\Http\Controllers\Controller;
use App\Models\QrSetting;
use App\Models\Transfer;
use App\Services\Billing\BillingClient;
use Illuminate\Http\RedirectResponse;
use Illuminate\Http\Request;
@@ -49,10 +50,30 @@ class AccountController extends Controller
$user = ladill_account();
[$balanceMinor, $ledger] = $this->billingSnapshot($user?->public_id);
$activeTransfers = Transfer::query()
->where('user_id', $user->id)
->where('status', Transfer::STATUS_ACTIVE)
->where(function ($query) {
$query->whereNull('expires_at')->orWhere('expires_at', '>', now());
})
->orderByDesc('storage_bytes')
->get();
$storageBytes = (int) $activeTransfers->sum('storage_bytes');
$storageGb = round($storageBytes / (1024 * 1024 * 1024), 2);
$pricePerGb = (float) config('transfer.price_per_gb_month', 1.0);
$monthlyTotalGhs = round($activeTransfers->sum(fn (Transfer $transfer) => $transfer->monthlyCostGhs()), 2);
return view('qr.account.billing', [
'balanceMinor' => $balanceMinor,
'spentMinor' => (int) ($ledger['spent_minor'] ?? 0),
'creditedMinor' => (int) ($ledger['credited_minor'] ?? 0),
'activeTransfers' => $activeTransfers,
'storageBytes' => $storageBytes,
'storageGb' => $storageGb,
'pricePerGb' => $pricePerGb,
'monthlyTotalGhs' => $monthlyTotalGhs,
'walletUrl' => route('account.wallet'),
'topupUrl' => $this->topupUrl(),
]);
}