Skip to content

Commit

Permalink
feat: added BSDAs
Browse files Browse the repository at this point in the history
  • Loading branch information
GaelFerrand committed Nov 26, 2024
1 parent e5752aa commit 2c4fe1c
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 3 deletions.
30 changes: 30 additions & 0 deletions back/src/queue/jobs/administrativeTransfer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { prisma } from "@td/prisma";
import { Job } from "bull";
import { getFormRepository } from "../../forms/repository";
import { AuthType } from "../../auth";
import { getBsdaRepository } from "../../bsda/repository";

export type AdministrativeTransferArgs = { fromOrgId: string; toOrgId: string };

Expand Down Expand Up @@ -48,5 +49,34 @@ export async function processAdministrativeTransferJob(
}
);

// BSDAs
const bsdasToTransfer = await prisma.bsda.findMany({
where: {
destinationCompanySiret: fromOrgId,
status: {
in: ["AWAITING_CHILD"]
}
},
select: { id: true }
});

const bsdaRepository = getBsdaRepository({
auth: AuthType.Bearer,
id: "JOB_ADMINISTRATIVE_TRANSFER",
name: "JOB_ADMINISTRATIVE_TRANSFER"
} as Express.User);

await bsdaRepository.updateMany(
{ id: { in: bsdasToTransfer.map(bsda => bsda.id) } },
{
destinationCompanySiret: toCompany.orgId,
destinationCompanyName: toCompany.name,
destinationCompanyAddress: toCompany.address,
destinationCompanyContact: toCompany.contact,
destinationCompanyMail: toCompany.contactEmail,
destinationCompanyPhone: toCompany.contactPhone
}
);

// Later on, other types of BSDs...
}
Original file line number Diff line number Diff line change
Expand Up @@ -158,9 +158,9 @@ export function RequestAdministrativeTranfer({ company }: Props) {
l'onglet "avancé de son établissement
</li>
<li>
L'ensemble des bordereaux (BSDD) au statut "awaiting-group" (En
attente de regroupement) sera transféré. (pas de sélection
possible)
L'ensemble des bordereaux (BSDD au statut "awaiting-group" et BSDA
au statut "awaiting-child" soit En attente de regroupement) sera
transféré (pas de sélection possible).
</li>
<li>L'opération est irréversible.</li>
</ul>
Expand Down

0 comments on commit 2c4fe1c

Please sign in to comment.