Class: Xrechnung::TaxTotal
- Inherits:
-
Object
- Object
- Xrechnung::TaxTotal
show all
- Includes:
- MemberContainer
- Defined in:
- lib/xrechnung/tax_total.rb
Overview
Instance Attribute Summary collapse
Instance Method Summary
collapse
#[], #[]=, included, #initialize
Instance Attribute Details
31
|
# File 'lib/xrechnung/tax_total.rb', line 31
member :tax_amount, type: Xrechnung::Currency
|
#tax_subtotals ⇒ Array
35
|
# File 'lib/xrechnung/tax_total.rb', line 35
member :tax_subtotals, type: Array, default: []
|
Instance Method Details
#get_tax_subtotal(tax_category) ⇒ Object
51
52
53
54
55
56
57
58
59
60
|
# File 'lib/xrechnung/tax_total.rb', line 51
def get_tax_subtotal(tax_category)
element = tax_subtotals.find { _1.tax_category == tax_category }
unless element
element = Xrechnung::TaxSubtotal.new(tax_category: tax_category)
tax_subtotals << element
end
element
end
|
#to_xml(xml) ⇒ Object
38
39
40
41
42
43
44
|
# File 'lib/xrechnung/tax_total.rb', line 38
def to_xml(xml)
xml.cbc :TaxAmount, *tax_amount.xml_args
tax_subtotals.each do |tax_subtotal|
tax_subtotal&.to_xml(xml)
end
xml.target!
end
|
#update_amounts ⇒ Object
46
47
48
49
|
# File 'lib/xrechnung/tax_total.rb', line 46
def update_amounts
value = tax_subtotals.sum(&:update_amount)
self.tax_amount = Xrechnung::Currency::EUR(value)
end
|