Add AccountingStatement
This commit is contained in:
@@ -0,0 +1,69 @@
|
||||
<?php
|
||||
|
||||
namespace App\Entity;
|
||||
|
||||
use ApiPlatform\Metadata as API;
|
||||
use App\Repository\AccountingStatementRepository;
|
||||
use Doctrine\DBAL\Types\Types;
|
||||
use Doctrine\ORM\Mapping as ORM;
|
||||
|
||||
/**
|
||||
* An AccountingStatement represents a change in the balance of an Accounting.\
|
||||
* \
|
||||
* When money is received, an statement holds it as available.
|
||||
* When money is issued, an statement draws available money from previous statements.\
|
||||
* \
|
||||
* The sum of available money in the statements is the available money at that Accounting.
|
||||
*/
|
||||
#[API\ApiResource]
|
||||
#[ORM\Entity(repositoryClass: AccountingStatementRepository::class)]
|
||||
class AccountingStatement
|
||||
{
|
||||
#[ORM\Id]
|
||||
#[ORM\GeneratedValue]
|
||||
#[ORM\Column]
|
||||
private ?int $id = null;
|
||||
|
||||
/**
|
||||
* The money held in this statement.
|
||||
*/
|
||||
#[ORM\Embedded(class: Money::class)]
|
||||
private ?Money $money = null;
|
||||
|
||||
/**
|
||||
* The direction of this statement.\
|
||||
* `incoming` means the transaction was received and the money is available.\
|
||||
* `outgoing` means the transaction was issued and the money is an expenditure.
|
||||
*/
|
||||
#[ORM\Column()]
|
||||
private ?AccountingStatementDirection $direction = null;
|
||||
|
||||
public function getId(): ?int
|
||||
{
|
||||
return $this->id;
|
||||
}
|
||||
|
||||
public function getMoney(): ?Money
|
||||
{
|
||||
return $this->money;
|
||||
}
|
||||
|
||||
public function setMoney(Money $money): static
|
||||
{
|
||||
$this->money = $money;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getDirection(): ?AccountingStatementDirection
|
||||
{
|
||||
return $this->direction;
|
||||
}
|
||||
|
||||
public function setDirection(AccountingStatementDirection $direction): static
|
||||
{
|
||||
$this->direction = $direction;
|
||||
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
<?php
|
||||
|
||||
namespace App\Entity;
|
||||
|
||||
enum AccountingStatementDirection: string
|
||||
{
|
||||
case Incoming = 'incoming';
|
||||
|
||||
case Outgoing = 'outgoing';
|
||||
}
|
||||
@@ -0,0 +1,48 @@
|
||||
<?php
|
||||
|
||||
namespace App\Repository;
|
||||
|
||||
use App\Entity\AccountingStatement;
|
||||
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
|
||||
use Doctrine\Persistence\ManagerRegistry;
|
||||
|
||||
/**
|
||||
* @extends ServiceEntityRepository<AccountingStatement>
|
||||
*
|
||||
* @method AccountingStatement|null find($id, $lockMode = null, $lockVersion = null)
|
||||
* @method AccountingStatement|null findOneBy(array $criteria, array $orderBy = null)
|
||||
* @method AccountingStatement[] findAll()
|
||||
* @method AccountingStatement[] findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null)
|
||||
*/
|
||||
class AccountingStatementRepository extends ServiceEntityRepository
|
||||
{
|
||||
public function __construct(ManagerRegistry $registry)
|
||||
{
|
||||
parent::__construct($registry, AccountingStatement::class);
|
||||
}
|
||||
|
||||
// /**
|
||||
// * @return AccountingStatement[] Returns an array of AccountingStatement 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): ?AccountingStatement
|
||||
// {
|
||||
// return $this->createQueryBuilder('a')
|
||||
// ->andWhere('a.exampleField = :val')
|
||||
// ->setParameter('val', $value)
|
||||
// ->getQuery()
|
||||
// ->getOneOrNullResult()
|
||||
// ;
|
||||
// }
|
||||
}
|
||||
Reference in New Issue
Block a user