Class: Facturae::Party

Inherits:
Object
  • Object
show all
Includes:
Validatable
Defined in:
lib/facturae/models/party.rb

Overview

Represents a party.

Constant Summary collapse

NATURAL_PERSON =
"F"
"J"
PARTY_TYPES =
[NATURAL_PERSON, LEGAL_ENTITY].freeze
TAX_RESIDENT =
"R"
TAX_NON_RESIDENT =
"E"
TAX_UE_RESIDENT =
"U"
TAX_TYPES =
[TAX_RESIDENT, TAX_NON_RESIDENT, TAX_UE_RESIDENT].freeze
NIF_PATTERN =

Spanish NIF: 8 digits + check letter

/\A\d{8}[A-Z]\z/
NIE_PATTERN =

Spanish NIE: X/Y/Z + 7 digits + check letter

/\A[XYZ]\d{7}[A-Z]\z/
CIF_PATTERN =

Spanish CIF: letter + 7 digits + control (digit or letter A-J)

/\A[ABCDEFGHJNPQRSUVW]\d{7}[0-9A-J]\z/

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Validatable

#errors, #valid?

Constructor Details

#initialize(person_type_code:, residence_type_code:, tax_id_number:, subject: Subject.new) ⇒ Party

Returns a new instance of Party.



29
30
31
32
33
34
35
36
37
# File 'lib/facturae/models/party.rb', line 29

def initialize(person_type_code:, residence_type_code:, tax_id_number:, subject: Subject.new)
  @tax_identification = {
    person_type_code: person_type_code,
    residence_type_code: residence_type_code,
    tax_id_number: tax_id_number
  }

  @subject = subject
end

Instance Attribute Details

#subjectFacturae::Subject

The subject.

Returns:



7
8
9
# File 'lib/facturae/models/party.rb', line 7

def subject
  @subject
end

#tax_idString

The tax identification number.

Returns:

  • (String)

    the current value of tax_id



7
8
9
# File 'lib/facturae/models/party.rb', line 7

def tax_id
  @tax_id
end

#tax_identificationObject

Returns the value of attribute tax_identification.



26
27
28
# File 'lib/facturae/models/party.rb', line 26

def tax_identification
  @tax_identification
end