first commit

This commit is contained in:
2024-11-18 17:07:22 +01:00
parent 416ce7479f
commit d8882c93b9
26 changed files with 1150 additions and 104 deletions

View File

@ -0,0 +1,49 @@
<?php
namespace App\Command;
use Symfony\Component\Console\Attribute\AsCommand;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Output\OutputInterface;
use Symfony\Component\Console\Style\SymfonyStyle;
#[AsCommand(
name: 'app:init',
description: 'Add a short description for your command',
)]
class InitCommand extends Command
{
public function __construct()
{
parent::__construct();
}
protected function configure(): void
{
$this
->addArgument('arg1', InputArgument::OPTIONAL, 'Argument description')
->addOption('option1', null, InputOption::VALUE_NONE, 'Option description')
;
}
protected function execute(InputInterface $input, OutputInterface $output): int
{
$io = new SymfonyStyle($input, $output);
$arg1 = $input->getArgument('arg1');
if ($arg1) {
$io->note(sprintf('You passed an argument: %s', $arg1));
}
if ($input->getOption('option1')) {
// ...
}
$io->success('You have a new command! Now make it your own! Pass --help to see your options.');
return Command::SUCCESS;
}
}

View File

@ -0,0 +1,18 @@
<?php
namespace App\Controller;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\Attribute\Route;
class HomeController extends AbstractController
{
#[Route('/', name: 'app_home')]
public function index(): Response
{
return $this->render('home/index.html.twig', [
'controller_name' => 'HomeController',
]);
}
}

176
src/Entity/Accounting.php Normal file
View File

@ -0,0 +1,176 @@
<?php
namespace App\Entity;
use App\Repository\AccountingRepository;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
#[ORM\Entity(repositoryClass: AccountingRepository::class)]
class Accounting
{
#[ORM\Id]
#[ORM\GeneratedValue]
#[ORM\Column]
private ?int $id = null;
#[ORM\Column(length: 255)]
private ?string $num01 = null;
#[ORM\Column(length: 255)]
private ?string $num02 = null;
#[ORM\Column(length: 255)]
private ?string $title = null;
#[ORM\Column]
private ?bool $actif = null;
#[ORM\ManyToOne(inversedBy: 'accountings')]
#[ORM\JoinColumn(nullable: false)]
private ?Company $company = null;
/**
* @var Collection<int, Operation>
*/
#[ORM\OneToMany(targetEntity: Operation::class, mappedBy: 'credit', orphanRemoval: true)]
private Collection $credits;
/**
* @var Collection<int, Operation>
*/
#[ORM\OneToMany(targetEntity: Operation::class, mappedBy: 'debit', orphanRemoval: true)]
private Collection $debits;
public function __construct()
{
$this->credits = new ArrayCollection();
$this->debits = new ArrayCollection();
}
public function getId(): ?int
{
return $this->id;
}
public function getNum01(): ?string
{
return $this->num01;
}
public function setNum01(string $num01): static
{
$this->num01 = $num01;
return $this;
}
public function getNum02(): ?string
{
return $this->num02;
}
public function setNum02(string $num02): static
{
$this->num02 = $num02;
return $this;
}
public function getTitle(): ?string
{
return $this->title;
}
public function setTitle(string $title): static
{
$this->title = $title;
return $this;
}
public function isActif(): ?bool
{
return $this->actif;
}
public function setActif(bool $actif): static
{
$this->actif = $actif;
return $this;
}
public function getCompany(): ?Company
{
return $this->company;
}
public function setCompany(?Company $company): static
{
$this->company = $company;
return $this;
}
/**
* @return Collection<int, Operation>
*/
public function getCredits(): Collection
{
return $this->credits;
}
public function addCredit(Operation $credit): static
{
if (!$this->credits->contains($credit)) {
$this->credits->add($credit);
$credit->setCredit($this);
}
return $this;
}
public function removeCredit(Operation $credit): static
{
if ($this->credits->removeElement($credit)) {
// set the owning side to null (unless already changed)
if ($credit->getCredit() === $this) {
$credit->setCredit(null);
}
}
return $this;
}
/**
* @return Collection<int, Operation>
*/
public function getDebits(): Collection
{
return $this->debits;
}
public function addDebit(Operation $debit): static
{
if (!$this->debits->contains($debit)) {
$this->debits->add($debit);
$debit->setDebit($this);
}
return $this;
}
public function removeDebit(Operation $debit): static
{
if ($this->debits->removeElement($debit)) {
// set the owning side to null (unless already changed)
if ($debit->getDebit() === $this) {
$debit->setDebit(null);
}
}
return $this;
}
}

263
src/Entity/Company.php Normal file
View File

