Class: Cetustek::Models::InvoiceItem
- Inherits:
-
Object
- Object
- Cetustek::Models::InvoiceItem
- Defined in:
- lib/cetustek/models/invoice_data.rb
Overview
A single 明細 row, spec AVM-26-03 Table 2 (發票) / Table 16 (折讓). 品名代號、品名、數量、單價 are 必填; 單位 is not.
Constant Summary collapse
- DTYPE_MAP =
Per-item 稅別註記 (DType) used for mixed-tax invoices (TaxType == 9).
{ taxable: '', # 應稅商品 -> 空白 zero_rate: 'TZ', # 零稅率商品 tax_free: 'TN' # 免稅商品 }.freeze
- REQUIRED =
免稅商品
%i[code name quantity unit_price].freeze
Instance Attribute Summary collapse
-
#code ⇒ Object
readonly
Returns the value of attribute code.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#quantity ⇒ Object
readonly
Returns the value of attribute quantity.
-
#tax_type ⇒ Object
readonly
Returns the value of attribute tax_type.
-
#unit ⇒ Object
readonly
Returns the value of attribute unit.
-
#unit_price ⇒ Object
readonly
Returns the value of attribute unit_price.
Instance Method Summary collapse
-
#d_type ⇒ Object
Returns the DType code: '', 'TZ' or 'TN'.
-
#initialize(attributes = {}) ⇒ InvoiceItem
constructor
A new instance of InvoiceItem.
Constructor Details
#initialize(attributes = {}) ⇒ InvoiceItem
Returns a new instance of InvoiceItem.
250 251 252 253 254 255 256 257 258 |
# File 'lib/cetustek/models/invoice_data.rb', line 250 def initialize(attributes = {}) @code = attributes[:code] @name = attributes[:name] @quantity = attributes[:quantity] @unit_price = attributes[:unit_price] @unit = attributes[:unit] @tax_type = attributes[:tax_type] || :taxable validate! end |
Instance Attribute Details
#code ⇒ Object (readonly)
Returns the value of attribute code.
248 249 250 |
# File 'lib/cetustek/models/invoice_data.rb', line 248 def code @code end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
248 249 250 |
# File 'lib/cetustek/models/invoice_data.rb', line 248 def name @name end |
#quantity ⇒ Object (readonly)
Returns the value of attribute quantity.
248 249 250 |
# File 'lib/cetustek/models/invoice_data.rb', line 248 def quantity @quantity end |
#tax_type ⇒ Object (readonly)
Returns the value of attribute tax_type.
248 249 250 |
# File 'lib/cetustek/models/invoice_data.rb', line 248 def tax_type @tax_type end |
#unit ⇒ Object (readonly)
Returns the value of attribute unit.
248 249 250 |
# File 'lib/cetustek/models/invoice_data.rb', line 248 def unit @unit end |
#unit_price ⇒ Object (readonly)
Returns the value of attribute unit_price.
248 249 250 |
# File 'lib/cetustek/models/invoice_data.rb', line 248 def unit_price @unit_price end |
Instance Method Details
#d_type ⇒ Object
Returns the DType code: '', 'TZ' or 'TN'. Accepts the friendly symbols above or a raw code string.
262 263 264 |
# File 'lib/cetustek/models/invoice_data.rb', line 262 def d_type DTYPE_MAP.fetch(@tax_type) { @tax_type.to_s } end |