Class: FacturX::Party

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

Overview

A seller, buyer, payee or ship-to party.

French identifiers are first-class: siret becomes the party GlobalID (scheme 0009), siren the legal organization ID (scheme 0002), and routing_id the electronic address (scheme 0225) used to route the invoice through the PPF, defaulting to the SIRET.

legal_information is BT-33, the seller's additional legal information: legal form, share capital, RCS registration, and any other statement the printed invoice must carry. A party holds a single postal address, so this is also where a registered office that differs from the invoicing establishment belongs.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name:, address: nil, contact: nil, trading_name: nil, legal_information: nil, siret: nil, siren: nil, vat_number: nil, tax_id: nil, global_id: nil, global_id_scheme: nil, legal_id: nil, legal_id_scheme: nil, routing_id: :derive_from_siret, routing_id_scheme: nil) ⇒ Party

Returns a new instance of Party.



23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
# File 'lib/factur_x/party.rb', line 23

def initialize(name:, address: nil, contact: nil, trading_name: nil,
               legal_information: nil,
               siret: nil, siren: nil, vat_number: nil, tax_id: nil,
               global_id: nil, global_id_scheme: nil,
               legal_id: nil, legal_id_scheme: nil,
               routing_id: :derive_from_siret, routing_id_scheme: nil)
  @name = name
  @trading_name = trading_name
  @legal_information = legal_information
  @address = address
  @contact = contact
  @siret = siret
  @siren = siren
  @vat_number = vat_number
  @tax_id = tax_id

  @global_id = global_id || siret
  @global_id_scheme = global_id_scheme || (Codes::Scheme::SIRET if @global_id && siret)

  @legal_id = legal_id || siren
  @legal_id_scheme = legal_id_scheme || (Codes::Scheme::SIREN if @legal_id && siren)

  @routing_id = routing_id == :derive_from_siret ? siret : routing_id
  @routing_id_scheme = routing_id_scheme || (Codes::Scheme::ROUTING_SIRET if @routing_id)
end

Instance Attribute Details

#addressObject (readonly)

Returns the value of attribute address.



19
20
21
# File 'lib/factur_x/party.rb', line 19

def address
  @address
end

#contactObject (readonly)

Returns the value of attribute contact.



19
20
21
# File 'lib/factur_x/party.rb', line 19

def contact
  @contact
end

#global_idObject (readonly)

Returns the value of attribute global_id.



19
20
21
# File 'lib/factur_x/party.rb', line 19

def global_id
  @global_id
end

#global_id_schemeObject (readonly)

Returns the value of attribute global_id_scheme.



19
20
21
# File 'lib/factur_x/party.rb', line 19

def global_id_scheme
  @global_id_scheme
end

Returns the value of attribute legal_id.



19
20
21
# File 'lib/factur_x/party.rb', line 19

def legal_id
  @legal_id
end

Returns the value of attribute legal_id_scheme.



19
20
21
# File 'lib/factur_x/party.rb', line 19

def legal_id_scheme
  @legal_id_scheme
end

Returns the value of attribute legal_information.



19
20
21
# File 'lib/factur_x/party.rb', line 19

def legal_information
  @legal_information
end

#nameObject (readonly)

Returns the value of attribute name.



19
20
21
# File 'lib/factur_x/party.rb', line 19

def name
  @name
end

#routing_idObject (readonly)

Returns the value of attribute routing_id.



19
20
21
# File 'lib/factur_x/party.rb', line 19

def routing_id
  @routing_id
end

#routing_id_schemeObject (readonly)

Returns the value of attribute routing_id_scheme.



19
20
21
# File 'lib/factur_x/party.rb', line 19

def routing_id_scheme
  @routing_id_scheme
end

#sirenObject (readonly)

Returns the value of attribute siren.



19
20
21
# File 'lib/factur_x/party.rb', line 19

def siren
  @siren
end

#siretObject (readonly)

Returns the value of attribute siret.



19
20
21
# File 'lib/factur_x/party.rb', line 19

def siret
  @siret
end

#tax_idObject (readonly)

Returns the value of attribute tax_id.



19
20
21
# File 'lib/factur_x/party.rb', line 19

def tax_id
  @tax_id
end

#trading_nameObject (readonly)

Returns the value of attribute trading_name.



19
20
21
# File 'lib/factur_x/party.rb', line 19

def trading_name
  @trading_name
end

#vat_numberObject (readonly)

Returns the value of attribute vat_number.



19
20
21
# File 'lib/factur_x/party.rb', line 19

def vat_number
  @vat_number
end

Instance Method Details

#contact?Boolean

Returns:

  • (Boolean)


49
50
51
# File 'lib/factur_x/party.rb', line 49

def contact?
  !contact.nil? && !contact.empty?
end

#tax_registrationsObject



53
54
55
56
57
58
# File 'lib/factur_x/party.rb', line 53

def tax_registrations
  registrations = []
  registrations << [vat_number, Codes::Scheme::VAT] if vat_number
  registrations << [tax_id, Codes::Scheme::FISCAL] if tax_id
  registrations
end