Skip to content

Commit

Permalink
JE-400: Added commando to recalculate invoice sums
Browse files Browse the repository at this point in the history
  • Loading branch information
tuj committed Dec 5, 2023
1 parent e4fd359 commit b08d3d0
Show file tree
Hide file tree
Showing 3 changed files with 59 additions and 1 deletion.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,11 @@ See [keep a changelog](https://keepachangelog.com/en/1.0.0/) for information abo

## [Unreleased]

* Changed redirect after create a manual invoice entry.
* Removed export options when client is not set.
* Added create new buttons to top of invoices and project billing lists.
* Added command to recalculate sums for all invoices.

## 1.0.2

## Changed
Expand Down
49 changes: 49 additions & 0 deletions src/Command/CalculateSumsCommand.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
<?php

namespace App\Command;

use App\Repository\InvoiceRepository;
use App\Service\BillingService;
use Symfony\Component\Console\Attribute\AsCommand;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
use Symfony\Component\Console\Style\SymfonyStyle;

#[AsCommand(
name: 'app:calc-sums',
description: 'Calculate sums for all invoices',
)]
class CalculateSumsCommand extends Command
{
public function __construct(
private readonly BillingService $billingService,
private readonly InvoiceRepository $invoiceRepository,
) {
parent::__construct($this->getName());
}

protected function configure(): void
{
}

protected function execute(InputInterface $input, OutputInterface $output): int
{
$io = new SymfonyStyle($input, $output);

$invoices = $this->invoiceRepository->findAll();

$io->info('Updating sums for invoices.');

$io->progressStart(count($invoices));

foreach ($invoices as $invoice) {
$io->progressAdvance();
$this->billingService->updateInvoiceTotalPrice($invoice);
}

$io->progressFinish();

return Command::SUCCESS;
}
}
6 changes: 5 additions & 1 deletion templates/invoice_entry/worklogs.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -82,11 +82,15 @@
</tr>
{% endif %}
<tr class="table-tr sticky-row">
<td colspan="8" class="table-td">
<td colspan="4" class="table-td">
<button type="submit" class="button mr-5" data-action="worklog-select#submitForm" data-worklog-select-target="submitButton">{{ 'worklog.action_save'|trans }}</button>
<span class="hidden" data-worklog-select-target="spinner">loading...</span>
<span class="hidden" data-worklog-select-target="result"></span>
</td>
<td colspan="4">
<a class="link" style="float: right; margin-right: 2em" href="{{ path('app_invoices_edit', {'id': invoice.id}) }}">{{ 'invoices.back_to_invoice'|trans }}</a>
<a class="link" style="float: right; margin-right: 2em" href="{{ path('app_invoice_entry_edit', {'id': invoiceEntry.id, 'invoice': invoice.id}) }}">{{ 'invoices.back_to_invoice_entry'|trans }}</a>
</td>
</tr>
</tbody>
</table>
Expand Down

0 comments on commit b08d3d0

Please sign in to comment.