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

View file

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