added supplier balance label
This commit is contained in:
parent
1cb52a20d4
commit
93a5863fbe
|
@ -4,9 +4,12 @@ import java.text.SimpleDateFormat;
|
|||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
import org.hso.ecommerce.entities.booking.BookingAccountEntry;
|
||||
import org.hso.ecommerce.entities.supplier.Supplier;
|
||||
import org.hso.ecommerce.entities.supplier.SupplierOrder;
|
||||
import org.hso.ecommerce.repos.booking.BookingAccountEntryRepository;
|
||||
import org.hso.ecommerce.repos.supplier.SupplierOrderRepository;
|
||||
import org.hso.ecommerce.repos.supplier.SupplierRepository;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
@ -26,6 +29,9 @@ public class SupplierIndexController {
|
|||
@Autowired
|
||||
private final SupplierOrderRepository supplierOrderRepository = null;
|
||||
|
||||
@Autowired
|
||||
private final BookingAccountEntryRepository bookingAccountEntryRepository = null;
|
||||
|
||||
@GetMapping("suppliers")
|
||||
public String listSuppliers(Model model) {
|
||||
|
||||
|
@ -43,7 +49,7 @@ public class SupplierIndexController {
|
|||
@GetMapping("/suppliers/{id}")
|
||||
public String supplierDetail(Model model, @PathVariable String id) {
|
||||
|
||||
int supplierId = Integer.parseInt(id);
|
||||
long supplierId = Integer.parseInt(id);
|
||||
|
||||
List<UImodelSupplierDetailOrders> orders = new ArrayList<UImodelSupplierDetailOrders>();
|
||||
|
||||
|
@ -51,8 +57,14 @@ public class SupplierIndexController {
|
|||
orders.add(new UImodelSupplierDetailOrders(supplierOrder));
|
||||
}
|
||||
|
||||
// get latest supplier booking
|
||||
Optional<BookingAccountEntry> supplierBooking = bookingAccountEntryRepository.getBySupplier(supplierId);
|
||||
|
||||
//get account balance
|
||||
String supplierBalance = ((supplierBooking.isPresent()) ? String.format("%.2f", ((float) supplierBooking.get().newSumCent / 100)) : "0,00");
|
||||
|
||||
UImodelSupplierDetail total = new UImodelSupplierDetail(supplierRepository.findSupplierById(supplierId).name,
|
||||
"42€", orders);
|
||||
supplierBalance, orders);
|
||||
|
||||
model.addAttribute("SupplierDetail", total);
|
||||
|
||||
|
|
|
@ -65,7 +65,7 @@
|
|||
<h2>Buchungen</h2>
|
||||
<div>
|
||||
<h4> Kontostand </h4>
|
||||
<h3><span th:text="${SupplierDetail.balance}"></span></h3>
|
||||
<h3><span th:text="${SupplierDetail.balance}"></span> €</h3>
|
||||
</div>
|
||||
<p>
|
||||
<table id="main-table">
|
||||
|
|
Reference in New Issue