@RequestMapping(value = "/{invoiceId}/control-letters/{id}/rows", method = RequestMethod.POST) public String createOrUpdateControlLetterRow( @PathVariable("id") int controlLetterid, @PathVariable("invoiceId") int invoiceId, @ModelAttribute("controlLetterRow") @Validated ControlLetterRow controlLetterRow, BindingResult bindingResult, Model model, RedirectAttributes redirectAttributes) { if (!bindingResult.hasErrors()) controlLetterRowValidator.validate(controlLetterRow, bindingResult); if (bindingResult.hasErrors()) { List<Employee> employees = employeeService.findAll(Employee.EmployeePosition.CONDUCTOR.getId()); List<Route> routes = routeService.findAll(); model.addAttribute("routes", routes); model.addAttribute("employees", employees); model.addAttribute("invoiceId", invoiceId); model.addAttribute("employees", employees); return "controlLetterRow/edit"; } // TODO: Trigger // Якщо рядок новий, то кондуктор ще не повертав квитки, отже вважаємо, що він повернув все, що // отримав if (controlLetterRow.isNew()) controlLetterRow.setTicketsReturned(controlLetterRow.getTicketsGiven()); return handleSaving( controlLetterRow, controlLetterRowService, redirectAttributes, "tickets-invoices/" + invoiceId + "/control-letters/" + controlLetterid + "/rows"); }