Class: Cetustek::Models::InvoiceData
- Inherits:
-
Object
- Object
- Cetustek::Models::InvoiceData
- Defined in:
- lib/cetustek/models/invoice_data.rb
Overview
Request data for CreateInvoiceV3 (開立發票), spec AVM-26-03 Table 1/2. Rules the spec fixes in print are enforced here; anything needing an external lookup (捐贈碼、手機條碼是否存在) is left to the caller.
Constant Summary collapse
- DEFAULT_TAX_RATE =
0.05- DEFAULT_INVOICE_TYPE =
一般稅額電子發票
'07'- SPECIAL_INVOICE_TYPE =
特種稅額電子發票
'08'- DEFAULT_RTN_MSG =
Json 回傳才拿得到平台配發的發票日期時間;Intertemporal 回開會讓本機日期失準。
'Json'- MAX_ITEMS =
9999- TAX_TYPES =
[TaxType::TAXABLE, TaxType::ZERO_RATE, TaxType::TAX_FREE, TaxType::SPECIAL, TaxType::ZERO_RATE_CUSTOMS, TaxType::MIXED].freeze
- DONATE_MARKS =
[DonateMark::CARRIER, DonateMark::DONATE, DonateMark::PAPER].freeze
Instance Attribute Summary collapse
-
#buyer_address ⇒ Object
readonly
Returns the value of attribute buyer_address.
-
#buyer_customer_number ⇒ Object
readonly
Returns the value of attribute buyer_customer_number.
-
#buyer_email ⇒ Object
readonly
Returns the value of attribute buyer_email.
-
#buyer_facsimile ⇒ Object
readonly
Returns the value of attribute buyer_facsimile.
-
#buyer_identifier ⇒ Object
readonly
Returns the value of attribute buyer_identifier.
-
#buyer_name ⇒ Object
readonly
Returns the value of attribute buyer_name.
-
#buyer_person_in_charge ⇒ Object
readonly
Returns the value of attribute buyer_person_in_charge.
-
#buyer_telephone ⇒ Object
readonly
Returns the value of attribute buyer_telephone.
-
#carrier_id1 ⇒ Object
(also: #carrier_id)
readonly
Returns the value of attribute carrier_id1.
-
#carrier_id2 ⇒ Object
readonly
Returns the value of attribute carrier_id2.
-
#carrier_type ⇒ Object
readonly
Returns the value of attribute carrier_type.
-
#donate_mark ⇒ Object
readonly
Returns the value of attribute donate_mark.
-
#hastax ⇒ Object
readonly
Returns the value of attribute hastax.
-
#invoice_type ⇒ Object
readonly
Returns the value of attribute invoice_type.
-
#items ⇒ Object
readonly
Returns the value of attribute items.
-
#mail_send ⇒ Object
readonly
Returns the value of attribute mail_send.
-
#npo_ban ⇒ Object
readonly
Returns the value of attribute npo_ban.
-
#order_date ⇒ Object
readonly
Returns the value of attribute order_date.
-
#order_id ⇒ Object
readonly
Returns the value of attribute order_id.
-
#payment_type ⇒ Object
readonly
Returns the value of attribute payment_type.
-
#remark ⇒ Object
readonly
Returns the value of attribute remark.
-
#round_num ⇒ Object
readonly
Returns the value of attribute round_num.
-
#rtn_msg ⇒ Object
readonly
Returns the value of attribute rtn_msg.
-
#tax_rate ⇒ Object
readonly
Returns the value of attribute tax_rate.
-
#tax_type ⇒ Object
readonly
Returns the value of attribute tax_type.
-
#zero_reason ⇒ Object
readonly
Returns the value of attribute zero_reason.
Instance Method Summary collapse
-
#initialize(attributes = {}) ⇒ InvoiceData
constructor
A new instance of InvoiceData.
-
#mixed_tax? ⇒ Boolean
混合稅率發票 (限收銀機):每筆明細需標註 DType。.
-
#special_tax? ⇒ Boolean
特種稅額發票:TaxRate 必填,InvoiceType 必須為 08。.
Constructor Details
#initialize(attributes = {}) ⇒ InvoiceData
Returns a new instance of InvoiceData.
71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 |
# File 'lib/cetustek/models/invoice_data.rb', line 71 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] @buyer_address = attributes[:buyer_address] @buyer_person_in_charge = attributes[:buyer_person_in_charge] @buyer_telephone = attributes[:buyer_telephone] @buyer_facsimile = attributes[:buyer_facsimile] @buyer_customer_number = attributes[:buyer_customer_number] @donate_mark = attributes[:donate_mark] @carrier_type = attributes[:carrier_type] @carrier_id1 = attributes[:carrier_id1] || attributes[:carrier_id] # 手機條碼與自然人憑證沒有顯碼隱碼之分,兩欄填相同值。 @carrier_id2 = attributes[:carrier_id2] || @carrier_id1 @npo_ban = attributes[:npo_ban] @items = attributes[:items] || [] @payment_type = attributes[:payment_type] @tax_type = attributes[:tax_type] || TaxType::TAXABLE # 特種稅率是營業性質決定的,不能沿用 5% 預設值。 @tax_rate = attributes.fetch(:tax_rate) { special_tax? ? nil : DEFAULT_TAX_RATE } @zero_reason = attributes[:zero_reason] @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) @remark = attributes[:remark] @round_num = attributes[:round_num] @mail_send = attributes[:mail_send] @rtn_msg = attributes.fetch(:rtn_msg, DEFAULT_RTN_MSG) validate! end |
Instance Attribute Details
#buyer_address ⇒ Object (readonly)
Returns the value of attribute buyer_address.
61 62 63 |
# File 'lib/cetustek/models/invoice_data.rb', line 61 def buyer_address @buyer_address end |
#buyer_customer_number ⇒ Object (readonly)
Returns the value of attribute buyer_customer_number.
61 62 63 |
# File 'lib/cetustek/models/invoice_data.rb', line 61 def buyer_customer_number @buyer_customer_number end |
#buyer_email ⇒ Object (readonly)
Returns the value of attribute buyer_email.
61 62 63 |
# File 'lib/cetustek/models/invoice_data.rb', line 61 def buyer_email @buyer_email end |
#buyer_facsimile ⇒ Object (readonly)
Returns the value of attribute buyer_facsimile.
61 62 63 |
# File 'lib/cetustek/models/invoice_data.rb', line 61 def buyer_facsimile @buyer_facsimile end |
#buyer_identifier ⇒ Object (readonly)
Returns the value of attribute buyer_identifier.
61 62 63 |
# File 'lib/cetustek/models/invoice_data.rb', line 61 def buyer_identifier @buyer_identifier end |
#buyer_name ⇒ Object (readonly)
Returns the value of attribute buyer_name.
61 62 63 |
# File 'lib/cetustek/models/invoice_data.rb', line 61 def buyer_name @buyer_name end |
#buyer_person_in_charge ⇒ Object (readonly)
Returns the value of attribute buyer_person_in_charge.
61 62 63 |
# File 'lib/cetustek/models/invoice_data.rb', line 61 def buyer_person_in_charge @buyer_person_in_charge end |
#buyer_telephone ⇒ Object (readonly)
Returns the value of attribute buyer_telephone.
61 62 63 |
# File 'lib/cetustek/models/invoice_data.rb', line 61 def buyer_telephone @buyer_telephone end |
#carrier_id1 ⇒ Object (readonly) Also known as: carrier_id
Returns the value of attribute carrier_id1.
61 62 63 |
# File 'lib/cetustek/models/invoice_data.rb', line 61 def carrier_id1 @carrier_id1 end |
#carrier_id2 ⇒ Object (readonly)
Returns the value of attribute carrier_id2.
61 62 63 |
# File 'lib/cetustek/models/invoice_data.rb', line 61 def carrier_id2 @carrier_id2 end |
#carrier_type ⇒ Object (readonly)
Returns the value of attribute carrier_type.
61 62 63 |
# File 'lib/cetustek/models/invoice_data.rb', line 61 def carrier_type @carrier_type end |
#donate_mark ⇒ Object (readonly)
Returns the value of attribute donate_mark.
61 62 63 |
# File 'lib/cetustek/models/invoice_data.rb', line 61 def donate_mark @donate_mark end |
#hastax ⇒ Object (readonly)
Returns the value of attribute hastax.
61 62 63 |
# File 'lib/cetustek/models/invoice_data.rb', line 61 def hastax @hastax end |
#invoice_type ⇒ Object (readonly)
Returns the value of attribute invoice_type.
61 62 63 |
# File 'lib/cetustek/models/invoice_data.rb', line 61 def invoice_type @invoice_type end |
#items ⇒ Object (readonly)
Returns the value of attribute items.
61 62 63 |
# File 'lib/cetustek/models/invoice_data.rb', line 61 def items @items end |
#mail_send ⇒ Object (readonly)
Returns the value of attribute mail_send.
61 62 63 |
# File 'lib/cetustek/models/invoice_data.rb', line 61 def mail_send @mail_send end |
#npo_ban ⇒ Object (readonly)
Returns the value of attribute npo_ban.
61 62 63 |
# File 'lib/cetustek/models/invoice_data.rb', line 61 def npo_ban @npo_ban end |
#order_date ⇒ Object (readonly)
Returns the value of attribute order_date.
61 62 63 |
# File 'lib/cetustek/models/invoice_data.rb', line 61 def order_date @order_date end |
#order_id ⇒ Object (readonly)
Returns the value of attribute order_id.
61 62 63 |
# File 'lib/cetustek/models/invoice_data.rb', line 61 def order_id @order_id end |
#payment_type ⇒ Object (readonly)
Returns the value of attribute payment_type.
61 62 63 |
# File 'lib/cetustek/models/invoice_data.rb', line 61 def payment_type @payment_type end |
#remark ⇒ Object (readonly)
Returns the value of attribute remark.
61 62 63 |
# File 'lib/cetustek/models/invoice_data.rb', line 61 def remark @remark end |
#round_num ⇒ Object (readonly)
Returns the value of attribute round_num.
61 62 63 |
# File 'lib/cetustek/models/invoice_data.rb', line 61 def round_num @round_num end |
#rtn_msg ⇒ Object (readonly)
Returns the value of attribute rtn_msg.
61 62 63 |
# File 'lib/cetustek/models/invoice_data.rb', line 61 def rtn_msg @rtn_msg end |
#tax_rate ⇒ Object (readonly)
Returns the value of attribute tax_rate.
61 62 63 |
# File 'lib/cetustek/models/invoice_data.rb', line 61 def tax_rate @tax_rate end |
#tax_type ⇒ Object (readonly)
Returns the value of attribute tax_type.
61 62 63 |
# File 'lib/cetustek/models/invoice_data.rb', line 61 def tax_type @tax_type end |
#zero_reason ⇒ Object (readonly)
Returns the value of attribute zero_reason.
61 62 63 |
# File 'lib/cetustek/models/invoice_data.rb', line 61 def zero_reason @zero_reason end |