From 6f5a7a587aee80e8d6516afa7ed3a00a8913c815 Mon Sep 17 00:00:00 2001 From: vgreb Date: Sun, 16 Aug 2026 23:14:15 +0200 Subject: [PATCH] =?UTF-8?q?refonte=20comptabilit=C3=A9=20avec=20Doctrine?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- config/packages/ting.yaml | 7 - ...make_transaction_payment_type_nullable.php | 34 ++ db/seeds/ComptaCompte.php | 8 + phpstan-baseline.php | 546 +++--------------- .../AppBundle/Accounting/Entity/Invoicing.php | 118 ++++ .../Accounting/Entity/InvoicingDetail.php | 44 ++ .../Accounting/Entity/InvoicingPeriod.php | 27 + .../Repository/InvoicingPeriodRepository.php | 43 ++ .../Entity/Repository/InvoicingRepository.php | 127 ++++ .../Repository/TransactionRepository.php | 99 ++++ .../Accounting/Entity/Transaction.php | 99 ++++ .../AppBundle/Accounting/Form/InvoiceType.php | 34 +- .../Accounting/Form/InvoicingPeriodType.php | 8 +- .../Accounting/Form/InvoicingRowType.php | 10 +- .../Accounting/Form/QuotationType.php | 30 +- .../Accounting/Form/TransactionType.php | 133 ++--- .../AppBundle/Accounting/InvoicingMailer.php | 6 +- .../Accounting/InvoicingNumberGenerator.php | 2 +- .../Accounting/InvoicingPdfGenerator.php | 80 +-- .../AppBundle/Accounting/Model/Invoicing.php | 383 ------------ .../Accounting/Model/InvoicingDetail.php | 124 ---- .../Accounting/Model/InvoicingPeriod.php | 72 --- .../Repository/InvoicingDetailRepository.php | 101 ---- .../Repository/InvoicingPeriodRepository.php | 94 --- .../Model/Repository/InvoicingRepository.php | 322 ----------- .../Repository/TransactionRepository.php | 244 -------- .../Accounting/Model/Transaction.php | 357 ------------ .../Accounting/TransactionModification.php | 24 +- sources/AppBundle/Compta/CsvExtractor.php | 64 +- .../Invoice/DownloadInvoiceAction.php | 4 +- .../Accounting/Invoice/EditInvoiceAction.php | 5 +- .../Accounting/Invoice/ListInvoiceAction.php | 18 +- .../Invoice/SendInvoiceEmailAction.php | 2 +- .../Journal/AddTransactionAction.php | 10 +- .../Accounting/Journal/AllocateAction.php | 55 +- .../Admin/Accounting/Journal/DeleteAction.php | 6 +- .../Journal/DownloadAttachmentAction.php | 10 +- .../Journal/DownloadAttachmentsAction.php | 6 +- .../Journal/EditTransactionAction.php | 16 +- .../Admin/Accounting/Journal/ExportAction.php | 8 +- .../Admin/Accounting/Journal/ListAction.php | 8 +- .../Accounting/Journal/UpdateInfoAction.php | 18 +- .../Journal/UploadAttachmentAction.php | 16 +- .../Quotation/AddQuotationAction.php | 83 ++- .../Quotation/ConvertQuotationAction.php | 4 +- .../Quotation/DownloadQuotationAction.php | 2 +- .../Quotation/EditQuotationAction.php | 24 +- .../Quotation/ListQuotationAction.php | 12 +- .../Website/Payment/InvoiceAction.php | 18 +- .../Website/Payment/InvoiceDownloadAction.php | 2 +- .../Website/Payment/InvoiceRedirectAction.php | 7 +- .../admin/accounting/invoice/edit.html.twig | 38 +- .../admin/accounting/invoice/list.html.twig | 28 +- .../admin/accounting/journal/form.html.twig | 32 +- .../admin/accounting/journal/list.html.twig | 2 +- .../journal/vat_calculation.js.twig | 10 +- .../quotation/_javascript.html.twig | 4 +- .../accounting/quotation/_prototype.html.twig | 4 +- .../admin/accounting/quotation/form.html.twig | 32 +- .../admin/accounting/quotation/list.html.twig | 32 +- .../Admin/Tresorerie/DevisFactures.feature | 58 +- .../features/Admin/Tresorerie/Journal.feature | 40 +- .../Admin/Tresorerie/JournalImport.feature | 8 +- 63 files changed, 1179 insertions(+), 2683 deletions(-) create mode 100644 db/migrations/20260816000000_make_transaction_payment_type_nullable.php create mode 100644 sources/AppBundle/Accounting/Entity/Invoicing.php create mode 100644 sources/AppBundle/Accounting/Entity/InvoicingDetail.php create mode 100644 sources/AppBundle/Accounting/Entity/InvoicingPeriod.php create mode 100644 sources/AppBundle/Accounting/Entity/Repository/InvoicingPeriodRepository.php create mode 100644 sources/AppBundle/Accounting/Entity/Repository/InvoicingRepository.php create mode 100644 sources/AppBundle/Accounting/Entity/Repository/TransactionRepository.php create mode 100644 sources/AppBundle/Accounting/Entity/Transaction.php delete mode 100644 sources/AppBundle/Accounting/Model/Invoicing.php delete mode 100644 sources/AppBundle/Accounting/Model/InvoicingDetail.php delete mode 100644 sources/AppBundle/Accounting/Model/InvoicingPeriod.php delete mode 100644 sources/AppBundle/Accounting/Model/Repository/InvoicingDetailRepository.php delete mode 100644 sources/AppBundle/Accounting/Model/Repository/InvoicingPeriodRepository.php delete mode 100644 sources/AppBundle/Accounting/Model/Repository/InvoicingRepository.php delete mode 100644 sources/AppBundle/Accounting/Model/Repository/TransactionRepository.php delete mode 100644 sources/AppBundle/Accounting/Model/Transaction.php diff --git a/config/packages/ting.yaml b/config/packages/ting.yaml index 50e74aa9c..6ddf960e9 100644 --- a/config/packages/ting.yaml +++ b/config/packages/ting.yaml @@ -17,13 +17,6 @@ ting: default: connection: main database: '%database_name%' - accounting: - namespace: AppBundle\Accounting\Model\Repository - directory: "@AppBundle/Accounting/Model/Repository" - options: - default: - connection: main - database: "%database_name%" association: namespace : AppBundle\Association\Model\Repository directory : "@AppBundle/Association/Model/Repository" diff --git a/db/migrations/20260816000000_make_transaction_payment_type_nullable.php b/db/migrations/20260816000000_make_transaction_payment_type_nullable.php new file mode 100644 index 000000000..8cfccc2eb --- /dev/null +++ b/db/migrations/20260816000000_make_transaction_payment_type_nullable.php @@ -0,0 +1,34 @@ +table('compta') + ->changeColumn('idmode_regl', 'integer', [ + 'limit' => 5, + 'null' => true, + 'default' => null, + ]) + ->update(); + + $this->execute('UPDATE compta SET idmode_regl = NULL WHERE idmode_regl = 0'); + } + + public function down(): void + { + $this->execute('UPDATE compta SET idmode_regl = 0 WHERE idmode_regl IS NULL'); + + $this->table('compta') + ->changeColumn('idmode_regl', 'integer', [ + 'limit' => 5, + 'null' => false, + 'default' => 0, + ]) + ->update(); + } +} diff --git a/db/seeds/ComptaCompte.php b/db/seeds/ComptaCompte.php index d515d6e77..05b5e4874 100644 --- a/db/seeds/ComptaCompte.php +++ b/db/seeds/ComptaCompte.php @@ -27,6 +27,14 @@ public function run(): void 'nom_compte' => 'Paypal', 'archived_at' => new DateTime('last year')->format('Y-m-d H:i:s'), ], + [ + 'id' => 5, + 'nom_compte' => 'Compte courant CMUT', + ], + [ + 'id' => 6, + 'nom_compte' => 'Livret CMUT', + ], ]; $table = $this->table('compta_compte'); diff --git a/phpstan-baseline.php b/phpstan-baseline.php index 7a414568a..1e94d36d1 100644 --- a/phpstan-baseline.php +++ b/phpstan-baseline.php @@ -199,6 +199,30 @@ 'count' => 1, 'path' => __DIR__ . '/sources/Afup/Utils/Vat.php', ]; +$ignoreErrors[] = [ + 'message' => '#^Property AppBundle\\\\Accounting\\\\Entity\\\\InvoicingDetail\\:\\:\\$designation type mapping mismatch\\: property can contain string\\|null but database expects string\\.$#', + 'identifier' => 'doctrine.columnType', + 'count' => 1, + 'path' => __DIR__ . '/sources/AppBundle/Accounting/Entity/InvoicingDetail.php', +]; +$ignoreErrors[] = [ + 'message' => '#^Property AppBundle\\\\Accounting\\\\Entity\\\\InvoicingDetail\\:\\:\\$prixUnitaire type mapping mismatch\\: property can contain float\\|null but database expects float\\|int\\.$#', + 'identifier' => 'doctrine.columnType', + 'count' => 1, + 'path' => __DIR__ . '/sources/AppBundle/Accounting/Entity/InvoicingDetail.php', +]; +$ignoreErrors[] = [ + 'message' => '#^Property AppBundle\\\\Accounting\\\\Entity\\\\InvoicingDetail\\:\\:\\$quantite type mapping mismatch\\: property can contain float\\|null but database expects float\\|int\\.$#', + 'identifier' => 'doctrine.columnType', + 'count' => 1, + 'path' => __DIR__ . '/sources/AppBundle/Accounting/Entity/InvoicingDetail.php', +]; +$ignoreErrors[] = [ + 'message' => '#^Property AppBundle\\\\Accounting\\\\Entity\\\\InvoicingDetail\\:\\:\\$reference type mapping mismatch\\: property can contain string\\|null but database expects string\\.$#', + 'identifier' => 'doctrine.columnType', + 'count' => 1, + 'path' => __DIR__ . '/sources/AppBundle/Accounting/Entity/InvoicingDetail.php', +]; $ignoreErrors[] = [ 'message' => '#^Method AppBundle\\\\Accounting\\\\Entity\\\\Repository\\\\AccountRepository\\:\\:getAllSortedByName\\(\\) should return array\\ but returns mixed\\.$#', 'identifier' => 'return.type', @@ -217,6 +241,30 @@ 'count' => 1, 'path' => __DIR__ . '/sources/AppBundle/Accounting/Entity/Repository/EventRepository.php', ]; +$ignoreErrors[] = [ + 'message' => '#^Method AppBundle\\\\Accounting\\\\Entity\\\\Repository\\\\InvoicingPeriodRepository\\:\\:getCurrentPeriod\\(\\) should return AppBundle\\\\Accounting\\\\Entity\\\\InvoicingPeriod but returns AppBundle\\\\Accounting\\\\Entity\\\\InvoicingPeriod\\|null\\.$#', + 'identifier' => 'return.type', + 'count' => 1, + 'path' => __DIR__ . '/sources/AppBundle/Accounting/Entity/Repository/InvoicingPeriodRepository.php', +]; +$ignoreErrors[] = [ + 'message' => '#^Cannot access property \\$dateDebut on AppBundle\\\\Accounting\\\\Entity\\\\InvoicingPeriod\\|null\\.$#', + 'identifier' => 'property.nonObject', + 'count' => 2, + 'path' => __DIR__ . '/sources/AppBundle/Accounting/Entity/Repository/InvoicingRepository.php', +]; +$ignoreErrors[] = [ + 'message' => '#^Cannot access property \\$dateFin on AppBundle\\\\Accounting\\\\Entity\\\\InvoicingPeriod\\|null\\.$#', + 'identifier' => 'property.nonObject', + 'count' => 2, + 'path' => __DIR__ . '/sources/AppBundle/Accounting/Entity/Repository/InvoicingRepository.php', +]; +$ignoreErrors[] = [ + 'message' => '#^Cannot cast mixed to int\\.$#', + 'identifier' => 'cast.int', + 'count' => 2, + 'path' => __DIR__ . '/sources/AppBundle/Accounting/Entity/Repository/InvoicingRepository.php', +]; $ignoreErrors[] = [ 'message' => '#^Method AppBundle\\\\Accounting\\\\Entity\\\\Repository\\\\PaymentRepository\\:\\:getAllSortedByName\\(\\) should return array\\ but returns mixed\\.$#', 'identifier' => 'return.type', @@ -235,6 +283,18 @@ 'count' => 1, 'path' => __DIR__ . '/sources/AppBundle/Accounting/Entity/Repository/RuleRepository.php', ]; +$ignoreErrors[] = [ + 'message' => '#^Cannot call method format\\(\\) on DateTime\\|null\\.$#', + 'identifier' => 'method.nonObject', + 'count' => 2, + 'path' => __DIR__ . '/sources/AppBundle/Accounting/Entity/Repository/TransactionRepository.php', +]; +$ignoreErrors[] = [ + 'message' => '#^Method AppBundle\\\\Accounting\\\\Entity\\\\Repository\\\\TransactionRepository\\:\\:getNextTransaction\\(\\) should return AppBundle\\\\Accounting\\\\Entity\\\\Transaction\\|null but returns mixed\\.$#', + 'identifier' => 'return.type', + 'count' => 1, + 'path' => __DIR__ . '/sources/AppBundle/Accounting/Entity/Repository/TransactionRepository.php', +]; $ignoreErrors[] = [ 'message' => '#^Class AppBundle\\\\Accounting\\\\Form\\\\AccountType extends generic class Symfony\\\\Component\\\\Form\\\\AbstractType but does not specify its types\\: TData$#', 'identifier' => 'missingType.generics', @@ -325,36 +385,6 @@ 'count' => 1, 'path' => __DIR__ . '/sources/AppBundle/Accounting/Form/TransactionType.php', ]; -$ignoreErrors[] = [ - 'message' => '#^Method AppBundle\\\\Accounting\\\\Form\\\\TransactionType\\:\\:buildAccountChoice\\(\\) return type has no value type specified in iterable type array\\.$#', - 'identifier' => 'missingType.iterableValue', - 'count' => 1, - 'path' => __DIR__ . '/sources/AppBundle/Accounting/Form/TransactionType.php', -]; -$ignoreErrors[] = [ - 'message' => '#^Method AppBundle\\\\Accounting\\\\Form\\\\TransactionType\\:\\:buildCategoryChoice\\(\\) return type has no value type specified in iterable type array\\.$#', - 'identifier' => 'missingType.iterableValue', - 'count' => 1, - 'path' => __DIR__ . '/sources/AppBundle/Accounting/Form/TransactionType.php', -]; -$ignoreErrors[] = [ - 'message' => '#^Method AppBundle\\\\Accounting\\\\Form\\\\TransactionType\\:\\:buildEventChoice\\(\\) return type has no value type specified in iterable type array\\.$#', - 'identifier' => 'missingType.iterableValue', - 'count' => 1, - 'path' => __DIR__ . '/sources/AppBundle/Accounting/Form/TransactionType.php', -]; -$ignoreErrors[] = [ - 'message' => '#^Method AppBundle\\\\Accounting\\\\Form\\\\TransactionType\\:\\:buildOperationTypeChoice\\(\\) return type has no value type specified in iterable type array\\.$#', - 'identifier' => 'missingType.iterableValue', - 'count' => 1, - 'path' => __DIR__ . '/sources/AppBundle/Accounting/Form/TransactionType.php', -]; -$ignoreErrors[] = [ - 'message' => '#^Method AppBundle\\\\Accounting\\\\Form\\\\TransactionType\\:\\:buildPaymentTypeChoice\\(\\) return type has no value type specified in iterable type array\\.$#', - 'identifier' => 'missingType.iterableValue', - 'count' => 1, - 'path' => __DIR__ . '/sources/AppBundle/Accounting/Form/TransactionType.php', -]; $ignoreErrors[] = [ 'message' => '#^Class AppBundle\\\\Accounting\\\\Form\\\\TransactionsImportType extends generic class Symfony\\\\Component\\\\Form\\\\AbstractType but does not specify its types\\: TData$#', 'identifier' => 'missingType.generics', @@ -391,12 +421,6 @@ 'count' => 1, 'path' => __DIR__ . '/sources/AppBundle/Accounting/InvoicingPdfGenerator.php', ]; -$ignoreErrors[] = [ - 'message' => '#^Parameter \\#1 \\$id of method Afup\\\\Site\\\\Utils\\\\Pays\\:\\:obtenirNom\\(\\) expects string, string\\|null given\\.$#', - 'identifier' => 'argument.type', - 'count' => 1, - 'path' => __DIR__ . '/sources/AppBundle/Accounting/InvoicingPdfGenerator.php', -]; $ignoreErrors[] = [ 'message' => '#^Parameter \\#1 \\$num of function number_format expects float, float\\|null given\\.$#', 'identifier' => 'argument.type', @@ -409,150 +433,6 @@ 'count' => 1, 'path' => __DIR__ . '/sources/AppBundle/Accounting/InvoicingPdfGenerator.php', ]; -$ignoreErrors[] = [ - 'message' => '#^Property AppBundle\\\\Accounting\\\\Model\\\\Invoicing\\:\\:\\$countryId \\(string\\) does not accept string\\|null\\.$#', - 'identifier' => 'assign.propertyType', - 'count' => 1, - 'path' => __DIR__ . '/sources/AppBundle/Accounting/Model/Invoicing.php', -]; -$ignoreErrors[] = [ - 'message' => '#^Cannot access offset \'id\' on mixed\\.$#', - 'identifier' => 'offsetAccess.nonOffsetAccessible', - 'count' => 1, - 'path' => __DIR__ . '/sources/AppBundle/Accounting/Model/Repository/InvoicingDetailRepository.php', -]; -$ignoreErrors[] = [ - 'message' => '#^Method AppBundle\\\\Accounting\\\\Model\\\\Repository\\\\InvoicingDetailRepository\\:\\:getRowsIdsPerInvoicingId\\(\\) return type has no value type specified in iterable type array\\.$#', - 'identifier' => 'missingType.iterableValue', - 'count' => 1, - 'path' => __DIR__ . '/sources/AppBundle/Accounting/Model/Repository/InvoicingDetailRepository.php', -]; -$ignoreErrors[] = [ - 'message' => '#^Method AppBundle\\\\Accounting\\\\Model\\\\Repository\\\\InvoicingDetailRepository\\:\\:initMetadata\\(\\) has parameter \\$options with no value type specified in iterable type array\\.$#', - 'identifier' => 'missingType.iterableValue', - 'count' => 1, - 'path' => __DIR__ . '/sources/AppBundle/Accounting/Model/Repository/InvoicingDetailRepository.php', -]; -$ignoreErrors[] = [ - 'message' => '#^Method AppBundle\\\\Accounting\\\\Model\\\\Repository\\\\InvoicingDetailRepository\\:\\:initMetadata\\(\\) should return M of CCMBenchmark\\\\Ting\\\\Repository\\\\Metadata but returns CCMBenchmark\\\\Ting\\\\Repository\\\\Metadata\\\\.$#', - 'identifier' => 'return.type', - 'count' => 1, - 'path' => __DIR__ . '/sources/AppBundle/Accounting/Model/Repository/InvoicingDetailRepository.php', -]; -$ignoreErrors[] = [ - 'message' => '#^Parameter \\#1 \\$databaseName of method CCMBenchmark\\\\Ting\\\\Repository\\\\Metadata\\\\:\\:setDatabase\\(\\) expects string, mixed given\\.$#', - 'identifier' => 'argument.type', - 'count' => 1, - 'path' => __DIR__ . '/sources/AppBundle/Accounting/Model/Repository/InvoicingDetailRepository.php', -]; -$ignoreErrors[] = [ - 'message' => '#^Method AppBundle\\\\Accounting\\\\Model\\\\Repository\\\\InvoicingPeriodRepository\\:\\:getCurrentPeriod\\(\\) should return AppBundle\\\\Accounting\\\\Model\\\\InvoicingPeriod but returns AppBundle\\\\Accounting\\\\Model\\\\InvoicingPeriod\\|null\\.$#', - 'identifier' => 'return.type', - 'count' => 2, - 'path' => __DIR__ . '/sources/AppBundle/Accounting/Model/Repository/InvoicingPeriodRepository.php', -]; -$ignoreErrors[] = [ - 'message' => '#^Method AppBundle\\\\Accounting\\\\Model\\\\Repository\\\\InvoicingPeriodRepository\\:\\:initMetadata\\(\\) has parameter \\$options with no value type specified in iterable type array\\.$#', - 'identifier' => 'missingType.iterableValue', - 'count' => 1, - 'path' => __DIR__ . '/sources/AppBundle/Accounting/Model/Repository/InvoicingPeriodRepository.php', -]; -$ignoreErrors[] = [ - 'message' => '#^Method AppBundle\\\\Accounting\\\\Model\\\\Repository\\\\InvoicingPeriodRepository\\:\\:initMetadata\\(\\) should return M of CCMBenchmark\\\\Ting\\\\Repository\\\\Metadata but returns CCMBenchmark\\\\Ting\\\\Repository\\\\Metadata\\\\.$#', - 'identifier' => 'return.type', - 'count' => 1, - 'path' => __DIR__ . '/sources/AppBundle/Accounting/Model/Repository/InvoicingPeriodRepository.php', -]; -$ignoreErrors[] = [ - 'message' => '#^Parameter \\#1 \\$databaseName of method CCMBenchmark\\\\Ting\\\\Repository\\\\Metadata\\\\:\\:setDatabase\\(\\) expects string, mixed given\\.$#', - 'identifier' => 'argument.type', - 'count' => 1, - 'path' => __DIR__ . '/sources/AppBundle/Accounting/Model/Repository/InvoicingPeriodRepository.php', -]; -$ignoreErrors[] = [ - 'message' => '#^Cannot access offset \'next_index\' on mixed\\.$#', - 'identifier' => 'offsetAccess.nonOffsetAccessible', - 'count' => 2, - 'path' => __DIR__ . '/sources/AppBundle/Accounting/Model/Repository/InvoicingRepository.php', -]; -$ignoreErrors[] = [ - 'message' => '#^Cannot cast mixed to int\\.$#', - 'identifier' => 'cast.int', - 'count' => 2, - 'path' => __DIR__ . '/sources/AppBundle/Accounting/Model/Repository/InvoicingRepository.php', -]; -$ignoreErrors[] = [ - 'message' => '#^Method AppBundle\\\\Accounting\\\\Model\\\\Repository\\\\InvoicingRepository\\:\\:findOneWithDetails\\(\\) has parameter \\$params with no value type specified in iterable type array\\.$#', - 'identifier' => 'missingType.iterableValue', - 'count' => 1, - 'path' => __DIR__ . '/sources/AppBundle/Accounting/Model/Repository/InvoicingRepository.php', -]; -$ignoreErrors[] = [ - 'message' => '#^Method AppBundle\\\\Accounting\\\\Model\\\\Repository\\\\InvoicingRepository\\:\\:getInvoicesByPeriodId\\(\\) return type with generic interface CCMBenchmark\\\\Ting\\\\Repository\\\\CollectionInterface does not specify its types\\: T$#', - 'identifier' => 'missingType.generics', - 'count' => 1, - 'path' => __DIR__ . '/sources/AppBundle/Accounting/Model/Repository/InvoicingRepository.php', -]; -$ignoreErrors[] = [ - 'message' => '#^Method AppBundle\\\\Accounting\\\\Model\\\\Repository\\\\InvoicingRepository\\:\\:getQuotationsByPeriodId\\(\\) return type with generic interface CCMBenchmark\\\\Ting\\\\Repository\\\\CollectionInterface does not specify its types\\: T$#', - 'identifier' => 'missingType.generics', - 'count' => 1, - 'path' => __DIR__ . '/sources/AppBundle/Accounting/Model/Repository/InvoicingRepository.php', -]; -$ignoreErrors[] = [ - 'message' => '#^Method AppBundle\\\\Accounting\\\\Model\\\\Repository\\\\InvoicingRepository\\:\\:initMetadata\\(\\) has parameter \\$options with no value type specified in iterable type array\\.$#', - 'identifier' => 'missingType.iterableValue', - 'count' => 1, - 'path' => __DIR__ . '/sources/AppBundle/Accounting/Model/Repository/InvoicingRepository.php', -]; -$ignoreErrors[] = [ - 'message' => '#^Method AppBundle\\\\Accounting\\\\Model\\\\Repository\\\\InvoicingRepository\\:\\:initMetadata\\(\\) should return M of CCMBenchmark\\\\Ting\\\\Repository\\\\Metadata but returns CCMBenchmark\\\\Ting\\\\Repository\\\\Metadata\\\\.$#', - 'identifier' => 'return.type', - 'count' => 1, - 'path' => __DIR__ . '/sources/AppBundle/Accounting/Model/Repository/InvoicingRepository.php', -]; -$ignoreErrors[] = [ - 'message' => '#^Parameter \\#1 \\$databaseName of method CCMBenchmark\\\\Ting\\\\Repository\\\\Metadata\\\\:\\:setDatabase\\(\\) expects string, mixed given\\.$#', - 'identifier' => 'argument.type', - 'count' => 1, - 'path' => __DIR__ . '/sources/AppBundle/Accounting/Model/Repository/InvoicingRepository.php', -]; -$ignoreErrors[] = [ - 'message' => '#^Cannot call method format\\(\\) on DateTime\\|null\\.$#', - 'identifier' => 'method.nonObject', - 'count' => 2, - 'path' => __DIR__ . '/sources/AppBundle/Accounting/Model/Repository/TransactionRepository.php', -]; -$ignoreErrors[] = [ - 'message' => '#^Method AppBundle\\\\Accounting\\\\Model\\\\Repository\\\\TransactionRepository\\:\\:getEntriesPerInvoicingPeriod\\(\\) has no return type specified\\.$#', - 'identifier' => 'missingType.return', - 'count' => 1, - 'path' => __DIR__ . '/sources/AppBundle/Accounting/Model/Repository/TransactionRepository.php', -]; -$ignoreErrors[] = [ - 'message' => '#^Method AppBundle\\\\Accounting\\\\Model\\\\Repository\\\\TransactionRepository\\:\\:getNextTransaction\\(\\) should return AppBundle\\\\Accounting\\\\Model\\\\Transaction\\|null but returns mixed\\.$#', - 'identifier' => 'return.type', - 'count' => 1, - 'path' => __DIR__ . '/sources/AppBundle/Accounting/Model/Repository/TransactionRepository.php', -]; -$ignoreErrors[] = [ - 'message' => '#^Method AppBundle\\\\Accounting\\\\Model\\\\Repository\\\\TransactionRepository\\:\\:initMetadata\\(\\) has parameter \\$options with no value type specified in iterable type array\\.$#', - 'identifier' => 'missingType.iterableValue', - 'count' => 1, - 'path' => __DIR__ . '/sources/AppBundle/Accounting/Model/Repository/TransactionRepository.php', -]; -$ignoreErrors[] = [ - 'message' => '#^Method AppBundle\\\\Accounting\\\\Model\\\\Repository\\\\TransactionRepository\\:\\:initMetadata\\(\\) should return M of CCMBenchmark\\\\Ting\\\\Repository\\\\Metadata but returns CCMBenchmark\\\\Ting\\\\Repository\\\\Metadata\\\\.$#', - 'identifier' => 'return.type', - 'count' => 1, - 'path' => __DIR__ . '/sources/AppBundle/Accounting/Model/Repository/TransactionRepository.php', -]; -$ignoreErrors[] = [ - 'message' => '#^Parameter \\#1 \\$databaseName of method CCMBenchmark\\\\Ting\\\\Repository\\\\Metadata\\\\:\\:setDatabase\\(\\) expects string, mixed given\\.$#', - 'identifier' => 'argument.type', - 'count' => 1, - 'path' => __DIR__ . '/sources/AppBundle/Accounting/Model/Repository/TransactionRepository.php', -]; $ignoreErrors[] = [ 'message' => '#^Cannot cast mixed to int\\.$#', 'identifier' => 'cast.int', @@ -560,8 +440,8 @@ 'path' => __DIR__ . '/sources/AppBundle/Accounting/TransactionModification.php', ]; $ignoreErrors[] = [ - 'message' => '#^Parameter \\#1 \\$comment of method AppBundle\\\\Accounting\\\\Model\\\\Transaction\\:\\:setComment\\(\\) expects string\\|null, mixed given\\.$#', - 'identifier' => 'argument.type', + 'message' => '#^Property AppBundle\\\\Accounting\\\\Entity\\\\Transaction\\:\\:\\$commentaire \\(string\\|null\\) does not accept mixed\\.$#', + 'identifier' => 'assign.propertyType', 'count' => 1, 'path' => __DIR__ . '/sources/AppBundle/Accounting/TransactionModification.php', ]; @@ -2270,74 +2150,50 @@ 'path' => __DIR__ . '/sources/AppBundle/Command/VideosDataCommand.php', ]; $ignoreErrors[] = [ - 'message' => '#^Parameter \\#1 \\$amount of method AppBundle\\\\Accounting\\\\Model\\\\Transaction\\:\\:setAmount\\(\\) expects float, mixed given\\.$#', - 'identifier' => 'argument.type', - 'count' => 1, - 'path' => __DIR__ . '/sources/AppBundle/Compta/CsvExtractor.php', -]; -$ignoreErrors[] = [ - 'message' => '#^Parameter \\#1 \\$amountTva0 of method AppBundle\\\\Accounting\\\\Model\\\\Transaction\\:\\:setAmountTva0\\(\\) expects float\\|null, mixed given\\.$#', - 'identifier' => 'argument.type', - 'count' => 1, - 'path' => __DIR__ . '/sources/AppBundle/Compta/CsvExtractor.php', -]; -$ignoreErrors[] = [ - 'message' => '#^Parameter \\#1 \\$amountTva10 of method AppBundle\\\\Accounting\\\\Model\\\\Transaction\\:\\:setAmountTva10\\(\\) expects float\\|null, mixed given\\.$#', - 'identifier' => 'argument.type', - 'count' => 1, - 'path' => __DIR__ . '/sources/AppBundle/Compta/CsvExtractor.php', -]; -$ignoreErrors[] = [ - 'message' => '#^Parameter \\#1 \\$amountTva20 of method AppBundle\\\\Accounting\\\\Model\\\\Transaction\\:\\:setAmountTva20\\(\\) expects float\\|null, mixed given\\.$#', + 'message' => '#^Parameter \\#1 \\$datetime of class DateTime constructor expects string, mixed given\\.$#', 'identifier' => 'argument.type', 'count' => 1, 'path' => __DIR__ . '/sources/AppBundle/Compta/CsvExtractor.php', ]; $ignoreErrors[] = [ - 'message' => '#^Parameter \\#1 \\$amountTva5_5 of method AppBundle\\\\Accounting\\\\Model\\\\Transaction\\:\\:setAmountTva55\\(\\) expects float\\|null, mixed given\\.$#', - 'identifier' => 'argument.type', + 'message' => '#^Property AppBundle\\\\Accounting\\\\Entity\\\\Transaction\\:\\:\\$description \\(string\\) does not accept mixed\\.$#', + 'identifier' => 'assign.propertyType', 'count' => 1, 'path' => __DIR__ . '/sources/AppBundle/Compta/CsvExtractor.php', ]; $ignoreErrors[] = [ - 'message' => '#^Parameter \\#1 \\$attachmentRequired of method AppBundle\\\\Accounting\\\\Model\\\\Transaction\\:\\:setAttachmentRequired\\(\\) expects bool, mixed given\\.$#', - 'identifier' => 'argument.type', - 'count' => 2, - 'path' => __DIR__ . '/sources/AppBundle/Compta/CsvExtractor.php', -]; -$ignoreErrors[] = [ - 'message' => '#^Parameter \\#1 \\$categoryId of method AppBundle\\\\Accounting\\\\Model\\\\Transaction\\:\\:setCategoryId\\(\\) expects int\\|null, mixed given\\.$#', - 'identifier' => 'argument.type', + 'message' => '#^Property AppBundle\\\\Accounting\\\\Entity\\\\Transaction\\:\\:\\$justificatifRequis \\(bool\\) does not accept mixed\\.$#', + 'identifier' => 'assign.propertyType', 'count' => 2, 'path' => __DIR__ . '/sources/AppBundle/Compta/CsvExtractor.php', ]; $ignoreErrors[] = [ - 'message' => '#^Parameter \\#1 \\$datetime of class DateTime constructor expects string, mixed given\\.$#', - 'identifier' => 'argument.type', + 'message' => '#^Property AppBundle\\\\Accounting\\\\Entity\\\\Transaction\\:\\:\\$montant \\(float\\) does not accept mixed\\.$#', + 'identifier' => 'assign.propertyType', 'count' => 1, 'path' => __DIR__ . '/sources/AppBundle/Compta/CsvExtractor.php', ]; $ignoreErrors[] = [ - 'message' => '#^Parameter \\#1 \\$description of method AppBundle\\\\Accounting\\\\Model\\\\Transaction\\:\\:setDescription\\(\\) expects string, mixed given\\.$#', - 'identifier' => 'argument.type', + 'message' => '#^Property AppBundle\\\\Accounting\\\\Entity\\\\Transaction\\:\\:\\$montantTva0 \\(float\\|null\\) does not accept mixed\\.$#', + 'identifier' => 'assign.propertyType', 'count' => 1, 'path' => __DIR__ . '/sources/AppBundle/Compta/CsvExtractor.php', ]; $ignoreErrors[] = [ - 'message' => '#^Parameter \\#1 \\$eventId of method AppBundle\\\\Accounting\\\\Model\\\\Transaction\\:\\:setEventId\\(\\) expects int\\|null, mixed given\\.$#', - 'identifier' => 'argument.type', - 'count' => 2, + 'message' => '#^Property AppBundle\\\\Accounting\\\\Entity\\\\Transaction\\:\\:\\$montantTva10 \\(float\\|null\\) does not accept mixed\\.$#', + 'identifier' => 'assign.propertyType', + 'count' => 1, 'path' => __DIR__ . '/sources/AppBundle/Compta/CsvExtractor.php', ]; $ignoreErrors[] = [ - 'message' => '#^Parameter \\#1 \\$operationId of method AppBundle\\\\Accounting\\\\Model\\\\Transaction\\:\\:setOperationId\\(\\) expects int\\|null, mixed given\\.$#', - 'identifier' => 'argument.type', + 'message' => '#^Property AppBundle\\\\Accounting\\\\Entity\\\\Transaction\\:\\:\\$montantTva20 \\(float\\|null\\) does not accept mixed\\.$#', + 'identifier' => 'assign.propertyType', 'count' => 1, 'path' => __DIR__ . '/sources/AppBundle/Compta/CsvExtractor.php', ]; $ignoreErrors[] = [ - 'message' => '#^Parameter \\#1 \\$paymentTypeId of method AppBundle\\\\Accounting\\\\Model\\\\Transaction\\:\\:setPaymentTypeId\\(\\) expects int\\|null, mixed given\\.$#', - 'identifier' => 'argument.type', + 'message' => '#^Property AppBundle\\\\Accounting\\\\Entity\\\\Transaction\\:\\:\\$montantTva5_5 \\(float\\|null\\) does not accept mixed\\.$#', + 'identifier' => 'assign.propertyType', 'count' => 1, 'path' => __DIR__ . '/sources/AppBundle/Compta/CsvExtractor.php', ]; @@ -2462,7 +2318,7 @@ 'path' => __DIR__ . '/sources/AppBundle/Controller/Admin/Accounting/Configuration/EditRuleAction.php', ]; $ignoreErrors[] = [ - 'message' => '#^Parameter \\#1 \\$number of method AppBundle\\\\Accounting\\\\Model\\\\Repository\\\\InvoicingRepository\\:\\:getOneByInvoiceNumber\\(\\) expects string, string\\|null given\\.$#', + 'message' => '#^Parameter \\#1 \\$number of method AppBundle\\\\Accounting\\\\Entity\\\\Repository\\\\InvoicingRepository\\:\\:getOneByInvoiceNumber\\(\\) expects string, string\\|null given\\.$#', 'identifier' => 'argument.type', 'count' => 1, 'path' => __DIR__ . '/sources/AppBundle/Controller/Admin/Accounting/Invoice/DownloadInvoiceAction.php', @@ -2474,95 +2330,11 @@ 'path' => __DIR__ . '/sources/AppBundle/Controller/Admin/Accounting/Invoice/ListInvoiceAction.php', ]; $ignoreErrors[] = [ - 'message' => '#^Parameter \\#1 \\$number of method AppBundle\\\\Accounting\\\\Model\\\\Repository\\\\InvoicingRepository\\:\\:getOneByInvoiceNumber\\(\\) expects string, string\\|null given\\.$#', + 'message' => '#^Parameter \\#1 \\$number of method AppBundle\\\\Accounting\\\\Entity\\\\Repository\\\\InvoicingRepository\\:\\:getOneByInvoiceNumber\\(\\) expects string, string\\|null given\\.$#', 'identifier' => 'argument.type', 'count' => 1, 'path' => __DIR__ . '/sources/AppBundle/Controller/Admin/Accounting/Invoice/SendInvoiceEmailAction.php', ]; -$ignoreErrors[] = [ - 'message' => '#^Cannot call method getAccountId\\(\\) on AppBundle\\\\Accounting\\\\Model\\\\Transaction\\|null\\.$#', - 'identifier' => 'method.nonObject', - 'count' => 1, - 'path' => __DIR__ . '/sources/AppBundle/Controller/Admin/Accounting/Journal/AllocateAction.php', -]; -$ignoreErrors[] = [ - 'message' => '#^Cannot call method getAccountingDate\\(\\) on AppBundle\\\\Accounting\\\\Model\\\\Transaction\\|null\\.$#', - 'identifier' => 'method.nonObject', - 'count' => 1, - 'path' => __DIR__ . '/sources/AppBundle/Controller/Admin/Accounting/Journal/AllocateAction.php', -]; -$ignoreErrors[] = [ - 'message' => '#^Cannot call method getAmount\\(\\) on AppBundle\\\\Accounting\\\\Model\\\\Transaction\\|null\\.$#', - 'identifier' => 'method.nonObject', - 'count' => 1, - 'path' => __DIR__ . '/sources/AppBundle/Controller/Admin/Accounting/Journal/AllocateAction.php', -]; -$ignoreErrors[] = [ - 'message' => '#^Cannot call method getComment\\(\\) on AppBundle\\\\Accounting\\\\Model\\\\Transaction\\|null\\.$#', - 'identifier' => 'method.nonObject', - 'count' => 1, - 'path' => __DIR__ . '/sources/AppBundle/Controller/Admin/Accounting/Journal/AllocateAction.php', -]; -$ignoreErrors[] = [ - 'message' => '#^Cannot call method getDescription\\(\\) on AppBundle\\\\Accounting\\\\Model\\\\Transaction\\|null\\.$#', - 'identifier' => 'method.nonObject', - 'count' => 1, - 'path' => __DIR__ . '/sources/AppBundle/Controller/Admin/Accounting/Journal/AllocateAction.php', -]; -$ignoreErrors[] = [ - 'message' => '#^Cannot call method getNumber\\(\\) on AppBundle\\\\Accounting\\\\Model\\\\Transaction\\|null\\.$#', - 'identifier' => 'method.nonObject', - 'count' => 1, - 'path' => __DIR__ . '/sources/AppBundle/Controller/Admin/Accounting/Journal/AllocateAction.php', -]; -$ignoreErrors[] = [ - 'message' => '#^Cannot call method getOperationId\\(\\) on AppBundle\\\\Accounting\\\\Model\\\\Transaction\\|null\\.$#', - 'identifier' => 'method.nonObject', - 'count' => 1, - 'path' => __DIR__ . '/sources/AppBundle/Controller/Admin/Accounting/Journal/AllocateAction.php', -]; -$ignoreErrors[] = [ - 'message' => '#^Cannot call method getOperationNumber\\(\\) on AppBundle\\\\Accounting\\\\Model\\\\Transaction\\|null\\.$#', - 'identifier' => 'method.nonObject', - 'count' => 1, - 'path' => __DIR__ . '/sources/AppBundle/Controller/Admin/Accounting/Journal/AllocateAction.php', -]; -$ignoreErrors[] = [ - 'message' => '#^Cannot call method getPaymentDate\\(\\) on AppBundle\\\\Accounting\\\\Model\\\\Transaction\\|null\\.$#', - 'identifier' => 'method.nonObject', - 'count' => 1, - 'path' => __DIR__ . '/sources/AppBundle/Controller/Admin/Accounting/Journal/AllocateAction.php', -]; -$ignoreErrors[] = [ - 'message' => '#^Cannot call method getPaymentTypeId\\(\\) on AppBundle\\\\Accounting\\\\Model\\\\Transaction\\|null\\.$#', - 'identifier' => 'method.nonObject', - 'count' => 1, - 'path' => __DIR__ . '/sources/AppBundle/Controller/Admin/Accounting/Journal/AllocateAction.php', -]; -$ignoreErrors[] = [ - 'message' => '#^Cannot call method getTvaIntra\\(\\) on AppBundle\\\\Accounting\\\\Model\\\\Transaction\\|null\\.$#', - 'identifier' => 'method.nonObject', - 'count' => 1, - 'path' => __DIR__ . '/sources/AppBundle/Controller/Admin/Accounting/Journal/AllocateAction.php', -]; -$ignoreErrors[] = [ - 'message' => '#^Cannot call method getVendorName\\(\\) on AppBundle\\\\Accounting\\\\Model\\\\Transaction\\|null\\.$#', - 'identifier' => 'method.nonObject', - 'count' => 1, - 'path' => __DIR__ . '/sources/AppBundle/Controller/Admin/Accounting/Journal/AllocateAction.php', -]; -$ignoreErrors[] = [ - 'message' => '#^Cannot call method setAmount\\(\\) on AppBundle\\\\Accounting\\\\Model\\\\Transaction\\|null\\.$#', - 'identifier' => 'method.nonObject', - 'count' => 1, - 'path' => __DIR__ . '/sources/AppBundle/Controller/Admin/Accounting/Journal/AllocateAction.php', -]; -$ignoreErrors[] = [ - 'message' => '#^Parameter \\#1 \\$entity of method CCMBenchmark\\\\Ting\\\\Repository\\\\Repository\\\\:\\:save\\(\\) expects AppBundle\\\\Accounting\\\\Model\\\\Transaction, AppBundle\\\\Accounting\\\\Model\\\\Transaction\\|null given\\.$#', - 'identifier' => 'argument.type', - 'count' => 1, - 'path' => __DIR__ . '/sources/AppBundle/Controller/Admin/Accounting/Journal/AllocateAction.php', -]; $ignoreErrors[] = [ 'message' => '#^Cannot call method format\\(\\) on DateTime\\|null\\.$#', 'identifier' => 'method.nonObject', @@ -2582,149 +2354,17 @@ 'path' => __DIR__ . '/sources/AppBundle/Controller/Admin/Accounting/Journal/DownloadAttachmentsAction.php', ]; $ignoreErrors[] = [ - 'message' => '#^Cannot call method getId\\(\\) on AppBundle\\\\Accounting\\\\Model\\\\Transaction\\|null\\.$#', - 'identifier' => 'method.nonObject', + 'message' => '#^Cannot access property \\$id on AppBundle\\\\Accounting\\\\Entity\\\\Transaction\\|null\\.$#', + 'identifier' => 'property.nonObject', 'count' => 2, 'path' => __DIR__ . '/sources/AppBundle/Controller/Admin/Accounting/Journal/EditTransactionAction.php', ]; $ignoreErrors[] = [ - 'message' => '#^Parameter \\#1 \\$transactionId of method AppBundle\\\\Accounting\\\\Model\\\\Repository\\\\TransactionRepository\\:\\:getNextTransaction\\(\\) expects int, int\\|null given\\.$#', + 'message' => '#^Parameter \\#1 \\$transactionId of method AppBundle\\\\Accounting\\\\Entity\\\\Repository\\\\TransactionRepository\\:\\:getNextTransaction\\(\\) expects int, int\\|null given\\.$#', 'identifier' => 'argument.type', 'count' => 1, 'path' => __DIR__ . '/sources/AppBundle/Controller/Admin/Accounting/Journal/EditTransactionAction.php', ]; -$ignoreErrors[] = [ - 'message' => '#^Argument of an invalid type mixed supplied for foreach, only iterables are supported\\.$#', - 'identifier' => 'foreach.nonIterable', - 'count' => 1, - 'path' => __DIR__ . '/sources/AppBundle/Controller/Admin/Accounting/Journal/ExportAction.php', -]; -$ignoreErrors[] = [ - 'message' => '#^Cannot access offset \'attachment_filename\' on mixed\\.$#', - 'identifier' => 'offsetAccess.nonOffsetAccessible', - 'count' => 1, - 'path' => __DIR__ . '/sources/AppBundle/Controller/Admin/Accounting/Journal/ExportAction.php', -]; -$ignoreErrors[] = [ - 'message' => '#^Cannot access offset \'attachment_required\' on mixed\\.$#', - 'identifier' => 'offsetAccess.nonOffsetAccessible', - 'count' => 1, - 'path' => __DIR__ . '/sources/AppBundle/Controller/Admin/Accounting/Journal/ExportAction.php', -]; -$ignoreErrors[] = [ - 'message' => '#^Cannot access offset \'categorie\' on mixed\\.$#', - 'identifier' => 'offsetAccess.nonOffsetAccessible', - 'count' => 1, - 'path' => __DIR__ . '/sources/AppBundle/Controller/Admin/Accounting/Journal/ExportAction.php', -]; -$ignoreErrors[] = [ - 'message' => '#^Cannot access offset \'comment\' on mixed\\.$#', - 'identifier' => 'offsetAccess.nonOffsetAccessible', - 'count' => 1, - 'path' => __DIR__ . '/sources/AppBundle/Controller/Admin/Accounting/Journal/ExportAction.php', -]; -$ignoreErrors[] = [ - 'message' => '#^Cannot access offset \'date_ecriture\' on mixed\\.$#', - 'identifier' => 'offsetAccess.nonOffsetAccessible', - 'count' => 1, - 'path' => __DIR__ . '/sources/AppBundle/Controller/Admin/Accounting/Journal/ExportAction.php', -]; -$ignoreErrors[] = [ - 'message' => '#^Cannot access offset \'description\' on mixed\\.$#', - 'identifier' => 'offsetAccess.nonOffsetAccessible', - 'count' => 1, - 'path' => __DIR__ . '/sources/AppBundle/Controller/Admin/Accounting/Journal/ExportAction.php', -]; -$ignoreErrors[] = [ - 'message' => '#^Cannot access offset \'evenement\' on mixed\\.$#', - 'identifier' => 'offsetAccess.nonOffsetAccessible', - 'count' => 1, - 'path' => __DIR__ . '/sources/AppBundle/Controller/Admin/Accounting/Journal/ExportAction.php', -]; -$ignoreErrors[] = [ - 'message' => '#^Cannot access offset \'idoperation\' on mixed\\.$#', - 'identifier' => 'offsetAccess.nonOffsetAccessible', - 'count' => 2, - 'path' => __DIR__ . '/sources/AppBundle/Controller/Admin/Accounting/Journal/ExportAction.php', -]; -$ignoreErrors[] = [ - 'message' => '#^Cannot access offset \'montant\' on mixed\\.$#', - 'identifier' => 'offsetAccess.nonOffsetAccessible', - 'count' => 1, - 'path' => __DIR__ . '/sources/AppBundle/Controller/Admin/Accounting/Journal/ExportAction.php', -]; -$ignoreErrors[] = [ - 'message' => '#^Cannot access offset \'montant_ht\' on mixed\\.$#', - 'identifier' => 'offsetAccess.nonOffsetAccessible', - 'count' => 1, - 'path' => __DIR__ . '/sources/AppBundle/Controller/Admin/Accounting/Journal/ExportAction.php', -]; -$ignoreErrors[] = [ - 'message' => '#^Cannot access offset \'montant_ht_0\' on mixed\\.$#', - 'identifier' => 'offsetAccess.nonOffsetAccessible', - 'count' => 1, - 'path' => __DIR__ . '/sources/AppBundle/Controller/Admin/Accounting/Journal/ExportAction.php', -]; -$ignoreErrors[] = [ - 'message' => '#^Cannot access offset \'montant_ht_10\' on mixed\\.$#', - 'identifier' => 'offsetAccess.nonOffsetAccessible', - 'count' => 1, - 'path' => __DIR__ . '/sources/AppBundle/Controller/Admin/Accounting/Journal/ExportAction.php', -]; -$ignoreErrors[] = [ - 'message' => '#^Cannot access offset \'montant_ht_20\' on mixed\\.$#', - 'identifier' => 'offsetAccess.nonOffsetAccessible', - 'count' => 1, - 'path' => __DIR__ . '/sources/AppBundle/Controller/Admin/Accounting/Journal/ExportAction.php', -]; -$ignoreErrors[] = [ - 'message' => '#^Cannot access offset \'montant_ht_5_5\' on mixed\\.$#', - 'identifier' => 'offsetAccess.nonOffsetAccessible', - 'count' => 1, - 'path' => __DIR__ . '/sources/AppBundle/Controller/Admin/Accounting/Journal/ExportAction.php', -]; -$ignoreErrors[] = [ - 'message' => '#^Cannot access offset \'montant_tva\' on mixed\\.$#', - 'identifier' => 'offsetAccess.nonOffsetAccessible', - 'count' => 1, - 'path' => __DIR__ . '/sources/AppBundle/Controller/Admin/Accounting/Journal/ExportAction.php', -]; -$ignoreErrors[] = [ - 'message' => '#^Cannot access offset \'montant_tva_10\' on mixed\\.$#', - 'identifier' => 'offsetAccess.nonOffsetAccessible', - 'count' => 1, - 'path' => __DIR__ . '/sources/AppBundle/Controller/Admin/Accounting/Journal/ExportAction.php', -]; -$ignoreErrors[] = [ - 'message' => '#^Cannot access offset \'montant_tva_20\' on mixed\\.$#', - 'identifier' => 'offsetAccess.nonOffsetAccessible', - 'count' => 1, - 'path' => __DIR__ . '/sources/AppBundle/Controller/Admin/Accounting/Journal/ExportAction.php', -]; -$ignoreErrors[] = [ - 'message' => '#^Cannot access offset \'montant_tva_5_5\' on mixed\\.$#', - 'identifier' => 'offsetAccess.nonOffsetAccessible', - 'count' => 1, - 'path' => __DIR__ . '/sources/AppBundle/Controller/Admin/Accounting/Journal/ExportAction.php', -]; -$ignoreErrors[] = [ - 'message' => '#^Cannot access offset \'nom_compte\' on mixed\\.$#', - 'identifier' => 'offsetAccess.nonOffsetAccessible', - 'count' => 1, - 'path' => __DIR__ . '/sources/AppBundle/Controller/Admin/Accounting/Journal/ExportAction.php', -]; -$ignoreErrors[] = [ - 'message' => '#^Cannot access offset \'reglement\' on mixed\\.$#', - 'identifier' => 'offsetAccess.nonOffsetAccessible', - 'count' => 1, - 'path' => __DIR__ . '/sources/AppBundle/Controller/Admin/Accounting/Journal/ExportAction.php', -]; -$ignoreErrors[] = [ - 'message' => '#^Cannot access offset \'tva_zone\' on mixed\\.$#', - 'identifier' => 'offsetAccess.nonOffsetAccessible', - 'count' => 1, - 'path' => __DIR__ . '/sources/AppBundle/Controller/Admin/Accounting/Journal/ExportAction.php', -]; $ignoreErrors[] = [ 'message' => '#^Cannot call method format\\(\\) on DateTime\\|null\\.$#', 'identifier' => 'method.nonObject', @@ -2840,29 +2480,11 @@ 'path' => __DIR__ . '/sources/AppBundle/Controller/Admin/Accounting/MembershipFee/EditMembershipFeeAction.php', ]; $ignoreErrors[] = [ - 'message' => '#^Parameter \\#1 \\$number of method AppBundle\\\\Accounting\\\\Model\\\\Repository\\\\InvoicingRepository\\:\\:getOneByQuotationNumber\\(\\) expects string, string\\|null given\\.$#', + 'message' => '#^Parameter \\#1 \\$number of method AppBundle\\\\Accounting\\\\Entity\\\\Repository\\\\InvoicingRepository\\:\\:getOneByQuotationNumber\\(\\) expects string, string\\|null given\\.$#', 'identifier' => 'argument.type', 'count' => 1, 'path' => __DIR__ . '/sources/AppBundle/Controller/Admin/Accounting/Quotation/DownloadQuotationAction.php', ]; -$ignoreErrors[] = [ - 'message' => '#^Parameter \\#1 \\$array of function array_diff expects an array of values castable to string, array given\\.$#', - 'identifier' => 'argument.type', - 'count' => 1, - 'path' => __DIR__ . '/sources/AppBundle/Controller/Admin/Accounting/Quotation/EditQuotationAction.php', -]; -$ignoreErrors[] = [ - 'message' => '#^Parameter \\#1 \\$ids of method AppBundle\\\\Accounting\\\\Model\\\\Repository\\\\InvoicingDetailRepository\\:\\:removeRowsPerIds\\(\\) expects array\\, array given\\.$#', - 'identifier' => 'argument.type', - 'count' => 1, - 'path' => __DIR__ . '/sources/AppBundle/Controller/Admin/Accounting/Quotation/EditQuotationAction.php', -]; -$ignoreErrors[] = [ - 'message' => '#^Parameter \\#1 \\$invoicingId of method AppBundle\\\\Accounting\\\\Model\\\\Repository\\\\InvoicingDetailRepository\\:\\:getRowsIdsPerInvoicingId\\(\\) expects int, int\\|null given\\.$#', - 'identifier' => 'argument.type', - 'count' => 1, - 'path' => __DIR__ . '/sources/AppBundle/Controller/Admin/Accounting/Quotation/EditQuotationAction.php', -]; $ignoreErrors[] = [ 'message' => '#^Parameter \\#1 \\$date of static method Afup\\\\Site\\\\Utils\\\\Vat\\:\\:isSubjectedToVat\\(\\) expects DateTimeInterface, DateTime\\|null given\\.$#', 'identifier' => 'argument.type', diff --git a/sources/AppBundle/Accounting/Entity/Invoicing.php b/sources/AppBundle/Accounting/Entity/Invoicing.php new file mode 100644 index 000000000..952fd7463 --- /dev/null +++ b/sources/AppBundle/Accounting/Entity/Invoicing.php @@ -0,0 +1,118 @@ + */ + #[Assert\Valid] + #[ORM\OneToMany(targetEntity: InvoicingDetail::class, mappedBy: 'facture', cascade: ['persist', 'remove'], orphanRemoval: true)] + public Collection $details; + + // Non persistee - total calcule depuis les lignes de detail, alimente par les requetes de listing + public ?float $prix = null; + + public function __construct() + { + $this->details = new ArrayCollection(); + } + + public function addDetail(InvoicingDetail $detail): void + { + $this->details->add($detail); + $detail->facture = $this; + } + + public function getPaymentUrlRef(): string + { + if (empty($this->numeroFacture)) { + return ''; + } + + return urlencode(Utils::cryptFromText($this->id)); + } +} diff --git a/sources/AppBundle/Accounting/Entity/InvoicingDetail.php b/sources/AppBundle/Accounting/Entity/InvoicingDetail.php new file mode 100644 index 000000000..22c7a6660 --- /dev/null +++ b/sources/AppBundle/Accounting/Entity/InvoicingDetail.php @@ -0,0 +1,44 @@ + + */ +final class InvoicingPeriodRepository extends EntityRepository +{ + public function __construct(ManagerRegistry $registry) + { + parent::__construct($registry, InvoicingPeriod::class); + } + + public function getCurrentPeriod(?int $periodId = null): InvoicingPeriod + { + if ($periodId !== null) { + return $this->find($periodId); + } + + $startDate = new \DateTime(date('Y') . '-01-01'); + $endDate = new \DateTime(date('Y') . '-12-31'); + $period = $this->findOneBy([ + 'dateDebut' => $startDate, + 'dateFin' => $endDate, + ]); + + if (!$period instanceof InvoicingPeriod) { + $period = new InvoicingPeriod(); + $period->dateDebut = $startDate; + $period->dateFin = $endDate; + $this->save($period); + } + + return $period; + } +} diff --git a/sources/AppBundle/Accounting/Entity/Repository/InvoicingRepository.php b/sources/AppBundle/Accounting/Entity/Repository/InvoicingRepository.php new file mode 100644 index 000000000..ca5574973 --- /dev/null +++ b/sources/AppBundle/Accounting/Entity/Repository/InvoicingRepository.php @@ -0,0 +1,127 @@ + + */ +final class InvoicingRepository extends EntityRepository +{ + public function __construct( + ManagerRegistry $registry, + private readonly InvoicingPeriodRepository $invoicingPeriodRepository, + ) { + parent::__construct($registry, Invoicing::class); + } + + public function getById(int $id): ?Invoicing + { + return $this->find($id); + } + + public function getOneByInvoiceNumber(string $number): ?Invoicing + { + return $this->findOneBy(['numeroFacture' => $number]); + } + + public function getOneByQuotationNumber(string $number): ?Invoicing + { + return $this->findOneBy(['numeroDevis' => $number]); + } + + /** + * @return array + */ + public function getQuotationsByPeriodId(?int $periodId = null, string $sort = 'date', string $direction = 'desc'): array + { + $field = $sort === 'client' ? 'i.societe' : 'i.dateDevis'; + + $qb = $this->createQueryBuilder('i') + ->addSelect('SUM(d.quantite * d.prixUnitaire) as prix') + ->leftJoin('i.details', 'd') + ->where("i.numeroDevis != ''") + ->groupBy('i.id') + ->orderBy($field, $direction); + + if ($periodId !== null && $periodId !== 0) { + $period = $this->invoicingPeriodRepository->find($periodId); + $qb->andWhere('i.dateDevis >= :periodStart') + ->andWhere('i.dateDevis <= :periodEnd') + ->setParameter('periodStart', $period->dateDebut) + ->setParameter('periodEnd', $period->dateFin); + } + + return $this->mapRowsToInvoicings($qb->getQuery()->getResult()); + } + + /** + * @return array + */ + public function getInvoicesByPeriodId(?int $periodId = null, string $sort = 'date', string $direction = 'desc'): array + { + $field = $sort === 'client' ? 'i.societe' : 'i.dateFacture'; + + $qb = $this->createQueryBuilder('i') + ->addSelect('SUM(d.quantite * d.prixUnitaire) as prix') + ->leftJoin('i.details', 'd') + ->where("i.numeroFacture != ''") + ->groupBy('i.id') + ->orderBy($field, $direction); + + if ($periodId !== null && $periodId !== 0) { + $period = $this->invoicingPeriodRepository->find($periodId); + $qb->andWhere('i.dateFacture >= :periodStart') + ->andWhere('i.dateFacture <= :periodEnd') + ->setParameter('periodStart', $period->dateDebut) + ->setParameter('periodEnd', $period->dateFin); + } + + return $this->mapRowsToInvoicings($qb->getQuery()->getResult()); + } + + public function getNextInvoiceIndex(int $year): ?int + { + $result = $this->getEntityManager()->getConnection()->executeQuery( + "SELECT MAX(CAST(SUBSTRING_INDEX(numero_facture, '-', -1) AS UNSIGNED)) + 1 AS next_index FROM afup_compta_facture WHERE LEFT(numero_facture, 4) = :year", + ['year' => (string) $year], + )->fetchOne(); + + return $result !== null ? (int) $result : null; + } + + public function getNextQuotationIndex(int $year): ?int + { + $result = $this->getEntityManager()->getConnection()->executeQuery( + "SELECT MAX(CAST(SUBSTRING_INDEX(numero_devis, '-', -1) AS UNSIGNED)) + 1 AS next_index FROM afup_compta_facture WHERE LEFT(numero_devis, 4) = :year", + ['year' => (string) $year], + )->fetchOne(); + + return $result !== null ? (int) $result : null; + } + + public function convertQuotationToInvoice(Invoicing $quotation, string $invoiceNumber): void + { + $quotation->numeroFacture = $invoiceNumber; + $quotation->dateFacture = new \DateTime(); + $this->save($quotation); + } + + /** + * @param array $rows + * @return array + */ + private function mapRowsToInvoicings(array $rows): array + { + return array_map(static function (array $row): Invoicing { + $row[0]->prix = (float) $row['prix']; + + return $row[0]; + }, $rows); + } +} diff --git a/sources/AppBundle/Accounting/Entity/Repository/TransactionRepository.php b/sources/AppBundle/Accounting/Entity/Repository/TransactionRepository.php new file mode 100644 index 000000000..3c5f4724c --- /dev/null +++ b/sources/AppBundle/Accounting/Entity/Repository/TransactionRepository.php @@ -0,0 +1,99 @@ + + */ +final class TransactionRepository extends EntityRepository +{ + public function __construct(ManagerRegistry $registry) + { + parent::__construct($registry, Transaction::class); + } + + public function getNextTransaction(int $transactionId): ?Transaction + { + $undeterminedCategory = $this->getEntityManager()->getReference(Category::class, AutoQualifier::DEFAULT_CATEGORIE); + $undeterminedEvent = $this->getEntityManager()->getReference(Event::class, AutoQualifier::DEFAULT_EVENEMENT); + + return $this->createQueryBuilder('t') + ->where('t.categorie = :undeterminedCategory OR t.evenement = :undeterminedEvent') + ->andWhere('t.id > :transactionId') + ->setParameter('undeterminedCategory', $undeterminedCategory) + ->setParameter('undeterminedEvent', $undeterminedEvent) + ->setParameter('transactionId', $transactionId) + ->orderBy('t.id', 'ASC') + ->setMaxResults(1) + ->getQuery() + ->getOneOrNullResult(); + } + + /** + * @return array> + */ + public function getEntriesPerInvoicingPeriod(InvoicingPeriod $period, bool $onlyUnclasifedEntries, int $operationType = 0): array + { + $filtre = $operationType === 1 || $operationType === 2 ? ' AND compta.idoperation = :operationType ' : ''; + + $sql = 'SELECT ' + . 'compta.date_ecriture, compta.description, compta.montant, compta.idoperation, compta.id as idtmp, ' + . 'compta.comment, compta.attachment_required, compta.attachment_filename, ' + . 'compta_reglement.reglement, ' + . 'compta_evenement.evenement, ' + . 'compta_categorie.categorie, ' + . 'compta_compte.nom_compte, ' + . '(COALESCE(compta.montant_ht_soumis_tva_0,0) + COALESCE(compta.montant_ht_soumis_tva_5_5,0) + COALESCE(compta.montant_ht_soumis_tva_10, 0) + COALESCE(compta.montant_ht_soumis_tva_20, 0)) as montant_ht, ' + . '((COALESCE(compta.montant_ht_soumis_tva_5_5, 0)*0.055) + (COALESCE(compta.montant_ht_soumis_tva_10, 0)*0.1) + (COALESCE(compta.montant_ht_soumis_tva_20, 0)*0.2)) as montant_tva, ' + . 'compta.montant_ht_soumis_tva_0 as montant_ht_0, ' + . 'compta.montant_ht_soumis_tva_5_5 as montant_ht_5_5, ' + . 'compta.montant_ht_soumis_tva_5_5*0.055 as montant_tva_5_5, ' + . 'compta.montant_ht_soumis_tva_10 as montant_ht_10, ' + . 'compta.montant_ht_soumis_tva_10*0.1 as montant_tva_10, ' + . 'compta.montant_ht_soumis_tva_20 as montant_ht_20, ' + . 'compta.montant_ht_soumis_tva_20*0.2 as montant_tva_20, ' + . 'compta.tva_zone ' + . 'FROM compta ' + . 'LEFT JOIN compta_categorie on compta_categorie.id = compta.idcategorie ' + . 'LEFT JOIN compta_reglement on compta_reglement.id = compta.idmode_regl ' + . 'LEFT JOIN compta_evenement on compta_evenement.id = compta.idevenement ' + . 'LEFT JOIN compta_compte on compta_compte.id = compta.idcompte ' + . 'WHERE compta.date_ecriture >= :startDate ' + . 'AND compta.date_ecriture <= :endDate ' + . $filtre; + + if ($onlyUnclasifedEntries === true) { + $sql .= ' AND ( + compta_evenement.evenement = "A déterminer" + OR + compta_categorie.categorie = "A déterminer" + OR + compta_reglement.reglement = "A déterminer" + OR + (compta.attachment_required = 1 AND compta.attachment_filename IS NULL) + ) '; + } + + $sql .= 'ORDER BY compta.date_ecriture, numero_operation'; + + $params = [ + 'startDate' => $period->dateDebut->format('Y-m-d'), + 'endDate' => $period->dateFin->format('Y-m-d'), + ]; + if ($filtre !== '') { + $params['operationType'] = $operationType; + } + + return $this->getEntityManager()->getConnection()->executeQuery($sql, $params)->fetchAllAssociative(); + } +} diff --git a/sources/AppBundle/Accounting/Entity/Transaction.php b/sources/AppBundle/Accounting/Entity/Transaction.php new file mode 100644 index 000000000..c89f56e85 --- /dev/null +++ b/sources/AppBundle/Accounting/Entity/Transaction.php @@ -0,0 +1,99 @@ +dateEcriture = new \DateTime(); + $this->dateReglement = new \DateTime(); + } +} diff --git a/sources/AppBundle/Accounting/Form/InvoiceType.php b/sources/AppBundle/Accounting/Form/InvoiceType.php index c31316a6b..f7dc057f5 100644 --- a/sources/AppBundle/Accounting/Form/InvoiceType.php +++ b/sources/AppBundle/Accounting/Form/InvoiceType.php @@ -24,10 +24,10 @@ public function __construct(private readonly Pays $pays) {} public function buildForm(FormBuilderInterface $builder, array $options): void { - $builder->add('invoiceDate', DateType::class, [ + $builder->add('dateFacture', DateType::class, [ 'label' => 'Date facture', 'widget' => 'single_text', - ])->add('company', TextType::class, [ + ])->add('societe', TextType::class, [ 'label' => 'Société', 'constraints' => [ new Assert\NotBlank(), @@ -40,38 +40,38 @@ public function buildForm(FormBuilderInterface $builder, array $options): void 'constraints' => [ new Assert\Length(max: 50), ], - ])->add('address', TextareaType::class, [ + ])->add('adresse', TextareaType::class, [ 'label' => 'Adresse', - ])->add('zipcode', TextType::class, [ + ])->add('codePostal', TextType::class, [ 'label' => 'Code postal', 'constraints' => [ new Assert\NotBlank(), new Assert\Length(max: 10), ], - ])->add('city', TextType::class, [ + ])->add('ville', TextType::class, [ 'label' => 'Ville', 'constraints' => [ new Assert\NotBlank(), new Assert\Length(max: 50), ], - ])->add('countryId', ChoiceType::class, [ + ])->add('idPays', ChoiceType::class, [ 'label' => 'Pays', 'choices' => array_flip($this->pays->obtenirPays()), - ])->add('lastname', TextType::class, [ + ])->add('nom', TextType::class, [ 'label' => 'Nom', 'required' => false, 'empty_data' => '', 'constraints' => [ new Assert\Length(max: 50), ], - ])->add('firstname', TextType::class, [ + ])->add('prenom', TextType::class, [ 'label' => 'Prénom', 'required' => false, 'empty_data' => '', 'constraints' => [ new Assert\Length(max: 50), ], - ])->add('phone', TextType::class, [ + ])->add('telephone', TextType::class, [ 'label' => 'Tel', 'required' => false, 'empty_data' => '', @@ -90,21 +90,21 @@ public function buildForm(FormBuilderInterface $builder, array $options): void 'constraints' => [ new Assert\Length(max: 20), ], - ])->add('refClt1', TextType::class, [ + ])->add('referenceClient1', TextType::class, [ 'label' => 'Référence client', 'required' => false, 'empty_data' => '', 'constraints' => [ new Assert\Length(max: 50), ], - ])->add('refClt2', TextType::class, [ + ])->add('referenceClient2', TextType::class, [ 'label' => 'Référence client 2', 'required' => false, 'empty_data' => '', 'constraints' => [ new Assert\Length(max: 50), ], - ])->add('refClt3', TextType::class, [ + ])->add('referenceClient3', TextType::class, [ 'label' => 'Référence client 3', 'required' => false, 'empty_data' => '', @@ -115,7 +115,7 @@ public function buildForm(FormBuilderInterface $builder, array $options): void 'required' => false, 'empty_data' => '', 'label' => 'Observation', - ])->add('currency', EnumType::class, [ + ])->add('deviseFacture', EnumType::class, [ 'required' => false, 'class' => InvoicingCurrency::class, 'attr' => ['size' => count(InvoicingCurrency::cases())], @@ -127,21 +127,21 @@ public function buildForm(FormBuilderInterface $builder, array $options): void 'allow_add' => false, 'allow_delete' => false, 'entry_options' => ['disabled' => true], - ])->add('quotationNumber', TextType::class, [ + ])->add('numeroDevis', TextType::class, [ 'label' => 'Numéro de devis', 'required' => false, 'attr' => ['readonly' => 'readonly'], 'constraints' => [ new Assert\Length(max: 50), ], - ])->add('invoiceNumber', TextType::class, [ + ])->add('numeroFacture', TextType::class, [ 'label' => 'Numéro facture', 'required' => false, 'attr' => ['readonly' => 'readonly'], 'constraints' => [ new Assert\Length(max: 50), ], - ])->add('paymentStatus', EnumType::class, [ + ])->add('etatPaiement', EnumType::class, [ 'required' => false, 'class' => InvoicingPaymentStatus::class, 'attr' => ['size' => count(InvoicingPaymentStatus::cases())], @@ -149,7 +149,7 @@ public function buildForm(FormBuilderInterface $builder, array $options): void 'placeholder' => false, 'choice_label' => fn(InvoicingPaymentStatus $choice, string $key, mixed $value): string => $choice->label(), ]) - ->add('paymentDate', DateType::class, [ + ->add('datePaiement', DateType::class, [ 'label' => 'Date de paiement', 'required' => false, 'widget' => 'single_text', diff --git a/sources/AppBundle/Accounting/Form/InvoicingPeriodType.php b/sources/AppBundle/Accounting/Form/InvoicingPeriodType.php index 05659f941..103b1f5af 100644 --- a/sources/AppBundle/Accounting/Form/InvoicingPeriodType.php +++ b/sources/AppBundle/Accounting/Form/InvoicingPeriodType.php @@ -4,8 +4,7 @@ namespace AppBundle\Accounting\Form; -use AppBundle\Accounting\Model\InvoicingPeriod; -use AppBundle\Accounting\Model\Repository\InvoicingPeriodRepository; +use AppBundle\Accounting\Entity\Repository\InvoicingPeriodRepository; use Symfony\Component\Form\AbstractType; use Symfony\Component\Form\Extension\Core\Type\ChoiceType; use Symfony\Component\Form\FormBuilderInterface; @@ -18,9 +17,8 @@ public function __construct(private readonly InvoicingPeriodRepository $invoicin public function buildForm(FormBuilderInterface $builder, array $options): void { $periods = []; - /** @var InvoicingPeriod $period */ - foreach ($this->invoicingPeriodRepository->getAll() as $period) { - $periods["{$period->getStartDate()->format('d/m/Y')} - {$period->getEndDate()->format('d/m/Y')}"] = $period->getId(); + foreach ($this->invoicingPeriodRepository->findAll() as $period) { + $periods["{$period->dateDebut->format('d/m/Y')} - {$period->dateFin->format('d/m/Y')}"] = $period->id; } $builder->add('periodId', ChoiceType::class, [ diff --git a/sources/AppBundle/Accounting/Form/InvoicingRowType.php b/sources/AppBundle/Accounting/Form/InvoicingRowType.php index 2d0dcea81..54af7539f 100644 --- a/sources/AppBundle/Accounting/Form/InvoicingRowType.php +++ b/sources/AppBundle/Accounting/Form/InvoicingRowType.php @@ -4,7 +4,7 @@ namespace AppBundle\Accounting\Form; -use AppBundle\Accounting\Model\InvoicingDetail; +use AppBundle\Accounting\Entity\InvoicingDetail; use Symfony\Component\Form\AbstractType; use Symfony\Component\Form\Extension\Core\DataTransformer\MoneyToLocalizedStringTransformer; use Symfony\Component\Form\Extension\Core\Type\ChoiceType; @@ -33,14 +33,14 @@ public function buildForm(FormBuilderInterface $builder, array $options): void new Assert\Type('string'), new Assert\Length(max: 100), ], - ])->add('quantity', NumberType::class, [ + ])->add('quantite', NumberType::class, [ 'label' => 'Quantité', 'scale' => 2, 'constraints' => [ new Assert\NotBlank(), new Assert\Type(type: 'numeric'), ], - ])->add('unitPrice', NumberType::class, [ + ])->add('prixUnitaire', NumberType::class, [ 'label' => 'Prix unitaire HT', 'scale' => 2, 'constraints' => [ @@ -56,8 +56,8 @@ public function buildForm(FormBuilderInterface $builder, array $options): void new Assert\NotBlank(), ], ]); - $builder->get('unitPrice')->resetViewTransformers(); - $builder->get('unitPrice')->addViewTransformer( + $builder->get('prixUnitaire')->resetViewTransformers(); + $builder->get('prixUnitaire')->addViewTransformer( new MoneyToLocalizedStringTransformer(2, false, null, null, 'en'), ); } diff --git a/sources/AppBundle/Accounting/Form/QuotationType.php b/sources/AppBundle/Accounting/Form/QuotationType.php index 01d2a1302..5d6777ae2 100644 --- a/sources/AppBundle/Accounting/Form/QuotationType.php +++ b/sources/AppBundle/Accounting/Form/QuotationType.php @@ -5,8 +5,8 @@ namespace AppBundle\Accounting\Form; use Afup\Site\Utils\Pays; +use AppBundle\Accounting\Entity\Invoicing; use AppBundle\Accounting\InvoicingCurrency; -use AppBundle\Accounting\Model\Invoicing; use Symfony\Component\Form\AbstractType; use Symfony\Component\Form\Extension\Core\Type\ChoiceType; use Symfony\Component\Form\Extension\Core\Type\CollectionType; @@ -27,11 +27,11 @@ public function __construct(private readonly Pays $pays) {} public function buildForm(FormBuilderInterface $builder, array $options): void { - $builder->add('quotationDate', DateType::class, [ + $builder->add('dateDevis', DateType::class, [ 'label' => 'Date devis', 'required' => true, 'widget' => 'single_text', - ])->add('company', TextType::class, [ + ])->add('societe', TextType::class, [ 'label' => 'Société', 'empty_data' => '', 'constraints' => [ @@ -47,13 +47,13 @@ public function buildForm(FormBuilderInterface $builder, array $options): void new Assert\Type('string'), new Assert\Length(max: 50), ], - ])->add('address', TextareaType::class, [ + ])->add('adresse', TextareaType::class, [ 'label' => 'Adresse', 'empty_data' => '', 'constraints' => [ new Assert\Type('string'), ], - ])->add('zipcode', TextType::class, [ + ])->add('codePostal', TextType::class, [ 'label' => 'Code postal', 'empty_data' => '', 'constraints' => [ @@ -61,7 +61,7 @@ public function buildForm(FormBuilderInterface $builder, array $options): void new Assert\Type('string'), new Assert\Length(max: 10), ], - ])->add('city', TextType::class, [ + ])->add('ville', TextType::class, [ 'label' => 'Ville', 'empty_data' => '', 'constraints' => [ @@ -69,10 +69,10 @@ public function buildForm(FormBuilderInterface $builder, array $options): void new Assert\Type('string'), new Assert\Length(max: 50), ], - ])->add('countryId', ChoiceType::class, [ + ])->add('idPays', ChoiceType::class, [ 'label' => 'Pays', 'choices' => array_flip($this->pays->obtenirPays()), - ])->add('lastname', TextType::class, [ + ])->add('nom', TextType::class, [ 'label' => 'Nom', 'required' => false, 'empty_data' => '', @@ -80,7 +80,7 @@ public function buildForm(FormBuilderInterface $builder, array $options): void new Assert\Type('string'), new Assert\Length(max: 50), ], - ])->add('firstname', TextType::class, [ + ])->add('prenom', TextType::class, [ 'label' => 'Prénom', 'required' => false, 'empty_data' => '', @@ -88,7 +88,7 @@ public function buildForm(FormBuilderInterface $builder, array $options): void new Assert\Type('string'), new Assert\Length(max: 50), ], - ])->add('phone', TextType::class, [ + ])->add('telephone', TextType::class, [ 'label' => 'Tel', 'required' => false, 'empty_data' => '', @@ -112,7 +112,7 @@ public function buildForm(FormBuilderInterface $builder, array $options): void new Assert\Type('string'), new Assert\Length(max: 20), ], - ])->add('refClt1', TextType::class, [ + ])->add('referenceClient1', TextType::class, [ 'label' => 'Référence client', 'required' => false, 'empty_data' => '', @@ -120,7 +120,7 @@ public function buildForm(FormBuilderInterface $builder, array $options): void new Assert\Type('string'), new Assert\Length(max: 50), ], - ])->add('refClt2', TextType::class, [ + ])->add('referenceClient2', TextType::class, [ 'label' => 'Référence client 2', 'required' => false, 'empty_data' => '', @@ -128,7 +128,7 @@ public function buildForm(FormBuilderInterface $builder, array $options): void new Assert\Type('string'), new Assert\Length(max: 50), ], - ])->add('refClt3', TextType::class, [ + ])->add('referenceClient3', TextType::class, [ 'label' => 'Référence client 3', 'required' => false, 'empty_data' => '', @@ -140,7 +140,7 @@ public function buildForm(FormBuilderInterface $builder, array $options): void 'required' => false, 'empty_data' => '', 'label' => 'Observation', - ])->add('currency', EnumType::class, [ + ])->add('deviseFacture', EnumType::class, [ 'required' => false, 'class' => InvoicingCurrency::class, 'attr' => ['size' => count(InvoicingCurrency::cases())], @@ -154,7 +154,7 @@ public function buildForm(FormBuilderInterface $builder, array $options): void ]); if ($options['actionType'] === 'edit') { - $builder->add('quotationNumber', TextType::class, [ + $builder->add('numeroDevis', TextType::class, [ 'label' => 'Numéro de devis', 'required' => false, 'constraints' => [ diff --git a/sources/AppBundle/Accounting/Form/TransactionType.php b/sources/AppBundle/Accounting/Form/TransactionType.php index b616e6121..f4f744cfc 100644 --- a/sources/AppBundle/Accounting/Form/TransactionType.php +++ b/sources/AppBundle/Accounting/Form/TransactionType.php @@ -4,17 +4,21 @@ namespace AppBundle\Accounting\Form; +use AppBundle\Accounting\Entity\Account; +use AppBundle\Accounting\Entity\Category; use AppBundle\Accounting\Entity\Event; +use AppBundle\Accounting\Entity\Operation; +use AppBundle\Accounting\Entity\Payment; use AppBundle\Accounting\Entity\Repository\AccountRepository; use AppBundle\Accounting\Entity\Repository\CategoryRepository; use AppBundle\Accounting\Entity\Repository\EventRepository; use AppBundle\Accounting\Entity\Repository\OperationRepository; use AppBundle\Accounting\Entity\Repository\PaymentRepository; -use AppBundle\Accounting\Model\Transaction; +use AppBundle\Accounting\Entity\Transaction; use AppBundle\Accounting\TvaZone; +use Symfony\Bridge\Doctrine\Form\Type\EntityType; use Symfony\Component\Form\AbstractType; use Symfony\Component\Form\Extension\Core\DataTransformer\MoneyToLocalizedStringTransformer; -use Symfony\Component\Form\Extension\Core\Type\ChoiceType; use Symfony\Component\Form\Extension\Core\Type\DateType; use Symfony\Component\Form\Extension\Core\Type\EnumType; use Symfony\Component\Form\Extension\Core\Type\MoneyType; @@ -37,44 +41,52 @@ public function __construct( public function buildForm(FormBuilderInterface $builder, array $options): void { - $builder->add('operationId', ChoiceType::class, [ + $builder->add('operation', EntityType::class, [ 'label' => 'Type d\'opération', - 'choices' => $this->buildOperationTypeChoice(), + 'class' => Operation::class, + 'choices' => $this->operationRepository->findAll(), + 'choice_label' => 'name', 'placeholder' => '', 'constraints' => [ new Assert\NotBlank(message: "Type d'opération manquant"), ], ]) - ->add('accountId', ChoiceType::class, [ + ->add('compte', EntityType::class, [ 'label' => 'Compte', - 'choices' => $this->buildAccountChoice(), + 'class' => Account::class, + 'choices' => $this->accountRepository->getAllSortedByName(), + 'choice_label' => 'name', 'placeholder' => '', 'constraints' => [ new Assert\NotBlank(), ], ]) - ->add('eventId', ChoiceType::class, [ + ->add('evenement', EntityType::class, [ 'label' => 'Évènement', - 'choices' => $this->buildEventChoice(), + 'class' => Event::class, + 'choices' => $this->eventRepository->getAllSortedByName(), + 'choice_label' => 'name', 'placeholder' => '', 'constraints' => [ new Assert\NotBlank(message: "Évènement manquant"), ], ]) - ->add('accountingDate', DateType::class, [ + ->add('dateEcriture', DateType::class, [ 'label' => 'Date saisie', 'widget' => 'single_text', 'required' => false, ]) - ->add('categoryId', ChoiceType::class, [ + ->add('categorie', EntityType::class, [ 'label' => 'categorie', + 'class' => Category::class, 'placeholder' => '', - 'choices' => $this->buildCategoryChoice(), + 'choices' => $this->categoryRepository->getAllSortedByName(), + 'choice_label' => 'name', 'constraints' => [ new Assert\NotBlank(message: "Catégorie manquante"), ], ]) - ->add('vendorName', TextType::class, [ + ->add('nomFournisseur', TextType::class, [ 'label' => 'Nom fournisseurs ', 'required' => false, 'empty_data' => '', @@ -83,7 +95,7 @@ public function buildForm(FormBuilderInterface $builder, array $options): void 'label' => 'TVA intracommunautaire (facture)', 'required' => false, ]) - ->add('number', TextType::class, [ + ->add('numero', TextType::class, [ 'label' => 'Numero facture', 'required' => false, 'empty_data' => '', @@ -93,7 +105,7 @@ public function buildForm(FormBuilderInterface $builder, array $options): void 'required' => false, 'empty_data' => '', ]) - ->add('amount', MoneyType::class, [ + ->add('montant', MoneyType::class, [ 'label' => 'Montant', 'currency' => '', 'constraints' => [ @@ -101,26 +113,26 @@ public function buildForm(FormBuilderInterface $builder, array $options): void new Assert\NotEqualTo(value: 0, message: "Montant manquant"), ], ]) - ->add('comment', TextType::class, [ + ->add('commentaire', TextType::class, [ 'label' => 'Commentaire', 'required' => false, ]) - ->add('amountTva5_5', MoneyType::class, [ + ->add('montantTva5_5', MoneyType::class, [ 'label' => 'Montant HT soumis à TVA 5.5%', 'required' => false, 'currency' => '', ]) - ->add('amountTva10', MoneyType::class, [ + ->add('montantTva10', MoneyType::class, [ 'label' => 'Montant HT soumis à TVA 10%', 'required' => false, 'currency' => '', ]) - ->add('amountTva20', MoneyType::class, [ + ->add('montantTva20', MoneyType::class, [ 'label' => 'Montant HT soumis à TVA 20%', 'required' => false, 'currency' => '', ]) - ->add('amountTva0', MoneyType::class, [ + ->add('montantTva0', MoneyType::class, [ 'label' => 'Montant HT non soumis à TVA', 'required' => false, 'currency' => '', @@ -134,17 +146,20 @@ public function buildForm(FormBuilderInterface $builder, array $options): void 'choice_label' => fn(TvaZone $choice, string $key, mixed $value): string => $choice->getLabel(), ]) - ->add('paymentTypeId', ChoiceType::class, [ + ->add('modeReglement', EntityType::class, [ 'label' => 'Réglement', + 'class' => Payment::class, 'required' => false, - 'choices' => $this->buildPaymentTypeChoice(), + 'placeholder' => '', + 'choices' => $this->paymentRepository->getAllSortedByName(), + 'choice_label' => 'name', ]) - ->add('paymentDate', DateType::class, [ + ->add('dateReglement', DateType::class, [ 'label' => 'Date', 'widget' => 'single_text', 'required' => false, ]) - ->add('paymentComment', TextType::class, [ + ->add('commentaireReglement', TextType::class, [ 'label' => 'Info réglement', 'required' => false, 'empty_data' => '', @@ -171,24 +186,24 @@ public function buildForm(FormBuilderInterface $builder, array $options): void ]); } - $builder->get('amount')->resetViewTransformers(); - $builder->get('amount')->addViewTransformer( + $builder->get('montant')->resetViewTransformers(); + $builder->get('montant')->addViewTransformer( new MoneyToLocalizedStringTransformer(2, false, null, null, 'en'), ); - $builder->get('amountTva0')->resetViewTransformers(); - $builder->get('amountTva0')->addViewTransformer( + $builder->get('montantTva0')->resetViewTransformers(); + $builder->get('montantTva0')->addViewTransformer( new MoneyToLocalizedStringTransformer(2, false, null, null, 'en'), ); - $builder->get('amountTva5_5')->resetViewTransformers(); - $builder->get('amountTva5_5')->addViewTransformer( + $builder->get('montantTva5_5')->resetViewTransformers(); + $builder->get('montantTva5_5')->addViewTransformer( new MoneyToLocalizedStringTransformer(2, false, null, null, 'en'), ); - $builder->get('amountTva10')->resetViewTransformers(); - $builder->get('amountTva10')->addViewTransformer( + $builder->get('montantTva10')->resetViewTransformers(); + $builder->get('montantTva10')->addViewTransformer( new MoneyToLocalizedStringTransformer(2, false, null, null, 'en'), ); - $builder->get('amountTva20')->resetViewTransformers(); - $builder->get('amountTva20')->addViewTransformer( + $builder->get('montantTva20')->resetViewTransformers(); + $builder->get('montantTva20')->addViewTransformer( new MoneyToLocalizedStringTransformer(2, false, null, null, 'en'), ); } @@ -204,56 +219,4 @@ public function configureOptions(OptionsResolver $resolver): void 'nextTransaction' => null, ]); } - - private function buildOperationTypeChoice(): array - { - $choices = []; - foreach ($this->operationRepository->findAll() as $operation) { - $choices[$operation->name] = $operation->id; - } - - return $choices; - } - - private function buildAccountChoice(): array - { - $choices = []; - foreach ($this->accountRepository->getAllSortedByName() as $account) { - $choices[$account->name] = $account->id; - } - - return $choices; - } - - private function buildEventChoice(): array - { - $choices = []; - /** @var Event $event */ - foreach ($this->eventRepository->getAllSortedByName() as $event) { - $choices[$event->name] = $event->id; - } - - return $choices; - } - - private function buildCategoryChoice(): array - { - $choices = []; - foreach ($this->categoryRepository->getAllSortedByName() as $category) { - $choices[$category->name] = $category->id; - } - - return $choices; - } - - private function buildPaymentTypeChoice(): array - { - $choices = []; - $choices[''] = 0; - foreach ($this->paymentRepository->getAllSortedByName() as $paymentType) { - $choices[$paymentType->name] = $paymentType->id; - } - - return $choices; - } } diff --git a/sources/AppBundle/Accounting/InvoicingMailer.php b/sources/AppBundle/Accounting/InvoicingMailer.php index 59d0d04d1..85450a8ff 100644 --- a/sources/AppBundle/Accounting/InvoicingMailer.php +++ b/sources/AppBundle/Accounting/InvoicingMailer.php @@ -5,7 +5,7 @@ namespace AppBundle\Accounting; use AppBundle\Afup; -use AppBundle\Accounting\Model\Invoicing; +use AppBundle\Accounting\Entity\Invoicing; use AppBundle\Email\Mailer\Attachment; use AppBundle\Email\Mailer\Mailer; use AppBundle\Email\Mailer\MailUser; @@ -23,7 +23,7 @@ public function __construct( public function sendInvoice(Invoicing $invoicing): bool { - $invoiceNumber = $invoicing->getInvoiceNumber(); + $invoiceNumber = $invoicing->numeroFacture; $sujet = "Facture AFUP"; @@ -41,7 +41,7 @@ public function sendInvoice(Invoicing $invoicing): bool $message = new Message( $sujet, new MailUser(MailUser::DEFAULT_SENDER_EMAIL, MailUser::DEFAULT_SENDER_NAME), - new MailUser($invoicing->getEmail(), $invoicing->getLastname()), + new MailUser($invoicing->email, $invoicing->nom), ); $message->addAttachment(new Attachment( $cheminFacture, diff --git a/sources/AppBundle/Accounting/InvoicingNumberGenerator.php b/sources/AppBundle/Accounting/InvoicingNumberGenerator.php index 4de1ff32c..4c6844480 100644 --- a/sources/AppBundle/Accounting/InvoicingNumberGenerator.php +++ b/sources/AppBundle/Accounting/InvoicingNumberGenerator.php @@ -4,7 +4,7 @@ namespace AppBundle\Accounting; -use AppBundle\Accounting\Model\Repository\InvoicingRepository; +use AppBundle\Accounting\Entity\Repository\InvoicingRepository; class InvoicingNumberGenerator { diff --git a/sources/AppBundle/Accounting/InvoicingPdfGenerator.php b/sources/AppBundle/Accounting/InvoicingPdfGenerator.php index 398cb45ce..03146dae7 100644 --- a/sources/AppBundle/Accounting/InvoicingPdfGenerator.php +++ b/sources/AppBundle/Accounting/InvoicingPdfGenerator.php @@ -7,8 +7,8 @@ use Afup\Site\Utils\Pays; use Afup\Site\Utils\PDF_Facture; use Afup\Site\Utils\Vat; -use AppBundle\Accounting\Model\Invoicing; -use AppBundle\Accounting\Model\InvoicingDetail; +use AppBundle\Accounting\Entity\Invoicing; +use AppBundle\Accounting\Entity\InvoicingDetail; use AppBundle\Compta\BankAccount\BankAccountFactory; class InvoicingPdfGenerator @@ -17,8 +17,8 @@ public function __construct(private readonly Pays $pays) {} public function generateInvoice(Invoicing $invoicing, ?string $path = null): string { - $date = $invoicing->getInvoiceDate() !== null - ? \DateTimeImmutable::createFromMutable($invoicing->getInvoiceDate()) + $date = $invoicing->dateFacture !== null + ? \DateTimeImmutable::createFromMutable($invoicing->dateFacture) : new \DateTimeImmutable(); $isSubjectedToVat = Vat::isSubjectedToVat($date); @@ -29,15 +29,15 @@ public function generateInvoice(Invoicing $invoicing, ?string $path = null): str $this->renderRecipient($pdf, $invoicing); $pdf->SetFont('Arial', 'BU', 10); - $pdf->Cell(0, 5, 'Facture n° ' . $invoicing->getInvoiceNumber(), 0, 0, 'C'); + $pdf->Cell(0, 5, 'Facture n° ' . $invoicing->numeroFacture, 0, 0, 'C'); $pdf->SetFont('Arial', '', 10); $this->renderClientReferences($pdf, $invoicing); $pdf->MultiCell(180, 5, 'Comme convenu, nous vous prions de trouver votre facture'); - $devise = ' ' . ($invoicing->getCurrency()?->symbol() ?? '€'); - [$totalHt, $totalTtc, $vatAmounts] = $this->renderLineItems($pdf, $invoicing->getDetails(), $isSubjectedToVat, $devise, true); + $devise = ' ' . ($invoicing->deviseFacture?->symbol() ?? '€'); + [$totalHt, $totalTtc, $vatAmounts] = $this->renderLineItems($pdf, $invoicing->details, $isSubjectedToVat, $devise, true); $this->renderTotals($pdf, $isSubjectedToVat, $totalHt, $totalTtc, $vatAmounts, $devise); @@ -54,11 +54,11 @@ public function generateInvoice(Invoicing $invoicing, ?string $path = null): str } $pdf->Ln(10); - if ($invoicing->getObservation() !== '') { + if ($invoicing->observation !== '') { $pdf->Cell(10, 5, 'Observations : '); $pdf->Ln(5); $pdf->SetFont('Arial', '', 8); - $pdf->MultiCell(130, 5, $invoicing->getObservation()); + $pdf->MultiCell(130, 5, $invoicing->observation); } return $this->output($pdf, $path, $this->getInvoiceFilename($invoicing)); @@ -66,8 +66,8 @@ public function generateInvoice(Invoicing $invoicing, ?string $path = null): str public function generateQuotation(Invoicing $invoicing, ?string $path = null): string { - $date = $invoicing->getQuotationDate() !== null - ? \DateTimeImmutable::createFromMutable($invoicing->getQuotationDate()) + $date = $invoicing->dateDevis !== null + ? \DateTimeImmutable::createFromMutable($invoicing->dateDevis) : new \DateTimeImmutable(); $isSubjectedToVat = Vat::isSubjectedToVat($date); @@ -78,15 +78,15 @@ public function generateQuotation(Invoicing $invoicing, ?string $path = null): s $this->renderRecipient($pdf, $invoicing); $pdf->SetFont('Arial', 'BU', 10); - $pdf->Cell(0, 5, 'Devis n° ' . $invoicing->getQuotationNumber(), 0, 0, 'C'); + $pdf->Cell(0, 5, 'Devis n° ' . $invoicing->numeroDevis, 0, 0, 'C'); $pdf->SetFont('Arial', '', 10); $this->renderClientReferences($pdf, $invoicing); $pdf->MultiCell(180, 5, 'Comme convenu, nous vous prions de trouver votre devis'); - $devise = ' ' . ($invoicing->getCurrency()?->symbol() ?? '€'); - [$totalHt, $totalTtc, $vatAmounts] = $this->renderLineItems($pdf, $invoicing->getDetails(), $isSubjectedToVat, $devise, false); + $devise = ' ' . ($invoicing->deviseFacture?->symbol() ?? '€'); + [$totalHt, $totalTtc, $vatAmounts] = $this->renderLineItems($pdf, $invoicing->details, $isSubjectedToVat, $devise, false); $this->renderTotals($pdf, $isSubjectedToVat, $totalHt, $totalTtc, $vatAmounts, $devise); @@ -98,19 +98,19 @@ public function generateQuotation(Invoicing $invoicing, ?string $path = null): s $pdf->Cell(10, 5, 'Observations : '); $pdf->Ln(5); $pdf->SetFont('Arial', '', 8); - $pdf->MultiCell(130, 5, $invoicing->getObservation()); + $pdf->MultiCell(130, 5, $invoicing->observation); return $this->output($pdf, $path, $this->getQuotationFilename($invoicing)); } public function getInvoiceFilename(Invoicing $invoicing): string { - return 'Facture - ' . $invoicing->getCompany() . ' - ' . ($invoicing->getInvoiceDate() ? $invoicing->getInvoiceDate()->format('Y-m-d') : '') . '.pdf'; + return 'Facture - ' . $invoicing->societe . ' - ' . ($invoicing->dateFacture ? $invoicing->dateFacture->format('Y-m-d') : '') . '.pdf'; } public function getQuotationFilename(Invoicing $invoicing): string { - return 'Devis - ' . $invoicing->getCompany() . ' - ' . ($invoicing->getQuotationDate() ? $invoicing->getQuotationDate()->format('Y-m-d') : '') . '.pdf'; + return 'Devis - ' . $invoicing->societe . ' - ' . ($invoicing->dateDevis ? $invoicing->dateDevis->format('Y-m-d') : '') . '.pdf'; } private function buildPdf(\DateTimeImmutable $date, bool $isSubjectedToVat): PDF_Facture @@ -134,24 +134,24 @@ private function renderRecipient(PDF_Facture $pdf, Invoicing $invoicing): void $pdf->Ln(10); $pdf->setx(120); $pdf->MultiCell(130, 5, - $invoicing->getCompany() . "\n" - . $invoicing->getService() . "\n" - . $invoicing->getAddress() . "\n" - . $invoicing->getZipcode() . ' ' - . $invoicing->getCity() . "\n" - . $this->pays->obtenirNom($invoicing->getCountryId()) - . ($invoicing->getTvaIntra() ? ("\nN° TVA Intracommunautaire : " . $invoicing->getTvaIntra()) : ''), + $invoicing->societe . "\n" + . $invoicing->service . "\n" + . $invoicing->adresse . "\n" + . $invoicing->codePostal . ' ' + . $invoicing->ville . "\n" + . $this->pays->obtenirNom($invoicing->idPays) + . ($invoicing->tvaIntra ? ("\nN° TVA Intracommunautaire : " . $invoicing->tvaIntra) : ''), ); $pdf->Ln(10); } private function renderClientReferences(PDF_Facture $pdf, Invoicing $invoicing): void { - if ($invoicing->getRefClt1() !== '' || $invoicing->getRefClt2() !== '' || $invoicing->getRefClt3() !== '') { + if ($invoicing->referenceClient1 !== '' || $invoicing->referenceClient2 !== '' || $invoicing->referenceClient3 !== '') { $pdf->Ln(15); $pdf->Cell(40, 5, 'Repère(s) : '); } - foreach ([$invoicing->getRefClt1(), $invoicing->getRefClt2(), $invoicing->getRefClt3()] as $ref) { + foreach ([$invoicing->referenceClient1, $invoicing->referenceClient2, $invoicing->referenceClient3] as $ref) { if ($ref !== '') { $pdf->setx(30); $pdf->Cell(100, 5, $ref); @@ -164,10 +164,10 @@ private function renderClientReferences(PDF_Facture $pdf, Invoicing $invoicing): /** * Renders the line-items table and returns [totalHt, totalTtc, vatAmounts]. * - * @param InvoicingDetail[] $details + * @param iterable $details * @return array{float, float, array} */ - private function renderLineItems(PDF_Facture $pdf, array $details, bool $isSubjectedToVat, string $devise, bool $drawColumnLines): array + private function renderLineItems(PDF_Facture $pdf, iterable $details, bool $isSubjectedToVat, string $devise, bool $drawColumnLines): array { $pdf->Ln(5); $pdf->SetFillColor(200, 200, 200); @@ -187,41 +187,41 @@ private function renderLineItems(PDF_Facture $pdf, array $details, bool $isSubje $columns = $isSubjectedToVat ? [0, 30, 90, 110, 130, 160, 190] : [0, 30, 110, 130, 160, 190]; foreach ($details as $detail) { - if ((float) $detail->getQuantity() === 0.0) { + if ((float) $detail->quantite === 0.0) { continue; } - $montantHt = $detail->getQuantity() * $detail->getUnitPrice(); + $montantHt = $detail->quantite * $detail->prixUnitaire; $montantTtc = $montantHt; $pdf->Ln(); $pdf->SetFillColor(255, 255, 255); if (!$drawColumnLines && !$isSubjectedToVat) { - $pdf->Cell(30, 5, $detail->getReference(), 1); - $pdf->Cell(80, 5, $detail->getDesignation(), 1); - $pdf->Cell(20, 5, number_format((float) $detail->getQuantity(), 2, '.', ''), 1, 0, 'C'); - $pdf->Cell(30, 5, number_format($detail->getUnitPrice(), 2, '.', '') . $devise, 1, 0, 'R'); + $pdf->Cell(30, 5, $detail->reference, 1); + $pdf->Cell(80, 5, $detail->designation, 1); + $pdf->Cell(20, 5, number_format((float) $detail->quantite, 2, '.', ''), 1, 0, 'C'); + $pdf->Cell(30, 5, number_format($detail->prixUnitaire, 2, '.', '') . $devise, 1, 0, 'R'); $pdf->Cell(30, 5, $this->formatValue($montantHt, false) . $devise, 1, 0, 'R'); } else { $y = $pdf->GetY(); $x = $pdf->GetX(); - $pdf->MultiCell(30, 5, $detail->getReference(), 'T'); + $pdf->MultiCell(30, 5, $detail->reference, 'T'); $x += 30; $pdf->SetXY($x, $y); $designationLength = $isSubjectedToVat ? 60 : 80; - $pdf->MultiCell($designationLength, 5, $detail->getDesignation(), 'T'); + $pdf->MultiCell($designationLength, 5, $detail->designation, 'T'); $x += $designationLength; $pdf->SetXY($x, $y); - $pdf->MultiCell(20, 5, number_format((float) $detail->getQuantity(), 2, '.', ''), 'T', 0, 'C'); + $pdf->MultiCell(20, 5, number_format((float) $detail->quantite, 2, '.', ''), 'T', 0, 'C'); $x += 20; if ($isSubjectedToVat) { $pdf->SetXY($x, $y); - $tva = (float) $detail->getTva(); + $tva = (float) $detail->tva; $pdf->MultiCell(20, 5, number_format($tva, 2, '.', '') . '%', 'T', 'C', 'C'); $tvaKey = (string) $tva; $vatAmounts[$tvaKey] = ($vatAmounts[$tvaKey] ?? 0.0) + ($tva / 100) * $montantTtc; @@ -231,8 +231,8 @@ private function renderLineItems(PDF_Facture $pdf, array $details, bool $isSubje $pdf->SetXY($x, $y); $unitPrice = $isSubjectedToVat - ? $this->formatValue($detail->getUnitPrice(), true) - : number_format($detail->getUnitPrice(), 2, '.', ''); + ? $this->formatValue($detail->prixUnitaire, true) + : number_format($detail->prixUnitaire, 2, '.', ''); $pdf->MultiCell(30, 5, $unitPrice . $devise, 'T', 0, 'R'); $x += 30; $pdf->SetXY($x, $y); diff --git a/sources/AppBundle/Accounting/Model/Invoicing.php b/sources/AppBundle/Accounting/Model/Invoicing.php deleted file mode 100644 index dd5c4fe8d..000000000 --- a/sources/AppBundle/Accounting/Model/Invoicing.php +++ /dev/null @@ -1,383 +0,0 @@ -id; - } - - public function setId(int $id): self - { - $this->propertyChanged('id', $this->id, $id); - $this->id = $id; - return $this; - } - - public function getQuotationDate(): ?DateTime - { - return $this->quotationDate; - } - - public function setQuotationDate(?DateTime $quotationDate): self - { - $this->propertyChanged('quotationDate', $this->quotationDate, $quotationDate); - $this->quotationDate = $quotationDate; - - return $this; - } - - public function getQuotationNumber(): ?string - { - return $this->quotationNumber; - } - - public function setQuotationNumber(?string $quotationNumber): self - { - $this->propertyChanged('quotationNumber', $this->quotationNumber, $quotationNumber); - $this->quotationNumber = $quotationNumber; - - return $this; - } - - public function getInvoiceDate(): ?DateTime - { - return $this->invoiceDate; - } - - public function setInvoiceDate(?DateTime $invoiceDate): self - { - $this->propertyChanged('invoiceDate', $this->invoiceDate, $invoiceDate); - $this->invoiceDate = $invoiceDate; - - 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 getCompany(): string - { - return $this->company; - } - - public function setCompany(string $company): self - { - $this->propertyChanged('company', $this->company, $company); - $this->company = $company; - - return $this; - } - - public function getService(): string - { - return $this->service; - } - - public function setService(string $service): self - { - $this->propertyChanged('service', $this->service, $service); - $this->service = $service; - - return $this; - } - - public function getAddress(): string - { - return $this->address; - } - - public function setAddress(string $address): self - { - $this->propertyChanged('address', $this->address, $address); - $this->address = $address; - - return $this; - } - - public function getZipcode(): string - { - return $this->zipcode; - } - - public function setZipcode(string $zipcode): self - { - $this->propertyChanged('zipcode', $this->zipcode, $zipcode); - $this->zipcode = $zipcode; - - return $this; - } - - public function getCity(): string - { - return $this->city; - } - - public function setCity(string $city): self - { - $this->propertyChanged('city', $this->city, $city); - $this->city = $city; - - return $this; - } - - public function getCountryId(): ?string - { - return $this->countryId; - } - - public function setCountryId(?string $countryId): self - { - $this->propertyChanged('countryId', $this->countryId, $countryId); - $this->countryId = $countryId; - - return $this; - } - - public function getEmail(): string - { - return $this->email; - } - - public function setEmail(string $email): self - { - $this->propertyChanged('email', $this->email, $email); - $this->email = $email; - - return $this; - } - - public function getTvaIntra(): ?string - { - return $this->tvaIntra; - } - - public function setTvaIntra(?string $tvaIntra): self - { - $this->propertyChanged('tvaIntra', $this->tvaIntra, $tvaIntra); - $this->tvaIntra = $tvaIntra; - - return $this; - } - - public function getObservation(): string - { - return $this->observation; - } - - public function setObservation(string $observation): self - { - $this->propertyChanged('observation', $this->observation, $observation); - $this->observation = $observation; - - return $this; - } - - public function getRefClt1(): string - { - return $this->refClt1; - } - - public function setRefClt1(string $refClt1): self - { - $this->propertyChanged('refClt1', $this->refClt1, $refClt1); - $this->refClt1 = $refClt1; - - return $this; - } - - public function getRefClt2(): string - { - return $this->refClt2; - } - - public function setRefClt2(string $refClt2): self - { - $this->propertyChanged('refClt2', $this->refClt2, $refClt2); - $this->refClt2 = $refClt2; - - return $this; - } - - public function getRefClt3(): string - { - return $this->refClt3; - } - - public function setRefClt3(string $refClt3): self - { - $this->propertyChanged('refClt3', $this->refClt3, $refClt3); - $this->refClt3 = $refClt3; - - return $this; - } - - public function getLastname(): string - { - return $this->lastname; - } - - public function setLastname(string $lastname): self - { - $this->propertyChanged('lastname', $this->lastname, $lastname); - $this->lastname = $lastname; - - return $this; - } - - public function getFirstname(): string - { - return $this->firstname; - } - - public function setFirstname(string $firstname): self - { - $this->propertyChanged('firstname', $this->firstname, $firstname); - $this->firstname = $firstname; - - return $this; - } - - public function getPhone(): string - { - return $this->phone; - } - - public function setPhone(string $phone): self - { - $this->propertyChanged('phone', $this->phone, $phone); - $this->phone = $phone; - - return $this; - } - - public function getPaymentStatus(): InvoicingPaymentStatus - { - return $this->paymentStatus; - } - - public function setPaymentStatus(InvoicingPaymentStatus $paymentStatus): self - { - $this->propertyChanged('paymentStatus', $this->paymentStatus, $paymentStatus); - $this->paymentStatus = $paymentStatus; - - return $this; - } - - public function getPaymentDate(): ?DateTime - { - return $this->paymentDate; - } - - public function setPaymentDate(?DateTime $paymentDate): self - { - $this->propertyChanged('paymentDate', $this->paymentDate, $paymentDate); - $this->paymentDate = $paymentDate; - - return $this; - } - - public function getCurrency(): ?InvoicingCurrency - { - return $this->currency; - } - - public function setCurrency(?InvoicingCurrency $currency): self - { - $this->propertyChanged('currency', $this->currency, $currency); - $this->currency = $currency; - - return $this; - } - - public function getPrice(): ?float - { - return $this->price; - } - - public function setPrice(?float $price): self - { - $this->price = $price; - - return $this; - } - - public function getPaymentUrlRef(): string - { - if (empty($this->getInvoiceNumber())) { - return ''; - } - - return urlencode(Utils::cryptFromText($this->getId())); - } - - /** @return InvoicingDetail[] */ - public function getDetails(): array - { - return $this->details; - } - - /** - * @param array $details - */ - public function setDetails(array $details): self - { - $this->details = $details; - - return $this; - } - -} diff --git a/sources/AppBundle/Accounting/Model/InvoicingDetail.php b/sources/AppBundle/Accounting/Model/InvoicingDetail.php deleted file mode 100644 index 2afc5f791..000000000 --- a/sources/AppBundle/Accounting/Model/InvoicingDetail.php +++ /dev/null @@ -1,124 +0,0 @@ -id; - } - - public function setId(int $id): self - { - $this->propertyChanged('id', $this->id, $id); - $this->id = $id; - return $this; - } - - public function getInvoicingId(): ?int - { - return $this->invoicingId; - } - - public function setInvoicingId(?int $invoicingId): self - { - $this->propertyChanged('invoicingId', $this->invoicingId, $invoicingId); - $this->invoicingId = $invoicingId; - - return $this; - } - - public function getReference(): ?string - { - return $this->reference; - } - - public function setReference(?string $ref): self - { - $this->propertyChanged('reference', $this->reference, $ref); - $this->reference = $ref; - - return $this; - } - - public function getDesignation(): ?string - { - return $this->designation; - } - - public function setDesignation(?string $designation): self - { - $this->propertyChanged('designation', $this->designation, $designation); - $this->designation = $designation; - - return $this; - } - - public function getQuantity(): ?float - { - return $this->quantity; - } - - public function setQuantity(?float $quantity): self - { - $this->propertyChanged('quantity', $this->quantity, $quantity); - $this->quantity = $quantity; - - return $this; - } - - public function getUnitPrice(): ?float - { - return $this->unitPrice; - } - - public function setUnitPrice(?float $unitPrice): self - { - $this->propertyChanged('unitPrice', $this->unitPrice, $unitPrice); - $this->unitPrice = $unitPrice; - - return $this; - } - - public function getTva(): ?float - { - return $this->tva; - } - - public function setTva(?float $tva): self - { - $this->propertyChanged('tva', $this->tva, $tva); - $this->tva = $tva; - - return $this; - } -} diff --git a/sources/AppBundle/Accounting/Model/InvoicingPeriod.php b/sources/AppBundle/Accounting/Model/InvoicingPeriod.php deleted file mode 100644 index 35bb300a4..000000000 --- a/sources/AppBundle/Accounting/Model/InvoicingPeriod.php +++ /dev/null @@ -1,72 +0,0 @@ -id; - } - - public function setId(?int $id): self - { - $this->id = $id; - $this->propertyChanged('id', $this->id, $id); - - return $this; - } - - public function getStartDate(): ?DateTime - { - return $this->startDate; - } - - public function setStartDate(?DateTime $startDate): self - { - $this->startDate = $startDate; - $this->propertyChanged('startdate', $this->startDate, $startDate); - - return $this; - } - - public function getEndDate(): ?DateTime - { - return $this->endDate; - } - - public function setEndDate(?DateTime $endDate): self - { - $this->endDate = $endDate; - $this->propertyChanged('endDate', $this->endDate, $endDate); - - return $this; - } - - public function getLocked(): ?bool - { - return $this->locked; - } - - public function setLocked(?bool $locked): self - { - $this->locked = $locked; - $this->propertyChanged('locked', $this->locked, $locked); - - return $this; - } -} diff --git a/sources/AppBundle/Accounting/Model/Repository/InvoicingDetailRepository.php b/sources/AppBundle/Accounting/Model/Repository/InvoicingDetailRepository.php deleted file mode 100644 index be9496450..000000000 --- a/sources/AppBundle/Accounting/Model/Repository/InvoicingDetailRepository.php +++ /dev/null @@ -1,101 +0,0 @@ - - */ -class InvoicingDetailRepository extends Repository implements MetadataInitializer -{ - public function getRowsIdsPerInvoicingId(int $invoicingId): array - { - $query = $this->getQuery( - 'SELECT id FROM afup_compta_facture_details WHERE idafup_compta_facture = :invoicingId', - )->setParams(['invoicingId' => $invoicingId]); - - $result = []; - foreach ($query->query($this->getCollection(new HydratorArray())) as $row) { - $result[] = $row['id']; - } - - return $result; - } - - /** - * @param int[] $ids - * @return void - */ - public function removeRowsPerIds(array $ids): void - { - $params = []; - $placeholders = []; - foreach (array_values($ids) as $i => $id) { - $key = 'id' . $i; - $placeholders[] = ':' . $key; - $params[$key] = (int) $id; - } - $query = sprintf('DELETE FROM %s WHERE id IN (%s)', $this->getMetadata()->getTable(), implode(', ', $placeholders)); - $this->getQuery($query)->setParams($params)->execute(); - } - - public static function initMetadata(SerializerFactoryInterface $serializerFactory, array $options = []) - { - $metadata = new Metadata($serializerFactory); - - $metadata->setEntity(InvoicingDetail::class); - $metadata->setConnectionName('main'); - $metadata->setDatabase($options['database']); - $metadata->setTable('afup_compta_facture_details'); - - $metadata - ->addField([ - 'columnName' => 'id', - 'fieldName' => 'id', - 'primary' => true, - 'autoincrement' => true, - 'type' => 'int', - ]) - ->addField([ - 'columnName' => 'idafup_compta_facture', - 'fieldName' => 'invoicingId', - 'type' => 'int', - ]) - ->addField([ - 'columnName' => 'ref', - 'fieldName' => 'reference', - 'type' => 'string', - ]) - ->addField([ - 'columnName' => 'designation', - 'fieldName' => 'designation', - 'type' => 'string', - ]) - ->addField([ - 'columnName' => 'quantite', - 'fieldName' => 'quantity', - 'type' => 'float', - ]) - ->addField([ - 'columnName' => 'pu', - 'fieldName' => 'unitPrice', - 'type' => 'float', - ]) - ->addField([ - 'columnName' => 'tva', - 'fieldName' => 'tva', - 'type' => 'float', - ]) - ; - - return $metadata; - } -} diff --git a/sources/AppBundle/Accounting/Model/Repository/InvoicingPeriodRepository.php b/sources/AppBundle/Accounting/Model/Repository/InvoicingPeriodRepository.php deleted file mode 100644 index f88f12664..000000000 --- a/sources/AppBundle/Accounting/Model/Repository/InvoicingPeriodRepository.php +++ /dev/null @@ -1,94 +0,0 @@ - - */ -class InvoicingPeriodRepository extends Repository implements MetadataInitializer -{ - public function getCurrentPeriod(?int $periodId = null): InvoicingPeriod - { - if ($periodId !== null) { - return $this->get($periodId); - } - - $startDate = new DateTime(date("Y") . "-01-01"); - $endDate = new DateTime(date("Y") . "-12-31"); - $period = $this->getOneBy([ - 'startDate' => $startDate->format('Y-m-d'), - 'endDate' => $endDate->format('Y-m-d'), - ]); - - if (!$period instanceof InvoicingPeriod) { - $period = new InvoicingPeriod(); - $period->setStartDate($startDate); - $period->setEndDate($endDate); - $this->save($period); - $period = $this->getOneBy([ - 'startDate' => $startDate->format('Y-m-d'), - 'endDate' => $endDate->format('Y-m-d'), - ]); - } - - return $period; - } - - public static function initMetadata(SerializerFactoryInterface $serializerFactory, array $options = []) - { - $metadata = new Metadata($serializerFactory); - - $metadata->setEntity(InvoicingPeriod::class); - $metadata->setConnectionName('main'); - $metadata->setDatabase($options['database']); - $metadata->setTable('compta_periode'); - - $metadata - ->addField([ - 'columnName' => 'id', - 'fieldName' => 'id', - 'primary' => true, - 'autoincrement' => true, - 'type' => 'int', - ]) - ->addField([ - 'columnName' => 'date_debut', - 'fieldName' => 'startDate', - 'type' => 'datetime', - 'serializer' => \CCMBenchmark\Ting\Serializer\DateTime::class, - 'serializer_options' => [ - 'serialize' => ['format' => 'Y-m-d'], - 'unserialize' => ['format' => 'Y-m-d', 'unSerializeUseFormat' => true], - ], - ]) - ->addField([ - 'columnName' => 'date_fin', - 'fieldName' => 'endDate', - 'type' => 'datetime', - 'serializer' => \CCMBenchmark\Ting\Serializer\DateTime::class, - 'serializer_options' => [ - 'serialize' => ['format' => 'Y-m-d'], - 'unserialize' => ['format' => 'Y-m-d', 'unSerializeUseFormat' => true], - ], - ]) - ->addField([ - 'columnName' => 'verouiller', - 'fieldName' => 'locked', - 'type' => 'bool', - 'serializer' => Boolean::class, - ]) - ; - - return $metadata; - } -} diff --git a/sources/AppBundle/Accounting/Model/Repository/InvoicingRepository.php b/sources/AppBundle/Accounting/Model/Repository/InvoicingRepository.php deleted file mode 100644 index 8ffdcafc6..000000000 --- a/sources/AppBundle/Accounting/Model/Repository/InvoicingRepository.php +++ /dev/null @@ -1,322 +0,0 @@ - - */ -class InvoicingRepository extends Repository implements MetadataInitializer -{ - public function getById(int $id): ?Invoicing - { - return $this->findOneWithDetails('acf.id = :id', ['id' => $id]); - } - - public function getQuotationsByPeriodId(?int $periodId = null, string $sort = 'date', string $direction = 'desc'): CollectionInterface - { - $filter = 'acf.date_devis'; - if ($sort === 'client') { - $filter = 'acf.societe'; - } - - /** @var Select $builder */ - $builder = $this->getQueryBuilder(self::QUERY_SELECT); - $builder->cols(['*', 'sum(acfd.quantite * acfd.pu) as price']) - ->from('afup_compta_facture acf') - ->leftJoin('afup_compta_facture_details acfd', 'acfd.idafup_compta_facture = acf.id') - ->where('acf.numero_devis != ""'); - - if ($periodId !== null && $periodId !== 0) { - $builder->where('acf.date_devis >= (select date_debut from compta_periode where id = :periodId)') - ->where('acf.date_devis <= (select date_fin from compta_periode where id = :periodId)') - ->bindValues(['periodId' => $periodId]); - } - $builder->groupBy(['acf.id', 'date_devis', 'numero_devis', 'date_facture', 'numero_facture', 'societe', 'adresse', 'code_postal', 'ville', 'id_pays', 'email', 'observation', 'ref_clt1', 'ref_clt2', 'ref_clt3', 'nom', 'prenom', 'tel', 'etat_paiement', 'date_paiement', 'devise_facture']) - ->orderBy(["$filter $direction"]); - - $hydrator = new HydratorSingleObject(); - $hydrator->mapAliasTo('price', 'acf', 'setPrice'); - - - return $this->getQuery($builder->getStatement()) - ->setParams($builder->getBindValues()) - ->query($this->getCollection($hydrator)); - } - - public function getInvoicesByPeriodId(?int $periodId = null, string $sort = 'date', string $direction = 'desc'): CollectionInterface - { - $filter = 'acf.date_facture'; - if ($sort === 'client') { - $filter = 'acf.societe'; - } - - /** @var Select $builder */ - $builder = $this->getQueryBuilder(self::QUERY_SELECT); - $builder->cols(['*', 'sum(acfd.quantite * acfd.pu) as price']) - ->from('afup_compta_facture acf') - ->leftJoin('afup_compta_facture_details acfd', 'acfd.idafup_compta_facture = acf.id') - ->where('acf.numero_facture != ""'); - - if ($periodId !== null && $periodId !== 0) { - $builder->where('acf.date_facture >= (select date_debut from compta_periode where id = :periodId)') - ->where('acf.date_facture <= (select date_fin from compta_periode where id = :periodId)') - ->bindValues(['periodId' => $periodId]); - } - $builder->groupBy(['acf.id', 'date_devis', 'numero_devis', 'date_facture', 'numero_facture', 'societe', 'adresse', 'code_postal', 'ville', 'id_pays', 'email', 'observation', 'ref_clt1', 'ref_clt2', 'ref_clt3', 'nom', 'prenom', 'tel', 'etat_paiement', 'date_paiement', 'devise_facture']) - ->orderBy(["$filter $direction"]); - - $hydrator = new HydratorSingleObject(); - $hydrator->mapAliasTo('price', 'acf', 'setPrice'); - - - return $this->getQuery($builder->getStatement()) - ->setParams($builder->getBindValues()) - ->query($this->getCollection($hydrator)); - } - - public function getOneByInvoiceNumber(string $number): ?Invoicing - { - return $this->findOneWithDetails('acf.numero_facture = :number', ['number' => $number]); - } - - public function getOneByQuotationNumber(string $number): ?Invoicing - { - return $this->findOneWithDetails('acf.numero_devis = :number', ['number' => $number]); - } - - public function getNextInvoiceIndex(int $year): ?int - { - $sql = 'SELECT MAX(CAST(SUBSTRING_INDEX(numero_facture, \'-\', -1) AS UNSIGNED)) + 1 AS next_index - FROM afup_compta_facture - WHERE LEFT(numero_facture, 4) = :year'; - - $rows = iterator_to_array( - $this->getQuery($sql)->setParams(['year' => (string) $year])->query($this->getCollection(new HydratorArray())), - ); - - return isset($rows[0]['next_index']) ? (int) $rows[0]['next_index'] : null; - } - - public function getNextQuotationIndex(int $year): ?int - { - $sql = 'SELECT MAX(CAST(SUBSTRING_INDEX(numero_devis, \'-\', -1) AS UNSIGNED)) + 1 AS next_index - FROM afup_compta_facture - WHERE LEFT(numero_devis, 4) = :year'; - - $rows = iterator_to_array( - $this->getQuery($sql)->setParams(['year' => (string) $year])->query($this->getCollection(new HydratorArray())), - ); - - return isset($rows[0]['next_index']) ? (int) $rows[0]['next_index'] : null; - } - - public function convertQuotationToInvoice(Invoicing $quotation, string $invoiceNumber): void - { - $quotation->setInvoiceNumber($invoiceNumber); - $quotation->setInvoiceDate(new \DateTime()); - $this->save($quotation); - } - - private function findOneWithDetails(string $whereClause, array $params): ?Invoicing - { - /** @var Select $builder */ - $builder = $this->getQueryBuilder(self::QUERY_SELECT); - $builder->cols(['acf.*', 'acfd.*']) - ->from('afup_compta_facture acf') - ->leftJoin('afup_compta_facture_details acfd', 'acfd.idafup_compta_facture = acf.id') - ->where($whereClause); - - $hydrator = new HydratorRelational(); - $hydrator->addRelation(new RelationMany(new AggregateFrom('acfd'), new AggregateTo('acf'), 'setDetails')); - $hydrator->callableFinalizeAggregate(fn(array $row) => $row['acf']); - - $collection = $this->getQuery($builder->getStatement()) - ->setParams($params) - ->query($this->getCollection($hydrator)); - - if ($collection->count() === 0) { - return null; - } - - /** @var Invoicing $entity */ - $entity = $collection->first(); - $entity->setDetails(array_values($entity->getDetails())); - - return $entity; - } - - public static function initMetadata(SerializerFactoryInterface $serializerFactory, array $options = []) - { - $metadata = new Metadata($serializerFactory); - - $metadata->setEntity(Invoicing::class); - $metadata->setConnectionName('main'); - $metadata->setDatabase($options['database']); - $metadata->setTable('afup_compta_facture'); - - $metadata - ->addField([ - 'columnName' => 'id', - 'fieldName' => 'id', - 'primary' => true, - 'autoincrement' => true, - 'type' => 'int', - ]) - ->addField([ - 'columnName' => 'date_devis', - 'fieldName' => 'quotationDate', - 'type' => 'date', - 'serializer' => DateTime::class, - 'serializer_options' => [ - 'serialize' => ['format' => 'Y-m-d'], - 'unserialize' => ['format' => 'Y-m-d', 'unSerializeUseFormat' => true], - ], - ]) - ->addField([ - 'columnName' => 'numero_devis', - 'fieldName' => 'quotationNumber', - 'type' => 'string', - ]) - ->addField([ - 'columnName' => 'date_facture', - 'fieldName' => 'invoiceDate', - 'type' => 'date', - 'serializer' => DateTime::class, - 'serializer_options' => [ - 'serialize' => ['format' => 'Y-m-d'], - 'unserialize' => ['format' => 'Y-m-d', 'unSerializeUseFormat' => true], - ], - ]) - ->addField([ - 'columnName' => 'numero_facture', - 'fieldName' => 'invoiceNumber', - 'type' => 'string', - ]) - ->addField([ - 'columnName' => 'societe', - 'fieldName' => 'company', - 'type' => 'string', - ]) - ->addField([ - 'columnName' => 'service', - 'fieldName' => 'service', - 'type' => 'string', - ]) - ->addField([ - 'columnName' => 'adresse', - 'fieldName' => 'address', - 'type' => 'string', - ]) - ->addField([ - 'columnName' => 'code_postal', - 'fieldName' => 'zipcode', - 'type' => 'string', - ]) - ->addField([ - 'columnName' => 'ville', - 'fieldName' => 'city', - 'type' => 'string', - ]) - ->addField([ - 'columnName' => 'id_pays', - 'fieldName' => 'countryId', - 'type' => 'string', - ]) - ->addField([ - 'columnName' => 'email', - 'fieldName' => 'email', - 'type' => 'string', - ]) - ->addField([ - 'columnName' => 'tva_intra', - 'fieldName' => 'tvaIntra', - 'type' => 'string', - ]) - ->addField([ - 'columnName' => 'observation', - 'fieldName' => 'observation', - 'type' => 'string', - ]) - ->addField([ - 'columnName' => 'ref_clt1', - 'fieldName' => 'refClt1', - 'type' => 'string', - ]) - ->addField([ - 'columnName' => 'ref_clt2', - 'fieldName' => 'refClt2', - 'type' => 'string', - ]) - ->addField([ - 'columnName' => 'ref_clt3', - 'fieldName' => 'refClt3', - 'type' => 'string', - ]) - ->addField([ - 'columnName' => 'nom', - 'fieldName' => 'lastname', - 'type' => 'string', - ]) - ->addField([ - 'columnName' => 'prenom', - 'fieldName' => 'firstname', - 'type' => 'string', - ]) - ->addField([ - 'columnName' => 'tel', - 'fieldName' => 'phone', - 'type' => 'string', - ]) - ->addField([ - 'columnName' => 'etat_paiement', - 'fieldName' => 'paymentStatus', - 'type' => 'enum', - 'serializer' => BackedEnum::class, - 'serializer_options' => [ - 'unserialize' => ['enum' => InvoicingPaymentStatus::class], - ], - ]) - ->addField([ - 'columnName' => 'date_paiement', - 'fieldName' => 'paymentDate', - 'type' => 'date', - 'serializer' => DateTime::class, - 'serializer_options' => [ - 'serialize' => ['format' => 'Y-m-d'], - 'unserialize' => ['format' => 'Y-m-d', 'unSerializeUseFormat' => true], - ], - ]) - ->addField([ - 'columnName' => 'devise_facture', - 'fieldName' => 'currency', - 'type' => 'enum', - 'serializer' => BackedEnum::class, - 'serializer_options' => [ - 'unserialize' => ['enum' => InvoicingCurrency::class], - ], - ]) - ; - - return $metadata; - } -} diff --git a/sources/AppBundle/Accounting/Model/Repository/TransactionRepository.php b/sources/AppBundle/Accounting/Model/Repository/TransactionRepository.php deleted file mode 100644 index 799be5219..000000000 --- a/sources/AppBundle/Accounting/Model/Repository/TransactionRepository.php +++ /dev/null @@ -1,244 +0,0 @@ - - */ -class TransactionRepository extends Repository implements MetadataInitializer -{ - public function getNextTransaction(int $transactionId): ?Transaction - { - $query = $this->getQuery('SELECT * FROM compta WHERE (idcategorie = :undeterminedCategoryId OR idevenement = :undeterminedEventId) AND id > :transactionId ORDER BY id ASC LIMIT 1'); - $query->setParams(['transactionId' => $transactionId, 'undeterminedCategoryId' => AutoQualifier::DEFAULT_CATEGORIE, 'undeterminedEventId' => AutoQualifier::DEFAULT_EVENEMENT]); - $collection = $query->query($this->getCollection(new HydratorSingleObject())); - if ($collection->count() > 0) { - return $collection->first(); - } - - return null; - } - - public function getEntriesPerInvoicingPeriod(InvoicingPeriod $period, bool $onlyUnclasifedEntries, int $operationType = 0) - { - - $filtre = $operationType === 1 || $operationType === 2 ? 'AND compta.idoperation =\'' . $operationType . '\' ' : ""; - - $requete = 'SELECT '; - $requete .= 'compta.date_ecriture, compta.description, compta.montant, compta.idoperation,compta.id as idtmp, '; - $requete .= 'compta.comment, compta.attachment_required, compta.attachment_filename, '; - $requete .= 'compta_reglement.reglement, '; - $requete .= 'compta_evenement.evenement, '; - $requete .= 'compta_categorie.categorie, '; - $requete .= 'compta_compte.nom_compte, '; - $requete .= '(COALESCE(compta.montant_ht_soumis_tva_0,0) + COALESCE(compta.montant_ht_soumis_tva_5_5,0) + COALESCE(compta.montant_ht_soumis_tva_10, 0) + COALESCE(compta.montant_ht_soumis_tva_20, 0)) as montant_ht, '; - $requete .= '((COALESCE(compta.montant_ht_soumis_tva_5_5, 0)*0.055) + (COALESCE(compta.montant_ht_soumis_tva_10, 0)*0.1) + (COALESCE(compta.montant_ht_soumis_tva_20, 0)*0.2)) as montant_tva, '; - $requete .= 'compta.montant_ht_soumis_tva_0 as montant_ht_0, '; - $requete .= 'compta.montant_ht_soumis_tva_5_5 as montant_ht_5_5, '; - $requete .= 'compta.montant_ht_soumis_tva_5_5*0.055 as montant_tva_5_5, '; - $requete .= 'compta.montant_ht_soumis_tva_10 as montant_ht_10, '; - $requete .= 'compta.montant_ht_soumis_tva_10*0.1 as montant_tva_10, '; - $requete .= 'compta.montant_ht_soumis_tva_20 as montant_ht_20, '; - $requete .= 'compta.montant_ht_soumis_tva_20*0.2 as montant_tva_20, '; - $requete .= 'compta.tva_zone '; - $requete .= 'FROM '; - $requete .= 'compta '; - $requete .= 'LEFT JOIN '; - $requete .= 'compta_categorie on compta_categorie.id=compta.idcategorie '; - $requete .= 'LEFT JOIN '; - $requete .= 'compta_reglement on compta_reglement.id=compta.idmode_regl '; - $requete .= 'LEFT JOIN '; - $requete .= 'compta_evenement on compta_evenement.id=compta.idevenement '; - $requete .= 'LEFT JOIN '; - $requete .= 'compta_compte on compta_compte.id=compta.idcompte '; - $requete .= 'WHERE '; - $requete .= ' compta.date_ecriture >= \'' . $period->getStartDate()->format('Y-m-d') . '\' '; - $requete .= 'AND compta.date_ecriture <= \'' . $period->getEndDate()->format('Y-m-d') . '\' '; - $requete .= $filtre; - if (true === $onlyUnclasifedEntries) { - $requete .= ' AND ( - compta_evenement.evenement = "A déterminer" - OR - compta_categorie.categorie = "A déterminer" - OR - compta_reglement.reglement = "A déterminer" - OR - (compta.attachment_required = 1 AND compta.attachment_filename IS NULL) - ) '; - } - $requete .= 'ORDER BY '; - $requete .= 'compta.date_ecriture, numero_operation'; - - $query = $this->getQuery($requete); - - return $query->query($this->getCollection(new HydratorArray())); - } - - public static function initMetadata(SerializerFactoryInterface $serializerFactory, array $options = []) - { - $metadata = new Metadata($serializerFactory); - - $metadata->setEntity(Transaction::class); - $metadata->setConnectionName('main'); - $metadata->setDatabase($options['database']); - $metadata->setTable('compta'); - - $metadata - ->addField([ - 'columnName' => 'id', - 'fieldName' => 'id', - 'primary' => true, - 'autoincrement' => true, - 'type' => 'int', - ]) - ->addField([ - 'columnName' => 'idclef', - 'fieldName' => 'idKey', - 'type' => 'string', - ]) - - ->addField([ - 'columnName' => 'idoperation', - 'fieldName' => 'operationId', - 'type' => 'int', - ]) - ->addField([ - 'columnName' => 'idcategorie', - 'fieldName' => 'categoryId', - 'type' => 'int', - ]) - ->addField([ - 'columnName' => 'date_ecriture', - 'fieldName' => 'accountingDate', - 'type' => 'date', - 'serializer' => DateTime::class, - 'serializer_options' => [ - 'serialize' => ['format' => 'Y-m-d'], - 'unserialize' => ['format' => 'Y-m-d', 'unSerializeUseFormat' => true], - ], - ]) - ->addField([ - 'columnName' => 'numero_operation', - 'fieldName' => 'operationNumber', - 'type' => 'string', - ]) - ->addField([ - 'columnName' => 'nom_frs', - 'fieldName' => 'vendorName', - 'type' => 'string', - ]) - ->addField([ - 'columnName' => 'tva_intra', - 'fieldName' => 'tvaIntra', - 'type' => 'string', - ]) - ->addField([ - 'columnName' => 'tva_zone', - 'fieldName' => 'tvaZone', - 'type' => 'enum', - 'serializer' => BackedEnum::class, - 'serializer_options' => [ - 'unserialize' => ['enum' => TvaZone::class], - ], - ]) - ->addField([ - 'columnName' => 'montant', - 'fieldName' => 'amount', - 'type' => 'float', - ]) - ->addField([ - 'columnName' => 'description', - 'fieldName' => 'description', - 'type' => 'string', - ]) - ->addField([ - 'columnName' => 'comment', - 'fieldName' => 'comment', - 'type' => 'string', - ]) - ->addField([ - 'columnName' => 'attachment_required', - 'fieldName' => 'attachmentRequired', - 'type' => 'booleab', - 'default' => false, - ]) - ->addField([ - 'columnName' => 'attachment_filename', - 'fieldName' => 'attachmentFilename', - 'type' => 'string', - ]) - ->addField([ - 'columnName' => 'numero', - 'fieldName' => 'number', - 'type' => 'string', - ]) - ->addField([ - 'columnName' => 'idmode_regl', - 'fieldName' => 'paymentTypeId', - 'type' => 'int', - ]) - ->addField([ - 'columnName' => 'date_regl', - 'fieldName' => 'paymentDate', - 'type' => 'date', - 'serializer' => DateTime::class, - 'serializer_options' => [ - 'serialize' => ['format' => 'Y-m-d'], - 'unserialize' => ['format' => 'Y-m-d', 'unSerializeUseFormat' => true], - ], - ]) - ->addField([ - 'columnName' => 'obs_regl', - 'fieldName' => 'paymentComment', - 'type' => 'string', - ]) - ->addField([ - 'columnName' => 'idevenement', - 'fieldName' => 'eventId', - 'type' => 'int', - ]) - ->addField([ - 'columnName' => 'idcompte', - 'fieldName' => 'accountId', - 'type' => 'int', - ]) - ->addField([ - 'columnName' => 'montant_ht_soumis_tva_20', - 'fieldName' => 'amountTva20', - 'type' => 'flaot', - ]) - ->addField([ - 'columnName' => 'montant_ht_soumis_tva_10', - 'fieldName' => 'amountTva10', - 'type' => 'flaot', - ]) - ->addField([ - 'columnName' => 'montant_ht_soumis_tva_5_5', - 'fieldName' => 'amountTva5_5', - 'type' => 'flaot', - ]) - ->addField([ - 'columnName' => 'montant_ht_soumis_tva_0', - 'fieldName' => 'amountTva0', - 'type' => 'flaot', - ]) - ; - - return $metadata; - } -} diff --git a/sources/AppBundle/Accounting/Model/Transaction.php b/sources/AppBundle/Accounting/Model/Transaction.php deleted file mode 100644 index 979923049..000000000 --- a/sources/AppBundle/Accounting/Model/Transaction.php +++ /dev/null @@ -1,357 +0,0 @@ -accountingDate = new DateTime(); - $this->paymentDate = new DateTime(); - } - - public function getId(): ?int - { - return $this->id; - } - - public function setId(int $id): self - { - $this->propertyChanged('id', $this->id, $id); - $this->id = $id; - return $this; - } - - public function getIdKey(): ?string - { - return $this->idKey; - } - - public function setIdKey(?string $idKey): self - { - $this->propertyChanged('name', $this->idKey, $idKey); - $this->idKey = $idKey; - - return $this; - } - - public function getOperationId(): ?int - { - return $this->operationId; - } - - public function setOperationId(?int $operationId): self - { - $this->propertyChanged('operationId', $this->operationId, $operationId); - $this->operationId = $operationId; - - return $this; - } - - public function getCategoryId(): ?int - { - return $this->categoryId; - } - - public function setCategoryId(?int $categoryId): self - { - $this->propertyChanged('categoryId', $this->categoryId, $categoryId); - $this->categoryId = $categoryId; - - return $this; - } - - public function getAccountingDate(): ?DateTime - { - return $this->accountingDate; - } - - public function setAccountingDate(?DateTime $accountingDate): self - { - $this->propertyChanged('accountingDate', $this->accountingDate, $accountingDate); - $this->accountingDate = $accountingDate; - - return $this; - } - - public function getOperationNumber(): ?string - { - return $this->operationNumber; - } - - public function setOperationNumber(?string $operationNumber): self - { - $this->propertyChanged('operationNumber', $this->operationNumber, $operationNumber); - $this->operationNumber = $operationNumber; - - return $this; - } - - public function getVendorName(): string - { - return $this->vendorName; - } - - public function setVendorName(string $vendorName): self - { - $this->propertyChanged('vendorName', $this->vendorName, $vendorName); - $this->vendorName = $vendorName; - - return $this; - } - - public function getTvaIntra(): ?string - { - return $this->tvaIntra; - } - - public function setTvaIntra(?string $tvaIntra): self - { - $this->propertyChanged('tvaIntra', $this->tvaIntra, $tvaIntra); - $this->tvaIntra = $tvaIntra; - - return $this; - } - - public function getTvaZone(): ?TvaZone - { - return $this->tvaZone; - } - - public function setTvaZone(?TvaZone $tvaZone): self - { - $this->propertyChanged('tvaZone', $this->tvaZone, $tvaZone); - $this->tvaZone = $tvaZone; - - 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 getDescription(): string - { - return $this->description; - } - - public function setDescription(string $description): self - { - $this->propertyChanged('description', $this->description, $description); - $this->description = $description; - - return $this; - } - - public function getComment(): ?string - { - return $this->comment; - } - - public function setComment(?string $comment): self - { - $this->propertyChanged('comment', $this->comment, $comment); - $this->comment = $comment; - - return $this; - } - - public function isAttachmentRequired(): bool - { - return $this->attachmentRequired; - } - - public function setAttachmentRequired(bool $attachmentRequired): self - { - $this->propertyChanged('attachmentRequired', $this->attachmentRequired, $attachmentRequired); - $this->attachmentRequired = $attachmentRequired; - - return $this; - } - - public function getAttachmentFilename(): ?string - { - return $this->attachmentFilename; - } - - public function setAttachmentFilename(?string $attachmentFilename): self - { - $this->propertyChanged('attachmentFilename', $this->attachmentFilename, $attachmentFilename); - $this->attachmentFilename = $attachmentFilename; - - return $this; - } - - public function getNumber(): string - { - return $this->number; - } - - public function setNumber(string $number): self - { - $this->propertyChanged('number', $this->number, $number); - $this->number = $number; - - return $this; - } - - public function getPaymentTypeId(): ?int - { - return $this->paymentTypeId; - } - - public function setPaymentTypeId(?int $paymentTypeId): self - { - $this->propertyChanged('paymentTypeId', $this->paymentTypeId, $paymentTypeId); - $this->paymentTypeId = $paymentTypeId; - - return $this; - } - - public function getPaymentDate(): ?DateTime - { - return $this->paymentDate; - } - - public function setPaymentDate(?DateTime $paymentDate): self - { - $this->propertyChanged('paymentDate', $this->paymentDate, $paymentDate); - $this->paymentDate = $paymentDate; - - return $this; - } - - public function getPaymentComment(): ?string - { - return $this->paymentComment; - } - - public function setPaymentComment(?string $paymentComment): self - { - $this->propertyChanged('paymentComment', $this->paymentComment, $paymentComment); - $this->paymentComment = $paymentComment; - - return $this; - } - - public function getEventId(): ?int - { - return $this->eventId; - } - - public function setEventId(?int $eventId): self - { - $this->propertyChanged('eventId', $this->eventId, $eventId); - $this->eventId = $eventId; - - return $this; - } - - public function getAccountId(): ?int - { - return $this->accountId; - } - - public function setAccountId(?int $accountId): self - { - $this->propertyChanged('accountId', $this->accountId, $accountId); - $this->accountId = $accountId; - - return $this; - } - - public function getAmountTva20(): ?float - { - return $this->amountTva20; - } - - public function setAmountTva20(?float $amountTva20): self - { - $this->propertyChanged('amountTva20', $this->amountTva20, $amountTva20); - $this->amountTva20 = $amountTva20; - - return $this; - } - - public function getAmountTva10(): ?float - { - return $this->amountTva10; - } - - public function setAmountTva10(?float $amountTva10): self - { - $this->propertyChanged('amountTva10', $this->amountTva10, $amountTva10); - $this->amountTva10 = $amountTva10; - - return $this; - } - - public function getAmountTva55(): ?float - { - return $this->amountTva5_5; - } - - public function setAmountTva55(?float $amountTva5_5): self - { - $this->propertyChanged('amountTva5_5', $this->amountTva5_5, $amountTva5_5); - $this->amountTva5_5 = $amountTva5_5; - - return $this; - } - - public function getAmountTva0(): ?float - { - return $this->amountTva0; - } - - public function setAmountTva0(?float $amountTva0): self - { - $this->propertyChanged('amountTva0', $this->amountTva0, $amountTva0); - $this->amountTva0 = $amountTva0; - - return $this; - } -} diff --git a/sources/AppBundle/Accounting/TransactionModification.php b/sources/AppBundle/Accounting/TransactionModification.php index f2fc252b9..159d39500 100644 --- a/sources/AppBundle/Accounting/TransactionModification.php +++ b/sources/AppBundle/Accounting/TransactionModification.php @@ -4,7 +4,10 @@ namespace AppBundle\Accounting; -use AppBundle\Accounting\Model\Transaction; +use AppBundle\Accounting\Entity\Repository\CategoryRepository; +use AppBundle\Accounting\Entity\Repository\EventRepository; +use AppBundle\Accounting\Entity\Repository\PaymentRepository; +use AppBundle\Accounting\Entity\Transaction; enum TransactionModification: string { @@ -14,14 +17,19 @@ enum TransactionModification: string case Comment = 'comment'; case RequiredAttachment = 'requiredAttachment'; - public function setValue(Transaction $transaction, mixed $value): void - { + public function setValue( + Transaction $transaction, + mixed $value, + CategoryRepository $categoryRepository, + PaymentRepository $paymentRepository, + EventRepository $eventRepository, + ): void { match ($this) { - self::Category => $transaction->setCategoryId((int) $value), - self::PaymentType => $transaction->setPaymentTypeId((int) $value), - self::Event => $transaction->setEventId((int) $value), - self::Comment => $transaction->setComment($value), - self::RequiredAttachment => $transaction->setAttachmentRequired((bool) $value), + self::Category => $transaction->categorie = $categoryRepository->find((int) $value), + self::PaymentType => $transaction->modeReglement = $paymentRepository->find((int) $value), + self::Event => $transaction->evenement = $eventRepository->find((int) $value), + self::Comment => $transaction->commentaire = $value, + self::RequiredAttachment => $transaction->justificatifRequis = (bool) $value, }; } diff --git a/sources/AppBundle/Compta/CsvExtractor.php b/sources/AppBundle/Compta/CsvExtractor.php index 9c5a7187a..137b85ad4 100644 --- a/sources/AppBundle/Compta/CsvExtractor.php +++ b/sources/AppBundle/Compta/CsvExtractor.php @@ -4,9 +4,14 @@ namespace AppBundle\Compta; +use AppBundle\Accounting\Entity\Repository\AccountRepository; +use AppBundle\Accounting\Entity\Repository\CategoryRepository; +use AppBundle\Accounting\Entity\Repository\EventRepository; +use AppBundle\Accounting\Entity\Repository\OperationRepository; +use AppBundle\Accounting\Entity\Repository\PaymentRepository; use AppBundle\Accounting\Entity\Repository\RuleRepository; -use AppBundle\Accounting\Model\Repository\TransactionRepository; -use AppBundle\Accounting\Model\Transaction; +use AppBundle\Accounting\Entity\Repository\TransactionRepository; +use AppBundle\Accounting\Entity\Transaction; use AppBundle\Compta\Importer\AutoQualifier; use AppBundle\Compta\Importer\Importer; @@ -15,6 +20,11 @@ class CsvExtractor public function __construct( private readonly RuleRepository $ruleRepository, private readonly TransactionRepository $transactionRepository, + private readonly OperationRepository $operationRepository, + private readonly AccountRepository $accountRepository, + private readonly CategoryRepository $categoryRepository, + private readonly PaymentRepository $paymentRepository, + private readonly EventRepository $eventRepository, ) {} public function extract(Importer $importer): bool @@ -29,43 +39,43 @@ public function extract(Importer $importer): bool foreach ($importer->extract() as $operation) { $numero_operation = $operation->numeroOperation; // On vérife si l'enregistrement existe déjà - $enregistrement = $this->transactionRepository->getOneBy(['operationNumber' => $numero_operation]); + $enregistrement = $this->transactionRepository->findOneBy(['numeroOperation' => $numero_operation]); $operationQualified = $qualifier->qualify($operation); if (!$enregistrement instanceof Transaction) { $transaction = new Transaction(); - $transaction->setOperationId($operationQualified['idoperation']) - ->setAccountId($importer->getCompteId()) - ->setCategoryId($operationQualified['categorie']) - ->setAccountingDate(new \DateTime($operationQualified['date_ecriture'])) - ->setVendorName('') - ->setTvaIntra('') - ->setAmount($operationQualified['montant']) - ->setDescription($operationQualified['description']) - ->setNumber('') - ->setPaymentTypeId($operationQualified['idModeReglement']) - ->setPaymentComment('') - ->setEventId($operationQualified['evenement']) - ->setOperationNumber($numero_operation) - ->setAttachmentRequired($operationQualified['attachmentRequired']) - ->setAmountTva0($operationQualified['montant_ht_soumis_tva_0']) - ->setAmountTva55($operationQualified['montant_ht_soumis_tva_5_5']) - ->setAmountTva10($operationQualified['montant_ht_soumis_tva_10']) - ->setAmountTva20($operationQualified['montant_ht_soumis_tva_20']); + $transaction->operation = $this->operationRepository->find($operationQualified['idoperation']); + $transaction->compte = $this->accountRepository->find($importer->getCompteId()); + $transaction->categorie = $this->categoryRepository->find($operationQualified['categorie']); + $transaction->dateEcriture = new \DateTime($operationQualified['date_ecriture']); + $transaction->nomFournisseur = ''; + $transaction->tvaIntra = ''; + $transaction->montant = $operationQualified['montant']; + $transaction->description = $operationQualified['description']; + $transaction->numero = ''; + $transaction->modeReglement = $this->paymentRepository->find($operationQualified['idModeReglement']); + $transaction->commentaireReglement = ''; + $transaction->evenement = $this->eventRepository->find($operationQualified['evenement']); + $transaction->numeroOperation = $numero_operation; + $transaction->justificatifRequis = $operationQualified['attachmentRequired']; + $transaction->montantTva0 = $operationQualified['montant_ht_soumis_tva_0']; + $transaction->montantTva5_5 = $operationQualified['montant_ht_soumis_tva_5_5']; + $transaction->montantTva10 = $operationQualified['montant_ht_soumis_tva_10']; + $transaction->montantTva20 = $operationQualified['montant_ht_soumis_tva_20']; $this->transactionRepository->save($transaction); } else { $modifier = false; - if ($enregistrement->getCategoryId() == AutoQualifier::DEFAULT_CATEGORIE && $operationQualified['categorie'] != AutoQualifier::DEFAULT_CATEGORIE) { - $enregistrement->setCategoryId($operationQualified['categorie']); + if ($enregistrement->categorie?->id === AutoQualifier::DEFAULT_CATEGORIE && $operationQualified['categorie'] != AutoQualifier::DEFAULT_CATEGORIE) { + $enregistrement->categorie = $this->categoryRepository->find($operationQualified['categorie']); $modifier = true; } - if ($enregistrement->getEventId() == AutoQualifier::DEFAULT_EVENEMENT && $operationQualified['evenement'] != AutoQualifier::DEFAULT_EVENEMENT) { - $enregistrement->setEventId($operationQualified['evenement']); + if ($enregistrement->evenement?->id === AutoQualifier::DEFAULT_EVENEMENT && $operationQualified['evenement'] != AutoQualifier::DEFAULT_EVENEMENT) { + $enregistrement->evenement = $this->eventRepository->find($operationQualified['evenement']); $modifier = true; } if ($modifier) { - $enregistrement->setAccountId($importer->getCompteId()) - ->setAttachmentRequired($operationQualified['attachmentRequired']); + $enregistrement->compte = $this->accountRepository->find($importer->getCompteId()); + $enregistrement->justificatifRequis = $operationQualified['attachmentRequired']; $this->transactionRepository->save($enregistrement); } } diff --git a/sources/AppBundle/Controller/Admin/Accounting/Invoice/DownloadInvoiceAction.php b/sources/AppBundle/Controller/Admin/Accounting/Invoice/DownloadInvoiceAction.php index 8537169f6..d0c3e87fe 100644 --- a/sources/AppBundle/Controller/Admin/Accounting/Invoice/DownloadInvoiceAction.php +++ b/sources/AppBundle/Controller/Admin/Accounting/Invoice/DownloadInvoiceAction.php @@ -4,9 +4,9 @@ namespace AppBundle\Controller\Admin\Accounting\Invoice; +use AppBundle\Accounting\Entity\Invoicing; +use AppBundle\Accounting\Entity\Repository\InvoicingRepository; use AppBundle\Accounting\InvoicingPdfGenerator; -use AppBundle\Accounting\Model\Invoicing; -use AppBundle\Accounting\Model\Repository\InvoicingRepository; use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Response; diff --git a/sources/AppBundle/Controller/Admin/Accounting/Invoice/EditInvoiceAction.php b/sources/AppBundle/Controller/Admin/Accounting/Invoice/EditInvoiceAction.php index 364b043f6..805e7eb1c 100644 --- a/sources/AppBundle/Controller/Admin/Accounting/Invoice/EditInvoiceAction.php +++ b/sources/AppBundle/Controller/Admin/Accounting/Invoice/EditInvoiceAction.php @@ -4,9 +4,9 @@ namespace AppBundle\Controller\Admin\Accounting\Invoice; +use AppBundle\Accounting\Entity\Invoicing; +use AppBundle\Accounting\Entity\Repository\InvoicingRepository; use AppBundle\Accounting\Form\InvoiceType; -use AppBundle\Accounting\Model\Invoicing; -use AppBundle\Accounting\Model\Repository\InvoicingRepository; use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Response; @@ -31,7 +31,6 @@ public function __invoke(Request $request): Response $this->addFlash('success', 'L\'écriture a été modifiée'); return $this->redirectToRoute('admin_accounting_invoices_list'); } catch (\Exception) { - $this->invoicingRepository->rollback(); $this->addFlash('error', 'L\'écriture n\'a pas pu être enregistrée'); } } diff --git a/sources/AppBundle/Controller/Admin/Accounting/Invoice/ListInvoiceAction.php b/sources/AppBundle/Controller/Admin/Accounting/Invoice/ListInvoiceAction.php index 484557269..a8c3b6ea1 100644 --- a/sources/AppBundle/Controller/Admin/Accounting/Invoice/ListInvoiceAction.php +++ b/sources/AppBundle/Controller/Admin/Accounting/Invoice/ListInvoiceAction.php @@ -5,11 +5,11 @@ namespace AppBundle\Controller\Admin\Accounting\Invoice; use Afup\Site\Utils\Vat; +use AppBundle\Accounting\Entity\Invoicing; +use AppBundle\Accounting\Entity\Repository\InvoicingPeriodRepository; +use AppBundle\Accounting\Entity\Repository\InvoicingRepository; use AppBundle\Accounting\Form\InvoicingPeriodType; use AppBundle\Accounting\InvoicingPaymentStatus; -use AppBundle\Accounting\Model\Invoicing; -use AppBundle\Accounting\Model\Repository\InvoicingRepository; -use AppBundle\Accounting\Model\Repository\InvoicingPeriodRepository; use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Response; @@ -31,29 +31,29 @@ public function __invoke(Request $request): Response $direction = $request->query->get('direction', 'desc'); $sort = $request->query->get('sort', 'date'); - $invoices = $this->invoiceRepository->getInvoicesByPeriodId($period->getId(), $sort, $direction); - $periods = $this->invoicingPeriodRepository->getAll(); + $invoices = $this->invoiceRepository->getInvoicesByPeriodId($period->id, $sort, $direction); + $periods = $this->invoicingPeriodRepository->findAll(); $totalHt = 0; /** @var Invoicing $invoice */ foreach ($invoices as $invoice) { - if ($invoice->getPaymentStatus() === InvoicingPaymentStatus::Cancelled) { + if ($invoice->etatPaiement === InvoicingPaymentStatus::Cancelled) { continue; } - $totalHt += $invoice->getPrice(); + $totalHt += $invoice->prix; } return new Response($this->twig->render('admin/accounting/invoice/list.html.twig', [ 'lines' => $invoices, 'periods' => $periods, - 'periodId' => $period->getId(), + 'periodId' => $period->id, 'formPeriod' => $formPeriod->createView(), 'direction' => $direction, 'sort' => $sort, 'totalHt' => $totalHt, - 'isSubjectedToVat' => Vat::isSubjectedToVat($period->getEndDate()), + 'isSubjectedToVat' => Vat::isSubjectedToVat($period->dateFin), ])); } } diff --git a/sources/AppBundle/Controller/Admin/Accounting/Invoice/SendInvoiceEmailAction.php b/sources/AppBundle/Controller/Admin/Accounting/Invoice/SendInvoiceEmailAction.php index 1690914b6..657e171b8 100644 --- a/sources/AppBundle/Controller/Admin/Accounting/Invoice/SendInvoiceEmailAction.php +++ b/sources/AppBundle/Controller/Admin/Accounting/Invoice/SendInvoiceEmailAction.php @@ -4,8 +4,8 @@ namespace AppBundle\Controller\Admin\Accounting\Invoice; +use AppBundle\Accounting\Entity\Repository\InvoicingRepository; use AppBundle\Accounting\InvoicingMailer; -use AppBundle\Accounting\Model\Repository\InvoicingRepository; use AppBundle\AuditLog\Audit; use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; use Symfony\Component\HttpFoundation\Request; diff --git a/sources/AppBundle/Controller/Admin/Accounting/Journal/AddTransactionAction.php b/sources/AppBundle/Controller/Admin/Accounting/Journal/AddTransactionAction.php index 1953a7a18..9ddeda396 100644 --- a/sources/AppBundle/Controller/Admin/Accounting/Journal/AddTransactionAction.php +++ b/sources/AppBundle/Controller/Admin/Accounting/Journal/AddTransactionAction.php @@ -4,9 +4,10 @@ namespace AppBundle\Controller\Admin\Accounting\Journal; +use AppBundle\Accounting\Entity\Repository\AccountRepository; +use AppBundle\Accounting\Entity\Repository\TransactionRepository; +use AppBundle\Accounting\Entity\Transaction; use AppBundle\Accounting\Form\TransactionType; -use AppBundle\Accounting\Model\Repository\TransactionRepository; -use AppBundle\Accounting\Model\Transaction; use AppBundle\AuditLog\Audit; use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; use Symfony\Component\HttpFoundation\Request; @@ -16,20 +17,21 @@ class AddTransactionAction extends AbstractController { public function __construct( private readonly TransactionRepository $transactionRepository, + private readonly AccountRepository $accountRepository, private readonly Audit $audit, ) {} public function __invoke(Request $request): Response { $transaction = new Transaction(); - $transaction->setAccountId(1); // Compte courant + $transaction->compte = $this->accountRepository->find(1); // Compte courant $form = $this->createForm(TransactionType::class, $transaction); $form->handleRequest($request); if ($form->isSubmitted() && $form->isValid()) { $this->transactionRepository->save($transaction); $this->audit->log("Ajout d'une écriture"); $this->addFlash('notice', "L'écriture a été ajoutée"); - return $this->redirect('/admin/accounting/journal/list#L' . $transaction->getId()); + return $this->redirect('/admin/accounting/journal/list#L' . $transaction->id); } return $this->render('admin/accounting/journal/add.html.twig', [ diff --git a/sources/AppBundle/Controller/Admin/Accounting/Journal/AllocateAction.php b/sources/AppBundle/Controller/Admin/Accounting/Journal/AllocateAction.php index 2c3710545..0a5fc8891 100644 --- a/sources/AppBundle/Controller/Admin/Accounting/Journal/AllocateAction.php +++ b/sources/AppBundle/Controller/Admin/Accounting/Journal/AllocateAction.php @@ -4,48 +4,61 @@ namespace AppBundle\Controller\Admin\Accounting\Journal; -use AppBundle\Accounting\Model\Repository\TransactionRepository; -use AppBundle\Accounting\Model\Transaction; +use AppBundle\Accounting\Entity\Repository\CategoryRepository; +use AppBundle\Accounting\Entity\Repository\EventRepository; +use AppBundle\Accounting\Entity\Repository\TransactionRepository; +use AppBundle\Accounting\Entity\Transaction; +use AppBundle\Compta\Importer\AutoQualifier; use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; use Symfony\Component\HttpFoundation\RedirectResponse; use Symfony\Component\HttpFoundation\Request; class AllocateAction extends AbstractController { - public function __construct(private readonly TransactionRepository $transactionRepository) {} + public function __construct( + private readonly TransactionRepository $transactionRepository, + private readonly CategoryRepository $categoryRepository, + private readonly EventRepository $eventRepository, + ) {} public function __invoke(Request $request, int $id): RedirectResponse { - $transaction = $this->transactionRepository->get($id); + $transaction = $this->transactionRepository->find($id); + if (!$transaction instanceof Transaction) { + throw $this->createNotFoundException(); + } + $amountToallocate = $request->query->get('amount'); $totalAmount = 0; + $undeterminedCategory = $this->categoryRepository->find(AutoQualifier::DEFAULT_CATEGORIE); + $undeterminedEvent = $this->eventRepository->find(AutoQualifier::DEFAULT_EVENEMENT); + $lastId = null; foreach (explode(';', (string) $amountToallocate) as $amount) { $amount = (float) $amount; $newTransaction = new Transaction(); - $newTransaction->setOperationId($transaction->getOperationId()) - ->setAccountId($transaction->getAccountId()) - ->setCategoryId(26) // A déterminer - ->setAmount($amount) - ->setAccountingDate($transaction->getAccountingDate()) - ->setVendorName($transaction->getVendorName()) - ->setTvaIntra($transaction->getTvaIntra()) - ->setAmount($amount) - ->setDescription($transaction->getDescription()) - ->setNumber($transaction->getNumber()) - ->setPaymentTypeId($transaction->getPaymentTypeId()) - ->setPaymentDate($transaction->getPaymentDate()) - ->setComment($transaction->getComment()) - ->setEventId(8) // A déterminer - ->setOperationNumber($transaction->getOperationNumber()); + $newTransaction->operation = $transaction->operation; + $newTransaction->compte = $transaction->compte; + $newTransaction->categorie = $undeterminedCategory; + $newTransaction->montant = $amount; + $newTransaction->dateEcriture = $transaction->dateEcriture; + $newTransaction->nomFournisseur = $transaction->nomFournisseur; + $newTransaction->tvaIntra = $transaction->tvaIntra; + $newTransaction->description = $transaction->description; + $newTransaction->numero = $transaction->numero; + $newTransaction->modeReglement = $transaction->modeReglement; + $newTransaction->dateReglement = $transaction->dateReglement; + $newTransaction->commentaire = $transaction->commentaire; + $newTransaction->evenement = $undeterminedEvent; + $newTransaction->numeroOperation = $transaction->numeroOperation; $this->transactionRepository->save($newTransaction); - $lastId = $newTransaction->getId(); + $lastId = $newTransaction->id; $totalAmount += $amount; } - $transaction->setAmount($transaction->getAmount() - $totalAmount); + $transaction->montant -= $totalAmount; $this->transactionRepository->save($transaction); $this->addFlash('notice', "L'écriture a été ventilée"); diff --git a/sources/AppBundle/Controller/Admin/Accounting/Journal/DeleteAction.php b/sources/AppBundle/Controller/Admin/Accounting/Journal/DeleteAction.php index 65ab0014a..2c5eac9e3 100644 --- a/sources/AppBundle/Controller/Admin/Accounting/Journal/DeleteAction.php +++ b/sources/AppBundle/Controller/Admin/Accounting/Journal/DeleteAction.php @@ -4,8 +4,8 @@ namespace AppBundle\Controller\Admin\Accounting\Journal; -use AppBundle\Accounting\Model\Repository\TransactionRepository; -use AppBundle\Accounting\Model\Transaction; +use AppBundle\Accounting\Entity\Repository\TransactionRepository; +use AppBundle\Accounting\Entity\Transaction; use AppBundle\AuditLog\Audit; use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; use Symfony\Component\HttpFoundation\Request; @@ -20,7 +20,7 @@ public function __construct( public function __invoke(Request $request, int $id): Response { - $accounting = $this->transactionRepository->get($id); + $accounting = $this->transactionRepository->find($id); if (!$accounting instanceof Transaction) { $this->addFlash('error', "Une erreur est survenue lors de la suppression de l'écriture"); return $this->redirectToRoute('admin_accounting_journal_list'); diff --git a/sources/AppBundle/Controller/Admin/Accounting/Journal/DownloadAttachmentAction.php b/sources/AppBundle/Controller/Admin/Accounting/Journal/DownloadAttachmentAction.php index 338aa0d4b..4938d3e79 100644 --- a/sources/AppBundle/Controller/Admin/Accounting/Journal/DownloadAttachmentAction.php +++ b/sources/AppBundle/Controller/Admin/Accounting/Journal/DownloadAttachmentAction.php @@ -4,8 +4,8 @@ namespace AppBundle\Controller\Admin\Accounting\Journal; -use AppBundle\Accounting\Model\Transaction; -use AppBundle\Accounting\Model\Repository\TransactionRepository; +use AppBundle\Accounting\Entity\Transaction; +use AppBundle\Accounting\Entity\Repository\TransactionRepository; use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; use Symfony\Component\DependencyInjection\Attribute\Autowire; use Symfony\Component\HttpFoundation\BinaryFileResponse; @@ -22,13 +22,13 @@ public function __construct( public function __invoke(Request $request, int $id): Response { - $accounting = $this->accountingRepository->get($id); + $accounting = $this->accountingRepository->find($id); if (!$accounting instanceof Transaction) { throw $this->createNotFoundException(); } - $path = $this->uploadDir . $accounting->getAttachmentFilename(); - if ($accounting->getAttachmentFilename() === null || !is_file($path)) { + $path = $this->uploadDir . $accounting->nomJustificatif; + if ($accounting->nomJustificatif === null || !is_file($path)) { throw $this->createNotFoundException('No attachment found'); } diff --git a/sources/AppBundle/Controller/Admin/Accounting/Journal/DownloadAttachmentsAction.php b/sources/AppBundle/Controller/Admin/Accounting/Journal/DownloadAttachmentsAction.php index 39175dc84..5f579488b 100644 --- a/sources/AppBundle/Controller/Admin/Accounting/Journal/DownloadAttachmentsAction.php +++ b/sources/AppBundle/Controller/Admin/Accounting/Journal/DownloadAttachmentsAction.php @@ -4,7 +4,7 @@ namespace AppBundle\Controller\Admin\Accounting\Journal; -use AppBundle\Accounting\Model\Repository\InvoicingPeriodRepository; +use AppBundle\Accounting\Entity\Repository\InvoicingPeriodRepository; use DateInterval; use DatePeriod; use RuntimeException; @@ -26,7 +26,7 @@ public function __invoke(Request $request): Response { $periodId = $request->query->has('periodId') && $request->query->get('periodId') ? (int) $request->query->get('periodId') : null; $period = $this->invoicingPeriodRepository->getCurrentPeriod($periodId); - $year = $period->getStartDate()->format('Y'); + $year = $period->dateDebut->format('Y'); // Create the zip $zipFilename = sys_get_temp_dir() . DIRECTORY_SEPARATOR . 'afup_justificatifs-' . $year . '.zip'; @@ -36,7 +36,7 @@ public function __invoke(Request $request): Response throw new RuntimeException("Impossible to open the Zip archive."); } - $datePeriod = new DatePeriod($period->getStartDate(), new DateInterval('P1M'), $period->getEndDate()); + $datePeriod = new DatePeriod($period->dateDebut, new DateInterval('P1M'), $period->dateFin); /** @var \DateTime $month */ foreach ($datePeriod as $month) { $directory = $year . $month->format('m'); diff --git a/sources/AppBundle/Controller/Admin/Accounting/Journal/EditTransactionAction.php b/sources/AppBundle/Controller/Admin/Accounting/Journal/EditTransactionAction.php index fe3c04a33..52eb50b56 100644 --- a/sources/AppBundle/Controller/Admin/Accounting/Journal/EditTransactionAction.php +++ b/sources/AppBundle/Controller/Admin/Accounting/Journal/EditTransactionAction.php @@ -4,9 +4,9 @@ namespace AppBundle\Controller\Admin\Accounting\Journal; -use AppBundle\Accounting\Model\Transaction; +use AppBundle\Accounting\Entity\Repository\TransactionRepository; +use AppBundle\Accounting\Entity\Transaction; use AppBundle\Accounting\Form\TransactionType; -use AppBundle\Accounting\Model\Repository\TransactionRepository; use AppBundle\AuditLog\Audit; use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; use Symfony\Component\Form\SubmitButton; @@ -23,11 +23,11 @@ public function __construct( public function __invoke(Request $request, int $id): Response { - $transaction = $this->transactionRepository->get($id); + $transaction = $this->transactionRepository->find($id); if (!$transaction instanceof Transaction) { throw new NotFoundHttpException(); } - $nextTransaction = $this->transactionRepository->getNextTransaction($transaction->getId()); + $nextTransaction = $this->transactionRepository->getNextTransaction($transaction->id); $form = $this->createForm(TransactionType::class, $transaction, ['operation' => 'edit', 'nextTransaction' => $nextTransaction]); @@ -36,18 +36,18 @@ public function __invoke(Request $request, int $id): Response $passButton = $form->has('pass') ? $form->get('pass') : null; if ($passButton instanceof SubmitButton && $passButton->isClicked()) { $this->addFlash('notice', 'L\'écriture n\'a pas été modifiée'); - return $this->redirectToRoute('admin_accounting_journal_edit', ['id' => $nextTransaction->getId()]); + return $this->redirectToRoute('admin_accounting_journal_edit', ['id' => $nextTransaction->id]); } $this->transactionRepository->save($transaction); - $this->audit->log("Modification d'une écriture ({$transaction->getId()})"); + $this->audit->log("Modification d'une écriture ({$transaction->id})"); $this->addFlash('notice', 'L\'écriture a été modifiée'); $submitAndPassButton = $form->has('submitAndPass') ? $form->get('submitAndPass') : null; if ($submitAndPassButton instanceof SubmitButton && $submitAndPassButton->isClicked()) { - return $this->redirectToRoute('admin_accounting_journal_edit', ['id' => $nextTransaction->getId()]); + return $this->redirectToRoute('admin_accounting_journal_edit', ['id' => $nextTransaction->id]); } else { - return $this->redirect('/admin/accounting/journal/list#L' . $transaction->getId()); + return $this->redirect('/admin/accounting/journal/list#L' . $transaction->id); } } return $this->render('admin/accounting/journal/edit.html.twig', [ diff --git a/sources/AppBundle/Controller/Admin/Accounting/Journal/ExportAction.php b/sources/AppBundle/Controller/Admin/Accounting/Journal/ExportAction.php index ca2729052..1f53e6f08 100644 --- a/sources/AppBundle/Controller/Admin/Accounting/Journal/ExportAction.php +++ b/sources/AppBundle/Controller/Admin/Accounting/Journal/ExportAction.php @@ -4,8 +4,8 @@ namespace AppBundle\Controller\Admin\Accounting\Journal; -use AppBundle\Accounting\Model\Repository\TransactionRepository; -use AppBundle\Accounting\Model\Repository\InvoicingPeriodRepository; +use AppBundle\Accounting\Entity\Repository\InvoicingPeriodRepository; +use AppBundle\Accounting\Entity\Repository\TransactionRepository; use AppBundle\Accounting\TvaZone; use SplFileObject; use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; @@ -33,8 +33,8 @@ public function __invoke(Request $request): Response $csvFilename = sprintf( 'AFUP_%s_journal_from-%s_to-%s.csv', date('Y-M-d'), - $period->getStartDate()->format('Y-m-d'), - $period->getEndDate()->format('Y-m-d'), + $period->dateDebut->format('Y-m-d'), + $period->dateFin->format('Y-m-d'), ); $tmpFile = tempnam(sys_get_temp_dir(), $csvFilename); $file = new SplFileObject($tmpFile, 'w'); diff --git a/sources/AppBundle/Controller/Admin/Accounting/Journal/ListAction.php b/sources/AppBundle/Controller/Admin/Accounting/Journal/ListAction.php index 2a7810baa..1a67ef05f 100644 --- a/sources/AppBundle/Controller/Admin/Accounting/Journal/ListAction.php +++ b/sources/AppBundle/Controller/Admin/Accounting/Journal/ListAction.php @@ -6,10 +6,10 @@ use AppBundle\Accounting\Entity\Repository\CategoryRepository; use AppBundle\Accounting\Entity\Repository\EventRepository; +use AppBundle\Accounting\Entity\Repository\InvoicingPeriodRepository; use AppBundle\Accounting\Entity\Repository\PaymentRepository; +use AppBundle\Accounting\Entity\Repository\TransactionRepository; use AppBundle\Accounting\Form\InvoicingPeriodType; -use AppBundle\Accounting\Model\Repository\InvoicingPeriodRepository; -use AppBundle\Accounting\Model\Repository\TransactionRepository; use AppBundle\Accounting\OperationType; use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; use Symfony\Component\HttpFoundation\Request; @@ -30,7 +30,7 @@ public function __invoke(Request $request): Response $periodId = $request->query->has('periodId') ? $request->query->getInt('periodId') : null; $period = $this->invoicingPeriodRepository->getCurrentPeriod($periodId); $formPeriod = $this->createForm(InvoicingPeriodType::class, $period); - $periods = $this->invoicingPeriodRepository->getAll(); + $periods = $this->invoicingPeriodRepository->findAll(); $withReconciled = $request->query->getBoolean('with_reconciled'); $type = OperationType::tryfrom($request->query->getInt('type')); @@ -38,7 +38,7 @@ public function __invoke(Request $request): Response return $this->render('admin/accounting/journal/list.html.twig', [ 'periods' => $periods, - 'periodId' => $period->getId(), + 'periodId' => $period->id, 'formPeriod' => $formPeriod->createView(), 'withReconciled' => $withReconciled, 'type' => $type, diff --git a/sources/AppBundle/Controller/Admin/Accounting/Journal/UpdateInfoAction.php b/sources/AppBundle/Controller/Admin/Accounting/Journal/UpdateInfoAction.php index 3ddfa2d23..04173c711 100644 --- a/sources/AppBundle/Controller/Admin/Accounting/Journal/UpdateInfoAction.php +++ b/sources/AppBundle/Controller/Admin/Accounting/Journal/UpdateInfoAction.php @@ -4,8 +4,11 @@ namespace AppBundle\Controller\Admin\Accounting\Journal; -use AppBundle\Accounting\Model\Repository\TransactionRepository; -use AppBundle\Accounting\Model\Transaction; +use AppBundle\Accounting\Entity\Repository\CategoryRepository; +use AppBundle\Accounting\Entity\Repository\EventRepository; +use AppBundle\Accounting\Entity\Repository\PaymentRepository; +use AppBundle\Accounting\Entity\Repository\TransactionRepository; +use AppBundle\Accounting\Entity\Transaction; use AppBundle\Accounting\TransactionModification; use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; use Symfony\Component\HttpFoundation\JsonResponse; @@ -14,14 +17,19 @@ class UpdateInfoAction extends AbstractController { - public function __construct(private readonly TransactionRepository $transactionRepository) {} + public function __construct( + private readonly TransactionRepository $transactionRepository, + private readonly CategoryRepository $categoryRepository, + private readonly PaymentRepository $paymentRepository, + private readonly EventRepository $eventRepository, + ) {} public function __invoke( Request $request, int $id, TransactionModification $modification, ): JsonResponse { - $transaction = $this->transactionRepository->get($id); + $transaction = $this->transactionRepository->find($id); if (!$transaction instanceof Transaction) { throw $this->createNotFoundException(); } @@ -32,7 +40,7 @@ public function __invoke( throw new \InvalidArgumentException(sprintf('Value cannot be empty for "%s"', $modification->value)); } - $modification->setValue($transaction, $value); + $modification->setValue($transaction, $value, $this->categoryRepository, $this->paymentRepository, $this->eventRepository); $this->transactionRepository->save($transaction); } catch (\InvalidArgumentException $e) { return new JsonResponse(['error' => $e->getMessage()], Response::HTTP_BAD_REQUEST); diff --git a/sources/AppBundle/Controller/Admin/Accounting/Journal/UploadAttachmentAction.php b/sources/AppBundle/Controller/Admin/Accounting/Journal/UploadAttachmentAction.php index 046db6b2b..bb88076ba 100644 --- a/sources/AppBundle/Controller/Admin/Accounting/Journal/UploadAttachmentAction.php +++ b/sources/AppBundle/Controller/Admin/Accounting/Journal/UploadAttachmentAction.php @@ -4,8 +4,8 @@ namespace AppBundle\Controller\Admin\Accounting\Journal; -use AppBundle\Accounting\Model\Repository\TransactionRepository; -use AppBundle\Accounting\Model\Transaction; +use AppBundle\Accounting\Entity\Repository\TransactionRepository; +use AppBundle\Accounting\Entity\Transaction; use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; use Symfony\Component\DependencyInjection\Attribute\Autowire; use Symfony\Component\HttpFoundation\File\UploadedFile; @@ -24,7 +24,7 @@ public function __construct( public function __invoke(Request $request, int $id): Response { - $transaction = $this->transactionRepository->get($id); + $transaction = $this->transactionRepository->find($id); if (!$transaction instanceof Transaction) { throw $this->createNotFoundException(); } @@ -33,7 +33,7 @@ public function __invoke(Request $request, int $id): Response return new Response('No file uploaded', 400); } - $directory = $transaction->getAccountingDate()->format('Ym') . DIRECTORY_SEPARATOR; + $directory = $transaction->dateEcriture->format('Ym') . DIRECTORY_SEPARATOR; $targetDir = $this->uploadDir . $directory; if (!is_dir($targetDir)) { mkdir($targetDir, 0750, true); @@ -49,19 +49,19 @@ public function __invoke(Request $request, int $id): Response } $filename = sprintf('%s.%s', - $transaction->getAccountingDate()->format('Y-m-d') . '_' . $transaction->getId() . '_' . substr(sha1_file($file->getPathname()), 0, 6), + $transaction->dateEcriture->format('Y-m-d') . '_' . $transaction->id . '_' . substr(sha1_file($file->getPathname()), 0, 6), $file->guessExtension(), ); $file->move($targetDir, $filename); - if (!empty($transaction->getAttachmentFilename())) { - $oldFilename = $this->uploadDir . $transaction->getAttachmentFilename(); + if (!empty($transaction->nomJustificatif)) { + $oldFilename = $this->uploadDir . $transaction->nomJustificatif; if (is_file($oldFilename)) { unlink($oldFilename); } } - $transaction->setAttachmentFilename($directory . $filename); + $transaction->nomJustificatif = $directory . $filename; $this->transactionRepository->save($transaction); return new Response(); diff --git a/sources/AppBundle/Controller/Admin/Accounting/Quotation/AddQuotationAction.php b/sources/AppBundle/Controller/Admin/Accounting/Quotation/AddQuotationAction.php index d84092380..d627cd9f2 100644 --- a/sources/AppBundle/Controller/Admin/Accounting/Quotation/AddQuotationAction.php +++ b/sources/AppBundle/Controller/Admin/Accounting/Quotation/AddQuotationAction.php @@ -4,13 +4,12 @@ namespace AppBundle\Controller\Admin\Accounting\Quotation; -use AppBundle\Accounting\InvoicingNumberGenerator; +use AppBundle\Accounting\Entity\Invoicing; +use AppBundle\Accounting\Entity\InvoicingDetail; +use AppBundle\Accounting\Entity\Repository\InvoicingRepository; use AppBundle\Accounting\Entity\Repository\ProduitRepository; use AppBundle\Accounting\Form\QuotationType; -use AppBundle\Accounting\Model\Invoicing; -use AppBundle\Accounting\Model\InvoicingDetail; -use AppBundle\Accounting\Model\Repository\InvoicingDetailRepository; -use AppBundle\Accounting\Model\Repository\InvoicingRepository; +use AppBundle\Accounting\InvoicingNumberGenerator; use Psr\Log\LoggerInterface; use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; use Symfony\Component\HttpFoundation\Request; @@ -21,7 +20,6 @@ class AddQuotationAction extends AbstractController public function __construct( private readonly InvoicingRepository $invoicingRepository, private readonly InvoicingNumberGenerator $numberGenerator, - private readonly InvoicingDetailRepository $invoicingDetailRepository, private readonly ProduitRepository $produitRepository, private readonly LoggerInterface $logger, ) {} @@ -33,18 +31,14 @@ public function __invoke(Request $request): Response $form->handleRequest($request); if ($form->isSubmitted() && $form->isValid()) { try { - $this->invoicingRepository->startTransaction(); - $quotation->setQuotationNumber($this->numberGenerator->generateQuotationNumber()); - $this->invoicingRepository->save($quotation); - foreach ($quotation->getDetails() as $detail) { - $detail->setInvoicingId($quotation->getId()); - $this->invoicingDetailRepository->save($detail); + $quotation->numeroDevis = $this->numberGenerator->generateQuotationNumber(); + foreach ($quotation->details as $detail) { + $detail->facture = $quotation; } - $this->invoicingRepository->commit(); + $this->invoicingRepository->save($quotation); $this->addFlash('success', 'L\'écriture a été ajoutée'); return $this->redirectToRoute('admin_accounting_quotations_list'); } catch (\Exception $e) { - $this->invoicingRepository->rollback(); $this->logger->error('Échec de l\'ajout d\'un devis : ' . $e->getMessage(), ['exception' => $e]); $this->addFlash('error', 'L\'écriture n\'a pas pu être enregistrée'); } @@ -62,42 +56,43 @@ private function init(int $quotationId): Invoicing { $baseQuotation = $this->invoicingRepository->getById($quotationId); if (!$baseQuotation instanceof Invoicing) { - $quotation = new Invoicing(); - $quotation->setQuotationDate(new \DateTime()); - $quotation->setCountryId('FR'); + $quotation = new Invoicing(); + $quotation->dateDevis = new \DateTime(); + $quotation->idPays = 'FR'; return $quotation; } $quotation = new Invoicing(); - $quotation->setQuotationDate(new \DateTime()); - $quotation->setInvoiceDate($baseQuotation->getInvoiceDate()); - $quotation->setCompany($baseQuotation->getCompany()); - $quotation->setService($baseQuotation->getService()); - $quotation->setAddress($baseQuotation->getAddress()); - $quotation->setZipcode($baseQuotation->getZipcode()); - $quotation->setCity($baseQuotation->getCity()); - $quotation->setCountryId($baseQuotation->getCountryId()); - $quotation->setEmail($baseQuotation->getEmail()); - $quotation->setTvaIntra($baseQuotation->getTvaIntra()); - $quotation->setObservation($baseQuotation->getObservation()); - $quotation->setRefClt1($baseQuotation->getRefClt1()); - $quotation->setRefClt2($baseQuotation->getRefClt2()); - $quotation->setRefClt3($baseQuotation->getRefClt3()); - $quotation->setLastname($baseQuotation->getLastname()); - $quotation->setFirstname($baseQuotation->getFirstname()); - $quotation->setPhone($baseQuotation->getPhone()); - $quotation->setQuotationNumber(''); - $quotation->setInvoiceNumber(''); - $quotation->setDetails(array_map(static function (InvoicingDetail $detail) { + $quotation->dateDevis = new \DateTime(); + $quotation->dateFacture = $baseQuotation->dateFacture; + $quotation->societe = $baseQuotation->societe; + $quotation->service = $baseQuotation->service; + $quotation->adresse = $baseQuotation->adresse; + $quotation->codePostal = $baseQuotation->codePostal; + $quotation->ville = $baseQuotation->ville; + $quotation->idPays = $baseQuotation->idPays; + $quotation->email = $baseQuotation->email; + $quotation->tvaIntra = $baseQuotation->tvaIntra; + $quotation->observation = $baseQuotation->observation; + $quotation->referenceClient1 = $baseQuotation->referenceClient1; + $quotation->referenceClient2 = $baseQuotation->referenceClient2; + $quotation->referenceClient3 = $baseQuotation->referenceClient3; + $quotation->nom = $baseQuotation->nom; + $quotation->prenom = $baseQuotation->prenom; + $quotation->telephone = $baseQuotation->telephone; + $quotation->numeroDevis = ''; + $quotation->numeroFacture = ''; + + foreach ($baseQuotation->details as $detail) { $clone = new InvoicingDetail(); - $clone->setReference($detail->getReference()); - $clone->setDesignation($detail->getDesignation()); - $clone->setQuantity($detail->getQuantity()); - $clone->setUnitPrice($detail->getUnitPrice()); - $clone->setTva($detail->getTva()); - return $clone; - }, $baseQuotation->getDetails())); + $clone->reference = $detail->reference; + $clone->designation = $detail->designation; + $clone->quantite = $detail->quantite; + $clone->prixUnitaire = $detail->prixUnitaire; + $clone->tva = $detail->tva; + $quotation->addDetail($clone); + } return $quotation; } diff --git a/sources/AppBundle/Controller/Admin/Accounting/Quotation/ConvertQuotationAction.php b/sources/AppBundle/Controller/Admin/Accounting/Quotation/ConvertQuotationAction.php index b1e7c7e0c..6d327489e 100644 --- a/sources/AppBundle/Controller/Admin/Accounting/Quotation/ConvertQuotationAction.php +++ b/sources/AppBundle/Controller/Admin/Accounting/Quotation/ConvertQuotationAction.php @@ -4,8 +4,8 @@ namespace AppBundle\Controller\Admin\Accounting\Quotation; +use AppBundle\Accounting\Entity\Repository\InvoicingRepository; use AppBundle\Accounting\InvoicingNumberGenerator; -use AppBundle\Accounting\Model\Repository\InvoicingRepository; use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Response; @@ -21,7 +21,7 @@ public function __construct( public function __invoke(Request $request): Response { $quotationRef = $request->query->get('ref'); - $quotation = $this->invoicingRepository->getOneBy(['quotationNumber' => $quotationRef]); + $quotation = $this->invoicingRepository->findOneBy(['numeroDevis' => $quotationRef]); if ($quotation === null) { throw new NotFoundHttpException("Ce devis n'existe pas"); } diff --git a/sources/AppBundle/Controller/Admin/Accounting/Quotation/DownloadQuotationAction.php b/sources/AppBundle/Controller/Admin/Accounting/Quotation/DownloadQuotationAction.php index 86bcdcbb7..32d577ed0 100644 --- a/sources/AppBundle/Controller/Admin/Accounting/Quotation/DownloadQuotationAction.php +++ b/sources/AppBundle/Controller/Admin/Accounting/Quotation/DownloadQuotationAction.php @@ -4,8 +4,8 @@ namespace AppBundle\Controller\Admin\Accounting\Quotation; +use AppBundle\Accounting\Entity\Repository\InvoicingRepository; use AppBundle\Accounting\InvoicingPdfGenerator; -use AppBundle\Accounting\Model\Repository\InvoicingRepository; use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Response; diff --git a/sources/AppBundle/Controller/Admin/Accounting/Quotation/EditQuotationAction.php b/sources/AppBundle/Controller/Admin/Accounting/Quotation/EditQuotationAction.php index 58156dfec..e24c6db7f 100644 --- a/sources/AppBundle/Controller/Admin/Accounting/Quotation/EditQuotationAction.php +++ b/sources/AppBundle/Controller/Admin/Accounting/Quotation/EditQuotationAction.php @@ -4,10 +4,9 @@ namespace AppBundle\Controller\Admin\Accounting\Quotation; +use AppBundle\Accounting\Entity\Repository\InvoicingRepository; use AppBundle\Accounting\Entity\Repository\ProduitRepository; use AppBundle\Accounting\Form\QuotationType; -use AppBundle\Accounting\Model\Repository\InvoicingDetailRepository; -use AppBundle\Accounting\Model\Repository\InvoicingRepository; use Psr\Log\LoggerInterface; use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; use Symfony\Component\HttpFoundation\Request; @@ -17,7 +16,6 @@ class EditQuotationAction extends AbstractController { public function __construct( private readonly InvoicingRepository $invoicingRepository, - private readonly InvoicingDetailRepository $invoicingDetailRepository, private readonly ProduitRepository $produitRepository, private readonly LoggerInterface $logger, ) {} @@ -34,27 +32,13 @@ public function __invoke(Request $request): Response $form->handleRequest($request); if ($form->isSubmitted() && $form->isValid()) { try { - $idsToRemove = $this->invoicingDetailRepository->getRowsIdsPerInvoicingId($quotation->getId()); - $existingIds = []; - $this->invoicingRepository->startTransaction(); - $this->invoicingRepository->save($quotation); - foreach ($quotation->getDetails() as $detail) { - if ($detail->getId() !== null) { - $existingIds[] = $detail->getId(); - } - $detail->setInvoicingId($quotation->getId()); - $this->invoicingDetailRepository->save($detail); - } - - $idsToRemove = array_diff($idsToRemove, $existingIds); - if ($idsToRemove) { - $this->invoicingDetailRepository->removeRowsPerIds($idsToRemove); + foreach ($quotation->details as $detail) { + $detail->facture = $quotation; } - $this->invoicingRepository->commit(); + $this->invoicingRepository->save($quotation); $this->addFlash('success', 'L\'écriture a été modifiée'); return $this->redirectToRoute('admin_accounting_quotations_list'); } catch (\Exception $e) { - $this->invoicingRepository->rollback(); $this->logger->error('Échec de la modification d\'un devis : ' . $e->getMessage(), ['exception' => $e]); $this->addFlash('error', 'L\'écriture n\'a pas pu être enregistrée'); } diff --git a/sources/AppBundle/Controller/Admin/Accounting/Quotation/ListQuotationAction.php b/sources/AppBundle/Controller/Admin/Accounting/Quotation/ListQuotationAction.php index 34218afc5..b7f5d7f17 100644 --- a/sources/AppBundle/Controller/Admin/Accounting/Quotation/ListQuotationAction.php +++ b/sources/AppBundle/Controller/Admin/Accounting/Quotation/ListQuotationAction.php @@ -5,9 +5,9 @@ namespace AppBundle\Controller\Admin\Accounting\Quotation; use Afup\Site\Utils\Vat; +use AppBundle\Accounting\Entity\Repository\InvoicingPeriodRepository; +use AppBundle\Accounting\Entity\Repository\InvoicingRepository; use AppBundle\Accounting\Form\InvoicingPeriodType; -use AppBundle\Accounting\Model\Repository\InvoicingRepository; -use AppBundle\Accounting\Model\Repository\InvoicingPeriodRepository; use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Response; @@ -29,17 +29,17 @@ public function __invoke(Request $request): Response $direction = $request->query->get('direction', 'desc'); $sort = $request->query->get('sort', 'date'); - $quotations = $this->invoiceRepository->getQuotationsByPeriodId($period->getId(), $sort, $direction); - $periods = $this->invoicingPeriodRepository->getAll(); + $quotations = $this->invoiceRepository->getQuotationsByPeriodId($period->id, $sort, $direction); + $periods = $this->invoicingPeriodRepository->findAll(); return new Response($this->twig->render('admin/accounting/quotation/list.html.twig', [ 'lines' => $quotations, 'periods' => $periods, - 'periodId' => $period->getId(), + 'periodId' => $period->id, 'formPeriod' => $formPeriod->createView(), 'direction' => $direction, 'sort' => $sort, - 'isSubjectedToVat' => Vat::isSubjectedToVat($period->getEndDate()), + 'isSubjectedToVat' => Vat::isSubjectedToVat($period->dateFin), ])); } } diff --git a/sources/AppBundle/Controller/Website/Payment/InvoiceAction.php b/sources/AppBundle/Controller/Website/Payment/InvoiceAction.php index 9753060e5..bcc5fc02d 100644 --- a/sources/AppBundle/Controller/Website/Payment/InvoiceAction.php +++ b/sources/AppBundle/Controller/Website/Payment/InvoiceAction.php @@ -5,9 +5,9 @@ namespace AppBundle\Controller\Website\Payment; use Afup\Site\Utils\Utils; +use AppBundle\Accounting\Entity\Invoicing; +use AppBundle\Accounting\Entity\Repository\InvoicingRepository; use AppBundle\Accounting\InvoicingPaymentStatus; -use AppBundle\Accounting\Model\Invoicing; -use AppBundle\Accounting\Model\Repository\InvoicingRepository; use AppBundle\Payment\PayboxBilling; use AppBundle\Payment\PayboxFactory; use AppBundle\Twig\ViewRenderer; @@ -37,12 +37,12 @@ public function __invoke(Request $request): Response } $paybox = null; - if ($invoice->getPaymentStatus() === InvoicingPaymentStatus::Waiting) { + if ($invoice->etatPaiement === InvoicingPaymentStatus::Waiting) { $paybox = $this->buildPaybox($invoice); } return $this->view->render('site/payment/invoice.html.twig', [ - 'invoice_number' => $invoice->getInvoiceNumber(), + 'invoice_number' => $invoice->numeroFacture, 'ref' => $ref, 'paybox' => $paybox, ]); @@ -51,22 +51,22 @@ public function __invoke(Request $request): Response private function buildPaybox(Invoicing $invoice): string { $amount = 0.0; - foreach ($invoice->getDetails() as $detail) { - $amount += $detail->getQuantity() * $detail->getUnitPrice() * (1 + ($detail->getTva() / 100)); + foreach ($invoice->details as $detail) { + $amount += $detail->quantite * $detail->prixUnitaire * (1 + ($detail->tva / 100)); } $paybox = $this->payboxFactory->getPaybox(); $paybox ->setTotal((int) ($amount * 100)) - ->setCmd($invoice->getInvoiceNumber()) - ->setPorteur($invoice->getEmail()) + ->setCmd($invoice->numeroFacture) + ->setPorteur($invoice->email) ->setUrlRetourEffectue($this->generateUrl('payment_invoice_redirect', ['type' => 'success'], UrlGeneratorInterface::ABSOLUTE_URL)) ->setUrlRetourAnnule($this->generateUrl('payment_invoice_redirect', ['type' => 'canceled'], UrlGeneratorInterface::ABSOLUTE_URL)) ->setUrlRetourRefuse($this->generateUrl('payment_invoice_redirect', ['type' => 'refused'], UrlGeneratorInterface::ABSOLUTE_URL)) ->setUrlRetourErreur($this->generateUrl('payment_invoice_redirect', ['type' => 'error'], UrlGeneratorInterface::ABSOLUTE_URL)) ; - $payboxBilling = new PayboxBilling($invoice->getFirstname(), $invoice->getLastname(), $invoice->getAddress(), $invoice->getZipcode(), $invoice->getCity(), $invoice->getCountryId()); + $payboxBilling = new PayboxBilling($invoice->prenom, $invoice->nom, $invoice->adresse, $invoice->codePostal, $invoice->ville, $invoice->idPays); return $paybox->generate(new \DateTime(), $payboxBilling); } diff --git a/sources/AppBundle/Controller/Website/Payment/InvoiceDownloadAction.php b/sources/AppBundle/Controller/Website/Payment/InvoiceDownloadAction.php index cee5ca93d..3fba96558 100644 --- a/sources/AppBundle/Controller/Website/Payment/InvoiceDownloadAction.php +++ b/sources/AppBundle/Controller/Website/Payment/InvoiceDownloadAction.php @@ -5,8 +5,8 @@ namespace AppBundle\Controller\Website\Payment; use Afup\Site\Utils\Utils; +use AppBundle\Accounting\Entity\Repository\InvoicingRepository; use AppBundle\Accounting\InvoicingPdfGenerator; -use AppBundle\Accounting\Model\Repository\InvoicingRepository; use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Response; diff --git a/sources/AppBundle/Controller/Website/Payment/InvoiceRedirectAction.php b/sources/AppBundle/Controller/Website/Payment/InvoiceRedirectAction.php index 15f1b7bec..871f9e9ea 100644 --- a/sources/AppBundle/Controller/Website/Payment/InvoiceRedirectAction.php +++ b/sources/AppBundle/Controller/Website/Payment/InvoiceRedirectAction.php @@ -5,7 +5,7 @@ namespace AppBundle\Controller\Website\Payment; use Afup\Site\Utils\Utils; -use AppBundle\Accounting\Model\Repository\InvoicingRepository; +use AppBundle\Accounting\Entity\Repository\InvoicingRepository; use AppBundle\Payment\PayboxResponseFactory; use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; use Symfony\Component\HttpFoundation\RedirectResponse; @@ -21,12 +21,11 @@ public function __invoke(Request $request, string $type = 'success'): RedirectRe if (!$invoiceRef) { throw $this->createNotFoundException('Facture inexistante, ref manquant'); } - // getOneBy() intentionally used here: only getId() is needed, no details required - $invoice = $this->invoicingRepository->getOneBy(['invoiceNumber' => $invoiceRef]); + $invoice = $this->invoicingRepository->findOneBy(['numeroFacture' => $invoiceRef]); if ($invoice === null) { throw $this->createNotFoundException('Facture inexistante'); } - $cryptRef = urlencode(Utils::cryptFromText($invoice->getId())); + $cryptRef = urlencode(Utils::cryptFromText($invoice->id)); $payboxResponse = PayboxResponseFactory::createFromRequest($request); if ($payboxResponse->isSuccessful()) { diff --git a/templates/admin/accounting/invoice/edit.html.twig b/templates/admin/accounting/invoice/edit.html.twig index 86190c064..b9be1bba5 100644 --- a/templates/admin/accounting/invoice/edit.html.twig +++ b/templates/admin/accounting/invoice/edit.html.twig @@ -17,7 +17,7 @@
- {{ form_row(form.invoiceDate) }} + {{ form_row(form.dateFacture) }}
@@ -34,12 +34,12 @@ Ces informations concernent la personne ou la société qui sera facturée

- {{ form_row(form.company) }} + {{ form_row(form.societe) }} {{ form_row(form.service) }} - {{ form_row(form.address) }} - {{ form_row(form.zipcode) }} - {{ form_row(form.city) }} - {{ form_row(form.countryId) }} + {{ form_row(form.adresse) }} + {{ form_row(form.codePostal) }} + {{ form_row(form.ville) }} + {{ form_row(form.idPays) }} @@ -49,9 +49,9 @@
- {{ form_row(form.lastname) }} - {{ form_row(form.firstname) }} - {{ form_row(form.phone) }} + {{ form_row(form.nom) }} + {{ form_row(form.prenom) }} + {{ form_row(form.telephone) }} {{ form_row(form.email) }} {{ form_row(form.tvaIntra) }}
@@ -70,8 +70,8 @@ Numéro généré automatiquement et affiché en automatique

- {{ form_row(form.quotationNumber) }} - {{ form_row(form.invoiceNumber) }} + {{ form_row(form.numeroDevis) }} + {{ form_row(form.numeroFacture) }} @@ -88,9 +88,9 @@ Possible d'avoir plusieurs références à mettre (obligation client)

- {{ form_row(form.refClt1) }} - {{ form_row(form.refClt2) }} - {{ form_row(form.refClt3) }} + {{ form_row(form.referenceClient1) }} + {{ form_row(form.referenceClient2) }} + {{ form_row(form.referenceClient3) }} @@ -117,9 +117,9 @@
- {{ form_row(form.currency) }} - {{ form_row(form.paymentStatus) }} - {{ form_row(form.paymentDate) }} + {{ form_row(form.deviseFacture) }} + {{ form_row(form.etatPaiement) }} + {{ form_row(form.datePaiement) }}
@@ -142,8 +142,8 @@ {{ form_row(detail.reference) }} {{ form_row(detail.tva) }} {{ form_row(detail.designation) }} - {{ form_row(detail.quantity) }} - {{ form_row(detail.unitPrice) }} + {{ form_row(detail.quantite) }} + {{ form_row(detail.prixUnitaire) }} {% endfor %} diff --git a/templates/admin/accounting/invoice/list.html.twig b/templates/admin/accounting/invoice/list.html.twig index 2c831cedd..68f770aa3 100644 --- a/templates/admin/accounting/invoice/list.html.twig +++ b/templates/admin/accounting/invoice/list.html.twig @@ -13,7 +13,7 @@ {% include 'admin/accounting/invoicing-period.form.html.twig' with {form: formPeriod, url: path('admin_accounting_invoices_list')} %} - {% if lines.count > 0 %} + {% if lines|length > 0 %} @@ -40,39 +40,39 @@ {% for line in lines %} - - - - - + + + + + - +
{{ line.invoiceDate|format_date('short') }}{{ line.company }}{{ line.city }}{{ line.invoiceNumber }}{{ line.refClt1 }}{{ line.dateFacture|format_date('short') }}{{ line.societe }}{{ line.ville }}{{ line.numeroFacture }}{{ line.referenceClient1 }} - {% if line.paymentStatus == enum('AppBundle\\Accounting\\InvoicingPaymentStatus').Cancelled %} + {% if line.etatPaiement == enum('AppBundle\\Accounting\\InvoicingPaymentStatus').Cancelled %} Annulé - {% elseif line.paymentStatus == enum('AppBundle\\Accounting\\InvoicingPaymentStatus').Payed %} + {% elseif line.etatPaiement == enum('AppBundle\\Accounting\\InvoicingPaymentStatus').Payed %} Payé {% else %} En attente {% endif %} {{ line.price|number_format(2, ',', ' ') }}{{ line.prix|number_format(2, ',', ' ') }} - - diff --git a/templates/admin/accounting/journal/form.html.twig b/templates/admin/accounting/journal/form.html.twig index d2b5d5e72..e91619037 100644 --- a/templates/admin/accounting/journal/form.html.twig +++ b/templates/admin/accounting/journal/form.html.twig @@ -6,9 +6,9 @@

Sélectionner un Journal

- {{ form_row(form.operationId) }} - {{ form_row(form.accountId) }} - {{ form_row(form.eventId) }} + {{ form_row(form.operation) }} + {{ form_row(form.compte) }} + {{ form_row(form.evenement) }}
@@ -16,14 +16,14 @@

Détail Facture

- {{ form_row(form.accountingDate) }} - {{ form_row(form.categoryId) }} - {{ form_row(form.vendorName) }} + {{ form_row(form.dateEcriture) }} + {{ form_row(form.categorie) }} + {{ form_row(form.nomFournisseur) }} {{ form_row(form.tvaIntra) }} - {{ form_row(form.number) }} + {{ form_row(form.numero) }} {{ form_row(form.description) }} - {{ form_row(form.amount) }} - {{ form_row(form.comment) }} + {{ form_row(form.montant) }} + {{ form_row(form.commentaire) }}
@@ -31,7 +31,7 @@

TVA

- {{ form_row(form.amountTva10) }} + {{ form_row(form.montantTva10) }} - {{ form_row(form.amountTva20) }} + {{ form_row(form.montantTva20) }} - {{ form_row(form.amountTva0) }} + {{ form_row(form.montantTva0) }}
@@ -71,9 +71,9 @@

Réglement

- {{ form_row(form.paymentTypeId) }} - {{ form_row(form.paymentDate) }} - {{ form_row(form.paymentComment) }} + {{ form_row(form.modeReglement) }} + {{ form_row(form.dateReglement) }} + {{ form_row(form.commentaireReglement) }}
diff --git a/templates/admin/accounting/journal/list.html.twig b/templates/admin/accounting/journal/list.html.twig index f4349ce0e..b56c17725 100644 --- a/templates/admin/accounting/journal/list.html.twig +++ b/templates/admin/accounting/journal/list.html.twig @@ -56,7 +56,7 @@
- {% if transactions.count > 0 %} + {% if transactions|length > 0 %} diff --git a/templates/admin/accounting/journal/vat_calculation.js.twig b/templates/admin/accounting/journal/vat_calculation.js.twig index f25aed039..4d47355ba 100644 --- a/templates/admin/accounting/journal/vat_calculation.js.twig +++ b/templates/admin/accounting/journal/vat_calculation.js.twig @@ -1,14 +1,14 @@