Merge branch 'settled-after'

Stephen Paul Weber created

* settled-after:
  Bills and BTC are settled immediately

Change summary

bin/billing_monthly_cronjob          | 4 ++--
bin/process_invite_rewards           | 4 ++--
bin/process_pending_btc_transactions | 4 ++--
3 files changed, 6 insertions(+), 6 deletions(-)

Detailed changes

bin/billing_monthly_cronjob 🔗

@@ -97,9 +97,9 @@ class Plan
 		transaction_id = "#{customer_id}-renew-until-#{RENEW_UNTIL}"
 		db.exec_params(<<-SQL, [customer_id, transaction_id, -price])
 			INSERT INTO transactions
-				(customer_id, transaction_id, amount, note)
+				(customer_id, transaction_id, settled_after, amount, note)
 			VALUES
-				($1, $2, $3, 'Renew account plan')
+				($1, $2, LOCALTIMESTAMP, $3, 'Renew account plan')
 		SQL
 	end
 

bin/process_invite_rewards 🔗

@@ -46,9 +46,9 @@ db.transaction do
 		price = BigDecimal(plan[:monthly_price]) / 10000
 		db.exec(<<~SQL, [row["creator_id"], row["code"], price])
 			INSERT INTO transactions
-				(customer_id, transaction_id, amount, note)
+				(customer_id, transaction_id, settled_after, amount, note)
 			VALUES
-				($1, 'reward_' || $1 || '_for_' || $2, $3, 'Reward for referral ' || $2)
+				($1, 'reward_' || $1 || '_for_' || $2, LOCALTIMESTAMP, $3, 'Reward for referral ' || $2)
 		SQL
 		db.exec(<<~SQL, [row["creator_id"]])
 			INSERT INTO invites (creator_id) VALUES ($1)

bin/process_pending_btc_transactions 🔗

@@ -206,9 +206,9 @@ class Customer
 		args = [@customer_id, id, amount, note]
 		DB.exec_params(<<-SQL, args).cmd_tuples.positive?
 			INSERT INTO transactions
-				(customer_id, transaction_id, amount, note)
+				(customer_id, transaction_id, settled_after, amount, note)
 			VALUES
-					($1, $2, $3, $4)
+				($1, $2, LOCALTIMESTAMP, $3, $4)
 			ON CONFLICT (transaction_id) DO NOTHING
 		SQL
 	end