fixup! Update basics of order package to salespoint

This commit is contained in:
Mathis Kral 2023-11-19 13:37:08 +01:00
parent 506824a8b7
commit 43785cde3d
2 changed files with 12 additions and 8 deletions

View file

@ -8,6 +8,7 @@ import org.salespointframework.order.Order;
import org.salespointframework.order.OrderManagement;
import org.salespointframework.quantity.Quantity;
import org.salespointframework.time.Interval;
import org.salespointframework.useraccount.Role;
import org.salespointframework.useraccount.UserAccount;
import org.salespointframework.useraccount.web.LoggedIn;
import org.springframework.data.domain.Pageable;
@ -92,11 +93,15 @@ public class OrderController {
}
@PostMapping("/allOrders/remove")
@PreAuthorize("hasRole('BOSS')")
public String removeOrder(@RequestParam Order.OrderIdentifier orderID) {
CustomOrder myOrder = orderManagement.get(orderID).get(); // TODO
orderManagement.cancelOrder(myOrder, "I have my own reasons.");
return "redirect:/allOrders";
public String removeOrder(@RequestParam Order.OrderIdentifier orderID, @LoggedIn Optional<UserAccount> userAccount) {
return userAccount.map(account -> {
if (account.hasRole(Role.of("ADMIN"))) {
CustomOrder myOrder = orderManagement.get(orderID).get(); // FIXME
orderManagement.cancelOrder(myOrder, "I have my own reasons.");
return "redirect:/allOrders";
}
return "redirect:/";
}).orElse("redirect:/");
}
@ -114,7 +119,6 @@ public class OrderController {
return userAccount.map(account -> {
CustomOrder myOrder = new CustomOrder(account.getId(), cart);
orderManagement.payOrder(myOrder); // TODO: change this later
orderManagement.completeOrder(myOrder); // TODO: change this later
cart.clear();
List<CustomOrder> myOrders = orderManagement.findBy(account).stream().collect(Collectors.toList());

View file

@ -13,7 +13,7 @@
<th>Kunde</th>
<th>Produktdetails</th>
<th>Rechnung</th>
<th>Bezahlt</th>
<th>Status</th>
<th>Preis</th>
<th></th>
</tr>
@ -37,7 +37,7 @@
<span>Keine Rechnung verfügbar</span>
</div>
</td>
<td>&#9746</td> <!--von Admin bearbeitbar-->
<td th:text="${order.getOrderStatus()}"></td> <!--von Admin bearbeitbar-->
<td>
<th:block th:text="${order.getTotal()}"/>
<th:block th:text="€"/>