diff --git a/app/config/routing/admin_accounting.yml b/app/config/routing/admin_accounting.yml
index b9c022566..f681c9019 100644
--- a/app/config/routing/admin_accounting.yml
+++ b/app/config/routing/admin_accounting.yml
@@ -10,6 +10,10 @@ admin_accounting_bank_accounts:
resource: "admin_accounting_bank_accounts.yml"
prefix: /bank-accounts
+admin_accounting_journal:
+ resource: "admin_accounting/journal.yml"
+ prefix: /journal
+
admin_accounting_quotations_list:
path: /quotations/list
defaults: {_controller: AppBundle\Controller\Admin\Accounting\Quotation\ListQuotationAction}
diff --git a/app/config/routing/admin_accounting/journal.yml b/app/config/routing/admin_accounting/journal.yml
new file mode 100644
index 000000000..e7f0f20b1
--- /dev/null
+++ b/app/config/routing/admin_accounting/journal.yml
@@ -0,0 +1,6 @@
+admin_accounting_journal_delete:
+ path: /delete/{id}
+ defaults:
+ _controller: AppBundle\Controller\Admin\Accounting\Journal\DeleteAction
+ requirements:
+ id: \d+
diff --git a/htdocs/pages/administration/compta_journal.php b/htdocs/pages/administration/compta_journal.php
index f57da40fc..79cf731a2 100755
--- a/htdocs/pages/administration/compta_journal.php
+++ b/htdocs/pages/administration/compta_journal.php
@@ -20,7 +20,6 @@
'credit',
'ajouter',
'modifier',
- 'supprimer',
'importer',
'ventiler',
'modifier_colonne',
@@ -577,13 +576,6 @@
header('X-Info: ' . $e->getMessage());
}
exit;
-} elseif ($action == 'supprimer') {
- if ($compta->supprimerEcriture($_GET['id'])) {
- Logs::log('Suppression de l\'écriture ' . $_GET['id']);
- afficherMessage('L\'écriture a été supprimée', 'index.php?page=compta_journal&action=lister');
- } else {
- afficherMessage('Une erreur est survenue lors de la suppression de l\'écriture', 'index.php?page=compta_journal&action=lister', true);
- }
} elseif ($action == 'importer') {
$formulaire = instancierFormulaire();
$formulaire->addElement('header', null , 'Import CSV');
diff --git a/htdocs/templates/administration/compta_journal.html b/htdocs/templates/administration/compta_journal.html
index ba4adf820..5b34cfa16 100644
--- a/htdocs/templates/administration/compta_journal.html
+++ b/htdocs/templates/administration/compta_journal.html
@@ -198,7 +198,7 @@
Journal
-
+ */
+class TransactionRepository extends Repository implements MetadataInitializer
+{
+ 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' => 'string',
+ ])
+ ->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
new file mode 100644
index 000000000..f84144370
--- /dev/null
+++ b/sources/AppBundle/Accounting/Model/Transaction.php
@@ -0,0 +1,350 @@
+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(): ?string
+ {
+ return $this->tvaZone;
+ }
+
+ public function setTvaZone(?string $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('amountTva55', $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/Controller/Admin/Accounting/Journal/DeleteAction.php b/sources/AppBundle/Controller/Admin/Accounting/Journal/DeleteAction.php
new file mode 100644
index 000000000..d2bbc9a7d
--- /dev/null
+++ b/sources/AppBundle/Controller/Admin/Accounting/Journal/DeleteAction.php
@@ -0,0 +1,38 @@
+transactionRepository->get($id);
+ if (!$accounting instanceof Transaction) {
+ $_SESSION['flash'] = "Une erreur est survenue lors de la suppression de l'écriture";
+ $_SESSION['erreur'] = true;
+ $this->addFlash('error', "Une erreur est survenue lors de la suppression de l'écriture");
+ return $this->redirect('/pages/administration/index.php?page=compta_journal');
+ }
+
+ $this->transactionRepository->delete($accounting);
+ $this->audit->log("Suppression de l'écriture {$id}");
+ $_SESSION['flash'] = "L'écriture a été supprimée";
+ $_SESSION['erreur'] = false;
+ $this->addFlash('notice', "L'écriture a été supprimée");
+ return $this->redirect('/pages/administration/index.php?page=compta_journal');
+ }
+}
diff --git a/tests/behat/features/Admin/Tresorerie/Journal.feature b/tests/behat/features/Admin/Tresorerie/Journal.feature
index 7e7bf4ccf..a26236cc8 100644
--- a/tests/behat/features/Admin/Tresorerie/Journal.feature
+++ b/tests/behat/features/Admin/Tresorerie/Journal.feature
@@ -90,3 +90,10 @@ Feature: Administration - Trésorerie - Journal
When I follow "Journal"
And I follow "Télécharger les justificatifs groupés par mois"
Then the response header "Content-disposition" should match '#filename="afup_justificatifs-(.*).zip"#'
+
+ @reloadDbWithTestData
+ Scenario: Compte journal Suppression d'une transaction
+ Given I am logged in as admin and on the Administration
+ When I am on "/pages/administration/index.php?page=compta_journal&id_periode=15"
+ And I follow the button of tooltip "Supprimer la fiche de PRLV SEPA ONLINE SAS SCW SCALEWAY "
+ Then I should see "L'écriture a été supprimée"