From a3e7f34c56d132d8d0d3c4ec67b1b93c251df5a2 Mon Sep 17 00:00:00 2001 From: vgreb Date: Sat, 25 Jul 2026 00:21:04 +0200 Subject: [PATCH] Refonte cotisations avec Doctrine --- app/config/packages/doctrine.yaml | 5 + app/config/packages/ting.yaml | 7 - phpstan-baseline.php | 166 ++++--------- .../SubscriptionManagement.php | 6 +- .../UserMembership/SeniorityComputer.php | 15 +- .../UserMembership/UserService.php | 4 +- .../PayboxCallbackSimulatorCommand.php | 2 +- .../MembershipFee/AddMembershipFeeAction.php | 29 ++- .../DeleteMembershipFeeAction.php | 6 +- .../MembershipFee/EditMembershipFeeAction.php | 6 +- .../MembershipFee/ListMembershipFeeAction.php | 6 +- .../Controller/Website/Member/IndexAction.php | 6 +- .../Website/Membership/Fee/DownloadAction.php | 14 +- .../Website/Membership/Fee/IndexAction.php | 18 +- .../Membership/GeneralMeeting/IndexAction.php | 2 +- .../Website/Membership/InvoiceAction.php | 6 +- .../Membership/PayboxCallbackAction.php | 4 +- .../Website/Membership/PaymentAction.php | 10 +- .../MembershipFee/Entity/Cotisation.php | 66 +++++ .../Repository/CotisationRepository.php | 76 ++++++ .../MembershipFee/Form/MembershipFeeType.php | 14 +- .../MembershipFeeInvoicePdfGenerator.php | 34 +-- .../MembershipFee/MembershipFeeMailer.php | 20 +- .../MembershipFee/MembershipFeeService.php | 53 ++-- .../MembershipFee/Model/MembershipFee.php | 226 ------------------ .../Repository/MembershipFeeRepository.php | 224 ----------------- .../MembershipFee/OnlinePaymentHandler.php | 6 +- .../AppBundle/Security/MembershipFeeVoter.php | 18 +- .../accounting/membership/form.html.twig | 14 +- .../accounting/membership/list.html.twig | 18 +- .../membership/membershipfee.html.twig | 12 +- .../site/company_membership/payment.html.twig | 8 +- .../AdminPersonnesMoralesCotisations.feature | 26 +- ...AdminPersonnesPhysiquesCotisations.feature | 24 +- .../MembershipFeeServiceTest.php | 12 +- 35 files changed, 386 insertions(+), 777 deletions(-) create mode 100644 sources/AppBundle/MembershipFee/Entity/Cotisation.php create mode 100644 sources/AppBundle/MembershipFee/Entity/Repository/CotisationRepository.php delete mode 100644 sources/AppBundle/MembershipFee/Model/MembershipFee.php delete mode 100644 sources/AppBundle/MembershipFee/Model/Repository/MembershipFeeRepository.php diff --git a/app/config/packages/doctrine.yaml b/app/config/packages/doctrine.yaml index 6b14a03ab..b3ca28ec9 100644 --- a/app/config/packages/doctrine.yaml +++ b/app/config/packages/doctrine.yaml @@ -31,6 +31,11 @@ doctrine: is_bundle: false dir: '%kernel.project_dir%/../sources/AppBundle/Association/Entity' prefix: 'AppBundle\Association\Entity' + MembershipFee: + type: attribute + is_bundle: false + dir: '%kernel.project_dir%/../sources/AppBundle/MembershipFee/Entity' + prefix: 'AppBundle\MembershipFee\Entity' AssembleeGenerale: type: attribute is_bundle: false diff --git a/app/config/packages/ting.yaml b/app/config/packages/ting.yaml index 67a05af85..50e74aa9c 100644 --- a/app/config/packages/ting.yaml +++ b/app/config/packages/ting.yaml @@ -31,10 +31,3 @@ ting: default: connection: main database: '%database_name%' - membershipfee: - namespace: AppBundle\MembershipFee\Model\Repository - directory: "@AppBundle/MembershipFee/Model/Repository" - options: - default: - connection: main - database: "%database_name%" diff --git a/phpstan-baseline.php b/phpstan-baseline.php index 05d397863..33d97a0e4 100644 --- a/phpstan-baseline.php +++ b/phpstan-baseline.php @@ -3086,7 +3086,7 @@ 'path' => __DIR__ . '/sources/AppBundle/Controller/Admin/Accounting/MembershipFee/AddMembershipFeeAction.php', ]; $ignoreErrors[] = [ - 'message' => '#^Parameter \\#1 \\$entity of method CCMBenchmark\\\\Ting\\\\Repository\\\\Repository\\\\:\\:delete\\(\\) expects AppBundle\\\\MembershipFee\\\\Model\\\\MembershipFee, AppBundle\\\\MembershipFee\\\\Model\\\\MembershipFee\\|null given\\.$#', + 'message' => '#^Parameter \\#1 \\$entity of method AppBundle\\\\Doctrine\\\\EntityRepository\\\\:\\:delete\\(\\) expects AppBundle\\\\MembershipFee\\\\Entity\\\\Cotisation, AppBundle\\\\MembershipFee\\\\Entity\\\\Cotisation\\|null given\\.$#', 'identifier' => 'argument.type', 'count' => 1, 'path' => __DIR__ . '/sources/AppBundle/Controller/Admin/Accounting/MembershipFee/DeleteMembershipFeeAction.php', @@ -3122,7 +3122,7 @@ 'path' => __DIR__ . '/sources/AppBundle/Controller/Admin/Accounting/MembershipFee/EditMembershipFeeAction.php', ]; $ignoreErrors[] = [ - 'message' => '#^Parameter \\#1 \\$entity of method CCMBenchmark\\\\Ting\\\\Repository\\\\Repository\\\\:\\:save\\(\\) expects AppBundle\\\\MembershipFee\\\\Model\\\\MembershipFee, AppBundle\\\\MembershipFee\\\\Model\\\\MembershipFee\\|null given\\.$#', + 'message' => '#^Parameter \\#1 \\$entity of method AppBundle\\\\Doctrine\\\\EntityRepository\\\\:\\:save\\(\\) expects AppBundle\\\\MembershipFee\\\\Entity\\\\Cotisation, AppBundle\\\\MembershipFee\\\\Entity\\\\Cotisation\\|null given\\.$#', 'identifier' => 'argument.type', 'count' => 1, 'path' => __DIR__ . '/sources/AppBundle/Controller/Admin/Accounting/MembershipFee/EditMembershipFeeAction.php', @@ -5498,25 +5498,25 @@ 'path' => __DIR__ . '/sources/AppBundle/Controller/Website/Membership/ContactDetailsAction.php', ]; $ignoreErrors[] = [ - 'message' => '#^Cannot call method format\\(\\) on DateTime\\|null\\.$#', - 'identifier' => 'method.nonObject', + 'message' => '#^Cannot access property \\$dateDebut on AppBundle\\\\MembershipFee\\\\Entity\\\\Cotisation\\|null\\.$#', + 'identifier' => 'property.nonObject', 'count' => 1, 'path' => __DIR__ . '/sources/AppBundle/Controller/Website/Membership/Fee/DownloadAction.php', ]; $ignoreErrors[] = [ - 'message' => '#^Cannot call method getStartDate\\(\\) on AppBundle\\\\MembershipFee\\\\Model\\\\MembershipFee\\|null\\.$#', - 'identifier' => 'method.nonObject', - 'count' => 1, + 'message' => '#^Cannot access property \\$idPersonne on AppBundle\\\\MembershipFee\\\\Entity\\\\Cotisation\\|null\\.$#', + 'identifier' => 'property.nonObject', + 'count' => 2, 'path' => __DIR__ . '/sources/AppBundle/Controller/Website/Membership/Fee/DownloadAction.php', ]; $ignoreErrors[] = [ - 'message' => '#^Cannot call method getUserId\\(\\) on AppBundle\\\\MembershipFee\\\\Model\\\\MembershipFee\\|null\\.$#', - 'identifier' => 'method.nonObject', - 'count' => 2, + 'message' => '#^Cannot access property \\$typePersonne on AppBundle\\\\MembershipFee\\\\Entity\\\\Cotisation\\|null\\.$#', + 'identifier' => 'property.nonObject', + 'count' => 1, 'path' => __DIR__ . '/sources/AppBundle/Controller/Website/Membership/Fee/DownloadAction.php', ]; $ignoreErrors[] = [ - 'message' => '#^Cannot call method getUserType\\(\\) on AppBundle\\\\MembershipFee\\\\Model\\\\MembershipFee\\|null\\.$#', + 'message' => '#^Cannot call method format\\(\\) on DateTime\\|null\\.$#', 'identifier' => 'method.nonObject', 'count' => 1, 'path' => __DIR__ . '/sources/AppBundle/Controller/Website/Membership/Fee/DownloadAction.php', @@ -5564,8 +5564,8 @@ 'path' => __DIR__ . '/sources/AppBundle/Controller/Website/Membership/GeneralMeeting/IndexAction.php', ]; $ignoreErrors[] = [ - 'message' => '#^Cannot call method getEndDate\\(\\) on AppBundle\\\\MembershipFee\\\\Model\\\\MembershipFee\\|null\\.$#', - 'identifier' => 'method.nonObject', + 'message' => '#^Cannot access property \\$dateFin on AppBundle\\\\MembershipFee\\\\Entity\\\\Cotisation\\|null\\.$#', + 'identifier' => 'property.nonObject', 'count' => 1, 'path' => __DIR__ . '/sources/AppBundle/Controller/Website/Membership/GeneralMeeting/IndexAction.php', ]; @@ -9080,61 +9080,55 @@ 'path' => __DIR__ . '/sources/AppBundle/MembershipFee/MembershipFeeInvoicePdfGenerator.php', ]; $ignoreErrors[] = [ - 'message' => '#^Cannot call method format\\(\\) on DateTimeImmutable\\|false\\.$#', - 'identifier' => 'method.nonObject', - 'count' => 1, + 'message' => '#^Cannot access property \\$dateDebut on AppBundle\\\\MembershipFee\\\\Entity\\\\Cotisation\\|null\\.$#', + 'identifier' => 'property.nonObject', + 'count' => 2, 'path' => __DIR__ . '/sources/AppBundle/MembershipFee/MembershipFeeInvoicePdfGenerator.php', ]; $ignoreErrors[] = [ - 'message' => '#^Cannot call method getAmount\\(\\) on AppBundle\\\\MembershipFee\\\\Model\\\\MembershipFee\\|null\\.$#', - 'identifier' => 'method.nonObject', + 'message' => '#^Cannot access property \\$dateFin on AppBundle\\\\MembershipFee\\\\Entity\\\\Cotisation\\|null\\.$#', + 'identifier' => 'property.nonObject', 'count' => 1, 'path' => __DIR__ . '/sources/AppBundle/MembershipFee/MembershipFeeInvoicePdfGenerator.php', ]; $ignoreErrors[] = [ - 'message' => '#^Cannot call method getClientReference\\(\\) on AppBundle\\\\MembershipFee\\\\Model\\\\MembershipFee\\|null\\.$#', - 'identifier' => 'method.nonObject', - 'count' => 2, - 'path' => __DIR__ . '/sources/AppBundle/MembershipFee/MembershipFeeInvoicePdfGenerator.php', -]; -$ignoreErrors[] = [ - 'message' => '#^Cannot call method getEndDate\\(\\) on AppBundle\\\\MembershipFee\\\\Model\\\\MembershipFee\\|null\\.$#', - 'identifier' => 'method.nonObject', + 'message' => '#^Cannot access property \\$idPersonne on AppBundle\\\\MembershipFee\\\\Entity\\\\Cotisation\\|null\\.$#', + 'identifier' => 'property.nonObject', 'count' => 1, 'path' => __DIR__ . '/sources/AppBundle/MembershipFee/MembershipFeeInvoicePdfGenerator.php', ]; $ignoreErrors[] = [ - 'message' => '#^Cannot call method getInvoiceDate\\(\\) on AppBundle\\\\MembershipFee\\\\Model\\\\MembershipFee\\|null\\.$#', - 'identifier' => 'method.nonObject', + 'message' => '#^Cannot access property \\$montant on AppBundle\\\\MembershipFee\\\\Entity\\\\Cotisation\\|null\\.$#', + 'identifier' => 'property.nonObject', 'count' => 1, 'path' => __DIR__ . '/sources/AppBundle/MembershipFee/MembershipFeeInvoicePdfGenerator.php', ]; $ignoreErrors[] = [ - 'message' => '#^Cannot call method getInvoiceNumber\\(\\) on AppBundle\\\\MembershipFee\\\\Model\\\\MembershipFee\\|null\\.$#', - 'identifier' => 'method.nonObject', + 'message' => '#^Cannot access property \\$numeroFacture on AppBundle\\\\MembershipFee\\\\Entity\\\\Cotisation\\|null\\.$#', + 'identifier' => 'property.nonObject', 'count' => 4, 'path' => __DIR__ . '/sources/AppBundle/MembershipFee/MembershipFeeInvoicePdfGenerator.php', ]; $ignoreErrors[] = [ - 'message' => '#^Cannot call method getStartDate\\(\\) on AppBundle\\\\MembershipFee\\\\Model\\\\MembershipFee\\|null\\.$#', - 'identifier' => 'method.nonObject', + 'message' => '#^Cannot access property \\$referenceClient on AppBundle\\\\MembershipFee\\\\Entity\\\\Cotisation\\|null\\.$#', + 'identifier' => 'property.nonObject', 'count' => 2, 'path' => __DIR__ . '/sources/AppBundle/MembershipFee/MembershipFeeInvoicePdfGenerator.php', ]; $ignoreErrors[] = [ - 'message' => '#^Cannot call method getTimestamp\\(\\) on DateTime\\|null\\.$#', - 'identifier' => 'method.nonObject', + 'message' => '#^Cannot access property \\$typePersonne on AppBundle\\\\MembershipFee\\\\Entity\\\\Cotisation\\|null\\.$#', + 'identifier' => 'property.nonObject', 'count' => 3, 'path' => __DIR__ . '/sources/AppBundle/MembershipFee/MembershipFeeInvoicePdfGenerator.php', ]; $ignoreErrors[] = [ - 'message' => '#^Cannot call method getUserId\\(\\) on AppBundle\\\\MembershipFee\\\\Model\\\\MembershipFee\\|null\\.$#', + 'message' => '#^Cannot call method format\\(\\) on DateTimeImmutable\\|false\\.$#', 'identifier' => 'method.nonObject', 'count' => 1, 'path' => __DIR__ . '/sources/AppBundle/MembershipFee/MembershipFeeInvoicePdfGenerator.php', ]; $ignoreErrors[] = [ - 'message' => '#^Cannot call method getUserType\\(\\) on AppBundle\\\\MembershipFee\\\\Model\\\\MembershipFee\\|null\\.$#', + 'message' => '#^Cannot call method getTimestamp\\(\\) on DateTime\\|null\\.$#', 'identifier' => 'method.nonObject', 'count' => 3, 'path' => __DIR__ . '/sources/AppBundle/MembershipFee/MembershipFeeInvoicePdfGenerator.php', @@ -9188,116 +9182,44 @@ 'path' => __DIR__ . '/sources/AppBundle/MembershipFee/MembershipFeeInvoicePdfGenerator.php', ]; $ignoreErrors[] = [ - 'message' => '#^Cannot access property \\$value on AppBundle\\\\Association\\\\MemberType\\|null\\.$#', + 'message' => '#^Cannot access property \\$dateDebut on AppBundle\\\\MembershipFee\\\\Entity\\\\Cotisation\\|null\\.$#', 'identifier' => 'property.nonObject', 'count' => 1, 'path' => __DIR__ . '/sources/AppBundle/MembershipFee/MembershipFeeMailer.php', ]; $ignoreErrors[] = [ - 'message' => '#^Cannot call method getStartDate\\(\\) on AppBundle\\\\MembershipFee\\\\Model\\\\MembershipFee\\|null\\.$#', - 'identifier' => 'method.nonObject', - 'count' => 1, - 'path' => __DIR__ . '/sources/AppBundle/MembershipFee/MembershipFeeMailer.php', -]; -$ignoreErrors[] = [ - 'message' => '#^Cannot call method getTimestamp\\(\\) on DateTime\\|null\\.$#', - 'identifier' => 'method.nonObject', - 'count' => 1, - 'path' => __DIR__ . '/sources/AppBundle/MembershipFee/MembershipFeeMailer.php', -]; -$ignoreErrors[] = [ - 'message' => '#^Cannot call method getUserId\\(\\) on AppBundle\\\\MembershipFee\\\\Model\\\\MembershipFee\\|null\\.$#', - 'identifier' => 'method.nonObject', + 'message' => '#^Cannot access property \\$idPersonne on AppBundle\\\\MembershipFee\\\\Entity\\\\Cotisation\\|null\\.$#', + 'identifier' => 'property.nonObject', 'count' => 3, 'path' => __DIR__ . '/sources/AppBundle/MembershipFee/MembershipFeeMailer.php', ]; $ignoreErrors[] = [ - 'message' => '#^Cannot call method getUserType\\(\\) on AppBundle\\\\MembershipFee\\\\Model\\\\MembershipFee\\|null\\.$#', - 'identifier' => 'method.nonObject', + 'message' => '#^Cannot access property \\$typePersonne on AppBundle\\\\MembershipFee\\\\Entity\\\\Cotisation\\|null\\.$#', + 'identifier' => 'property.nonObject', 'count' => 2, 'path' => __DIR__ . '/sources/AppBundle/MembershipFee/MembershipFeeMailer.php', ]; $ignoreErrors[] = [ - 'message' => '#^Parameter \\#1 \\$entity of method CCMBenchmark\\\\Ting\\\\Repository\\\\Repository\\\\:\\:delete\\(\\) expects AppBundle\\\\MembershipFee\\\\Model\\\\MembershipFee, AppBundle\\\\MembershipFee\\\\Model\\\\MembershipFee\\|null given\\.$#', - 'identifier' => 'argument.type', - 'count' => 1, - 'path' => __DIR__ . '/sources/AppBundle/MembershipFee/MembershipFeeService.php', -]; -$ignoreErrors[] = [ - 'message' => '#^Binary operation "\\." between \'@\' and mixed results in an error\\.$#', - 'identifier' => 'binaryOp.invalid', - 'count' => 1, - 'path' => __DIR__ . '/sources/AppBundle/MembershipFee/Model/Repository/MembershipFeeRepository.php', -]; -$ignoreErrors[] = [ - 'message' => '#^Binary operation "\\." between non\\-falsy\\-string and mixed results in an error\\.$#', - 'identifier' => 'binaryOp.invalid', - 'count' => 1, - 'path' => __DIR__ . '/sources/AppBundle/MembershipFee/Model/Repository/MembershipFeeRepository.php', -]; -$ignoreErrors[] = [ - 'message' => '#^Cannot access offset \'date_fin\' on mixed\\.$#', - 'identifier' => 'offsetAccess.nonOffsetAccessible', - 'count' => 1, - 'path' => __DIR__ . '/sources/AppBundle/MembershipFee/Model/Repository/MembershipFeeRepository.php', -]; -$ignoreErrors[] = [ - 'message' => '#^Cannot access offset 0 on mixed\\.$#', - 'identifier' => 'offsetAccess.nonOffsetAccessible', - 'count' => 1, - 'path' => __DIR__ . '/sources/AppBundle/MembershipFee/Model/Repository/MembershipFeeRepository.php', -]; -$ignoreErrors[] = [ - 'message' => '#^Cannot access property \\$number on mixed\\.$#', + 'message' => '#^Cannot access property \\$value on AppBundle\\\\Association\\\\MemberType\\|null\\.$#', 'identifier' => 'property.nonObject', - 'count' => 2, - 'path' => __DIR__ . '/sources/AppBundle/MembershipFee/Model/Repository/MembershipFeeRepository.php', -]; -$ignoreErrors[] = [ - 'message' => '#^Method AppBundle\\\\MembershipFee\\\\Model\\\\Repository\\\\MembershipFeeRepository\\:\\:getLatestByUserTypeAndId\\(\\) should return AppBundle\\\\MembershipFee\\\\Model\\\\MembershipFee\\|null but returns mixed\\.$#', - 'identifier' => 'return.type', - 'count' => 1, - 'path' => __DIR__ . '/sources/AppBundle/MembershipFee/Model/Repository/MembershipFeeRepository.php', -]; -$ignoreErrors[] = [ - 'message' => '#^Method AppBundle\\\\MembershipFee\\\\Model\\\\Repository\\\\MembershipFeeRepository\\:\\:getListByUserTypeAndId\\(\\) should return CCMBenchmark\\\\Ting\\\\Repository\\\\Collection\\ but returns CCMBenchmark\\\\Ting\\\\Repository\\\\CollectionInterface\\.$#', - 'identifier' => 'return.type', - 'count' => 1, - 'path' => __DIR__ . '/sources/AppBundle/MembershipFee/Model/Repository/MembershipFeeRepository.php', -]; -$ignoreErrors[] = [ - 'message' => '#^Method AppBundle\\\\MembershipFee\\\\Model\\\\Repository\\\\MembershipFeeRepository\\:\\:initMetadata\\(\\) has parameter \\$options with no value type specified in iterable type array\\.$#', - 'identifier' => 'missingType.iterableValue', - 'count' => 1, - 'path' => __DIR__ . '/sources/AppBundle/MembershipFee/Model/Repository/MembershipFeeRepository.php', -]; -$ignoreErrors[] = [ - 'message' => '#^Method AppBundle\\\\MembershipFee\\\\Model\\\\Repository\\\\MembershipFeeRepository\\:\\:initMetadata\\(\\) should return M of CCMBenchmark\\\\Ting\\\\Repository\\\\Metadata but returns CCMBenchmark\\\\Ting\\\\Repository\\\\Metadata\\\\.$#', - 'identifier' => 'return.type', 'count' => 1, - 'path' => __DIR__ . '/sources/AppBundle/MembershipFee/Model/Repository/MembershipFeeRepository.php', + 'path' => __DIR__ . '/sources/AppBundle/MembershipFee/MembershipFeeMailer.php', ]; $ignoreErrors[] = [ - 'message' => '#^Method AppBundle\\\\MembershipFee\\\\Model\\\\Repository\\\\MembershipFeeRepository\\:\\:updatePayment\\(\\) should return bool but returns mixed\\.$#', - 'identifier' => 'return.type', + 'message' => '#^Cannot call method getTimestamp\\(\\) on DateTime\\|null\\.$#', + 'identifier' => 'method.nonObject', 'count' => 1, - 'path' => __DIR__ . '/sources/AppBundle/MembershipFee/Model/Repository/MembershipFeeRepository.php', + 'path' => __DIR__ . '/sources/AppBundle/MembershipFee/MembershipFeeMailer.php', ]; $ignoreErrors[] = [ - 'message' => '#^Parameter \\#1 \\$databaseName of method CCMBenchmark\\\\Ting\\\\Repository\\\\Metadata\\\\:\\:setDatabase\\(\\) expects string, mixed given\\.$#', + 'message' => '#^Parameter \\#1 \\$entity of method AppBundle\\\\Doctrine\\\\EntityRepository\\\\:\\:delete\\(\\) expects AppBundle\\\\MembershipFee\\\\Entity\\\\Cotisation, AppBundle\\\\MembershipFee\\\\Entity\\\\Cotisation\\|null given\\.$#', 'identifier' => 'argument.type', 'count' => 1, - 'path' => __DIR__ . '/sources/AppBundle/MembershipFee/Model/Repository/MembershipFeeRepository.php', -]; -$ignoreErrors[] = [ - 'message' => '#^Unable to resolve the template type U in call to method CCMBenchmark\\\\Ting\\\\Repository\\\\Repository\\\\:\\:getCollection\\(\\)$#', - 'identifier' => 'argument.templateType', - 'count' => 1, - 'path' => __DIR__ . '/sources/AppBundle/MembershipFee/Model/Repository/MembershipFeeRepository.php', + 'path' => __DIR__ . '/sources/AppBundle/MembershipFee/MembershipFeeService.php', ]; $ignoreErrors[] = [ - 'message' => '#^Cannot call method getId\\(\\) on AppBundle\\\\MembershipFee\\\\Model\\\\MembershipFee\\|null\\.$#', - 'identifier' => 'method.nonObject', + 'message' => '#^Cannot access property \\$id on AppBundle\\\\MembershipFee\\\\Entity\\\\Cotisation\\|null\\.$#', + 'identifier' => 'property.nonObject', 'count' => 1, 'path' => __DIR__ . '/sources/AppBundle/MembershipFee/OnlinePaymentHandler.php', ]; diff --git a/sources/AppBundle/Association/CompanyMembership/SubscriptionManagement.php b/sources/AppBundle/Association/CompanyMembership/SubscriptionManagement.php index 6303e6248..c2d006564 100644 --- a/sources/AppBundle/Association/CompanyMembership/SubscriptionManagement.php +++ b/sources/AppBundle/Association/CompanyMembership/SubscriptionManagement.php @@ -8,7 +8,7 @@ use Afup\Site\Utils\Utils; use AppBundle\Association\MemberType; use AppBundle\Association\Model\CompanyMember; -use AppBundle\MembershipFee\Model\MembershipFee; +use AppBundle\MembershipFee\Entity\Cotisation; final readonly class SubscriptionManagement { @@ -35,10 +35,10 @@ public function createInvoiceForInscription(CompanyMember $company, int $numberO ); $subscription = $this->membershipFeeService->getLatestByUserTypeAndId(MemberType::MemberCompany, $company->getId()); - if (!$subscription instanceof MembershipFee) { + if (!$subscription instanceof Cotisation) { throw new \RuntimeException('An error occured'); } - return ['invoice' => $subscription->getInvoiceNumber(), 'token' => $subscription->getToken()]; + return ['invoice' => $subscription->numeroFacture, 'token' => $subscription->token]; } } diff --git a/sources/AppBundle/Association/UserMembership/SeniorityComputer.php b/sources/AppBundle/Association/UserMembership/SeniorityComputer.php index e9983c1a4..f4fc7e099 100644 --- a/sources/AppBundle/Association/UserMembership/SeniorityComputer.php +++ b/sources/AppBundle/Association/UserMembership/SeniorityComputer.php @@ -7,13 +7,12 @@ use AppBundle\Association\MemberType; use AppBundle\Association\Model\CompanyMember; use AppBundle\Association\Model\User; -use AppBundle\MembershipFee\Model\MembershipFee; -use AppBundle\MembershipFee\Model\Repository\MembershipFeeRepository; -use CCMBenchmark\Ting\Repository\Collection; +use AppBundle\MembershipFee\Entity\Cotisation; +use AppBundle\MembershipFee\Entity\Repository\CotisationRepository; class SeniorityComputer { - public function __construct(private readonly MembershipFeeRepository $membershipFeeRepository) {} + public function __construct(private readonly CotisationRepository $membershipFeeRepository) {} /** @return array{years: int, first_year: int|null} */ public function computeCompanyAndReturnInfos(CompanyMember $companyMember): array @@ -39,18 +38,18 @@ public function computeAndReturnInfos(User $user): array } /** - * @param Collection $cotisations + * @param Cotisation[] $cotisations * @return array{years: int, first_year: int|null} */ - private function computeFromCotisationsAndReturnInfos(Collection $cotisations): array + private function computeFromCotisationsAndReturnInfos(array $cotisations): array { $now = new \DateTime(); $diffs = []; $years = []; foreach ($cotisations as $coti) { - $from = $coti->getStartDate(); - $to = $coti->getEndDate(); + $from = $coti->dateDebut; + $to = $coti->dateFin; $to = min($now, $to); $diffs[] = $from->diff($to); $years[] = $from->format('Y'); diff --git a/sources/AppBundle/Association/UserMembership/UserService.php b/sources/AppBundle/Association/UserMembership/UserService.php index 149b2a022..85c260350 100644 --- a/sources/AppBundle/Association/UserMembership/UserService.php +++ b/sources/AppBundle/Association/UserMembership/UserService.php @@ -12,7 +12,7 @@ use AppBundle\Email\Mailer\MailUser; use AppBundle\Email\Mailer\MailUserFactory; use AppBundle\Email\Mailer\Message; -use AppBundle\MembershipFee\Model\MembershipFee; +use AppBundle\MembershipFee\Entity\Cotisation; use Symfony\Component\PasswordHasher\Hasher\UserPasswordHasherInterface; use Symfony\Component\Routing\Generator\UrlGeneratorInterface; @@ -86,7 +86,7 @@ public function sendWelcomeEmail(User $user): bool return $this->mailer->send($message); } - public function getLastSubscription(User $user): ?MembershipFee + public function getLastSubscription(User $user): ?Cotisation { if ($user->getCompanyId()) { $id = $user->getCompanyId(); diff --git a/sources/AppBundle/Command/PayboxCallbackSimulatorCommand.php b/sources/AppBundle/Command/PayboxCallbackSimulatorCommand.php index fd147f009..f920441c3 100644 --- a/sources/AppBundle/Command/PayboxCallbackSimulatorCommand.php +++ b/sources/AppBundle/Command/PayboxCallbackSimulatorCommand.php @@ -115,7 +115,7 @@ private function callCotisation(string $cmd, string $status): string } $url = $this->urlGenerator->generate('membership_payment'); - return $this->buildUrl($url, $cotisation->getAmount(), $cmd, $status); + return $this->buildUrl($url, $cotisation->montant, $cmd, $status); } private function callInvoice(string $cmd, string $status): string diff --git a/sources/AppBundle/Controller/Admin/Accounting/MembershipFee/AddMembershipFeeAction.php b/sources/AppBundle/Controller/Admin/Accounting/MembershipFee/AddMembershipFeeAction.php index 8aedfff74..d1ccb2179 100644 --- a/sources/AppBundle/Controller/Admin/Accounting/MembershipFee/AddMembershipFeeAction.php +++ b/sources/AppBundle/Controller/Admin/Accounting/MembershipFee/AddMembershipFeeAction.php @@ -8,9 +8,9 @@ use AppBundle\Association\Model\Repository\CompanyMemberRepository; use AppBundle\Association\Model\Repository\UserRepository; use AppBundle\AuditLog\Audit; +use AppBundle\MembershipFee\Entity\Cotisation; +use AppBundle\MembershipFee\Entity\Repository\CotisationRepository; use AppBundle\MembershipFee\Form\MembershipFeeType; -use AppBundle\MembershipFee\Model\MembershipFee; -use AppBundle\MembershipFee\Model\Repository\MembershipFeeRepository; use Psr\Clock\ClockInterface; use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; use Symfony\Component\HttpFoundation\Request; @@ -21,14 +21,14 @@ class AddMembershipFeeAction extends AbstractController public function __construct( private readonly CompanyMemberRepository $companyMemberRepository, private readonly UserRepository $userRepository, - private readonly MembershipFeeRepository $membershipFeeRepository, + private readonly CotisationRepository $membershipFeeRepository, private readonly ClockInterface $clock, private readonly Audit $audit, ) {} public function __invoke(MemberType $memberType, int $memberId, Request $request): Response { - $membershipFee = new MembershipFee(); + $membershipFee = new Cotisation(); $member = match ($memberType) { MemberType::MemberCompany => $this->companyMemberRepository->get($memberId), MemberType::MemberPhysical => $this->userRepository->get($memberId), @@ -37,13 +37,12 @@ public function __invoke(MemberType $memberType, int $memberId, Request $request $startDate = $this->membershipFeeRepository->getMembershipStartingDate($memberType, $member->getId()); $endDate = clone $startDate; $endDate->modify('+1 year'); - $membershipFee->setStartDate($startDate) - ->setEndDate($endDate) - ->setUserType($memberType) - ->setUserId($member->getId()) - ->setToken(base64_encode(random_bytes(30))) - ->setInvoiceDate($this->clock->now()) - ; + $membershipFee->dateDebut = $startDate; + $membershipFee->dateFin = $endDate; + $membershipFee->typePersonne = $memberType; + $membershipFee->idPersonne = $member->getId(); + $membershipFee->token = base64_encode(random_bytes(30)); + $membershipFee->dateFacture = $this->clock->now(); $form = $this->createForm(MembershipFeeType::class, $membershipFee); $form->handleRequest($request); @@ -58,12 +57,12 @@ public function __invoke(MemberType $memberType, int $memberId, Request $request $name = $memberType->value === MemberType::MemberCompany->value ? $member->getCompanyName() : $member->getFirstName() . ' ' . $member->getLastName(); try { - $membershipFee->setInvoiceNumber($this->membershipFeeRepository->generateInvoiceNumber()); + $membershipFee->numeroFacture = $this->membershipFeeRepository->generateInvoiceNumber(); $this->membershipFeeRepository->save($membershipFee); - $this->audit->log("Ajout de la cotisation jusqu'au " . $fmt->format($membershipFee->getEndDate()) . ' pour ' . $name); - $this->addFlash('notice', "La cotisation jusqu'au " . $fmt->format($membershipFee->getEndDate()) . ' pour ' . $name . ' a bien été ajoutée'); + $this->audit->log("Ajout de la cotisation jusqu'au " . $fmt->format($membershipFee->dateFin) . ' pour ' . $name); + $this->addFlash('notice', "La cotisation jusqu'au " . $fmt->format($membershipFee->dateFin) . ' pour ' . $name . ' a bien été ajoutée'); } catch (\Exception) { - $this->addFlash('error', 'Une erreur est survenue lors de l\'ajout de la cotisation jusqu\'au ' . $fmt->format($membershipFee->getEndDate()) . ' pour ' . $name); + $this->addFlash('error', 'Une erreur est survenue lors de l\'ajout de la cotisation jusqu\'au ' . $fmt->format($membershipFee->dateFin) . ' pour ' . $name); } return $this->redirectToRoute('admin_membership_fee_list', ['memberType' => $memberType->value, 'memberId' => $member->getId()]); } diff --git a/sources/AppBundle/Controller/Admin/Accounting/MembershipFee/DeleteMembershipFeeAction.php b/sources/AppBundle/Controller/Admin/Accounting/MembershipFee/DeleteMembershipFeeAction.php index 34b9ae0c7..6add1dfa2 100644 --- a/sources/AppBundle/Controller/Admin/Accounting/MembershipFee/DeleteMembershipFeeAction.php +++ b/sources/AppBundle/Controller/Admin/Accounting/MembershipFee/DeleteMembershipFeeAction.php @@ -6,7 +6,7 @@ use AppBundle\Association\MemberType; use AppBundle\AuditLog\Audit; -use AppBundle\MembershipFee\Model\Repository\MembershipFeeRepository; +use AppBundle\MembershipFee\Entity\Repository\CotisationRepository; use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Response; @@ -16,7 +16,7 @@ class DeleteMembershipFeeAction extends AbstractController { public function __construct( - private readonly MembershipFeeRepository $membershipFeeRepository, + private readonly CotisationRepository $membershipFeeRepository, private readonly CsrfTokenManagerInterface $csrfTokenManager, private readonly Audit $audit, ) {} @@ -29,7 +29,7 @@ public function __invoke(MemberType $memberType, int $memberId, int $membershipF } try { - $membershipFee = $this->membershipFeeRepository->get($membershipFeeId); + $membershipFee = $this->membershipFeeRepository->find($membershipFeeId); $this->membershipFeeRepository->delete($membershipFee); $this->audit->log('Suppression de la cotisation ' . $membershipFeeId); diff --git a/sources/AppBundle/Controller/Admin/Accounting/MembershipFee/EditMembershipFeeAction.php b/sources/AppBundle/Controller/Admin/Accounting/MembershipFee/EditMembershipFeeAction.php index e2fb20ff9..e42bcbbfa 100644 --- a/sources/AppBundle/Controller/Admin/Accounting/MembershipFee/EditMembershipFeeAction.php +++ b/sources/AppBundle/Controller/Admin/Accounting/MembershipFee/EditMembershipFeeAction.php @@ -8,8 +8,8 @@ use AppBundle\Association\Model\Repository\CompanyMemberRepository; use AppBundle\Association\Model\Repository\UserRepository; use AppBundle\AuditLog\Audit; +use AppBundle\MembershipFee\Entity\Repository\CotisationRepository; use AppBundle\MembershipFee\Form\MembershipFeeType; -use AppBundle\MembershipFee\Model\Repository\MembershipFeeRepository; use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Response; @@ -19,13 +19,13 @@ class EditMembershipFeeAction extends AbstractController public function __construct( private readonly CompanyMemberRepository $companyMemberRepository, private readonly UserRepository $userRepository, - private readonly MembershipFeeRepository $membershipFeeRepository, + private readonly CotisationRepository $membershipFeeRepository, private readonly Audit $audit, ) {} public function __invoke(MemberType $memberType, int $memberId, int $membershipFeeId, Request $request): Response { - $membershipFee = $this->membershipFeeRepository->get($membershipFeeId); + $membershipFee = $this->membershipFeeRepository->find($membershipFeeId); $member = match ($memberType) { MemberType::MemberCompany => $this->companyMemberRepository->get($memberId), MemberType::MemberPhysical => $this->userRepository->get($memberId), diff --git a/sources/AppBundle/Controller/Admin/Accounting/MembershipFee/ListMembershipFeeAction.php b/sources/AppBundle/Controller/Admin/Accounting/MembershipFee/ListMembershipFeeAction.php index d6b49ccf0..be3f49c9d 100644 --- a/sources/AppBundle/Controller/Admin/Accounting/MembershipFee/ListMembershipFeeAction.php +++ b/sources/AppBundle/Controller/Admin/Accounting/MembershipFee/ListMembershipFeeAction.php @@ -7,7 +7,7 @@ use AppBundle\Association\MemberType; use AppBundle\Association\Model\Repository\CompanyMemberRepository; use AppBundle\Association\Model\Repository\UserRepository; -use AppBundle\MembershipFee\Model\Repository\MembershipFeeRepository; +use AppBundle\MembershipFee\Entity\Repository\CotisationRepository; use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; use Symfony\Component\HttpFoundation\Response; use Symfony\Component\Security\Core\User\UserInterface; @@ -18,7 +18,7 @@ class ListMembershipFeeAction extends AbstractController public function __construct( private readonly CompanyMemberRepository $companyMemberRepository, private readonly UserRepository $userRepository, - private readonly MembershipFeeRepository $membershipFeeRepository, + private readonly CotisationRepository $membershipFeeRepository, ) {} public function __invoke(#[CurrentUser] UserInterface $user, MemberType $memberType, int $memberId): Response @@ -28,7 +28,7 @@ public function __invoke(#[CurrentUser] UserInterface $user, MemberType $memberT MemberType::MemberPhysical => $this->userRepository->get($memberId), }; - $memberships = $this->membershipFeeRepository->getBy(['userType' => $memberType->value, 'userId' => $memberId]); + $memberships = $this->membershipFeeRepository->findBy(['typePersonne' => $memberType, 'idPersonne' => $memberId]); return $this->render('admin/accounting/membership/list.html.twig', [ 'memberType' => $memberType, diff --git a/sources/AppBundle/Controller/Website/Member/IndexAction.php b/sources/AppBundle/Controller/Website/Member/IndexAction.php index 7842ce866..4ad325299 100644 --- a/sources/AppBundle/Controller/Website/Member/IndexAction.php +++ b/sources/AppBundle/Controller/Website/Member/IndexAction.php @@ -10,7 +10,7 @@ use AppBundle\Association\UserMembership\BadgesComputer; use AppBundle\Association\UserMembership\UserService; use AppBundle\GeneralMeeting\GeneralMeetingRepository; -use AppBundle\MembershipFee\Model\MembershipFee; +use AppBundle\MembershipFee\Entity\Cotisation; use AppBundle\Security\Authentication; use AppBundle\Veille\Entity\Repository\NewsletterInscriptionRepository; use AppBundle\Twig\ViewRenderer; @@ -40,8 +40,8 @@ public function __invoke(): Response $cotisation = $userService->getLastSubscription($user); $dateFinCotisation = null; - if ($cotisation instanceof MembershipFee) { - $dateFinCotisation = $cotisation->getEndDate(); + if ($cotisation instanceof Cotisation) { + $dateFinCotisation = $cotisation->dateFin; } $daysBeforeMembershipExpiration = $user->getDaysBeforeMembershipExpiration(); diff --git a/sources/AppBundle/Controller/Website/Membership/Fee/DownloadAction.php b/sources/AppBundle/Controller/Website/Membership/Fee/DownloadAction.php index 768a8a481..19a5c4871 100644 --- a/sources/AppBundle/Controller/Website/Membership/Fee/DownloadAction.php +++ b/sources/AppBundle/Controller/Website/Membership/Fee/DownloadAction.php @@ -12,7 +12,7 @@ use AppBundle\Association\Model\Repository\UserRepository; use AppBundle\Association\Model\User; use AppBundle\AuditLog\Audit; -use AppBundle\MembershipFee\Model\Repository\MembershipFeeRepository; +use AppBundle\MembershipFee\Entity\Repository\CotisationRepository; use AppBundle\Security\MembershipFeeVoter; use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; use Symfony\Component\HttpFoundation\BinaryFileResponse; @@ -25,7 +25,7 @@ final class DownloadAction extends AbstractController public function __construct( private readonly UserRepository $userRepository, private readonly CompanyMemberRepository $companyMemberRepository, - private readonly MembershipFeeRepository $membershipFeeRepository, + private readonly CotisationRepository $membershipFeeRepository, private readonly MembershipFeeInvoicePdfGenerator $pdfGenerator, private readonly Droits $droits, private readonly Audit $audit, @@ -43,19 +43,19 @@ public function __invoke(Request $request): BinaryFileResponse $tempfile = tempnam(sys_get_temp_dir(), 'membership_fee_download'); $numeroFacture = $this->pdfGenerator->genererFacture($id, $tempfile); - $membershipFee = $this->membershipFeeRepository->get($id); + $membershipFee = $this->membershipFeeRepository->find($id); - if ($membershipFee->getUserType() === MemberType::MemberCompany) { - $company = $this->companyMemberRepository->get($membershipFee->getUserId()); + if ($membershipFee->typePersonne === MemberType::MemberCompany) { + $company = $this->companyMemberRepository->get($membershipFee->idPersonne); Assert::isInstanceOf($company, CompanyMember::class); $patternPrefix = $company->getCompanyName(); } else { - $user = $this->userRepository->get($membershipFee->getUserId()); + $user = $this->userRepository->get($membershipFee->idPersonne); Assert::isInstanceOf($user, User::class); $patternPrefix = $user->getLastName(); } - $pattern = str_replace(' ', '', $patternPrefix) . '_' . $numeroFacture . '_' . $membershipFee->getStartDate()->format('dmY') . '.pdf'; + $pattern = str_replace(' ', '', $patternPrefix) . '_' . $numeroFacture . '_' . $membershipFee->dateDebut->format('dmY') . '.pdf'; $response = new BinaryFileResponse($tempfile, Response::HTTP_OK, [], false); $response->deleteFileAfterSend(true); diff --git a/sources/AppBundle/Controller/Website/Membership/Fee/IndexAction.php b/sources/AppBundle/Controller/Website/Membership/Fee/IndexAction.php index 3a8f9cfb9..bec2fd38c 100644 --- a/sources/AppBundle/Controller/Website/Membership/Fee/IndexAction.php +++ b/sources/AppBundle/Controller/Website/Membership/Fee/IndexAction.php @@ -15,8 +15,8 @@ use AppBundle\Association\Model\Repository\CompanyMemberRepository; use AppBundle\Association\Model\Repository\UserRepository; use AppBundle\Association\UserMembership\UserService; -use AppBundle\MembershipFee\Model\MembershipFee; -use AppBundle\MembershipFee\Model\Repository\MembershipFeeRepository; +use AppBundle\MembershipFee\Entity\Cotisation; +use AppBundle\MembershipFee\Entity\Repository\CotisationRepository; use AppBundle\Payment\PayboxBilling; use AppBundle\Payment\PayboxFactory; use AppBundle\Twig\ViewRenderer; @@ -33,7 +33,7 @@ public function __construct( private readonly UserService $userService, private readonly PayboxFactory $payboxFactory, private readonly MembershipFeeService $membershipFeeService, - private readonly MembershipFeeRepository $membershipFeeRepository, + private readonly CotisationRepository $membershipFeeRepository, private readonly Droits $droits, ) {} @@ -48,15 +48,15 @@ public function __invoke(): Response $now = new \DateTime('now'); $isSubjectedToVat = Vat::isSubjectedToVat($now); - if (!$cotisation instanceof MembershipFee) { + if (!$cotisation instanceof Cotisation) { $message = ''; } else { $endSubscription = $this->membershipFeeService->getNextSubscriptionExpiration($cotisation); $message = sprintf( 'Votre dernière cotisation -- %s € -- est valable jusqu\'au %s.
Si vous renouvelez votre cotisation maintenant, celle-ci sera valable jusqu\'au %s.', - number_format((float) $cotisation->getAmount(), 2, ',', ' '), - $cotisation->getEndDate()->format('d/m/Y'), + number_format((float) $cotisation->montant, 2, ',', ' '), + $cotisation->dateFin->format('d/m/Y'), $endSubscription->format('d/m/Y'), ); } @@ -64,11 +64,11 @@ public function __invoke(): Response $cotisations_physique = $this->membershipFeeRepository->getListByUserTypeAndId(MemberType::MemberPhysical, $user->getId()); $cotisations_morale = $this->membershipFeeRepository->getListByUserTypeAndId(MemberType::MemberCompany, $user->getCompanyId()); - /** @var array $liste_cotisations */ - $liste_cotisations = array_merge(iterator_to_array($cotisations_physique), iterator_to_array($cotisations_morale)); + /** @var array $liste_cotisations */ + $liste_cotisations = array_merge($cotisations_physique, $cotisations_morale); foreach ($liste_cotisations as $cotisation) { - $cotisation->setDownloadInvoice($this->isGranted(MembershipFeeVoter::READ_INVOICE, (string) $cotisation->getId())); + $cotisation->telechargerFacture = $this->isGranted(MembershipFeeVoter::READ_INVOICE, (string) $cotisation->id); } if ($user->getCompanyId() > 0) { diff --git a/sources/AppBundle/Controller/Website/Membership/GeneralMeeting/IndexAction.php b/sources/AppBundle/Controller/Website/Membership/GeneralMeeting/IndexAction.php index 027c19283..cb394bd63 100644 --- a/sources/AppBundle/Controller/Website/Membership/GeneralMeeting/IndexAction.php +++ b/sources/AppBundle/Controller/Website/Membership/GeneralMeeting/IndexAction.php @@ -48,7 +48,7 @@ public function __invoke(Request $request): Response $generalMeetingPlanned = $this->assembleGeneraleRepository->hasPlanned(); $cotisation = $userService->getLastSubscription($user); - $needsMembersheepFeePayment = $latestDate->getTimestamp() > strtotime("+14 day", $cotisation->getEndDate()->getTimestamp()); + $needsMembersheepFeePayment = $latestDate->getTimestamp() > strtotime("+14 day", $cotisation->dateFin->getTimestamp()); if ($needsMembersheepFeePayment) { return $this->view->render('admin/association/membership/generalmeeting_membersheepfee.html.twig', [ diff --git a/sources/AppBundle/Controller/Website/Membership/InvoiceAction.php b/sources/AppBundle/Controller/Website/Membership/InvoiceAction.php index d65d1fe1a..c88b02dc0 100644 --- a/sources/AppBundle/Controller/Website/Membership/InvoiceAction.php +++ b/sources/AppBundle/Controller/Website/Membership/InvoiceAction.php @@ -6,7 +6,7 @@ use AppBundle\MembershipFee\MembershipFeeService; use AppBundle\MembershipFee\MembershipFeeInvoicePdfGenerator; -use AppBundle\MembershipFee\Model\MembershipFee; +use AppBundle\MembershipFee\Entity\Cotisation; use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; use Symfony\Component\HttpFoundation\Response; @@ -21,12 +21,12 @@ public function __invoke(string $invoiceNumber, ?string $token): Response { $invoice = $this->membershipFeeService->getByInvoice($invoiceNumber, $token); - if (!$invoice instanceof MembershipFee) { + if (!$invoice instanceof Cotisation) { throw $this->createNotFoundException(sprintf('Could not find the invoice "%s" with token "%s"', $invoiceNumber, $token)); } ob_start(); - $this->pdfGenerator->genererFacture($invoice->getId()); + $this->pdfGenerator->genererFacture($invoice->id); $pdf = ob_get_clean(); $response = new Response($pdf); diff --git a/sources/AppBundle/Controller/Website/Membership/PayboxCallbackAction.php b/sources/AppBundle/Controller/Website/Membership/PayboxCallbackAction.php index b06efab56..af9649dd9 100644 --- a/sources/AppBundle/Controller/Website/Membership/PayboxCallbackAction.php +++ b/sources/AppBundle/Controller/Website/Membership/PayboxCallbackAction.php @@ -12,7 +12,7 @@ use AppBundle\Association\MemberType; use AppBundle\Association\Model\Repository\UserRepository; use AppBundle\AuditLog\Audit; -use AppBundle\MembershipFee\Model\MembershipFee; +use AppBundle\MembershipFee\Entity\Cotisation; use AppBundle\Payment\PayboxResponseFactory; use Symfony\Component\EventDispatcher\EventDispatcherInterface; use Symfony\Component\HttpFoundation\Request; @@ -61,7 +61,7 @@ public function __invoke(Request $request): Response $account = $this->onlinePaymentHandler->getAccountFromCmd($cleanedCmd); $lastCotisation = $this->membershipFeeService->getLatestByUserTypeAndId(MemberType::from($account['type']), $account['id']); - if (!$lastCotisation instanceof MembershipFee && $account['type'] == MemberType::MemberPhysical->value) { + if (!$lastCotisation instanceof Cotisation && $account['type'] == MemberType::MemberPhysical->value) { $user = $this->userRepository->get($account['id']); $this->eventDispatcher->dispatch(new NewMemberEvent($user)); } diff --git a/sources/AppBundle/Controller/Website/Membership/PaymentAction.php b/sources/AppBundle/Controller/Website/Membership/PaymentAction.php index 197462b29..7353aeb97 100644 --- a/sources/AppBundle/Controller/Website/Membership/PaymentAction.php +++ b/sources/AppBundle/Controller/Website/Membership/PaymentAction.php @@ -8,7 +8,7 @@ use AppBundle\MembershipFee\MembershipFeeService; use AppBundle\Association\Model\Repository\CompanyMemberRepository; use AppBundle\Compta\BankAccount\BankAccountFactory; -use AppBundle\MembershipFee\Model\MembershipFee; +use AppBundle\MembershipFee\Entity\Cotisation; use AppBundle\Payment\PayboxBilling; use AppBundle\Payment\PayboxFactory; use AppBundle\Twig\ViewRenderer; @@ -28,8 +28,8 @@ public function __invoke(string $invoiceNumber, ?string $token): Response { $invoice = $this->membershipFeeService->getByInvoice($invoiceNumber, $token); $company = null; - if ($invoice instanceof MembershipFee) { - $company = $this->companyMemberRepository->get($invoice->getUserId()); + if ($invoice instanceof Cotisation) { + $company = $this->companyMemberRepository->get($invoice->idPersonne); } if (!$invoice || $company === null) { @@ -40,7 +40,7 @@ public function __invoke(string $invoiceNumber, ?string $token): Response $paybox = $this->payboxFactory->createPayboxForSubscription( 'F' . $invoiceNumber, - (float) $invoice->getAmount(), + (float) $invoice->montant, $company->getEmail(), $payboxBilling, ); @@ -50,7 +50,7 @@ public function __invoke(string $invoiceNumber, ?string $token): Response return $this->view->render('site/company_membership/payment.html.twig', [ 'paybox' => $paybox, 'invoice' => $invoice, - 'bankAccount' => $bankAccountFactory->createApplyableAt(new \DateTimeImmutable('@' . $invoice->getStartDate()->getTimestamp())), + 'bankAccount' => $bankAccountFactory->createApplyableAt(new \DateTimeImmutable('@' . $invoice->dateDebut->getTimestamp())), 'afup' => [ 'raison_sociale' => Afup::RAISON_SOCIALE, 'adresse' => Afup::ADRESSE, diff --git a/sources/AppBundle/MembershipFee/Entity/Cotisation.php b/sources/AppBundle/MembershipFee/Entity/Cotisation.php new file mode 100644 index 000000000..63db8b467 --- /dev/null +++ b/sources/AppBundle/MembershipFee/Entity/Cotisation.php @@ -0,0 +1,66 @@ + + */ +class CotisationRepository extends EntityRepository +{ + public function __construct(ManagerRegistry $registry) + { + parent::__construct($registry, Cotisation::class); + } + + public function getMembershipStartingDate(MemberType $typePersonne, int $idPersonne): DateTime + { + return $this->getLatestByUserTypeAndId($typePersonne, $idPersonne)->dateFin ?? new DateTime(); + } + + public function generateInvoiceNumber(): string + { + $result = $this->getEntityManager()->getConnection()->executeQuery( + <<<'SQL' +SELECT MAX(CAST(SUBSTRING_INDEX(numero_facture, '-', -1) AS UNSIGNED)) + 1 as number +FROM afup_cotisations +WHERE LEFT(numero_facture, 4) = :date + OR LEFT(numero_facture, 10) = :prefixed_date +SQL, + ['date' => date('Y'), 'prefixed_date' => 'COTIS-' . date('Y')], + )->fetchOne(); + + return 'COTIS-' . date('Y') . '-' . (is_numeric($result) ? (int) $result : 1); + } + + public function updatePayment(int $id, int $typeReglement, string $informationsReglement): bool + { + $cotisation = $this->find($id); + if (!$cotisation instanceof Cotisation) { + return false; + } + + $cotisation->typeReglement = MembershipFeePayment::from($typeReglement); + $cotisation->informationsReglement = $informationsReglement; + $this->save($cotisation); + + return true; + } + + public function getLatestByUserTypeAndId(MemberType $typePersonne, int $idPersonne): ?Cotisation + { + return $this->findOneBy( + ['typePersonne' => $typePersonne, 'idPersonne' => $idPersonne], + ['dateFin' => 'DESC'], + ); + } + + /** + * @return Cotisation[] + */ + public function getListByUserTypeAndId(MemberType $typePersonne, int $idPersonne): array + { + return $this->findBy( + ['typePersonne' => $typePersonne, 'idPersonne' => $idPersonne], + ['dateFin' => 'DESC'], + ); + } +} diff --git a/sources/AppBundle/MembershipFee/Form/MembershipFeeType.php b/sources/AppBundle/MembershipFee/Form/MembershipFeeType.php index 45f1e63f4..a01ef070a 100644 --- a/sources/AppBundle/MembershipFee/Form/MembershipFeeType.php +++ b/sources/AppBundle/MembershipFee/Form/MembershipFeeType.php @@ -18,7 +18,7 @@ class MembershipFeeType extends AbstractType { public function buildForm(FormBuilderInterface $builder, array $options): void { - $builder->add('amount', NumberType::class, [ + $builder->add('montant', NumberType::class, [ 'label' => 'Montant', 'required' => true, 'scale' => 2, @@ -27,7 +27,7 @@ public function buildForm(FormBuilderInterface $builder, array $options): void new Assert\GreaterThanOrEqual(0), ], ]) - ->add('paymentType', EnumType::class, [ + ->add('typeReglement', EnumType::class, [ 'class' => MembershipFeePayment::class, 'label' => 'Type de réglement', 'required' => true, @@ -37,25 +37,25 @@ public function buildForm(FormBuilderInterface $builder, array $options): void ], 'choice_label' => fn(MembershipFeePayment $choice, string $key, mixed $value): string => $choice->label(), ]) - ->add('paymentDetails', TextType::class, [ + ->add('informationsReglement', TextType::class, [ 'label' => 'Informations', 'required' => false, ]) - ->add('clientReference', TextType::class, [ + ->add('referenceClient', TextType::class, [ 'label' => 'Référence client', 'required' => false, ]) - ->add('startDate', DateType::class, [ + ->add('dateDebut', DateType::class, [ 'required' => false, 'widget' => 'single_text', 'label' => 'Date début', ]) - ->add('endDate', DateType::class, [ + ->add('dateFin', DateType::class, [ 'required' => false, 'widget' => 'single_text', 'label' => 'Date fin', ]) - ->add('comments', TextareaType::class, [ + ->add('commentaires', TextareaType::class, [ 'required' => false, 'label' => 'Commentaires', ]); diff --git a/sources/AppBundle/MembershipFee/MembershipFeeInvoicePdfGenerator.php b/sources/AppBundle/MembershipFee/MembershipFeeInvoicePdfGenerator.php index 8d9e77f80..f7afeeeba 100644 --- a/sources/AppBundle/MembershipFee/MembershipFeeInvoicePdfGenerator.php +++ b/sources/AppBundle/MembershipFee/MembershipFeeInvoicePdfGenerator.php @@ -14,12 +14,12 @@ use AppBundle\Association\Model\Repository\UserRepository; use AppBundle\Association\Model\User; use AppBundle\Compta\BankAccount\BankAccountFactory; -use AppBundle\MembershipFee\Model\Repository\MembershipFeeRepository; +use AppBundle\MembershipFee\Entity\Repository\CotisationRepository; final readonly class MembershipFeeInvoicePdfGenerator { public function __construct( - private MembershipFeeRepository $membershipFeeRepository, + private CotisationRepository $membershipFeeRepository, private UserRepository $userRepository, private CompanyMemberRepository $companyMemberRepository, private InvoiceGenerator $invoiceGenerator, @@ -35,19 +35,19 @@ public function __construct( */ public function genererFacture(int $idCotisation, ?string $chemin = null): ?string { - $cotisation = $this->membershipFeeRepository->get($idCotisation); + $cotisation = $this->membershipFeeRepository->find($idCotisation); - $userRepository = match ($cotisation->getUserType()) { + $userRepository = match ($cotisation->typePersonne) { MemberType::MemberCompany => $this->companyMemberRepository, default => $this->userRepository, }; /** @var User|CompanyMember $user */ - $user = $userRepository->get($cotisation->getUserId()); + $user = $userRepository->get($cotisation->idPersonne); $invoiceData = $this->invoiceGenerator->getInvoiceData($user); - $dateFacture = $cotisation->getInvoiceDate() - ?? \DateTimeImmutable::createFromFormat('U', (string) $cotisation->getStartDate()->getTimestamp()); + $dateFacture = $cotisation->dateFacture + ?? \DateTimeImmutable::createFromFormat('U', (string) $cotisation->dateDebut->getTimestamp()); $isSubjectedToVat = Vat::isSubjectedToVat($dateFacture); $pdf = new PDF_Facture($this->bankAccountFactory->createApplyableAt($dateFacture), $isSubjectedToVat); @@ -61,25 +61,25 @@ public function genererFacture(int $idCotisation, ?string $chemin = null): ?stri $pdf->Ln(); $pdf->SetFont('Arial', 'BU', 10); - $pdf->Cell(130, 5, 'Objet : Facture n°' . $cotisation->getInvoiceNumber()); + $pdf->Cell(130, 5, 'Objet : Facture n°' . $cotisation->numeroFacture); $pdf->SetFont('Arial', '', 10); $pdf->Ln(10); $pdf->MultiCell(130, 5, $invoiceData->recipient . "\n" . $invoiceData->address . "\n" . $invoiceData->zipcode . "\n" . $invoiceData->city); - if ($cotisation->getClientReference() !== null) { + if ($cotisation->referenceClient !== null) { $pdf->Ln(10); $pdf->MultiCell(180, 5, sprintf( "Référence client : %s", - $cotisation->getClientReference(), + $cotisation->referenceClient, )); } $pdf->Ln(15); $pdf->MultiCell(180, 5, "Facture concernant votre adhésion à l'Association Française des Utilisateurs de PHP (AFUP)."); - $dateFin = $cotisation->getEndDate()->getTimestamp(); - $montant = $cotisation->getAmount(); + $dateFin = $cotisation->dateFin->getTimestamp(); + $montant = $cotisation->montant; if (false === $isSubjectedToVat) { $pdf->Ln(10); @@ -98,7 +98,7 @@ public function genererFacture(int $idCotisation, ?string $chemin = null): ?stri $pdf->Cell(10, 5, 'TVA non applicable - art. 293B du CGI'); } else { // On stocke le montant de la cotisation TTC. Pour les personnes morales, on extrait le HT pour éviter d'appliquer deux fois la TVA. - if ($cotisation->getUserType() === MemberType::MemberCompany) { + if ($cotisation->typePersonne === MemberType::MemberCompany) { $montant = Vat::getRoundedWithoutVatPriceFromPriceWithVat($montant, Utils::MEMBERSHIP_FEE_VAT_RATE); } @@ -110,7 +110,7 @@ public function genererFacture(int $idCotisation, ?string $chemin = null): ?stri $pdf->Cell(25, 5, 'Taux TVA', 1, 0, 'R', 1); $pdf->Cell(25, 5, 'Prix TTC', 1, 0, 'R', 1); - if ($cotisation->getUserType() === MemberType::MemberCompany) { + if ($cotisation->typePersonne === MemberType::MemberCompany) { [$totalHt, $total] = $this->buildDetailsPersonneMorale($pdf, $montant, $dateFin); } else { [$totalHt, $total] = $this->buildDetailsPersonnePhysique($pdf, $montant, $dateFin); @@ -133,16 +133,16 @@ public function genererFacture(int $idCotisation, ?string $chemin = null): ?stri } $pdf->Ln(15); - $pdf->Cell(10, 5, 'Lors de votre règlement, merci de préciser la mention : "Facture n°' . $cotisation->getInvoiceNumber() . '"'); + $pdf->Cell(10, 5, 'Lors de votre règlement, merci de préciser la mention : "Facture n°' . $cotisation->numeroFacture . '"'); if (is_null($chemin)) { - $pattern = str_replace(' ', '', $invoiceData->patternPrefix) . '_' . $cotisation->getInvoiceNumber() . '_' . date('dmY', $cotisation->getStartDate()->getTimestamp()) . '.pdf'; + $pattern = str_replace(' ', '', $invoiceData->patternPrefix) . '_' . $cotisation->numeroFacture . '_' . date('dmY', $cotisation->dateDebut->getTimestamp()) . '.pdf'; $pdf->Output($pattern, 'D', true); } else { $pdf->Output($chemin, 'F', true); } - return $cotisation->getInvoiceNumber(); + return $cotisation->numeroFacture; } private function buildDetailsPersonneMorale(PDF_Facture $pdf, float $montant, int $dateFin): array diff --git a/sources/AppBundle/MembershipFee/MembershipFeeMailer.php b/sources/AppBundle/MembershipFee/MembershipFeeMailer.php index d7edb3285..6e825272c 100644 --- a/sources/AppBundle/MembershipFee/MembershipFeeMailer.php +++ b/sources/AppBundle/MembershipFee/MembershipFeeMailer.php @@ -13,14 +13,14 @@ use AppBundle\Email\Mailer\MailUser; use AppBundle\Email\Mailer\MailUserFactory; use AppBundle\Email\Mailer\Message; -use AppBundle\MembershipFee\Model\Repository\MembershipFeeRepository; +use AppBundle\MembershipFee\Entity\Repository\CotisationRepository; use Symfony\Component\DependencyInjection\Attribute\Autowire; use Webmozart\Assert\Assert; final readonly class MembershipFeeMailer { public function __construct( - private MembershipFeeRepository $membershipFeeRepository, + private CotisationRepository $membershipFeeRepository, private UserRepository $userRepository, private CompanyMemberRepository $companyMemberRepository, private Mailer $mailer, @@ -36,10 +36,10 @@ public function __construct( */ public function envoyerFacture(int $idCotisation): bool { - $membership = $this->membershipFeeRepository->get($idCotisation); + $membership = $this->membershipFeeRepository->find($idCotisation); - if ($membership->getUserType() === MemberType::MemberCompany) { - $company = $this->companyMemberRepository->get($membership->getUserId()); + if ($membership->typePersonne === MemberType::MemberCompany) { + $company = $this->companyMemberRepository->get($membership->idPersonne); Assert::notNull($company); $contactPhysique = [ 'nom' => $company->getLastName(), @@ -47,7 +47,7 @@ public function envoyerFacture(int $idCotisation): bool 'email' => $company->getEmail(), ]; } else { - $user = $this->userRepository->get($membership->getUserId()); + $user = $this->userRepository->get($membership->idPersonne); Assert::notNull($user); $contactPhysique = [ 'nom' => $user->getLastName(), @@ -67,7 +67,7 @@ public function envoyerFacture(int $idCotisation): bool $cheminFacture = $this->publicCacheDir . 'fact' . $idCotisation . '.pdf'; $numeroFacture = $this->pdfGenerator->genererFacture($idCotisation, $cheminFacture); - $pattern = str_replace(' ', '', $patternPrefix) . '_' . $numeroFacture . '_' . date('dmY', $membership->getStartDate()->getTimestamp()) . '.pdf'; + $pattern = str_replace(' ', '', $patternPrefix) . '_' . $numeroFacture . '_' . date('dmY', $membership->dateDebut->getTimestamp()) . '.pdf'; $message = new Message('Facture AFUP', null, new MailUser( $contactPhysique['email'], @@ -90,9 +90,9 @@ public function notifierReglementEnLigneAuTresorier(string $cmd, float $total, s if (str_starts_with($cmd, 'F')) { // Facture $invoiceNumber = substr($cmd, 1); - $cotisation = $this->membershipFeeRepository->getOneBy(['invoiceNumber' => $invoiceNumber]); - $typePersonne = $cotisation->getUserType()->value; - $idPersonne = $cotisation->getUserId(); + $cotisation = $this->membershipFeeRepository->findOneBy(['numeroFacture' => $invoiceNumber]); + $typePersonne = $cotisation->typePersonne->value; + $idPersonne = $cotisation->idPersonne; } else { // Cotisation [$ref, $date, $typePersonne, $idPersonne, $reste] = explode('-', $cmd, 5); diff --git a/sources/AppBundle/MembershipFee/MembershipFeeService.php b/sources/AppBundle/MembershipFee/MembershipFeeService.php index 02083088f..2e83eddb5 100644 --- a/sources/AppBundle/MembershipFee/MembershipFeeService.php +++ b/sources/AppBundle/MembershipFee/MembershipFeeService.php @@ -6,14 +6,14 @@ use AppBundle\Association\MemberType; use AppBundle\Controller\Admin\Membership\MembershipFeePayment; -use AppBundle\MembershipFee\Model\MembershipFee; -use AppBundle\MembershipFee\Model\Repository\MembershipFeeRepository; +use AppBundle\MembershipFee\Entity\Cotisation; +use AppBundle\MembershipFee\Entity\Repository\CotisationRepository; use DateInterval; use DateTime; class MembershipFeeService { - public function __construct(private readonly MembershipFeeRepository $membershipFeeRepository) {} + public function __construct(private readonly CotisationRepository $membershipFeeRepository) {} public function ajouter( MemberType $typePersonne, @@ -34,27 +34,26 @@ public function ajouter( // Référence client à mentionner sur la facture ?string $referenceClient = null, ): void { - $membershipFee = new MembershipFee(); - $membershipFee - ->setUserType($typePersonne) - ->setUserId($idPersonne) - ->setAmount($montant) - ->setPaymentType($typeReglement !== null ? MembershipFeePayment::from($typeReglement) : null) - ->setPaymentDetails($informationsReglement) - ->setStartDate(new DateTime('@' . $dateDebut)) - ->setEndDate(new DateTime('@' . $dateFin)) - ->setInvoiceNumber($this->membershipFeeRepository->generateInvoiceNumber()) - ->setToken(base64_encode(random_bytes(30))) - ->setComments($commentaires) - ->setClientReference($referenceClient) - ->setInvoiceDate(new \DateTimeImmutable()) - ; - $this->membershipFeeRepository->save($membershipFee); + $cotisation = new Cotisation(); + $cotisation->typePersonne = $typePersonne; + $cotisation->idPersonne = $idPersonne; + $cotisation->montant = $montant; + $cotisation->typeReglement = $typeReglement !== null ? MembershipFeePayment::from($typeReglement) : null; + $cotisation->informationsReglement = $informationsReglement; + $cotisation->dateDebut = new DateTime('@' . $dateDebut); + $cotisation->dateFin = new DateTime('@' . $dateFin); + $cotisation->numeroFacture = $this->membershipFeeRepository->generateInvoiceNumber(); + $cotisation->token = base64_encode(random_bytes(30)); + $cotisation->commentaires = $commentaires; + $cotisation->referenceClient = $referenceClient; + $cotisation->dateFacture = new \DateTimeImmutable(); + + $this->membershipFeeRepository->save($cotisation); } public function isAlreadyPaid(string $cmd): bool { - return $this->membershipFeeRepository->getOneBy(['paymentDetails' => $cmd]) instanceof MembershipFee; + return $this->membershipFeeRepository->findOneBy(['informationsReglement' => $cmd]) instanceof Cotisation; } /** @@ -65,7 +64,7 @@ public function isAlreadyPaid(string $cmd): bool */ public function supprimer(int $id): bool { - $cotisation = $this->membershipFeeRepository->get($id); + $cotisation = $this->membershipFeeRepository->find($id); $this->membershipFeeRepository->delete($cotisation); return true; } @@ -86,14 +85,14 @@ public function updatePayment(int $id, int $typeReglement, string $informationsR /** * Retourne la dernière cotisation d'une personne */ - public function getLatestByUserTypeAndId(MemberType $typePersonne, int $idPersonne): ?MembershipFee + public function getLatestByUserTypeAndId(MemberType $typePersonne, int $idPersonne): ?Cotisation { return $this->membershipFeeRepository->getLatestByUserTypeAndId($typePersonne, $idPersonne); } - public function getNextSubscriptionExpiration(?MembershipFee $cotisation = null): DateTime + public function getNextSubscriptionExpiration(?Cotisation $cotisation = null): DateTime { - $endDate = $cotisation?->getEndDate(); + $endDate = $cotisation?->dateFin; $endSubscription = $endDate !== null ? (clone $endDate)->setTime(23, 59, 59) : new DateTime(); $base = $now = new DateTime(); @@ -110,12 +109,12 @@ public function getNextSubscriptionExpiration(?MembershipFee $cotisation = null) /** * Renvoit la cotisation demandée */ - public function getByInvoice(string $invoiceId, ?string $token = null): ?MembershipFee + public function getByInvoice(string $invoiceId, ?string $token = null): ?Cotisation { - $criterias = ['invoiceNumber' => $invoiceId]; + $criterias = ['numeroFacture' => $invoiceId]; if ($token !== null) { $criterias['token'] = $token; } - return $this->membershipFeeRepository->getOneBy($criterias); + return $this->membershipFeeRepository->findOneBy($criterias); } } diff --git a/sources/AppBundle/MembershipFee/Model/MembershipFee.php b/sources/AppBundle/MembershipFee/Model/MembershipFee.php deleted file mode 100644 index 1bf59c7ca..000000000 --- a/sources/AppBundle/MembershipFee/Model/MembershipFee.php +++ /dev/null @@ -1,226 +0,0 @@ -id; - } - - public function setId(int $id): self - { - $this->propertyChanged('id', $this->id, $id); - $this->id = $id; - return $this; - } - - public function getUserType(): ?MemberType - { - return $this->userType; - } - - public function setUserType(?MemberType $userType): self - { - $this->propertyChanged('userType', $this->userType, $userType); - $this->userType = $userType; - return $this; - } - - public function getUserId(): ?int - { - return $this->userId; - } - - public function setUserId(?int $userId): self - { - $this->propertyChanged('userId', $this->userId, $userId); - $this->userId = $userId; - return $this; - } - - public function getAmount(): ?float - { - return $this->amount; - } - - public function setAmount(?float $amount): self - { - $this->propertyChanged('amount', $this->amount, $amount); - $this->amount = $amount; - return $this; - } - - public function getPaymentType(): ?MembershipFeePayment - { - return $this->paymentType; - } - - public function setPaymentType(?MembershipFeePayment $paymentType): self - { - $this->propertyChanged('paymentType', $this->paymentType, $paymentType); - $this->paymentType = $paymentType; - return $this; - } - - public function getPaymentDetails(): ?string - { - return $this->paymentDetails; - } - - public function setPaymentDetails(?string $paymentDetails): self - { - $this->propertyChanged('paymentDetails', $this->paymentDetails, $paymentDetails); - $this->paymentDetails = $paymentDetails; - return $this; - } - - public function getStartDate(): ?DateTime - { - return $this->startDate; - } - - public function setStartDate(?DateTime $startDate): self - { - $this->propertyChanged('startDate', $this->startDate, $startDate); - $this->startDate = $startDate; - return $this; - } - - public function getEndDate(): ?DateTime - { - return $this->endDate; - } - - public function setEndDate(?DateTime $endDate): self - { - $this->propertyChanged('endDate', $this->endDate, $endDate); - $this->endDate = $endDate; - return $this; - } - - public function getInvoiceNumber(): ?string - { - return $this->invoiceNumber; - } - - public function setInvoiceNumber(?string $invoiceNumber): self - { - $this->propertyChanged('invoiceNumber', $this->invoiceNumber, $invoiceNumber); - $this->invoiceNumber = $invoiceNumber; - return $this; - } - - public function getInvoiceDate(): ?DateTimeImmutable - { - return $this->invoiceDate; - } - - public function setInvoiceDate(?\DateTimeImmutable $invoiceDate): self - { - $this->propertyChanged('invoiceDate', $this->invoiceDate, $invoiceDate); - $this->invoiceDate = $invoiceDate; - return $this; - } - - public function getClientReference(): ?string - { - return $this->clientReference; - } - - public function setClientReference(?string $clientReference): self - { - $this->propertyChanged('clientReference', $this->clientReference, $clientReference); - $this->clientReference = $clientReference; - return $this; - } - - public function getComments(): ?string - { - return $this->comments; - } - - public function setComments(?string $comments): self - { - $this->propertyChanged('comments', $this->comments, $comments); - $this->comments = $comments; - return $this; - } - - public function getToken(): ?string - { - return $this->token; - } - - public function setToken(?string $token): self - { - $this->propertyChanged('token', $this->token, $token); - $this->token = $token; - return $this; - } - - public function getNbReminders(): ?int - { - return $this->nbReminders; - } - - public function setNbReminders(?int $nbReminders): self - { - $this->propertyChanged('nbReminders', $this->nbReminders, $nbReminders); - $this->nbReminders = $nbReminders; - return $this; - } - - public function getLastReminderDate(): ?DateTime - { - return $this->lastReminderDate; - } - - public function setLastReminderDate(?DateTime $lastReminderDate): self - { - $this->propertyChanged('lastReminderDate', $this->lastReminderDate, $lastReminderDate); - $this->lastReminderDate = $lastReminderDate; - return $this; - } - - public function canDownloadInvoice(): bool - { - return $this->downloadInvoice; - } - - public function setDownloadInvoice(bool $hasPermission): self - { - $this->downloadInvoice = $hasPermission; - return $this; - } -} diff --git a/sources/AppBundle/MembershipFee/Model/Repository/MembershipFeeRepository.php b/sources/AppBundle/MembershipFee/Model/Repository/MembershipFeeRepository.php deleted file mode 100644 index 6ecb640d9..000000000 --- a/sources/AppBundle/MembershipFee/Model/Repository/MembershipFeeRepository.php +++ /dev/null @@ -1,224 +0,0 @@ - - */ -class MembershipFeeRepository extends Repository implements MetadataInitializer -{ - public function getMembershipStartingDate(MemberType $memberType, int $idMember): DateTime - { - /** @var SelectInterface $qb */ - $qb = $this->getQueryBuilder('SELECT'); - $qb->from('afup_cotisations') - ->cols(['date_fin']) - ->where('type_personne = :type_personne') - ->where('id_personne = :id_personne') - ->orderBy(['date_fin DESC']); - - $result = $this->getQuery($qb->getStatement()) - ->setParams( - ['type_personne' => $memberType->value, 'id_personne' => $idMember], - )->execute(); - - return isset($result['date_fin']) ? new DateTime('@' . $result['date_fin']) : new DateTime(); - } - - public function generateInvoiceNumber(): string - { - $sql = 'SELECT'; - $sql .= " MAX(CAST(SUBSTRING_INDEX(numero_facture, '-', -1) AS UNSIGNED)) + 1 as number "; - $sql .= 'FROM'; - $sql .= ' afup_cotisations '; - $sql .= 'WHERE'; - $sql .= ' LEFT(numero_facture, 4) = :date'; - $sql .= ' OR LEFT(numero_facture, 10) = :prefixed_date'; - - $result = $this->getQuery($sql) - ->setParams(['date' => date('Y'), 'prefixed_date' => 'COTIS-' . date('Y')]) - ->query($this->getCollection())->first()[0]; - - - return 'COTIS-' . date('Y') . '-' . (is_null($result?->number) ? 1 : $result->number); - } - - public function updatePayment(int $id, int $paymentType, string $paymentInfos): bool - { - $sql = 'UPDATE'; - $sql .= ' afup_cotisations '; - $sql .= 'SET'; - $sql .= ' type_reglement = :paymentType,'; - $sql .= ' informations_reglement = :paymentInfos'; - $sql .= ' WHERE'; - $sql .= ' id=:id'; - - return $this->getQuery($sql)->setParams(['paymentType' => $paymentType, 'paymentInfos' => $paymentInfos, 'id' => $id])->execute(); - } - - public function getLatestByUserTypeAndId(MemberType $type_personne, int $id_personne): ?MembershipFee - { - $sql = 'SELECT'; - $sql .= ' * '; - $sql .= 'FROM'; - $sql .= ' afup_cotisations '; - $sql .= 'WHERE'; - $sql .= ' type_personne = :userType '; - $sql .= ' AND id_personne = :userId '; - $sql .= 'ORDER BY'; - $sql .= ' date_fin DESC '; - $sql .= 'LIMIT 0, 1 '; - - $collection = $this->getQuery($sql)->setParams(['userType' => $type_personne->value, 'userId' => $id_personne])->query($this->getCollection(new HydratorSingleObject())); - if ($collection->count() === 0) { - return null; - } - return $collection->first(); - } - - /** - * @return Collection - */ - public function getListByUserTypeAndId(MemberType $memberType, int $memberId): Collection - { - $sql = 'SELECT * '; - $sql .= 'FROM'; - $sql .= ' afup_cotisations '; - $sql .= 'WHERE'; - $sql .= ' type_personne = :userType '; - $sql .= ' AND id_personne = :userId '; - $sql .= 'ORDER BY date_fin DESC'; - - return $this->getQuery($sql)->setParams(['userType' => $memberType->value, 'userId' => $memberId])->query($this->getCollection(new HydratorSingleObject())); - } - - public static function initMetadata(SerializerFactoryInterface $serializerFactory, array $options = []) - { - $metadata = new Metadata($serializerFactory); - - $metadata->setEntity(MembershipFee::class); - $metadata->setConnectionName('main'); - $metadata->setDatabase($options['database']); - $metadata->setTable('afup_cotisations'); - - $metadata - ->addField([ - 'columnName' => 'id', - 'fieldName' => 'id', - 'primary' => true, - 'autoincrement' => true, - 'type' => 'int', - ]) - ->addField([ - 'columnName' => 'type_personne', - 'fieldName' => 'userType', - 'type' => 'int', - 'serializer' => BackedEnum::class, - 'serializer_options' => [ - 'unserialize' => ['enum' => MemberType::class], - ], - ]) - ->addField([ - 'columnName' => 'id_personne', - 'fieldName' => 'userId', - 'type' => 'int', - ]) - ->addField([ - 'columnName' => 'montant', - 'fieldName' => 'amount', - 'type' => 'float', - ]) - ->addField([ - 'columnName' => 'type_reglement', - 'fieldName' => 'paymentType', - 'type' => 'int', - 'serializer' => BackedEnum::class, - 'serializer_options' => [ - 'unserialize' => ['enum' => MembershipFeePayment::class], - ], - ]) - ->addField([ - 'columnName' => 'informations_reglement', - 'fieldName' => 'paymentDetails', - 'type' => 'string', - ]) - ->addField([ - 'columnName' => 'date_debut', - 'fieldName' => 'startDate', - 'type' => 'datetime', - 'serializer_options' => [ - 'unserialize' => ['unSerializeUseFormat' => true, 'format' => 'U'], - 'serialize' => ['serializeUseFormat' => true, 'format' => 'U'], - ], - ]) - ->addField([ - 'columnName' => 'date_fin', - 'fieldName' => 'endDate', - 'type' => 'datetime', - 'serializer_options' => [ - 'unserialize' => ['unSerializeUseFormat' => true, 'format' => 'U'], - 'serialize' => ['serializeUseFormat' => true, 'format' => 'U'], - ], - ]) - ->addField([ - 'columnName' => 'numero_facture', - 'fieldName' => 'invoiceNumber', - 'type' => 'string', - ]) - ->addField([ - 'columnName' => 'date_facture', - 'fieldName' => 'invoiceDate', - 'type' => 'datetime_immutable', - 'serializer_options' => [ - 'unserialize' => ['unSerializeUseFormat' => true, 'format' => 'Y-m-d H:i:s'], - 'serialize' => ['serializeUseFormat' => true, 'format' => 'Y-m-d H:i:s'], - ], - ]) - ->addField([ - 'columnName' => 'reference_client', - 'fieldName' => 'clientReference', - 'type' => 'string', - ]) - ->addField([ - 'columnName' => 'commentaires', - 'fieldName' => 'comments', - 'type' => 'string', - ]) - ->addField([ - 'columnName' => 'token', - 'fieldName' => 'token', - 'type' => 'string', - ]) - ->addField([ - 'columnName' => 'nombre_relances', - 'fieldName' => 'nbReminders', - 'type' => 'int', - ]) - ->addField([ - 'columnName' => 'date_derniere_relance', - 'fieldName' => 'lastReminderDate', - 'type' => 'datetime', - 'serializer_options' => [ - 'unserialize' => ['unSerializeUseFormat' => true, 'format' => 'U'], - ], - ]) - ; - - return $metadata; - } -} diff --git a/sources/AppBundle/MembershipFee/OnlinePaymentHandler.php b/sources/AppBundle/MembershipFee/OnlinePaymentHandler.php index 4f9c35cf0..a7cd7c567 100644 --- a/sources/AppBundle/MembershipFee/OnlinePaymentHandler.php +++ b/sources/AppBundle/MembershipFee/OnlinePaymentHandler.php @@ -6,7 +6,7 @@ use AppBundle\Association\MemberType; use AppBundle\Controller\Admin\Membership\MembershipFeePayment; -use AppBundle\MembershipFee\Model\MembershipFee; +use AppBundle\MembershipFee\Entity\Cotisation; class OnlinePaymentHandler { @@ -40,7 +40,7 @@ public function validerReglementEnLigne(string $cmd, float $total, string $autor $cotisation = $this->membershipFeeService->getByInvoice($invoiceNumber); $this->membershipFeeService->updatePayment( - $cotisation->getId(), + $cotisation->id, MembershipFeePayment::OnlinePayment->value, "autorisation : " . $autorisation . " / transaction : " . $transaction, ); @@ -49,7 +49,7 @@ public function validerReglementEnLigne(string $cmd, float $total, string $autor $dateDebut = mktime(0, 0, 0, (int) substr($date, 2, 2), (int) substr($date, 0, 2), (int) substr($date, 4, 4)); $cotisation = $this->membershipFeeService->getLatestByUserTypeAndId(MemberType::from((int) $typePersonne), (int) $idPersonne); - $dateFinPrecedente = !$cotisation instanceof MembershipFee ? 0 : $cotisation->getEndDate()->getTimestamp(); + $dateFinPrecedente = !$cotisation instanceof Cotisation ? 0 : $cotisation->dateFin->getTimestamp(); if ($dateFinPrecedente > 0) { $dateDebut = strtotime('+1day', $dateFinPrecedente); diff --git a/sources/AppBundle/Security/MembershipFeeVoter.php b/sources/AppBundle/Security/MembershipFeeVoter.php index daf627af3..9a486cf97 100644 --- a/sources/AppBundle/Security/MembershipFeeVoter.php +++ b/sources/AppBundle/Security/MembershipFeeVoter.php @@ -6,8 +6,8 @@ use Afup\Site\Droits; use AppBundle\Association\MemberType; -use AppBundle\MembershipFee\Model\MembershipFee; -use AppBundle\MembershipFee\Model\Repository\MembershipFeeRepository; +use AppBundle\MembershipFee\Entity\Cotisation; +use AppBundle\MembershipFee\Entity\Repository\CotisationRepository; use Symfony\Component\Security\Core\Authentication\Token\TokenInterface; use Symfony\Component\Security\Core\Authorization\Voter\Vote; use Symfony\Component\Security\Core\Authorization\Voter\Voter; @@ -18,7 +18,7 @@ class MembershipFeeVoter extends Voter public function __construct( private readonly Droits $droits, - private readonly MembershipFeeRepository $membershipFeeRepository, + private readonly CotisationRepository $membershipFeeRepository, ) {} protected function supports(string $attribute, mixed $subject): bool @@ -28,17 +28,17 @@ protected function supports(string $attribute, mixed $subject): bool protected function voteOnAttribute(string $attribute, mixed $subject, TokenInterface $token, ?Vote $vote = null): bool { - $cotisation = $this->membershipFeeRepository->get((int) $subject); - if (!$cotisation instanceof MembershipFee) { + $cotisation = $this->membershipFeeRepository->find((int) $subject); + if (!$cotisation instanceof Cotisation) { return false; } - if ($cotisation->getUserType() === MemberType::MemberPhysical) { - return $cotisation->getUserId() === $this->droits->obtenirIdentifiant(); + if ($cotisation->typePersonne === MemberType::MemberPhysical) { + return $cotisation->idPersonne === $this->droits->obtenirIdentifiant(); } - if ($cotisation->getUserType() === MemberType::MemberCompany) { - return $this->droits->verifierDroitManagerPersonneMorale($cotisation->getUserId()); + if ($cotisation->typePersonne === MemberType::MemberCompany) { + return $this->droits->verifierDroitManagerPersonneMorale($cotisation->idPersonne); } return false; diff --git a/templates/admin/accounting/membership/form.html.twig b/templates/admin/accounting/membership/form.html.twig index 338d1e8de..cf2dbbb91 100644 --- a/templates/admin/accounting/membership/form.html.twig +++ b/templates/admin/accounting/membership/form.html.twig @@ -5,13 +5,13 @@
- {{ form_row(form.amount) }} - {{ form_row(form.paymentType) }} - {{ form_row(form.paymentDetails) }} - {{ form_row(form.clientReference) }} - {{ form_row(form.startDate) }} - {{ form_row(form.endDate) }} - {{ form_row(form.comments) }} + {{ form_row(form.montant) }} + {{ form_row(form.typeReglement) }} + {{ form_row(form.informationsReglement) }} + {{ form_row(form.referenceClient) }} + {{ form_row(form.dateDebut) }} + {{ form_row(form.dateFin) }} + {{ form_row(form.commentaires) }}
diff --git a/templates/admin/accounting/membership/list.html.twig b/templates/admin/accounting/membership/list.html.twig index 81ced30d0..ed97af7c4 100644 --- a/templates/admin/accounting/membership/list.html.twig +++ b/templates/admin/accounting/membership/list.html.twig @@ -43,17 +43,17 @@ {% if memberships|length > 0 %} {% for membership in memberships %} - {{ membership.startDate|format_date('short') }} - {{ membership.endDate|format_date('short') }} - {{ membership.amount|number_format(2, '.', ' ') }} € + {{ membership.dateDebut|format_date('short') }} + {{ membership.dateFin|format_date('short') }} + {{ membership.montant|number_format(2, '.', ' ') }} € - {% if membership.paymentType == enum('AppBundle\\Controller\\Admin\\Membership\\MembershipFeePayment').Cash %} + {% if membership.typeReglement == enum('AppBundle\\Controller\\Admin\\Membership\\MembershipFeePayment').Cash %} en espèces - {% elseif membership.paymentType == enum('AppBundle\\Controller\\Admin\\Membership\\MembershipFeePayment').Check %} - par chèque n° {{ membership.paymentDetails }} - {% elseif membership.paymentType == enum('AppBundle\\Controller\\Admin\\Membership\\MembershipFeePayment').BankTransfert %} - par virement n° {{ membership.paymentDetails }} - {% elseif membership.paymentType == enum('AppBundle\\Controller\\Admin\\Membership\\MembershipFeePayment').OnlinePayment %} + {% elseif membership.typeReglement == enum('AppBundle\\Controller\\Admin\\Membership\\MembershipFeePayment').Check %} + par chèque n° {{ membership.informationsReglement }} + {% elseif membership.typeReglement == enum('AppBundle\\Controller\\Admin\\Membership\\MembershipFeePayment').BankTransfert %} + par virement n° {{ membership.informationsReglement }} + {% elseif membership.typeReglement == enum('AppBundle\\Controller\\Admin\\Membership\\MembershipFeePayment').OnlinePayment %} en ligne {% endif %} diff --git a/templates/admin/association/membership/membershipfee.html.twig b/templates/admin/association/membership/membershipfee.html.twig index 2bead8f7a..90acfabf1 100644 --- a/templates/admin/association/membership/membershipfee.html.twig +++ b/templates/admin/association/membership/membershipfee.html.twig @@ -38,18 +38,18 @@ {% for cotisation in cotisations %} - {{ cotisation.startDate|date('d/m/Y') }} + {{ cotisation.dateDebut|date('d/m/Y') }} - {{ cotisation.endDate|date('d/m/Y') }} - {% if cotisation.startDate < time and cotisation.endDate > time %} + {{ cotisation.dateFin|date('d/m/Y') }} + {% if cotisation.dateDebut < time and cotisation.dateFin > time %} (toujours valide) {% endif %} - {{ cotisation.amount|number_format(2, ',') }} € + {{ cotisation.montant|number_format(2, ',') }} € - {% if cotisation.canDownloadInvoice %} - + {% if cotisation.telechargerFacture %} + Télécharger la facture diff --git a/templates/site/company_membership/payment.html.twig b/templates/site/company_membership/payment.html.twig index 3bd992b88..2316f7285 100644 --- a/templates/site/company_membership/payment.html.twig +++ b/templates/site/company_membership/payment.html.twig @@ -7,17 +7,17 @@ Votre inscription a bien été enregistrée ! Il ne vous reste plus qu'à régler votre cotisation.

- Montant de la cotisation: {{ invoice.amount|number_format(2, '.', ' ') }} Euros + Montant de la cotisation: {{ invoice.montant|number_format(2, '.', ' ') }} Euros

Facture disponible

- Télécharger la facture + Télécharger la facture

Régler votre cotisation par Carte Bleue

{{ paybox|raw }}

Régler votre cotisation par chèque

-

Libellez le chèque à cet ordre: {{ afup.raison_sociale }}. Indiquez au dos le numéro de facture: {{ invoice.invoiceNumber }}

+

Libellez le chèque à cet ordre: {{ afup.raison_sociale }}. Indiquez au dos le numéro de facture: {{ invoice.numeroFacture }}

{{ afup.raison_sociale }}
{{ afup.adresse }}
@@ -25,7 +25,7 @@

Régler votre cotisation par virement bancaire

- Lors d'un règlement par virement bancaire, indiquez ce libellé: {{ invoice.invoiceNumber }}. + Lors d'un règlement par virement bancaire, indiquez ce libellé: {{ invoice.numeroFacture }}.

diff --git a/tests/behat/features/Admin/AdminPersonnesMoralesCotisations.feature b/tests/behat/features/Admin/AdminPersonnesMoralesCotisations.feature index e7f26bec4..5bfd0f582 100644 --- a/tests/behat/features/Admin/AdminPersonnesMoralesCotisations.feature +++ b/tests/behat/features/Admin/AdminPersonnesMoralesCotisations.feature @@ -23,7 +23,7 @@ Feature: Administration - Partie Personnes morales - cotisations Then I should see "Cotisations de MyCorp" When I follow the button of tooltip "Modifier la cotisation" Then I should see "Modifier une cotisation" - When I fill in "membership_fee[amount]" with "152" + When I fill in "membership_fee[montant]" with "152" And I press "Modifier" Then I should see "La cotisation pour MyCorp a bien été modifiée" Then I should see "152.00" @@ -33,12 +33,12 @@ Feature: Administration - Partie Personnes morales - cotisations # ajout d'une cotisation When I follow "Ajouter" Then I should see "Ajouter une cotisation" - When I fill in "membership_fee[amount]" with "150" - And I select "0" from "membership_fee[paymentType]" - When I fill in "membership_fee[paymentDetails]" with "notes du réglement" - When I fill in "membership_fee[clientReference]" with "42" - And I fill in "membership_fee[startDate]" with "2022-03-05" - And I fill in "membership_fee[endDate]" with "2023-03-05" + When I fill in "membership_fee[montant]" with "150" + And I select "0" from "membership_fee[typeReglement]" + When I fill in "membership_fee[informationsReglement]" with "notes du réglement" + When I fill in "membership_fee[referenceClient]" with "42" + And I fill in "membership_fee[dateDebut]" with "2022-03-05" + And I fill in "membership_fee[dateFin]" with "2023-03-05" And I press "Ajouter" Then I should see "La cotisation jusqu'au 05 mars 2023 pour MyCorp a bien été ajoutée" Then I should see "05/03/2022" @@ -48,24 +48,24 @@ Feature: Administration - Partie Personnes morales - cotisations # Modification du mode de paiement - chèque When I follow the button of tooltip "Modifier la cotisation" Then I should see "Modifier une cotisation" - And I select "Chèques" from "membership_fee[paymentType]" - And I fill in "membership_fee[paymentDetails]" with "42" + And I select "Chèques" from "membership_fee[typeReglement]" + And I fill in "membership_fee[informationsReglement]" with "42" And I press "Modifier" Then I should see "La cotisation pour MyCorp a bien été modifiée" Then I should see "par chèque n° 42" # Modification du mode de paiement - virement When I follow the button of tooltip "Modifier la cotisation" Then I should see "Modifier une cotisation" - And I select "Virement" from "membership_fee[paymentType]" - And I fill in "membership_fee[paymentDetails]" with "8342" + And I select "Virement" from "membership_fee[typeReglement]" + And I fill in "membership_fee[informationsReglement]" with "8342" And I press "Modifier" Then I should see "La cotisation pour MyCorp a bien été modifiée" Then I should see "par virement n° 8342" # Modification du mode de paiement - paiement en ligne When I follow the button of tooltip "Modifier la cotisation" Then I should see "Modifier une cotisation" - And I select "En ligne" from "membership_fee[paymentType]" - And I fill in "membership_fee[paymentDetails]" with "" + And I select "En ligne" from "membership_fee[typeReglement]" + And I fill in "membership_fee[informationsReglement]" with "" And I press "Modifier" Then I should see "La cotisation pour MyCorp a bien été modifiée" Then I should see "en ligne" diff --git a/tests/behat/features/Admin/AdminPersonnesPhysiquesCotisations.feature b/tests/behat/features/Admin/AdminPersonnesPhysiquesCotisations.feature index 948945a8e..8c3405e29 100644 --- a/tests/behat/features/Admin/AdminPersonnesPhysiquesCotisations.feature +++ b/tests/behat/features/Admin/AdminPersonnesPhysiquesCotisations.feature @@ -58,7 +58,7 @@ Feature: Administration - Partie Personnes physiques - cotisations Then I should see "Cotisations de Personne Paul" When I follow the button of tooltip "Modifier la cotisation" Then I should see "Modifier une cotisation" - When I fill in "membership_fee[amount]" with "30" + When I fill in "membership_fee[montant]" with "30" And I press "Modifier" Then I should see "La cotisation pour Personne Paul a bien été modifiée" Then I should see "30.00" @@ -68,11 +68,11 @@ Feature: Administration - Partie Personnes physiques - cotisations # ajout d'une cotisation When I follow "Ajouter" Then I should see "Ajouter une cotisation" - When I fill in "membership_fee[amount]" with "25" - And I select "0" from "membership_fee[paymentType]" - When I fill in "membership_fee[paymentDetails]" with "notes du réglement" - And I fill in "membership_fee[startDate]" with "2022-03-05" - And I fill in "membership_fee[endDate]" with "2023-03-05" + When I fill in "membership_fee[montant]" with "25" + And I select "0" from "membership_fee[typeReglement]" + When I fill in "membership_fee[informationsReglement]" with "notes du réglement" + And I fill in "membership_fee[dateDebut]" with "2022-03-05" + And I fill in "membership_fee[dateFin]" with "2023-03-05" And I press "Ajouter" Then I should see "La cotisation jusqu'au 05 mars 2023 pour Personne Paul a bien été ajoutée" Then I should see "05/03/2022" @@ -82,24 +82,24 @@ Feature: Administration - Partie Personnes physiques - cotisations # Modification du mode de paiement - chèque When I follow the button of tooltip "Modifier la cotisation" Then I should see "Modifier une cotisation" - And I select "Chèques" from "membership_fee[paymentType]" - And I fill in "membership_fee[paymentDetails]" with "42" + And I select "Chèques" from "membership_fee[typeReglement]" + And I fill in "membership_fee[informationsReglement]" with "42" And I press "Modifier" Then I should see "La cotisation pour Personne Paul a bien été modifiée" Then I should see "par chèque n° 42" # Modification du mode de paiement - virement When I follow the button of tooltip "Modifier la cotisation" Then I should see "Modifier une cotisation" - And I select "Virement" from "membership_fee[paymentType]" - And I fill in "membership_fee[paymentDetails]" with "8342" + And I select "Virement" from "membership_fee[typeReglement]" + And I fill in "membership_fee[informationsReglement]" with "8342" And I press "Modifier" Then I should see "La cotisation pour Personne Paul a bien été modifiée" Then I should see "par virement n° 8342" # Modification du mode de paiement - paiement en ligne When I follow the button of tooltip "Modifier la cotisation" Then I should see "Modifier une cotisation" - And I select "En ligne" from "membership_fee[paymentType]" - And I fill in "membership_fee[paymentDetails]" with "" + And I select "En ligne" from "membership_fee[typeReglement]" + And I fill in "membership_fee[informationsReglement]" with "" And I press "Modifier" Then I should see "La cotisation pour Personne Paul a bien été modifiée" Then I should see "en ligne" diff --git a/tests/unit/AppBundle/MembershipFee/MembershipFeeServiceTest.php b/tests/unit/AppBundle/MembershipFee/MembershipFeeServiceTest.php index d408b7cb1..974aff973 100644 --- a/tests/unit/AppBundle/MembershipFee/MembershipFeeServiceTest.php +++ b/tests/unit/AppBundle/MembershipFee/MembershipFeeServiceTest.php @@ -5,9 +5,9 @@ namespace AppBundle\Tests\MembershipFee; use AppBundle\Association\MemberType; +use AppBundle\MembershipFee\Entity\Cotisation; +use AppBundle\MembershipFee\Entity\Repository\CotisationRepository; use AppBundle\MembershipFee\MembershipFeeService; -use AppBundle\MembershipFee\Model\MembershipFee; -use AppBundle\MembershipFee\Model\Repository\MembershipFeeRepository; use AppBundle\MembershipFee\OnlinePaymentHandler; use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\TestCase; @@ -39,12 +39,12 @@ public static function generateCotisationProvider(): array #[DataProvider('generateCotisationProvider')] public function testFinProchaineCotisation(\DateTimeInterface $dateFin, \DateTimeInterface $expected): void { - $membershipFeeRepository = $this->createMock(MembershipFeeRepository::class); + $membershipFeeRepository = $this->createMock(CotisationRepository::class); $membershipFeeService = new MembershipFeeService($membershipFeeRepository); - $membershipFee = new MembershipFee(); - $membershipFee->setEndDate(new \DateTime('@' . $dateFin->format('U'))); + $membershipFee = new Cotisation(); + $membershipFee->dateFin = new \DateTime('@' . $dateFin->format('U')); $actual = $membershipFeeService->getNextSubscriptionExpiration($membershipFee); @@ -68,7 +68,7 @@ public static function accountCmdProvider(): array #[DataProvider('accountCmdProvider')] public function testGetAccountFromCmd(string $cmd, array $expected): void { - $membershipFeeRepository = $this->createMock(MembershipFeeRepository::class); + $membershipFeeRepository = $this->createMock(CotisationRepository::class); $membershipFeeService = new MembershipFeeService($membershipFeeRepository);