Tell user about bonus amount when doing credit card top up

Stephen Paul Weber created

Change summary

lib/transaction.rb | 5 +++++
sgx_jmp.rb         | 6 +++---
2 files changed, 8 insertions(+), 3 deletions(-)

Detailed changes

lib/transaction.rb 🔗

@@ -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

sgx_jmp.rb 🔗

@@ -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|