Class: Cetustek::QueryAllowance
- Inherits:
-
Object
- Object
- Cetustek::QueryAllowance
- Extended by:
- Soap
- Defined in:
- lib/cetustek/queries.rb
Overview
2.11 QueryAllowance 查詢折讓資料
Constant Summary collapse
- FIELDS =
Spec AVM-26-03 Table 20. Note the query response uses ProductCode and InvoiceDate, unlike CreateAllowance's ProductionCode and InvoiceYear.
%w[AllowanceNumber AllowanceDate InvoiceNumber InvoiceDate BuyerIdentifier BuyerName BuyerAddress Reason AllowanceStatus BackStatus SaleAmount TaxAmount].freeze
- DETAIL_FIELDS =
%w[SequenceNumber ProductCode Description Quantity Unit UnitPrice Amount Tax TaxType].freeze
Class Method Summary collapse
-
.find(allowance_number) ⇒ Object
Same query, with the returned XML parsed into a Hash of snake_case keys plus a :details array.
- .parse(xml) ⇒ Object
- .query(allowance_number) ⇒ Object
Methods included from Soap
rentid, soap_call, soap_client, soap_return, source
Class Method Details
.find(allowance_number) ⇒ Object
Same query, with the returned XML parsed into a Hash of snake_case keys plus a :details array. Values are the raw strings from the XML; returns nil when the platform answers with nothing at all.
95 96 97 |
# File 'lib/cetustek/queries.rb', line 95 def self.find(allowance_number) parse(soap_return(query(allowance_number), :query_allowance)) end |
.parse(xml) ⇒ Object
99 100 101 102 103 104 105 106 |
# File 'lib/cetustek/queries.rb', line 99 def self.parse(xml) root = Xml.parse_response(xml) return nil unless root data = Xml.parse_fields(root, FIELDS) data[:details] = root.locate('Details/ProductItem').map { |item| Xml.parse_fields(item, DETAIL_FIELDS) } data end |
.query(allowance_number) ⇒ Object
88 89 90 |
# File 'lib/cetustek/queries.rb', line 88 def self.query(allowance_number) soap_call(:query_allowance, allowancenumber: allowance_number) end |