Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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