This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package me.parzibyte.sistemaventasspringboot; | |
import javax.persistence.*; | |
import java.util.Set; | |
@Entity | |
public class Venta { | |
@Id | |
@GeneratedValue(strategy = GenerationType.AUTO) | |
private Integer id; | |
private String fechaYHora; | |
@OneToMany(mappedBy = "venta", cascade = CascadeType.ALL) | |
private Set<ProductoVendido> productos; | |
public Venta() { | |
this.fechaYHora = Utiles.obtenerFechaYHoraActual(); | |
} | |
public Integer getId() { | |
return id; | |
} | |
public void setId(Integer id) { | |
this.id = id; | |
} | |
public Float getTotal() { | |
Float total = 0f; | |
for (ProductoVendido productoVendido : this.productos) { | |
total += productoVendido.getTotal(); | |
} | |
return total; | |
} | |
public String getFechaYHora() { | |
return fechaYHora; | |
} | |
public void setFechaYHora(String fechaYHora) { | |
this.fechaYHora = fechaYHora; | |
} | |
public Set<ProductoVendido> getProductos() { | |
return productos; | |
} | |
public void setProductos(Set<ProductoVendido> productos) { | |
this.productos = productos; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment