mirror of
https://git.imnavajas.es/jjimenez/erp-imprimelibros.git
synced 2026-01-20 07:40:22 +00:00
falta el selector de acabados
This commit is contained in:
@ -26,6 +26,7 @@ import com.fasterxml.jackson.core.type.TypeReference;
|
||||
import com.imprimelibros.erp.externalApi.skApiClient;
|
||||
import com.imprimelibros.erp.presupuesto.classes.ImagenPresupuesto;
|
||||
import com.imprimelibros.erp.presupuesto.classes.PresupuestoMaquetacion;
|
||||
import com.imprimelibros.erp.presupuesto.classes.PresupuestoMarcapaginas;
|
||||
import com.imprimelibros.erp.presupuesto.validation.PresupuestoValidationGroups;
|
||||
|
||||
import jakarta.validation.Valid;
|
||||
@ -344,4 +345,34 @@ public class PresupuestoController {
|
||||
return ResponseEntity.ok(resultado);
|
||||
}
|
||||
|
||||
@GetMapping(value = "/public/marcapaginas/form", produces = MediaType.TEXT_HTML_VALUE)
|
||||
public String getMarcapaginasForm(Model model) {
|
||||
model.addAttribute("presupuestoMarcapaginas", new PresupuestoMarcapaginas());
|
||||
return "imprimelibros/presupuestos/presupuesto-marcapaginas-form :: marcapaginasForm";
|
||||
}
|
||||
|
||||
@GetMapping("/public/marcapaginas")
|
||||
public ResponseEntity<?> getPresupuestoMarcapaginas(
|
||||
@Valid @ModelAttribute PresupuestoMarcapaginas presupuestoMarcapaginas,
|
||||
BindingResult result,
|
||||
Locale locale) {
|
||||
|
||||
if (result.hasErrors()) {
|
||||
// Construimos un mapa field -> mensaje para tu AJAX
|
||||
Map<String, String> errores = result.getFieldErrors().stream()
|
||||
.collect(java.util.stream.Collectors.toMap(
|
||||
fe -> fe.getField(),
|
||||
fe -> fe.getDefaultMessage(),
|
||||
(a, b) -> a));
|
||||
return ResponseEntity.badRequest().body(errores);
|
||||
}
|
||||
|
||||
Map<String, Object> resultado = presupuestoService.getPrecioMarcapaginas(presupuestoMarcapaginas, locale);
|
||||
if ((Double) resultado.get("precio_total") == 0.0 && (Double) resultado.get("precio_unitario") == 0.0) {
|
||||
return ResponseEntity.badRequest()
|
||||
.body(messageSource.getMessage("presupuesto.errores.presupuesto-marcapaginas", null, locale));
|
||||
}
|
||||
return ResponseEntity.ok(resultado);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user