diff --git a/lib/customer.rb b/lib/customer.rb index b29f74dbde0bcf0486cb50aff246f64860681d81..8ed9c6db230915bf95686c82fc0cd588f7887194 100644 --- a/lib/customer.rb +++ b/lib/customer.rb @@ -35,10 +35,16 @@ class Customer :transactions def self.extract(customer_id, jid, **kwargs) - (kwargs[:parent_customer_id] ? ChildCustomer : Customer).new( + klass, *keys = if kwargs[:parent_customer_id] + [ChildCustomer, :parent_customer_id] + else + [Customer] + end + + klass.new( customer_id, jid, plan: CustomerPlan.extract(customer_id, kwargs), - **kwargs.slice(:balance, :sgx, :tndetails) + **kwargs.slice(:balance, :sgx, :tndetails, *keys) ) end