Commit fa7ce658 by Julien Jorry

Fix import : fix adherent import : can update from adherent import if needed + fix some errors

parent ac119167
......@@ -130,12 +130,10 @@ class IndexController extends AbstractController
$siege = $form['siege']->getData();
$user = $form['user']->getData();
$groupe = $form['groupe']->getData();
$comptoir = $form['comptoir']->getData();
$configs = $form['config']->getData();
$iban = $form['iban']->getData();
$website = $form['website']->getData();
$groupe->setSiege($siege);
$comptoir->setGroupe($groupe);
//Création du prestataire recevant les cotisations
$presta = new Prestataire();
......@@ -203,17 +201,28 @@ class IndexController extends AbstractController
$this->em->persist($account);
$this->em->persist($groupe);
}
$comptoirData = $form['comptoir']->getData();
$comptoirName = $comptoirData['name'];
$comptoirCompte = $comptoirData['compte'];
$comptoirGeoloc = $comptoirData['geoloc'];
if (!empty($comptoir)) {
$comptoir = new Comptoir();
$comptoir->setName($comptoirName);
$comptoir->setEnabled(true);
$comptoir->setGeoloc($comptoirGeoloc);
$comptoir->setGroupe($groupe);
$this->em->persist($comptoir);
if (null == $comptoir->getAccountWithCurrency(CurrencyEnum::CURRENCY_MLC)) {
$account = new AccountComptoir();
$account
->setBalance($comptoir->getCompte())
->setBalance(empty($comptoirCompte) ? $comptoirCompte : 0)
->setCurrency(CurrencyEnum::CURRENCY_MLC)
;
$comptoir->addAccount($account);
$this->em->persist($account);
$this->em->persist($comptoir);
}
}
$this->userManager->updateUser($user);
$this->em->persist($presta);
if (null == $presta->getAccountWithCurrency(CurrencyEnum::CURRENCY_EMLC)) {
......
......@@ -57,4 +57,9 @@ class AccountAdherent extends Account
{
return $this->getAdherent();
}
public function __toString(): string
{
return 'AccountAdherent '.$this->getAdherent();
}
}
......@@ -14,6 +14,7 @@ use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\ORM\Mapping as ORM;
use Gedmo\Timestampable\Traits\TimestampableEntity;
use Ramsey\Uuid\Doctrine\UuidGenerator;
use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
use Symfony\Component\Serializer\Annotation\Groups;
use Symfony\Component\Serializer\Annotation\MaxDepth;
......@@ -32,6 +33,7 @@ use Symfony\Component\Serializer\Annotation\MaxDepth;
* denormalizationContext={"groups"={"write"}}
* )
* @ORM\Entity(repositoryClass="App\Repository\ComptoirRepository")
* @UniqueEntity(fields="slug", message="Name or Slug is already taken.")
* @ORM\HasLifecycleCallbacks()
* @ORM\Table(name="comptoir")
*/
......
......@@ -23,7 +23,7 @@ use Symfony\Component\Serializer\Annotation\Groups;
* TRANSACTION
* - Cotisation d'un adhérent.
*
* @ORM\Entity
* @ORM\Entity(repositoryClass="App\Repository\CotisationRepository")
*/
class CotisationAdherent extends Cotisation
{
......
......@@ -20,7 +20,7 @@ trait HasCompteEntity
/**
* @return int
*/
public function getCompte(): float
public function getCompte(): ?float
{
return $this->compte;
}
......@@ -30,7 +30,7 @@ trait HasCompteEntity
*
* @return $this
*/
public function setCompte(float $compte)
public function setCompte(?float $compte)
{
$this->compte = $compte;
......
......@@ -13,6 +13,7 @@ use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\ORM\Mapping as ORM;
use Gedmo\Timestampable\Traits\TimestampableEntity;
use Ramsey\Uuid\Doctrine\UuidGenerator;
use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
use Symfony\Component\Serializer\Annotation\Groups;
use Symfony\Component\Serializer\Annotation\MaxDepth;
......@@ -31,6 +32,7 @@ use Symfony\Component\Serializer\Annotation\MaxDepth;
* denormalizationContext={"groups"={"write"}}
* )
* @ORM\Entity
* @UniqueEntity(fields="slug", message="Name or Slug is already taken.")
* @ORM\Table(name="groupe")
* @ORM\HasLifecycleCallbacks()
*/
......
......@@ -12,6 +12,7 @@ use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\ORM\Mapping as ORM;
use Gedmo\Timestampable\Traits\TimestampableEntity;
use Ramsey\Uuid\Doctrine\UuidGenerator;
use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
use Symfony\Component\Serializer\Annotation\Groups;
use Symfony\Component\Validator\Constraints as Assert;
......@@ -30,6 +31,7 @@ use Symfony\Component\Validator\Constraints as Assert;
* denormalizationContext={"groups"={"write"}}
* )
* @ORM\Entity(repositoryClass="App\Repository\GroupeprestataireRepository")
* @UniqueEntity(fields="slug", message="Name or Slug is already taken.")
* @ORM\Table(name="groupeprestaire")
*/
class Groupeprestataire
......
......@@ -14,6 +14,7 @@ use Gedmo\Mapping\Annotation as Gedmo;
use Gedmo\Timestampable\Traits\TimestampableEntity;
use Ramsey\Uuid\Doctrine\UuidGenerator;
use SpecShaper\GdprBundle\Validator\Constraints as GdprAssert;
use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
use Symfony\Component\Serializer\Annotation\Groups;
use Symfony\Component\Validator\Constraints as Assert;
......@@ -32,6 +33,7 @@ use Symfony\Component\Validator\Constraints as Assert;
* denormalizationContext={"groups"={"write"}}
* )
* @ORM\Entity(repositoryClass="App\Repository\PrestataireRepository")
* @UniqueEntity(fields="slug", message="Raison or Slug is already taken.")
* @ORM\Table(name="prestataire")
* @ORM\HasLifecycleCallbacks()
*/
......
......@@ -18,17 +18,17 @@ class FirstComptoirFormType extends AbstractType
->add('enabled', HiddenType::class, array('data' => true))
->add('name', TextType::class, array(
'label' => 'Nom :',
'required' => true,
'required' => false,
'help' => "Vous pourrez éditer la description dans l'interface d'administration"
))
->add('geoloc', GeolocFormType::class, array(
'label' => 'Géolocalisation :',
'attr' => ['class' => 'ml-4'],
'required' => true
'required' => false
))
->add('compte', NumberType::class, array(
'label' => 'Solde de monnaie papier actuellement au comptoir :',
'required' => true
'required' => false
))
;
}
......@@ -36,7 +36,8 @@ class FirstComptoirFormType extends AbstractType
public function configureOptions(OptionsResolver $resolver)
{
$resolver->setDefaults([
'data_class' => Comptoir::class
'data_class' => null,
'validation_groups' => false,
]);
}
......
<?php
namespace App\Repository;
use App\Entity\Adherent;
use App\Entity\CotisationAdherent;
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
use Doctrine\Persistence\ManagerRegistry;
/**
* @method CotisationAdherent|null find($id, $lockMode = null, $lockVersion = null)
* @method CotisationAdherent|null findOneBy(array $criteria, array $orderBy = null)
* @method CotisationAdherent[] findAll()
* @method CotisationAdherent[] findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null)
*/
class CotisationRepository extends ServiceEntityRepository
{
public function __construct(ManagerRegistry $registry)
{
parent::__construct($registry, CotisationAdherent::class);
$em = $this->getEntityManager();
$this->connection = $em->getConnection();
$this->tableName = $em->getMetadataFactory()->getMetadataFor(CotisationAdherent::class)->getTableName();
}
public function isCotisationAdherentExist(Adherent $adherent, $montant, $year): bool
{
$qb = $this->createQueryBuilder('f');
$result = $qb
->leftJoin('f.cotisationInfos', 'i')
->where("f.type = 'cotisation_adherent'")
->andWhere('f.montant = :montant')
->andWhere('f.expediteur = :adherent')
->andWhere('i.annee = :year')
->setParameter('montant', $montant)
->setParameter('adherent', $adherent)
->setParameter('year', $year)
->getQuery()
->getResult();
return !empty($result);
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment