Skip to content

Commit

Permalink
[TRA-15655] Correction de la mise à jour des numéros d'identification…
Browse files Browse the repository at this point in the history
… sur le bsvhu (#3876)
  • Loading branch information
providenz committed Jan 9, 2025
2 parents 8ecc230 + 8949788 commit d4b0125
Show file tree
Hide file tree
Showing 17 changed files with 242 additions and 106 deletions.
4 changes: 4 additions & 0 deletions Changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,10 @@ et le projet suit un schéma de versionning inspiré de [Calendar Versioning](ht

- Pour le Bsvhu lors d'un transport routier, la plaque d'immatriculation est désormais obligatoire et les poids de déchets sont limités à 40 T (50 kT pour les autres modes) [PR 3719](https://github.com/MTES-MCT/trackdechets/pull/3719)

#### :bug: Corrections de bugs

- Correction de la mise à jour des numéros d'identification sur le bsvhu [PR 3876](https://github.com/MTES-MCT/trackdechets/pull/3876)

# [2024.12.1] 17/12/2024

#### :rocket: Nouvelles fonctionnalités
Expand Down
2 changes: 2 additions & 0 deletions back/src/bsvhu/converter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,7 @@ export function expandVhuFormFromDb(form: PrismaVhuForm): GraphqlVhuForm {
mail: form.transporterCompanyMail,
vatNumber: form.transporterCompanyVatNumber
}),
customInfo: form.transporterCustomInfo,
recepisse: nullIfNoValues<BsvhuRecepisse>({
number: form.transporterRecepisseNumber,
department: form.transporterRecepisseDepartment,
Expand Down Expand Up @@ -370,6 +371,7 @@ function flattenVhuTransporterInput({
transporterCompanyVatNumber: chain(transporter, t =>
chain(t.company, c => c.vatNumber)
),
transporterCustomInfo: chain(transporter, t => t.customInfo),
transporterRecepisseNumber: chain(transporter, t =>
chain(t.recepisse, r => r.number)
),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,10 @@ const UPDATE_VHU_FORM = gql`
validityLimit
isExempted
}
customInfo
transport {
plates
}
}
intermediaries {
siret
Expand Down Expand Up @@ -312,7 +316,9 @@ describe("Mutation.Vhu.update", () => {
const { mutate } = makeClient(user);
const input = {
transporter: {
company: { vatNumber: foreignTransporter.vatNumber }
company: { vatNumber: foreignTransporter.vatNumber },
customInfo: "lorem",
transport: { plates: ["SD-34-PO"] }
}
};
const { data } = await mutate<Pick<Mutation, "updateBsvhu">>(
Expand All @@ -325,6 +331,10 @@ describe("Mutation.Vhu.update", () => {
expect(data.updateBsvhu.transporter!.company!.vatNumber).toBe(
foreignTransporter.vatNumber
);
expect(data.updateBsvhu.transporter!.customInfo).toBe("lorem");
expect(data.updateBsvhu.transporter!.transport!.plates).toStrictEqual([
"SD-34-PO"
]);
});

it("should update transporter recepisse with data pulled from db", async () => {
Expand Down
2 changes: 2 additions & 0 deletions back/src/bsvhu/typeDefs/bsvhu.inputs.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -282,6 +282,8 @@ input BsvhuTransporterInput {
company: CompanyInput
"Récépissé transporteur"
recepisse: BsvhuRecepisseInput
"Champ libre"
customInfo: String
"Informations liés au transport"
transport: BsvhuTransportInput
}
Expand Down
2 changes: 2 additions & 0 deletions back/src/bsvhu/typeDefs/bsvhu.objects.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,8 @@ type BsvhuTransporter {
company: FormCompany
"Récépissé transporteur"
recepisse: BsvhuRecepisse
"Champ libre"
customInfo: String
"Informations liés au transport"
transport: BsvhuTransport
}
Expand Down
6 changes: 5 additions & 1 deletion back/src/bsvhu/validation/rules.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ export type BsvhuEditableFields = Required<
| "emitterCustomInfo"
| "emitterNotOnTD"
| "destinationCustomInfo"
| "transporterCustomInfo"
| "emitterEmissionSignatureDate"
| "emitterEmissionSignatureAuthor"
| "transporterTransportSignatureDate"
Expand Down Expand Up @@ -541,6 +540,11 @@ export const bsvhuEditionRules: BsvhuEditionRules = {
}
}
},
transporterCustomInfo: {
readableFieldName:
"les champs d'informations complémentaires du transporteur",
sealed: { from: "TRANSPORT" }
},
ecoOrganismeName: {
readableFieldName: "le nom de l'éco-organisme",
sealed: { from: "OPERATION" },
Expand Down
1 change: 0 additions & 1 deletion back/src/bsvhu/validation/schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,6 @@ const rawBsvhuSchema = z.object({
)
.max(2, "Un maximum de 2 plaques d'immatriculation est accepté")
.default([]),

ecoOrganismeName: z.string().nullish(),
ecoOrganismeSiret: siretSchema(CompanyRole.EcoOrganisme).nullish(),
brokerCompanyName: z.string().nullish(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -461,6 +461,7 @@ function BsdCardList({
const hasAutomaticSignature = siretsWithAutomaticSignature?.includes(
node?.emitter?.company?.siret
);

return (
<li className="bsd-card-list__item" key={key}>
<BsdCard
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ import {
MutationUpdateBsdasriArgs,
MutationUpdateBsffArgs,
MutationUpdateBspaohArgs,
MutationUpdateFormTransporterArgs
MutationUpdateFormTransporterArgs,
MutationUpdateBsvhuArgs
} from "@td/codegen-ui";
import TdModal from "../../../common/Components/Modal/Modal";
import { NotificationError } from "../../../common/Components/Error/Error";
Expand All @@ -20,6 +21,7 @@ import { UPDATE_BSDD_TRANSPORTER } from "../../../common/queries/bsdd/queries";
import { UPDATE_BSFF_FORM } from "../../../common/queries/bsff/queries";
import { UPDATE_BSDASRI } from "../../../common/queries/bsdasri/queries";
import { UPDATE_BSPAOH } from "../../../common/queries/bspaoh/queries";
import { UPDATE_VHU_FORM } from "../../../common/queries/bsvhu/queries";
import TransporterInfoEditForm from "./TransporterInfoEditForm";
import { Loader } from "../../../common/Components";

Expand Down Expand Up @@ -73,6 +75,13 @@ const TransporterInfoEditModal = ({
UPDATE_BSPAOH
);

const [
updateTransporterInfoBsvhu,
{ error: errorBsvhu, loading: loadingBsvhu }
] = useMutation<Pick<Mutation, "updateBsvhu">, MutationUpdateBsvhuArgs>(
UPDATE_VHU_FORM
);

const onSubmitForm = async data => {
if (bsd.type === BsdType.Bsdd) {
await updateTransporterInfoBsdd({
Expand Down Expand Up @@ -140,17 +149,35 @@ const TransporterInfoEditModal = ({
}
}
});
} else if (bsd.type === BsdType.Bsvhu) {
await updateTransporterInfoBsvhu({
variables: {
id: bsd.id,
input: {
transporter: {
customInfo: data.customInfo,
transport: { plates: formattedPlates }
}
}
}
});
}
};

const error =
errorBsdd || errorBsda || errorBsdasri || errorBsff || errorBspaoh;
errorBsdd ||
errorBsda ||
errorBsdasri ||
errorBsff ||
errorBspaoh ||
errorBsvhu;
const loading =
loadingBsdd ||
loadingBsda ||
loadingBsdasri ||
loadingBsff ||
loadingBspaoh;
loadingBspaoh ||
loadingBsvhu;

return (
<TdModal
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import { useForm, FormProvider } from "react-hook-form";
import { datetimeToYYYYMMDDHHSS } from "../paohUtils";
import { SignatureTimestamp } from "./components/Signature";

import { RhfTagsInputWrapper } from "../../../../../Apps/Forms/Components/TagsInput/TagsInputWrapper";
import { RhfTagsInputWrapper } from "../../../../Forms/Components/TagsInput/TagsInputWrapper";

// instanciate schema in component to have an up-to-date max datetime validaton
const getSchema = () =>
Expand Down
Loading

0 comments on commit d4b0125

Please sign in to comment.