app/models/billing/account.rb in billing-0.0.4a vs app/models/billing/account.rb in billing-0.0.4b
- old
+ new
@@ -78,10 +78,11 @@
def paid?
has_payments? && balance.zero?
end
def build_typed_payment(attributes = {})
- payments.new(attributes.merge(type: origin.try(:payment_model) || 'Billing::PaymentWithType'))
+ payment_origin = attributes[:origin] || origins.find_by_id(attributes[:origin_id])
+ payments.new(attributes.merge(type: (payment_origin || origin).try(:payment_model) || 'Billing::PaymentWithType'))
end
def fiscalize #TODO test
extface_job = origin.fiscal_device.fiscalize(self) if fiscalizable? && origin.try(:fiscal_device)
extface_job if save