diff --git a/src/Entity/Accounting.php b/src/Entity/Accounting.php deleted file mode 100644 index 90abcd8..0000000 --- a/src/Entity/Accounting.php +++ /dev/null @@ -1,157 +0,0 @@ - - */ - #[ORM\OneToMany(mappedBy: 'accounting', targetEntity: AccountingIncoming::class)] - #[API\ApiProperty(writable: false)] - private Collection $incomings; - - /** - * Accounting Outgoing movements state the Accounting expenses - * @var Collection - */ - #[ORM\OneToMany(mappedBy: 'accounting', targetEntity: AccountingOutgoing::class)] - #[API\ApiProperty(writable: false)] - private Collection $outgoings; - - public function __construct() - { - $this->incomings = new ArrayCollection(); - $this->outgoings = new ArrayCollection(); - } - - public function getId(): ?int - { - return $this->id; - } - - public function getAmount(): int - { - return $this->amount; - } - - public function setAmount(int $amount): static - { - $this->amount = $amount; - - return $this; - } - - public function getCurrency(): string - { - return $this->currency; - } - - public function setCurrency(string $currency): static - { - $this->currency = $currency; - - return $this; - } - - /** - * @return Collection - */ - public function getIncomings(): Collection - { - return $this->incomings; - } - - public function addIncoming(AccountingIncoming $incomings): static - { - if (!$this->incomings->contains($incomings)) { - $this->incomings->add($incomings); - $incomings->setAccounting($this); - } - - return $this; - } - - public function removeIncoming(AccountingIncoming $incomings): static - { - if ($this->incomings->removeElement($incomings)) { - // set the owning side to null (unless already changed) - if ($incomings->getAccounting() === $this) { - $incomings->setAccounting(null); - } - } - - return $this; - } - - /** - * @return Collection - */ - public function getOutgoings(): Collection - { - return $this->outgoings; - } - - public function addOutgoing(AccountingOutgoing $outgoings): static - { - if (!$this->outgoings->contains($outgoings)) { - $this->outgoings->add($outgoings); - $outgoings->setAccounting($this); - } - - return $this; - } - - public function removeOutgoing(AccountingOutgoing $outgoings): static - { - if ($this->outgoings->removeElement($outgoings)) { - // set the owning side to null (unless already changed) - if ($outgoings->getAccounting() === $this) { - $outgoings->setAccounting(null); - } - } - - return $this; - } -} diff --git a/src/Entity/AccountingFunding.php b/src/Entity/AccountingFunding.php deleted file mode 100644 index 1d88b4c..0000000 --- a/src/Entity/AccountingFunding.php +++ /dev/null @@ -1,101 +0,0 @@ -id; - } - - public function getAmount(): int - { - return $this->amount; - } - - public function setAmount(int $amount): static - { - $this->amount = $amount; - - return $this; - } - - public function getCurrency(): string - { - return $this->currency; - } - - public function setCurrency(string $currency): static - { - $this->currency = $currency; - - return $this; - } - - public function getOutgoing(): ?AccountingOutgoing - { - return $this->outgoing; - } - - public function setOutgoing(?AccountingOutgoing $outgoing): static - { - $this->outgoing = $outgoing; - - return $this; - } - - public function getIncoming(): ?AccountingIncoming - { - return $this->incoming; - } - - public function setIncoming(?AccountingIncoming $incoming): static - { - $this->incoming = $incoming; - - return $this; - } -} diff --git a/src/Entity/AccountingIncoming.php b/src/Entity/AccountingIncoming.php deleted file mode 100644 index 24a6e0a..0000000 --- a/src/Entity/AccountingIncoming.php +++ /dev/null @@ -1,188 +0,0 @@ - new API\Link(fromClass: Accounting::class, fromProperty: 'id'), - 'id' => new API\Link(fromClass: AccountingIncoming::class) - ], - operations: [new API\Get()] -)] -class AccountingIncoming extends Monetizable -{ - #[ORM\Id] - #[ORM\GeneratedValue] - #[ORM\Column] - private ?int $id = null; - - /** - * The available amount of this Incoming.\ - * Expressed in the minor unit of the currency (cents, pennies, etc) - */ - #[ORM\Column] - private int $amount = 0; - - /** - * Originally received amount of the Incoming.\ - * Expressed in the minor unit of the currency (cents, pennies, etc) - */ - #[ORM\Column] - private ?int $amountOriginal = 0; - - /** - * 3-letter ISO 4217 currency code. Same as parent Accounting. - */ - #[ORM\Column(length: 3)] - private string $currency = ""; - - #[ORM\ManyToOne(inversedBy: 'incoming')] - #[ORM\JoinColumn(nullable: false)] - private ?Accounting $accounting = null; - - /** - * The received Transaction that generated this Incoming. - */ - #[ORM\OneToOne(cascade: ['persist', 'remove'])] - #[ORM\JoinColumn(nullable: false)] - private ?Transaction $transaction = null; - - /** - * When receiving Transactions in a different currency an exchange operation will be performed.\ - * Original amount, currency and exchange rate data can be referenced here. - */ - #[ORM\Embedded(class: TransactionExchange::class)] - private ?object $transactionExchange = null; - - /** - * A list of Accounting Fundings detailing the expenditures financed by this Incoming movement. - */ - #[ORM\OneToMany(mappedBy: 'incoming', targetEntity: AccountingFunding::class)] - private Collection $spentOn; - - public function __construct() - { - $this->spentOn = new ArrayCollection(); - } - - public function getId(): ?int - { - return $this->id; - } - - public function getAmount(): int - { - return $this->amount; - } - - public function setAmount(int $amount): static - { - $this->amount = $amount; - - return $this; - } - - public function getAmountOriginal(): int - { - return $this->amountOriginal; - } - - public function setAmountOriginal(int $amountOriginal): static - { - $this->amountOriginal = $amountOriginal; - - return $this; - } - - public function getCurrency(): string - { - return $this->currency; - } - - public function setCurrency(string $currency): static - { - $this->currency = $currency; - - return $this; - } - - public function getAccounting(): ?Accounting - { - return $this->accounting; - } - - public function setAccounting(?Accounting $accounting): static - { - $this->accounting = $accounting; - - return $this; - } - - public function getTransaction(): ?Transaction - { - return $this->transaction; - } - - public function setTransaction(Transaction $transaction): static - { - $this->transaction = $transaction; - - return $this; - } - - public function getTransactionExchange(): ?object - { - return $this->transactionExchange; - } - - public function setTransactionExchange(?object $transactionExchange): static - { - $this->transactionExchange = $transactionExchange; - - return $this; - } - - /** - * @return Collection - */ - public function getSpentOn(): Collection - { - return $this->spentOn; - } - - public function addSpentOn(AccountingFunding $spentOn): static - { - if (!$this->spentOn->contains($spentOn)) { - $this->spentOn->add($spentOn); - $spentOn->setIncoming($this); - } - - return $this; - } - - public function removeSpentOn(AccountingFunding $spentOn): static - { - if ($this->spentOn->removeElement($spentOn)) { - // set the owning side to null (unless already changed) - if ($spentOn->getIncoming() === $this) { - $spentOn->setIncoming(null); - } - } - - return $this; - } -} diff --git a/src/Entity/AccountingOutgoing.php b/src/Entity/AccountingOutgoing.php deleted file mode 100644 index 278e2ed..0000000 --- a/src/Entity/AccountingOutgoing.php +++ /dev/null @@ -1,169 +0,0 @@ - new API\Link(fromClass: Accounting::class, fromProperty: 'id'), - 'id' => new API\Link(fromClass: AccountingOutgoing::class) - ], - operations: [new API\Get()] -)] -class AccountingOutgoing extends Monetizable -{ - #[ORM\Id] - #[ORM\GeneratedValue] - #[ORM\Column] - private ?int $id = null; - - /** - * Amount leaving the Accounting. - * Expressed in the minor unit of the currency (cents, pennies, etc) - */ - #[ORM\Column] - private int $amount = 0; - - /** - * 3-letter ISO 4217 currency code. Same as parent Accounting. - */ - #[ORM\Column(length: 3)] - private string $currency = ""; - - #[ORM\ManyToOne(inversedBy: 'outgoing')] - #[ORM\JoinColumn(nullable: false)] - private ?Accounting $accounting = null; - - /** - * The Transaction that generated this Outgoing. - */ - #[ORM\OneToOne(cascade: ['persist', 'remove'])] - #[ORM\JoinColumn(nullable: false)] - private ?Transaction $transaction = null; - - /** - * When a Transaction asks for a different currency an exchange operation will be performed.\ - * Original amount, currency and exchange rate data can be referenced here. - */ - #[ORM\Embedded(class: TransactionExchange::class)] - private ?object $transactionExchange = null; - - /** - * A list of Accounting Fundings detailing the Incomings that secured the funds. - */ - #[ORM\OneToMany(mappedBy: 'outgoing', targetEntity: AccountingFunding::class)] - private Collection $financedBy; - - public function __construct() - { - $this->financedBy = new ArrayCollection(); - } - - public function getId(): ?int - { - return $this->id; - } - - public function getAmount(): int - { - return $this->amount; - } - - public function setAmount(int $amount): static - { - $this->amount = $amount; - - return $this; - } - - public function getCurrency(): string - { - return $this->currency; - } - - public function setCurrency(string $currency): static - { - $this->currency = $currency; - - return $this; - } - - public function getAccounting(): ?Accounting - { - return $this->accounting; - } - - public function setAccounting(?Accounting $accounting): static - { - $this->accounting = $accounting; - - return $this; - } - - public function getTransaction(): ?Transaction - { - return $this->transaction; - } - - public function setTransaction(Transaction $transaction): static - { - $this->transaction = $transaction; - - return $this; - } - - public function getTransactionExchange(): ?object - { - return $this->transactionExchange; - } - - public function setTransactionExchange(?object $transactionExchange): static - { - $this->transactionExchange = $transactionExchange; - - return $this; - } - - /** - * @return Collection - */ - public function getFinancedBy(): Collection - { - return $this->financedBy; - } - - public function addFinancedBy(AccountingFunding $financedBy): static - { - if (!$this->financedBy->contains($financedBy)) { - $this->financedBy->add($financedBy); - $financedBy->setOutgoing($this); - } - - return $this; - } - - public function removeFinancedBy(AccountingFunding $financedBy): static - { - if ($this->financedBy->removeElement($financedBy)) { - // set the owning side to null (unless already changed) - if ($financedBy->getOutgoing() === $this) { - $financedBy->setOutgoing(null); - } - } - - return $this; - } -} diff --git a/src/Entity/Project.php b/src/Entity/Project.php deleted file mode 100644 index 421c0c2..0000000 --- a/src/Entity/Project.php +++ /dev/null @@ -1,62 +0,0 @@ -accounting = new Accounting(); - } - - public function getId(): ?int - { - return $this->id; - } - - public function getName(): ?string - { - return $this->name; - } - - public function setName(string $name): static - { - $this->name = $name; - - return $this; - } - - public function getAccounting(): ?Accounting - { - return $this->accounting; - } - - public function setAccounting(Accounting $accounting): static - { - $this->accounting = $accounting; - - return $this; - } -} diff --git a/src/Entity/Transaction.php b/src/Entity/Transaction.php deleted file mode 100644 index 654526e..0000000 --- a/src/Entity/Transaction.php +++ /dev/null @@ -1,129 +0,0 @@ -id; - } - - public function getAmount(): int - { - return $this->amount; - } - - public function setAmount(int $amount): static - { - $this->amount = $amount; - - return $this; - } - - public function getCurrency(): string - { - return $this->currency; - } - - public function setCurrency(string $currency): static - { - $this->currency = $currency; - - return $this; - } - - public function getOrigin(): ?TransactionOrigin - { - return $this->origin; - } - - public function setOrigin(TransactionOrigin $origin): static - { - $this->origin = $origin; - - return $this; - } - - public function getTarget(): ?TransactionTarget - { - return $this->target; - } - - public function setTarget(TransactionTarget $target): static - { - $this->target = $target; - - return $this; - } - - public function getGateway(): ?string - { - return $this->gateway; - } - - public function setGateway(string $gateway): static - { - $this->gateway = $gateway; - - return $this; - } -} diff --git a/src/Entity/TransactionExchange.php b/src/Entity/TransactionExchange.php deleted file mode 100644 index a66d2f7..0000000 --- a/src/Entity/TransactionExchange.php +++ /dev/null @@ -1,68 +0,0 @@ -amount = $amount; - $this->currency = $currency; - $this->rate = $rate; - $this->rateDateTime = $rateDateTime; - $this->rateProvider = $rateProvider; - } - - public function getAmount(): int - { - return $this->amount; - } - - public function getCurrency(): string - { - return $this->currency; - } -} diff --git a/src/Entity/TransactionOrigin.php b/src/Entity/TransactionOrigin.php deleted file mode 100644 index 169e71c..0000000 --- a/src/Entity/TransactionOrigin.php +++ /dev/null @@ -1,84 +0,0 @@ -id; - } - - public function getTransaction(): ?Transaction - { - return $this->transaction; - } - - public function setTransaction(Transaction $transaction): static - { - // set the owning side of the relation if necessary - if ($transaction->getOrigin() !== $this) { - $transaction->setOrigin($this); - } - - $this->transaction = $transaction; - - return $this; - } - - public function getAccounting(): ?Accounting - { - return $this->accounting; - } - - public function setAccounting(?Accounting $accounting): static - { - $this->accounting = $accounting; - - return $this; - } - - public function getOutgoing(): ?AccountingOutgoing - { - return $this->outgoing; - } - - public function setOutgoing(AccountingOutgoing $outgoing): static - { - $this->outgoing = $outgoing; - - return $this; - } -} diff --git a/src/Entity/TransactionTarget.php b/src/Entity/TransactionTarget.php deleted file mode 100644 index 066196b..0000000 --- a/src/Entity/TransactionTarget.php +++ /dev/null @@ -1,84 +0,0 @@ -id; - } - - public function getTransaction(): ?Transaction - { - return $this->transaction; - } - - public function setTransaction(Transaction $transaction): static - { - // set the owning side of the relation if necessary - if ($transaction->getTarget() !== $this) { - $transaction->setTarget($this); - } - - $this->transaction = $transaction; - - return $this; - } - - public function getAccounting(): ?Accounting - { - return $this->accounting; - } - - public function setAccounting(?Accounting $accounting): static - { - $this->accounting = $accounting; - - return $this; - } - - public function getIncoming(): ?AccountingIncoming - { - return $this->incoming; - } - - public function setIncoming(AccountingIncoming $incoming): static - { - $this->incoming = $incoming; - - return $this; - } -} diff --git a/src/Repository/AccountingFundingRepository.php b/src/Repository/AccountingFundingRepository.php deleted file mode 100644 index 1f26233..0000000 --- a/src/Repository/AccountingFundingRepository.php +++ /dev/null @@ -1,48 +0,0 @@ - - * - * @method AccountingFunding|null find($id, $lockMode = null, $lockVersion = null) - * @method AccountingFunding|null findOneBy(array $criteria, array $orderBy = null) - * @method AccountingFunding[] findAll() - * @method AccountingFunding[] findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null) - */ -class AccountingFundingRepository extends ServiceEntityRepository -{ - public function __construct(ManagerRegistry $registry) - { - parent::__construct($registry, AccountingFunding::class); - } - -// /** -// * @return AccountingFunding[] Returns an array of AccountingFunding 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): ?AccountingFunding -// { -// return $this->createQueryBuilder('a') -// ->andWhere('a.exampleField = :val') -// ->setParameter('val', $value) -// ->getQuery() -// ->getOneOrNullResult() -// ; -// } -} diff --git a/src/Repository/AccountingIncomingRepository.php b/src/Repository/AccountingIncomingRepository.php deleted file mode 100644 index 67993dc..0000000 --- a/src/Repository/AccountingIncomingRepository.php +++ /dev/null @@ -1,48 +0,0 @@ - - * - * @method AccountingIncoming|null find($id, $lockMode = null, $lockVersion = null) - * @method AccountingIncoming|null findOneBy(array $criteria, array $orderBy = null) - * @method AccountingIncoming[] findAll() - * @method AccountingIncoming[] findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null) - */ -class AccountingIncomingRepository extends ServiceEntityRepository -{ - public function __construct(ManagerRegistry $registry) - { - parent::__construct($registry, AccountingIncoming::class); - } - -// /** -// * @return AccountingIncoming[] Returns an array of AccountingIncoming 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): ?AccountingIncoming -// { -// return $this->createQueryBuilder('a') -// ->andWhere('a.exampleField = :val') -// ->setParameter('val', $value) -// ->getQuery() -// ->getOneOrNullResult() -// ; -// } -} diff --git a/src/Repository/AccountingOutgoingRepository.php b/src/Repository/AccountingOutgoingRepository.php deleted file mode 100644 index 84af864..0000000 --- a/src/Repository/AccountingOutgoingRepository.php +++ /dev/null @@ -1,48 +0,0 @@ - - * - * @method AccountingOutgoing|null find($id, $lockMode = null, $lockVersion = null) - * @method AccountingOutgoing|null findOneBy(array $criteria, array $orderBy = null) - * @method AccountingOutgoing[] findAll() - * @method AccountingOutgoing[] findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null) - */ -class AccountingOutgoingRepository extends ServiceEntityRepository -{ - public function __construct(ManagerRegistry $registry) - { - parent::__construct($registry, AccountingOutgoing::class); - } - -// /** -// * @return AccountingOutgoing[] Returns an array of AccountingOutgoing 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): ?AccountingOutgoing -// { -// return $this->createQueryBuilder('a') -// ->andWhere('a.exampleField = :val') -// ->setParameter('val', $value) -// ->getQuery() -// ->getOneOrNullResult() -// ; -// } -} diff --git a/src/Repository/AccountingRepository.php b/src/Repository/AccountingRepository.php deleted file mode 100644 index cd500ab..0000000 --- a/src/Repository/AccountingRepository.php +++ /dev/null @@ -1,48 +0,0 @@ - - * - * @method Accounting|null find($id, $lockMode = null, $lockVersion = null) - * @method Accounting|null findOneBy(array $criteria, array $orderBy = null) - * @method Accounting[] findAll() - * @method Accounting[] findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null) - */ -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() -// ; -// } -} diff --git a/src/Repository/ProjectRepository.php b/src/Repository/ProjectRepository.php deleted file mode 100644 index 477b761..0000000 --- a/src/Repository/ProjectRepository.php +++ /dev/null @@ -1,48 +0,0 @@ - - * - * @method Project|null find($id, $lockMode = null, $lockVersion = null) - * @method Project|null findOneBy(array $criteria, array $orderBy = null) - * @method Project[] findAll() - * @method Project[] findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null) - */ -class ProjectRepository extends ServiceEntityRepository -{ - public function __construct(ManagerRegistry $registry) - { - parent::__construct($registry, Project::class); - } - -// /** -// * @return Project[] Returns an array of Project objects -// */ -// public function findByExampleField($value): array -// { -// return $this->createQueryBuilder('p') -// ->andWhere('p.exampleField = :val') -// ->setParameter('val', $value) -// ->orderBy('p.id', 'ASC') -// ->setMaxResults(10) -// ->getQuery() -// ->getResult() -// ; -// } - -// public function findOneBySomeField($value): ?Project -// { -// return $this->createQueryBuilder('p') -// ->andWhere('p.exampleField = :val') -// ->setParameter('val', $value) -// ->getQuery() -// ->getOneOrNullResult() -// ; -// } -} diff --git a/src/Repository/TransactionOriginRepository.php b/src/Repository/TransactionOriginRepository.php deleted file mode 100644 index b0c0ccd..0000000 --- a/src/Repository/TransactionOriginRepository.php +++ /dev/null @@ -1,48 +0,0 @@ - - * - * @method TransactionOrigin|null find($id, $lockMode = null, $lockVersion = null) - * @method TransactionOrigin|null findOneBy(array $criteria, array $orderBy = null) - * @method TransactionOrigin[] findAll() - * @method TransactionOrigin[] findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null) - */ -class TransactionOriginRepository extends ServiceEntityRepository -{ - public function __construct(ManagerRegistry $registry) - { - parent::__construct($registry, TransactionOrigin::class); - } - -// /** -// * @return TransactionOrigin[] Returns an array of TransactionOrigin objects -// */ -// public function findByExampleField($value): array -// { -// return $this->createQueryBuilder('t') -// ->andWhere('t.exampleField = :val') -// ->setParameter('val', $value) -// ->orderBy('t.id', 'ASC') -// ->setMaxResults(10) -// ->getQuery() -// ->getResult() -// ; -// } - -// public function findOneBySomeField($value): ?TransactionOrigin -// { -// return $this->createQueryBuilder('t') -// ->andWhere('t.exampleField = :val') -// ->setParameter('val', $value) -// ->getQuery() -// ->getOneOrNullResult() -// ; -// } -} diff --git a/src/Repository/TransactionRepository.php b/src/Repository/TransactionRepository.php deleted file mode 100644 index 8dc1122..0000000 --- a/src/Repository/TransactionRepository.php +++ /dev/null @@ -1,48 +0,0 @@ - - * - * @method Transaction|null find($id, $lockMode = null, $lockVersion = null) - * @method Transaction|null findOneBy(array $criteria, array $orderBy = null) - * @method Transaction[] findAll() - * @method Transaction[] findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null) - */ -class TransactionRepository extends ServiceEntityRepository -{ - public function __construct(ManagerRegistry $registry) - { - parent::__construct($registry, Transaction::class); - } - -// /** -// * @return Transaction[] Returns an array of Transaction objects -// */ -// public function findByExampleField($value): array -// { -// return $this->createQueryBuilder('t') -// ->andWhere('t.exampleField = :val') -// ->setParameter('val', $value) -// ->orderBy('t.id', 'ASC') -// ->setMaxResults(10) -// ->getQuery() -// ->getResult() -// ; -// } - -// public function findOneBySomeField($value): ?Transaction -// { -// return $this->createQueryBuilder('t') -// ->andWhere('t.exampleField = :val') -// ->setParameter('val', $value) -// ->getQuery() -// ->getOneOrNullResult() -// ; -// } -} diff --git a/src/Repository/TransactionTargetRepository.php b/src/Repository/TransactionTargetRepository.php deleted file mode 100644 index c2a46f0..0000000 --- a/src/Repository/TransactionTargetRepository.php +++ /dev/null @@ -1,48 +0,0 @@ - - * - * @method TransactionTarget|null find($id, $lockMode = null, $lockVersion = null) - * @method TransactionTarget|null findOneBy(array $criteria, array $orderBy = null) - * @method TransactionTarget[] findAll() - * @method TransactionTarget[] findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null) - */ -class TransactionTargetRepository extends ServiceEntityRepository -{ - public function __construct(ManagerRegistry $registry) - { - parent::__construct($registry, TransactionTarget::class); - } - -// /** -// * @return TransactionTarget[] Returns an array of TransactionTarget objects -// */ -// public function findByExampleField($value): array -// { -// return $this->createQueryBuilder('t') -// ->andWhere('t.exampleField = :val') -// ->setParameter('val', $value) -// ->orderBy('t.id', 'ASC') -// ->setMaxResults(10) -// ->getQuery() -// ->getResult() -// ; -// } - -// public function findOneBySomeField($value): ?TransactionTarget -// { -// return $this->createQueryBuilder('t') -// ->andWhere('t.exampleField = :val') -// ->setParameter('val', $value) -// ->getQuery() -// ->getOneOrNullResult() -// ; -// } -} diff --git a/src/Service/AccountingService.php b/src/Service/AccountingService.php deleted file mode 100644 index 0ba78c2..0000000 --- a/src/Service/AccountingService.php +++ /dev/null @@ -1,129 +0,0 @@ -getOrigin()->getAccounting(); - if (!$accounting->hasCurrencyOf($attempt)) { - $exchange = $this->exchanges->getExchangeFor($attempt->getCurrency(), $accounting->getCurrency()); - $conversion = $exchange->getConversion($attempt, $accounting->getCurrency()); - - $attempt->setAmount($conversion->getAmount()); - $attempt->setCurrency($conversion->getCurrency()); - - $transactionExchange = new TransactionExchange( - $transaction->getAmount(), - $transaction->getCurrency(), - $exchange->getConversionRate($transaction->getCurrency(), $accounting->getCurrency()), - $exchange->getConversionDate($transaction->getCurrency(), $accounting->getCurrency()), - $exchange->getName(), - ); - } - - if ($accounting->isLessThan($attempt)) { - throw new \Exception("The origin Accounting cannot secure the funding for the Transaction"); - } - - $outgoing = new AccountingOutgoing(); - $outgoing->setCurrency($accounting->getCurrency()); - $outgoing->setAccounting($accounting); - $outgoing->setTransaction($transaction); - $outgoing->setTransactionExchange($transactionExchange); - - foreach ($accounting->getIncomings() as $incoming) { - if ($attempt->isZero()) break; - if ($incoming->isZero()) continue; - - $funding = new AccountingFunding(); - $funding->setCurrency($incoming->getCurrency()); - - if ($incoming->isGreaterThan($attempt)) { - $funding->plus($attempt); - $incoming->minus($attempt); - $attempt->setAmount(0); - } - - if ($incoming->isLessThanOrEqualTo($attempt)) { - $funding->plus($incoming); - $attempt->minus($incoming); - $incoming->setAmount(0); - } - - $incoming->addSpentOn($funding); - - $outgoing->plus($funding); - $outgoing->addFinancedBy($funding); - - $accounting->minus($funding); - - continue; - } - - $accounting->addOutgoing($outgoing); - - $origin = $transaction->getOrigin(); - $origin->setOutgoing($outgoing); - - $transaction->setOrigin($origin); - - return $transaction; - } - - public function storeTransaction(Transaction $transaction): Transaction - { - $transactionExchange = null; - - $accounting = $transaction->getTarget()->getAccounting(); - if (!$accounting->hasCurrencyOf($transaction)) { - $exchange = $this->exchanges->getExchangeFor($transaction->getCurrency(), $accounting->getCurrency()); - $conversion = $exchange->getConversion($transaction, $accounting->getCurrency()); - - $transaction->setAmount($conversion->getAmount()); - $transaction->setCurrency($conversion->getCurrency()); - - $transactionExchange = new TransactionExchange( - $transaction->getAmount(), - $transaction->getCurrency(), - $exchange->getConversionRate($transaction->getCurrency(), $accounting->getCurrency()), - $exchange->getConversionDate($transaction->getCurrency(), $accounting->getCurrency()), - $exchange->getName(), - ); - } - - $incoming = new AccountingIncoming(); - $incoming->setAmount($transaction->getAmount()); - $incoming->setAmountOriginal($transaction->getAmount()); - $incoming->setCurrency($accounting->getCurrency()); - $incoming->setAccounting($accounting); - $incoming->setTransaction($transaction); - $incoming->setTransactionExchange($transactionExchange); - - $accounting->setAmount($accounting->plus($incoming)->getAmount()); - $accounting->addIncoming($incoming); - - $target = $transaction->getTarget(); - $target->setIncoming($incoming); - - $transaction->setTarget($target); - - return $transaction; - } -} diff --git a/src/State/TransactionStateProcessor.php b/src/State/TransactionStateProcessor.php deleted file mode 100644 index a97eba6..0000000 --- a/src/State/TransactionStateProcessor.php +++ /dev/null @@ -1,39 +0,0 @@ -getOrigin()->getAccounting()->getId() === - $transaction->getTarget()->getAccounting()->getId() - ) { - throw new \Exception("The target Accounting cannot be the same as the origin Accounting"); - } - - $transaction = $this->accountingService->spendTransaction($transaction); - $transaction = $this->accountingService->storeTransaction($transaction); - - var_dump($transaction); - exit; - - return $transaction; - } -}