mirror of
https://git.imnavajas.es/jjimenez/erp-imprimelibros.git
synced 2026-01-24 09:40:21 +00:00
terminado (provisional) modulo de facturas
This commit is contained in:
@ -1,5 +1,8 @@
|
||||
package com.imprimelibros.erp.facturacion.dto;
|
||||
|
||||
import java.time.Instant;
|
||||
|
||||
import com.imprimelibros.erp.facturacion.FacturaDireccion;
|
||||
import com.imprimelibros.erp.pedidos.PedidoDireccion;
|
||||
|
||||
public class DireccionFacturacionDto {
|
||||
@ -76,6 +79,13 @@ public class DireccionFacturacionDto {
|
||||
this.telefono = telefono;
|
||||
}
|
||||
|
||||
|
||||
public FacturaDireccion toFacturaDireccion() {
|
||||
FacturaDireccion fd = new FacturaDireccion();
|
||||
applyTo(fd);
|
||||
return fd;
|
||||
}
|
||||
|
||||
public PedidoDireccion toPedidoDireccion() {
|
||||
PedidoDireccion pd = new PedidoDireccion();
|
||||
applyTo(pd);
|
||||
@ -84,6 +94,7 @@ public class DireccionFacturacionDto {
|
||||
}
|
||||
|
||||
public void applyTo(PedidoDireccion pd) {
|
||||
pd.setAtt("");
|
||||
pd.setRazonSocial(this.razonSocial);
|
||||
pd.setIdentificacionFiscal(this.identificacionFiscal);
|
||||
pd.setDireccion(this.direccion);
|
||||
@ -107,4 +118,30 @@ public class DireccionFacturacionDto {
|
||||
pd.setTelefono(this.telefono);
|
||||
}
|
||||
|
||||
public void applyTo(FacturaDireccion fd ) {
|
||||
fd.setAtt("");
|
||||
fd.setRazonSocial(this.razonSocial);
|
||||
fd.setIdentificacionFiscal(this.identificacionFiscal);
|
||||
fd.setDireccion(this.direccion);
|
||||
|
||||
// CP robusto
|
||||
Integer cpInt = null;
|
||||
if (this.cp != null && !this.cp.isBlank()) {
|
||||
try {
|
||||
cpInt = Integer.valueOf(this.cp.trim());
|
||||
} catch (NumberFormatException ignored) {
|
||||
// si quieres, lanza IllegalArgumentException para validarlo
|
||||
}
|
||||
}
|
||||
fd.setCp(cpInt);
|
||||
|
||||
fd.setCiudad(this.ciudad);
|
||||
fd.setProvincia(this.provincia);
|
||||
|
||||
fd.setPaisCode3(this.paisKeyword);
|
||||
|
||||
fd.setTelefono(this.telefono);
|
||||
fd.setCreatedAt(Instant.now());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -0,0 +1,36 @@
|
||||
package com.imprimelibros.erp.facturacion.dto;
|
||||
|
||||
public class FacturaAddRequestDto {
|
||||
|
||||
private Long user;
|
||||
private Long serie;
|
||||
private Long direccion;
|
||||
private Long factura_rectificada;
|
||||
|
||||
// getters y setters
|
||||
public Long getUser() {
|
||||
return user;
|
||||
}
|
||||
public void setUser(Long user) {
|
||||
this.user = user;
|
||||
}
|
||||
public Long getSerie() {
|
||||
return serie;
|
||||
}
|
||||
public void setSerie(Long serie) {
|
||||
this.serie = serie;
|
||||
}
|
||||
public Long getDireccion() {
|
||||
return direccion;
|
||||
}
|
||||
public void setDireccion(Long direccion) {
|
||||
this.direccion = direccion;
|
||||
}
|
||||
public Long getFactura_rectificada() {
|
||||
return factura_rectificada;
|
||||
}
|
||||
public void setFactura_rectificada(Long factura_rectificada) {
|
||||
this.factura_rectificada = factura_rectificada;
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,67 @@
|
||||
package com.imprimelibros.erp.facturacion.dto;
|
||||
|
||||
import com.imprimelibros.erp.pedidos.PedidoDireccion;
|
||||
import com.imprimelibros.erp.facturacion.FacturaDireccion;
|
||||
|
||||
import java.time.Instant;
|
||||
|
||||
import com.imprimelibros.erp.direcciones.Direccion.TipoIdentificacionFiscal;
|
||||
|
||||
public final class FacturaDireccionMapper {
|
||||
|
||||
private FacturaDireccionMapper() {}
|
||||
|
||||
public static FacturaDireccion fromPedidoDireccion(PedidoDireccion src) {
|
||||
if (src == null) return null;
|
||||
|
||||
FacturaDireccion dst = new FacturaDireccion();
|
||||
|
||||
dst.setUnidades(src.getUnidades());
|
||||
dst.setEmail(src.getEmail());
|
||||
dst.setAtt(src.getAtt());
|
||||
dst.setDireccion(src.getDireccion());
|
||||
dst.setCp(src.getCp());
|
||||
dst.setCiudad(src.getCiudad());
|
||||
dst.setProvincia(src.getProvincia());
|
||||
dst.setPaisCode3(src.getPaisCode3());
|
||||
dst.setTelefono(src.getTelefono());
|
||||
dst.setInstrucciones(src.getInstrucciones());
|
||||
dst.setRazonSocial(src.getRazonSocial());
|
||||
dst.setCreatedAt(Instant.now());
|
||||
|
||||
// OJO: en PedidoDireccion usas Direccion.TipoIdentificacionFiscal
|
||||
// En FacturaDireccion usa el enum que hayas definido/importado.
|
||||
dst.setTipoIdentificacionFiscal(
|
||||
TipoIdentificacionFiscal.valueOf(src.getTipoIdentificacionFiscal().name())
|
||||
);
|
||||
|
||||
dst.setIdentificacionFiscal(src.getIdentificacionFiscal());
|
||||
|
||||
return dst;
|
||||
}
|
||||
|
||||
public static FacturaDireccion fromDireccion(com.imprimelibros.erp.direcciones.Direccion src) {
|
||||
if (src == null) return null;
|
||||
|
||||
FacturaDireccion dst = new FacturaDireccion();
|
||||
|
||||
dst.setUnidades(null);
|
||||
dst.setEmail(src.getUser().getUserName());
|
||||
dst.setAtt(src.getAtt());
|
||||
dst.setDireccion(src.getDireccion());
|
||||
dst.setCp(src.getCp());
|
||||
dst.setCiudad(src.getCiudad());
|
||||
dst.setProvincia(src.getProvincia());
|
||||
dst.setPaisCode3(src.getPais().getCode3());
|
||||
dst.setTelefono(src.getTelefono());
|
||||
dst.setInstrucciones(src.getInstrucciones());
|
||||
dst.setRazonSocial(src.getRazonSocial());
|
||||
dst.setCreatedAt(Instant.now());
|
||||
|
||||
dst.setTipoIdentificacionFiscal(src.getTipoIdentificacionFiscal());
|
||||
|
||||
dst.setIdentificacionFiscal(src.getIdentificacionFiscal());
|
||||
|
||||
return dst;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user