Merge branch 'develop' into feat/gv4-099-add-charge-refund-in-paypal

This commit is contained in:
2025-05-07 15:58:10 +02:00
5 changed files with 50 additions and 44 deletions
@@ -5,6 +5,7 @@ namespace App\ApiResource\Accounting;
use ApiPlatform\Doctrine\Orm\State\Options;
use ApiPlatform\Metadata as API;
use App\ApiResource\Project\ProjectApiResource;
use App\ApiResource\TipjarApiResource;
use App\ApiResource\User\UserApiResource;
use App\Entity\Accounting\Accounting;
use App\Entity\Money;
@@ -56,7 +57,7 @@ class AccountingApiResource
/**
* The resource owning this Accounting.
*
* @return UserApiResource|ProjectApiResource|Tipjar
* @return UserApiResource|ProjectApiResource|TipjarApiResource
*/
public function getOwner(): ?object
{
@@ -79,5 +80,5 @@ class AccountingApiResource
public ?ProjectApiResource $project = null;
#[API\ApiProperty(readable: false, writable: false)]
public ?Tipjar $tipjar = null;
public ?TipjarApiResource $tipjar = null;
}
@@ -24,7 +24,7 @@ use Symfony\Component\Validator\Constraints as Assert;
provider: ApiResourceStateProvider::class
)]
#[API\Get()]
#[API\GetCollection(security: "is_granted('IS_AUTHENTICATED_FULLY')")]
#[API\GetCollection()]
#[API\Patch(
input: ChargeUpdationDto::class,
processor: ChargeStateProcessor::class,
@@ -37,7 +37,7 @@ class ChargeApiResource
/**
* The Checkout to which this Charge item belongs to.
*/
#[API\ApiProperty(writable: false)]
#[API\ApiProperty(writable: false, security: 'is_granted("IS_AUTHENTICATED_FULLY")')]
public CheckoutApiResource $checkout;
/**
+42
View File
@@ -0,0 +1,42 @@
<?php
namespace App\ApiResource;
use ApiPlatform\Doctrine\Orm\State\Options;
use ApiPlatform\Metadata as API;
use App\ApiResource\Accounting\AccountingApiResource;
use App\Entity\Tipjar;
use App\State\ApiResourceStateProcessor;
use App\State\ApiResourceStateProvider;
use Symfony\Component\Validator\Constraints as Assert;
/**
* Unlike other Money recipients a Tipjar receives money with no further goal.\
* \
* Tips to the platform owners and other no-purpose money can target a Tipjar.
*/
#[API\ApiResource(
shortName: 'Tipjar',
stateOptions: new Options(entityClass: Tipjar::class),
provider: ApiResourceStateProvider::class,
processor: ApiResourceStateProcessor::class
)]
#[API\GetCollection()]
#[API\Post()]
#[API\Get()]
#[API\Delete()]
#[API\Patch()]
class TipjarApiResource
{
#[API\ApiProperty(identifier: true, writable: false)]
public int $id;
#[API\ApiProperty(writable: false)]
public AccountingApiResource $accounting;
/**
* Human readable, non white space, unique string.
*/
#[Assert\NotBlank()]
public string $name;
}
-33
View File
@@ -1,33 +0,0 @@
<?php
namespace App\Doctrine;
use App\Entity\Gateway\Charge;
use App\Security\Trait\UserTrait;
use Doctrine\ORM\QueryBuilder;
final class GatewayChargeExtension extends AbstractQueryResourceExtensionInterface
{
use UserTrait;
protected function supports(string $resourceClass): bool
{
return $resourceClass === Charge::class;
}
protected function applyFilters(QueryBuilder $queryBuilder, string $rootAlias): void
{
$user = $this->getAuthenticatedUser();
if ($this->isAdmin($user)) {
return;
}
$queryBuilder
->leftJoin("$rootAlias.checkout", 'c')
->leftJoin('c.origin', 'co')
->leftJoin('co.user', 'u')
->andWhere('u.id = :userId')
->setParameter('userId', $user->getId());
}
}
+3 -7
View File
@@ -2,10 +2,11 @@
namespace App\Entity;
use ApiPlatform\Metadata as API;
use App\Entity\Accounting\Accounting;
use App\Entity\Interface\AccountingOwnerInterface;
use App\Mapping\Provider\EntityMapProvider;
use App\Repository\TipjarRepository;
use AutoMapper\Attribute\MapProvider;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
@@ -14,12 +15,8 @@ use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
* \
* Tips to the platform owners and other no-purpose money can target a Tipjar.
*/
#[MapProvider(EntityMapProvider::class)]
#[UniqueEntity(fields: ['name'], message: 'A Tipjar with that name already exists.')]
#[API\GetCollection()]
#[API\Post()]
#[API\Get()]
#[API\Delete()]
#[API\Patch()]
#[ORM\Entity(repositoryClass: TipjarRepository::class)]
class Tipjar implements AccountingOwnerInterface
{
@@ -34,7 +31,6 @@ class Tipjar implements AccountingOwnerInterface
#[ORM\Column(length: 255)]
private ?string $name = null;
#[API\ApiProperty(writable: false)]
#[ORM\OneToOne(inversedBy: 'tipjar', cascade: ['persist'])]
private ?Accounting $accounting = null;