~singpolyma/sgx-jmp

f5cf4455b8f5b486d3321e1a67f39b1f9e2c6f70 — Stephen Paul Weber 1 year, 28 days ago f238598
Tell user about bonus amount when doing credit card top up
2 files changed, 8 insertions(+), 3 deletions(-)

M lib/transaction.rb
M sgx_jmp.rb
M lib/transaction.rb => lib/transaction.rb +5 -0
@@ 70,6 70,11 @@ class Transaction
			end
	end

	def to_s
		plus = " + #{'%.4f' % bonus} bonus"
		"$#{'%.2f' % amount}#{plus if bonus.positive?}"
	end

protected

	def insert_tx

M sgx_jmp.rb => sgx_jmp.rb +3 -3
@@ 367,9 367,9 @@ command :execute?, node: "top up", sessionid: nil do |iq|
		iq = iq2 # This allows the catch to use it also
		Transaction.sale(customer, **credit_form.parse(iq2.form))
	}.then { |transaction|
		transaction.insert.then { transaction.amount }
	}.then { |amount|
		reply_with_note(iq, "$#{'%.2f' % amount} added to your account balance.")
		transaction.insert.then do
			reply_with_note(iq, "#{transaction} added to your account balance.")
		end
	}.catch_only(BuyAccountCreditForm::AmountValidationError) { |e|
		reply_with_note(iq, e.message, type: :error)
	}.catch { |e|