Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions app/config/routing/admin_accounting.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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}
Expand Down
6 changes: 6 additions & 0 deletions app/config/routing/admin_accounting/journal.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
admin_accounting_journal_download:
path: /download/{id}
requirements:
id: '\d+'
defaults:
_controller: AppBundle\Controller\Admin\Accounting\Journal\DownloadAttachmentAction
21 changes: 21 additions & 0 deletions db/seeds/Compta.php
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,27 @@ public function run(): void
'date_regl' => null,
'idevenement' => 0,
],
[
'id' => '6',
'date_ecriture' => '2024-03-10',
'numero_operation' => 'BILL-XXX',
'nom_frs' => '',
'montant' => 42.5,
'description' => 'une facture',
'comment' => null,
'attachment_required' => 1,
'attachment_filename' => 'facture.pdf',
'idcompte' => 1,
'montant_ht_soumis_tva_20' => 34,
'idclef' => 2,
'numero' => '',
'obs_regl' => '',
'idoperation' => 0,
'idcategorie' => 0,
'idmode_regl' => 0,
'date_regl' => null,
'idevenement' => 0,
],
[
'id' => '5',
'idoperation' => 1,
Expand Down
37 changes: 0 additions & 37 deletions htdocs/pages/administration/compta_journal.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@
'ventiler',
'modifier_colonne',
'export',
'download_attachment',
'upload_attachment',
]);

Expand Down Expand Up @@ -541,42 +540,6 @@
echo $e->getMessage();
}
exit;
}

/**
* Download a line attachment
*/ elseif ($action === 'download_attachment') {
try {
// Bad request?
if (!isset($_GET['id']) || !($line = $compta->obtenir((int) $_GET['id']))) {
throw new Exception("Please verify parameters", 400);
}

// Test line existence
if (!$line['id']) {
throw new Exception("Not found", 404);
}

// Test file existence
$filename = AFUP_CHEMIN_RACINE . 'uploads' . DIRECTORY_SEPARATOR . $line['attachment_filename'];
if (!$line['attachment_filename'] || !is_file($filename)) {
throw new RuntimeException('File not found.');
}

// Download it
$finfo = new finfo(FILEINFO_MIME_TYPE);
$mime = $finfo->file($filename);

header('Content-Type: ' . $mime);
header("Content-Transfer-Encoding: Binary");
header("Content-disposition: attachment; filename=\"" . basename($filename) . "\"");
readfile($filename);
exit;
} catch (Exception $e) {
header('HTTP/1.1 400 Bad Request');
header('X-Info: ' . $e->getMessage());
}
exit;
} elseif ($action == 'supprimer') {
if ($compta->supprimerEcriture($_GET['id'])) {
Logs::log('Suppression de l\'écriture ' . $_GET['id']);
Expand Down
2 changes: 1 addition & 1 deletion htdocs/templates/administration/compta_journal.html
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ <h2>Journal</h2>
<a
{if !$ecriture.attachment_filename}style="display:none;"{/if}
class="js-has-attachment"
href="index.php?page=compta_journal&amp;action=download_attachment&amp;id={$ecriture.idtmp}"
href="/admin/accounting/journal/download/{$ecriture.idtmp}"
title="Télécharger le justificatif"
>
<i class="paperclip icon"></i>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,167 @@
<?php

declare(strict_types=1);

namespace AppBundle\Accounting\Model\Repository;

use AppBundle\Accounting\Model\Transaction;
use CCMBenchmark\Ting\Repository\Metadata;
use CCMBenchmark\Ting\Repository\MetadataInitializer;
use CCMBenchmark\Ting\Repository\Repository;
use CCMBenchmark\Ting\Serializer\DateTime;
use CCMBenchmark\Ting\Serializer\SerializerFactoryInterface;

/**
* @extends Repository<Transaction>
*/
class TransactionRepository extends Repository implements MetadataInitializer
{
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;
}
}
Loading