Skip to content

Commit

Permalink
[TRA-15342] Le champ destinationCap du BSDA est scellé à partir de l'…
Browse files Browse the repository at this point in the history
…étape de transport (ou émission si pas d'entreprise de travaux) (#3778)

* feat: modified seal rule on destinationCap

* fix: simplified code
  • Loading branch information
GaelFerrand authored Dec 2, 2024
1 parent 0295b5f commit 2bf2a50
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion back/src/bsda/validation/rules.ts
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,17 @@ const sealedFromEmissionExceptAddOrRemoveNextDestination: GetBsdaSignatureTypeFn
return isEmitter ? "WORK" : "EMISSION";
};

const sealedFromEmissionExceptIfWorker: GetBsdaSignatureTypeFn<ZodBsda> = (
bsda,
_
) => {
// Si entreprise de travaux: on peut modifier jusqu'à l'étape de transport
// Sinon, scellé dès la signature émetteur
const hasWorker = bsda?.workerCompanySiret;

return hasWorker ? "TRANSPORT" : "EMISSION";
};

/**
* Renvoie la signature émetteur s'il n'y a pas d'entreprise de travaux sur le BSDA.
* Sinon, renvoie la signature de l'entreprise de travaux.
Expand Down Expand Up @@ -434,7 +445,7 @@ export const bsdaEditionRules: BsdaEditionRules = {
},
destinationCap: {
readableFieldName: "le CAP du destinataire",
sealed: { from: sealedFromEmissionExceptAddOrRemoveNextDestination },
sealed: { from: sealedFromEmissionExceptIfWorker },
required: {
from: "EMISSION",
when: bsda =>
Expand Down

0 comments on commit 2bf2a50

Please sign in to comment.