Commit 891ae661 authored by Mahmoud Aglan's avatar Mahmoud Aglan

Fix remaining accounting column bugs from smoke test

- Views used ['code'] but query now returns ['account_code'] — fixed in
  budgets/index, daily_transactions/index, opening_entries/create
- journal_entry_lines columns are 'debit'/'credit' not 'debit_amount'/
  'credit_amount' — fixed in BudgetService, HistoricalBalance,
  OpeningEntryController, DailyTransactionService
- Column 'description' doesn't exist, use 'description_ar'
Co-Authored-By: 's avatarClaude Opus 4.6 <noreply@anthropic.com>
parent e9a2dc12
......@@ -124,11 +124,10 @@ class OpeningEntryController extends Controller
$db->insert('journal_entry_lines', [
'journal_entry_id' => $journalEntryId,
'account_id' => $line['account_id'],
'debit_amount' => $line['debit'],
'credit_amount' => $line['credit'],
'description' => $line['description'],
'debit' => $line['debit'],
'credit' => $line['credit'],
'description_ar' => $line['description'],
'created_at' => $now,
'updated_at' => $now,
]);
}
......
......@@ -31,9 +31,9 @@ class HistoricalBalance extends Model
$balances = $db->select("
SELECT
jel.account_id,
SUM(jel.debit_amount) AS debit_total,
SUM(jel.credit_amount) AS credit_total,
SUM(jel.debit_amount) - SUM(jel.credit_amount) AS closing_balance
SUM(jel.debit) AS debit_total,
SUM(jel.credit) AS credit_total,
SUM(jel.debit) - SUM(jel.credit) AS closing_balance
FROM journal_entry_lines jel
JOIN journal_entries je ON je.id = jel.journal_entry_id
WHERE je.fiscal_year_id = ? AND je.status = 'posted'
......
......@@ -51,8 +51,8 @@ class BudgetService
$actuals = $db->select("
SELECT
jel.account_id,
SUM(jel.debit_amount) AS total_debit,
SUM(jel.credit_amount) AS total_credit
SUM(jel.debit) AS total_debit,
SUM(jel.credit) AS total_credit
FROM journal_entry_lines jel
JOIN journal_entries je ON je.id = jel.journal_entry_id
WHERE je.fiscal_year_id = ?
......@@ -120,8 +120,8 @@ class BudgetService
$actuals = $db->select("
SELECT
jel.account_id,
SUM(jel.debit_amount) AS total_debit,
SUM(jel.credit_amount) AS total_credit
SUM(jel.debit) AS total_debit,
SUM(jel.credit) AS total_credit
FROM journal_entry_lines jel
JOIN journal_entries je ON je.id = jel.journal_entry_id
WHERE je.fiscal_year_id = ?
......
......@@ -42,10 +42,10 @@ class DailyTransactionService
$lines[] = [
'account_id' => $accountId,
'debit_amount' => $debit,
'credit_amount' => $credit,
'debit' => $debit,
'credit' => $credit,
'cost_center_id' => $tx['cost_center_id'] ? (int)$tx['cost_center_id'] : null,
'description' => $tx['description'] ?? 'حركة يومية مجمعة',
'description_ar' => $tx['description'] ?? 'حركة يومية مجمعة',
];
}
......@@ -87,12 +87,11 @@ class DailyTransactionService
$db->insert('journal_entry_lines', [
'journal_entry_id' => $journalEntryId,
'account_id' => $line['account_id'],
'debit_amount' => $line['debit_amount'],
'credit_amount' => $line['credit_amount'],
'debit' => $line['debit'],
'credit' => $line['credit'],
'cost_center_id' => $line['cost_center_id'],
'description' => $line['description'],
'description_ar' => $line['description_ar'],
'created_at' => $now,
'updated_at' => $now,
]);
}
......
......@@ -41,7 +41,7 @@
<select name="account_id" class="form-select" required>
<option value="">— اختر حساب —</option>
<?php foreach ($accounts as $acc): ?>
<option value="<?= (int)$acc['id'] ?>"><?= e($acc['code']) ?><?= e($acc['name_ar']) ?></option>
<option value="<?= (int)$acc['id'] ?>"><?= e($acc['account_code']) ?><?= e($acc['name_ar']) ?></option>
<?php endforeach; ?>
</select>
</div>
......@@ -103,7 +103,7 @@
$total = array_sum(array_column($periods, 'budgeted_amount'));
?>
<tr>
<td><?= $acc ? e($acc['code'] . ' — ' . $acc['name_ar']) : 'حساب #' . $accountId ?></td>
<td><?= $acc ? e($acc['account_code'] . ' — ' . $acc['name_ar']) : 'حساب #' . $accountId ?></td>
<td style="text-align:center;font-weight:600;"><?= number_format($total, 2) ?></td>
<td style="text-align:center;"><?= count($periods) ?></td>
</tr>
......
......@@ -34,7 +34,7 @@
<select name="account_id" class="form-select" required>
<option value="">— اختر —</option>
<?php foreach ($accounts as $acc): ?>
<option value="<?= (int)$acc['id'] ?>"><?= e($acc['code']) ?><?= e($acc['name_ar']) ?></option>
<option value="<?= (int)$acc['id'] ?>"><?= e($acc['account_code']) ?><?= e($acc['name_ar']) ?></option>
<?php endforeach; ?>
</select>
</div>
......@@ -126,7 +126,7 @@
?>
<tr>
<td><?= $i + 1 ?></td>
<td><?= $acc ? e($acc['code'] . ' — ' . $acc['name_ar']) : '#' . $tx['account_id'] ?></td>
<td><?= $acc ? e($acc['account_code'] . ' — ' . $acc['name_ar']) : '#' . $tx['account_id'] ?></td>
<td style="text-align:center;<?= $isDebit ? 'font-weight:600;' : 'color:#9CA3AF;' ?>"><?= $isDebit ? number_format($amount, 2) : '—' ?></td>
<td style="text-align:center;<?= !$isDebit ? 'font-weight:600;' : 'color:#9CA3AF;' ?>"><?= !$isDebit ? number_format($amount, 2) : '—' ?></td>
<td><?= $jt ? e($jt['name_ar']) : '—' ?></td>
......
......@@ -39,7 +39,7 @@
<select name="entries[0][account_id]" class="form-select" required>
<option value="">— اختر حساب —</option>
<?php foreach ($accounts as $acc): ?>
<option value="<?= (int)$acc['id'] ?>"><?= e($acc['code']) ?><?= e($acc['name_ar']) ?></option>
<option value="<?= (int)$acc['id'] ?>"><?= e($acc['account_code']) ?><?= e($acc['name_ar']) ?></option>
<?php endforeach; ?>
</select>
</td>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment