BrightSide Workbench Full Report + Source Code
org.turro.financials.entity.Product Class Reference
Inheritance diagram for org.turro.financials.entity.Product:
Collaboration diagram for org.turro.financials.entity.Product:

Public Member Functions

String getDescription ()
 
void setDescription (String description)
 
long getId ()
 
void setId (long id)
 
String getKeywords ()
 
void setKeywords (String keywords)
 
double getPrice ()
 
void setPrice (double price)
 
Set< ProductByContractorgetProductByContractors ()
 
void setProductByContractors (Set< ProductByContractor > productByContractors)
 
String getProductCode ()
 
void setProductCode (String productCode)
 
double getTax ()
 
void setTax (double tax)
 
boolean isPublishable ()
 
void setPublishable (boolean publishable)
 
boolean isService ()
 
void setService (boolean service)
 
boolean isPromoted ()
 
void setPromoted (boolean promoted)
 
boolean isDelivery ()
 
void setDelivery (boolean delivery)
 
boolean isConcept ()
 
void setConcept (boolean concept)
 
boolean isAttachments ()
 
void setAttachments (boolean attachments)
 
Object entityId ()
 
boolean isEmpty ()
 
void prepareSave ()
 
String getDescription (boolean fields)
 
String getFieldDescription ()
 
double getPriceWithTax (int fractions)
 
ProductByContractor getProductByContractor ()
 
void setProductByContractor (ProductByContractor productByContractor)
 
long getProductId ()
 
String getProductCodeStr ()
 
double getProductCost ()
 
double getProductCostTax ()
 
double getProductPrice ()
 
double getProductPriceTax ()
 
IProduct load (Object id)
 
String getProductName ()
 
double getProductStock (Date date, Contract store)
 
String getProductString ()
 
boolean isUncoded ()
 
Collection< MovementgetMovements ()
 
Collection< MovementgetMovements (Date from, Date to, Contract store)
 
ProductRegulation getLastInventory (Dao dao, Contract store, Date date)
 
double getStock (Contract store, Date date)
 
FieldItSet getFields ()
 
ValueItSet getValues ()
 
Object getFieldValue (String label)
 
Collection< IValueItEntitygetRelated ()
 
MappingSet getSerializerMappings ()
 
- Public Member Functions inherited from org.turro.jpa.entity.IDaoEntity
default boolean isNew ()
 
default void prepareDelete ()
 
default void removeEmpties ()
 
default Collection< Collection > collections ()
 

Static Public Member Functions

static List< ProductgetProducts ()
 
static Product getProductByCode (String code)
 
static List< ProductgetProducts (String concept, boolean equality)
 

Detailed Description

Author
Lluis TurrĂ³ Cutiller lluis.nosp@m.@tur.nosp@m.ro.or.nosp@m.g

Definition at line 44 of file Product.java.

Member Function Documentation

◆ entityId()

Object org.turro.financials.entity.Product.entityId ( )

Implements org.turro.jpa.entity.IDaoEntity.

Definition at line 167 of file Product.java.

167  {
168  return id;
169  }

◆ getDescription() [1/2]

String org.turro.financials.entity.Product.getDescription ( )

Definition at line 60 of file Product.java.

60  {
61  return description;
62  }
Here is the caller graph for this function:

◆ getDescription() [2/2]

String org.turro.financials.entity.Product.getDescription ( boolean  fields)

Definition at line 185 of file Product.java.

185  {
186  return description +
187  (Strings.isBlank(keywords) ? "" : " " + keywords) +
188  (fields ? getFieldDescription() : "");
189  }
Here is the call graph for this function:

◆ getFieldDescription()

String org.turro.financials.entity.Product.getFieldDescription ( )

Definition at line 191 of file Product.java.

191  {
192  String extra = getValues().getDescriptionFields();
193  return Strings.isBlank(extra) ? "" : " " + extra;
194  }
Here is the call graph for this function:
Here is the caller graph for this function:

◆ getFields()

FieldItSet org.turro.financials.entity.Product.getFields ( )

Implements org.turro.fieldit.IValueItEntity.

Definition at line 499 of file Product.java.

499  {
500  return GroupItUtil.getFields(FinancialsPU.getObjectPath(this));
501  }
Here is the call graph for this function:

