update customer filter and overview
This commit is contained in:
+31
-1
@@ -1,10 +1,10 @@
|
|||||||
package de.champonthis.buntspecht.controller;
|
package de.champonthis.buntspecht.controller;
|
||||||
|
|
||||||
import java.time.Instant;
|
import java.time.Instant;
|
||||||
|
import java.util.List;
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.data.web.PagedModel;
|
|
||||||
import org.springframework.http.HttpStatus;
|
import org.springframework.http.HttpStatus;
|
||||||
import org.springframework.security.access.prepost.PreAuthorize;
|
import org.springframework.security.access.prepost.PreAuthorize;
|
||||||
import org.springframework.util.StringUtils;
|
import org.springframework.util.StringUtils;
|
||||||
@@ -20,6 +20,7 @@ import org.springframework.web.bind.annotation.RequestParam;
|
|||||||
import org.springframework.web.bind.annotation.RestController;
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
import com.querydsl.core.QueryResults;
|
import com.querydsl.core.QueryResults;
|
||||||
|
import com.querydsl.core.Tuple;
|
||||||
|
|
||||||
import de.champonthis.buntspecht.businesslogic.TurnoverManager;
|
import de.champonthis.buntspecht.businesslogic.TurnoverManager;
|
||||||
import de.champonthis.buntspecht.businesslogic.UserManager;
|
import de.champonthis.buntspecht.businesslogic.UserManager;
|
||||||
@@ -64,6 +65,35 @@ public class TurnoverController extends BaseController {
|
|||||||
sort.orElse("created"), descending.orElse(false), filter);
|
sort.orElse("created"), descending.orElse(false), filter);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@PreAuthorize("isAuthenticated()")
|
||||||
|
@GetMapping("/overview")
|
||||||
|
@Transactional
|
||||||
|
public Tuple overview(
|
||||||
|
@RequestParam("limit") Optional<Long> limitParameter,
|
||||||
|
@RequestParam("offset") Optional<Long> offsetParameter,
|
||||||
|
@RequestParam("sort") Optional<String> sort,
|
||||||
|
@RequestParam("descending") Optional<Boolean> descending,
|
||||||
|
@RequestParam("from") Optional<Instant> from,
|
||||||
|
@RequestParam("to") Optional<Instant> to,
|
||||||
|
@RequestParam("customer") Optional<String> customer,
|
||||||
|
@RequestParam("motif") Optional<String> motif) {
|
||||||
|
|
||||||
|
TurnoverFilterModel filter = new TurnoverFilterModel();
|
||||||
|
filter.setCreated(new MinMax<Instant>(from.orElse(null), to.orElse(null)));
|
||||||
|
filter.setCustomer(customer.orElse(null));
|
||||||
|
filter.setMotif(motif.orElse(null));
|
||||||
|
|
||||||
|
List<Tuple> result = turnoverManager.overview(getCurrentUsername(), limitParameter.orElse(15L),
|
||||||
|
offsetParameter.orElse(0L), sort.orElse("username"),
|
||||||
|
descending.orElse(false), filter).getResults();
|
||||||
|
|
||||||
|
if (result.isEmpty()) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
return result.get(0);
|
||||||
|
}
|
||||||
|
|
||||||
@PreAuthorize("isAuthenticated()")
|
@PreAuthorize("isAuthenticated()")
|
||||||
@GetMapping("/{id}")
|
@GetMapping("/{id}")
|
||||||
@Transactional
|
@Transactional
|
||||||
|
|||||||
+1
-1
@@ -64,7 +64,7 @@ public class TurnoverManagementController extends BaseController {
|
|||||||
@PreAuthorize("hasRole('ROLE_ADMIN')")
|
@PreAuthorize("hasRole('ROLE_ADMIN')")
|
||||||
@GetMapping("/overview")
|
@GetMapping("/overview")
|
||||||
@Transactional
|
@Transactional
|
||||||
public QueryResults<Tuple> fetchGroup(
|
public QueryResults<Tuple> overview(
|
||||||
@RequestParam("username") Optional<String> usernameParameter,
|
@RequestParam("username") Optional<String> usernameParameter,
|
||||||
@RequestParam("limit") Optional<Long> limitParameter,
|
@RequestParam("limit") Optional<Long> limitParameter,
|
||||||
@RequestParam("offset") Optional<Long> offsetParameter,
|
@RequestParam("offset") Optional<Long> offsetParameter,
|
||||||
|
|||||||
@@ -31,6 +31,16 @@
|
|||||||
}
|
}
|
||||||
</mat-autocomplete>
|
</mat-autocomplete>
|
||||||
</mat-form-field>
|
</mat-form-field>
|
||||||
|
|
||||||
|
<mat-form-field class="margin">
|
||||||
|
<mat-label>{{'turnovers.filter.customer' | i18n}}</mat-label>
|
||||||
|
<input type="text" matInput (input)="setInputFilter('customer', $event.target)">
|
||||||
|
</mat-form-field>
|
||||||
|
|
||||||
|
<mat-form-field class="margin">
|
||||||
|
<mat-label>{{'turnovers.filter.motif' | i18n}}</mat-label>
|
||||||
|
<input type="text" matInput (input)="setInputFilter('motif', $event.target)">
|
||||||
|
</mat-form-field>
|
||||||
</form>
|
</form>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|||||||
@@ -19,9 +19,19 @@
|
|||||||
<mat-datepicker-toggle matIconSuffix [for]="picker"></mat-datepicker-toggle>
|
<mat-datepicker-toggle matIconSuffix [for]="picker"></mat-datepicker-toggle>
|
||||||
<mat-date-range-picker #picker></mat-date-range-picker>
|
<mat-date-range-picker #picker></mat-date-range-picker>
|
||||||
</mat-form-field>
|
</mat-form-field>
|
||||||
|
|
||||||
|
<mat-form-field class="margin">
|
||||||
|
<mat-label>{{'turnovers.filter.customer' | i18n}}</mat-label>
|
||||||
|
<input type="text" matInput (input)="setInputFilter('customer', $event.target)">
|
||||||
|
</mat-form-field>
|
||||||
|
|
||||||
|
<mat-form-field class="margin">
|
||||||
|
<mat-label>{{'turnovers.filter.motif' | i18n}}</mat-label>
|
||||||
|
<input type="text" matInput (input)="setInputFilter('motif', $event.target)">
|
||||||
|
</mat-form-field>
|
||||||
</form>
|
</form>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<ui-turnovers class="flex column grow" [turnovers]="turnovers" (page)="applyPage($event)"
|
<ui-turnovers class="flex column grow" [turnovers]="turnovers" [overview]="overview" (page)="applyPage($event)"
|
||||||
(sort)="applySort($event)"></ui-turnovers>
|
(sort)="applySort($event)"></ui-turnovers>
|
||||||
</div>
|
</div>
|
||||||
@@ -14,6 +14,7 @@ import { UserManagementService } from 'src/app/services/user.management.service'
|
|||||||
export class PageTurnovers implements OnInit {
|
export class PageTurnovers implements OnInit {
|
||||||
|
|
||||||
turnovers: any;
|
turnovers: any;
|
||||||
|
overview: any[];
|
||||||
sort: string = "created";
|
sort: string = "created";
|
||||||
descending: boolean = true;
|
descending: boolean = true;
|
||||||
filterOpen: boolean = false;
|
filterOpen: boolean = false;
|
||||||
@@ -40,6 +41,17 @@ export class PageTurnovers implements OnInit {
|
|||||||
this.turnovers = { error: error };
|
this.turnovers = { error: error };
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
this.turnoverService.overview(this.turnovers.limit || 15, this.turnovers.offset || 0, this.sort, this.descending, this.turnovers.filter).subscribe({
|
||||||
|
next: (data: any) => {
|
||||||
|
this.overview = data;
|
||||||
|
if (!this.overview) {
|
||||||
|
this.overview = ['', 0, 0];
|
||||||
|
}
|
||||||
|
}, error: (error) => {
|
||||||
|
this.turnovers = { error: error };
|
||||||
|
}
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
applyPage(event: PageEvent) {
|
applyPage(event: PageEvent) {
|
||||||
@@ -54,6 +66,10 @@ export class PageTurnovers implements OnInit {
|
|||||||
this.update();
|
this.update();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
setInputFilter(key: string, target: EventTarget) {
|
||||||
|
this.setFilter(key, (target as HTMLInputElement).value);
|
||||||
|
}
|
||||||
|
|
||||||
setFilter(key: string, value) {
|
setFilter(key: string, value) {
|
||||||
if (value != this.turnovers.filter[key]) {
|
if (value != this.turnovers.filter[key]) {
|
||||||
this.turnovers.filter[key] = value;
|
this.turnovers.filter[key] = value;
|
||||||
|
|||||||
@@ -16,6 +16,10 @@ export class TurnoverService {
|
|||||||
return this.abstractService.fetch("/turnovers", limit, offset, sort, descending, filter);
|
return this.abstractService.fetch("/turnovers", limit, offset, sort, descending, filter);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
overview(limit: number, offset: number, sort: string, descending: boolean, filter: any | undefined) {
|
||||||
|
return this.abstractService.fetch("/turnovers/overview", limit, offset, sort, descending, filter);
|
||||||
|
}
|
||||||
|
|
||||||
get(id: number) {
|
get(id: number) {
|
||||||
return this.http.get(environment.apiUrl + "/turnovers/" + id);
|
return this.http.get(environment.apiUrl + "/turnovers/" + id);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -125,6 +125,12 @@
|
|||||||
<span class="spacer"></span>
|
<span class="spacer"></span>
|
||||||
|
|
||||||
<div class="mat-mdc-paginator flex">
|
<div class="mat-mdc-paginator flex">
|
||||||
|
@if (overview && overview.length > 2) {
|
||||||
|
<div class="flex middle">
|
||||||
|
<span class="margin">{{'turnover.price.total' | i18n:(overview[1] | number: '1.2-2')}}</span> <span
|
||||||
|
class="margin">{{'turnover.timeInvestment.total' | i18n:(overview[2] | number: '1.1-1')}}</span>
|
||||||
|
</div>
|
||||||
|
}
|
||||||
<span class="spacer"></span>
|
<span class="spacer"></span>
|
||||||
<mat-paginator [pageSizeOptions]="pageSizeOptions" [pageIndex]="turnovers.offset / turnovers.limit"
|
<mat-paginator [pageSizeOptions]="pageSizeOptions" [pageIndex]="turnovers.offset / turnovers.limit"
|
||||||
[length]="turnovers.total" [pageSize]="turnovers.limit" (page)="page.emit($event)" showFirstLastButtons>
|
[length]="turnovers.total" [pageSize]="turnovers.limit" (page)="page.emit($event)" showFirstLastButtons>
|
||||||
|
|||||||
@@ -11,6 +11,7 @@ import { Router } from '@angular/router';
|
|||||||
export class UiTurnovers implements OnInit {
|
export class UiTurnovers implements OnInit {
|
||||||
|
|
||||||
@Input() turnovers: any;
|
@Input() turnovers: any;
|
||||||
|
@Input() overview: any[];
|
||||||
@Input() showFilter: boolean = true;
|
@Input() showFilter: boolean = true;
|
||||||
@Input() linkTurnover: boolean = true;
|
@Input() linkTurnover: boolean = true;
|
||||||
@Input() username: boolean = false;
|
@Input() username: boolean = false;
|
||||||
|
|||||||
@@ -115,13 +115,15 @@
|
|||||||
"price": {
|
"price": {
|
||||||
".": "Preis",
|
".": "Preis",
|
||||||
"error": "Angabe des Preises erforderlich",
|
"error": "Angabe des Preises erforderlich",
|
||||||
"suffix": "€"
|
"suffix": "€",
|
||||||
|
"total": "Umsatz: {0} €"
|
||||||
},
|
},
|
||||||
"remark": "Bemerkungen",
|
"remark": "Bemerkungen",
|
||||||
"success": "Erfolgreich gespeichert",
|
"success": "Erfolgreich gespeichert",
|
||||||
"timeInvestment": {
|
"timeInvestment": {
|
||||||
".": "Zeiteinsatz",
|
".": "Zeiteinsatz",
|
||||||
"suffix": "Std."
|
"suffix": "Std.",
|
||||||
|
"total": "Zeiteinsatz: {0} Std."
|
||||||
},
|
},
|
||||||
"update": "Aktualisieren",
|
"update": "Aktualisieren",
|
||||||
"updated": {
|
"updated": {
|
||||||
@@ -134,10 +136,12 @@
|
|||||||
".": "Buchungen",
|
".": "Buchungen",
|
||||||
"filter": {
|
"filter": {
|
||||||
"created": {
|
"created": {
|
||||||
".": "Erstellungsdatum",
|
".": "Zeitraum",
|
||||||
"from": "von",
|
"from": "von",
|
||||||
"to": "bis"
|
"to": "bis"
|
||||||
},
|
},
|
||||||
|
"customer": "Kunde durchsuchen",
|
||||||
|
"motif": "Motif durchsuchen",
|
||||||
"username": "User auswählen"
|
"username": "User auswählen"
|
||||||
},
|
},
|
||||||
"mine": "Eigene Buchungen"
|
"mine": "Eigene Buchungen"
|
||||||
|
|||||||
@@ -1,15 +1,7 @@
|
|||||||
{
|
{
|
||||||
"folders": [
|
"folders": [
|
||||||
{
|
{
|
||||||
"path": "buntspecht-backend"
|
"path": "."
|
||||||
},
|
}
|
||||||
{
|
]
|
||||||
"path": "buntspecht-frontend"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"settings": {
|
|
||||||
"java.configuration.updateBuildConfiguration": "automatic",
|
|
||||||
"java.compile.nullAnalysis.mode": "disabled",
|
|
||||||
"html.autoClosingTags": false
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user