Class: Ksef::InvoiceHeader
- Inherits:
-
Object
- Object
- Ksef::InvoiceHeader
- Defined in:
- lib/ksef/invoice_header.rb
Overview
Lightweight value object describing an invoice as returned by ‘POST /invoices/query/metadata`. Built from a single element of the `invoices` array in the API response.
The object intentionally exposes a small, business-meaningful slice of the full payload. The raw hash is preserved on #raw for advanced callers.
Instance Attribute Summary collapse
-
#acquired_at ⇒ Object
readonly
Returns the value of attribute acquired_at.
-
#currency ⇒ Object
readonly
Returns the value of attribute currency.
-
#form_code ⇒ Object
readonly
Returns the value of attribute form_code.
-
#form_schema_version ⇒ Object
readonly
Returns the value of attribute form_schema_version.
-
#gross_amount ⇒ Object
readonly
Returns the value of attribute gross_amount.
-
#has_attachment ⇒ Object
readonly
Returns the value of attribute has_attachment.
-
#invoice_hash ⇒ Object
readonly
Returns the value of attribute invoice_hash.
-
#invoice_number ⇒ Object
readonly
Returns the value of attribute invoice_number.
-
#invoice_type ⇒ Object
readonly
Returns the value of attribute invoice_type.
-
#invoicing_mode ⇒ Object
readonly
Returns the value of attribute invoicing_mode.
-
#issued_on ⇒ Object
readonly
Returns the value of attribute issued_on.
-
#issuer_name ⇒ Object
readonly
Returns the value of attribute issuer_name.
-
#issuer_nip ⇒ Object
readonly
Returns the value of attribute issuer_nip.
-
#ksef_reference_number ⇒ Object
readonly
Returns the value of attribute ksef_reference_number.
-
#net_amount ⇒ Object
readonly
Returns the value of attribute net_amount.
-
#permanently_stored_at ⇒ Object
readonly
Returns the value of attribute permanently_stored_at.
-
#raw ⇒ Object
readonly
Returns the value of attribute raw.
-
#recipient_name ⇒ Object
readonly
Returns the value of attribute recipient_name.
-
#recipient_nip ⇒ Object
readonly
Returns the value of attribute recipient_nip.
-
#self_invoicing ⇒ Object
readonly
Returns the value of attribute self_invoicing.
-
#vat_amount ⇒ Object
readonly
Returns the value of attribute vat_amount.
Instance Method Summary collapse
- #has_attachment? ⇒ Boolean
-
#initialize(raw) ⇒ InvoiceHeader
constructor
A new instance of InvoiceHeader.
- #self_invoicing? ⇒ Boolean
Constructor Details
#initialize(raw) ⇒ InvoiceHeader
Returns a new instance of InvoiceHeader.
25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 |
# File 'lib/ksef/invoice_header.rb', line 25 def initialize(raw) @raw = raw @ksef_reference_number = raw["ksefNumber"] @invoice_number = raw["invoiceNumber"] @issuer_nip = raw.dig("seller", "nip") @issuer_name = raw.dig("seller", "name") @recipient_nip = raw.dig("buyer", "identifier", "value") @recipient_name = raw.dig("buyer", "name") @issued_on = parse_date(raw["issueDate"]) @acquired_at = parse_time(raw["acquisitionDate"]) @permanently_stored_at = parse_time(raw["permanentStorageDate"]) @net_amount = raw["netAmount"] @gross_amount = raw["grossAmount"] @vat_amount = raw["vatAmount"] @currency = raw["currency"] @invoicing_mode = raw["invoicingMode"] @invoice_type = raw["invoiceType"] @form_code = raw.dig("formCode", "value") @form_schema_version = raw.dig("formCode", "schemaVersion") @self_invoicing = raw["isSelfInvoicing"] @has_attachment = raw["hasAttachment"] @invoice_hash = raw["invoiceHash"] end |
Instance Attribute Details
#acquired_at ⇒ Object (readonly)
Returns the value of attribute acquired_at.
14 15 16 |
# File 'lib/ksef/invoice_header.rb', line 14 def acquired_at @acquired_at end |
#currency ⇒ Object (readonly)
Returns the value of attribute currency.
14 15 16 |
# File 'lib/ksef/invoice_header.rb', line 14 def currency @currency end |
#form_code ⇒ Object (readonly)
Returns the value of attribute form_code.
14 15 16 |
# File 'lib/ksef/invoice_header.rb', line 14 def form_code @form_code end |
#form_schema_version ⇒ Object (readonly)
Returns the value of attribute form_schema_version.
14 15 16 |
# File 'lib/ksef/invoice_header.rb', line 14 def form_schema_version @form_schema_version end |
#gross_amount ⇒ Object (readonly)
Returns the value of attribute gross_amount.
14 15 16 |
# File 'lib/ksef/invoice_header.rb', line 14 def gross_amount @gross_amount end |
#has_attachment ⇒ Object (readonly)
Returns the value of attribute has_attachment.
14 15 16 |
# File 'lib/ksef/invoice_header.rb', line 14 def @has_attachment end |
#invoice_hash ⇒ Object (readonly)
Returns the value of attribute invoice_hash.
14 15 16 |
# File 'lib/ksef/invoice_header.rb', line 14 def invoice_hash @invoice_hash end |
#invoice_number ⇒ Object (readonly)
Returns the value of attribute invoice_number.
14 15 16 |
# File 'lib/ksef/invoice_header.rb', line 14 def invoice_number @invoice_number end |
#invoice_type ⇒ Object (readonly)
Returns the value of attribute invoice_type.
14 15 16 |
# File 'lib/ksef/invoice_header.rb', line 14 def invoice_type @invoice_type end |
#invoicing_mode ⇒ Object (readonly)
Returns the value of attribute invoicing_mode.
14 15 16 |
# File 'lib/ksef/invoice_header.rb', line 14 def invoicing_mode @invoicing_mode end |
#issued_on ⇒ Object (readonly)
Returns the value of attribute issued_on.
14 15 16 |
# File 'lib/ksef/invoice_header.rb', line 14 def issued_on @issued_on end |
#issuer_name ⇒ Object (readonly)
Returns the value of attribute issuer_name.
14 15 16 |
# File 'lib/ksef/invoice_header.rb', line 14 def issuer_name @issuer_name end |
#issuer_nip ⇒ Object (readonly)
Returns the value of attribute issuer_nip.
14 15 16 |
# File 'lib/ksef/invoice_header.rb', line 14 def issuer_nip @issuer_nip end |
#ksef_reference_number ⇒ Object (readonly)
Returns the value of attribute ksef_reference_number.
14 15 16 |
# File 'lib/ksef/invoice_header.rb', line 14 def ksef_reference_number @ksef_reference_number end |
#net_amount ⇒ Object (readonly)
Returns the value of attribute net_amount.
14 15 16 |
# File 'lib/ksef/invoice_header.rb', line 14 def net_amount @net_amount end |
#permanently_stored_at ⇒ Object (readonly)
Returns the value of attribute permanently_stored_at.
14 15 16 |
# File 'lib/ksef/invoice_header.rb', line 14 def permanently_stored_at @permanently_stored_at end |
#raw ⇒ Object (readonly)
Returns the value of attribute raw.
14 15 16 |
# File 'lib/ksef/invoice_header.rb', line 14 def raw @raw end |
#recipient_name ⇒ Object (readonly)
Returns the value of attribute recipient_name.
14 15 16 |
# File 'lib/ksef/invoice_header.rb', line 14 def recipient_name @recipient_name end |
#recipient_nip ⇒ Object (readonly)
Returns the value of attribute recipient_nip.
14 15 16 |
# File 'lib/ksef/invoice_header.rb', line 14 def recipient_nip @recipient_nip end |
#self_invoicing ⇒ Object (readonly)
Returns the value of attribute self_invoicing.
14 15 16 |
# File 'lib/ksef/invoice_header.rb', line 14 def self_invoicing @self_invoicing end |
#vat_amount ⇒ Object (readonly)
Returns the value of attribute vat_amount.
14 15 16 |
# File 'lib/ksef/invoice_header.rb', line 14 def vat_amount @vat_amount end |
Instance Method Details
#has_attachment? ⇒ Boolean
53 54 55 |
# File 'lib/ksef/invoice_header.rb', line 53 def @has_attachment == true end |
#self_invoicing? ⇒ Boolean
49 50 51 |
# File 'lib/ksef/invoice_header.rb', line 49 def self_invoicing? @self_invoicing == true end |