◆ getFieldValue()

Object org.turro.financials.entity.Product.getFieldValue ( String  label)

Implements org.turro.fieldit.IValueItEntity.

Definition at line 509 of file Product.java.

509  {
510  return FieldItUtil.getFieldValue(label, FinancialsPU.getObjectPath(this));
511  }
Here is the call graph for this function:

◆ getId()

long org.turro.financials.entity.Product.getId ( )

Definition at line 68 of file Product.java.

68  {
69  return id;
70  }
Here is the caller graph for this function:

◆ getKeywords()

String org.turro.financials.entity.Product.getKeywords ( )

Definition at line 76 of file Product.java.

76  {
77  return keywords;
78  }
Here is the caller graph for this function:

◆ getLastInventory()

ProductRegulation org.turro.financials.entity.Product.getLastInventory ( Dao  dao,
Contract  store,
Date  date 
)

Definition at line 380 of file Product.java.

380  {
381  WhereClause wc = new WhereClause();
382  wc.addClause("select pr from ProductRegulation pr");
383  wc.addClause("where pr.product = :product");
384  wc.addNamedValue("product", this);
385  wc.addClause("and pr.store = :store");
386  wc.addNamedValue("store", store);
387  wc.addClause("and pr.type = :type");
388  wc.addNamedValue("type", RegulationType.INVENTORY);
389  wc.addClause("and pr.regulationDate = ");
390  wc.addClause("(select max(pr2.regulationDate) from ProductRegulation pr2");
391  wc.addClause("where pr2.product = pr.product");
392  wc.addClause("and pr2.regulationDate <= :date");
393  wc.addNamedValue("date", date);
394  wc.addClause("and pr2.store = pr.store");
395  wc.addClause("and pr2.type = pr.type)");
396  return (ProductRegulation) dao.getSingleResultOrNull(wc);
397  }
Here is the call graph for this function:
Here is the caller graph for this function:

◆ getMovements() [1/2]

Collection<Movement> org.turro.financials.entity.Product.getMovements ( )

Implements org.turro.financials.product.IProduct.

Definition at line 322 of file Product.java.

322  {
323  WhereClause wc = new WhereClause();
324  wc.addClause("select new org.turro.financials.product.Movement");
325  wc.addClause("(dl.document.contract, dl.document.documentDate,");
326  wc.addClause("dl.lineType.stockCoefficient,dl.quantity,dl.price,dl.concept)");
327  wc.addClause("from DocumentLine dl");
328  wc.addClause("where (dl.product = :product");
329  wc.addNamedValue("product", this);
330  wc.addClause("or dl.productByContractor = :pbc)");
331  wc.addNamedValue("pbc", productByContractor);
332  wc.addClause("and dl.quantity <> 0");
333  wc.addClause("order by dl.document.receiptDate desc, dl.lineOrder");
334  return new FinancialsPU().getResultList(wc, 100);
335  }
Here is the call graph for this function:

◆ getMovements() [2/2]

Collection<Movement> org.turro.financials.entity.Product.getMovements ( Date  from,
Date  to,
Contract  store 
)

Implements org.turro.financials.product.IProduct.

Definition at line 338 of file Product.java.

