From 41faf764c664ce619878612a4d4aa34f44bf9567 Mon Sep 17 00:00:00 2001 From: Stephen Paul Weber Date: Mon, 11 Apr 2022 13:15:49 -0500 Subject: [PATCH] Bills and BTC are settled immediately --- bin/billing_monthly_cronjob | 4 ++-- bin/process_invite_rewards | 4 ++-- bin/process_pending_btc_transactions | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/bin/billing_monthly_cronjob b/bin/billing_monthly_cronjob index 13ecf56..ab6aeeb 100755 --- a/bin/billing_monthly_cronjob +++ b/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 diff --git a/bin/process_invite_rewards b/bin/process_invite_rewards index c8bceaf..b255504 100755 --- a/bin/process_invite_rewards +++ b/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) diff --git a/bin/process_pending_btc_transactions b/bin/process_pending_btc_transactions index b560f5f..30a4525 100755 --- a/bin/process_pending_btc_transactions +++ b/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 -- 2.38.4