This repository has been archived on 2020-08-02. You can view files and clone it, but cannot push or open issues or pull requests.
e-commerce/web_backend/src/main/java/org/hso/ecommerce/controller/intern/InternIndexController.java

35 lines
1.4 KiB
Java
Raw Normal View History

2020-04-29 22:44:16 +02:00
package org.hso.ecommerce.controller.intern;
2020-04-28 22:41:29 +02:00
import java.util.Optional;
import org.hso.ecommerce.controller.intern.accounting.AccountingController;
import org.hso.ecommerce.entities.booking.BookingAccountEntry;
import org.hso.ecommerce.repos.booking.BookingAccountEntryRepository;
import org.springframework.beans.factory.annotation.Autowired;
2020-04-28 22:41:29 +02:00
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
2020-04-28 22:41:29 +02:00
@Controller
@RequestMapping("/intern")
2020-05-01 10:48:12 +02:00
public class InternIndexController {
@Autowired
private final BookingAccountEntryRepository bookingAccountEntryRepository = null;
@GetMapping("/")
public String intern(Model model) {
Optional<BookingAccountEntry> mainAccount = bookingAccountEntryRepository.getByMain();
int mainAccountBalance = mainAccount.map(entry -> entry.newSumCent).orElse(0);
Optional<BookingAccountEntry> vatAccount = bookingAccountEntryRepository.getByVat();
int vatAccountBalance = vatAccount.map(entry -> entry.newSumCent).orElse(0);
model.addAttribute("mainAccountBalance", AccountingController.fmtEuro(mainAccountBalance));
model.addAttribute("vatAccountBalance", AccountingController.fmtEuro(vatAccountBalance));
return "intern/index";
}
2020-04-28 22:41:29 +02:00
}