Modified by www.SourceFiles.app
This commit is contained in:
@@ -450,12 +450,14 @@ BEGIN
|
||||
END LOOP;
|
||||
|
||||
-- Step 9: outstanding credits, oldest first, never below zero.
|
||||
-- Every column is alias-qualified: this function's RETURNS TABLE declares an
|
||||
-- `amount_cents` output, which would otherwise shadow the table's column.
|
||||
FOR cred IN
|
||||
SELECT * FROM public.student_credits
|
||||
WHERE student_id = _student AND NOT is_void
|
||||
AND amount_applied_cents < amount_cents
|
||||
AND (expires_on IS NULL OR expires_on >= _from)
|
||||
ORDER BY issued_at
|
||||
SELECT sc.* FROM public.student_credits sc
|
||||
WHERE sc.student_id = _student AND NOT sc.is_void
|
||||
AND sc.amount_applied_cents < sc.amount_cents
|
||||
AND (sc.expires_on IS NULL OR sc.expires_on >= _from)
|
||||
ORDER BY sc.issued_at
|
||||
LOOP
|
||||
EXIT WHEN running_total <= 0;
|
||||
remaining := cred.amount_cents - cred.amount_applied_cents;
|
||||
|
||||
Reference in New Issue
Block a user