@ -0,0 +1,263 @@
<?php
namespace App\Entity;
use App\Repository\CompanyRepository;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\DBAL\Types\Types;
use Doctrine\ORM\Mapping as ORM;
#[ORM\Entity(repositoryClass: CompanyRepository::class)]
class Company
{
#[ORM\Id]
#[ORM\GeneratedValue]
#[ORM\Column]
private ?int $id = null;
#[ORM\Column(length: 255)]
private ?string $title = null;
#[ORM\Column(type: Types::TEXT, nullable: true)]
private ?string $adress = null;
#[ORM\Column(length: 255, nullable: true)]
private ?string $logo = null;
#[ORM\Column(length: 255, nullable: true)]
private ?string $bankname = null;
#[ORM\Column(length: 255, nullable: true)]
private ?string $bankcode = null;
#[ORM\Column(length: 255, nullable: true)]
private ?string $bankguichet = null;
#[ORM\Column(length: 255, nullable: true)]
private ?string $banknum = null;
#[ORM\Column(length: 255, nullable: true)]
private ?string $bankkey = null;
#[ORM\Column(length: 255, nullable: true)]
private ?string $banklocality = null;
#[ORM\Column(length: 255, nullable: true)]
private ?string $bankiban = null;
#[ORM\Column(length: 255, nullable: true)]
private ?string $bankbic = null;
/**
* @var Collection<int, Accounting>
*/
#[ORM\OneToMany(targetEntity: Accounting::class, mappedBy: 'company', orphanRemoval: true)]
private Collection $accountings;
/**
* @var Collection<int, User>
*/
#[ORM\ManyToMany(targetEntity: User::class, mappedBy: 'companys')]
private Collection $users;
public function __construct()
{
$this->accountings = new ArrayCollection();
$this->users = new ArrayCollection();
}
public function getId(): ?int
{
return $this->id;
}
public function getTitle(): ?string
{
return $this->title;
}
public function setTitle(string $title): static
{
$this->title = $title;
return $this;
}
public function getAdress(): ?string
{
return $this->adress;
}
public function setAdress(string $adress): static
{
$this->adress = $adress;
return $this;
}
public function getLogo(): ?string
{
return $this->logo;
}
public function setLogo(?string $logo): static
{
$this->logo = $logo;
return $this;
}
public function getBankname(): ?string
{
return $this->bankname;
}
public function setBankname(?string $bankname): static
{
$this->bankname = $bankname;
return $this;
}
public function getBankcode(): ?string
{
return $this->bankcode;
}
public function setBankcode(?string $bankcode): static
{
$this->bankcode = $bankcode;
return $this;
}
public function getBankguichet(): ?string
{
return $this->bankguichet;
}
public function setBankguichet(?string $bankguichet): static
{
$this->bankguichet = $bankguichet;
return $this;
}
public function getBanknum(): ?string
{
return $this->banknum;
}
public function setBanknum(?string $banknum): static
{
$this->banknum = $banknum;
return $this;
}
public function getBankkey(): ?string
{
return $this->bankkey;
}
public function setBankkey(?string $bankkey): static
{
$this->bankkey = $bankkey;
return $this;
}
public function getBanklocality(): ?string
{
return $this->banklocality;
}
public function setBanklocality(?string $banklocality): static
{
$this->banklocality = $banklocality;
return $this;
}
public function getBankiban(): ?string
{
return $this->bankiban;
}
public function setBankiban(?string $bankiban): static
{
$this->bankiban = $bankiban;
return $this;
}
public function getBankbic(): ?string
{
return $this->bankbic;
}
public function setBankbic(?string $bankbic): static
{
$this->bankbic = $bankbic;
return $this;
}
/**
* @return Collection<int, Accounting>
*/
public function getAccountings(): Collection
{
return $this->accountings;
}
public function addAccounting(Accounting $accounting): static
{
if (!$this->accountings->contains($accounting)) {
$this->accountings->add($accounting);
$accounting->setCompany($this);
}
return $this;
}
public function removeAccounting(Accounting $accounting): static
{
if ($this->accountings->removeElement($accounting)) {
// set the owning side to null (unless already changed)
if ($accounting->getCompany() === $this) {
$accounting->setCompany(null);
}
}
return $this;
}
/**
* @return Collection<int, User>
*/
public function getUsers(): Collection
{
return $this->users;
}
public function addUser(User $user): static
{
if (!$this->users->contains($user)) {
$this->users->add($user);
$user->addCompany($this);
}
return $this;
}
public function removeUser(User $user): static
{
if ($this->users->removeElement($user)) {
$user->removeCompany($this);
}
return $this;
}
}