338  {
339  WhereClause wc = new WhereClause();
340  wc.addClause("select new org.turro.financials.product.Movement");
341  wc.addClause("('Accumulated',coalesce(sum(dl.quantity*dl.lineType.stockCoefficient),0.0),coalesce(sum(dl.quantity*dl.price*dl.lineType.stockCoefficient),0.0))");
342  wc.addClause("from DocumentLine dl");
343  wc.addClause("where (dl.product = :product");
344  wc.addNamedValue("product", this);
345  wc.addClause("or dl.productByContractor = :pbc)");
346  wc.addNamedValue("pbc", productByContractor);
347  if(store != null) {
348  wc.addClause("and dl.store = :store");
349  wc.addNamedValue("store", store);
350  }
351  wc.addClause("and dl.quantity <> 0");
352  wc.addClause("and dl.document.receiptDate < :from2");
353  wc.addNamedValue("from2", from);
354  Collection<Movement> movs = new FinancialsPU().getResultList(wc);
355  wc = new WhereClause();
356  wc.addClause("select new org.turro.financials.product.Movement");
357  wc.addClause("(dl.document.contract, dl.document.documentDate,");
358  wc.addClause("dl.lineType.stockCoefficient,dl.quantity,dl.price,dl.concept)");
359  wc.addClause("from DocumentLine dl");
360  wc.addClause("where (dl.product = :product");
361  wc.addNamedValue("product", this);
362  wc.addClause("or dl.productByContractor = :pbc)");
363  wc.addNamedValue("pbc", productByContractor);
364  if(store != null) {
365  wc.addClause("and dl.store = :store");
366  wc.addNamedValue("store", store);
367  }
368  wc.addClause("and dl.quantity <> 0");
369  wc.addClause("and dl.document.receiptDate >= :from2");
370  wc.addNamedValue("from2", from);
371  if(to != null) {
372  wc.addClause("and dl.document.receiptDate <= :to2");
373  wc.addNamedValue("to2", to);
374  }
375  wc.addClause("order by dl.document.receiptDate asc, dl.lineOrder");
376  movs.addAll(new FinancialsPU().getResultList(wc));
377  return movs;
378  }
Here is the call graph for this function:

◆ getPrice()

double org.turro.financials.entity.Product.getPrice ( )

Definition at line 84 of file Product.java.

84  {
85  return price;
86  }
Here is the caller graph for this function:

◆ getPriceWithTax()

double org.turro.financials.entity.Product.getPriceWithTax ( int  fractions)

Definition at line 196 of file Product.java.

196  {
197  double taxable = new Round(price).decimals(fractions).value();
198  return new Round((taxable * (1.0 + tax / 100.0))).decimals(fractions).value();
199  }
Here is the call graph for this function:

◆ getProductByCode()

static Product org.turro.financials.entity.Product.getProductByCode ( String  code)
static

Definition at line 443 of file Product.java.

443  {
444  WhereClause wc = new WhereClause();
445  wc.addClause("select prod from Product prod where productCode = :code");
446  wc.addNamedValue("code", code);
447  return (Product) new FinancialsPU().getSingleResultOrNull(wc);
448  }
Here is the call graph for this function:

◆ getProductByContractor()

ProductByContractor org.turro.financials.entity.Product.getProductByContractor ( )

Implements org.turro.financials.product.IProduct.

Definition at line 208 of file Product.java.

208  {
209  return productByContractor;
210  }
Here is the caller graph for this function:

◆ getProductByContractors()

Set<ProductByContractor> org.turro.financials.entity.Product.getProductByContractors ( )

Definition at line 92 of file Product.java.

92  {
93  return productByContractors;
94  }
Here is the caller graph for this function:

◆ getProductCode()

String org.turro.financials.entity.Product.getProductCode ( )

Definition at line 100 of file Product.java.

100  {
101  return productCode;
102  }
Here is the caller graph for this function:

◆ getProductCodeStr()

String org.turro.financials.entity.Product.getProductCodeStr ( )

Implements org.turro.financials.product.IProduct.

Definition at line 223 of file Product.java.

223  {
224  return productCode;
225  }
Here is the caller graph for this function:

◆ getProductCost()

double org.turro.financials.entity.Product.getProductCost ( )

Implements org.turro.financials.product.IProduct.

Definition at line 228 of file Product.java.

228  {
229  if(lastCost == null) {
230  Object d[] = loadData(1);
231  lastCost = (Double) d[0];
232  lastCostTax = (Double) d[1];
233  }
234  return lastCost;
235  }

◆ getProductCostTax()

double org.turro.financials.entity.Product.getProductCostTax ( )

Implements org.turro.financials.product.IProduct.

Definition at line 238 of file Product.java.

238  {
239  if(lastCost == null) {
240  Object d[] = loadData(1);
241  lastCost = (Double) d[0];
242  lastCostTax = (Double) d[1];
243  }
244  return lastCostTax;
245  }

◆ getProductId()

long org.turro.financials.entity.Product.getProductId ( )

Implements org.turro.financials.product.IProduct.

Definition at line 218 of file Product.java.

218  {
219  return id;
220  }

◆ getProductName()

