add dueDate, fix icons, add CSV export, UI fixes
This commit is contained in:
+11
@@ -55,6 +55,9 @@ public class TurnoverManager {
|
||||
case "created":
|
||||
path = qTurnover.created;
|
||||
break;
|
||||
case "dueDate":
|
||||
path = qTurnover.dueDate;
|
||||
break;
|
||||
case "updated":
|
||||
path = qTurnover.updated;
|
||||
break;
|
||||
@@ -90,6 +93,14 @@ public class TurnoverManager {
|
||||
builder.and(qTurnover.created.before(filter.getCreated().getMax()));
|
||||
}
|
||||
}
|
||||
if (filter.getDueDate() != null) {
|
||||
if (filter.getDueDate().getMin() != null) {
|
||||
builder.and(qTurnover.dueDate.after(filter.getDueDate().getMin()));
|
||||
}
|
||||
if (filter.getDueDate().getMax() != null) {
|
||||
builder.and(qTurnover.dueDate.before(filter.getDueDate().getMax()));
|
||||
}
|
||||
}
|
||||
if (filter.getUpdated() != null) {
|
||||
if (filter.getUpdated().getMin() != null) {
|
||||
builder.and(qTurnover.updated.after(filter.getUpdated().getMin()));
|
||||
|
||||
+16
-13
@@ -53,16 +53,19 @@ public class TurnoverController extends BaseController {
|
||||
@RequestParam("descending") Optional<Boolean> descending,
|
||||
@RequestParam("from") Optional<Instant> from,
|
||||
@RequestParam("to") Optional<Instant> to,
|
||||
@RequestParam("created_from") Optional<Instant> fromCreated,
|
||||
@RequestParam("created_to") Optional<Instant> toCreated,
|
||||
@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.setDueDate(new MinMax<Instant>(from.orElse(null), to.orElse(null)));
|
||||
filter.setCreated(new MinMax<Instant>(fromCreated.orElse(null), toCreated.orElse(null)));
|
||||
filter.setCustomer(customer.orElse(null));
|
||||
filter.setMotif(motif.orElse(null));
|
||||
|
||||
return turnoverManager.fetch(getCurrentUsername(), limitParameter.orElse(15L), offsetParameter.orElse(0L),
|
||||
sort.orElse("created"), descending.orElse(false), filter);
|
||||
sort.orElse("dueDate"), descending.orElse(false), filter);
|
||||
}
|
||||
|
||||
@PreAuthorize("isAuthenticated()")
|
||||
@@ -75,11 +78,14 @@ public class TurnoverController extends BaseController {
|
||||
@RequestParam("descending") Optional<Boolean> descending,
|
||||
@RequestParam("from") Optional<Instant> from,
|
||||
@RequestParam("to") Optional<Instant> to,
|
||||
@RequestParam("created_from") Optional<Instant> fromCreated,
|
||||
@RequestParam("created_to") Optional<Instant> toCreated,
|
||||
@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.setDueDate(new MinMax<Instant>(from.orElse(null), to.orElse(null)));
|
||||
filter.setCreated(new MinMax<Instant>(fromCreated.orElse(null), toCreated.orElse(null)));
|
||||
filter.setCustomer(customer.orElse(null));
|
||||
filter.setMotif(motif.orElse(null));
|
||||
|
||||
@@ -124,6 +130,9 @@ public class TurnoverController extends BaseController {
|
||||
}
|
||||
turnover.setCreated(Instant.now());
|
||||
turnover.setUpdated(turnover.getCreated());
|
||||
if (turnover.getDueDate() == null) {
|
||||
turnover.setDueDate(turnover.getCreated());
|
||||
}
|
||||
|
||||
return turnoverManager.save(turnover);
|
||||
}
|
||||
@@ -154,18 +163,12 @@ public class TurnoverController extends BaseController {
|
||||
throw new EntityResponseStatusException(HttpStatus.NOT_MODIFIED);
|
||||
}
|
||||
|
||||
if (turnover.getDueDate() == null) {
|
||||
turnover.setDueDate(turnover.getCreated());
|
||||
}
|
||||
|
||||
turnover.setUpdated(Instant.now());
|
||||
|
||||
return turnoverManager.save(turnover);
|
||||
}
|
||||
|
||||
@PreAuthorize("hasRole('ROLE_ADMIN')")
|
||||
@DeleteMapping("/{id}")
|
||||
public void deleteById(@PathVariable("id") Long id) {
|
||||
if (!turnoverManager.exists(id)) {
|
||||
throw new EntityResponseStatusException(HttpStatus.NO_CONTENT);
|
||||
}
|
||||
|
||||
turnoverManager.deleteById(id);
|
||||
}
|
||||
}
|
||||
|
||||
+2
@@ -77,6 +77,8 @@ public class DebugController {
|
||||
turnover.setCreated(randomDate(startInclusive, endExclusive));
|
||||
turnover.setUpdated(splittableRandom.nextBoolean() ? turnover.getCreated()
|
||||
: randomDate(turnover.getCreated(), endExclusive));
|
||||
turnover.setDueDate(splittableRandom.nextBoolean() ? turnover.getCreated()
|
||||
: randomDate(startInclusive, turnover.getCreated()));
|
||||
turnover.setCustomer(RandomStringUtils.randomAlphabetic(splittableRandom.nextInt(3, 10)));
|
||||
|
||||
turnover.setMotif(RandomStringUtils.randomAlphabetic(splittableRandom.nextInt(5, 30)));
|
||||
|
||||
+18
-3
@@ -49,16 +49,19 @@ public class TurnoverManagementController extends BaseController {
|
||||
@RequestParam("descending") Optional<Boolean> descending,
|
||||
@RequestParam("from") Optional<Instant> from,
|
||||
@RequestParam("to") Optional<Instant> to,
|
||||
@RequestParam("created_from") Optional<Instant> fromCreated,
|
||||
@RequestParam("created_to") Optional<Instant> toCreated,
|
||||
@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.setDueDate(new MinMax<Instant>(from.orElse(null), to.orElse(null)));
|
||||
filter.setCreated(new MinMax<Instant>(fromCreated.orElse(null), toCreated.orElse(null)));
|
||||
filter.setCustomer(customer.orElse(null));
|
||||
filter.setMotif(motif.orElse(null));
|
||||
|
||||
return turnoverManager.fetch(usernameParameter.orElse(null), limitParameter.orElse(15L),
|
||||
offsetParameter.orElse(0L), sort.orElse("created"), descending.orElse(false), filter);
|
||||
offsetParameter.orElse(0L), sort.orElse("dueDate"), descending.orElse(false), filter);
|
||||
}
|
||||
|
||||
@PreAuthorize("hasRole('ROLE_ADMIN')")
|
||||
@@ -72,11 +75,14 @@ public class TurnoverManagementController extends BaseController {
|
||||
@RequestParam("descending") Optional<Boolean> descending,
|
||||
@RequestParam("from") Optional<Instant> from,
|
||||
@RequestParam("to") Optional<Instant> to,
|
||||
@RequestParam("created_from") Optional<Instant> fromCreated,
|
||||
@RequestParam("created_to") Optional<Instant> toCreated,
|
||||
@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.setDueDate(new MinMax<Instant>(from.orElse(null), to.orElse(null)));
|
||||
filter.setCreated(new MinMax<Instant>(fromCreated.orElse(null), toCreated.orElse(null)));
|
||||
filter.setCustomer(customer.orElse(null));
|
||||
filter.setMotif(motif.orElse(null));
|
||||
return turnoverManager.overview(usernameParameter.orElse(null), limitParameter.orElse(15L),
|
||||
@@ -106,6 +112,15 @@ public class TurnoverManagementController extends BaseController {
|
||||
throw new EntityResponseStatusException(errors.getAllErrors(), HttpStatus.CONFLICT);
|
||||
}
|
||||
|
||||
Turnover existing = turnoverManager.get(turnover.getId());
|
||||
if (existing.equals(turnover)) {
|
||||
throw new EntityResponseStatusException(HttpStatus.NOT_MODIFIED);
|
||||
}
|
||||
|
||||
if (turnover.getDueDate() == null) {
|
||||
turnover.setDueDate(turnover.getCreated());
|
||||
}
|
||||
|
||||
turnover.setUpdated(Instant.now());
|
||||
|
||||
return turnoverManager.save(turnover);
|
||||
|
||||
+9
@@ -5,6 +5,7 @@ import java.time.Instant;
|
||||
public class TurnoverFilterModel {
|
||||
|
||||
private MinMax<Instant> created;
|
||||
private MinMax<Instant> dueDate;
|
||||
private MinMax<Instant> updated;
|
||||
private String customer;
|
||||
private String motif;
|
||||
@@ -19,6 +20,14 @@ public class TurnoverFilterModel {
|
||||
this.created = created;
|
||||
}
|
||||
|
||||
public MinMax<Instant> getDueDate() {
|
||||
return dueDate;
|
||||
}
|
||||
|
||||
public void setDueDate(MinMax<Instant> dueDate) {
|
||||
this.dueDate = dueDate;
|
||||
}
|
||||
|
||||
public MinMax<Instant> getUpdated() {
|
||||
return updated;
|
||||
}
|
||||
|
||||
@@ -25,6 +25,9 @@ public class Turnover {
|
||||
@Column(name = "created", nullable = false, updatable = false)
|
||||
private Instant created;
|
||||
|
||||
@Column(name = "due_date", nullable = false)
|
||||
private Instant dueDate;
|
||||
|
||||
@Column(name = "updated", nullable = false)
|
||||
private Instant updated;
|
||||
|
||||
@@ -72,6 +75,14 @@ public class Turnover {
|
||||
this.created = created;
|
||||
}
|
||||
|
||||
public Instant getDueDate() {
|
||||
return dueDate;
|
||||
}
|
||||
|
||||
public void setDueDate(Instant dueDate) {
|
||||
this.dueDate = dueDate;
|
||||
}
|
||||
|
||||
public Instant getUpdated() {
|
||||
return updated;
|
||||
}
|
||||
@@ -136,6 +147,8 @@ public class Turnover {
|
||||
Turnover turnover = (Turnover) obj;
|
||||
boolean equals = true;
|
||||
|
||||
equals &= dueDate.equals(turnover.getDueDate());
|
||||
|
||||
equals &= id == null && turnover.getId() == null || id.equals(turnover.getId());
|
||||
|
||||
equals &= username == null && turnover.getUsername() == null || username.equals(turnover.getUsername());
|
||||
|
||||
Reference in New Issue
Block a user