@extends('layouts.finance') @section('title', 'Edit Transaction') @section('subtitle', 'Edit transaction #' . $transaction->id) @section('content') @php $metadata = $transaction->metadata ?? []; $isCardTransaction = (int) $transaction->credit_card_id > 0; $isBankTransaction = (int) $transaction->bank_account_id > 0; $txKind = old('tx_kind', $metadata['tx_kind'] ?? ($transaction->type === 'income' ? 'Deposit' : 'Payment')); $txCategory = old('tx_category', $metadata['tx_category'] ?? null); $editMode = old('tx_mode', $transaction->type === 'income' ? 'credit' : 'debit'); $bankCreditCategories = ['Manual Credit', 'Factory Payout', 'Pearson Testing Services', 'Debt', 'Collectibles', 'Credit from KuickPay', 'Pending KuickPay', 'Credit from PayFast', 'Pending PayFast', 'Others']; $bankDebitCategories = ['Transferring in another linked account', 'Invoice', 'Debt', 'Factory', 'Lent', 'Expense', 'Credit Card']; $cardCreditCategories = ['Manual Amount']; $cardDebitCategories = ['Invoice', 'Debt', 'Expense', 'Zakat', 'Charity', 'Factory', 'Bank Charges', 'Others', 'Manual Charge']; $editCategoryOptionsByMode = [ 'bank' => [ 'credit' => $bankCreditCategories, 'debit' => $bankDebitCategories, ], 'card' => [ 'credit' => $cardCreditCategories, 'debit' => $cardDebitCategories, ], ]; $initialCategoryOptions = $isCardTransaction ? ($editMode === 'credit' ? $cardCreditCategories : $cardDebitCategories) : ($editMode === 'credit' ? $bankCreditCategories : $bankDebitCategories); if ($txCategory && ! in_array($txCategory, $initialCategoryOptions, true)) { $initialCategoryOptions[] = $txCategory; } $txCurrency = $transaction->bankAccount?->currency ?? $transaction->creditCard?->currency ?? $metadata['currency'] ?? 'USD'; $transferSplitCurrency = $metadata['transfer_partial_currency'] ?? $txCurrency; $txStatus = old('status', $metadata['status'] ?? 'Cleared'); $transferSplitsText = old( 'transfer_partial_amounts', collect($metadata['transfer_partial_amounts'] ?? [])->filter()->implode("\n") ); $usesTransferSplits = old( 'use_transfer_splits', collect($metadata['transfer_partial_amounts'] ?? [])->filter()->isNotEmpty() ? '1' : '0' ) === '1'; $invoiceNumbers = old('invoice_numbers', $metadata['invoice_numbers'] ?? []); $selectedExpenseCategoryId = old('expense_category_id', $metadata['expense_category_id'] ?? null); $selectedExpenseSubcategoryId = old('expense_subcategory_id', $metadata['expense_subcategory_id'] ?? null); $selectedEmployeeId = old('employee_id', $metadata['employee_id'] ?? null); $selectedDebtId = old('debt_id', $metadata['debt_id'] ?? null); $selectedCreditCardId = old('credit_card_id', $metadata['credit_card_id'] ?? null); $editAmount = old('amount', number_format((float) ($metadata['gross_amount'] ?? $transaction->amount), 2, '.', '')); $editFeeAmount = old('fee_amount', isset($metadata['fee_amount']) && $metadata['fee_amount'] !== null ? number_format((float) $metadata['fee_amount'], 2, '.', '') : ''); $editConversionRate = old('conversion_rate', isset($metadata['base_conversion_rate']) && $metadata['base_conversion_rate'] !== null ? number_format((float) $metadata['base_conversion_rate'], 4, '.', '') : ($transaction->conversion_rate !== null ? number_format((float) $transaction->conversion_rate, 4, '.', '') : '')); $allSubcategories = \App\Models\ExpenseSubcategory::query() ->orderBy('name') ->get(['id', 'expense_category_id', 'name']) ->map(fn ($subcategory) => [ 'id' => (string) $subcategory->id, 'expense_category_id' => (string) $subcategory->expense_category_id, 'name' => $subcategory->name, ]) ->all(); $accountLabel = $isCardTransaction ? trim(($transaction->creditCard->issuer ?? '-').' - '.($transaction->creditCard->card_name ?? '').' ('.$txCurrency.')') : trim(($transaction->bankAccount->name ?? '-').' - '.($transaction->bankAccount->bank_name ?? '').' ('.$txCurrency.')'); $returnUrl = $returnUrl ?? route('finance.transactions', array_filter([ 'bucket' => $transaction->bankAccount?->transactionCategoryKey() ?? 'credit-cards', 'bank_account_id' => $transaction->bank_account_id, 'credit_card_id' => $transaction->credit_card_id, ])); @endphp
Transactions
Transactions / Edit #{{ $transaction->id }}

Edit Transaction

Update the transaction details. Funding account/card and currency stay fixed.
Back
@csrf @method('PUT')
Optional fee deducted before money reaches the bank.
Clear this field to remove the fee and restore the full amount.
Enable this to record the partial amounts that make up this transaction.
Use one amount per line, comma, or space.
@foreach($unpaidInvoices as $invoice) @endforeach
Cancel
@endsection @push('styles') @endpush @push('scripts') @endpush