19 package org.turro.erp.entity;
21 import java.util.Date;
22 import java.util.HashSet;
24 import javax.persistence.*;
25 import org.turro.erp.db.ErpPU;
26 import org.turro.financials.db.FinancialsPU;
27 import org.turro.financials.entity.Contract;
28 import org.turro.financials.entity.DocumentLine;
29 import org.turro.financials.entity.Product;
30 import org.turro.financials.entity.ProductByContractor;
31 import org.turro.financials.product.CachedIProduct;
32 import org.turro.financials.product.IProduct;
33 import org.turro.financials.product.IProductKey;
34 import org.turro.jpa.Dao;
35 import org.turro.jpa.entity.CachedEntity;
42 public class OrderItem implements java.io.Serializable {
45 @GeneratedValue(strategy=GenerationType.IDENTITY)
46 @Column(name=
"IDENTIFIER")
51 private String description;
53 private long providerId, providerProductId, productId, documentLineId;
61 @Temporal(value = TemporalType.DATE)
62 private Date documentDate;
64 private String documentNumber;
66 private double units, dedication, cost, tax, maxCost;
68 private boolean costMaximum, providerFixed, sent;
70 private String productDescription;
72 @Column(name=
"DELIVERY_DATE")
73 @Temporal(value = TemporalType.TIMESTAMP)
74 private Date delivery;
79 @OneToOne(cascade= CascadeType.ALL)
82 @OneToMany(mappedBy =
"orderItem", fetch = FetchType.LAZY)
83 private Set<ReceiptItem> receiptItems =
new HashSet<ReceiptItem>();
98 this.costMaximum = costMaximum;
106 this.dedication = dedication;
114 this.delivery = delivery;
122 this.description = description;
130 this.documentDate = documentDate;
134 return documentLineId;
138 this.documentLineId = documentLineId;
142 return documentNumber;
146 this.documentNumber = documentNumber;
158 return humanResource;
162 this.humanResource = humanResource;
178 this.maxCost = maxCost;
182 return productDescription;
186 this.productDescription = productDescription;
194 this.productId = productId;
198 return providerFixed;
202 this.providerFixed = providerFixed;
210 this.providerId = providerId;
214 return providerProductId;
218 this.providerProductId = providerProductId;
224 receiptItems = dao.lazyLoader(
OrderItem.class,
this,
"receiptItems").receiptItems;
232 receiptItems = dao.lazyLoader(
OrderItem.class,
this,
"receiptItems").receiptItems;
238 this.receiptItems = receiptItems;
246 this.related = related;
250 return requiredUsage;
254 this.requiredUsage = requiredUsage;
262 this.resource = resource;
283 private transient CachedEntity<DocumentLine, Long> documentLine =
284 new CachedEntity<DocumentLine, Long>() {
286 protected Dao createDao() {
292 return documentLine.getEntity(documentLineId);
296 documentLineId = this.documentLine.setEntity(documentLine);
299 private transient CachedEntity<Product, Long> product =
300 new CachedEntity<Product, Long>() {
302 protected Dao createDao() {
308 return product.getEntity(productId);
312 productId = this.product.setEntity(product);
318 return iproduct.
getIProduct(
new IProductKey(productId, providerId, providerProductId, productDescription));
329 private transient CachedEntity<Contract, Long> provider =
330 new CachedEntity<Contract, Long>() {
332 protected Dao createDao() {
338 return provider.getEntity(providerId);
342 providerId = this.provider.setEntity(provider);
345 private transient CachedEntity<ProductByContractor, Long> providerProduct =
346 new CachedEntity<ProductByContractor, Long>() {
348 protected Dao createDao() {
354 return providerProduct.getEntity(providerProductId);
358 providerProductId = this.providerProduct.setEntity(providerProduct);
369 "select oi from OrderItem oi " +
371 new Object[] {
this });
375 if(requiredUsage ==
null) {
381 return requiredUsage;
385 if(humanResource !=
null) {
386 return humanResource.getName();
387 }
else if(resource !=
null) {
388 return resource.getName();
396 if(humanResource !=
null) {
398 }
else if(resource !=
null) {
406 return cost * units * dedication;
445 boolean processed =
false;
447 tmp += ri.getUnits();
462 double q = 0.0d, d = 0.0d;
463 if(humanResource !=
null) {
466 d += ri.getUnits() * ri.getDedication();
469 return q != 0.0d ? d / q : 1.0d;
473 return units * dedication;
479 q += ri.getUnits() * ri.getDedication();
493 return d / dedication;
498 if(empty && related !=
null) {
void setDocumentLine(DocumentLine documentLine)
void setProvider(Contract provider)
HumanResource getHumanResource()
void setDocumentDate(Date documentDate)
ReceiptItem startReceipt(Date startWorking)
void setReceiptItems(Set< ReceiptItem > receiptItems)
RequiredUsage getOwnerRequiredUsage()
double getRealDedication()
Set< ReceiptItem > getReceiptItems()
void setDescription(String description)
void setCost(double cost)
void setDocumentNumber(String documentNumber)
void setDelivery(Date delivery)
void setProviderProductId(long providerProductId)
double convertToReal(double d)
void setUnits(double units)
void setIProduct(IProduct product)
RequiredUsage getRequiredUsage()
boolean isProviderFixed()
void setDedication(double dedication)
void setProductDescription(String productDescription)
void setSent(boolean sent)
Set< ReceiptItem > getUpdatedReceiptItems()
void setProviderId(long providerId)
void setRequiredUsage(RequiredUsage requiredUsage)
void setProductId(long productId)
ReceiptItem startReceipt(Date startWorking, double receiptUnits)
void setCostMaximum(boolean costMaximum)
ProductByContractor getProviderProduct()
void setProviderFixed(boolean providerFixed)
void setProviderProduct(ProductByContractor providerProduct)
void setMaxCost(double maxCost)
void setProduct(Product product)
String getDocumentNumber()
void setDocumentLineId(long documentLineId)
double getExpectedUnits()
long getProviderProductId()
String getProductDescription()
DocumentLine getDocumentLine()
void setHumanResource(HumanResource humanResource)
void setRelated(OrderItem related)
void setResource(Resource resource)
void setProductId(long productId)
void setDedication(double dedication)
void setProductDescription(String productDescription)
void setResource(Resource resource)
void setHumanResource(HumanResource humanResource)
void setDescription(String description)
void setOrderItem(OrderItem orderItem)
void setProviderId(long providerId)
void setDocumentNumber(String documentNumber)
void setProviderProductId(long providerProductId)
void setStartWorking(Date startWorking)
void setUnits(double units)
void setCost(double cost)
void setDocumentDate(Date documentDate)
IProductKey setIProduct(IProduct product)
IProduct getIProduct(IProductKey productKey)
long getProviderProductId()
String getProductDescription()
Object getSingleResultOrNull(SqlClause sc)
boolean isNotLoaded(Object o, String attribute)