fix: populate payment_mode in organization search results by rohilsurana · Pull Request #1491 · raystack/frontier
Compute payment_mode as a derived column in the org billing search query based on billing_customers.provider_id: orgs without a billing provider are "prepaid", orgs with one are "postpaid". The field was defined in proto and wired through all layers but never selected in the SQL query, so it always returned empty.
Postpaid if billing_customers.credit_min is defined and positive (customer has a credit limit), prepaid otherwise.
Add a GENERATED ALWAYS STORED column on billing_customers that derives payment_mode from credit_min (negative = postpaid, else prepaid). The query now reads the column directly instead of computing it inline.
rsbh approved these changes Mar 31, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters