Update payment.rb

This commit is contained in:
2016-08-05 21:17:31 -04:00
committed by GitHub
parent 5a91e21d45
commit 9a28247b7f

View File

@@ -18,11 +18,25 @@ class Payment
validates :total_amount, numericality: true
def save
# TODO Save the payment
payment = Quickbooks::Model::Payment.new
payment.customer_ref = Qbo.get_base(:account).service.fetch_by_id(@customer_id)
payment.deposit_to_account_ref = Qbo.get_base(:account).service.fetch_by_id(@account_id)
payment.payment_method_ref = Qbo.get_base(:payment_method).service.fetch_by_id(@payment_id)
payment.total = @total_amount
begin
Qbo.get_base(:payment).service.update(payment)
rescue Exception => e
@errors.add(e.message)
end
end
def save!
# TODO Save! the payment
save
end
# Dummy stub to make validtions happy.