terminando pdf de facturas

This commit is contained in:
2026-01-02 21:47:06 +01:00
parent bf823281a5
commit 6bea279066
30 changed files with 7112 additions and 6245 deletions

View File

@ -25,8 +25,8 @@ public class PdfController {
@RequestParam(defaultValue = "inline") String mode,
Locale locale) {
if (type.equals(DocumentType.PRESUPUESTO.toString()) && id == null) {
throw new IllegalArgumentException("Falta el ID del presupuesto para generar el PDF");
if (id == null) {
throw new IllegalArgumentException("Falta el ID para generar el PDF");
}
if (type.equals(DocumentType.PRESUPUESTO.toString())) {
Long presupuestoId = Long.valueOf(id);
@ -39,7 +39,22 @@ public class PdfController {
: ContentDisposition.inline()).filename("presupuesto-" + id + ".pdf").build());
return new ResponseEntity<>(pdf, headers, HttpStatus.OK);
} else {
}/*else if(type.equals(DocumentType.PEDIDO.toString())) {
} */else if (type.equals(DocumentType.FACTURA.toString())) {
Long facturaId = Long.valueOf(id);
byte[] pdf = pdfService.generaFactura(facturaId, locale);
var headers = new HttpHeaders();
headers.setContentType(MediaType.APPLICATION_PDF);
headers.setContentDisposition(
("download".equals(mode)
? ContentDisposition.attachment()
: ContentDisposition.inline()).filename("factura-" + id + ".pdf").build());
return new ResponseEntity<>(pdf, headers, HttpStatus.OK);
}
else {
return ResponseEntity.status(HttpStatus.NOT_FOUND).body(null);
}