From 713b6210c21e985cef61aa862e45a6d395e67ede Mon Sep 17 00:00:00 2001
From: Fadil Zemmari <fadil.zemmari@xelians.fr>
Date: Mon, 28 Sep 2020 13:19:03 +0200
Subject: [PATCH] [US TRTL-390 TRTL-391] Change customer & owner internalCode
 feature

---
 .../vitamui/iam/common/dto/CustomerDto.java   |  5 +--
 .../server/customer/domain/Customer.java      |  5 +--
 .../commons/api/enums/AddressType.java        | 43 -------------------
 .../models/customer/address-type.enum.ts      | 40 -----------------
 .../models/customer/customer.interface.ts     |  2 -
 .../src/app/modules/models/customer/index.ts  |  1 -
 .../src/app/core/api/customer-api.service.ts  |  1 -
 .../src/app/core/customer.service.spec.ts     |  3 +-
 .../customer-create.component.html            | 26 +++--------
 .../customer-create.component.spec.ts         |  2 -
 .../customer-create.component.ts              | 33 +++++---------
 .../customer-list.component.spec.ts           |  7 +--
 .../customer-list.service.spec.ts             |  6 +--
 .../customer-list/customer-list.service.ts    |  1 -
 .../graphic-identity-tab.component.spec.ts    |  4 +-
 .../graphic-identity-update.component.spec.ts |  3 +-
 .../information-tab.component.spec.ts         |  4 +-
 .../sso-tab/sso-tab.component.spec.ts         |  3 +-
 .../customer-resolver.service.spec.ts         |  3 +-
 .../owner-form/owner-form.component.html      | 11 +++--
 .../owner-form/owner-form.component.ts        |  6 +--
 .../user-create/user-create.component.html    | 17 +++-----
 .../user/user-create/user-create.component.ts | 16 ++-----
 .../user-information-tab.component.spec.ts    |  4 +-
 .../identity/service/CustomerServiceTest.java |  2 -
 25 files changed, 43 insertions(+), 205 deletions(-)
 delete mode 100644 commons/commons-api/src/main/java/fr/gouv/vitamui/commons/api/enums/AddressType.java
 delete mode 100644 ui/ui-frontend-common/src/app/modules/models/customer/address-type.enum.ts

diff --git a/api/api-iam/iam-commons/src/main/java/fr/gouv/vitamui/iam/common/dto/CustomerDto.java b/api/api-iam/iam-commons/src/main/java/fr/gouv/vitamui/iam/common/dto/CustomerDto.java
index c6b5040f..3970877d 100644
--- a/api/api-iam/iam-commons/src/main/java/fr/gouv/vitamui/iam/common/dto/CustomerDto.java
+++ b/api/api-iam/iam-commons/src/main/java/fr/gouv/vitamui/iam/common/dto/CustomerDto.java
@@ -43,7 +43,6 @@ import java.util.Map;
 import javax.validation.constraints.NotNull;
 import javax.validation.constraints.Size;
 
-import fr.gouv.vitamui.commons.api.enums.AddressType;
 import org.hibernate.validator.constraints.Length;
 
 import com.fasterxml.jackson.annotation.JsonInclude;