String org.turro.financials.entity.Product.getProductName ( )

Implements org.turro.financials.product.IProduct.

Definition at line 279 of file Product.java.

279  {
280  return description;
281  }

◆ getProductPrice()

double org.turro.financials.entity.Product.getProductPrice ( )

Implements org.turro.financials.product.IProduct.

Definition at line 248 of file Product.java.

248  {
249  if(price == 0.0d) {
250  if(lastPrice == null) {
251  Object d[] = loadData(-1);
252  lastPrice = (Double) d[0];
253  lastPriceTax = (Double) d[1];
254  }
255  return lastPrice;
256  }
257  return price;
258  }

◆ getProductPriceTax()

double org.turro.financials.entity.Product.getProductPriceTax ( )

Implements org.turro.financials.product.IProduct.

Definition at line 261 of file Product.java.

261  {
262  if(tax == 0.0d) {
263  if(lastPrice == null) {
264  Object d[] = loadData(-1);
265  lastPrice = (Double) d[0];
266  lastPriceTax = (Double) d[1];
267  }
268  return lastPriceTax;
269  }
270  return tax;
271  }

◆ getProducts() [1/2]

static List<Product> org.turro.financials.entity.Product.getProducts ( )
static

Definition at line 439 of file Product.java.

439  {
440  return getProducts(null, false);
441  }
static List< Product > getProducts()
Definition: Product.java:439
Here is the caller graph for this function:

◆ getProducts() [2/2]

static List<Product> org.turro.financials.entity.Product.getProducts ( String  concept,
boolean  equality 
)
static

Definition at line 450 of file Product.java.

450  {
451  WhereClause wc = new WhereClause();
452  wc.addClause("select prod");
453  getDescriptionQuery(wc, concept, equality);
454  List<Product> list = new FinancialsPU().getResultList(wc);
455  return list;
456  }
Here is the call graph for this function:

◆ getProductStock()

double org.turro.financials.entity.Product.getProductStock ( Date  date,
Contract  store 
)

Implements org.turro.financials.product.IProduct.

Definition at line 284 of file Product.java.

284  {
285  return getStock(store, date);
286 // WhereClause wc = new WhereClause();
287 // wc.addClause("select coalesce(sum(quantity*dl.lineType.stockCoefficient*1.0),0.0) ");
288 // wc.addClause("from DocumentLine dl");
289 // wc.addClause("where dl.product = :product");
290 // wc.addNamedValue("product", this);
291 // if(store != null) {
292 // wc.addClause("and dl.store = :store");
293 // wc.addNamedValue("store", store);
294 // }
295 // wc.addClause("and dl.lineType.stockCoefficient <> 0");
296 // wc.addClause("and dl.quantity <> 0");
297 // if(date != null) {
298 // wc.addClause("and dl.document.receiptDate <= :date");
299 // wc.addNamedValue("date", date);
300 // }
301 // Double stock = (Double) new FinancialsPU().getSingleResultOrNull(wc);
302 // return stock == null ? 0.0 : stock;
303  }
double getStock(Contract store, Date date)
Definition: Product.java:399
Here is the call graph for this function:

◆ getProductString()

String org.turro.financials.entity.Product.getProductString ( )

Implements org.turro.financials.product.IProduct.

Definition at line 306 of file Product.java.

306  {
307  if(productByContractor != null &&
308  productByContractor.getContract() != null &&
309  productByContractor.getContract().isUseContractorCode()) {
310  return "##" + productByContractor.getContractorCode() + Chars.forward().spaced() + getDescription(true);
311  } else {
312  return "#" + productCode + Chars.forward().spaced() + getDescription(true);
313  }
314  }
Here is the call graph for this function:
Here is the caller graph for this function:

◆ getRelated()

Collection<IValueItEntity> org.turro.financials.entity.Product.getRelated ( )

Implements org.turro.fieldit.IValueItEntity.

Definition at line 514 of file Product.java.

514  {
515  Collection<String> paths = FieldItUtil.related(FinancialsPU.getObjectPath(this));
516  return new ArrayList<>();
517  }
Here is the call graph for this function:

◆ getSerializerMappings()

MappingSet org.turro.financials.entity.Product.getSerializerMappings ( )

