From 2c4fe1ce678b5c0a7b1e870b947ea1a184ae5f49 Mon Sep 17 00:00:00 2001 From: GaelFerrand Date: Tue, 26 Nov 2024 10:38:46 +0100 Subject: [PATCH] feat: added BSDAs --- back/src/queue/jobs/administrativeTransfer.ts | 30 +++++++++++++++++++ .../RequestAdministrativeTransfer.tsx | 6 ++-- 2 files changed, 33 insertions(+), 3 deletions(-) diff --git a/back/src/queue/jobs/administrativeTransfer.ts b/back/src/queue/jobs/administrativeTransfer.ts index 63fcb00375..a9eea9e227 100644 --- a/back/src/queue/jobs/administrativeTransfer.ts +++ b/back/src/queue/jobs/administrativeTransfer.ts @@ -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 }; @@ -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... } diff --git a/front/src/Apps/Companies/CompanyAdvanced/RequestAdministrativeTransfer.tsx b/front/src/Apps/Companies/CompanyAdvanced/RequestAdministrativeTransfer.tsx index c72472f96e..542db61619 100644 --- a/front/src/Apps/Companies/CompanyAdvanced/RequestAdministrativeTransfer.tsx +++ b/front/src/Apps/Companies/CompanyAdvanced/RequestAdministrativeTransfer.tsx @@ -158,9 +158,9 @@ export function RequestAdministrativeTranfer({ company }: Props) { l'onglet "avancé de son établissement
  • - 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).
  • L'opération est irréversible.