Minor bug fixes

This commit is contained in:
2025-09-09 14:19:45 +02:00
parent 545f188c1e
commit fe18ae8edc
8 changed files with 20 additions and 9 deletions
+1 -1
View File
@@ -28,7 +28,7 @@ class ApiMoney implements MoneyInterface
* Conversion metadata.
*/
#[API\ApiProperty(readable: true, writable: false)]
public ?array $conversion;
public ?array $conversion = null;
public function __construct(
int $amount,
@@ -13,6 +13,7 @@ use App\Entity\Project\Reward;
use App\State\ApiResourceStateProvider;
use App\State\Project\RewardStateProcessor;
use AutoMapper\Attribute\MapTo;
use Symfony\Component\Serializer\Attribute\MaxDepth;
use Symfony\Component\Validator\Constraints as Assert;
/**
@@ -91,5 +92,6 @@ class RewardApiResource
* @var RewardClaimApiResource[]
*/
#[API\ApiProperty(writable: false)]
#[MaxDepth(2)]
public array $claims;
}
+7 -1
View File
@@ -64,7 +64,13 @@ class UsersPump implements PumpInterface
private function getDateCreated(array $record): \DateTime
{
return new \DateTime($record['created'] ?? $record['modified']);
$created = new \DateTime($record['created'] ?? '0000-00-00');
if ($created > new \DateTime('2011-01-01')) {
return $created;
}
return new \DateTime($record['modified'] ?? 'now');
}
private function getUserType(array $record): UserType
+1 -1
View File
@@ -27,7 +27,7 @@ class RewardClaim implements UserOwnedInterface
#[ORM\JoinColumn(nullable: false)]
private ?Charge $charge = null;
#[ORM\ManyToOne(inversedBy: 'claims')]
#[ORM\ManyToOne(inversedBy: 'claims', cascade: ['persist'])]
#[ORM\JoinColumn(nullable: false)]
private ?Reward $reward = null;
+1 -1
View File
@@ -16,7 +16,7 @@ use Doctrine\ORM\Mapping\Embedded;
#[MapProvider(EntityMapProvider::class)]
#[ORM\Table(name: 'project_support')]
#[ORM\UniqueConstraint(fields: ['project', 'origin'])]
#[ORM\UniqueConstraint(fields: ['project', 'origin'], name: 'project_origin_unique')]
#[ORM\Entity(repositoryClass: SupportRepository::class)]
class Support
{
@@ -99,8 +99,8 @@ class GatewayCheckoutSupportsListener
{
/** @var Support|null */
$projectSupport = $this->supportRepository->findOneBy([
'project' => $project->getId(),
'origin' => $origin->getId(),
'project' => $project,
'origin' => $origin,
]);
if (!$projectSupport) {
+3 -1
View File
@@ -4,13 +4,15 @@ namespace App\Mapping;
use AutoMapper\AutoMapper as InnerMapper;
use AutoMapper\AutoMapperInterface;
use AutoMapper\MapperContext;
class AutoMapper implements AutoMapperInterface
{
public const CACHE_DIR = 'automapper';
public const DEFAULT_CONTEXT = [
'skip_null_values' => true,
MapperContext::DEPTH => 1,
MapperContext::SKIP_NULL_VALUES => true,
];
private AutoMapperInterface $innerMapper;
+3 -2
View File
@@ -55,7 +55,7 @@ class AccountingService
*
* @return Transaction[]
*/
private function getTransactionsInPeriod(
private function filterTransactions(
array $transactions,
\DateTimeInterface $start,
\DateTimeInterface $end,
@@ -97,13 +97,14 @@ class AccountingService
$period->getStartDate(),
$period->getEndDate(),
);
$points = [];
$totalBalance = new Money(0, $accounting->getCurrency());
$accountingId = $accounting->getId();
foreach ($period as $start) {
$end = \DateTime::createFromInterface($start)->add($period->getDateInterval());
$periodTrxs = $this->getTransactionsInPeriod($trxs, $start, $end);
$periodTrxs = $this->filterTransactions($trxs, $start, $end);
$balance = $aggregate ? $totalBalance : new Money(0, $accounting->getCurrency());
foreach ($periodTrxs as $trx) {