expose attestationSocialeAttachment and attestationFiscaleAttachment

This commit is contained in:
Christophe Robillard 2020-05-06 15:06:04 +02:00
parent b7d511a6e2
commit 10a21f9010
4 changed files with 23 additions and 0 deletions

View file

@ -692,6 +692,8 @@ type Effectif {
}
type Entreprise {
attestationFiscaleAttachment: File
attestationSocialeAttachment: File
capitalSocial: BigInt!
codeEffectifEntreprise: String!
dateCreation: ISO8601Date!

View file

@ -21,6 +21,16 @@ module Types
field :nom, String, null: false
field :prenom, String, null: false
field :inline_adresse, String, null: false
field :attestation_sociale_attachment, Types::File, null: true
field :attestation_fiscale_attachment, Types::File, null: true
def attestation_sociale_attachment
load_attachment_for(:entreprise_attestation_sociale_attachment)
end
def attestation_fiscale_attachment
load_attachment_for(:entreprise_attestation_fiscale_attachment)
end
def effectif_mensuel
if object.effectif_mensuel.present?
@ -39,6 +49,15 @@ module Types
}
end
end
private
def load_attachment_for(key)
Loaders::Association.for(
Etablissement,
key => :blob
).load(object.etablissement)
end
end
class AssociationType < Types::BaseObject

View file

@ -3,6 +3,7 @@ class Entreprise < Hashie::Dash
self[attribute]
end
property :etablissement
property :siren
property :capital_social
property :numero_tva_intracommunautaire

View file

@ -96,6 +96,7 @@ class Etablissement < ApplicationRecord
def entreprise
Entreprise.new(
etablissement: self,
siren: entreprise_siren,
capital_social: entreprise_capital_social,
numero_tva_intracommunautaire: entreprise_numero_tva_intracommunautaire,