Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 0 additions & 7 deletions config/packages/ting.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,6 @@ ting:
default:
connection: main
database: '%database_name%'
accounting:
namespace: AppBundle\Accounting\Model\Repository
directory: "@AppBundle/Accounting/Model/Repository"
options:
default:
connection: main
database: "%database_name%"
association:
namespace : AppBundle\Association\Model\Repository
directory : "@AppBundle/Association/Model/Repository"
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
<?php

declare(strict_types=1);

use Phinx\Migration\AbstractMigration;

final class MakeTransactionPaymentTypeNullable extends AbstractMigration
{
public function up(): void
{
$this->table('compta')
->changeColumn('idmode_regl', 'integer', [
'limit' => 5,
'null' => true,
'default' => null,
])
->update();

$this->execute('UPDATE compta SET idmode_regl = NULL WHERE idmode_regl = 0');
}

public function down(): void
{
$this->execute('UPDATE compta SET idmode_regl = 0 WHERE idmode_regl IS NULL');

$this->table('compta')
->changeColumn('idmode_regl', 'integer', [
'limit' => 5,
'null' => false,
'default' => 0,
])
->update();
}
}
8 changes: 8 additions & 0 deletions db/seeds/ComptaCompte.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,14 @@ public function run(): void
'nom_compte' => 'Paypal',
'archived_at' => new DateTime('last year')->format('Y-m-d H:i:s'),
],
[
'id' => 5,
'nom_compte' => 'Compte courant CMUT',
],
[
'id' => 6,
'nom_compte' => 'Livret CMUT',
],
];

$table = $this->table('compta_compte');
Expand Down
546 changes: 84 additions & 462 deletions phpstan-baseline.php

Large diffs are not rendered by default.

118 changes: 118 additions & 0 deletions sources/AppBundle/Accounting/Entity/Invoicing.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,118 @@
<?php

declare(strict_types=1);

namespace AppBundle\Accounting\Entity;

use Afup\Site\Utils\Utils;
use AppBundle\Accounting\Entity\Repository\InvoicingRepository;
use AppBundle\Accounting\InvoicingCurrency;
use AppBundle\Accounting\InvoicingPaymentStatus;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\Validator\Constraints as Assert;

#[ORM\Entity(repositoryClass: InvoicingRepository::class)]
#[ORM\Table(name: 'afup_compta_facture')]
class Invoicing
{
#[ORM\Id]
#[ORM\GeneratedValue]
#[ORM\Column]
public ?int $id = null;

#[ORM\Column(name: 'date_devis', nullable: true)]
public ?\DateTime $dateDevis = null;

#[ORM\Column(name: 'numero_devis', nullable: true)]
public ?string $numeroDevis = null;

#[ORM\Column(name: 'date_facture', nullable: true)]
public ?\DateTime $dateFacture = null;

#[ORM\Column(name: 'numero_facture', nullable: true)]
public ?string $numeroFacture = null;

#[ORM\Column(name: 'societe', length: 50, nullable: false)]
public string $societe = '';

#[ORM\Column(name: 'service', length: 50, nullable: false)]
public string $service = '';

#[ORM\Column(name: 'adresse', type: 'text', nullable: false)]
public string $adresse = '';

#[ORM\Column(name: 'code_postal', length: 10, nullable: false)]
public string $codePostal = '';

#[ORM\Column(name: 'ville', length: 50, nullable: false)]
public string $ville = '';

#[ORM\Column(name: 'id_pays', length: 10, nullable: false)]
public string $idPays = '';

#[ORM\Column(length: 100, nullable: false)]
public string $email = '';

#[ORM\Column(name: 'tva_intra', length: 20, nullable: true)]
public ?string $tvaIntra = null;

#[ORM\Column(type: 'text', nullable: false)]
public string $observation = '';

#[ORM\Column(name: 'ref_clt1', length: 50, nullable: false)]
public string $referenceClient1 = '';

#[ORM\Column(name: 'ref_clt2', length: 50, nullable: false)]
public string $referenceClient2 = '';

#[ORM\Column(name: 'ref_clt3', length: 50, nullable: false)]
public string $referenceClient3 = '';

#[ORM\Column(name: 'nom', length: 50, nullable: false)]
public string $nom = '';

#[ORM\Column(name: 'prenom', length: 50, nullable: false)]
public string $prenom = '';

#[ORM\Column(name: 'tel', length: 30, nullable: false)]
public string $telephone = '';

#[ORM\Column(name: 'etat_paiement', nullable: false, enumType: InvoicingPaymentStatus::class)]
public InvoicingPaymentStatus $etatPaiement = InvoicingPaymentStatus::Waiting;

#[ORM\Column(name: 'date_paiement', nullable: true)]
public ?\DateTime $datePaiement = null;

#[ORM\Column(name: 'devise_facture', nullable: true, enumType: InvoicingCurrency::class)]
public ?InvoicingCurrency $deviseFacture = null;

/** @var Collection<int, InvoicingDetail> */
#[Assert\Valid]
#[ORM\OneToMany(targetEntity: InvoicingDetail::class, mappedBy: 'facture', cascade: ['persist', 'remove'], orphanRemoval: true)]
public Collection $details;

// Non persistee - total calcule depuis les lignes de detail, alimente par les requetes de listing
public ?float $prix = null;

public function __construct()
{
$this->details = new ArrayCollection();
}

public function addDetail(InvoicingDetail $detail): void
{
$this->details->add($detail);
$detail->facture = $this;
}

public function getPaymentUrlRef(): string
{
if (empty($this->numeroFacture)) {
return '';
}

return urlencode(Utils::cryptFromText($this->id));
}
}
44 changes: 44 additions & 0 deletions sources/AppBundle/Accounting/Entity/InvoicingDetail.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
<?php

