46 lines
1.6 KiB
Java
46 lines
1.6 KiB
Java
package org.hso.ecommerce.controller.intern.suppliers;
|
|
|
|
import java.util.List;
|
|
|
|
import javax.servlet.http.HttpServletRequest;
|
|
|
|
import org.hso.ecommerce.controller.intern.AccountingController;
|
|
import org.hso.ecommerce.controller.intern.AccountingController.ShortTemplateBookingResult;
|
|
import org.hso.ecommerce.entities.booking.Booking;
|
|
import org.hso.ecommerce.repos.booking.BookingRepository;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.stereotype.Controller;
|
|
import org.springframework.web.bind.annotation.GetMapping;
|
|
import org.springframework.web.bind.annotation.PathVariable;
|
|
import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
|
@Controller
|
|
@RequestMapping("/intern/suppliers")
|
|
public class SupplierIndexController {
|
|
|
|
@Autowired
|
|
private BookingRepository bookingRepository = null;
|
|
|
|
@Autowired
|
|
private AccountingController accountingController = null;
|
|
|
|
@GetMapping("/")
|
|
public String internSuppliers() {
|
|
return "intern/suppliers/index";
|
|
}
|
|
|
|
@GetMapping("/{supplierId}")
|
|
public String internSuppliersId(HttpServletRequest request, @PathVariable(required = true) long supplierId) {
|
|
|
|
// Table of bookings
|
|
List<Booking> bookings = bookingRepository.supplierBookingsReverseChronologically(supplierId);
|
|
ShortTemplateBookingResult result = accountingController.buildShortTemplate(bookings,
|
|
account -> account.supplierAccount != null && account.supplierAccount.id == supplierId);
|
|
request.setAttribute("balance", result.balance);
|
|
request.setAttribute("bookings", result.bookings);
|
|
|
|
return "intern/suppliers/id";
|
|
}
|
|
|
|
}
|