Class: Xrechnung::AllowanceCharge

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from MemberContainer

#[], #[]=, included

Constructor Details

#initialize(**kwargs) ⇒ AllowanceCharge



33
34
35
36
37
38
39
40
41
42
43
# File 'lib/xrechnung/allowance_charge.rb', line 33

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

  unless kwargs[:base_amount].is_a?(Currency) || kwargs[:base_amount].nil?
    kwargs[:base_amount] = Currency::EUR(kwargs[:base_amount])
  end

  super(**kwargs)
end

Instance Attribute Details

#allowance_charge_reasonString



15
# File 'lib/xrechnung/allowance_charge.rb', line 15

member :allowance_charge_reason, type: String

#allowance_charge_reason_codeString



11
# File 'lib/xrechnung/allowance_charge.rb', line 11

member :allowance_charge_reason_code, type: Integer

#amountXrechnung::Currency



23
# File 'lib/xrechnung/allowance_charge.rb', line 23

member :amount, type: Xrechnung::Currency

#base_amountXrechnung::Currency



27
# File 'lib/xrechnung/allowance_charge.rb', line 27

member :base_amount, type: Xrechnung::Currency, optional: true

#charge_indicatorTrueClass, FalseClass



7
# File 'lib/xrechnung/allowance_charge.rb', line 7

member :charge_indicator, type: [TrueClass, FalseClass]

#multiplier_factor_numericBigDecimal



19
# File 'lib/xrechnung/allowance_charge.rb', line 19

member :multiplier_factor_numeric, type: BigDecimal, transform_value: ->(v) { BigDecimal(v, 0) }

#tax_categoryXrechnung::TaxCategory



31
# File 'lib/xrechnung/allowance_charge.rb', line 31

member :tax_category, type: Xrechnung::TaxCategory

Instance Method Details

#to_xml(xml) ⇒ Object

noinspection RubyResolve



46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
# File 'lib/xrechnung/allowance_charge.rb', line 46

def to_xml(xml)
  xml.cac :AllowanceCharge do
    xml.cbc :ChargeIndicator, charge_indicator

    if allowance_charge_reason_code
      xml.cbc :AllowanceChargeReasonCode, allowance_charge_reason_code
    end

    if allowance_charge_reason
      xml.cbc :AllowanceChargeReason, allowance_charge_reason
    end

    if multiplier_factor_numeric
      xml.cbc :MultiplierFactorNumeric, format("%.2f", multiplier_factor_numeric)
    end

    xml.cbc :Amount, *amount.xml_args

    if base_amount
      xml.cbc :BaseAmount, *base_amount.xml_args
    end

    tax_category&.to_xml(xml)
  end
end