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 ...@@ -130,12 +130,10 @@ class IndexController extends AbstractController
$siege = $form['siege']->getData(); $siege = $form['siege']->getData();
$user = $form['user']->getData(); $user = $form['user']->getData();
$groupe = $form['groupe']->getData(); $groupe = $form['groupe']->getData();
$comptoir = $form['comptoir']->getData();
$configs = $form['config']->getData(); $configs = $form['config']->getData();
$iban = $form['iban']->getData(); $iban = $form['iban']->getData();
$website = $form['website']->getData(); $website = $form['website']->getData();
$groupe->setSiege($siege); $groupe->setSiege($siege);
$comptoir->setGroupe($groupe);
//Création du prestataire recevant les cotisations //Création du prestataire recevant les cotisations
$presta = new Prestataire(); $presta = new Prestataire();
...@@ -203,16 +201,27 @@ class IndexController extends AbstractController ...@@ -203,16 +201,27 @@ class IndexController extends AbstractController
$this->em->persist($account); $this->em->persist($account);
$this->em->persist($groupe); $this->em->persist($groupe);
} }
$this->em->persist($comptoir); $comptoirData = $form['comptoir']->getData();
if (null == $comptoir->getAccountWithCurrency(CurrencyEnum::CURRENCY_MLC)) { $comptoirName = $comptoirData['name'];
$account = new AccountComptoir(); $comptoirCompte = $comptoirData['compte'];
$account $comptoirGeoloc = $comptoirData['geoloc'];
->setBalance($comptoir->getCompte()) if (!empty($comptoir)) {
->setCurrency(CurrencyEnum::CURRENCY_MLC) $comptoir = new Comptoir();
; $comptoir->setName($comptoirName);
$comptoir->addAccount($account); $comptoir->setEnabled(true);
$this->em->persist($account); $comptoir->setGeoloc($comptoirGeoloc);
$comptoir->setGroupe($groupe);
$this->em->persist($comptoir); $this->em->persist($comptoir);
if (null == $comptoir->getAccountWithCurrency(CurrencyEnum::CURRENCY_MLC)) {
$account = new AccountComptoir();
$account
->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->userManager->updateUser($user);
$this->em->persist($presta); $this->em->persist($presta);
......
...@@ -57,4 +57,9 @@ class AccountAdherent extends Account ...@@ -57,4 +57,9 @@ class AccountAdherent extends Account
{ {
return $this->getAdherent(); return $this->getAdherent();
} }
public function __toString(): string
{
return 'AccountAdherent '.$this->getAdherent();
}
} }
...@@ -14,6 +14,7 @@ use Doctrine\Common\Collections\ArrayCollection; ...@@ -14,6 +14,7 @@ use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\ORM\Mapping as ORM; use Doctrine\ORM\Mapping as ORM;
use Gedmo\Timestampable\Traits\TimestampableEntity; use Gedmo\Timestampable\Traits\TimestampableEntity;
use Ramsey\Uuid\Doctrine\UuidGenerator; use Ramsey\Uuid\Doctrine\UuidGenerator;
use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
use Symfony\Component\Serializer\Annotation\Groups; use Symfony\Component\Serializer\Annotation\Groups;
use Symfony\Component\Serializer\Annotation\MaxDepth; use Symfony\Component\Serializer\Annotation\MaxDepth;
...@@ -32,6 +33,7 @@ use Symfony\Component\Serializer\Annotation\MaxDepth; ...@@ -32,6 +33,7 @@ use Symfony\Component\Serializer\Annotation\MaxDepth;
* denormalizationContext={"groups"={"write"}} * denormalizationContext={"groups"={"write"}}
* ) * )
* @ORM\Entity(repositoryClass="App\Repository\ComptoirRepository") * @ORM\Entity(repositoryClass="App\Repository\ComptoirRepository")
* @UniqueEntity(fields="slug", message="Name or Slug is already taken.")
* @ORM\HasLifecycleCallbacks() * @ORM\HasLifecycleCallbacks()
* @ORM\Table(name="comptoir") * @ORM\Table(name="comptoir")
*/ */
......
...@@ -23,7 +23,7 @@ use Symfony\Component\Serializer\Annotation\Groups; ...@@ -23,7 +23,7 @@ use Symfony\Component\Serializer\Annotation\Groups;
* TRANSACTION * TRANSACTION
* - Cotisation d'un adhérent. * - Cotisation d'un adhérent.
* *
* @ORM\Entity * @ORM\Entity(repositoryClass="App\Repository\CotisationRepository")
*/ */
class CotisationAdherent extends Cotisation class CotisationAdherent extends Cotisation
{ {
......
...@@ -20,7 +20,7 @@ trait HasCompteEntity ...@@ -20,7 +20,7 @@ trait HasCompteEntity
/** /**
* @return int * @return int
*/ */
public function getCompte(): float public function getCompte(): ?float
{ {
return $this->compte; return $this->compte;
} }
...@@ -30,7 +30,7 @@ trait HasCompteEntity ...@@ -30,7 +30,7 @@ trait HasCompteEntity
* *
* @return $this * @return $this
*/ */
public function setCompte(float $compte) public function setCompte(?float $compte)
{ {
$this->compte = $compte; $this->compte = $compte;
......
...@@ -13,6 +13,7 @@ use Doctrine\Common\Collections\ArrayCollection; ...@@ -13,6 +13,7 @@ use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\ORM\Mapping as ORM; use Doctrine\ORM\Mapping as ORM;
use Gedmo\Timestampable\Traits\TimestampableEntity; use Gedmo\Timestampable\Traits\TimestampableEntity;
use Ramsey\Uuid\Doctrine\UuidGenerator; use Ramsey\Uuid\Doctrine\UuidGenerator;
use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
use Symfony\Component\Serializer\Annotation\Groups; use Symfony\Component\Serializer\Annotation\Groups;
use Symfony\Component\Serializer\Annotation\MaxDepth; use Symfony\Component\Serializer\Annotation\MaxDepth;
...@@ -31,6 +32,7 @@ use Symfony\Component\Serializer\Annotation\MaxDepth; ...@@ -31,6 +32,7 @@ use Symfony\Component\Serializer\Annotation\MaxDepth;
* denormalizationContext={"groups"={"write"}} * denormalizationContext={"groups"={"write"}}
* ) * )
* @ORM\Entity * @ORM\Entity
* @UniqueEntity(fields="slug", message="Name or Slug is already taken.")
* @ORM\Table(name="groupe") * @ORM\Table(name="groupe")
* @ORM\HasLifecycleCallbacks() * @ORM\HasLifecycleCallbacks()
*/ */
......
...@@ -12,6 +12,7 @@ use Doctrine\Common\Collections\ArrayCollection; ...@@ -12,6 +12,7 @@ use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\ORM\Mapping as ORM; use Doctrine\ORM\Mapping as ORM;
use Gedmo\Timestampable\Traits\TimestampableEntity; use Gedmo\Timestampable\Traits\TimestampableEntity;
use Ramsey\Uuid\Doctrine\UuidGenerator; use Ramsey\Uuid\Doctrine\UuidGenerator;
use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
use Symfony\Component\Serializer\Annotation\Groups; use Symfony\Component\Serializer\Annotation\Groups;
use Symfony\Component\Validator\Constraints as Assert; use Symfony\Component\Validator\Constraints as Assert;
...@@ -30,6 +31,7 @@ use Symfony\Component\Validator\Constraints as Assert; ...@@ -30,6 +31,7 @@ use Symfony\Component\Validator\Constraints as Assert;
* denormalizationContext={"groups"={"write"}} * denormalizationContext={"groups"={"write"}}
* ) * )
* @ORM\Entity(repositoryClass="App\Repository\GroupeprestataireRepository") * @ORM\Entity(repositoryClass="App\Repository\GroupeprestataireRepository")
* @UniqueEntity(fields="slug", message="Name or Slug is already taken.")
* @ORM\Table(name="groupeprestaire") * @ORM\Table(name="groupeprestaire")
*/ */
class Groupeprestataire class Groupeprestataire
......
...@@ -14,6 +14,7 @@ use Gedmo\Mapping\Annotation as Gedmo; ...@@ -14,6 +14,7 @@ use Gedmo\Mapping\Annotation as Gedmo;
use Gedmo\Timestampable\Traits\TimestampableEntity; use Gedmo\Timestampable\Traits\TimestampableEntity;
use Ramsey\Uuid\Doctrine\UuidGenerator; use Ramsey\Uuid\Doctrine\UuidGenerator;
use SpecShaper\GdprBundle\Validator\Constraints as GdprAssert; use SpecShaper\GdprBundle\Validator\Constraints as GdprAssert;
use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
use Symfony\Component\Serializer\Annotation\Groups; use Symfony\Component\Serializer\Annotation\Groups;
use Symfony\Component\Validator\Constraints as Assert; use Symfony\Component\Validator\Constraints as Assert;
...@@ -32,6 +33,7 @@ use Symfony\Component\Validator\Constraints as Assert; ...@@ -32,6 +33,7 @@ use Symfony\Component\Validator\Constraints as Assert;
* denormalizationContext={"groups"={"write"}} * denormalizationContext={"groups"={"write"}}
* ) * )
* @ORM\Entity(repositoryClass="App\Repository\PrestataireRepository") * @ORM\Entity(repositoryClass="App\Repository\PrestataireRepository")
* @UniqueEntity(fields="slug", message="Raison or Slug is already taken.")
* @ORM\Table(name="prestataire") * @ORM\Table(name="prestataire")
* @ORM\HasLifecycleCallbacks() * @ORM\HasLifecycleCallbacks()
*/ */
......
...@@ -18,17 +18,17 @@ class FirstComptoirFormType extends AbstractType ...@@ -18,17 +18,17 @@ class FirstComptoirFormType extends AbstractType
->add('enabled', HiddenType::class, array('data' => true)) ->add('enabled', HiddenType::class, array('data' => true))
->add('name', TextType::class, array( ->add('name', TextType::class, array(
'label' => 'Nom :', 'label' => 'Nom :',
'required' => true, 'required' => false,
'help' => "Vous pourrez éditer la description dans l'interface d'administration" 'help' => "Vous pourrez éditer la description dans l'interface d'administration"
)) ))
->add('geoloc', GeolocFormType::class, array( ->add('geoloc', GeolocFormType::class, array(
'label' => 'Géolocalisation :', 'label' => 'Géolocalisation :',
'attr' => ['class' => 'ml-4'], 'attr' => ['class' => 'ml-4'],
'required' => true 'required' => false
)) ))
->add('compte', NumberType::class, array( ->add('compte', NumberType::class, array(
'label' => 'Solde de monnaie papier actuellement au comptoir :', 'label' => 'Solde de monnaie papier actuellement au comptoir :',
'required' => true 'required' => false
)) ))
; ;
} }
...@@ -36,7 +36,8 @@ class FirstComptoirFormType extends AbstractType ...@@ -36,7 +36,8 @@ class FirstComptoirFormType extends AbstractType
public function configureOptions(OptionsResolver $resolver) public function configureOptions(OptionsResolver $resolver)
{ {
$resolver->setDefaults([ $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