If a user has no balance, then their balance is 0

Stephen Paul Weber created

Change summary

bin/billing_monthly_cronjob | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)

Detailed changes

bin/billing_monthly_cronjob 🔗

@@ -179,8 +179,8 @@ end
 db.transaction do
 	db.exec(
 		<<-SQL
-		SELECT customer_id, plan_name, expires_at, balance
-		FROM customer_plans INNER JOIN balances USING (customer_id)
+		SELECT customer_id, plan_name, expires_at, COALESCE(balance, 0) AS balance
+		FROM customer_plans LEFT JOIN balances USING (customer_id)
 		WHERE expires_at <= NOW()
 		SQL
 	).each do |row|