Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 0cab76d

Browse files
authored
Affichage du total facturé en HT sur la période (afup#2128)
Cette valeur est nécessaire lors du bilan annuel et un calcul automatique évite des erreurs.
1 parent b8570ad commit 0cab76d

3 files changed

Lines changed: 30 additions & 0 deletions

File tree

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace AppBundle\Accounting;
6+
7+
enum InvoicingPaymentStatus: int
8+
{
9+
case Waiting = 0;
10+
case Payed = 1;
11+
case Cancelled = 2;
12+
}

sources/AppBundle/Controller/Admin/Accounting/Invoice/ListInvoiceAction.php

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55
namespace AppBundle\Controller\Admin\Accounting\Invoice;
66

77
use AppBundle\Accounting\Form\InvoicingPeriodType;
8+
use AppBundle\Accounting\InvoicingPaymentStatus;
9+
use AppBundle\Accounting\Model\Invoicing;
810
use AppBundle\Accounting\Model\Repository\InvoicingRepository;
911
use AppBundle\Accounting\Model\Repository\InvoicingPeriodRepository;
1012
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
@@ -31,13 +33,25 @@ public function __invoke(Request $request): Response
3133
$invoices = $this->invoiceRepository->getInvoicesByPeriodId($period->getId(), $sort, $direction);
3234
$periods = $this->invoicingPeriodRepository->getAll();
3335

36+
$totalHt = 0;
37+
38+
/** @var Invoicing $invoice */
39+
foreach ($invoices as $invoice) {
40+
if ($invoice->getPaymentStatus() === InvoicingPaymentStatus::Cancelled->value) {
41+
continue;
42+
}
43+
44+
$totalHt += $invoice->getPrice();
45+
}
46+
3447
return new Response($this->twig->render('admin/accounting/invoice/list.html.twig', [
3548
'lines' => $invoices,
3649
'periods' => $periods,
3750
'periodId' => $period->getId(),
3851
'formPeriod' => $formPeriod->createView(),
3952
'direction' => $direction,
4053
'sort' => $sort,
54+
'totalHt' => $totalHt,
4155
]));
4256
}
4357
}

templates/admin/accounting/invoice/list.html.twig

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,10 @@
8989
{% endfor %}
9090
</tbody>
9191
</table>
92+
93+
<div class="ui message">
94+
Total facturé en HT sur cette période : {{ totalHt|number_format(2, ',', ' ') }} €
95+
</div>
9296
{% else %}
9397
<div class="ui placeholder segment">
9498
<div class="ui icon header">

0 commit comments

Comments
 (0)