Class: Cetustek::Models::AllowanceData

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

Overview

Request data for CreateAllowance (開立折讓單), spec AVM-26-03 Table 15/16. Line items reuse InvoiceItem (code/name/quantity/unit/unit_price).

Constant Summary collapse

TAX_TYPES =

折讓單稅別只有應稅/零稅率/免稅,發票的 4 (特種稅率)、5 (經海關出口) 與 9 (混合) 在折讓單無效。

[TaxType::TAXABLE, TaxType::ZERO_RATE, TaxType::TAX_FREE].freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(attributes = {}) ⇒ AllowanceData

Returns a new instance of AllowanceData.



18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/cetustek/models/allowance_data.rb', line 18

def initialize(attributes = {})
  @allowance_number = attributes[:allowance_number]
  @allowance_date = attributes[:allowance_date]
  @invoice_number = attributes[:invoice_number]
  @invoice_year = attributes[:invoice_year]
  @buyer_address = attributes[:buyer_address]
  @buyer_email = attributes[:buyer_email]
  @tax_type = attributes[:tax_type] || TaxType::TAXABLE
  unless TAX_TYPES.include?(@tax_type.to_i)
    raise ArgumentError, "tax_type must be 1 (應稅), 2 (零稅率) or 3 (免稅), got #{@tax_type.inspect}"
  end

  @reason = attributes[:reason]
  @round_num = attributes[:round_num] # optional 金額計算位數
  @items = attributes[:items] || []
end

Instance Attribute Details

#allowance_dateObject (readonly)

Returns the value of attribute allowance_date.



14
15
16
# File 'lib/cetustek/models/allowance_data.rb', line 14

def allowance_date
  @allowance_date
end

#allowance_numberObject (readonly)

Returns the value of attribute allowance_number.



14
15
16
# File 'lib/cetustek/models/allowance_data.rb', line 14

def allowance_number
  @allowance_number
end

#buyer_addressObject (readonly)

Returns the value of attribute buyer_address.



14
15
16
# File 'lib/cetustek/models/allowance_data.rb', line 14

def buyer_address
  @buyer_address
end

#buyer_emailObject (readonly)

Returns the value of attribute buyer_email.



14
15
16
# File 'lib/cetustek/models/allowance_data.rb', line 14

def buyer_email
  @buyer_email
end

#invoice_numberObject (readonly)

Returns the value of attribute invoice_number.



14
15
16
# File 'lib/cetustek/models/allowance_data.rb', line 14

def invoice_number
  @invoice_number
end

#invoice_yearObject (readonly)

Returns the value of attribute invoice_year.



14
15
16
# File 'lib/cetustek/models/allowance_data.rb', line 14

def invoice_year
  @invoice_year
end

#itemsObject (readonly)

Returns the value of attribute items.



14
15
16
# File 'lib/cetustek/models/allowance_data.rb', line 14

def items
  @items
end

#reasonObject (readonly)

Returns the value of attribute reason.



14
15
16
# File 'lib/cetustek/models/allowance_data.rb', line 14

def reason
  @reason
end

#round_numObject (readonly)

Returns the value of attribute round_num.



14
15
16
# File 'lib/cetustek/models/allowance_data.rb', line 14

def round_num
  @round_num
end

#tax_typeObject (readonly)

Returns the value of attribute tax_type.



14
15
16
# File 'lib/cetustek/models/allowance_data.rb', line 14

def tax_type
  @tax_type
end