Skip to content

Commit

Permalink
Merge pull request #109 from itk-dev/feature/1207-search-invoice
Browse files Browse the repository at this point in the history
1207: Added invoice query
  • Loading branch information
rimi-itk authored Apr 19, 2024
2 parents a0b727e + 58b1299 commit 0cd9127
Show file tree
Hide file tree
Showing 7 changed files with 26 additions and 2 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

* [PR-109](https://github.com/itk-dev/economics/pull/109)
1207: Added invoice query
* [PR-106](https://github.com/itk-dev/economics/pull/106)
1202: Handled worklog deletions

Expand Down
6 changes: 5 additions & 1 deletion assets/styles/app.css
Original file line number Diff line number Diff line change
Expand Up @@ -140,10 +140,14 @@
@apply invisible;
}

.form-default, #sprint_report {
#sprint_report {
@apply grid gap-3 mb-6 md:grid-cols-4;
}

.form-default {
@apply grid gap-3 mb-6 md:grid-cols-5;
}

.form-default > div {
@apply flex flex-col justify-end;
}
Expand Down
8 changes: 8 additions & 0 deletions src/Form/InvoiceFilterType.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,14 @@ class InvoiceFilterType extends AbstractType
public function buildForm(FormBuilderInterface $builder, array $options): void
{
$builder
->add('query', SearchType::class, [
'label' => 'invoices.query_label',
'label_attr' => ['class' => 'label'],
'attr' => [
'class' => 'form-element',
'placeholder' => 'invoices.query_placeholder',
],
])
->add('recorded', ChoiceType::class, [
'required' => true,
'label' => 'invoices.recorded',
Expand Down
1 change: 1 addition & 0 deletions src/Model/Invoices/InvoiceFilterData.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

class InvoiceFilterData
{
public ?string $query = '';
public ?bool $recorded = false;
public ?string $createdBy = '';
public ?bool $projectBilling = false;
Expand Down
8 changes: 7 additions & 1 deletion src/Repository/InvoiceRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -82,8 +82,14 @@ public function getFilteredPagination(InvoiceFilterData $invoiceFilterData, int

$qb->andWhere('invoice.recorded = :recorded')->setParameter('recorded', $invoiceFilterData->recorded);

$getLikeExpression = static fn (string $value) => str_contains($value, '%') ? $value : '%'.$value.'%';

if (!empty($invoiceFilterData->query)) {
$qb->andWhere('invoice.name LIKE :query')->setParameter('query', $getLikeExpression($invoiceFilterData->query));
}

if (!empty($invoiceFilterData->createdBy)) {
$qb->andWhere('invoice.createdBy LIKE :createdBy')->setParameter('createdBy', $invoiceFilterData->createdBy);
$qb->andWhere('invoice.createdBy LIKE :createdBy')->setParameter('createdBy', $getLikeExpression($invoiceFilterData->createdBy));
}

if ($invoiceFilterData->projectBilling) {
Expand Down
1 change: 1 addition & 0 deletions templates/invoices/index.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@

{{ form_start(form) }}
<div class="form-default">
{{ form_row(form.query) }}
{{ form_row(form.recorded) }}
{{ form_row(form.createdBy) }}
{{ form_row(form.projectBilling) }}
Expand Down
2 changes: 2 additions & 0 deletions translations/messages.da.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -280,6 +280,8 @@ invoices:
client_project_lead: "Project Lead"
required_fields_not_set_for_creating_entries: "\"Til konto\" og \"Materialenummer\" skal være valgt før der kan oprettes fakturalinjer."
type: "Kundekonto type"
query_label: Søg
query_placeholder: Søg på fakturanavn

material_number_enum:
internal: "Interne: 103361"
Expand Down

0 comments on commit 0cd9127

Please sign in to comment.