fix: populate payment_mode in organization search results by rohilsurana · Pull Request #1491 · raystack/frontier

coderabbitai[bot]

coderabbitai[bot]

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.

@rohilsurana

@rohilsurana

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.

@rohilsurana

@rohilsurana

@rohilsurana

@rohilsurana

rsbh

rsbh approved these changes Mar 31, 2026