Commit e9a2dc12 authored by Mahmoud Aglan's avatar Mahmoud Aglan

Fix 9 smoke test errors: wrong column names and missing views

- chart_of_accounts uses 'account_code' not 'code' — fixed in
  BudgetController, DailyTransactionController, OpeningEntryController,
  BudgetService
- academy_levels uses 'level_order' not 'sort_order' — fixed in
  EnrollWizardController, PlayerController
- Created 4 missing views: daily_cash, settlements/form,
  documentary_credits/form, guarantees/form
Co-Authored-By: 's avatarClaude Opus 4.6 <noreply@anthropic.com>
parent afb0d96f
......@@ -23,10 +23,10 @@ class BudgetController extends Controller
$selectedYearId = (int)($request->get('fiscal_year_id') ?? ($currentYear['id'] ?? 0));
$accounts = $db->select("
SELECT id, code, name_ar, account_type, is_header
SELECT id, account_code, name_ar, account_type, is_header
FROM chart_of_accounts
WHERE is_archived = 0 AND is_header = 0
ORDER BY code
ORDER BY account_code
");
$budgets = [];
......
......@@ -21,7 +21,7 @@ class DailyTransactionController extends Controller
$transactions = DailyTransaction::getByDate($date);
$db = App::getInstance()->db();
$accounts = $db->select("SELECT id, code, name_ar FROM chart_of_accounts WHERE is_archived = 0 AND is_header = 0 ORDER BY code");
$accounts = $db->select("SELECT id, account_code, name_ar FROM chart_of_accounts WHERE is_archived = 0 AND is_header = 0 ORDER BY account_code");
$journalTypes = JournalType::getActive();
$costCenters = $db->select("SELECT id, code, name_ar FROM cost_centers WHERE is_active = 1 ORDER BY code");
......
......@@ -22,11 +22,11 @@ class OpeningEntryController extends Controller
$historicalBalances = [];
if ($selectedYearId) {
$historicalBalances = $db->select("
SELECT hb.*, coa.code AS account_code, coa.name_ar AS account_name
SELECT hb.*, coa.account_code, coa.name_ar AS account_name
FROM historical_balances hb
JOIN chart_of_accounts coa ON coa.id = hb.account_id
WHERE hb.fiscal_year_id = ?
ORDER BY coa.code
ORDER BY coa.account_code
", [$selectedYearId]);
}
......@@ -43,7 +43,7 @@ class OpeningEntryController extends Controller
$db = App::getInstance()->db();
$fiscalYears = $db->select("SELECT id, name_ar, start_date, end_date, status FROM fiscal_years WHERE is_archived = 0 AND status = 'open' ORDER BY start_date DESC");
$accounts = $db->select("SELECT id, code, name_ar, account_type FROM chart_of_accounts WHERE is_archived = 0 AND is_header = 0 ORDER BY code");
$accounts = $db->select("SELECT id, account_code, name_ar, account_type FROM chart_of_accounts WHERE is_archived = 0 AND is_header = 0 ORDER BY account_code");
return $this->view('Accounting/Views/opening_entries/create', [
'fiscalYears' => $fiscalYears,
......
......@@ -23,7 +23,7 @@ class BudgetService
$budgets = $db->select("
SELECT
ab.account_id,
coa.code AS account_code,
coa.account_code AS account_code,
coa.name_ar AS account_name,
coa.account_type,
SUM(ab.budgeted_amount) AS total_budget
......@@ -31,8 +31,8 @@ class BudgetService
JOIN chart_of_accounts coa ON coa.id = ab.account_id
WHERE ab.fiscal_year_id = ?
{$periodFilter}
GROUP BY ab.account_id, coa.code, coa.name_ar, coa.account_type
ORDER BY coa.code
GROUP BY ab.account_id, coa.account_code, coa.name_ar, coa.account_type
ORDER BY coa.account_code
", $params);
$fy = $db->selectOne("SELECT start_date, end_date FROM fiscal_years WHERE id = ?", [$fiscalYearId]);
......@@ -106,15 +106,15 @@ class BudgetService
$budgets = $db->select("
SELECT
ccb.account_id,
coa.code AS account_code,
coa.account_code AS account_code,
coa.name_ar AS account_name,
coa.account_type,
SUM(ccb.budgeted_amount) AS total_budget
FROM cost_center_budgets ccb
LEFT JOIN chart_of_accounts coa ON coa.id = ccb.account_id
WHERE ccb.fiscal_year_id = ? AND ccb.cost_center_id = ?
GROUP BY ccb.account_id, coa.code, coa.name_ar, coa.account_type
ORDER BY coa.code
GROUP BY ccb.account_id, coa.account_code, coa.name_ar, coa.account_type
ORDER BY coa.account_code
", [$fiscalYearId, $costCenterId]);
$actuals = $db->select("
......
<?php $__template->layout('Layout.main'); ?>
<?php $__template->section('title'); ?><?= $credit ? 'تعديل اعتماد مستندي' : 'اعتماد مستندي جديد' ?><?php $__template->endSection(); ?>
<?php $__template->section('content'); ?>
<div class="card">
<div class="card-header"><h3 style="margin:0;font-size:16px;"><?= $credit ? 'تعديل اعتماد مستندي' : 'إنشاء اعتماد مستندي' ?></h3></div>
<div style="padding:20px;">
<form method="POST" action="<?= $credit ? '/accounting/documentary-credits/' . (int)$credit['id'] : '/accounting/documentary-credits' ?>">
<?= csrf_field() ?>
<div style="display:grid;grid-template-columns:1fr 1fr;gap:15px;margin-bottom:15px;">
<div>
<label class="form-label">رقم الاعتماد</label>
<input type="text" name="credit_number" value="<?= e($credit['credit_number'] ?? '') ?>" class="form-control" required>
</div>
<div>
<label class="form-label">تاريخ الفتح</label>
<input type="date" name="opening_date" value="<?= e($credit['opening_date'] ?? date('Y-m-d')) ?>" class="form-control" required>
</div>
</div>
<div style="display:grid;grid-template-columns:1fr 1fr;gap:15px;margin-bottom:15px;">
<div>
<label class="form-label">المورد</label>
<select name="supplier_id" class="form-select" required>
<option value="">— اختر مورد —</option>
<?php foreach ($suppliers as $s): ?>
<option value="<?= (int)$s['id'] ?>" <?= ((int)($credit['supplier_id'] ?? 0)) === (int)$s['id'] ? 'selected' : '' ?>><?= e($s['name_ar']) ?></option>
<?php endforeach; ?>
</select>
</div>
<div>
<label class="form-label">البنك</label>
<select name="bank_account_id" class="form-select" required>
<option value="">— اختر بنك —</option>
<?php foreach ($bankAccounts as $ba): ?>
<option value="<?= (int)$ba['id'] ?>" <?= ((int)($credit['bank_account_id'] ?? 0)) === (int)$ba['id'] ? 'selected' : '' ?>><?= e($ba['account_name_ar']) ?></option>
<?php endforeach; ?>
</select>
</div>
</div>
<div style="display:grid;grid-template-columns:1fr 1fr 1fr;gap:15px;margin-bottom:15px;">
<div>
<label class="form-label">المبلغ</label>
<input type="number" name="amount" step="0.01" value="<?= e($credit['amount'] ?? '') ?>" class="form-control" required>
</div>
<div>
<label class="form-label">العملة</label>
<input type="text" name="currency" value="<?= e($credit['currency'] ?? 'EGP') ?>" class="form-control">
</div>
<div>
<label class="form-label">تاريخ الانتهاء</label>
<input type="date" name="expiry_date" value="<?= e($credit['expiry_date'] ?? '') ?>" class="form-control">
</div>
</div>
<div style="margin-bottom:15px;">
<label class="form-label">الوصف</label>
<textarea name="description" class="form-control" rows="3"><?= e($credit['description'] ?? '') ?></textarea>
</div>
<div style="display:flex;gap:10px;">
<button type="submit" class="btn btn-primary">حفظ</button>
<a href="/accounting/documentary-credits" class="btn btn-outline">إلغاء</a>
</div>
</form>
</div>
</div>
<?php $__template->endSection(); ?>
<?php $__template->layout('Layout.main'); ?>
<?php $__template->section('title'); ?><?= $guarantee ? 'تعديل خطاب ضمان' : 'خطاب ضمان جديد' ?><?php $__template->endSection(); ?>
<?php $__template->section('content'); ?>
<div class="card">
<div class="card-header"><h3 style="margin:0;font-size:16px;"><?= $guarantee ? 'تعديل خطاب ضمان' : 'إنشاء خطاب ضمان' ?></h3></div>
<div style="padding:20px;">
<form method="POST" action="<?= $guarantee ? '/accounting/guarantees/' . (int)$guarantee['id'] : '/accounting/guarantees' ?>">
<?= csrf_field() ?>
<div style="display:grid;grid-template-columns:1fr 1fr;gap:15px;margin-bottom:15px;">
<div>
<label class="form-label">رقم خطاب الضمان</label>
<input type="text" name="guarantee_number" value="<?= e($guarantee['guarantee_number'] ?? '') ?>" class="form-control" required>
</div>
<div>
<label class="form-label">نوع الضمان</label>
<select name="guarantee_type" class="form-select" required>
<option value="">— اختر —</option>
<option value="initial" <?= ($guarantee['guarantee_type'] ?? '') === 'initial' ? 'selected' : '' ?>>ابتدائي</option>
<option value="final" <?= ($guarantee['guarantee_type'] ?? '') === 'final' ? 'selected' : '' ?>>نهائي</option>
<option value="advance" <?= ($guarantee['guarantee_type'] ?? '') === 'advance' ? 'selected' : '' ?>>دفعة مقدمة</option>
<option value="maintenance" <?= ($guarantee['guarantee_type'] ?? '') === 'maintenance' ? 'selected' : '' ?>>صيانة</option>
</select>
</div>
</div>
<div style="display:grid;grid-template-columns:1fr 1fr;gap:15px;margin-bottom:15px;">
<div>
<label class="form-label">البنك</label>
<select name="bank_account_id" class="form-select" required>
<option value="">— اختر بنك —</option>
<?php foreach ($bankAccounts as $ba): ?>
<option value="<?= (int)$ba['id'] ?>" <?= ((int)($guarantee['bank_account_id'] ?? 0)) === (int)$ba['id'] ? 'selected' : '' ?>><?= e($ba['account_name_ar']) ?></option>
<?php endforeach; ?>
</select>
</div>
<div>
<label class="form-label">الجهة المستفيدة</label>
<input type="text" name="beneficiary" value="<?= e($guarantee['beneficiary'] ?? '') ?>" class="form-control" required>
</div>
</div>
<div style="display:grid;grid-template-columns:1fr 1fr 1fr;gap:15px;margin-bottom:15px;">
<div>
<label class="form-label">المبلغ</label>
<input type="number" name="amount" step="0.01" value="<?= e($guarantee['amount'] ?? '') ?>" class="form-control" required>
</div>
<div>
<label class="form-label">تاريخ الإصدار</label>
<input type="date" name="issue_date" value="<?= e($guarantee['issue_date'] ?? date('Y-m-d')) ?>" class="form-control" required>
</div>
<div>
<label class="form-label">تاريخ الانتهاء</label>
<input type="date" name="expiry_date" value="<?= e($guarantee['expiry_date'] ?? '') ?>" class="form-control" required>
</div>
</div>
<div style="margin-bottom:15px;">
<label class="form-label">ملاحظات</label>
<textarea name="notes" class="form-control" rows="3"><?= e($guarantee['notes'] ?? '') ?></textarea>
</div>
<div style="display:flex;gap:10px;">
<button type="submit" class="btn btn-primary">حفظ</button>
<a href="/accounting/guarantees" class="btn btn-outline">إلغاء</a>
</div>
</form>
</div>
</div>
<?php $__template->endSection(); ?>
<?php $__template->layout('Layout.main'); ?>
<?php $__template->section('title'); ?>تسوية جديدة<?php $__template->endSection(); ?>
<?php $__template->section('content'); ?>
<div class="card">
<div class="card-header"><h3 style="margin:0;font-size:16px;">إنشاء تسوية</h3></div>
<div style="padding:20px;">
<form method="POST" action="/accounting/settlements">
<?= csrf_field() ?>
<div style="display:grid;grid-template-columns:1fr 1fr;gap:15px;margin-bottom:15px;">
<div>
<label class="form-label">نوع التسوية</label>
<select name="settlement_type" class="form-select" required>
<option value="">— اختر —</option>
<option value="supplier">تسوية مورد</option>
<option value="member">تسوية عضو</option>
<option value="other">أخرى</option>
</select>
</div>
<div>
<label class="form-label">التاريخ</label>
<input type="date" name="settlement_date" value="<?= date('Y-m-d') ?>" class="form-control" required>
</div>
</div>
<div style="display:grid;grid-template-columns:1fr 1fr;gap:15px;margin-bottom:15px;">
<div>
<label class="form-label">المورد</label>
<select name="supplier_id" class="form-select">
<option value="">— اختياري —</option>
<?php foreach ($suppliers as $s): ?>
<option value="<?= (int)$s['id'] ?>"><?= e($s['name_ar']) ?></option>
<?php endforeach; ?>
</select>
</div>
<div>
<label class="form-label">الحساب البنكي</label>
<select name="bank_account_id" class="form-select">
<option value="">— اختياري —</option>
<?php foreach ($bankAccounts as $ba): ?>
<option value="<?= (int)$ba['id'] ?>"><?= e($ba['account_name_ar']) ?></option>
<?php endforeach; ?>
</select>
</div>
</div>
<div style="display:grid;grid-template-columns:1fr 1fr;gap:15px;margin-bottom:15px;">
<div>
<label class="form-label">المبلغ</label>
<input type="number" name="amount" step="0.01" class="form-control" required>
</div>
<div>
<label class="form-label">المرجع</label>
<input type="text" name="reference" class="form-control" placeholder="رقم الشيك / الحوالة">
</div>
</div>
<div style="margin-bottom:15px;">
<label class="form-label">ملاحظات</label>
<textarea name="notes" class="form-control" rows="3"></textarea>
</div>
<div style="display:flex;gap:10px;">
<button type="submit" class="btn btn-primary">حفظ التسوية</button>
<a href="/accounting/settlements" class="btn btn-outline">إلغاء</a>
</div>
</form>
</div>
</div>
<?php $__template->endSection(); ?>
<?php $__template->layout('Layout.main'); ?>
<?php $__template->section('title'); ?>حركة الخزينة اليومية<?php $__template->endSection(); ?>
<?php $__template->section('content'); ?>
<div class="card" style="margin-bottom:15px;">
<div style="padding:15px 20px;">
<form method="GET" action="/accounting/statements/daily-cash" style="display:flex;gap:10px;align-items:end;">
<div>
<label class="form-label" style="font-size:12px;">التاريخ</label>
<input type="date" name="date" value="<?= e($date) ?>" class="form-control">
</div>
<button type="submit" class="btn btn-primary">عرض</button>
</form>
</div>
</div>
<div class="card">
<div class="card-header"><h3 style="margin:0;font-size:16px;">حركات <?= e($date) ?></h3></div>
<div class="table-responsive">
<table class="table">
<thead>
<tr>
<th>الحساب البنكي / الخزينة</th>
<th>وارد</th>
<th>صادر</th>
<th>الرصيد</th>
<th>ملاحظات</th>
</tr>
</thead>
<tbody>
<?php if (empty($movements)): ?>
<tr><td colspan="5" style="text-align:center;color:#6B7280;">لا توجد حركات في هذا التاريخ</td></tr>
<?php else: ?>
<?php foreach ($movements as $m): ?>
<tr>
<td><?= e($m['description'] ?? '—') ?></td>
<td style="color:#059669;"><?= number_format((float)($m['cash_in'] ?? 0), 2) ?></td>
<td style="color:#DC2626;"><?= number_format((float)($m['cash_out'] ?? 0), 2) ?></td>
<td style="font-weight:600;"><?= number_format((float)($m['balance'] ?? 0), 2) ?></td>
<td style="font-size:12px;color:#6B7280;"><?= e($m['notes'] ?? '') ?></td>
</tr>
<?php endforeach; ?>
<?php endif; ?>
</tbody>
</table>
</div>
</div>
<?php $__template->endSection(); ?>
......@@ -23,7 +23,7 @@ class EnrollWizardController extends Controller
FROM academy_levels al
JOIN academies a ON a.id = al.academy_id
WHERE a.is_active = 1
ORDER BY a.discipline_id, al.sort_order ASC"
ORDER BY a.discipline_id, al.level_order ASC"
);
$groupTypes = [
......@@ -92,12 +92,12 @@ class EnrollWizardController extends Controller
}
$levels = $db->select(
"SELECT al.id, al.name_ar, al.sort_order
"SELECT al.id, al.name_ar, al.level_order
FROM academy_levels al
JOIN academies a ON a.id = al.academy_id
WHERE a.discipline_id = ? AND a.is_active = 1
GROUP BY al.name_ar
ORDER BY al.sort_order ASC",
ORDER BY al.level_order ASC",
[$disciplineId]
);
......
......@@ -643,7 +643,7 @@ class PlayerController extends Controller
FROM academy_levels al
JOIN academies a ON a.id = al.academy_id
WHERE a.is_active = 1
ORDER BY al.sort_order, al.name_ar"
ORDER BY al.level_order, al.name_ar"
);
$schedules = $db->select(
......
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