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.



24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
# File 'lib/cetustek/models/invoice_data.rb', line 24

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
end

Instance Attribute Details

#buyer_emailObject (readonly)

Returns the value of attribute buyer_email.



19
20
21
# File 'lib/cetustek/models/invoice_data.rb', line 19

def buyer_email
  @buyer_email
end

#buyer_identifierObject (readonly)

Returns the value of attribute buyer_identifier.



19
20
21
# File 'lib/cetustek/models/invoice_data.rb', line 19

def buyer_identifier
  @buyer_identifier
end

#buyer_nameObject (readonly)

Returns the value of attribute buyer_name.



19
20
21
# File 'lib/cetustek/models/invoice_data.rb', line 19

def buyer_name
  @buyer_name
end

#carrier_idObject (readonly)

Returns the value of attribute carrier_id.



19
20
21
# File 'lib/cetustek/models/invoice_data.rb', line 19

def carrier_id
  @carrier_id
end

#carrier_id2Object (readonly)

Returns the value of attribute carrier_id2.



19
20
21
# File 'lib/cetustek/models/invoice_data.rb', line 19

def carrier_id2
  @carrier_id2
end

#carrier_typeObject (readonly)

Returns the value of attribute carrier_type.



19
20
21
# File 'lib/cetustek/models/invoice_data.rb', line 19

def carrier_type
  @carrier_type
end

Returns the value of attribute donate_mark.



19
20
21
# File 'lib/cetustek/models/invoice_data.rb', line 19

def donate_mark
  @donate_mark
end

#invoice_typeObject (readonly)

Returns the value of attribute invoice_type.



19
20
21
# File 'lib/cetustek/models/invoice_data.rb', line 19

def invoice_type
  @invoice_type
end

#itemsObject (readonly)

Returns the value of attribute items.



19
20
21
# File 'lib/cetustek/models/invoice_data.rb', line 19

def items
  @items
end

#npo_banObject (readonly)

Returns the value of attribute npo_ban.



19
20
21
# File 'lib/cetustek/models/invoice_data.rb', line 19

def npo_ban
  @npo_ban
end

#order_dateObject (readonly)

Returns the value of attribute order_date.



19
20
21
# File 'lib/cetustek/models/invoice_data.rb', line 19

def order_date
  @order_date
end

#order_idObject (readonly)

Returns the value of attribute order_id.



19
20
21
# File 'lib/cetustek/models/invoice_data.rb', line 19

def order_id
  @order_id
end

#payment_typeObject (readonly)

Returns the value of attribute payment_type.



19
20
21
# File 'lib/cetustek/models/invoice_data.rb', line 19

def payment_type
  @payment_type
end

#tax_rateObject (readonly)

Returns the value of attribute tax_rate.



19
20
21
# File 'lib/cetustek/models/invoice_data.rb', line 19

def tax_rate
  @tax_rate
end

#tax_typeObject (readonly)

Returns the value of attribute tax_type.



19
20
21
# File 'lib/cetustek/models/invoice_data.rb', line 19

def tax_type
  @tax_type
end

Instance Method Details

#mixed_tax?Boolean

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

Returns:

  • (Boolean)


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

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