Class: Cetustek::Models::InvoiceData

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

Constant Summary collapse

DEFAULT_TAX_RATE =
0.05
DEFAULT_INVOICE_TYPE =

07: 一般稅額, 08: 特種稅額

'07'

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(attributes = {}) ⇒ InvoiceData

Returns a new instance of InvoiceData.



48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
# File 'lib/cetustek/models/invoice_data.rb', line 48

def initialize(attributes = {})
  @order_id = attributes[:order_id]
  @order_date = attributes[:order_date]
  @buyer_identifier = attributes[:buyer_identifier]
  @buyer_name = attributes[:buyer_name]
  @buyer_email = attributes[:buyer_email]
  @donate_mark = attributes[:donate_mark]
  @carrier_type = attributes[:carrier_type]
  @carrier_id = attributes[:carrier_id]
  @carrier_id2 = attributes[:carrier_id2]
  @npo_ban = attributes[:npo_ban]
  @items = attributes[:items] || []
  @payment_type = attributes[:payment_type]
  @tax_type = attributes[:tax_type] || TaxType::TAXABLE
  @tax_rate = attributes.fetch(:tax_rate, DEFAULT_TAX_RATE)
  @invoice_type = attributes[:invoice_type] || DEFAULT_INVOICE_TYPE
  # hastax: 0 = item prices are tax-exclusive, 1 = tax-inclusive.
  # Comes from the order (e.g. tax-free purchases), not a fixed value.
  @hastax = attributes.fetch(:hastax, 1)
end

Instance Attribute Details

#buyer_emailObject (readonly)

Returns the value of attribute buyer_email.



43
44
45
# File 'lib/cetustek/models/invoice_data.rb', line 43

def buyer_email
  @buyer_email
end

#buyer_identifierObject (readonly)

Returns the value of attribute buyer_identifier.



43
44
45
# File 'lib/cetustek/models/invoice_data.rb', line 43

def buyer_identifier
  @buyer_identifier
end

#buyer_nameObject (readonly)

Returns the value of attribute buyer_name.



43
44
45
# File 'lib/cetustek/models/invoice_data.rb', line 43

def buyer_name
  @buyer_name
end

#carrier_idObject (readonly)

Returns the value of attribute carrier_id.



43
44
45
# File 'lib/cetustek/models/invoice_data.rb', line 43

def carrier_id
  @carrier_id
end

#carrier_id2Object (readonly)

Returns the value of attribute carrier_id2.



43
44
45
# File 'lib/cetustek/models/invoice_data.rb', line 43

def carrier_id2
  @carrier_id2
end

#carrier_typeObject (readonly)

Returns the value of attribute carrier_type.



43
44
45
# File 'lib/cetustek/models/invoice_data.rb', line 43

def carrier_type
  @carrier_type
end

Returns the value of attribute donate_mark.



43
44
45
# File 'lib/cetustek/models/invoice_data.rb', line 43

def donate_mark
  @donate_mark
end

#hastaxObject (readonly)

Returns the value of attribute hastax.



43
44
45
# File 'lib/cetustek/models/invoice_data.rb', line 43

def hastax
  @hastax
end

#invoice_typeObject (readonly)

Returns the value of attribute invoice_type.



43
44
45
# File 'lib/cetustek/models/invoice_data.rb', line 43

def invoice_type
  @invoice_type
end

#itemsObject (readonly)

Returns the value of attribute items.



43
44
45
# File 'lib/cetustek/models/invoice_data.rb', line 43

def items
  @items
end

#npo_banObject (readonly)

Returns the value of attribute npo_ban.



43
44
45
# File 'lib/cetustek/models/invoice_data.rb', line 43

def npo_ban
  @npo_ban
end

#order_dateObject (readonly)

Returns the value of attribute order_date.



43
44
45
# File 'lib/cetustek/models/invoice_data.rb', line 43

def order_date
  @order_date
end

#order_idObject (readonly)

Returns the value of attribute order_id.



43
44
45
# File 'lib/cetustek/models/invoice_data.rb', line 43

def order_id
  @order_id
end

#payment_typeObject (readonly)

Returns the value of attribute payment_type.



43
44
45
# File 'lib/cetustek/models/invoice_data.rb', line 43

def payment_type
  @payment_type
end

#tax_rateObject (readonly)

Returns the value of attribute tax_rate.



43
44
45
# File 'lib/cetustek/models/invoice_data.rb', line 43

def tax_rate
  @tax_rate
end

#tax_typeObject (readonly)

Returns the value of attribute tax_type.



43
44
45
# File 'lib/cetustek/models/invoice_data.rb', line 43

def tax_type
  @tax_type
end

Instance Method Details

#mixed_tax?Boolean

混合稅率發票 (限收銀機):每筆明細需標註 DType。

Returns:

  • (Boolean)


70
71
72
# File 'lib/cetustek/models/invoice_data.rb', line 70

def mixed_tax?
  @tax_type.to_i == TaxType::MIXED
end