Class: Xrechnung::InvoiceLine

Inherits:
Object
  • Object
show all
Includes:
MemberContainer
Defined in:
lib/xrechnung/invoice_line.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from MemberContainer

#[], #[]=, included

Constructor Details

#initialize(**kwargs) ⇒ InvoiceLine

Returns a new instance of InvoiceLine.



35
36
37
38
39
40
# File 'lib/xrechnung/invoice_line.rb', line 35

def initialize(**kwargs)
  unless kwargs[:line_extension_amount].is_a?(Currency)
    kwargs[:line_extension_amount] = Currency::EUR(kwargs[:line_extension_amount])
  end
  super(**kwargs)
end

Instance Attribute Details

#allowance_chargesArray<Xrechnung::AllowanceCharge>

Returns:



33
# File 'lib/xrechnung/invoice_line.rb', line 33

member :allowance_charges, type: Array, default: []

#idInteger

Returns:

  • (Integer)


9
# File 'lib/xrechnung/invoice_line.rb', line 9

member :id, type: Integer

#invoice_periodXrechnung::InvoicePeriod



21
# File 'lib/xrechnung/invoice_line.rb', line 21

member :invoice_period, type: Xrechnung::InvoicePeriod, optional: true

#invoiced_quantityXrechnung::Quantity

Returns:



13
# File 'lib/xrechnung/invoice_line.rb', line 13

member :invoiced_quantity, type: Xrechnung::Quantity

#itemXrechnung::Item

Returns:



25
# File 'lib/xrechnung/invoice_line.rb', line 25

member :item, type: Xrechnung::Item

#line_extension_amountXrechnung::Currency

Returns:



17
# File 'lib/xrechnung/invoice_line.rb', line 17

member :line_extension_amount, type: Xrechnung::Currency

#priceXrechnung::Price

Returns:



29
# File 'lib/xrechnung/invoice_line.rb', line 29

member :price, type: Xrechnung::Price

Instance Method Details

#to_xml(xml) ⇒ Object

noinspection RubyResolve



43
44
45
46
47
48
49
50
51
52
53
54
55
56
# File 'lib/xrechnung/invoice_line.rb', line 43

def to_xml(xml)
  xml.cac :InvoiceLine do
    xml.cbc :ID, id
    xml.cbc :InvoicedQuantity, invoiced_quantity.amount_to_s, unitCode: invoiced_quantity.unit_code
    xml.cbc :LineExtensionAmount, *line_extension_amount.xml_args

    invoice_period&.to_xml(xml) unless self.class.members[:invoice_period].optional && invoice_period.nil?
    allowance_charges.each do |allowance_charge|
      allowance_charge.to_xml(xml)
    end
    item&.to_xml(xml)
    price&.to_xml(xml)
  end
end