~singpolyma/sgx-jmp

6a7c0e90d57d7dc1b6f5e0776ff90dd723012b94 — Stephen Paul Weber 2 years ago dc2c141
Allow an in-transaction condition for billing
1 files changed, 4 insertions(+), 1 deletions(-)

M lib/customer_plan.rb
M lib/customer_plan.rb => lib/customer_plan.rb +4 -1
@@ 71,9 71,12 @@ class CustomerPlan

	def bill_plan(note: nil)
		EM.promise_fiber do
			DB.transaction do
			DB.transaction do |db|
				next false unless !block_given? || yield(db)

				charge_for_plan(note)
				add_one_month_to_current_plan unless activate_plan_starting_now
				true
			end
		end
	end