Class: Facturae::Invoice
- Inherits:
-
Object
- Object
- Facturae::Invoice
- Includes:
- Validatable
- Defined in:
- lib/facturae/models/invoice.rb
Overview
Represents an invoice.
Constant Summary collapse
- INVOICE_HEADER_KEYS =
%i[invoice_number invoice_series_code invoice_document_type invoice_class].freeze
- ISSUE_DATA_KEYS =
%i[issue_date language_name invoice_currency_code tax_currency_code].freeze
- TOTALS_KEYS =
%i[total_gross_amount total_gross_amount_before_taxes total_tax_outputs total_taxes_withheld invoice_total total_outstanding_amount total_executable_amount].freeze
Instance Attribute Summary collapse
-
#invoice_header ⇒ Hash
The invoice header.
-
#invoice_line ⇒ Array<Facturae::InvoiceLine>
The invoice lines.
-
#invoice_lines ⇒ Object
Returns the value of attribute invoice_lines.
-
#issue_data ⇒ Hash
The issue data.
-
#taxes_output ⇒ Array<Facturae::Tax>
The taxes output.
-
#taxes_withheld ⇒ Array<Facturae::Tax>
The taxes withheld.
-
#totals ⇒ Hash
The totals.
Instance Method Summary collapse
-
#add_invoice_line(invoice_line) ⇒ Object
rubocop:enable Metrics/ParameterLists.
-
#add_tax_output(tax) ⇒ Object
-
#add_tax_withheld(tax) ⇒ Object
-
#initialize(invoice_header: nil, issue_data: nil, totals: nil, taxes_output: nil, taxes_withheld: nil, invoice_lines: nil) ⇒ Invoice
constructor
rubocop:disable Metrics/ParameterLists.
Methods included from Validatable
Constructor Details
#initialize(invoice_header: nil, issue_data: nil, totals: nil, taxes_output: nil, taxes_withheld: nil, invoice_lines: nil) ⇒ Invoice
rubocop:disable Metrics/ParameterLists
27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 |
# File 'lib/facturae/models/invoice.rb', line 27 def initialize(invoice_header: nil, issue_data: nil, totals: nil, taxes_output: nil, taxes_withheld: nil, invoice_lines: nil) @invoice_header = invoice_header || { invoice_number: "unset", invoice_series_code: "unset", invoice_document_type: "unset", invoice_class: "unset" } @issue_data = issue_data || { issue_date: Date.today, invoice_currency_code: "unset", language_name: "unset" } @totals = totals || { total_gross_amount: 0.0, total_gross_amount_before_taxes: 0.0, total_tax_outputs: 0.0, total_taxes_withheld: 0.0, invoice_total: 0.0, total_outstanding_amount: 0.0, total_executable_amount: 0.0 } @taxes_output = taxes_output || [] @taxes_withheld = taxes_withheld || [] @invoice_lines = invoice_lines || [] end |
Instance Attribute Details
#invoice_header ⇒ Hash
The invoice header.
11 12 13 |
# File 'lib/facturae/models/invoice.rb', line 11 def invoice_header @invoice_header end |
#invoice_line ⇒ Array<Facturae::InvoiceLine>
The invoice lines.
11 12 13 |
# File 'lib/facturae/models/invoice.rb', line 11 def invoice_line @invoice_line end |
#invoice_lines ⇒ Object
Returns the value of attribute invoice_lines.
19 20 21 |
# File 'lib/facturae/models/invoice.rb', line 19 def invoice_lines @invoice_lines end |
#issue_data ⇒ Hash
The issue data.
11 12 13 |
# File 'lib/facturae/models/invoice.rb', line 11 def issue_data @issue_data end |
#taxes_output ⇒ Array<Facturae::Tax>
The taxes output.
11 12 13 |
# File 'lib/facturae/models/invoice.rb', line 11 def taxes_output @taxes_output end |
#taxes_withheld ⇒ Array<Facturae::Tax>
The taxes withheld.
11 12 13 |
# File 'lib/facturae/models/invoice.rb', line 11 def taxes_withheld @taxes_withheld end |
#totals ⇒ Hash
The totals.
11 12 13 |
# File 'lib/facturae/models/invoice.rb', line 11 def totals @totals end |
Instance Method Details
#add_invoice_line(invoice_line) ⇒ Object
rubocop:enable Metrics/ParameterLists
59 60 61 |
# File 'lib/facturae/models/invoice.rb', line 59 def add_invoice_line(invoice_line) @invoice_lines << invoice_line end |
#add_tax_output(tax) ⇒ Object
63 64 65 |
# File 'lib/facturae/models/invoice.rb', line 63 def add_tax_output(tax) @taxes_output << tax end |
#add_tax_withheld(tax) ⇒ Object
67 68 69 |
# File 'lib/facturae/models/invoice.rb', line 67 def add_tax_withheld(tax) @taxes_withheld << tax end |