Class: VerifactuRails::SistemaInformatico
- Inherits:
-
Object
- Object
- VerifactuRails::SistemaInformatico
- Defined in:
- lib/verifactu_rails/sistema_informatico.rb
Overview
Identificación del sistema informático de facturación, obligatoria en CADA registro remitido (sf:SistemaInformaticoType).
Ojo a lo que es esto realmente: la declaración de quién produce el SIF, en cada envío. Los valores describen al SIF DESPLEGADO, no a esta gema, y los aporta quien lo despliega. Esta librería es un componente del SIF, no el SIF.
Constant Summary collapse
- SOLO_VERIFACTU =
TipoUsoPosibleSoloVerifactu va fijo a 'S' y no se puede configurar.
No es un capricho: declarar 'N' significa que el SIF puede operar en modo NO VERI*FACTU, y eso obliga a llevar registro de eventos (RD 1007/2023; FAQs Desarrolladores v1.3, ap. 15, nota 1). Esta gema no implementa eventos, así que permitir 'N' sería dejar construir un sistema incompleto sin avisar. Si necesitas 'N', esta no es la librería.
'S'- PATRON_ID_SISTEMA =
Ap. 3.1.5: "deberá tener rellenas siempre las dos posiciones, cada una de las cuales deberá ser una letra mayúscula, excepto la Ñ, o un dígito numérico". El XSD solo limita la longitud a 2, así que sin esto pasaban valores de una posición o en minúscula.
/\A[A-Z0-9]{2}\z/
Instance Attribute Summary collapse
-
#id_sistema ⇒ Object
readonly
Returns the value of attribute id_sistema.
-
#multi_ot ⇒ Object
readonly
Returns the value of attribute multi_ot.
-
#multiples_ot ⇒ Object
readonly
Returns the value of attribute multiples_ot.
-
#nif ⇒ Object
readonly
Returns the value of attribute nif.
-
#nombre_razon ⇒ Object
readonly
Returns the value of attribute nombre_razon.
-
#nombre_sistema ⇒ Object
readonly
Returns the value of attribute nombre_sistema.
-
#numero_instalacion ⇒ Object
readonly
Returns the value of attribute numero_instalacion.
-
#version ⇒ Object
readonly
Returns the value of attribute version.
Instance Method Summary collapse
-
#a_pares ⇒ Object
Orden EXACTO de sf:SistemaInformaticoType.
-
#initialize(nombre_razon:, nif:, nombre_sistema:, id_sistema:, version:, numero_instalacion:, multi_ot: false, multiples_ot: false) ⇒ SistemaInformatico
constructor
A new instance of SistemaInformatico.
- #multi_ot? ⇒ Boolean
- #multiples_ot? ⇒ Boolean
- #solo_verifactu ⇒ Object
Constructor Details
#initialize(nombre_razon:, nif:, nombre_sistema:, id_sistema:, version:, numero_instalacion:, multi_ot: false, multiples_ot: false) ⇒ SistemaInformatico
Returns a new instance of SistemaInformatico.
30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 |
# File 'lib/verifactu_rails/sistema_informatico.rb', line 30 def initialize(nombre_razon:, nif:, nombre_sistema:, id_sistema:, version:, numero_instalacion:, multi_ot: false, multiples_ot: false) @nombre_razon = Formato.limitar(nombre_razon, 'NombreRazon', 120) @nif = Formato.nif(nif, 'NIF del productor') @nombre_sistema = Formato.limitar(nombre_sistema, 'NombreSistemaInformatico', 30) @id_sistema = validar_id_sistema(id_sistema) @version = Formato.limitar(version, 'Version', 50) @numero_instalacion = Formato.limitar(numero_instalacion, 'NumeroInstalacion', 100) # Por Formato.si_no y no por valor de verdad: 'N' es truthy en Ruby y se # emitía como 'S', invirtiendo lo que el usuario había declarado. @multi_ot = Formato.si_no(multi_ot, 'TipoUsoPosibleMultiOT') == 'S' @multiples_ot = Formato.si_no(multiples_ot, 'IndicadorMultiplesOT') == 'S' if @multiples_ot && !@multi_ot raise ValidacionError, 'IndicadorMultiplesOT no puede ser cierto si TipoUsoPosibleMultiOT ' \ 'es falso: no puedes estar usándolo para varios obligados si el ' \ 'sistema declara que no lo admite' end end |
Instance Attribute Details
#id_sistema ⇒ Object (readonly)
Returns the value of attribute id_sistema.
23 24 25 |
# File 'lib/verifactu_rails/sistema_informatico.rb', line 23 def id_sistema @id_sistema end |
#multi_ot ⇒ Object (readonly)
Returns the value of attribute multi_ot.
23 24 25 |
# File 'lib/verifactu_rails/sistema_informatico.rb', line 23 def multi_ot @multi_ot end |
#multiples_ot ⇒ Object (readonly)
Returns the value of attribute multiples_ot.
23 24 25 |
# File 'lib/verifactu_rails/sistema_informatico.rb', line 23 def multiples_ot @multiples_ot end |
#nif ⇒ Object (readonly)
Returns the value of attribute nif.
23 24 25 |
# File 'lib/verifactu_rails/sistema_informatico.rb', line 23 def nif @nif end |
#nombre_razon ⇒ Object (readonly)
Returns the value of attribute nombre_razon.
23 24 25 |
# File 'lib/verifactu_rails/sistema_informatico.rb', line 23 def nombre_razon @nombre_razon end |
#nombre_sistema ⇒ Object (readonly)
Returns the value of attribute nombre_sistema.
23 24 25 |
# File 'lib/verifactu_rails/sistema_informatico.rb', line 23 def nombre_sistema @nombre_sistema end |
#numero_instalacion ⇒ Object (readonly)
Returns the value of attribute numero_instalacion.
23 24 25 |
# File 'lib/verifactu_rails/sistema_informatico.rb', line 23 def numero_instalacion @numero_instalacion end |
#version ⇒ Object (readonly)
Returns the value of attribute version.
23 24 25 |
# File 'lib/verifactu_rails/sistema_informatico.rb', line 23 def version @version end |
Instance Method Details
#a_pares ⇒ Object
Orden EXACTO de sf:SistemaInformaticoType. Es una
63 64 65 66 67 68 69 70 71 72 73 74 75 |
# File 'lib/verifactu_rails/sistema_informatico.rb', line 63 def a_pares { 'NombreRazon' => nombre_razon, 'NIF' => nif, 'NombreSistemaInformatico' => nombre_sistema, 'IdSistemaInformatico' => id_sistema, 'Version' => version, 'NumeroInstalacion' => numero_instalacion, 'TipoUsoPosibleSoloVerifactu' => SOLO_VERIFACTU, 'TipoUsoPosibleMultiOT' => multi_ot ? 'S' : 'N', 'IndicadorMultiplesOT' => multiples_ot ? 'S' : 'N' } end |
#multi_ot? ⇒ Boolean
58 |
# File 'lib/verifactu_rails/sistema_informatico.rb', line 58 def multi_ot? = @multi_ot |
#multiples_ot? ⇒ Boolean
59 |
# File 'lib/verifactu_rails/sistema_informatico.rb', line 59 def multiples_ot? = @multiples_ot |
#solo_verifactu ⇒ Object
57 |
# File 'lib/verifactu_rails/sistema_informatico.rb', line 57 def solo_verifactu = SOLO_VERIFACTU |