fix financials
Tests / PHPUnit (push) Failing after 1m21s

This commit is contained in:
root
2026-07-18 22:57:40 -04:00
parent 068e739408
commit a30c1398a1
61 changed files with 10908 additions and 1775 deletions
+11 -2
View File
@@ -16,10 +16,16 @@ class DiscountUsageModel extends Model
'voucher_id',
'invoice_id',
'discount_amount',
'requested_discount_cents',
'eligible_base_cents',
'eligible_base_before_cents',
'applied_discount_cents',
'application_order',
'school_year',
'semester',
'updated_by',
'parent_id',
'description',
'used_at'
];
@@ -50,8 +56,12 @@ class DiscountUsageModel extends Model
{
$db = \Config\Database::connect();
$amountExpression = $db->fieldExists('applied_discount_cents', 'discount_usages')
? 'COALESCE(SUM(du.applied_discount_cents),0) / 100'
: 'COALESCE(SUM(du.discount_amount),0)';
$result = $db->table('discount_usages du')
->selectSum('du.discount_amount', 'total_discount')
->select($amountExpression . ' AS total_discount', false)
->join('invoices i', 'du.invoice_id = i.id')
->where('i.parent_id', $parentId)
->where('i.school_year', $schoolYear)
@@ -62,4 +72,3 @@ class DiscountUsageModel extends Model
}
}