Skip to content

Commit

Permalink
Hotfix/ Annexe 1 (#3393)
Browse files Browse the repository at this point in the history
* Fix signature

* Fix

* Enhance error message
  • Loading branch information
Riron authored Jun 6, 2024
1 parent e6c19f0 commit fecf12c
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2730,7 +2730,7 @@ describe("Mutation.updateForm", () => {

expect(errors).toEqual([
expect.objectContaining({
message: `L'émetteur du bordereau d'annexe 1 ${appendix1_1.id} n'est pas inscrit sur Trackdéchets. Il est impossible de joindre cette annexe à un bordereau chapeau sans éco-organisme.`,
message: `L'émetteur du bordereau d'annexe 1 ${appendix1_1.readableId} n'est pas inscrit sur Trackdéchets. Il est impossible de joindre cette annexe à un bordereau chapeau sans éco-organisme.`,
extensions: {
code: "BAD_USER_INPUT"
}
Expand All @@ -2745,6 +2745,14 @@ describe("Mutation.updateForm", () => {
set: ["ECO_ORGANISME"]
}
});
await prisma.ecoOrganisme.create({
data: {
address: "",
name: ecoOrganisme.company.name,
siret: ecoOrganisme.company.siret!
}
});

const { mutate } = makeClient(user);

const appendix1_1 = await prisma.form.create({
Expand All @@ -2759,8 +2767,6 @@ describe("Mutation.updateForm", () => {
emitterCompanyPhone: "01 01 01 01 01",
emitterCompanyMail: "[email protected]",
wasteDetailsCode: "16 06 01*",
ecoOrganismeName: ecoOrganisme.company.name,
ecoOrganismeSiret: ecoOrganisme.company.siret,
owner: { connect: { id: user.id } }
}
});
Expand All @@ -2772,7 +2778,9 @@ describe("Mutation.updateForm", () => {
status: Status.SEALED,
wasteDetailsCode: "16 06 01*",
emitterCompanySiret: company.siret,
emitterType: EmitterType.APPENDIX1
emitterType: EmitterType.APPENDIX1,
ecoOrganismeName: ecoOrganisme.company.name,
ecoOrganismeSiret: ecoOrganisme.company.siret
}
});

Expand Down
2 changes: 1 addition & 1 deletion back/src/forms/resolvers/mutations/signTransportForm.ts
Original file line number Diff line number Diff line change
Expand Up @@ -398,7 +398,7 @@ async function canTransporterSignWithoutEmitterSignature(existingForm: Form) {
});

if (
emitterProfile &&
!emitterProfile ||
[CompanyType.WASTEPROCESSOR, CompanyType.COLLECTOR].every(
profile => !emitterProfile.companyTypes.includes(profile)
)
Expand Down
4 changes: 2 additions & 2 deletions back/src/forms/validation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2025,7 +2025,7 @@ export async function validateAppendix1Groupement(
});

for (const initialForm of initialForms) {
if (initialForm.ecoOrganismeSiret || !initialForm.emitterCompanySiret) {
if (form.ecoOrganismeSiret || !initialForm.emitterCompanySiret) {
continue;
}

Expand All @@ -2035,7 +2035,7 @@ export async function validateAppendix1Groupement(
});
if (!company) {
throw new UserInputError(
`L'émetteur du bordereau d'annexe 1 ${initialForm.id} n'est pas inscrit sur Trackdéchets. Il est impossible de joindre cette annexe à un bordereau chapeau sans éco-organisme.`
`L'émetteur du bordereau d'annexe 1 ${initialForm.readableId} n'est pas inscrit sur Trackdéchets. Il est impossible de joindre cette annexe à un bordereau chapeau sans éco-organisme.`
);
}
}
Expand Down

0 comments on commit fecf12c

Please sign in to comment.