~singpolyma/jmp-pay

41faf764c664ce619878612a4d4aa34f44bf9567 — Stephen Paul Weber 1 year, 7 months ago 28bbd70
Bills and BTC are settled immediately
M bin/billing_monthly_cronjob => bin/billing_monthly_cronjob +2 -2
@@ 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


M bin/process_invite_rewards => bin/process_invite_rewards +2 -2
@@ 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)

M bin/process_pending_btc_transactions => bin/process_pending_btc_transactions +2 -2
@@ 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