declare(strict_types=1);

namespace AppBundle\Accounting\Entity;

use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\Validator\Constraints as Assert;

#[ORM\Entity]
#[ORM\Table(name: 'afup_compta_facture_details')]
class InvoicingDetail
{
#[ORM\Id]
#[ORM\GeneratedValue]
#[ORM\Column]
public ?int $id = null;

#[ORM\ManyToOne(targetEntity: Invoicing::class, inversedBy: 'details')]
#[ORM\JoinColumn(name: 'idafup_compta_facture', referencedColumnName: 'id', nullable: false)]
public Invoicing $facture;

#[Assert\NotBlank]
#[Assert\Length(max: 20)]
#[ORM\Column(name: 'ref', length: 50, nullable: false)]
public ?string $reference = null;

#[Assert\NotBlank]
#[Assert\Length(max: 100)]
#[ORM\Column(length: 100, nullable: false)]
public ?string $designation = null;

#[Assert\NotBlank]
#[ORM\Column(name: 'quantite', type: 'float', nullable: false)]
public ?float $quantite = null;

#[Assert\NotBlank]
#[ORM\Column(name: 'pu', type: 'float', nullable: false)]
public ?float $prixUnitaire = null;

#[Assert\NotBlank]
#[ORM\Column(type: 'float', nullable: true)]
public ?float $tva = null;
}
27 changes: 27 additions & 0 deletions sources/AppBundle/Accounting/Entity/InvoicingPeriod.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<?php

declare(strict_types=1);

namespace AppBundle\Accounting\Entity;

use AppBundle\Accounting\Entity\Repository\InvoicingPeriodRepository;
use Doctrine\ORM\Mapping as ORM;

#[ORM\Entity(repositoryClass: InvoicingPeriodRepository::class)]
#[ORM\Table(name: 'compta_periode')]
class InvoicingPeriod
{
#[ORM\Id]
#[ORM\GeneratedValue]
#[ORM\Column]
public ?int $id = null;

#[ORM\Column(name: 'date_debut', nullable: true)]
public ?\DateTime $dateDebut = null;

#[ORM\Column(name: 'date_fin', nullable: true)]
public ?\DateTime $dateFin = null;

#[ORM\Column(name: 'verouiller', nullable: true)]
public ?bool $verrouille = false;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
<?php

declare(strict_types=1);

namespace AppBundle\Accounting\Entity\Repository;

use AppBundle\Accounting\Entity\InvoicingPeriod;
use AppBundle\Doctrine\EntityRepository;
use Doctrine\Persistence\ManagerRegistry;

/**
* @extends EntityRepository<InvoicingPeriod>
*/
final class InvoicingPeriodRepository extends EntityRepository
{
public function __construct(ManagerRegistry $registry)
{
parent::__construct($registry, InvoicingPeriod::class);
}

public function getCurrentPeriod(?int $periodId = null): InvoicingPeriod
{
if ($periodId !== null) {
return $this->find($periodId);
}

$startDate = new \DateTime(date('Y') . '-01-01');
$endDate = new \DateTime(date('Y') . '-12-31');
$period = $this->findOneBy([
'dateDebut' => $startDate,
'dateFin' => $endDate,
]);

if (!$period instanceof InvoicingPeriod) {
$period = new InvoicingPeriod();
$period->dateDebut = $startDate;
$period->dateFin = $endDate;
$this->save($period);
}

return $period;
}
}
Loading
Loading