98
src/Entity/Operation.php Normal file
View File

@ -0,0 +1,98 @@
<?php
namespace App\Entity;
use App\Repository\OperationRepository;
use Doctrine\DBAL\Types\Types;
use Doctrine\ORM\Mapping as ORM;
#[ORM\Entity(repositoryClass: OperationRepository::class)]
class Operation
{
#[ORM\Id]
#[ORM\GeneratedValue]
#[ORM\Column]
private ?int $id = null;
#[ORM\Column(length: 255)]
private ?string $title = null;
#[ORM\Column(type: Types::DATETIME_MUTABLE)]
private ?\DateTimeInterface $date = null;
#[ORM\Column(type: Types::DECIMAL, precision: 10, scale: 2)]
private ?string $montant = null;
#[ORM\ManyToOne(inversedBy: 'credits')]
#[ORM\JoinColumn(nullable: false)]
private ?Accounting $credit = null;
#[ORM\ManyToOne(inversedBy: 'debits')]
#[ORM\JoinColumn(nullable: false)]
private ?Accounting $debit = null;
public function getId(): ?int
{
return $this->id;
}
public function getTitle(): ?string
{
return $this->title;
}
public function setTitle(string $title): static
{
$this->title = $title;
return $this;
}
public function getDate(): ?\DateTimeInterface
{
return $this->date;
}
public function setDate(\DateTimeInterface $date): static
{
$this->date = $date;
return $this;
}
public function getMontant(): ?string
{
return $this->montant;
}
public function setMontant(string $montant): static
{
$this->montant = $montant;
return $this;
}
public function getCredit(): ?Accounting
{
return $this->credit;
}
public function setCredit(?Accounting $credit): static
{
$this->credit = $credit;
return $this;
}
public function getDebit(): ?Accounting
{
return $this->debit;
}
public function setDebit(?Accounting $debit): static
{
$this->debit = $debit;
return $this;
}
}

145
src/Entity/User.php Normal file
View File

@ -0,0 +1,145 @@
<?php
namespace App\Entity;
use App\Repository\UserRepository;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\Security\Core\User\PasswordAuthenticatedUserInterface;
use Symfony\Component\Security\Core\User\UserInterface;
#[ORM\Entity(repositoryClass: UserRepository::class)]
#[ORM\UniqueConstraint(name: 'UNIQ_IDENTIFIER_USERNAME', fields: ['username'])]
class User implements UserInterface, PasswordAuthenticatedUserInterface
{
#[ORM\Id]
#[ORM\GeneratedValue]
#[ORM\Column]
private ?int $id = null;
#[ORM\Column(length: 180)]
private ?string $username = null;
/**
* @var list<string> The user roles
*/
#[ORM\Column]
private array $roles = [];
/**
* @var string The hashed password
*/
#[ORM\Column]
private ?string $password = null;
/**
* @var Collection<int, Company>
*/
#[ORM\ManyToMany(targetEntity: Company::class, inversedBy: 'users')]
private Collection $companys;
public function __construct()
{
$this->companys = new ArrayCollection();
}
public function getId(): ?int
{
return $this->id;
}
public function getUsername(): ?string
{
return $this->username;
}
public function setUsername(string $username): static
{
$this->username = $username;
return $this;
}
/**
* A visual identifier that represents this user.
*
* @see UserInterface
*/
public function getUserIdentifier(): string
{
return (string) $this->username;
}
/**
* @see UserInterface
*
* @return list<string>
*/
public function getRoles(): array
{
$roles = $this->roles;
// guarantee every user at least has ROLE_USER
$roles[] = 'ROLE_USER';
return array_unique($roles);
}
/**
* @param list<string> $roles
*/
public function setRoles(array $roles): static
{
$this->roles = $roles;
return $this;
}
/**
* @see PasswordAuthenticatedUserInterface
*/
public function getPassword(): ?string
{
return $this->password;
}
public function setPassword(string $password): static
{
$this->password = $password;
return $this;
}
/**
* @see UserInterface
*/
public function eraseCredentials(): void
{
// If you store any temporary, sensitive data on the user, clear it here
// $this->plainPassword = null;
}
/**
* @return Collection<int, Company>
*/
public function getCompanys(): Collection
{
return $this->companys;
}
public function addCompany(Company $company): static
{
if (!$this->companys->contains($company)) {
$this->companys->add($company);
}
return $this;
}
public function removeCompany(Company $company): static
{
$this->companys->removeElement($company);
return $this;
}
}

View File

