Add & generate tracking information to (Supplier-)OrderConfirmation. Fixes #110
This commit is contained in:
@ -1,8 +1,5 @@
|
||||
package org.hso.ecommerce.action.cronjob;
|
||||
|
||||
import java.sql.Timestamp;
|
||||
import java.util.HashMap;
|
||||
|
||||
import org.hso.ecommerce.action.cronjob.ReadSupplierDataAction.ArticleIdentifier;
|
||||
import org.hso.ecommerce.action.cronjob.ReadSupplierDataAction.Offer;
|
||||
import org.hso.ecommerce.api.SupplierService;
|
||||
@ -14,6 +11,9 @@ import org.hso.ecommerce.entities.supplier.SupplierOrder;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.sql.Timestamp;
|
||||
import java.util.HashMap;
|
||||
|
||||
public class ReorderAction {
|
||||
private static final Logger log = LoggerFactory.getLogger(ReorderAction.class);
|
||||
|
||||
@ -102,6 +102,10 @@ public class ReorderAction {
|
||||
createdOrder.numberOfUnits = confirm.quantity;
|
||||
createdOrder.pricePerUnitNetCent = confirm.pricePerUnitNetCent;
|
||||
createdOrder.totalPriceNet = confirm.totalPriceNetCharged;
|
||||
createdOrder.carrier = confirm.carrier;
|
||||
createdOrder.trackingId = confirm.trackingId;
|
||||
createdOrder.estimatedArrival = Timestamp.valueOf(confirm.estimatedArrival);
|
||||
|
||||
return createdOrder;
|
||||
}
|
||||
}
|
||||
|
@ -1,5 +1,7 @@
|
||||
package org.hso.ecommerce.api.data;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
public class OrderConfirmation {
|
||||
public String manufacturer;
|
||||
public String articleNumber;
|
||||
@ -9,4 +11,8 @@ public class OrderConfirmation {
|
||||
public int pricePerUnitNetCent;
|
||||
public int discountNetCent;
|
||||
public int totalPriceNetCharged;
|
||||
|
||||
public String carrier;
|
||||
public String trackingId;
|
||||
public LocalDateTime estimatedArrival;
|
||||
}
|
||||
|
@ -20,7 +20,6 @@ import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@ -115,6 +114,10 @@ public class SupplierOrderController {
|
||||
public String quantity;
|
||||
public String priceTotal;
|
||||
public boolean arrived;
|
||||
public String carrier;
|
||||
public String trackingId;
|
||||
public String estimatedArrival;
|
||||
|
||||
|
||||
public UImodelSupplierOrder(SupplierOrder order, Article article) {
|
||||
this.id = order.id;
|
||||
@ -125,9 +128,13 @@ public class SupplierOrderController {
|
||||
this.quantity = String.valueOf(order.numberOfUnits);
|
||||
this.priceTotal = String.format("%.2f", ((float) order.totalPriceNet / 100));
|
||||
|
||||
Date date = new Date();
|
||||
date.setTime(order.created.getTime());
|
||||
this.dateOrder = new SimpleDateFormat("dd.MM.yyyy").format(date);
|
||||
this.carrier = order.carrier != null ? order.carrier : " - ";
|
||||
this.trackingId = order.trackingId != null ? order.trackingId : " - ";
|
||||
this.estimatedArrival = order.estimatedArrival != null
|
||||
? new SimpleDateFormat("yyyy.MM.dd HH:00").format(order.estimatedArrival) + " Uhr"
|
||||
: " - ";
|
||||
|
||||
this.dateOrder = new SimpleDateFormat("yyyy.MM.dd").format(order.created);
|
||||
|
||||
arrived = order.delivered != null;
|
||||
}
|
||||
|
@ -28,6 +28,15 @@ public class SupplierOrder {
|
||||
// Includes discounts
|
||||
public int totalPriceNet;
|
||||
|
||||
@Column(nullable = true)
|
||||
public String carrier;
|
||||
|
||||
@Column(nullable = true)
|
||||
public String trackingId;
|
||||
|
||||
@Column(nullable = true)
|
||||
public Timestamp estimatedArrival;
|
||||
|
||||
@Column(nullable = true)
|
||||
public Timestamp delivered;
|
||||
|
||||
|
@ -47,7 +47,8 @@
|
||||
<td><span th:text="${order.id}"></span></td>
|
||||
<td><span th:text="${order.dateOrder}"></span></td>
|
||||
<td><span th:text="${order.supplierName}"></span></td>
|
||||
<td><a th:href="@{/intern/articles/{id}(id = ${order.articleId})}" class="button smaller" th:text="${order.articleName}"></a></td>
|
||||
<td><a th:href="@{/intern/articles/{id}(id = ${order.articleId})}" class="smaller"
|
||||
th:text="${order.articleName}"></a></td>
|
||||
<td><span th:text="${order.priceNet}"></span> €</td>
|
||||
<td><span th:text="${order.quantity}"></span></td>
|
||||
<td><span th:text="${order.priceTotal}"></span> €</td>
|
||||
@ -57,10 +58,13 @@
|
||||
</div>
|
||||
<!-- ELSE -->
|
||||
<div th:unless="${order.arrived}">
|
||||
Unterwegs <br>
|
||||
<form class="detailgrid" action="#" th:action="@{/intern/supplierOrders/store/{id}(id = ${order.id})}" method="POST">
|
||||
<input class="button smaller" type="submit" value="Eingang verbuchen" />
|
||||
Unterwegs: <span th:text="${order.carrier}"></span>, <span
|
||||
th:text="${order.trackingId}"></span><br/>
|
||||
<form class="detailgrid" action="#"
|
||||
th:action="@{/intern/supplierOrders/store/{id}(id = ${order.id})}" method="POST">
|
||||
<input class="button smaller" type="submit" value="Eingang verbuchen"/>
|
||||
</form>
|
||||
Geschätzte Ankunft: <span th:text="${order.estimatedArrival}"></span>.
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
|
Reference in New Issue
Block a user