Class: ACube::Schema::Header::Supplier

Inherits:
Object
  • Object
show all
Defined in:
lib/acube/schema/header/supplier.rb

Constant Summary collapse

FISCAL_REGIMES =
%w[RF01 RF02 RF03 RF04 RF05 RF06 RF07 RF08 RF09 RF10 RF11 RF12 RF13 RF14 RF15 RF16 RF17 RF18 RF19].freeze

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#addressObject

Returns the value of attribute address.



12
13
14
# File 'lib/acube/schema/header/supplier.rb', line 12

def address
  @address
end

#albo_professionalObject

Returns the value of attribute albo_professional.



10
11
12
# File 'lib/acube/schema/header/supplier.rb', line 10

def albo_professional
  @albo_professional
end

#albo_subscriptionObject

Returns the value of attribute albo_subscription.



10
11
12
# File 'lib/acube/schema/header/supplier.rb', line 10

def albo_subscription
  @albo_subscription
end

#albo_subscription_dateObject

Returns the value of attribute albo_subscription_date.



10
11
12
# File 'lib/acube/schema/header/supplier.rb', line 10

def albo_subscription_date
  @albo_subscription_date
end

#aldo_provinceObject

Returns the value of attribute aldo_province.



10
11
12
# File 'lib/acube/schema/header/supplier.rb', line 10

def aldo_province
  @aldo_province
end

#cityObject

Returns the value of attribute city.



12
13
14
# File 'lib/acube/schema/header/supplier.rb', line 12

def city
  @city
end

#civic_numberObject

Returns the value of attribute civic_number.



12
13
14
# File 'lib/acube/schema/header/supplier.rb', line 12

def civic_number
  @civic_number
end

#denominationObject

Returns the value of attribute denomination.



9
10
11
# File 'lib/acube/schema/header/supplier.rb', line 9

def denomination
  @denomination
end

#eori_codeObject

Returns the value of attribute eori_code.



9
10
11
# File 'lib/acube/schema/header/supplier.rb', line 9

def eori_code
  @eori_code
end

#first_nameObject

Returns the value of attribute first_name.



9
10
11
# File 'lib/acube/schema/header/supplier.rb', line 9

def first_name
  @first_name
end

#fiscal_codeObject

Returns the value of attribute fiscal_code.



8
9
10
# File 'lib/acube/schema/header/supplier.rb', line 8

def fiscal_code
  @fiscal_code
end

#fiscal_regimeObject

Returns the value of attribute fiscal_regime.



11
12
13
# File 'lib/acube/schema/header/supplier.rb', line 11

def fiscal_regime
  @fiscal_regime
end

#id_nationObject

Returns the value of attribute id_nation.



7
8
9
# File 'lib/acube/schema/header/supplier.rb', line 7

def id_nation
  @id_nation
end

#id_tax_codeObject

Returns the value of attribute id_tax_code.



7
8
9
# File 'lib/acube/schema/header/supplier.rb', line 7

def id_tax_code
  @id_tax_code
end

#last_nameObject

Returns the value of attribute last_name.



9
10
11
# File 'lib/acube/schema/header/supplier.rb', line 9

def last_name
  @last_name
end

#nationObject

Returns the value of attribute nation.



12
13
14
# File 'lib/acube/schema/header/supplier.rb', line 12

def nation
  @nation
end

#provinceObject

Returns the value of attribute province.



12
13
14
# File 'lib/acube/schema/header/supplier.rb', line 12

def province
  @province
end

#titleObject

Returns the value of attribute title.



9
10
11
# File 'lib/acube/schema/header/supplier.rb', line 9

def title
  @title
end

#zipObject

Returns the value of attribute zip.



12
13
14
# File 'lib/acube/schema/header/supplier.rb', line 12

def zip
  @zip
end

Class Method Details

.from(supplier) ⇒ Object



14
15
16
17
18
19
20
21
# File 'lib/acube/schema/header/supplier.rb', line 14

def self.from(supplier)
  new.tap do |supp|
    supplier.supplier_data.each do |key, value|
      value = value.is_a?(Symbol) ? supplier.send(value).to_s : value.to_s
      supp.send("#{key}=", value)
    end
  end
end

Instance Method Details

#to_xmlObject



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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
# File 'lib/acube/schema/header/supplier.rb', line 23

def to_xml
  Nokogiri::XML::Builder.new do |xml|
    xml.CedentePrestatore {
      xml.DatiAnagrafici {
        xml.IdFiscaleIVA {
          xml.IdPaese id_nation
          xml.IdCodice id_tax_code
        }
        
        xml.Anagrafica {
          if (first_name && last_name)
            xml.Nome first_name
            xml.Cognome last_name
          else
            xml.Denominazione denomination
          end
          xml.Titolo title if title
          xml.CodEORI eori_code if eori_code
        }

        xml.RegimeFiscale fiscal_regime
        xml.CodiceFiscale fiscal_code if fiscal_code

        xml.AlboProfessionale albo_professional if albo_professional
        xml.ProvinciaAlbo aldo_province if aldo_province
        xml.NumeroIscrizioneAlbo albo_subscription if albo_subscription
        xml.DataIscrizioneAlbo albo_subscription_date if albo_subscription_date
      }
      xml.Sede {
        xml.Indirizzo address
        xml.NumeroCivico civic_number if civic_number
        xml.CAP zip
        xml.Comune city
        xml.Provincia province
        xml.Nazione nation
      }
    }
  end.to_xml(save_with: 2)
end