src\Controller\EDIController.php line 42

Open in your IDE?
  1. <?php
  2. namespace App\Controller;
  3. use App\Entity\JOURNAL;
  4. use App\Entity\SAGE\GACCDUDATE;
  5. use App\Entity\SAGE\GACCENTRYA;
  6. use App\Entity\SAGE\GACCENTRY as sageGaccentries;
  7. use App\Entity\SAGE\GACCENTRYD as sageGaccentryd;
  8. use App\Entity\Bpartner;
  9. use App\Entity\Gaccentry as outputGaccentries;
  10. use App\Entity\CompteTier;
  11. use App\Entity\Gaccentryd;
  12. use App\Entity\Genratenum;
  13. use App\Entity\Partenaire;
  14. use Psr\Log\LoggerInterface;
  15. use Doctrine\DBAL\Connection;
  16. use Doctrine\ORM\Query\Expr\Join;
  17. use App\Service\ConnectionService;
  18. use Doctrine\DBAL\Driver\Exception;
  19. use Doctrine\Persistence\ManagerRegistry;
  20. use Symfony\Component\HttpFoundation\Request;
  21. use Symfony\Component\HttpFoundation\Response;
  22. use Symfony\Component\Routing\Annotation\Route;
  23. use Symfony\Component\HttpFoundation\JsonResponse;
  24. use Symfony\Contracts\HttpClient\HttpClientInterface;
  25. use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
  26. class EDIController extends AbstractController
  27. {
  28.     private $em;
  29.     private $client;
  30.     public function __construct(ConnectionService $em,HttpClientInterface $client)
  31.     {
  32.         $this->em $em;
  33.         $this->client $client;
  34.     }
  35.     #[Route('/edi'name'app_edi')]
  36.     public function index(): Response
  37.     {
  38.         return $this->render('edi/index.html.twig', [
  39.             'controller_name' => 'EDIController',
  40.         ]);
  41.     }
  42.     #[Route('/getCodeAdonix'name'app_getCodeAdonix')]
  43.     public function getCodeAdonix(): Response
  44.     {
  45.         $results $this->em->getEntity()->getRepository(outputGaccentries::class)->findByDate(); // Adjust the method to match your repository
  46.         // dd($results);
  47.         foreach ($results as $entry) {
  48.             $num $entry->getNum();
  49.     
  50.             // Use $num in your SQL query
  51.             $searchAdonix $this->em->getSage()->fetchAllAssociative("SELECT REF_0, NUM_0 FROM HCZ.GACCENTRY WHERE REF_0 = '".$num."' ");
  52.             
  53.             if ($searchAdonix) {
  54.                 $entry->setObservationFczFlag6($searchAdonix[0]['NUM_0']);
  55.                 $entry->setFczFlag6(8);
  56.                 $this->em->getEntity()->persist($entry);
  57.                 
  58.             }
  59.         }
  60.         $this->em->getEntity()->flush();
  61.         return new Response('ok');
  62.     }
  63.     #[Route('/sage/accnum'name'app_sage_accnum')]
  64.     public function accnum()
  65.     {
  66.         try {
  67.             $this->em->getInterface()->beginTransaction();
  68.             // Get the last account number (type is used as the account number here)
  69.             $accnum $this->em->getEntity()->getRepository(Genratenum::class)->findLastAccnum();
  70.             // Get the list of pieces to process
  71.             $pieceCaImport $this->em->getEntity()->getRepository(outputGaccentries::class)->findCaAccnum();
  72.         
  73.             // Iterate through each piece in the import
  74.             foreach ($pieceCaImport as $piece) {
  75.                 // dd($piece);
  76.                 $piece->setFczFlag3(1);
  77.                 $Gaccentryds $piece->getGaccentryds();
  78.         
  79.                 foreach ($Gaccentryds as $det) {
  80.                     $accnum++; // Increment account number
  81.                     $det->setPcg($accnum); // Set Pcg with the current account number
  82.                     $accnum++; // Increment account number again
  83.                     $det->setPca($accnum); // Set Pca with the current account number
  84.                 }
  85.             }
  86.         
  87.             $this->em->getEntity()->flush(); // Save all changes to the database
  88.             
  89.             $updateAccnum $this->em->getInterface()->fetchAssociative("UPDATE genratenum SET type = '".$accnum."' WHERE id = 810699");    
  90.             
  91.             $this->em->getInterface()->commit();
  92.     
  93.         } catch (Exception $e) {
  94.                 if ($this->em->getInterface()->isTransactionActive()) {
  95.                     $this->em->getInterface()->rollBack();
  96.                 }
  97.                 
  98.                 return new JsonResponse("Error: " $e->getMessage());
  99.         }
  100.             // return new JsonResponse($accnum);
  101.             return new JsonResponse("ok");
  102.     }
  103.     #[Route('/anomalie'name'app_anomalie')]
  104.     public function anomalie(Request $request): Response
  105.     {
  106.         // Construire la requĂȘte Doctrine pour chercher les anomalies
  107.         $queryBuilder $this->em->getEntity()->createQueryBuilder()
  108.         ->select('g.typ''g.num''g.accdat''g.desvcr''g.observation_fcz_flag6')
  109.         ->from(outputGaccentries::class, 'g')
  110.         ->where('g.fcz_flag6 = 9')
  111.         ->andWhere('g.fczFlag5 = 1')
  112.         ->andWhere('g.fczFlag3 = 0');
  113.         // Execute the main query
  114.         $results $queryBuilder->getQuery()->getResult();
  115.         foreach ($results as &$row) {
  116.             $row['accdat'] = $row['accdat']->format('Y-m-d'); // Adjust format as needed
  117.         }
  118.         // Return the response
  119.         return new JsonResponse($results);
  120.     }
  121.     
  122.     #[Route('/anomalie/observationPiece'name'app_anomalie_observationPiece')]
  123.     public function observationPiece(Request $request): JsonResponse
  124.     {
  125.         $qb $this->em->getEntity()->createQueryBuilder();
  126.         $qb->select('DISTINCT CASE
  127.                                 WHEN o.observation_fcz_flag6 LIKE :date THEN :dateLabel
  128.                                 WHEN o.observation_fcz_flag6 LIKE :fournisseur THEN :fournisseurLabel
  129.                                 WHEN o.observation_fcz_flag6 LIKE :client THEN :clientLabel
  130.                                 WHEN o.observation_fcz_flag6 LIKE :type THEN :typeLabel
  131.                                 WHEN o.observation_fcz_flag6 LIKE :desequilibrees THEN :desequilibreesLabel
  132.                                 WHEN o.observation_fcz_flag6 LIKE :det THEN :detLabel
  133.                                 WHEN o.observation_fcz_flag6 LIKE :acc THEN :cmpLabel
  134.                                 ELSE :otherLabel 
  135.                             END AS Observ')
  136.             ->from('App\Entity\Gaccentry''o')
  137.             ->where('o.fczFlag3 = :fczFlag3')
  138.             ->andWhere('o.fcz_flag6 = :fczFlag6')
  139.             ->andWhere('o.fczFlag5 = :fczFlag2')
  140.             ->setParameter('date''%DATE%')
  141.             ->setParameter('dateLabel''DATE')
  142.             ->setParameter('fournisseur''%FOURNISSEUR%')
  143.             ->setParameter('fournisseurLabel''FOURNISSEUR')
  144.             ->setParameter('client''%CLIENT%')
  145.             ->setParameter('clientLabel''CLIENT')
  146.             ->setParameter('acc''%ACC N EXISTE%')
  147.             ->setParameter('cmpLabel''compte')
  148.             ->setParameter('type''%TYPE%')
  149.             ->setParameter('typeLabel''TYPE')
  150.             ->setParameter('desequilibrees''%DESEQUILIBREES%')
  151.             ->setParameter('desequilibreesLabel''PIECE DESEQUILIBREES')
  152.             ->setParameter('det''%DET%')
  153.             ->setParameter('detLabel''SANS DET')
  154.             ->setParameter('otherLabel''OTHER')
  155.             ->setParameter('fczFlag3'0)
  156.             ->setParameter('fczFlag6'9)
  157.             ->setParameter('fczFlag2'1);
  158.         $observationFlags $qb->getQuery()->getResult();
  159.         $options = [];
  160.         foreach ($observationFlags as $flag) {
  161.             $options[] = $flag['Observ'];
  162.         }
  163.     
  164.         return new JsonResponse($options);
  165.     }
  166.     #[Route('/suivi/returnPiece'name'app_suivi_returnPiece')]
  167.     public function suiviReturnPiece(Request $request): Response
  168.     {
  169.         // Step 1: Retrieve the $num parameter from the query string
  170.         $num $request->query->get('num');
  171.         
  172.         // Step 2: Check if $num is present; return an error if it's missing
  173.         if (!$num) {
  174.             return new JsonResponse(['error' => 'Missing num parameter'], 400);
  175.         }
  176.         // Step 3: Perform the database queries using $num
  177.         $queryBuilderGaccentry $this->em->getEntity()->createQueryBuilder()
  178.             ->select('g.num''g.desvcr''g.accdat''g.observation_fcz_flag6','g.id')
  179.             ->from(outputGaccentries::class, 'g')
  180.             ->where('g.num = :num')
  181.             ->setParameter('num'$num);
  182.         $queryBuilderGaccentryd $this->em->getEntity()->createQueryBuilder()
  183.             ->select('d.typ0''d.cce0''d.acc''d.bpr''d.amtcur''d.acc''d.sns''d.lin''d.id')
  184.             ->from(outputGaccentries::class, 'd')
  185.             ->where('d.num = :num')
  186.             ->setParameter('num'$num);
  187.         // Step 4: Execute the queries
  188.         $outputGaccentry $queryBuilderGaccentry->getQuery()->getResult();
  189.         $outputGaccentryd $queryBuilderGaccentryd->getQuery()->getResult();
  190.         // Step 5: Format the accdat field in the result
  191.         foreach ($outputGaccentry as &$entry) {
  192.             if ($entry['accdat'] instanceof \DateTime) {
  193.                 // Format the DateTime object to 'Y-m-d H:i:s.u' format
  194.                 $entry['accdat'] = $entry['accdat']->format('Y-m-d H:i:s');  // Example: '2024-01-02 00:00:00.0'
  195.             }
  196.         }
  197.         // Step 6: Prepare the data for the response
  198.         $data = [
  199.             'outputGaccentry' => $outputGaccentry,
  200.             'outputGaccentryd' => $outputGaccentryd,
  201.         ];
  202.         // Step 3: Send the formatted data as a JSON response
  203.         return new JsonResponse($data);
  204.     }
  205.     #[Route('/bpsupplier'name'opp_bpsupplier')]
  206.     public function bpsupplier(Request $request): JsonResponse
  207.     {
  208.         $bpsupplierAdonix $this->em->getSage()->fetchAllAssociative("SELECT BPSNUM_0 , ENAFLG_0 FROM HCZ.BPSUPPLIER");
  209.         // Fetching all existing suppliers of type 'SUPPLIER' in one query
  210.         $bPartnerRepository $this->em->getEntity()->getRepository(Bpartner::class);
  211.         $existingSuppliers  $bPartnerRepository->findBy(['type' => 'SUPPLIER']);
  212.         // Creating a map of existing suppliers for fast lookup
  213.         $existingSuppliersMap = [];
  214.         foreach ($existingSuppliers as $supplier) {
  215.             $existingSuppliersMap[$supplier->getPartner()] = $supplier;
  216.         }
  217.         // Processing the bpsupplierAdonix data
  218.         foreach ($bpsupplierAdonix as $bpsupplier) {
  219.             $partner $bpsupplier["BPSNUM_0"];
  220.             $active $bpsupplier["ENAFLG_0"];
  221.             if (isset($existingSuppliersMap[$partner])) {
  222.                 $supplier $existingSuppliersMap[$partner];
  223.                 if ($supplier->getActive() !== $active) {
  224.                     $supplier->setActive($active);
  225.                     $this->em->getEntity()->persist($supplier); // Persist only when there's a change
  226.                 }
  227.             } else {
  228.                 $creationSupplier = new Bpartner();
  229.                 $creationSupplier->setPartner($partner);
  230.                 $creationSupplier->setActive($active);
  231.                 $creationSupplier->setType("SUPPLIER");
  232.                 $this->em->getEntity()->persist($creationSupplier);
  233.             }
  234.         }
  235.         // Flush all changes at once
  236.         $this->em->getEntity()->flush();
  237.         return new JsonResponse(['message' => 'Process supplier completed successfully']);
  238.     }
  239.     #[Route('/bpcustomer'name'app_bpcustomer')]
  240.     public function bpcustomer(Request $request): Response
  241.     {
  242.         $bpcustomerAdonix $this->em->getSage()->fetchAllAssociative("SELECT BPCNUM_0 , BPCSTA_0 FROM HCZ.BPCUSTOMER");
  243.         // Fetching all existing customers of type 'SUPPLIER' in one query
  244.         $bPartnerRepository $this->em->getEntity()->getRepository(Bpartner::class);
  245.         $existingCustomers $bPartnerRepository->findBy(['type' => 'CUSTOMER']);
  246.         // Creating a map of existing customers for fast lookup
  247.         $existingCustomersMap = [];
  248.         foreach ($existingCustomers as $customer) {
  249.             $existingCustomersMap[$customer->getPartner()] = $customer;
  250.         }
  251.         // Processing the bpcustomerAdonix data
  252.         foreach ($bpcustomerAdonix as $bpcustomer) {
  253.             $partner $bpcustomer["BPCNUM_0"];
  254.             $active $bpcustomer["BPCSTA_0"];
  255.             if (isset($existingCustomersMap[$partner])) {
  256.                 $customer $existingCustomersMap[$partner];
  257.                 if ($customer->getActive() !== $active) {
  258.                     $customer->setActive($active);
  259.                     $this->em->getEntity()->persist($customer); // Persist only when there's a change
  260.                 }
  261.             } else {
  262.                 $creationCustomer = new Bpartner();
  263.                 $creationCustomer->setPartner($partner);
  264.                 $creationCustomer->setActive($active);
  265.                 $creationCustomer->setType("CUSTOMER");
  266.                 $this->em->getEntity()->persist($creationCustomer);
  267.             }
  268.         }
  269.         // Flush all changes at once
  270.         $this->em->getEntity()->flush();
  271.         return new JsonResponse(['message' => 'Process customer completed successfully']);
  272.     }
  273.     #[Route('/PieceControle'name'app_PieceControle')]
  274.     public function PieceControle(): Response
  275.     {
  276.         $conditionMet false;
  277.         $Gaccentries  $this->em->getEntity()->getRepository(outputGaccentries::class)->findPieceValid();
  278.         // dd($Gaccentries);
  279.             $sumArray = [];
  280.             foreach ($Gaccentries as $key => $Gac) {
  281.                 // fcz_flag6 = 8 Is Exsit In Table ComptabilitĂ© sage
  282.                 $num $Gac->getNum();
  283.                 $RefCheck $this->em->getSage()->fetchAllAssociative("SELECT REF_0,NUM_0 FROM HCZ.GACCENTRY WHERE REF_0 = '".$num."' ");
  284.                 foreach ($RefCheck as $key => $value) {
  285.                     if ($RefCheck) {
  286.                         $Gac->setObservationFczFlag6($value['NUM_0']);
  287.                         $Gac->setFczFlag6(8);
  288.                         $conditionMet true;
  289.                     }
  290.                 }
  291.             // fcz_flag6 = 4 Is Exsit In dbcom 
  292.                 $NumCheck $this->em->getDbcom()->fetchAllAssociative("SELECT NUM_0,NUMX3_0 FROM YGAS WHERE NUM_0 = '".$num."' ");
  293.                 // dd($NumCheck);
  294.                 foreach ($NumCheck as $key => $value) {
  295.                     if ($NumCheck) {
  296.                         $Gac->setObservationFczFlag6(empty($value['NUMX3_0']) ? $value['NUM_0'] : $Gac->getObservationFczFlag6());
  297.                         $Gac->setFczFlag6(4);
  298.                         $Gac->setFczFlag3(1);
  299.                         $conditionMet true;
  300.                     }
  301.                 }
  302.             // fcz_flag6 = 9 Piece a Probleme 
  303.                 $jouCheck          $Gac->getJou();
  304.                 $matchingJournals  $this->em->getEntity()->getRepository(JOURNAL::class)->findJournal($jouCheck);
  305.                 if (!$matchingJournals) {
  306.                     $Gac->setObservationFczFlag6('JOURNAL N EXISTE PAS DANS SAGE' ' ' $jouCheck);
  307.                     $Gac->setFczFlag6(9);
  308.                     $conditionMet true;
  309.                 } 
  310.                 $cpy1Check    $Gac->getCpy1();
  311.                 $matchingCpy  $this->em->getEntity()->getRepository(Partenaire::class)->findCpy($cpy1Check);
  312.                 if (!$matchingCpy) {
  313.                     $Gac->setObservationFczFlag6('DOSSIER N EXISTE PAS DANS SAGE' ' ' $cpy1Check);
  314.                     $Gac->setFczFlag6(9);
  315.                     $conditionMet true;
  316.                 } 
  317.                 $fcy1Check    $Gac->getFcy1();
  318.                 $matchingFcy  $this->em->getEntity()->getRepository(Partenaire::class)->findFcy($fcy1Check);
  319.                 if (!$matchingFcy) {
  320.                     $Gac->setObservationFczFlag6('SOUS DOSSIER N EXISTE PAS DANS SAGE' ' ' $fcy1Check);
  321.                     $Gac->setFczFlag6(9);
  322.                     $conditionMet true;
  323.                 } 
  324.                 if ($Gac->getCur() != 'MAD') {
  325.                     $Gac->setObservationFczFlag6('DEVISE NON MAD' ' ' $Gac->getCur());
  326.                     $Gac->setFczFlag6(9);
  327.                     $conditionMet true;
  328.                 }
  329.                 
  330.                 $Year = (int) $Gac->getAccdat()->format('Y');
  331.                 // if ($Year < 2023 || $Year > 2025 || $Year == 2023) {
  332.                 if ($Year 2024 || $Year 2025 || $Year == 2024) {
  333.                     $Gac->setObservationFczFlag6('DIFFÉRENCE DE DATE DE 2025');
  334.                     $Gac->setFczFlag6(9);
  335.                     $conditionMet true;
  336.                 }
  337.                 if ($Gac->getDesvcr() && strpos($Gac->getDesvcr(), ';') !== false) {
  338.                     $Gac->setObservationFczFlag6('DÉSIGNATION AVEC POINT-VIRGULE');
  339.                     $Gac->setFczFlag6(9);
  340.                     $conditionMet true;
  341.                 }
  342.                 if ($Gac->getAccdat()->format('Y-m-d H:i:s') !== $Gac->getDuddat()->format('Y-m-d H:i:s') || $Gac->getAccdat()->format('Y-m-d H:i:s') !== $Gac->getRatdat()->format('Y-m-d H:i:s') ) {
  343.                     // dd($Gac->getAccdat(),$Gad->getAccdat());
  344.                     $Gac->setObservationFczFlag6('DIFFÉRENCE DATE');
  345.                     $Gac->setFczFlag6(9);
  346.                     $conditionMet true;
  347.                 }
  348.                 $typCheck $Gac->getTyp1();
  349.                 $sum "0";
  350.                 $matchingType  $this->em->getEntity()->getRepository(JOURNAL::class)->findType($typCheck);
  351.                 if ($matchingType) {
  352.                     $Gaccentryds  $Gac->getGaccentryds();
  353.                     // dd($Gaccentryds);
  354.                     if ($Gaccentryds->isEmpty()) {
  355.                         $Gac->setObservationFczFlag6('PIÈCE SANS DET');
  356.                         $Gac->setFczFlag6(9);
  357.                         $conditionMet true;
  358.                     }else {
  359.                         foreach ($Gaccentryds as $key => $Gad) {
  360.                             // dd($Gad);
  361.                             if ($Gac->getTyp1() !== $Gad->getTyp0()) {
  362.                                 $Gac->setObservationFczFlag6('TYPES NE SONT PAS LES MÊMES' ' ' .$Gac->getTyp1() . ' ' $Gad->getTyp0() );
  363.                                 $Gac->setFczFlag6(9);
  364.                                 $conditionMet true;
  365.                             }
  366.                             if ($Gac->getAccdat()->format('Y-m-d H:i:s') !== $Gad->getAccdat()->format('Y-m-d H:i:s')) {
  367.                                 // dd($Gac->getAccdat(),$Gad->getAccdat());
  368.                                 $Gac->setObservationFczFlag6('DIFFÉRENCE DE 2024');
  369.                                 $Gac->setFczFlag6(9);
  370.                                 $conditionMet true;
  371.                             }
  372.                             
  373.                             // dd("Hi date");
  374.                             if ($Gad->getAmtcur() < 0) {   
  375.                                 $Gac->setObservationFczFlag6('MONTANT NÉGATIF' ' ' $Gad->getAmtcur());
  376.                                 $Gac->setFczFlag6(9);
  377.                                 $conditionMet true;
  378.                             }
  379.                             if ($Gad->getSns() !== && $Gad->getSns() !== -1  ) {
  380.                                 $Gac->setObservationFczFlag6('SENS DIFFÉRENCE DE 1 ET -1' ' ' $Gad->getSns());
  381.                                 $Gac->setFczFlag6(9);
  382.                                 $conditionMet true;
  383.                             }
  384.                             $cceCheck     $Gad->getCce0();
  385.                             $matchingCce  $this->em->getEntity()->getRepository(Partenaire::class)->findCce($cceCheck);
  386.                             if (!$matchingCce) {
  387.                                 $Gac->setObservationFczFlag6('CCE N EXISTE PAS DANS SAGE' ' ' $cceCheck);
  388.                                 $Gac->setFczFlag6(9);
  389.                                 $conditionMet true;
  390.                             } 
  391.                             $accCheck     $Gad->getAcc();
  392.                             $cleanaccCheck str_replace(array("\r""\n"), ''$accCheck);
  393.                             $matchingAcc  $this->em->getEntity()->getRepository(CompteTier::class)->findAccByAcc($cleanaccCheck);
  394.                             if (!$matchingAcc) {
  395.                                 $Gac->setObservationFczFlag6('ACC N EXISTE PAS DANS SAGE' ' ' $Gad->getAcc());
  396.                                 $Gac->setFczFlag6(9);
  397.                                 $conditionMet true;
  398.                             } 
  399.                             foreach ($matchingAcc as $key => $value) {
  400.                                 if ($value['sac'] == '2') {
  401.                                     if (substr($Gad->getAcc(), 01) == '3') {
  402.                                         if ($Gad->getBpr()) {
  403.                                             $customerCheck $Gad->getBpr();
  404.                                             $cleanaccCheckCustomer str_replace(array("\r""\n"), ''$customerCheck);
  405.                                             $matchingCustomer  $this->em->getEntity()->getRepository(Bpartner::class)->findCustomer($cleanaccCheckCustomer);
  406.                                             if (!$matchingCustomer) {
  407.                                                 $Gac->setObservationFczFlag6('CLIENT N EXISTE PAS DANS SAGE ' ' ' $Gad->getBpr());
  408.                                                 $Gac->setFczFlag6(9);
  409.                                                 $conditionMet true;
  410.                                                 // if ($matchingCustomer->getActive() == 1) {
  411.                                                 //     // dd($matchingSupplier);
  412.                                                 //     $Gac->setObservationFczFlag6('CUSTOMER NOT ACTIVE IN SAGE' . ' ' . $Gad->getBpr());
  413.                                                 //     $Gac->setFczFlag6(9);
  414.                                                 //     $conditionMet = true;
  415.                                                 // }
  416.                                                 
  417.                                             }
  418.                                             elseif ($matchingCustomer?->getActive() === 1) {
  419.                                                 // dd($matchingCustomer);
  420.                                                 $Gac->setObservationFczFlag6('CLIENT NON ACTIF DANS SAGE' ' ' $Gad->getBpr());
  421.                                                 $Gac->setFczFlag6(9);
  422.                                                 $conditionMet true;
  423.                                             }
  424.                                         }else {
  425.                                             $Gac->setObservationFczFlag6('COMPTE CLIENT COLLECTIF SANS TIER' ' ' $Gad->getAcc());
  426.                                             $Gac->setFczFlag6(9);
  427.                                             $conditionMet true;
  428.                                         }
  429.                                     }if (substr($Gad->getAcc(), 01) == '4') {
  430.                                         if ($Gad->getBpr()) {
  431.                                             $supplierCheck    $Gad->getBpr();
  432.                                             $cleanaccCheckSupplier str_replace(array("\r""\n"), ''$supplierCheck);
  433.                                             $matchingSupplier $this->em->getEntity()->getRepository(Bpartner::class)->findSupplier($cleanaccCheckSupplier);
  434.                                             if (!$matchingSupplier) {
  435.                                                 $Gac->setObservationFczFlag6('FOURNISSEUR N EXISTE PAS DANS SAGE' ' ' $Gad->getBpr());
  436.                                                 $Gac->setFczFlag6(9);
  437.                                                 $conditionMet true;
  438.                                             }
  439.                                             elseif ($matchingSupplier->getActive() == 1) {
  440.                                                 $Gac->setObservationFczFlag6('FOURNISSEUR NON ACTIF DANS SAGE' ' ' $Gad->getBpr());
  441.                                                 $Gac->setFczFlag6(9);
  442.                                                 $conditionMet true;
  443.                                             }
  444.                                             //     dd($matchingSupplier);
  445.                                             // if ($matchingSupplier->getActive() == 1) {
  446.                                             //     // dd($matchingSupplier);
  447.                                             //     $Gac->setObservationFczFlag6('SUPPLIER NOT ACTIVE IN SAGE' . ' ' . $Gad->getBpr());
  448.                                             //     $Gac->setFczFlag6(9);
  449.                                             //     $conditionMet = true;
  450.                                             // }
  451.                                             // elseif($matchingSupplier->getActive() == null) {
  452.                                             //     $Gac->setObservationFczFlag6('SUPPLIER IS NUL' . ' ' . $Gad->getBpr());
  453.                                             //     $Gac->setFczFlag6(9);
  454.                                             //     $conditionMet = true;
  455.                                             // }
  456.                                         }else {
  457.                                             $Gac->setObservationFczFlag6('COMPTE FOURNISSEUR COLLECTIF SANS TIER' ' ' $Gad->getAcc());
  458.                                             $Gac->setFczFlag6(9);
  459.                                             $conditionMet true;
  460.                                         }
  461.                                     }
  462.                                 }
  463.                                 $all_acc substr($Gad->getAcc(), 01);
  464.                                 if ($all_acc == '5' || $all_acc == '6' || $all_acc == '7' || $all_acc == '2' || $all_acc == '1') {
  465.                                     if ($Gad->getBpr()) {
  466.                                         // dd($Gac->getBpr());
  467.                                         $Gac->setObservationFczFlag6('COMPTE' $Gad->getAcc() . 'AVEC TIER ' $Gad->getBpr());
  468.                                         $Gac->setFczFlag6(9);
  469.                                         $conditionMet true;
  470.                                     }
  471.                                 }
  472.                                 // if ($all_acc == '7' || $all_acc == '2' || $all_acc == '1') {
  473.                                 //     if ($Gad->getBpr()) {
  474.                                 //         $Gac->setObservationFczFlag6('ACC ' . $Gad->getAcc() . ' HAS TIER '. $Gad->getBpr());
  475.                                 //         $Gac->setFczFlag6(9);
  476.                                 //         $conditionMet = true;
  477.                                 //     }
  478.                                 // }
  479.                             }
  480.                             // $amtcur = round($Gad->getAmtcur(), 2);
  481.                             // if ($Gad->getSns() === -1) {
  482.                             //     $amtcur = -$amtcur;
  483.                             // }
  484.                         
  485.                             // $sum += $amtcur;
  486.                             // $amtcurFormatted = number_format($amtcur, 2, '.', ''); // Format as a number with two decimal places.
  487.                             // array_push($sumArray, $amtcurFormatted);
  488.                             $amtcur $Gad->getAmtcur();
  489.                             $sens $Gad->getSns();
  490.             
  491.                             $montant =$amtcur $sens;
  492.                             $sum += $montant;
  493.                         }
  494.                 }
  495.                 $finalBalance round($sum2); // Round to 2 decimal places for final balance
  496.                     if ($finalBalance != || $finalBalance != -) {
  497.                         $Gac->setObservationFczFlag6('PIECE DESEQUILIBREES' ' ' $finalBalance);
  498.                         $Gac->setFczFlag6(9);
  499.                         $conditionMet true;
  500.                     }
  501.                 }else {
  502.                     $Gac->setObservationFczFlag6('TYPE DOES NOT EXIST' ' ' $typCheck);
  503.                     $Gac->setFczFlag6(9);
  504.                     $conditionMet true;
  505.                 }
  506.                 // fcz_flag6 = 2 Piece Sans Probleme 
  507.                 if (!$conditionMet) {
  508.                     $Gac->setObservationFczFlag6('CONTROLLE DONE');
  509.                     $Gac->setFczFlag6(2);
  510.                 }
  511.                 $this->em->getEntity()->persist($Gac);
  512.             }
  513.             $this->em->getEntity()->flush();
  514.         return new Response('ok');
  515.     }
  516.     #[Route('/sage/inserted'name'app_sage_inserted')]
  517.     public function inserted()
  518.     {
  519.         try {
  520.             $this->em->getSage()->beginTransaction();
  521.             $this->em->getInterface()->beginTransaction();
  522.             $pieceCaImport $this->em->getEntity()->getRepository(outputGaccentries::class)->findCAUgouv();
  523.             // dd($pieceCaImport);
  524.             if ($pieceCaImport) {
  525.                 foreach ($pieceCaImport as $piece) {
  526.                     $piece->setFczFlag5(1);
  527.                     $piece->setFczFlag3(1);
  528.                     $piece->setFczFlag6(2);
  529.                     $adonixGaccentry = new sageGaccentries();
  530.                         $adonixGaccentry->setUPDTICK0("1");
  531.                         $adonixGaccentry->setTYP0($piece->getTyp());
  532.                         $adonixGaccentry->setNUM0($piece->getNum());
  533.                         $adonixGaccentry->setCPY0($piece->getCpy1());
  534.                         $adonixGaccentry->setFCY0($piece->getFcy1());
  535.                         $adonixGaccentry->setJOU0($piece->getJou());
  536.                         $adonixGaccentry->setFIY0(11);
  537.                         $adonixGaccentry->setPER0(12);
  538.                         $adonixGaccentry->setBOLLATO0('');
  539.                         $adonixGaccentry->setYREFE30('');
  540.                         $adonixGaccentry->setYREFE20('');
  541.                         $adonixGaccentry->setYREFE10('');
  542.                         $adonixGaccentry->setYREFE0($piece->getId());
  543.                         $adonixGaccentry->setACCDAT0($this->dateString($piece->getAccdat()));
  544.                         $adonixGaccentry->setENTDAT0($this->dateString($piece->getAccdat()));
  545.                         $adonixGaccentry->setVALDAT0($this->dateString($piece->getAccdat()));
  546.                         $adonixGaccentry->setDUDDAT0($this->dateString($piece->getAccdat()));
  547.                         $adonixGaccentry->setBANDAT0($this->dateString($piece->getAccdat()));
  548.                         $adonixGaccentry->setRATDAT0($this->dateString($piece->getAccdat()));
  549.                         $adonixGaccentry->setCAT0(1);
  550.                         $adonixGaccentry->setSTA0(1);
  551.                         $adonixGaccentry->setFNLPSTDAT0('1753-01-01 00:00:00.000');
  552.                         $adonixGaccentry->setORIMOD0(2);
  553.                         $adonixGaccentry->setDACDIA0('STDCO');
  554.                         $adonixGaccentry->setFLGDAS0(1);
  555.                         $adonixGaccentry->setFLGFUP0(1);
  556.                         $adonixGaccentry->setFLGPAZ0(4);
  557.                         $adonixGaccentry->setFLGREP0(1);
  558.                         $adonixGaccentry->setFLGGEN0(1);
  559.                         $adonixGaccentry->setTYPDUD0(2);
  560.                         $adonixGaccentry->setBANCIB0('');
  561.                         $adonixGaccentry->setCUR0('MAD');
  562.                         $adonixGaccentry->setTYPRAT0(1);
  563.                         $adonixGaccentry->setLED0('RFG');
  564.                         $adonixGaccentry->setLED1('RFA');
  565.                         $adonixGaccentry->setLED2('');
  566.                         $adonixGaccentry->setLED3('');
  567.                         $adonixGaccentry->setLED4('');
  568.                         $adonixGaccentry->setLED5('');
  569.                         $adonixGaccentry->setLED6('');
  570.                         $adonixGaccentry->setLED7('');
  571.                         $adonixGaccentry->setLED8('');
  572.                         $adonixGaccentry->setLED9('');
  573.                         $adonixGaccentry->setCURLED0('MAD');
  574.                         $adonixGaccentry->setCURLED1('MAD');
  575.                         $adonixGaccentry->setCURLED2('');
  576.                         $adonixGaccentry->setCURLED3('');
  577.                         $adonixGaccentry->setCURLED4('');
  578.                         $adonixGaccentry->setCURLED5('');
  579.                         $adonixGaccentry->setCURLED6('');
  580.                         $adonixGaccentry->setCURLED7('');
  581.                         $adonixGaccentry->setCURLED8('');
  582.                         $adonixGaccentry->setCURLED9('');
  583.                         $adonixGaccentry->setRATMLT0(1);
  584.                         $adonixGaccentry->setRATMLT1(0);
  585.                         $adonixGaccentry->setRATMLT2(0);
  586.                         $adonixGaccentry->setRATMLT3(0);
  587.                         $adonixGaccentry->setRATMLT4(0);
  588.                         $adonixGaccentry->setRATMLT5(0);
  589.                         $adonixGaccentry->setRATMLT6(0);
  590.                         $adonixGaccentry->setRATMLT7(0);
  591.                         $adonixGaccentry->setRATMLT8(0);
  592.                         $adonixGaccentry->setRATMLT9(0);
  593.                         $adonixGaccentry->setRATDIV0(1);
  594.                         $adonixGaccentry->setRATDIV1(0);
  595.                         $adonixGaccentry->setRATDIV2(0);
  596.                         $adonixGaccentry->setRATDIV3(0);
  597.                         $adonixGaccentry->setRATDIV4(0);
  598.                         $adonixGaccentry->setRATDIV5(0);
  599.                         $adonixGaccentry->setRATDIV6(0);
  600.                         $adonixGaccentry->setRATDIV7(0);
  601.                         $adonixGaccentry->setRATDIV8(0);
  602.                         $adonixGaccentry->setRATDIV9(0);
  603.                         $adonixGaccentry->setDESVCR0($piece->getDesvcr());
  604.                         $adonixGaccentry->setREF0($piece->getRef());
  605.                         $adonixGaccentry->setBPRVCR0('');
  606.                         $adonixGaccentry->setBPRDATVCR0('1753-01-01 00:00:00.000');
  607.                         $adonixGaccentry->setREFSIM0('');
  608.                         $adonixGaccentry->setREFINT0('');
  609.                         $adonixGaccentry->setNUMDCL0(0);
  610.                         $adonixGaccentry->setRVS0(0);
  611.                         $adonixGaccentry->setRVSDAT0('1753-01-01 00:00:00.000');
  612.                         $adonixGaccentry->setRVSORITYP0('');
  613.                         $adonixGaccentry->setRVSORINUM0('');
  614.                         $adonixGaccentry->setEXPNUM0(1);
  615.                         $adonixGaccentry->setCREDAT0((new \DateTime())->format('Y-m-d'));
  616.                         $adonixGaccentry->setCREUSR0('AHAZ');
  617.                         $adonixGaccentry->setUPDDAT0((new \DateTime())->format('Y-m-d'));
  618.                         $adonixGaccentry->setUPDUSR0('AHAZ');
  619.                         $adonixGaccentry->setORIGIN0(3);
  620.                         $adonixGaccentry->setCREDATTIM0((new \DateTime())->format('Y-m-d H:i:s'));  // For current date and time
  621.                         $adonixGaccentry->setUPDDATTIM0((new \DateTime())->format('Y-m-d H:i:s'));
  622.                         $adonixGaccentry->setAUUID0('xxxx');
  623.                         $adonixGaccentry->setFNLPSTNUM0('');
  624.                         $adonixGaccentry->setFNLPSTNUM1('');
  625.                         $adonixGaccentry->setFNLPSTNUM2('');
  626.                         $adonixGaccentry->setFNLPSTNUM3('');
  627.                         $adonixGaccentry->setFNLPSTNUM4('');
  628.                         $adonixGaccentry->setFNLPSTNUM5('');
  629.                         $adonixGaccentry->setFNLPSTNUM6('');
  630.                         $adonixGaccentry->setFNLPSTNUM7('');
  631.                         $adonixGaccentry->setFNLPSTNUM8('');
  632.                         $adonixGaccentry->setFNLPSTNUM9('');
  633.                         $adonixGaccentry->setPJT0('');
  634.                         $adonixGaccentry->setORICOD0("YGASANA");
  635.                         $adonixGaccentry->setYPCNUM0($piece->getCode());
  636.                         $adonixGaccentry->setYFLG0(0);
  637.                     $this->em->getAdonix()->persist($adonixGaccentry);
  638.                     
  639.                     foreach ($piece->getGaccentryds() as $key => $det) {
  640.                         $adonixGaccentrydPcg = new sageGaccentryd();
  641.                             $adonixGaccentrydPcg->setUPDTICK0(1);
  642.                             $adonixGaccentrydPcg->setTYP0($det->getTyp0());
  643.                             $adonixGaccentrydPcg->setNUM0($det->getNum());
  644.                             $adonixGaccentrydPcg->setLIN0($det->getLin());
  645.                             $adonixGaccentrydPcg->setLEDTYP0(1);
  646.                             $adonixGaccentrydPcg->setLED0('RFG');
  647.                             $adonixGaccentrydPcg->setACCNUM0($det->getPcg());
  648.                             $adonixGaccentrydPcg->setCHRNUM0('');
  649.                             $adonixGaccentrydPcg->setIDTLIN0($det->getLin());
  650.                             $adonixGaccentrydPcg->setCPY0($piece->getCpy1());
  651.                             $adonixGaccentrydPcg->setFCYLIN0($piece->getFcy1());
  652.                             $adonixGaccentrydPcg->setACCDAT0($this->dateString($piece->getAccdat()));
  653.                             $adonixGaccentrydPcg->setFIY0(11);
  654.                             $adonixGaccentrydPcg->setPER0(12);
  655.                             $adonixGaccentrydPcg->setCOA0('PCG');
  656.                             $adonixGaccentrydPcg->setSAC0($det->getSac() ?? '');
  657.                             $adonixGaccentrydPcg->setACC0($det->getAcc());
  658.                             $adonixGaccentrydPcg->setBPR0($det->getBpr() ?? '');
  659.                             $adonixGaccentrydPcg->setDSP0('');
  660.                             $adonixGaccentrydPcg->setSNS0($det->getSns());
  661.                             $adonixGaccentrydPcg->setCUR0('MAD');
  662.                             $adonixGaccentrydPcg->setAMTCUR0($det->getamtcur());
  663.                             $adonixGaccentrydPcg->setCURLED0('MAD');
  664.                             $adonixGaccentrydPcg->setAMTLED0($det->getamtcur());
  665.                             $adonixGaccentrydPcg->setAMTFLG0(0);
  666.                             $adonixGaccentrydPcg->setAMTLED10(0);
  667.                             $adonixGaccentrydPcg->setUOM0('');
  668.                             $adonixGaccentrydPcg->setQTY0(1);
  669.                             $adonixGaccentrydPcg->setDES0($det->getDes());
  670.                             $adonixGaccentrydPcg->setREFINTLIN0('');
  671.                             $adonixGaccentrydPcg->setOFFACC0('');
  672.                             $adonixGaccentrydPcg->setCSLCOD0('');
  673.                             $adonixGaccentrydPcg->setCSLFLO0('');
  674.                             $adonixGaccentrydPcg->setSTT10('');
  675.                             $adonixGaccentrydPcg->setSTT20('');
  676.                             $adonixGaccentrydPcg->setSTT30('');
  677.                             $adonixGaccentrydPcg->setMTC0('');
  678.                             $adonixGaccentrydPcg->setMTCDAT0('1753-01-01 00:00:00');
  679.                             $adonixGaccentrydPcg->setMTCDATMIN0('1753-01-01 00:00:00');
  680.                             $adonixGaccentrydPcg->setMTCDATMAX0('1753-01-01 00:00:00');
  681.                             $adonixGaccentrydPcg->setFLGMTC0(0);
  682.                             $adonixGaccentrydPcg->setFREREF0($det->getFreref0() ?? '');
  683.                             $adonixGaccentrydPcg->setCHK0('');
  684.                             $adonixGaccentrydPcg->setCHKDAT0('1753-01-01 00:00:00');
  685.                             $adonixGaccentrydPcg->setMRK0('');
  686.                             $adonixGaccentrydPcg->setTAX0('');
  687.                             $adonixGaccentrydPcg->setTAX20('');
  688.                             $adonixGaccentrydPcg->setTAX30('');
  689.                             $adonixGaccentrydPcg->setAMTVAT0(0);
  690.                             $adonixGaccentrydPcg->setINDEDVAT0(0);
  691.                             $adonixGaccentrydPcg->setEXPNUM0(1);
  692.                             $adonixGaccentrydPcg->setACCNUMORI0(0);
  693.                             $adonixGaccentrydPcg->setACCNUMDOE0(0);
  694.                             $adonixGaccentrydPcg->setCAPFLOTYP0('');
  695.                             $adonixGaccentrydPcg->setVATRAT0(0);
  696.                             $adonixGaccentrydPcg->setVATDEDRAT0(0);
  697.                             $adonixGaccentrydPcg->setCREDATTIM0((new \DateTime())->format('Y-m-d H:i:s'));
  698.                             $adonixGaccentrydPcg->setUPDDATTIM0((new \DateTime())->format('Y-m-d H:i:s'));
  699.                             $adonixGaccentrydPcg->setAUUID0(0xE52EA92BB5832);
  700.                             $adonixGaccentrydPcg->setCREUSR0('AHAZ');
  701.                             $adonixGaccentrydPcg->setUPDUSR0('AHAZ');
  702.                             $adonixGaccentrydPcg->setCSLBPR0('');
  703.                             $adonixGaccentrydPcg->setPJTLIN0('');
  704.                             $adonixGaccentrydPcg->setPCCCOD0('');
  705.                             $adonixGaccentrydPcg->setBSITRS0('');
  706.                             $adonixGaccentrydPcg->setYLETTR0('');
  707.                             $adonixGaccentrydPcg->setYBPCANC0('');
  708.                             $adonixGaccentrydPcg->setYREFE0($piece->getId());
  709.                             $adonixGaccentrydPcg->setYREFE10($det->getId());
  710.                             $adonixGaccentrydPcg->setYREFE20('');
  711.                             $adonixGaccentrydPcg->setYREFE30($det->getFczAccLibelle() ?? '');
  712.                             $adonixGaccentrydPcg->setAMTCURHIS0(0);
  713.                             $adonixGaccentrydPcg->setHISACC0($det->getAcc());
  714.                         $this->em->getAdonix()->persist($adonixGaccentrydPcg);
  715.                         $adonixGaccentrydPca = clone $adonixGaccentrydPcg;
  716.                             $adonixGaccentrydPca->setBPR0('');
  717.                             $adonixGaccentrydPca->setSAC0('');
  718.                             $adonixGaccentrydPca->setLED0('RFA');
  719.                             $adonixGaccentrydPca->setCOA0('PCA');
  720.                             $adonixGaccentrydPca->setACCNUM0($det->getPca());
  721.                             $adonixGaccentrydPca->setLEDTYP0(2);
  722.                         $this->em->getAdonix()->persist($adonixGaccentrydPca);
  723.                         $adonixGaccentrya = new GACCENTRYA();
  724.                             $adonixGaccentrya->setUPDTICK0(1);
  725.                             $adonixGaccentrya->setTYP0($det->getTyp0());
  726.                             $adonixGaccentrya->setNUM0($det->getNum());
  727.                             $adonixGaccentrya->setLIN0($det->getLin());
  728.                             $adonixGaccentrya->setLEDTYP0(2);
  729.                             $adonixGaccentrya->setANALIN0(1);
  730.                             $adonixGaccentrya->setIDTLIN0($det->getLin());
  731.                             $adonixGaccentrya->setLED0('RFA');
  732.                             $adonixGaccentrya->setCPY0($piece->getCpy1());
  733.                             $adonixGaccentrya->setFCYLIN0($piece->getFcy1());
  734.                             $adonixGaccentrya->setACCDAT0($this->dateString($piece->getAccdat()));
  735.                             $adonixGaccentrya->setACCNUM0($det->getPca());
  736.                             $adonixGaccentrya->setCOA0('PCA');
  737.                             $adonixGaccentrya->setACC0($det->getAcc());
  738.                             $adonixGaccentrya->setBPR0('');
  739.                             $adonixGaccentrya->setDIE0('CCT');
  740.                             $adonixGaccentrya->setDIE1('');
  741.                             $adonixGaccentrya->setDIE2('');
  742.                             $adonixGaccentrya->setDIE3('');
  743.                             $adonixGaccentrya->setDIE4('');
  744.                             $adonixGaccentrya->setDIE5('');
  745.                             $adonixGaccentrya->setDIE6('');
  746.                             $adonixGaccentrya->setDIE7('');
  747.                             $adonixGaccentrya->setDIE8('');
  748.                             $adonixGaccentrya->setCCE0($det->getcce0());
  749.                             $adonixGaccentrya->setCCE1('');
  750.                             $adonixGaccentrya->setCCE2('');
  751.                             $adonixGaccentrya->setCCE3('');
  752.                             $adonixGaccentrya->setCCE4('');
  753.                             $adonixGaccentrya->setCCE5('');
  754.                             $adonixGaccentrya->setCCE6('');
  755.                             $adonixGaccentrya->setCCE7('');
  756.                             $adonixGaccentrya->setCCE8('');
  757.                             $adonixGaccentrya->setSNS0($det->getSns());
  758.                             $adonixGaccentrya->setCUR0('MAD');
  759.                             $adonixGaccentrya->setAMTCUR0($det->getamtcur());
  760.                             $adonixGaccentrya->setCURLED0('MAD');
  761.                             $adonixGaccentrya->setAMTLED0($det->getamtcur());
  762.                             $adonixGaccentrya->setUOM0('');
  763.                             $adonixGaccentrya->setQTY0(0);
  764.                             $adonixGaccentrya->setACCNUMDOE0(0);
  765.                             $adonixGaccentrya->setCREDATTIM0((new \DateTime())->format('Y-m-d H:i:s'));
  766.                             $adonixGaccentrya->setUPDDATTIM0((new \DateTime())->format('Y-m-d H:i:s'));
  767.                             $adonixGaccentrya->setAUUID0(0xE52EA92BB5832);
  768.                             $adonixGaccentrya->setCREUSR0('ADMIN');
  769.                             $adonixGaccentrya->setUPDUSR0('ADMIN');
  770.                             $adonixGaccentrya->setYREFE0(0);
  771.                             $adonixGaccentrya->setYREFE10(0);
  772.                             $adonixGaccentrya->setYREFE20('');
  773.                             $adonixGaccentrya->setYREFE30('');
  774.                             $adonixGaccentrya->setAMTCURHIS0(0);
  775.                             $adonixGaccentrya->setHISACC0('');
  776.                         $this->em->getAdonix()->persist($adonixGaccentrya);
  777.                         if (!empty($det->getBpr())) {
  778.                             $ACCNUM1 $det->getPcg();
  779.                             $A7 "1";
  780.                             $NUMDUD_0 $ACCNUM1 '/' $A7;
  781.                             $adonixGaccdudate = new GACCDUDATE();
  782.                                 $adonixGaccdudate->setUPDTICK0(1);
  783.                                 $adonixGaccdudate->setTYP0($det->getTyp0());
  784.                                 $adonixGaccdudate->setNUM0($det->getNum());
  785.                                 $adonixGaccdudate->setLIG0($det->getLin());
  786.                                 $adonixGaccdudate->setDUDLIG0(1);
  787.                                 $adonixGaccdudate->setACCNUM0($det->getPcg());
  788.                                 $adonixGaccdudate->setCPY0($piece->getCpy1());
  789.                                 $adonixGaccdudate->setFCY0($piece->getFcy1());
  790.                                 $adonixGaccdudate->setCUR0('MAD');
  791.                                 $adonixGaccdudate->setSAC0($det->getSac());
  792.                                 $adonixGaccdudate->setBPR0($det->getBpr());
  793.                                 $adonixGaccdudate->setBPRTYP0(2);
  794.                                 $adonixGaccdudate->setBPRPAY0($det->getBpr());
  795.                                 $adonixGaccdudate->setBPAPAY0('A01');
  796.                                 $adonixGaccdudate->setDUDDAT0($this->dateString($piece->getAccdat()));
  797.                                 $adonixGaccdudate->setPAM0('CHQ');
  798.                                 $adonixGaccdudate->setPAMTYP0(1);
  799.                                 $adonixGaccdudate->setDEP0('');
  800.                                 $adonixGaccdudate->setSNS0($det->getSns());
  801.                                 $adonixGaccdudate->setAMTCUR0($det->getAmtcur());
  802.                                 $adonixGaccdudate->setAMTLOC0($det->getAmtcur());
  803.                                 $adonixGaccdudate->setPAYCUR0(0);
  804.                                 $adonixGaccdudate->setPAYLOC0(0);
  805.                                 $adonixGaccdudate->setTMPCUR0(0);
  806.                                 $adonixGaccdudate->setTMPLOC0(0);
  807.                                 $adonixGaccdudate->setFLGFUP0(0);
  808.                                 $adonixGaccdudate->setLEVFUP0(0);
  809.                                 $adonixGaccdudate->setDATFUP0('1753-01-01 00:00:00');
  810.                                 $adonixGaccdudate->setDPTCOD0('');
  811.                                 $adonixGaccdudate->setFLGPAZ0(4);
  812.                                 $adonixGaccdudate->setSOI0(1);
  813.                                 $adonixGaccdudate->setSOINUM0('');
  814.                                 $adonixGaccdudate->setDUDSTA0(2);
  815.                                 $adonixGaccdudate->setDINAMT0(0);
  816.                                 $adonixGaccdudate->setIBDAMT0(0);
  817.                                 $adonixGaccdudate->setVAT0(0);
  818.                                 $adonixGaccdudate->setFIY0(11);
  819.                                 $adonixGaccdudate->setPER0(12);
  820.                                 $adonixGaccdudate->setEXPSENDAT0('1753-01-01 00:00:00');
  821.                                 $adonixGaccdudate->setSENDAT0('1753-01-01 00:00:00');
  822.                                 $adonixGaccdudate->setSENINS0(0);
  823.                                 $adonixGaccdudate->setBPRFCT0('');
  824.                                 $adonixGaccdudate->setFCTVCR0('');
  825.                                 $adonixGaccdudate->setFLGCLE0(1);
  826.                                 $adonixGaccdudate->setPAYDAT0('1753-01-01 00:00:00');
  827.                                 $adonixGaccdudate->setTYPDUD0(3);
  828.                                 $adonixGaccdudate->setNUMDUD0($NUMDUD_0);
  829.                                 $adonixGaccdudate->setCREDAT0((new \DateTime())->format('Y-m-d'));
  830.                                 $adonixGaccdudate->setCREUSR0('AHAZ');
  831.                                 $adonixGaccdudate->setCREDATTIM0((new \DateTime())->format('Y-m-d H:i:s'));
  832.                                 $adonixGaccdudate->setUPDDATTIM0((new \DateTime())->format('Y-m-d H:i:s'));
  833.                                 $adonixGaccdudate->setAUUID0(0x2648915EB8E78C5937A2);
  834.                                 $adonixGaccdudate->setUPDUSR0('AHAZ');
  835.                                 $adonixGaccdudate->setUMRNUM0('');
  836.                                 $adonixGaccdudate->setBELVCS0('');
  837.                                 $adonixGaccdudate->setBIDNUMMAN0('');
  838.                                 $adonixGaccdudate->setBADBTRULE0(0);
  839.                                 $adonixGaccdudate->setYREFE0(0);
  840.                                 $adonixGaccdudate->setYREFE10(0);
  841.                                 $adonixGaccdudate->setYREFE20('');
  842.                                 $adonixGaccdudate->setYREFE30('');
  843.                                 $adonixGaccdudate->setAMTCURHIS0(0);
  844.                                 $adonixGaccdudate->setHISACC0('');
  845.                             $this->em->getAdonix()->persist($adonixGaccdudate);
  846.                         }else {
  847.                             continue;
  848.                         }
  849.                     }
  850.                 }
  851.             }
  852.             $this->em->getAdonix()->flush();
  853.             $this->em->getEntity()->flush();
  854.             $this->em->getInterface()->commit();
  855.         } catch (Exception $e) {
  856.             $this->em->getInterface()->rollBack();
  857.             return new JsonResponse("Error: " $e->getMessage());
  858.         }
  859.         return new JsonResponse('ok');
  860.     }
  861.     function dateString($date){
  862.                 
  863.         if($date)
  864.             if ($date->format('Y') == '-0001' )  return '';
  865.             else return $date->format('Y-m-d') ;
  866.         else return '';
  867.     }
  868. }