package domain;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Set;
import java.util.TreeSet;
public class CommandeClient {
public Integer id;
public String reference;
public Client client;
public String objet;
public float total_prix;
public Date date_creation;
public Date date_mise_jour;
public boolean etatPaye;
public boolean etatLivrer;
public int nbreproduits;
public Set<ProduitCommandeClient> produits_commandes = new TreeSet<ProduitCommandeClient>();
public Integer getId() {
return id;
}
public void setId(Integer id) {
this.id = id;
}
public String getReference() {
return reference;
}
public void setReference(String reference) {
this.reference = reference;
}
public Client getClient() {
return client;
}
public void setClient(Client client) {
this.client = client;
}
public String getObjet() {
return objet;
}
public void setObjet(String objet) {
this.objet = objet;
}
public float getTotal_prix() {
return total_prix;
}
public void setTotal_prix(float totalPrix) {
total_prix = totalPrix;
}
public void setTotal_prix() {
for (ProduitCommandeClient p : produits_commandes)
total_prix += p.prix_vente * p.quantite_commandee;
}
public Date getDate_creation() {
return date_creation;
}
public void setDate_creation(Date dateCreation) {
date_creation = dateCreation;
}
public Date getDate_mise_jour() {
return date_mise_jour;
}
public void setDate_mise_jour(Date dateMiseJour) {
date_mise_jour = dateMiseJour;
}
public Set<ProduitCommandeClient> getProduits_commandes() {
return produits_commandes;
}
public void setProduits_commandes(
Set<ProduitCommandeClient> produits_commandes) {
this.produits_commandes = produits_commandes;
}
public boolean isEtatPaye() {
return etatPaye;
}
public void setEtatPaye(boolean etatPaye) {
this.etatPaye = etatPaye;
}
public boolean isEtatLivrer() {
return etatLivrer;
}
public void setEtatLivrer(boolean etatLivrer) {
this.etatLivrer = etatLivrer;
}
public List<Integer> getIdProduitsCommande() {
List<Integer> liste = new ArrayList<Integer>();
for (ProduitCommandeClient produitCommandeClient : produits_commandes) {
liste.add(produitCommandeClient.getProduit().getId());
}
return liste;
}
public ProduitCommandeClient getProduitCommandeClientById(Integer id) {
for (ProduitCommandeClient produitCommandeClient : produits_commandes) {
if (produitCommandeClient.getId() == id) return produitCommandeClient;
}
return null;
}
public void addProduitCommande(ProduitCommandeClient p) {
getProduits_commandes().add(p);
p.setCommandeClient(this);
}
}
Partager