Say what customer was affected

Stephen Paul Weber created

Change summary

lib/bill_plan_command.rb | 14 +++++++++-----
1 file changed, 9 insertions(+), 5 deletions(-)

Detailed changes

lib/bill_plan_command.rb 🔗

@@ -2,7 +2,7 @@
 
 class BillPlanCommand
 	def self.for(customer)
-		return ForUnregistered.new unless customer.registered?
+		return ForUnregistered.new(customer) unless customer.registered?
 
 		unless customer.balance > customer.monthly_price
 			return ForLowBalance.new(customer)
@@ -19,7 +19,7 @@ class BillPlanCommand
 		@customer.bill_plan(note: "Renew account plan")
 		Command.reply do |reply|
 			reply.note_type = :info
-			reply.note_text = "Customer billed"
+			reply.note_text = "#{@customer.customer_id} billed"
 		end
 	end
 
@@ -30,12 +30,12 @@ class BillPlanCommand
 
 		def call
 			LowBalance.for(@customer).then(&:notify!).then do |amount|
-				return command_for(amount).call if amount&.positive?
+				next command_for(amount).call if amount&.positive?
 
 				notify_failure
 				Command.reply do |reply|
 					reply.note_type = :error
-					reply.note_text = "Customer balance is too low"
+					reply.note_text = "#{@customer.customer_id} balance is too low"
 				end
 			end
 		end
@@ -59,10 +59,14 @@ class BillPlanCommand
 	end
 
 	class ForUnregistered
+		def initialize(customer)
+			@customer = customer
+		end
+
 		def call
 			Command.reply do |reply|
 				reply.note_type = :error
-				reply.note_text = "Customer is not registered"
+				reply.note_text = "#{@customer.customer_id} is not registered"
 			end
 		end
 	end