@@ -101,13 +100,11 @@ public class CustomerDto extends IdDto {
     @NotNull
     private String defaultEmailDomain;
 
+    @NotNull
     private AddressDto address;
 
     private String internalCode;
 
-    @NotNull
-    private AddressType addressType;
-
     private boolean subrogeable = false;
 
     private boolean readonly = false;
diff --git a/api/api-iam/iam-internal/src/main/java/fr/gouv/vitamui/iam/internal/server/customer/domain/Customer.java b/api/api-iam/iam-internal/src/main/java/fr/gouv/vitamui/iam/internal/server/customer/domain/Customer.java
index 36286385..c60664d0 100644
--- a/api/api-iam/iam-internal/src/main/java/fr/gouv/vitamui/iam/internal/server/customer/domain/Customer.java
+++ b/api/api-iam/iam-internal/src/main/java/fr/gouv/vitamui/iam/internal/server/customer/domain/Customer.java
@@ -41,7 +41,6 @@ import java.util.List;
 import javax.validation.constraints.NotNull;
 import javax.validation.constraints.Size;
 
-import fr.gouv.vitamui.commons.api.enums.AddressType;
 import org.hibernate.validator.constraints.Length;
 import org.springframework.data.annotation.TypeAlias;
 import org.springframework.data.mongodb.core.index.Indexed;
@@ -105,13 +104,11 @@ public class Customer extends IdDocument {
     @NotNull
     private String defaultEmailDomain;
 
+    @NotNull
     private Address address;
 
     private String internalCode;
 
-    @NotNull
-    private AddressType addressType;
-
     private boolean readonly = false;
 
     private boolean subrogeable = false;
diff --git a/commons/commons-api/src/main/java/fr/gouv/vitamui/commons/api/enums/AddressType.java b/commons/commons-api/src/main/java/fr/gouv/vitamui/commons/api/enums/AddressType.java
deleted file mode 100644
index 0c90007c..00000000
--- a/commons/commons-api/src/main/java/fr/gouv/vitamui/commons/api/enums/AddressType.java
+++ /dev/null
@@ -1,43 +0,0 @@
-/**
- * Copyright French Prime minister Office/SGMAP/DINSIC/Vitam Program (2019-2020)
- * and the signatories of the "VITAM - Accord du Contributeur" agreement.
- *
- * contact@programmevitam.fr
- *
- * This software is a computer program whose purpose is to implement
- * implement a digital archiving front-office system for the secure and
- * efficient high volumetry VITAM solution.
- *
- * This software is governed by the CeCILL-C license under French law and
- * abiding by the rules of distribution of free software.  You can  use,
- * modify and/ or redistribute the software under the terms of the CeCILL-C
- * license as circulated by CEA, CNRS and INRIA at the following URL
- * "http://www.cecill.info".
- *
- * As a counterpart to the access to the source code and  rights to copy,
- * modify and redistribute granted by the license, users are provided only
- * with a limited warranty  and the software's author,  the holder of the
- * economic rights,  and the successive licensors  have only  limited
- * liability.
- *
- * In this respect, the user's attention is drawn to the risks associated
- * with loading,  using,  modifying and/or developing or reproducing the
- * software by the user in light of its specific status of free software,
- * that may mean  that it is complicated to manipulate,  and  that  also
- * therefore means  that it is reserved for developers  and  experienced
- * professionals having in-depth computer knowledge. Users are therefore
- * encouraged to load and test the software's suitability as regards their
- * requirements in conditions enabling the security of their systems and/or
- * data to be ensured and,  more generally, to use and operate it in the
- * same conditions as regards security.
- *
- * The fact that you are presently reading this means that you have had
- * knowledge of the CeCILL-C license and that you accept its terms.
- */
-package fr.gouv.vitamui.commons.api.enums;
-
-/** Possible address types of a Customer or an Owner **/
-public enum AddressType {
-    POSTAL,
-    INTERNAL_CODE,
-}
diff --git a/ui/ui-frontend-common/src/app/modules/models/customer/address-type.enum.ts b/ui/ui-frontend-common/src/app/modules/models/customer/address-type.enum.ts
deleted file mode 100644
index 3e5d3f99..00000000
--- a/ui/ui-frontend-common/src/app/modules/models/customer/address-type.enum.ts
+++ /dev/null
@@ -1,40 +0,0 @@
-/*
- * Copyright French Prime minister Office/SGMAP/DINSIC/Vitam Program (2019-2020)
- * and the signatories of the "VITAM - Accord du Contributeur" agreement.
- *
- * contact@programmevitam.fr
- *
- * This software is a computer program whose purpose is to implement
- * implement a digital archiving front-office system for the secure and
- * efficient high volumetry VITAM solution.
- *
- * This software is governed by the CeCILL-C license under French law and
- * abiding by the rules of distribution of free software.  You can  use,
- * modify and/ or redistribute the software under the terms of the CeCILL-C
- * license as circulated by CEA, CNRS and INRIA at the following URL
- * "http://www.cecill.info".
- *
- * As a counterpart to the access to the source code and  rights to copy,
- * modify and redistribute granted by the license, users are provided only
- * with a limited warranty  and the software's author,  the holder of the
- * economic rights,  and the successive licensors  have only  limited
- * liability.
- *
- * In this respect, the user's attention is drawn to the risks associated
- * with loading,  using,  modifying and/or developing or reproducing the
- * software by the user in light of its specific status of free software,
- * that may mean  that it is complicated to manipulate,  and  that  also
- * therefore means  that it is reserved for developers  and  experienced
- * professionals having in-depth computer knowledge. Users are therefore
- * encouraged to load and test the software's suitability as regards their
- * requirements in conditions enabling the security of their systems and/or
- * data to be ensured and,  more generally, to use and operate it in the
- * same conditions as regards security.
- *
- * The fact that you are presently reading this means that you have had
- * knowledge of the CeCILL-C license and that you accept its terms.
- */
-export enum AddressType {
-    POSTAL = 'POSTAL',
-    INTERNAL_CODE = 'INTERNAL_CODE'
-}
diff --git a/ui/ui-frontend-common/src/app/modules/models/customer/customer.interface.ts b/ui/ui-frontend-common/src/app/modules/models/customer/customer.interface.ts
index 0221cef6..7a936ae2 100644
--- a/ui/ui-frontend-common/src/app/modules/models/customer/customer.interface.ts
+++ b/ui/ui-frontend-common/src/app/modules/models/customer/customer.interface.ts
@@ -35,7 +35,6 @@
  * knowledge of the CeCILL-C license and that you accept its terms.
  */
 import { Id } from '../id.interface';
-import { AddressType } from './address-type.enum';
 import { Address } from './address.interface';
 import { OtpState } from './otp-state.enum';
 import { Owner } from './owner.interface';
@@ -51,7 +50,6 @@ export interface Customer extends Id {
   idp?: boolean;
   address: Address;
   internalCode?: string;
-  addressType: AddressType;
   language: string;
   emailDomains: string[];
   defaultEmailDomain: string;
diff --git a/ui/ui-frontend-common/src/app/modules/models/customer/index.ts b/ui/ui-frontend-common/src/app/modules/models/customer/index.ts
index 4540adc7..00d32156 100644
--- a/ui/ui-frontend-common/src/app/modules/models/customer/index.ts
+++ b/ui/ui-frontend-common/src/app/modules/models/customer/index.ts
@@ -42,4 +42,3 @@ export * from './identity-provider.interface';
 export * from './tenant.interface';
 export * from './basic-customer.interface';
 export * from './customer.interface';
-export * from './address-type.enum';
diff --git a/ui/ui-frontend/projects/identity/src/app/core/api/customer-api.service.ts b/ui/ui-frontend/projects/identity/src/app/core/api/customer-api.service.ts
index e5dc8bc0..af55bd04 100644
--- a/ui/ui-frontend/projects/identity/src/app/core/api/customer-api.service.ts
+++ b/ui/ui-frontend/projects/identity/src/app/core/api/customer-api.service.ts
@@ -77,7 +77,6 @@ export class CustomerApiService extends BaseHttpClient<Customer> {
       otp: customer.otp,
       idp: customer.idp,
       address: customer.address,
-      addressType: customer.addressType,
       internalCode: customer.internalCode,
       language: customer.language,
       emailDomains: customer.emailDomains,
diff --git a/ui/ui-frontend/projects/identity/src/app/core/customer.service.spec.ts b/ui/ui-frontend/projects/identity/src/app/core/customer.service.spec.ts
index a7d29330..07fd70e6 100644
--- a/ui/ui-frontend/projects/identity/src/app/core/customer.service.spec.ts
+++ b/ui/ui-frontend/projects/identity/src/app/core/customer.service.spec.ts
@@ -34,7 +34,7 @@
  * The fact that you are presently reading this means that you have had
  * knowledge of the CeCILL-C license and that you accept its terms.
  */
-import { AddressType, ENVIRONMENT, LoggerModule } from 'ui-frontend-common';
+import { ENVIRONMENT, LoggerModule } from 'ui-frontend-common';
 import { BASE_URL, Customer, Operators, OtpState, SearchQuery } from 'ui-frontend-common';
 import { environment } from './../../environments/environment';
 
@@ -169,7 +169,6 @@ const expectedCustomer: Customer = {
   companyName: 'John Co.',
   passwordRevocationDelay: 3,
   otp: OtpState.OPTIONAL,
-  addressType: AddressType.POSTAL,
   address: {
     street: 'street',
     zipCode: '12345',
diff --git a/ui/ui-frontend/projects/identity/src/app/customer/customer-create/customer-create.component.html b/ui/ui-frontend/projects/identity/src/app/customer/customer-create/customer-create.component.html
index 060f9ec8..0ec50b65 100644
--- a/ui/ui-frontend/projects/identity/src/app/customer/customer-create/customer-create.component.html
+++ b/ui/ui-frontend/projects/identity/src/app/customer/customer-create/customer-create.component.html
@@ -39,26 +39,7 @@
           </vitamui-common-input>
         </div>
 
-        <div class="mb-4">
-          <div i18n="Address type@@CustomerAddressType" class="mb-2">Type d'adresse</div>
-          <mat-button-toggle-group #group="matButtonToggleGroup" formControlName="addressType">
-            <mat-button-toggle color="primary" value="POSTAL"
-              [ngClass]="{'selected': form.get('addressType').value === ADDRESS_TYPE.POSTAL}">Postale</mat-button-toggle>
-            <mat-button-toggle color="primary" value="INTERNAL_CODE"
-              [ngClass]="{'selected': form.get('addressType').value === ADDRESS_TYPE.INTERNAL_CODE}">Code interne</mat-button-toggle>
-          </mat-button-toggle-group>
-        </div>
-
-        <div *ngIf="form.get('addressType').value === ADDRESS_TYPE.INTERNAL_CODE">
-          <vitamui-common-input class="field-street" formControlName="internalCode" maxlength="20" required placeholder="Code interne"
-          i18n-placeholder="Internal code@@customerInternalCodePlaceholder">
-            <vitamui-common-input-error
-            *ngIf="form.get('internalCode')?.touched && !!form.get('internalCode')?.errors?.required"
-            i18n="Required field error hint@@formErrorRequiredField">Champ requis</vitamui-common-input-error>
-          </vitamui-common-input>
-        </div>
-
-        <ng-container formGroupName="address" *ngIf="form.get('addressType').value === ADDRESS_TYPE.POSTAL">
+        <ng-container formGroupName="address">
           <div>
             <vitamui-common-input class="field-street" formControlName="street" maxlength="250" required
               placeholder="N° et nom de rue"
@@ -103,6 +84,9 @@
           </div>
         </ng-container>
 
+        <vitamui-common-input class="field-street" formControlName="internalCode" maxlength="20" placeholder="Code interne"
+        i18n-placeholder="Internal code@@customerInternalCodePlaceholder"></vitamui-common-input>
+
         <div class="d-flex">
           <label for="language" class="inline-label label-language"
             i18n="Interface language (by default for the user)@@customerCreateLanguageInputLabel">
@@ -258,7 +242,7 @@
         <h2 i18n="Create evidence owner title@@customerCreateTitle3">Création du propriétaire des éléments de preuve
         </h2>
         <div class="form-group">
-          <app-owner-form [formControl]="form.get(['owners', 0])" [customerInfo]="customerInfo" [addressType]="form.get('addressType').value"></app-owner-form>
+          <app-owner-form [formControl]="form.get(['owners', 0])" [customerInfo]="customerInfo"></app-owner-form>
           <p class="hint" i18n="the evidence tenant is automatically created with the owner@@customerCreateHint">Le
             coffre des éléments de preuve est créé automatiquement avec son propriétaire</p>
         </div>
diff --git a/ui/ui-frontend/projects/identity/src/app/customer/customer-create/customer-create.component.spec.ts b/ui/ui-frontend/projects/identity/src/app/customer/customer-create/customer-create.component.spec.ts
index a7d9b1a9..190ffb7e 100644
--- a/ui/ui-frontend/projects/identity/src/app/customer/customer-create/customer-create.component.spec.ts
+++ b/ui/ui-frontend/projects/identity/src/app/customer/customer-create/customer-create.component.spec.ts
@@ -35,7 +35,6 @@
  * knowledge of the CeCILL-C license and that you accept its terms.
  */
 import { EMPTY, of } from 'rxjs';
-import { AddressType } from 'ui-frontend-common';
 import { ConfirmDialogService, OtpState } from 'ui-frontend-common';
 import { VitamUICommonTestModule } from 'ui-frontend-common/testing';
 
@@ -100,7 +99,6 @@ const expectedCustomer = {
   hasCustomGraphicIdentity: false,
   passwordRevocationDelay: 3,
   otp: OtpState.OPTIONAL,
-  addressType: AddressType.POSTAL,
   address: {
     street: 'street',
     zipCode: '12345',
diff --git a/ui/ui-frontend/projects/identity/src/app/customer/customer-create/customer-create.component.ts b/ui/ui-frontend/projects/identity/src/app/customer/customer-create/customer-create.component.ts
index be6dbfb9..606acdef 100644
--- a/ui/ui-frontend/projects/identity/src/app/customer/customer-create/customer-create.component.ts
+++ b/ui/ui-frontend/projects/identity/src/app/customer/customer-create/customer-create.component.ts
@@ -35,7 +35,7 @@
  * knowledge of the CeCILL-C license and that you accept its terms.
  */
 import { merge, Subscription } from 'rxjs';
-import { AddressType, ConfirmDialogService, Customer, OtpState, ThemeService } from 'ui-frontend-common';
+import { ConfirmDialogService, Customer, OtpState, ThemeService } from 'ui-frontend-common';
 
 import { Component, Inject, OnDestroy, OnInit, ViewChild } from '@angular/core';
 import { FormBuilder, FormGroup, Validators } from '@angular/forms';
@@ -52,7 +52,6 @@ interface CustomerInfo {
    code: string;
    name: string;
    companyName: string;
-   addressType: AddressType;
 }
 
 @Component({
@@ -61,8 +60,6 @@ interface CustomerInfo {
   styleUrls: ['./customer-create.component.scss']
 })
 export class CustomerCreateComponent implements OnInit, OnDestroy {
-  public readonly ADDRESS_TYPE = AddressType;
-
   @ViewChild('fileSearch', { static: false }) public fileSearch: any;
 
   public form: FormGroup;
@@ -83,7 +80,6 @@ export class CustomerCreateComponent implements OnInit, OnDestroy {
     code: '',
     name: '',
     companyName: '',
-    addressType: AddressType.POSTAL
   };
 
   // stepCount is the total number of steps and is used to calculate the advancement of the progress bar.
@@ -117,13 +113,12 @@ export class CustomerCreateComponent implements OnInit, OnDestroy {
       passwordRevocationDelay: 6,
       otp: OtpState.OPTIONAL,
       address: this.formBuilder.group({
-        street: [''],
-        zipCode: [''],
-        city: [''],
-        country: ['FR']
+        street: [null, Validators.required],
+        zipCode: [null, Validators.required],
+        city: [null, Validators.required],
+        country: ['FR', Validators.required]
       }),
       internalCode: [null],
-      addressType: [AddressType.POSTAL, Validators.required],
       language: ['FRENCH', Validators.required],
       emailDomains: [null, Validators.required],
       defaultEmailDomain: [null, Validators.required],
@@ -172,7 +167,6 @@ export class CustomerCreateComponent implements OnInit, OnDestroy {
       this.form.get('code').valueChanges,
       this.form.get('name').valueChanges,
       this.form.get('companyName').valueChanges,
-      this.form.get('addressType').valueChanges
     )
     .subscribe(() => {
       // reset object to trigger customerInfo input update in child component
@@ -180,7 +174,6 @@ export class CustomerCreateComponent implements OnInit, OnDestroy {
         code: this.form.get('code').value,
         name: this.form.get('name').value,
         companyName: this.form.get('companyName').value,
-        addressType: this.form.get('addressType').value
       };
     });
   }
@@ -271,18 +264,14 @@ export class CustomerCreateComponent implements OnInit, OnDestroy {
   }
 
   firstStepInvalid(): boolean {
-    const response = this.form.get('code').invalid || this.form.get('code').pending ||
-    this.form.get('name').invalid || this.form.get('name').pending ||
-    this.form.get('companyName').invalid || this.form.get('companyName').pending;
-
-    if (this.form.get('addressType').value === AddressType.POSTAL) {
-      return response || this.form.get('address.street').invalid || this.form.get('address.street').pending ||
+    return this.form.get('code').invalid || this.form.get('code').pending ||
+      this.form.get('name').invalid || this.form.get('name').pending ||
+      this.form.get('companyName').invalid || this.form.get('companyName').pending ||
+      this.form.get('address.street').invalid || this.form.get('address.street').pending ||
       this.form.get('address.zipCode').invalid || this.form.get('address.zipCode').pending ||
       this.form.get('address.city').invalid || this.form.get('address.city').pending ||
-      this.form.get('address.country').invalid || this.form.get('address.country').pending;
-    } else if (this.form.get('addressType').value === AddressType.INTERNAL_CODE) {
-      return response || this.form.get('internalCode').invalid || this.form.get('internalCode').pending;
-    }
+      this.form.get('address.country').invalid || this.form.get('address.country').pending ||
+      this.form.get('internalCode').invalid || this.form.get('internalCode').pending;
   }
 
   secondStepInvalid(): boolean {
diff --git a/ui/ui-frontend/projects/identity/src/app/customer/customer-list/customer-list.component.spec.ts b/ui/ui-frontend/projects/identity/src/app/customer/customer-list/customer-list.component.spec.ts
index 6a679bda..23fd0258 100644
--- a/ui/ui-frontend/projects/identity/src/app/customer/customer-list/customer-list.component.spec.ts
+++ b/ui/ui-frontend/projects/identity/src/app/customer/customer-list/customer-list.component.spec.ts
@@ -45,7 +45,7 @@ import { NoopAnimationsModule } from '@angular/platform-browser/animations';
 import { Router } from '@angular/router';
 import { of ,  Subject } from 'rxjs';
 
-import { AddressType, Customer, OtpState, Owner, Tenant } from 'ui-frontend-common';
+import { Customer, OtpState, Owner, Tenant } from 'ui-frontend-common';
 import { InfiniteScrollStubDirective, VitamUICommonTestModule } from 'ui-frontend-common/testing';
 import { CustomerService } from '../../core/customer.service';
 import { CustomerDataService } from '../customer.data.service';
@@ -107,7 +107,6 @@ describe('CustomerListComponent', () => {
           'kouygues.com',
         ],
         defaultEmailDomain: 'kouygues.com',
-        addressType: AddressType.POSTAL,
         address: {
           street: '13 rue faubourg',
           zipCode: '75009',
@@ -134,7 +133,6 @@ describe('CustomerListComponent', () => {
           'louygues.com',
         ],
         defaultEmailDomain: 'louygues.com',
-        addressType: AddressType.POSTAL,
         address: {
           street: '13 rue faubourg',
           zipCode: '75009',
@@ -161,7 +159,6 @@ describe('CustomerListComponent', () => {
           'mouygues.com',
         ],
         defaultEmailDomain: 'mouygues.com',
-        addressType: AddressType.POSTAL,
         address: {
           street: '13 rue faubourg',
           zipCode: '75009',
@@ -188,7 +185,6 @@ describe('CustomerListComponent', () => {
           'nrange.com',
         ],
         defaultEmailDomain: 'nrange.com',
-        addressType: AddressType.POSTAL,
         address: {
           street: '13 rue faubourg',
           zipCode: '75009',
@@ -215,7 +211,6 @@ describe('CustomerListComponent', () => {
           'bouygues.com',
         ],
         defaultEmailDomain: 'bouygues.com',
-        addressType: AddressType.POSTAL,
         address: {
           street: '13 rue faubourg',
           zipCode: '75009',
diff --git a/ui/ui-frontend/projects/identity/src/app/customer/customer-list/customer-list.service.spec.ts b/ui/ui-frontend/projects/identity/src/app/customer/customer-list/customer-list.service.spec.ts
index cc9a7c70..fcc8ee66 100644
--- a/ui/ui-frontend/projects/identity/src/app/customer/customer-list/customer-list.service.spec.ts
+++ b/ui/ui-frontend/projects/identity/src/app/customer/customer-list/customer-list.service.spec.ts
@@ -38,7 +38,7 @@
 import { HttpClientTestingModule, HttpTestingController } from '@angular/common/http/testing';
 import { Type } from '@angular/core';
 import { TestBed } from '@angular/core/testing';
-import { AddressType, ENVIRONMENT } from 'ui-frontend-common';
+import { ENVIRONMENT } from 'ui-frontend-common';
 import { BASE_URL, Customer, Direction, LoggerModule, OtpState, PageRequest } from 'ui-frontend-common';
 import { environment } from './../../../environments/environment';
 import { CustomerListService } from './customer-list.service';
@@ -93,7 +93,6 @@ const expectedCustomersPage: { values: Customer[], pageNum: number, pageSize: nu
           readonly: false
         },
       ],
-      addressType: AddressType.POSTAL,
       internalCode: '1',
       address: {
         street: '73 rue du Faubourg Poissonnière ',
@@ -151,7 +150,6 @@ const expectedCustomersPage: { values: Customer[], pageNum: number, pageSize: nu
           readonly: false
         },
       ],
-      addressType: AddressType.POSTAL,
       internalCode: '1',
       address: {
         street: '22-30 Avenue de WAGRAM',
@@ -217,7 +215,6 @@ const customersPage: { values: Customer[], pageNum: number, pageSize: number, ha
           readonly: false
         },
       ],
-      addressType: AddressType.POSTAL,
       internalCode: '1',
       address: {
         street: '73 rue du Faubourg Poissonnière ',
@@ -275,7 +272,6 @@ const customersPage: { values: Customer[], pageNum: number, pageSize: number, ha
           readonly: false
         },
       ],
-      addressType: AddressType.POSTAL,
       internalCode: '1',
       address: {
         street: '22-30 Avenue de WAGRAM',
diff --git a/ui/ui-frontend/projects/identity/src/app/customer/customer-list/customer-list.service.ts b/ui/ui-frontend/projects/identity/src/app/customer/customer-list/customer-list.service.ts
index 54755321..99ced1b1 100644
--- a/ui/ui-frontend/projects/identity/src/app/customer/customer-list/customer-list.service.ts
+++ b/ui/ui-frontend/projects/identity/src/app/customer/customer-list/customer-list.service.ts
@@ -94,7 +94,6 @@ export class CustomerListService extends SearchService<Customer> {
       passwordRevocationDelay: customer.passwordRevocationDelay,
       otp: customer.otp,
       address: customer.address,
-      addressType: customer.addressType,
       internalCode: customer.internalCode,
       language: customer.language,
       emailDomains: customer.emailDomains,
diff --git a/ui/ui-frontend/projects/identity/src/app/customer/customer-preview/graphic-identity-tab/graphic-identity-tab.component.spec.ts b/ui/ui-frontend/projects/identity/src/app/customer/customer-preview/graphic-identity-tab/graphic-identity-tab.component.spec.ts
index ffd21301..c3c5eaa2 100644
--- a/ui/ui-frontend/projects/identity/src/app/customer/customer-preview/graphic-identity-tab/graphic-identity-tab.component.spec.ts
+++ b/ui/ui-frontend/projects/identity/src/app/customer/customer-preview/graphic-identity-tab/graphic-identity-tab.component.spec.ts
@@ -39,7 +39,7 @@ import { Component } from '@angular/core';
 import { async, ComponentFixture, TestBed } from '@angular/core/testing';
 import { MAT_DIALOG_DATA, MatDialog, MatDialogRef } from '@angular/material/dialog';
 import { of } from 'rxjs';
-import { AddressType, ENVIRONMENT } from 'ui-frontend-common';
+import { ENVIRONMENT } from 'ui-frontend-common';
 import { BASE_URL, Customer, LoggerModule, OtpState } from 'ui-frontend-common';
 import { VitamUISnackBar } from '../../../shared/vitamui-snack-bar';
 import { environment } from './../../../../environments/environment';
@@ -57,7 +57,6 @@ let expectedCustomer: Customer = {
   passwordRevocationDelay: 6,
   otp: OtpState.DEACTIVATED,
   idp: true,
-  addressType: AddressType.POSTAL,
   address: {
     street: '85 rue des bois',
     zipCode: '75013',
@@ -119,7 +118,6 @@ describe('GraphicIdentityTabComponent', () => {
       passwordRevocationDelay: 6,
       otp: OtpState.DEACTIVATED,
       idp: true,
-      addressType: AddressType.POSTAL,
       address: {
         street: '85 rue des bois',
         zipCode: '75013',
diff --git a/ui/ui-frontend/projects/identity/src/app/customer/customer-preview/graphic-identity-tab/graphic-identity-update/graphic-identity-update.component.spec.ts b/ui/ui-frontend/projects/identity/src/app/customer/customer-preview/graphic-identity-tab/graphic-identity-update/graphic-identity-update.component.spec.ts
index ce075c4d..3e24ed5e 100644
--- a/ui/ui-frontend/projects/identity/src/app/customer/customer-preview/graphic-identity-tab/graphic-identity-update/graphic-identity-update.component.spec.ts
+++ b/ui/ui-frontend/projects/identity/src/app/customer/customer-preview/graphic-identity-tab/graphic-identity-update/graphic-identity-update.component.spec.ts
@@ -40,7 +40,7 @@ import { async, ComponentFixture, TestBed } from '@angular/core/testing';
 import { ControlValueAccessor, NG_VALUE_ACCESSOR } from '@angular/forms';
 import { ReactiveFormsModule } from '@angular/forms';
 import { MAT_DIALOG_DATA, MatDialogRef } from '@angular/material/dialog';
-import { AddressType, ENVIRONMENT } from 'ui-frontend-common';
+import { ENVIRONMENT } from 'ui-frontend-common';
 import { BASE_URL, Customer, InjectorModule, LoggerModule, OtpState } from 'ui-frontend-common';
 import { VitamUICommonTestModule } from 'ui-frontend-common/testing';
 import { environment } from './../../../../../environments/environment';
@@ -61,7 +61,6 @@ const expectedCustomer: Customer = {
   passwordRevocationDelay: 6,
   otp: OtpState.DEACTIVATED,
   idp: true,
-  addressType: AddressType.POSTAL,
   address: {
     street: '85 rue des bois',
     zipCode: '75013',
diff --git a/ui/ui-frontend/projects/identity/src/app/customer/customer-preview/information-tab/information-tab.component.spec.ts b/ui/ui-frontend/projects/identity/src/app/customer/customer-preview/information-tab/information-tab.component.spec.ts
index 7e874a30..d89d402e 100644
--- a/ui/ui-frontend/projects/identity/src/app/customer/customer-preview/information-tab/information-tab.component.spec.ts
+++ b/ui/ui-frontend/projects/identity/src/app/customer/customer-preview/information-tab/information-tab.component.spec.ts
@@ -41,7 +41,7 @@ import { AsyncValidator, ControlValueAccessor, NG_VALUE_ACCESSOR, ReactiveFormsM
 import { NoopAnimationsModule } from '@angular/platform-browser/animations';
 import { of } from 'rxjs';
 
-import { AddressType, Customer, OtpState } from 'ui-frontend-common';
+import { Customer, OtpState } from 'ui-frontend-common';
 import { VitamUICommonTestModule } from 'ui-frontend-common/testing';
 import { CustomerService } from '../../../core/customer.service';
 import { CustomerCreateValidators } from '../../customer-create/customer-create.validators';
@@ -64,7 +64,6 @@ let expectedCustomer: Customer = {
         'kouygues.com',
     ],
     defaultEmailDomain: 'kouygues.com',
-    addressType: AddressType.POSTAL,
     address: {
         street: '13 rue faubourg',
         zipCode: '75009',
@@ -143,7 +142,6 @@ describe('Customer InformationTabComponent', () => {
         'kouygues.com',
       ],
       defaultEmailDomain: 'kouygues.com',
-      addressType: AddressType.POSTAL,
       address: {
         street: '13 rue faubourg',
         zipCode: '75009',
diff --git a/ui/ui-frontend/projects/identity/src/app/customer/customer-preview/sso-tab/sso-tab.component.spec.ts b/ui/ui-frontend/projects/identity/src/app/customer/customer-preview/sso-tab/sso-tab.component.spec.ts
index 7414439b..82d424d9 100644
--- a/ui/ui-frontend/projects/identity/src/app/customer/customer-preview/sso-tab/sso-tab.component.spec.ts
+++ b/ui/ui-frontend/projects/identity/src/app/customer/customer-preview/sso-tab/sso-tab.component.spec.ts
@@ -40,7 +40,7 @@ import { async, ComponentFixture, TestBed } from '@angular/core/testing';
 import { MatDialog } from '@angular/material/dialog';
 import { of ,  Subject } from 'rxjs';
 
-import { AddressType, Customer, IdentityProvider, OtpState } from 'ui-frontend-common';
+import { Customer, IdentityProvider, OtpState } from 'ui-frontend-common';
 import { IdentityProviderService } from './identity-provider.service';
 import { SsoTabComponent } from './sso-tab.component';
 
@@ -85,7 +85,6 @@ class TestHostComponent {
         'test6.com',
     ],
     defaultEmailDomain : '1test.com',
-    addressType: AddressType.POSTAL,
     address : {
         street : '73 rue du Faubourg Poissonnière ',
         zipCode : '75009',
diff --git a/ui/ui-frontend/projects/identity/src/app/customer/customer-resolver.service.spec.ts b/ui/ui-frontend/projects/identity/src/app/customer/customer-resolver.service.spec.ts
index 05cc3927..52ebeee6 100644
--- a/ui/ui-frontend/projects/identity/src/app/customer/customer-resolver.service.spec.ts
+++ b/ui/ui-frontend/projects/identity/src/app/customer/customer-resolver.service.spec.ts
@@ -40,7 +40,7 @@ import { inject, TestBed } from '@angular/core/testing';
 import { ActivatedRouteSnapshot, Router } from '@angular/router';
 import { of } from 'rxjs';
 
-import { AddressType, Customer, OtpState } from 'ui-frontend-common';
+import { Customer, OtpState } from 'ui-frontend-common';
 import { CustomerService } from '../core/customer.service';
 import { CustomerResolver } from './customer-resolver.service';
 
@@ -61,7 +61,6 @@ const expectedCustomer: Customer = {
     'kouygues.com',
   ],
   defaultEmailDomain: 'kouygues.com',
-  addressType: AddressType.POSTAL,
   address: {
     street: '13 rue faubourg',
     zipCode: '75009',
diff --git a/ui/ui-frontend/projects/identity/src/app/customer/owner-form/owner-form.component.html b/ui/ui-frontend/projects/identity/src/app/customer/owner-form/owner-form.component.html
index 1d401e73..78b72721 100644
--- a/ui/ui-frontend/projects/identity/src/app/customer/owner-form/owner-form.component.html
+++ b/ui/ui-frontend/projects/identity/src/app/customer/owner-form/owner-form.component.html
@@ -17,12 +17,7 @@
     </vitamui-common-input>
   </div>
 
-  <div *ngIf="addressType === ADDRESS_TYPE.INTERNAL_CODE">
-    <vitamui-common-input class="field-street" formControlName="internalCode" maxlength="20" placeholder="Code interne"
-    i18n-placeholder="Internal code@@OwnerInternalCodePlaceholder"></vitamui-common-input>
-  </div>
-
-  <ng-container formGroupName="address" *ngIf="addressType === ADDRESS_TYPE.POSTAL">
+  <ng-container formGroupName="address">
     <div>
       <vitamui-common-input class="field-street" formControlName="street" maxlength="250" placeholder="N° et nom de la rue" i18n-placeholder="Owner street input placeholder@@ownerFormStreetInputPlaceholder"></vitamui-common-input>
     </div>
@@ -47,4 +42,8 @@
       </div>
     </mat-form-field>
   </ng-container>
+
+  <vitamui-common-input class="field-street" formControlName="internalCode" maxlength="20" placeholder="Code interne"
+  i18n-placeholder="Internal code@@OwnerInternalCodePlaceholder"></vitamui-common-input>
+
 </ng-container>
diff --git a/ui/ui-frontend/projects/identity/src/app/customer/owner-form/owner-form.component.ts b/ui/ui-frontend/projects/identity/src/app/customer/owner-form/owner-form.component.ts
index b8d9056b..62ddaccf 100644
--- a/ui/ui-frontend/projects/identity/src/app/customer/owner-form/owner-form.component.ts
+++ b/ui/ui-frontend/projects/identity/src/app/customer/owner-form/owner-form.component.ts
@@ -39,7 +39,7 @@ import { Component, forwardRef, Input, OnDestroy, OnInit } from '@angular/core';
 import { ControlValueAccessor, FormBuilder, FormGroup, NG_VALUE_ACCESSOR, Validators } from '@angular/forms';
 import { merge } from 'rxjs';
 import { distinctUntilChanged, map } from 'rxjs/operators';
-import { AddressType, Customer } from 'ui-frontend-common';
+import { Customer } from 'ui-frontend-common';
 
 import { Owner } from 'ui-frontend-common';
 import { OwnerFormValidators } from './owner-form.validators';
@@ -58,14 +58,10 @@ export const OWNER_FORM_VALUE_ACCESSOR: any = {
 })
 export class OwnerFormComponent implements ControlValueAccessor, OnDestroy, OnInit {
 
-  @Input() addressType: AddressType;
-
   form: FormGroup;
 
   private sub: any;
 
-  public ADDRESS_TYPE = AddressType;
-
   @Input()
   set customerId(customerId: string) {
     this._customerId = customerId;
diff --git a/ui/ui-frontend/projects/identity/src/app/user/user-create/user-create.component.html b/ui/ui-frontend/projects/identity/src/app/user/user-create/user-create.component.html
index 317cf395..79a9abaf 100644
--- a/ui/ui-frontend/projects/identity/src/app/user/user-create/user-create.component.html
+++ b/ui/ui-frontend/projects/identity/src/app/user/user-create/user-create.component.html
@@ -156,16 +156,7 @@
     <cdk-step>
       <div class="content">
         <h2 i18n="@@userCreateAddressTitle">Coordonnées</h2>
-
-        <ng-container *ngIf="customer.addressType === ADDRESS_TYPE.INTERNAL_CODE">
-          <div>
-            <vitamui-common-input class="field-street" required formControlName="internalCode" maxlength="20" placeholder="Code interne"
-              i18n-placeholder="@@userCreateInternalCodeInputPlaceholder">
-            </vitamui-common-input>
-          </div>
-        </ng-container>
-
-        <ng-container formGroupName="address" *ngIf="!customer.addressType || customer.addressType === ADDRESS_TYPE.POSTAL">
+        <ng-container formGroupName="address">
           <div>
             <vitamui-common-input class="field-street" [required]="!addressEmpty" formControlName="street" maxlength="250" placeholder="N° et nom de rue"
               i18n-placeholder="@@userCreateStreetInputPlaceholder">
@@ -204,6 +195,12 @@
             </mat-form-field>
           </div>
 
+          <div>
+            <vitamui-common-input class="field-street" required formControlName="internalCode" maxlength="20" placeholder="Code interne"
+              i18n-placeholder="@@userCreateInternalCodeInputPlaceholder">
+            </vitamui-common-input>
+          </div>
+
           <div>
             <vitamui-common-input class="field-site-code" formControlName="siteCode" placeholder="Code du site"
                                   i18n-placeholder="user create siteCode@@userCreateSiteCode">
diff --git a/ui/ui-frontend/projects/identity/src/app/user/user-create/user-create.component.ts b/ui/ui-frontend/projects/identity/src/app/user/user-create/user-create.component.ts
index 3149340d..8227fc5a 100644
--- a/ui/ui-frontend/projects/identity/src/app/user/user-create/user-create.component.ts
+++ b/ui/ui-frontend/projects/identity/src/app/user/user-create/user-create.component.ts
@@ -35,7 +35,6 @@
  * knowledge of the CeCILL-C license and that you accept its terms.
  */
 import { Subscription } from 'rxjs';
-import { AddressType } from 'ui-frontend-common';
 import {
   AdminUserProfile, AuthService, ConfirmDialogService, Customer, isRootLevel, OtpState, ProfileSelection
 } from 'ui-frontend-common';
@@ -88,8 +87,6 @@ export class UserCreateComponent implements OnInit, OnDestroy {
 
   public creating = false;
 
-  public ADDRESS_TYPE = AddressType;
-
   // stepCount is the total number of steps and is used to calculate the advancement of the progress bar.
   // We could get the number of steps using ViewChildren(StepComponent) but this triggers a
   // "Expression has changed after it was checked" error so we instead manually define the value.
@@ -124,11 +121,6 @@ export class UserCreateComponent implements OnInit, OnDestroy {
       domain: [this.customer.emailDomains[0]]
     });
 
-    let internalCode: string;
-    if (this.customer.addressType === AddressType.INTERNAL_CODE) {
-      internalCode = this.customer.internalCode;
-    }
-
     this.form = this.formBuilder.group(
       {
         enabled: true,
@@ -158,7 +150,7 @@ export class UserCreateComponent implements OnInit, OnDestroy {
           city: [null],
           country: ['FR']
         }),
-        internalCode: [internalCode],
+        internalCode: [this.customer.internalCode],
         siteCode: [null],
       },
       { validator: UserValidators.missingPhoneNumber }
@@ -240,10 +232,8 @@ export class UserCreateComponent implements OnInit, OnDestroy {
   }
 
   public thirdStepInvalid(): boolean {
-    if (!this.customer.addressType || this.customer.addressType === AddressType.POSTAL) {
-      return this.form.get('address').pending || this.form.get('address').invalid;
-    }
-    return this.form.get('internalCode').pending || this.form.get('internalCode').invalid;
+    return this.form.get('address').pending || this.form.get('address').invalid ||
+    this.form.get('internalCode').pending || this.form.get('internalCode').invalid;
   }
 
   passGroupStep() {
diff --git a/ui/ui-frontend/projects/identity/src/app/user/user-preview/user-information-tab/user-information-tab.component.spec.ts b/ui/ui-frontend/projects/identity/src/app/user/user-preview/user-information-tab/user-information-tab.component.spec.ts
index 2e6c470c..a6b7bd3d 100644
--- a/ui/ui-frontend/projects/identity/src/app/user/user-preview/user-information-tab/user-information-tab.component.spec.ts
+++ b/ui/ui-frontend/projects/identity/src/app/user/user-preview/user-information-tab/user-information-tab.component.spec.ts
@@ -37,7 +37,7 @@
 /* tslint:disable: max-file-line-count max-classes-per-file */
 
 import { of } from 'rxjs';
-import { AddressType, AdminUserProfile, AuthService, Customer, OtpState, User } from 'ui-frontend-common';
+import { AdminUserProfile, AuthService, Customer, OtpState, User } from 'ui-frontend-common';
 import { VitamUICommonTestModule } from 'ui-frontend-common/testing';
 
 import { Component, Directive, Input, ViewChild } from '@angular/core';
@@ -90,7 +90,6 @@ let expectedCustomer: Customer = {
   passwordRevocationDelay: 6,
   otp: OtpState.DEACTIVATED,
   idp: true,
-  addressType: AddressType.POSTAL,
   address: {
     street: '85 rue des bois',
     zipCode: '75013',
@@ -199,7 +198,6 @@ describe('UserInfoTabComponent', () => {
       passwordRevocationDelay: 6,
       otp: OtpState.DEACTIVATED,
       idp: true,
-      addressType: AddressType.POSTAL,
       address: {
         street: '85 rue des bois',
         zipCode: '75013',
diff --git a/ui/ui-identity/src/test/java/fr/gouv/vitamui/identity/service/CustomerServiceTest.java b/ui/ui-identity/src/test/java/fr/gouv/vitamui/identity/service/CustomerServiceTest.java
index 46f918be..f041b38a 100644
--- a/ui/ui-identity/src/test/java/fr/gouv/vitamui/identity/service/CustomerServiceTest.java
+++ b/ui/ui-identity/src/test/java/fr/gouv/vitamui/identity/service/CustomerServiceTest.java
@@ -7,7 +7,6 @@ import static org.mockito.ArgumentMatchers.any;
 import java.util.Arrays;
 import java.util.Optional;
 
-import fr.gouv.vitamui.commons.api.enums.AddressType;
 import org.junit.Before;
 import org.junit.Test;
 import org.junit.runner.RunWith;
@@ -120,7 +119,6 @@ public class CustomerServiceTest extends UIIdentityServiceTest<CustomerDto> {
         customer.setOtp(OtpEnum.OPTIONAL);
         customer.setLanguage(LanguageDto.FRENCH);
         customer.setOwners(Arrays.asList(new OwnerDto()));
-        customer.setAddressType(AddressType.POSTAL);
         customer.setAddress(new AddressDto("street", "zipCode", "city", "country"));
         customer.setDefaultEmailDomain("@vitamui.com");
         customer.setPasswordRevocationDelay(1);
-- 
GitLab