Definition at line 521 of file Product.java.

521  {
522  MappingSet set = new MappingSet();
523  set.addMapping(Product.class, 1,
524  new String[] { "id", "productCode", "description", "keywords", "price", "tax",
525  "publishable", "service", "promoted", "delivery", "concept", "attachments" },
526  new String[] { "productByContractors" });
527  set.addMapping(ProductByContractor.class, 2,
528  new String[] { "contractorCode", "price", "tax" },
529  new String[] { "contract" });
530  set.addMapping(Contract.class, 3,
531  new String[] { "id", "name" },
532  null);
533  return set;
534  }

◆ getStock()

double org.turro.financials.entity.Product.getStock ( Contract  store,
Date  date 
)

Definition at line 399 of file Product.java.

399  {
400  Dao dao = new FinancialsPU();
401  ProductRegulation pr = getLastInventory(dao, store, date);
402  double stock = pr == null ? 0.0 : pr.getQuantity();
403  WhereClause wc = new WhereClause();
404  wc.addClause("select coalesce(sum(dl.quantity*dl.lineType.stockCoefficient),0.0)");
405  wc.addClause("from DocumentLine dl");
406  wc.addClause("where dl.product = :product");
407  wc.addNamedValue("product", this);
408  wc.addClause("and dl.store = :store");
409  wc.addNamedValue("store", store);
410  wc.addClause("and dl.quantity <> 0");
411  wc.addClause("and dl.document.receiptDate <= :date");
412  wc.addNamedValue("date", date);
413  if(pr != null) {
414  wc.addClause("and dl.document.receiptDate >= :from");
415  wc.addNamedValue("from", pr.getRegulationDate());
416  }
417  Double result = (Double) dao.getSingleResultOrNull(wc);
418  stock += result == null ? 0.0 : result;
419  wc = new WhereClause();
420  wc.addClause("select sum(quantity)");
421  wc.addClause("from ProductRegulation pr");
422  wc.addClause("where pr.product = :product");
423  wc.addNamedValue("product", this);
424  wc.addClause("and pr.store = :store");
425  wc.addNamedValue("store", store);
426  wc.addClause("and pr.type <> :type");
427  wc.addNamedValue("type", RegulationType.INVENTORY);
428  wc.addClause("and pr.regulationDate <= :date");
429  wc.addNamedValue("date", date);
430  if(pr != null) {
431  wc.addClause("and pr.regulationDate >= :from");
432  wc.addNamedValue("from", pr.getRegulationDate());
433  }
434  result = (Double) dao.getSingleResultOrNull(wc);
435  stock += result == null ? 0.0 : result;
436  return stock;
437  }
ProductRegulation getLastInventory(Dao dao, Contract store, Date date)
Definition: Product.java:380
Here is the call graph for this function:
Here is the caller graph for this function:

◆ getTax()

double org.turro.financials.entity.Product.getTax ( )

Definition at line 108 of file Product.java.

108  {
109  return tax;
110  }
Here is the caller graph for this function:

◆ getValues()

ValueItSet org.turro.financials.entity.Product.getValues ( )

Implements org.turro.fieldit.IValueItEntity.

Definition at line 504 of file Product.java.

504  {
505  return GroupItUtil.getValues(FinancialsPU.getObjectPath(this));
506  }
Here is the call graph for this function:
Here is the caller graph for this function:

◆ isAttachments()

boolean org.turro.financials.entity.Product.isAttachments ( )

Definition at line 156 of file Product.java.

156  {
157  return attachments;
158  }

◆ isConcept()

boolean org.turro.financials.entity.Product.isConcept ( )

Definition at line 148 of file Product.java.

148  {
149  return concept;
150  }
Here is the caller graph for this function:

◆ isDelivery()

boolean org.turro.financials.entity.Product.isDelivery ( )

Definition at line 140 of file Product.java.

140  {
141  return delivery;
142  }
Here is the caller graph for this function:

◆ isEmpty()

boolean org.turro.financials.entity.Product.isEmpty ( )

Implements org.turro.jpa.entity.IDaoEntity.

Definition at line 172 of file Product.java.

172  {
173  return Strings.isBlank(description);
174  }

