generated from betagouv/rails-template
-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
86 additions
and
60 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
# frozen_string_literal: true | ||
|
||
module ASP | ||
module Entities | ||
module Adresse | ||
class Base < Entity | ||
attribute :codetypeadr, :string | ||
attribute :codecominsee, :string | ||
attribute :codeinseepays, :string | ||
attribute :codepostalcedex, :string | ||
|
||
validates_presence_of %i[ | ||
codetypeadr | ||
codeinseepays | ||
codepostalcedex | ||
codecominsee | ||
] | ||
|
||
def fragment(xml) | ||
xml.codetypeadr(codetypeadr) | ||
xml.codeinseepays(codeinseepays) | ||
xml.codepostalcedex(codepostalcedex) | ||
xml.codecominsee(codecominsee) | ||
end | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
# frozen_string_literal: true | ||
|
||
module ASP | ||
module Entities | ||
module Adresse | ||
class Etranger < Base | ||
# NOTE: for students living outside of France we take address attributes from the establishment | ||
def fragment(xml) | ||
establishment = payment_request.pfmp.establishment | ||
|
||
raise ASP::Errors::MissingEstablishmentCommuneCodeError if establishment.commune_code.blank? | ||
raise ASP::Errors::MissingEstablishmentPostalCodeError if establishment.postal_code.blank? | ||
|
||
xml.codetypeadr(Mappers::AdresseMapper::PRINCIPAL_ADDRESS_TYPE) | ||
xml.codecominsee(establishment.commune_code) | ||
xml.codepostalcedex(establishment.postal_code) | ||
xml.codeinseepays(InseeCodes::FRANCE_INSEE_COUNTRY_CODE) | ||
end | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
# frozen_string_literal: true | ||
|
||
module ASP | ||
module Entities | ||
module Adresse | ||
class Indu < Base | ||
attribute :pointremise, :string | ||
attribute :cpltdistribution, :string | ||
|
||
validates_presence_of %i[ | ||
pointremise | ||
cpltdistribution | ||
] | ||
|
||
def fragment(xml) | ||
xml.pointremise(payment_request.student.address_line1.slice(0, 38)) # Max 38 characters | ||
xml.cpltdistribution(payment_request.student.address_line2&.slice(0, 38)) # Max 38 characters | ||
xml.codetypeadr(ASP::Mappers::AdresseMapper::PRINCIPAL_ADDRESS_TYPE) | ||
xml.codeinseepays(InseeCountryCodeMapper.call(payment_request.student.address_country_code)) | ||
xml.codepostalcedex(payment_request.student.address_postal_code) | ||
xml.codecominsee(payment_request.student.address_city_insee_code) | ||
end | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters