Skip to content

Commit

Permalink
gg
Browse files Browse the repository at this point in the history
  • Loading branch information
Mrzz98 committed Feb 12, 2023
1 parent a8e392c commit c73f774
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ public class Cliente {
private String correo;

@Temporal(TemporalType.TIMESTAMP)
@JsonFormat(pattern = "dd/MM/yyyy hh:mm")
@JsonFormat(pattern = "yyyy-dd-mm hh:mm")
@Column(name = "FECHA_INGRESO")
private Date fechaIngreso;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public class Empleado {
private String correo;

@Temporal(TemporalType.TIMESTAMP)
@JsonFormat(pattern = "dd/MM/yyyy hh:mm")
@JsonFormat(pattern = "yyyy-dd-mm hh:mm")
@Column(name = "FECHA_INGRESO")
private Date fechaIngreso;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public class OrdenCompra implements Serializable {
@NotNull(message="No puede estar vacio")
@Column(name="FECHA_EMISION")
@Temporal(TemporalType.DATE)
@DateTimeFormat(pattern="yyyy-MM-dd")
@JsonFormat(pattern = "yyyy-dd-mm hh:mm")
private Date fechaEmision;

@Column(name="OBSERVACIONES",nullable=false,length=300)
Expand All @@ -59,6 +59,14 @@ public class OrdenCompra implements Serializable {
@JoinColumn(name="ID_PROVEEDOR")
private Proveedor proveedor;

@JsonProperty("ID_CLIENTE")
@JsonIdentityInfo(generator = ObjectIdGenerators.PropertyGenerator.class, property = "id")
@JsonIdentityReference(alwaysAsId = true)
@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name="ID_CLIENTE")
private Cliente cliente;


@Column(name="TOTAL_PAGO")
private Double total;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ public class Proveedor {
private String correo;

@Temporal(TemporalType.TIMESTAMP)
@JsonFormat(pattern = "dd/MM/yyyy hh:mm")
@JsonFormat(pattern = "yyyy-dd-mm hh:mm")
@Column(name = "FECHA_INGRESO")
private Date fechaIngreso;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@

import com.backendcarwash.backendcarwash.dto.ResponseDTO;
import com.backendcarwash.backendcarwash.dto.TableDTO;
import com.backendcarwash.backendcarwash.model.DetalleOrdenCompra;
import com.backendcarwash.backendcarwash.model.OrdenCompra;
import com.backendcarwash.backendcarwash.repository.DetalleOrdenCompraRepository;
import com.backendcarwash.backendcarwash.repository.OrdenCompraRepository;
import lombok.RequiredArgsConstructor;
import org.springframework.http.HttpStatus;
Expand All @@ -19,12 +21,20 @@
public class OrdenCompraServiceImpl implements OrdenCompraService {

private final OrdenCompraRepository ordenCompraRepository;

private final DetalleOrdenCompraRepository detalleOrdenCompraRepository;
@Override
public ResponseDTO crearOrdenCompra(OrdenCompra ordenCompra) {
if(ordenCompra.getDetalles() == null){
return new ResponseDTO(new Date(), HttpStatus.BAD_REQUEST, "Se requieren los detalles.", null);
}
List<DetalleOrdenCompra> detalles = ordenCompra.getDetalles() ;
ordenCompraRepository.save(ordenCompra);
for(DetalleOrdenCompra det: detalles){
det.setOrdenCompra(ordenCompra);
}
detalleOrdenCompraRepository.saveAll(detalles);
ordenCompra.setDetalles(detalles);


return new ResponseDTO(new Date(), HttpStatus.OK, "Creado con exito.", null);
Expand Down

0 comments on commit c73f774

Please sign in to comment.