From 1ccdcdec4dd0156ba2173547b25e8d2c219814ea Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?No=C3=ABl=20Mugnier?= Date: Tue, 12 Oct 2021 19:06:26 +0200 Subject: [PATCH] =?UTF-8?q?Ajout=20de=20la=20gestion=20de=20l'adresse=20de?= =?UTF-8?q?=20facturation=20=C3=A0=20la=20cr=C3=A9ation=20du=20compte?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/routes/register/owner/FormCompany.svelte | 113 +++++++++++++++++-- src/routes/register/registerCompanyForm.js | 26 ++++- 2 files changed, 126 insertions(+), 13 deletions(-) diff --git a/src/routes/register/owner/FormCompany.svelte b/src/routes/register/owner/FormCompany.svelte index f3adfd8d..38243a73 100644 --- a/src/routes/register/owner/FormCompany.svelte +++ b/src/routes/register/owner/FormCompany.svelte @@ -143,7 +143,7 @@ @@ -156,21 +156,23 @@ {#if !isStore} -
- +
+
+ +
{/if} {#if !$company.notSubjectToVat} @@ -219,10 +221,16 @@ />
+ {#if isStore} + Seuls l'équipe Sheaft et les producteurs partenaires peuvent voir votre mail et votre téléphone. + {:else} Seuls l'équipe Sheaft et les clients ayant commandé auprès de vous peuvent voir votre mail et votre téléphone. + {/if}
+
+
+

Adresse de Facturation

+
+
+
+ +
+
+ {#if $company.differentBillingAddress} +
+ + + +
+
+ + + +
+
+ + +
+
+
+
+ + + +
+
+ + + +
+
+
+
+ + +
+ {/if}
diff --git a/src/routes/register/registerCompanyForm.js b/src/routes/register/registerCompanyForm.js index 19b0cde9..cb5c9e4a 100644 --- a/src/routes/register/registerCompanyForm.js +++ b/src/routes/register/registerCompanyForm.js @@ -1,9 +1,12 @@ -import { getDefaultFields } from "../../stores/form"; import formatISO from "date-fns/formatISO"; -import { normalizeOpeningHours, getDefaultDenormalizedOpeningHours } from "../../helpers/app"; + import { writable, get } from "svelte/store"; + import omit from "lodash/omit"; + import RegistrationKind from "../../enums/RegistrationKind"; +import { normalizeOpeningHours, getDefaultDenormalizedOpeningHours } from "../../helpers/app"; +import { getDefaultFields } from "../../stores/form"; export const siret = writable(null); @@ -13,6 +16,7 @@ export const companyInitialValues = { vatIdentifier: null, kind: null, notSubjectToVat: false, + differentBillingAddress: false, email: null, //$authUserAccount?.profile?.email || phone: null, // $authUserAccount?.profile?.phone address: { @@ -22,6 +26,14 @@ export const companyInitialValues = { zipcode: null, country: "FR", }, + billing: { + name: null, + line1: null, + line2: null, + city: null, + zipcode: null, + country: "FR", + }, registrationKind: null, registrationCode: null, registrationCity: null, @@ -76,6 +88,10 @@ export const companyValidators = (values) => ({ city: { value: values.address.city, validators: ["required"], enabled: true }, zipcode: { value: values.address.zipcode, validators: ["required"], enabled: true }, line1: { value: values.address.line1, validators: ["required"], enabled: true }, + billingCity: { value: values.billing.city, validators: ["required"], enabled: values.differentBillingAddress }, + billingZipcode: { value: values.billing.zipcode, validators: ["required"], enabled: values.differentBillingAddress }, + billingLine1: { value: values.billing.line1, validators: ["required"], enabled: values.differentBillingAddress }, + billingName: { value: values.billing.name, validators: ["required"], enabled: values.differentBillingAddress }, }); export const normalizeCompany = (profile) => { @@ -96,12 +112,16 @@ export const normalizeCompany = (profile) => { picture: profile.picture || null, address: { ...omit(get(productionSite).address, ["insee", "id"]), country: "FR" }, legals: { - ...omit(companyInfos, ["commercialName", "notSubjectToVat", "phone"]), + ...omit(companyInfos, ["commercialName", "notSubjectToVat", "phone", "differentBillingAddress"]), siret: get(siret).toString(), address: companyInfos.address ? { ...companyInfos.address, country: companyInfos.address?.country?.code || (companyInfos.address?.country ?? "FR"), } : null, + billing: companyInfos.differentBillingAddress ? { + ...companyInfos.billing, + country: companyInfos.billing?.country?.code || (companyInfos.billing?.country ?? "FR") + } : null, vatIdentifier: companyInfos.vatIdentifier && !companyInfos.notSubjectToVat ? "FR" + companyInfos.vatIdentifier + get(siret).toString().substring(0, 9)