Class: Cetustek::CreateInvoice

Inherits:
Object
  • Object
show all
Includes:
Soap
Defined in:
lib/cetustek/create_invoice.rb

Overview

2.1 CreateInvoiceV3 開立發票. Returns the issued invoice on success and raises ResultError otherwise. Persisting the result is the caller's job.

Instance Method Summary collapse

Methods included from Soap

#rentid, #soap_call, #soap_client, #soap_return, #source

Constructor Details

#initialize(invoice_data) ⇒ CreateInvoice

Returns a new instance of CreateInvoice.



13
14
15
# File 'lib/cetustek/create_invoice.rb', line 13

def initialize(invoice_data)
  @invoice_data = invoice_data
end

Instance Method Details

#executeObject



17
18
19
20
21
22
# File 'lib/cetustek/create_invoice.rb', line 17

def execute
  xml = Services::InvoiceXmlBuilder.new(@invoice_data).build
  # hastax: 0 = 明細單價未稅, 1 = 含稅; comes from the order, not a constant.
  response = soap_call(:create_invoice_v3, invoicexml: xml, hastax: @invoice_data.hastax)
  Services::ResponseHandler.new(response, @invoice_data, xml).process
end