Class: FacturX::AllowanceCharge

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

Overview

A document level allowance (BG-20) or charge (BG-21).

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(amount:, charge:, basis_amount: nil, percentage: nil, reason: nil, reason_code: nil, vat_category: Codes::VatCategory::STANDARD, vat_rate: nil) ⇒ AllowanceCharge

Returns a new instance of AllowanceCharge.



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

def initialize(amount:, charge:, basis_amount: nil, percentage: nil,
               reason: nil, reason_code: nil,
               vat_category: Codes::VatCategory::STANDARD, vat_rate: nil)
  @amount = amount
  @charge = charge
  @basis_amount = basis_amount
  @percentage = percentage
  @reason = reason
  @reason_code = reason_code
  @vat_category = vat_category
  @vat_rate = vat_rate
end

Instance Attribute Details

#amountObject (readonly)

Returns the value of attribute amount.



8
9
10
# File 'lib/factur_x/allowance_charge.rb', line 8

def amount
  @amount
end

#basis_amountObject (readonly)

Returns the value of attribute basis_amount.



8
9
10
# File 'lib/factur_x/allowance_charge.rb', line 8

def basis_amount
  @basis_amount
end

#chargeObject (readonly)

Returns the value of attribute charge.



8
9
10
# File 'lib/factur_x/allowance_charge.rb', line 8

def charge
  @charge
end

#percentageObject (readonly)

Returns the value of attribute percentage.



8
9
10
# File 'lib/factur_x/allowance_charge.rb', line 8

def percentage
  @percentage
end

#reasonObject (readonly)

Returns the value of attribute reason.



8
9
10
# File 'lib/factur_x/allowance_charge.rb', line 8

def reason
  @reason
end

#reason_codeObject (readonly)

Returns the value of attribute reason_code.



8
9
10
# File 'lib/factur_x/allowance_charge.rb', line 8

def reason_code
  @reason_code
end

#vat_categoryObject (readonly)

Returns the value of attribute vat_category.



8
9
10
# File 'lib/factur_x/allowance_charge.rb', line 8

def vat_category
  @vat_category
end

#vat_rateObject (readonly)

Returns the value of attribute vat_rate.



8
9
10
# File 'lib/factur_x/allowance_charge.rb', line 8

def vat_rate
  @vat_rate
end

Class Method Details

.allowance(**attributes) ⇒ Object



24
25
26
# File 'lib/factur_x/allowance_charge.rb', line 24

def self.allowance(**attributes)
  new(charge: false, **attributes)
end

.charge(**attributes) ⇒ Object



28
29
30
# File 'lib/factur_x/allowance_charge.rb', line 28

def self.charge(**attributes)
  new(charge: true, **attributes)
end

Instance Method Details

#amount_decimalObject



36
37
38
# File 'lib/factur_x/allowance_charge.rb', line 36

def amount_decimal
  Formatting.decimal(amount)
end

#charge?Boolean

Returns:

  • (Boolean)


32
33
34
# File 'lib/factur_x/allowance_charge.rb', line 32

def charge?
  charge
end