feature/supplier_page #52
@ -4,9 +4,12 @@ import java.text.SimpleDateFormat;
 | 
				
			|||||||
import java.util.ArrayList;
 | 
					import java.util.ArrayList;
 | 
				
			||||||
import java.util.Date;
 | 
					import java.util.Date;
 | 
				
			||||||
import java.util.List;
 | 
					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.Supplier;
 | 
				
			||||||
import org.hso.ecommerce.entities.supplier.SupplierOrder;
 | 
					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.SupplierOrderRepository;
 | 
				
			||||||
import org.hso.ecommerce.repos.supplier.SupplierRepository;
 | 
					import org.hso.ecommerce.repos.supplier.SupplierRepository;
 | 
				
			||||||
import org.springframework.beans.factory.annotation.Autowired;
 | 
					import org.springframework.beans.factory.annotation.Autowired;
 | 
				
			||||||
@ -26,6 +29,9 @@ public class SupplierIndexController {
 | 
				
			|||||||
	@Autowired
 | 
						@Autowired
 | 
				
			||||||
	private final SupplierOrderRepository supplierOrderRepository = null;
 | 
						private final SupplierOrderRepository supplierOrderRepository = null;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						@Autowired
 | 
				
			||||||
 | 
						private final BookingAccountEntryRepository bookingAccountEntryRepository = null;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	@GetMapping("suppliers")
 | 
						@GetMapping("suppliers")
 | 
				
			||||||
	public String listSuppliers(Model model) {
 | 
						public String listSuppliers(Model model) {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -43,7 +49,7 @@ public class SupplierIndexController {
 | 
				
			|||||||
	@GetMapping("/suppliers/{id}")
 | 
						@GetMapping("/suppliers/{id}")
 | 
				
			||||||
	public String supplierDetail(Model model, @PathVariable String 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>();
 | 
							List<UImodelSupplierDetailOrders> orders = new ArrayList<UImodelSupplierDetailOrders>();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -51,8 +57,14 @@ public class SupplierIndexController {
 | 
				
			|||||||
			orders.add(new UImodelSupplierDetailOrders(supplierOrder));
 | 
								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,
 | 
							UImodelSupplierDetail total = new UImodelSupplierDetail(supplierRepository.findSupplierById(supplierId).name,
 | 
				
			||||||
				"42€", orders);
 | 
									supplierBalance, orders);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		model.addAttribute("SupplierDetail", total);
 | 
							model.addAttribute("SupplierDetail", total);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
				
			|||||||
@ -65,7 +65,7 @@
 | 
				
			|||||||
            <h2>Buchungen</h2>
 | 
					            <h2>Buchungen</h2>
 | 
				
			||||||
            <div>
 | 
					            <div>
 | 
				
			||||||
               <h4> Kontostand </h4>
 | 
					               <h4> Kontostand </h4>
 | 
				
			||||||
               <h3><span th:text="${SupplierDetail.balance}"></span></h3>
 | 
					               <h3><span th:text="${SupplierDetail.balance}"></span> €</h3>
 | 
				
			||||||
            </div>
 | 
					            </div>
 | 
				
			||||||
            <p>
 | 
					            <p>
 | 
				
			||||||
            <table id="main-table">
 | 
					            <table id="main-table">
 | 
				
			||||||
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user