@ -0,0 +1,43 @@
<?php
namespace App\Repository;
use App\Entity\Accounting;
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
use Doctrine\Persistence\ManagerRegistry;
/**
* @extends ServiceEntityRepository<Accounting>
*/
class AccountingRepository extends ServiceEntityRepository
{
public function __construct(ManagerRegistry $registry)
{
parent::__construct($registry, Accounting::class);
}
// /**
// * @return Accounting[] Returns an array of Accounting objects
// */
// public function findByExampleField($value): array
// {
// return $this->createQueryBuilder('a')
// ->andWhere('a.exampleField = :val')
// ->setParameter('val', $value)
// ->orderBy('a.id', 'ASC')
// ->setMaxResults(10)
// ->getQuery()
// ->getResult()
// ;
// }
// public function findOneBySomeField($value): ?Accounting
// {
// return $this->createQueryBuilder('a')
// ->andWhere('a.exampleField = :val')
// ->setParameter('val', $value)
// ->getQuery()
// ->getOneOrNullResult()
// ;
// }
}

View File

@ -0,0 +1,43 @@
<?php
namespace App\Repository;
use App\Entity\Company;
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
use Doctrine\Persistence\ManagerRegistry;
/**
* @extends ServiceEntityRepository<Company>
*/
class CompanyRepository extends ServiceEntityRepository
{
public function __construct(ManagerRegistry $registry)
{
parent::__construct($registry, Company::class);
}
// /**
// * @return Company[] Returns an array of Company objects
// */
// public function findByExampleField($value): array
// {
// return $this->createQueryBuilder('c')
// ->andWhere('c.exampleField = :val')
// ->setParameter('val', $value)
// ->orderBy('c.id', 'ASC')
// ->setMaxResults(10)
// ->getQuery()
// ->getResult()
// ;
// }
// public function findOneBySomeField($value): ?Company
// {
// return $this->createQueryBuilder('c')
// ->andWhere('c.exampleField = :val')
// ->setParameter('val', $value)
// ->getQuery()
// ->getOneOrNullResult()
// ;
// }
}

View File

@ -0,0 +1,43 @@
<?php
namespace App\Repository;
use App\Entity\Operation;
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
use Doctrine\Persistence\ManagerRegistry;
/**
* @extends ServiceEntityRepository<Operation>
*/
class OperationRepository extends ServiceEntityRepository
{
public function __construct(ManagerRegistry $registry)
{
parent::__construct($registry, Operation::class);
}
// /**
// * @return Operation[] Returns an array of Operation objects
// */
// public function findByExampleField($value): array
// {
// return $this->createQueryBuilder('o')
// ->andWhere('o.exampleField = :val')
// ->setParameter('val', $value)
// ->orderBy('o.id', 'ASC')
// ->setMaxResults(10)
// ->getQuery()
// ->getResult()
// ;
// }
// public function findOneBySomeField($value): ?Operation
// {
// return $this->createQueryBuilder('o')
// ->andWhere('o.exampleField = :val')
// ->setParameter('val', $value)
// ->getQuery()
// ->getOneOrNullResult()
// ;
// }
}

View File

@ -0,0 +1,60 @@
<?php
namespace App\Repository;
use App\Entity\User;
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
use Doctrine\Persistence\ManagerRegistry;
use Symfony\Component\Security\Core\Exception\UnsupportedUserException;
use Symfony\Component\Security\Core\User\PasswordAuthenticatedUserInterface;
use Symfony\Component\Security\Core\User\PasswordUpgraderInterface;
/**
* @extends ServiceEntityRepository<User>
*/
class UserRepository extends ServiceEntityRepository implements PasswordUpgraderInterface
{
public function __construct(ManagerRegistry $registry)
{
parent::__construct($registry, User::class);
}
/**
* Used to upgrade (rehash) the user's password automatically over time.
*/
public function upgradePassword(PasswordAuthenticatedUserInterface $user, string $newHashedPassword): void
{
if (!$user instanceof User) {
throw new UnsupportedUserException(sprintf('Instances of "%s" are not supported.', $user::class));
}
$user->setPassword($newHashedPassword);
$this->getEntityManager()->persist($user);
$this->getEntityManager()->flush();
}
// /**
// * @return User[] Returns an array of User objects
// */
// public function findByExampleField($value): array
// {
// return $this->createQueryBuilder('u')
// ->andWhere('u.exampleField = :val')
// ->setParameter('val', $value)
// ->orderBy('u.id', 'ASC')
// ->setMaxResults(10)
// ->getQuery()
// ->getResult()
// ;
// }
// public function findOneBySomeField($value): ?User
// {
// return $this->createQueryBuilder('u')
// ->andWhere('u.exampleField = :val')
// ->setParameter('val', $value)
// ->getQuery()
// ->getOneOrNullResult()
// ;
// }
}