diff --git a/CHANGELOG.md b/CHANGELOG.md index ddf38626..f942bba8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,8 @@ See [keep a changelog](https://keepachangelog.com/en/1.0.0/) for information abo ## [Unreleased] +* Fixed command to recalculate sums for all invoices by first calculating invoice entries. + ## 1.0.3 * Changed redirect after create a manual invoice entry. diff --git a/src/Command/CalculateSumsCommand.php b/src/Command/CalculateSumsCommand.php index 4b611d02..6398a09d 100644 --- a/src/Command/CalculateSumsCommand.php +++ b/src/Command/CalculateSumsCommand.php @@ -2,6 +2,7 @@ namespace App\Command; +use App\Entity\Invoice; use App\Repository\InvoiceRepository; use App\Service\BillingService; use Symfony\Component\Console\Attribute\AsCommand; @@ -37,9 +38,13 @@ protected function execute(InputInterface $input, OutputInterface $output): int $io->progressStart(count($invoices)); + /** @var Invoice $invoice */ foreach ($invoices as $invoice) { $io->progressAdvance(); - $this->billingService->updateInvoiceTotalPrice($invoice); + + foreach ($invoice->getInvoiceEntries() as $invoiceEntry) { + $this->billingService->updateInvoiceEntryTotalPrice($invoiceEntry); + } } $io->progressFinish();