19 package org.turro.erp.entity;
21 import java.util.Collection;
22 import java.util.Date;
23 import java.util.Iterator;
24 import javax.persistence.*;
25 import org.turro.string.Strings;
26 import org.turro.contacts.Contact;
27 import org.turro.contacts.db.ContactsPU;
28 import org.turro.financials.db.FinancialsPU;
29 import org.turro.financials.entity.Contract;
30 import org.turro.financials.entity.DocumentLine;
31 import org.turro.financials.entity.Product;
32 import org.turro.financials.entity.ProductByContractor;
33 import org.turro.financials.product.CachedIProduct;
34 import org.turro.financials.product.IProduct;
35 import org.turro.financials.product.IProductKey;
36 import org.turro.jpa.Dao;
37 import org.turro.jpa.entity.CachedEntity;
47 @GeneratedValue(strategy=GenerationType.IDENTITY)
48 @Column(name=
"IDENTIFIER")
53 private String description;
55 private long providerId, providerProductId, productId, documentLineId;
63 @Temporal(value = TemporalType.DATE)
64 private Date documentDate;
66 private String documentNumber;
68 private double units, dedication, cost, tax;
70 private String productDescription;
72 @Column(name=
"START_WORKING")
73 @Temporal(value = TemporalType.TIMESTAMP)
74 private Date startWorking;
76 private String receptorId;
94 this.dedication = dedication;
102 this.description = description;
110 this.documentDate = documentDate;
114 return documentLineId;
118 this.documentLineId = documentLineId;
122 return documentNumber;
126 this.documentNumber = documentNumber;
138 return humanResource;
142 this.humanResource = humanResource;
158 this.orderItem = orderItem;
162 return productDescription;
166 this.productDescription = productDescription;
174 this.productId = productId;
182 this.providerId = providerId;
186 return providerProductId;
190 this.providerProductId = providerProductId;
198 this.receptorId = receptorId;
206 this.resource = resource;
214 this.startWorking = startWorking;
227 private transient CachedEntity<DocumentLine, Long> documentLine =
228 new CachedEntity<DocumentLine, Long>() {
230 protected Dao createDao() {
236 return documentLine.getEntity(documentLineId);
240 documentLineId = this.documentLine.setEntity(documentLine);
243 private transient CachedEntity<Product, Long> product =
244 new CachedEntity<Product, Long>() {
246 protected Dao createDao() {
252 return product.getEntity(productId);
256 productId = this.product.setEntity(product);
262 return iproduct.
getIProduct(
new IProductKey(productId, providerId, providerProductId, productDescription));
273 private transient CachedEntity<Contract, Long> provider =
274 new CachedEntity<Contract, Long>() {
276 protected Dao createDao() {
282 return provider.getEntity(providerId);
286 providerId = this.provider.setEntity(provider);
289 private transient CachedEntity<ProductByContractor, Long> providerProduct =
290 new CachedEntity<ProductByContractor, Long>() {
292 protected Dao createDao() {
298 return providerProduct.getEntity(providerProductId);
302 providerProductId = this.providerProduct.setEntity(providerProduct);
307 private transient CachedEntity<Contact, String> receptor =
308 new CachedEntity<Contact, String>() {
310 protected Dao createDao() {
316 return receptor.getEntity(receptorId);
320 receptorId = this.receptor.setEntity(petitioner);
328 return ((providerProductId > 0 || productId > 0) ||
329 !Strings.isEmpty(productDescription));
333 return humanResource !=
null;
337 return resource !=
null;
341 if(humanResource !=
null) {
342 return humanResource.getName();
343 }
else if(resource !=
null) {
344 return resource.getName();
352 if(humanResource !=
null) {
354 }
else if(resource !=
null) {
362 return cost * units * dedication;
366 return startWorking ==
null ? documentDate : startWorking;
370 if(orderItem ==
null) {
373 if(orderItem.getUnits() <= units) {
384 Iterator<ReceiptItem> itri = ris.iterator();
386 return ris.iterator().next();
393 return units * dedication;
Set< ReceiptItem > getReceiptItems()
void setProductId(long productId)
void setDedication(double dedication)
void setProductDescription(String productDescription)
String getDocumentNumber()
void setResource(Resource resource)
void setHumanResource(HumanResource humanResource)
void setDescription(String description)
void setProvider(Contract provider)
void setOrderItem(OrderItem orderItem)
void setProviderId(long providerId)
void setReceptorId(String receptorId)
void setDocumentNumber(String documentNumber)
void setIProduct(IProduct product)
void setDocumentLineId(long documentLineId)
boolean isHumanResourceType()
String getProductDescription()
void setProduct(Product product)
void setDocumentLine(DocumentLine documentLine)
ProductByContractor getProviderProduct()
long getProviderProductId()
void setProviderProductId(long providerProductId)
HumanResource getHumanResource()
void setStartWorking(Date startWorking)
void setUnits(double units)
void setPetitioner(Contact petitioner)
void setProviderProduct(ProductByContractor providerProduct)
void setCost(double cost)
void setDocumentDate(Date documentDate)
DocumentLine getDocumentLine()
ReceiptStatus getStatus()
IProductKey setIProduct(IProduct product)
IProduct getIProduct(IProductKey productKey)
long getProviderProductId()
String getProductDescription()
RECEIPT_PROCESSED_PARTIALLY