From 8a0fe8aa6c01ff402acb95d78321cec2d02822e4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marek=20D=C4=9Bdi=C4=8D?= Date: Fri, 22 Sep 2023 09:40:50 +0200 Subject: [PATCH 01/12] Nullable grant ID --- app/model/Grant/SkautisGrantId.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/model/Grant/SkautisGrantId.php b/app/model/Grant/SkautisGrantId.php index b5bf8557d..301636a08 100644 --- a/app/model/Grant/SkautisGrantId.php +++ b/app/model/Grant/SkautisGrantId.php @@ -6,7 +6,7 @@ final class SkautisGrantId { - public function __construct(private int $value) + public function __construct(private int|null $value) { } From bafbf46552ff59c7fd598ba96b84c302349e765c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marek=20D=C4=9Bdi=C4=8D?= Date: Fri, 22 Sep 2023 16:39:58 +0200 Subject: [PATCH 02/12] Fixed education module budget hint --- .../presenters/BudgetPresenter.php | 89 ++++++++++++++++++ .../templates/Budget/default.latte | 92 +++++++++++++++++++ .../EducationModule/templates/header.latte | 4 + app/config/config.neon | 4 + .../Queries/EducationBudgetQuery.php | 27 ++++++ .../EducationBudgetQueryHandler.php | 39 ++++++++ 6 files changed, 255 insertions(+) create mode 100644 app/AccountancyModule/EducationModule/presenters/BudgetPresenter.php create mode 100644 app/AccountancyModule/EducationModule/templates/Budget/default.latte create mode 100644 app/model/Skautis/ReadModel/Queries/EducationBudgetQuery.php create mode 100644 app/model/Skautis/ReadModel/QueryHandlers/EducationBudgetQueryHandler.php diff --git a/app/AccountancyModule/EducationModule/presenters/BudgetPresenter.php b/app/AccountancyModule/EducationModule/presenters/BudgetPresenter.php new file mode 100644 index 000000000..e1e1c2c69 --- /dev/null +++ b/app/AccountancyModule/EducationModule/presenters/BudgetPresenter.php @@ -0,0 +1,89 @@ +aid) { + return; + } + + $this->flashMessage('Musíš vybrat akci', 'danger'); + $this->redirect('Default:'); + } + + public function renderDefault(int $aid): void + { + $educationId = new SkautisEducationId($aid); + + try { + $inconsistentTotals = $this->queryBus->handle(new InconsistentEducationCategoryTotalsQuery($educationId)); + $this->template->setParameters([ + 'isConsistent' => count($inconsistentTotals) === 0, + 'toRepair' => $inconsistentTotals, + 'budgetEntries' => $this->queryBus->handle(new EducationBudgetQuery($educationId, $this->event->grantId)), + 'categoriesSummary' => $this->queryBus->handle(new CategoriesSummaryQuery($this->getCashbookId($aid))), + 'isUpdateStatementAllowed' => $this->authorizator->isAllowed(Education::UPDATE_REAL_BUDGET_SPENDING, $aid), + ]); + if (! $this->isAjax()) { + return; + } + + $this->redrawControl('contentSnip'); + } catch (MissingCategory) { + $this->template->setParameters(['missingCategories' => true]); + } + } + + /** + * přepočte hodnoty v jednotlivých kategorich + */ + public function handleConvert(int $aid): void + { + $this->editableOnly(); + + $this->commandBus->handle(new UpdateEducationCategoryTotals($this->getCashbookId($aid))); + $this->flashMessage('Kategorie byly přepočítány.'); + + if ($this->isAjax()) { + $this->redrawControl('flash'); + } else { + $this->redirect('this', $aid); + } + } + + private function getCashbookId(int $educationId): CashbookId + { + return $this->queryBus->handle(new EducationCashbookIdQuery(new SkautisEducationId($educationId))); + } + + protected function createComponentCategoryAutocomputedControl(): MissingAutocomputedCategoryControl + { + return $this->missingAutocomputedCategoryControlFactory->create(new SkautisEducationId($this->aid)); + } +} diff --git a/app/AccountancyModule/EducationModule/templates/Budget/default.latte b/app/AccountancyModule/EducationModule/templates/Budget/default.latte new file mode 100644 index 000000000..3a8217b2c --- /dev/null +++ b/app/AccountancyModule/EducationModule/templates/Budget/default.latte @@ -0,0 +1,92 @@ +{block #title}{$event->getDisplayName()} - rozpočet{/block} + +{define #budgetTable $entries, $income} + + + + + + + + + + + +
PoložkaČástka
{$entry->name} + {$entry->total|price} +
+{/define} + +{define #categoriesTable $categoriesSummary, $income} + + + + + + + + {var $balance = 0} + + {do $balance += (float)$categorySummary->total->getAmount()/100} + + + + + + + +
PoložkaČástka
{$categorySummary->name} + {$categorySummary->total|price} +
Celkem{$balance|price}
+{/define} + +{block #content} + +{include ../header.latte} + +{ifset $missingCategories} + {control categoryAutocomputedControl} +{else} +
+

Nekonzistentní data!

+

Součet paragonů v kategoriích neodpovídá částkám uvedeným ve SkautISu.

+ {if $isEditable} +

Hospodaření může aktualizovat data ve SkautISu tak, aby byla shodná s evidencí plateb.

+
+ {if $isUpdateStatementAllowed} + + + Aktualizovat data ve SkautISu + + {else} +

+ + Nemáte oprávnění pro úpravu částek v rozpočtu uvedených ve skautisu. +

+ {/if} + {/if} +
+ +
+
+

Skutečné náklady

+ {include #categoriesTable $categoriesSummary, FALSE} +
+
+

Skutečné výnosy

+ {include #categoriesTable $categoriesSummary, TRUE} +
+ +
+ +
+

Předpokl. náklady

+ {include #budgetTable $budgetEntries, FALSE} +
+
+

Předpokládané výnosy

+ {include #budgetTable $budgetEntries, TRUE} +
+
+{/ifset} diff --git a/app/AccountancyModule/EducationModule/templates/header.latte b/app/AccountancyModule/EducationModule/templates/header.latte index 01dae47ed..576bd5655 100644 --- a/app/AccountancyModule/EducationModule/templates/header.latte +++ b/app/AccountancyModule/EducationModule/templates/header.latte @@ -16,6 +16,10 @@ Evidence plateb +
  • + Rozpočet +