Class: Cetustek::Models::InvoiceItem

Inherits:
Object
  • Object
show all
Defined in:
lib/cetustek/models/invoice_data.rb

Constant Summary collapse

DTYPE_MAP =

Per-item 稅別註記 (DType) used for mixed-tax invoices (TaxType == 9).

{
  taxable: '',    # 應稅商品 -> 空白
  zero_rate: 'TZ', # 零稅率商品
  tax_free: 'TN'   # 免稅商品
}.freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(attributes = {}) ⇒ InvoiceItem

Returns a new instance of InvoiceItem.



85
86
87
88
89
90
91
92
# File 'lib/cetustek/models/invoice_data.rb', line 85

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
end

Instance Attribute Details

#codeObject (readonly)

Returns the value of attribute code.



83
84
85
# File 'lib/cetustek/models/invoice_data.rb', line 83

def code
  @code
end

#nameObject (readonly)

Returns the value of attribute name.



83
84
85
# File 'lib/cetustek/models/invoice_data.rb', line 83

def name
  @name
end

#quantityObject (readonly)

Returns the value of attribute quantity.



83
84
85
# File 'lib/cetustek/models/invoice_data.rb', line 83

def quantity
  @quantity
end

#tax_typeObject (readonly)

Returns the value of attribute tax_type.



83
84
85
# File 'lib/cetustek/models/invoice_data.rb', line 83

def tax_type
  @tax_type
end

#unitObject (readonly)

Returns the value of attribute unit.



83
84
85
# File 'lib/cetustek/models/invoice_data.rb', line 83

def unit
  @unit
end

#unit_priceObject (readonly)

Returns the value of attribute unit_price.



83
84
85
# File 'lib/cetustek/models/invoice_data.rb', line 83

def unit_price
  @unit_price
end

Instance Method Details

#d_typeObject

Returns the DType code: '', 'TZ' or 'TN'. Accepts the friendly symbols above or a raw code string.



96
97
98
# File 'lib/cetustek/models/invoice_data.rb', line 96

def d_type
  DTYPE_MAP.fetch(@tax_type) { @tax_type.to_s }
end