◆ isPromoted()

boolean org.turro.financials.entity.Product.isPromoted ( )

Definition at line 132 of file Product.java.

132  {
133  return promoted;
134  }

◆ isPublishable()

boolean org.turro.financials.entity.Product.isPublishable ( )

Definition at line 116 of file Product.java.

116  {
117  return publishable;
118  }
Here is the caller graph for this function:

◆ isService()

boolean org.turro.financials.entity.Product.isService ( )

Definition at line 124 of file Product.java.

124  {
125  return service;
126  }

◆ isUncoded()

boolean org.turro.financials.entity.Product.isUncoded ( )

Implements org.turro.financials.product.IProduct.

Definition at line 317 of file Product.java.

317  {
318  return false;
319  }

◆ load()

IProduct org.turro.financials.entity.Product.load ( Object  id)

Implements org.turro.financials.product.IProduct.

Definition at line 274 of file Product.java.

274  {
275  throw new UnsupportedOperationException("Not supported yet.");
276  }

◆ prepareSave()

void org.turro.financials.entity.Product.prepareSave ( )

Implements org.turro.jpa.entity.IDaoEntity.

Definition at line 177 of file Product.java.

177  {
178  if(Strings.isBlank(productCode)) {
179  productCode = IdUtils.getNewLongIdFromString(new FinancialsPU(), "Product", "productCode") + "";
180  }
181  }
Here is the call graph for this function:

◆ setAttachments()

void org.turro.financials.entity.Product.setAttachments ( boolean  attachments)

Definition at line 160 of file Product.java.

160  {
161  this.attachments = attachments;
162  }

◆ setConcept()

void org.turro.financials.entity.Product.setConcept ( boolean  concept)

Definition at line 152 of file Product.java.

152  {
153  this.concept = concept;
154  }

◆ setDelivery()

void org.turro.financials.entity.Product.setDelivery ( boolean  delivery)

Definition at line 144 of file Product.java.

144  {
145  this.delivery = delivery;
146  }

◆ setDescription()

void org.turro.financials.entity.Product.setDescription ( String  description)

Definition at line 64 of file Product.java.

64  {
65  this.description = description;
66  }

◆ setId()

void org.turro.financials.entity.Product.setId ( long  id)

Definition at line 72 of file Product.java.

72  {
73  this.id = id;
74  }

◆ setKeywords()

void org.turro.financials.entity.Product.setKeywords ( String  keywords)

Definition at line 80 of file Product.java.

80  {
81  this.keywords = keywords;
82  }

◆ setPrice()

void org.turro.financials.entity.Product.setPrice ( double  price)

Definition at line 88 of file Product.java.

88  {
89  this.price = price;
90  }

◆ setProductByContractor()

void org.turro.financials.entity.Product.setProductByContractor ( ProductByContractor  productByContractor)

Implements org.turro.financials.product.IProduct.

Definition at line 213 of file Product.java.

213  {
214  this.productByContractor = productByContractor;
215  }
Here is the caller graph for this function:

◆ setProductByContractors()

void org.turro.financials.entity.Product.setProductByContractors ( Set< ProductByContractor productByContractors)

Definition at line 96 of file Product.java.

96  {
97  this.productByContractors = productByContractors;
98  }

◆ setProductCode()

void org.turro.financials.entity.Product.setProductCode ( String  productCode)

Definition at line 104 of file Product.java.

104  {
105  this.productCode = productCode;
106  }

◆ setPromoted()

void org.turro.financials.entity.Product.setPromoted ( boolean  promoted)

Definition at line 136 of file Product.java.

136  {
137  this.promoted = promoted;
138  }

◆ setPublishable()

void org.turro.financials.entity.Product.setPublishable ( boolean  publishable)

Definition at line 120 of file Product.java.

120  {
121  this.publishable = publishable;
122  }

◆ setService()

void org.turro.financials.entity.Product.setService ( boolean  service)

Definition at line 128 of file Product.java.

128  {
129  this.service = service;
130  }

◆ setTax()

void org.turro.financials.entity.Product.setTax ( double  tax)

Definition at line 112 of file Product.java.

112  {
113  this.tax = tax;
114  }

The documentation for this class was generated from the following file: