class Stripe2QB::Converters::RefundToRefundReceipt
Attributes
refund[R]
refund_receipt[R]
Public Class Methods
new(refund, configuration)
click to toggle source
Calls superclass method
Stripe2QB::Converters::Base::new
# File lib/stripe2qb/converters/refund_to_refund_receipt.rb, line 7 def initialize(refund, configuration) super(configuration) @refund = refund @refund_receipt = build_refund_receipt end
Public Instance Methods
create!()
click to toggle source
# File lib/stripe2qb/converters/refund_to_refund_receipt.rb, line 28 def create! raise "RefundReceipt for #{refund.id} already exists: #{find.id}" if exists? quickbooks_api.refund_receipt_service.create(refund_receipt) end
delete!()
click to toggle source
# File lib/stripe2qb/converters/refund_to_refund_receipt.rb, line 34 def delete! return false unless exists? result = quickbooks_api.refund_receipt_service.delete(find) @found = nil result end
find()
click to toggle source
# File lib/stripe2qb/converters/refund_to_refund_receipt.rb, line 14 def find return @found if @found # Quickbooks doesn't have payment_ref_number on RefundReceipts, so we # have to search for a match on private_note... # first narrow down results by txn_date refund_receipts = quickbooks_api.refund_receipt_service.find_by(:txn_date, format_date(refund.created)) refund_receipts.each do |refund_receipt| return @found = refund_receipt if refund_receipt.private_note =~ /#{refund.id}/ end nil end
Private Instance Methods
build_refund_receipt()
click to toggle source
# File lib/stripe2qb/converters/refund_to_refund_receipt.rb, line 45 def build_refund_receipt refund_receipt = Quickbooks::Model::RefundReceipt.new refund_receipt.customer_id = quickbooks_api.receipt_customer.id refund_receipt.payment_method_id = quickbooks_api.receipt_payment_method.id refund_receipt.deposit_to_account_id = quickbooks_api.receipt_account.id refund_receipt.txn_date = format_date(refund.created) refund_receipt.private_note = "Imported by Stripe2QB: #{refund.id}" refund_receipt.auto_doc_number! line_item = Quickbooks::Model::Line.new line_item.amount = amount = format_amount(-1 * refund.amount) # convert to positive number for RefundReceipt line_item.description = refund.description line_item.sales_item! do |detail| detail.quantity = 1 detail.unit_price = amount detail.item_id = quickbooks_api.receipt_item.id end refund_receipt.line_items << line_item refund_receipt end