Class: FacturX::TaxBreakdown

Inherits:
Object
  • Object
show all
Defined in:
lib/factur_x/tax_breakdown.rb

Overview

One VAT category / rate pair of the invoice (BG-23).

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(basis_amount:, calculated_amount:, category: Codes::VatCategory::STANDARD, rate: nil, exemption_reason: nil, exemption_reason_code: nil) ⇒ TaxBreakdown

Returns a new instance of TaxBreakdown.



12
13
14
15
16
17
18
19
20
21
# File 'lib/factur_x/tax_breakdown.rb', line 12

def initialize(basis_amount:, calculated_amount:,
               category: Codes::VatCategory::STANDARD, rate: nil,
               exemption_reason: nil, exemption_reason_code: nil)
  @category = category
  @rate = rate
  @basis_amount = basis_amount
  @calculated_amount = calculated_amount
  @exemption_reason = exemption_reason
  @exemption_reason_code = exemption_reason_code
end

Instance Attribute Details

#basis_amountObject (readonly)

Returns the value of attribute basis_amount.



9
10
11
# File 'lib/factur_x/tax_breakdown.rb', line 9

def basis_amount
  @basis_amount
end

#calculated_amountObject (readonly)

Returns the value of attribute calculated_amount.



9
10
11
# File 'lib/factur_x/tax_breakdown.rb', line 9

def calculated_amount
  @calculated_amount
end

#categoryObject (readonly)

Returns the value of attribute category.



9
10
11
# File 'lib/factur_x/tax_breakdown.rb', line 9

def category
  @category
end

#exemption_reasonObject (readonly)

Returns the value of attribute exemption_reason.



9
10
11
# File 'lib/factur_x/tax_breakdown.rb', line 9

def exemption_reason
  @exemption_reason
end

#exemption_reason_codeObject (readonly)

Returns the value of attribute exemption_reason_code.



9
10
11
# File 'lib/factur_x/tax_breakdown.rb', line 9

def exemption_reason_code
  @exemption_reason_code
end

#rateObject (readonly)

Returns the value of attribute rate.



9
10
11
# File 'lib/factur_x/tax_breakdown.rb', line 9

def rate
  @rate
end

Instance Method Details

#basis_amount_decimalObject



27
28
29
# File 'lib/factur_x/tax_breakdown.rb', line 27

def basis_amount_decimal
  Formatting.decimal(basis_amount)
end

#calculated_amount_decimalObject



31
32
33
# File 'lib/factur_x/tax_breakdown.rb', line 31

def calculated_amount_decimal
  Formatting.decimal(calculated_amount)
end

#rate_decimalObject



23
24
25
# File 'lib/factur_x/tax_breakdown.rb', line 23

def rate_decimal
  Formatting.decimal(rate || 0)
end

#tax_keyObject



35
36
37
# File 'lib/factur_x/tax_breakdown.rb', line 35

def tax_key
  [category, rate_decimal]
end