Commit 21c91113 authored by Stephane Bouvry's avatar Stephane Bouvry
Browse files

PCRU : Génération du fichier partenaires

parent 2407c56f
Loading
Loading
Loading
Loading
+8 −6
Original line number Diff line number Diff line
@@ -349,7 +349,6 @@ class AdministrationController extends AbstractOscarController implements UsePro
                        return $this->getResponseInternalError($e->getMessage());
                    }
                    return $this->jsonOutput(['tvas' => $this->getProjectGrantService()->getTVAsForJson()]);
                    break;

                case 'POST':

@@ -381,7 +380,6 @@ class AdministrationController extends AbstractOscarController implements UsePro
                    } catch (\Exception $e) {
                        return $this->getResponseInternalError($e->getMessage());
                    }
                    break;

                default:
                    return $this->getResponseBadRequest("Erreur d'API");
@@ -404,15 +402,19 @@ class AdministrationController extends AbstractOscarController implements UsePro
                $this->flashMessenger()->addSuccessMessage('Les référentiels PCRU ont été mis à jour');
                $this->redirect()->toRoute('administration/accueil');
                return [];

            case "iso-3166-update":

                return [];
            default:
                return $this->getResponseBadRequest();
        }

        return [];
    }

    /**
     * Liste des pays ISO 3166
     *
     * @return array|\Zend\Http\Response
     * @throws OscarException
     */
    public function paysIso3166Action()
    {
        $this->getOscarUserContextService()->check(Privileges::MAINTENANCE_MENU_ADMIN);
+0 −2
Original line number Diff line number Diff line
@@ -2786,10 +2786,8 @@ class ProjectGrantController extends AbstractOscarController implements UseNotif
     */
    public function pcruListAction()
    {

        $this->getOscarUserContextService()->check(Privileges::MAINTENANCE_PCRU_LIST);
        $accessUpload = $this->getOscarUserContextService()->hasPrivileges(Privileges::MAINTENANCE_PCRU_UPLOAD);

        $pcruInfos = $this->getProjectGrantService()->getPCRUService()->getPcruInfos();
        $methods = $this->getHttpXMethod();

+7 −0
Original line number Diff line number Diff line
@@ -342,6 +342,13 @@ class Organization implements ResourceInterface, IConnectedObject
        $this->setDateCreated(new \DateTime());
    }

    public function getCodePcru(){
        if( $this->getSiret() ) return $this->getSiret();
        if( $this->getTvaintra() ) return $this->getTvaintra();
        if( $this->getDuns() ) return $this->getDuns();
        return null;
    }

    public function isClose()
    {
        return $this->getDateEnd() && $this->getDateEnd() <= new \DateTime();
+19 −0
Original line number Diff line number Diff line
@@ -138,4 +138,23 @@ class OrganizationRepository extends EntityRepository implements IConnectedRepos
            ->setParameter('search', '%"'.$connector.'";s:'.strlen($value).':"'.$value.'";%');
        return $qb;
    }

    /**
     * @param $code
     * @return Organization|null
     * @throws NoResultException
     * @throws \Doctrine\ORM\NonUniqueResultException
     */
    public function getOrganizationByCodePCRU( $code ) :?Organization
    {
        $qb = $this->getEntityManager()->createQueryBuilder('o')
            ->select('o')
            ->from(Organization::class, 'o')
            ->where('o.siret = :code OR o.duns = :code OR o.tvaintra = :code')
            ->getQuery()
            ->setParameter('code', $code)
        ;

        return $qb->getSingleResult();
    }
}
 No newline at end of file
+10 −1
Original line number Diff line number Diff line
@@ -47,6 +47,7 @@ class ActivityPcruInfoFromActivityFactory

        // Intitulé du rôle "Laboratoire" pour PCRU
        $roleStructureToFind = $this->oscarConfigurationService->getOptionalConfiguration('pcru_unite_role', 'Laboratoire');
        $rolePartnerToFind = $this->oscarConfigurationService->getOptionalConfiguration('pcru_patner_role', 'Financeur');

        // Donnèes trouvées
        $codeUniteLabintel = "";
@@ -58,7 +59,6 @@ class ActivityPcruInfoFromActivityFactory
            $activityPcruInfos->addError("Aucune structure $roleStructureToFind pour cette activité.");
        }


        $organizationsParsed = [];
        /** @var ActivityOrganization $unite */
        foreach ($activity->getOrganizationsWithRole($roleStructureToFind) as $unite) {
@@ -69,6 +69,14 @@ class ActivityPcruInfoFromActivityFactory
            }
        }

        $partners = [];
        /** @var ActivityOrganization $partner */
        foreach ($activity->getOrganizationsWithRole($rolePartnerToFind) as $partner) {
            if( $partner->getOrganization()->getCodePcru() ){
                $partners[] = $partner->getOrganization()->getCodePcru();
            }
        }

        if( $codeUniteLabintel == "" ){
            $activityPcruInfos->addError("Le $roleStructureToFind (".implode(', ', $organizationsParsed).") n'a pas de code LABINTEL");
        }
@@ -121,6 +129,7 @@ class ActivityPcruInfoFromActivityFactory
            ->setDocumentPath($documentSigned)
            ->setDocumentId($documentId)
            ->setSigleUnite($sigleUnit)
            ->setPartenaires(implode('|', $partners))
            ->setPoleCompetivite($activity->getPcruPoleCompetitiviteStr())
            ->setNumContratTutelleGestionnaire($activity->getOscarNum())
            ->setValidePoleCompetivite($activity->isPcruPolePoleCompetitiviteStr())
Loading