Class: Cetustek::QueryInvoiceNumberByOrderId

Inherits:
Object
  • Object
show all
Extended by:
Soap
Defined in:
lib/cetustek/queries.rb

Overview

2.6 QueryInvoiceNumberbyOrderid 以訂單編號查詢發票號碼

Constant Summary collapse

FORMAT =

發票號碼格式,字軌 2 碼大寫字母+8 碼數字 (Table 9). Anything else that isn't the "nodata" sentinel is a bare result code, not a number.

/\A[A-Z]{2}\d{8}\z/

Class Method Summary collapse

Methods included from Soap

rentid, soap_call, soap_client, soap_return, source

Class Method Details

.find(order_id) ⇒ Object

Same query, returning just the bare invoice number string, or nil for an empty response or the documented "nodata". A response that isn't either shape is a result code, raised as ResultError like the other Query* classes — it used to be returned as if it were the number.



67
68
69
70
71
72
73
# File 'lib/cetustek/queries.rb', line 67

def self.find(order_id)
  body = soap_return(query(order_id), :query_invoice_number_by_orderid).to_s.strip
  return nil if body.empty? || body == 'nodata'
  return body if body.match?(FORMAT)

  ResultCode.raise!(body, ResultCode::COMMON)
end

.query(order_id) ⇒ Object



59
60
61
# File 'lib/cetustek/queries.rb', line 59

def self.query(order_id)
  soap_call(:query_invoice_number_by_orderid, orderid: order_id)
end