18 package org.turro.erp.entity;
21 import javax.persistence.*;
22 import org.turro.string.Strings;
23 import org.hibernate.annotations.SortType;
24 import org.turro.elephant.impl.util.StringParser;
25 import org.turro.erp.db.ErpPU;
26 import org.turro.erp.workorder.ReferenceStatusWrapper;
27 import org.turro.financials.db.FinancialsPU;
28 import org.turro.financials.entity.Contract;
29 import org.turro.financials.entity.Product;
30 import org.turro.jpa.Dao;
31 import org.turro.jpa.entity.CachedEntity;
41 @GeneratedValue(strategy=GenerationType.IDENTITY)
42 @Column(name=
"IDENTIFIER")
46 private org.turro.erp.entity.WorkOrder workOrder;
48 @OneToOne(cascade = CascadeType.ALL, orphanRemoval =
true)
53 private String description;
55 private long productId;
59 private boolean validated, noFraction, delivered;
61 private double quantity, price, tax, retention;
63 private long serviceId;
66 private org.turro.erp.entity.Project project;
68 @OneToMany(fetch = FetchType.EAGER, cascade= CascadeType.ALL, orphanRemoval=
true)
69 private Set<Budget> budgets =
new HashSet<Budget>();
71 @OneToMany(fetch = FetchType.EAGER, cascade= CascadeType.ALL, orphanRemoval=
true)
73 private Set<Breakdown> breakdowns =
new HashSet<Breakdown>();
75 @OneToMany(mappedBy =
"orderReference", fetch = FetchType.EAGER, cascade = CascadeType.REMOVE, orphanRemoval=
true)
76 @org.hibernate.annotations.Sort(type=SortType.COMPARATOR, comparator=org.turro.erp.entity.TaskComparator.class)
77 private SortedSet<Task> tasks =
new TreeSet<Task>(
new org.turro.erp.entity.TaskComparator());
84 this.breakdowns = breakdowns;
92 this.budgets = budgets;
100 this.customerOrder = customerOrder;
101 if(customerOrder !=
null) {
112 this.delivered = delivered;
120 this.description = description;
136 this.noFraction = noFraction;
144 this.orderRef = orderRef;
160 this.productId = productId;
168 this.quantity = quantity;
176 this.retention = retention;
184 this.serviceId = serviceId;
208 this.validated = validated;
216 this.workOrder = workOrder;
221 private transient CachedEntity<Product, Long> product =
222 new CachedEntity<Product, Long>() {
224 protected Dao createDao() {
230 return product.getEntity(productId);
234 productId = this.product.setEntity(product);
237 private transient CachedEntity<Contract, Long> service =
238 new CachedEntity<Contract, Long>() {
240 protected Dao createDao() {
246 return service.getEntity(serviceId);
250 serviceId = this.service.setEntity(service);
260 return (productId > 0 ?
getProduct().getProductString() :
"") +
275 boolean empty = (Strings.isBlank(description) && productId == 0) ||
281 Iterator<Task> it = tasks.iterator();
282 while(it.hasNext()) {
289 Iterator<Breakdown> itb = breakdowns.iterator();
290 while(itb.hasNext()) {
303 for(
Task t : tasks) {
304 t.prepareForSaving();
311 tasks = dao.lazyLoader(
OrderReference.class,
this,
"tasks").tasks;
317 this.customerOrder = cu;
333 private boolean hasDeliveredBudget() {
334 if(budgets.isEmpty())
return false;
336 if(b.isDelivered()) {
344 if(budgets.isEmpty())
return false;
354 return customerOrder !=
null && customerOrder.
isWantBudget();
static String toHTML(String value)
void setServiceId(long service)
void setCustomerId(long customerId)
ReferenceStatusWrapper getStatusWrapper(Date now)
void setValidated(boolean validated)
void initFrom(CustomerOrder cu)
void setRetention(double retention)
void setQuantity(double quantity)
void setPrice(double price)
Set< Task > getUpdatedTasks()
String getSomeDescription()
void setProduct(Product product)
String getHtmlDescription()
void setNoFraction(boolean noFraction)
boolean hasBugdetStopper()
void setWorkOrder(WorkOrder workOrder)
Set< Budget > getBudgets()
ReferenceStatusWrapper getStatusWrapper()
void setServiceId(long serviceId)
String getFullDescription()
String getOrderDescription()
CustomerOrder getCustomerOrder()
void setBreakdowns(Set< Breakdown > breakdowns)
void setDescription(String description)
boolean hasAcceptedBudget()
SortedSet< Task > getTasks()
void setTasks(SortedSet< Task > tasks)
Set< Breakdown > getBreakdowns()
void setDelivered(boolean delivered)
void setBudgets(Set< Budget > budgets)
void setCustomerOrder(CustomerOrder customerOrder)
void setProductId(long productId)
void setOrderRef(int orderRef)
void setService(Contract service)
boolean hasPendingBudget()
void setOrderReference(OrderReference orderReference)
String getFullDescription()