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|