BrightSide Workbench Full Report + Source Code
Contracted.java
Go to the documentation of this file.
1 /*
2  * TurrĂ³ i Cutiller Foundation. License notice.
3  * Copyright (C) 2018 Lluis TurrĂ³ Cutiller <http://www.turro.org/>
4  *
5  * This program is free software: you can redistribute it and/or modify
6  * it under the terms of the GNU Affero General Public License as published by
7  * the Free Software Foundation, either version 3 of the License, or
8  * (at your option) any later version.
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  * GNU Affero General Public License for more details.
14  *
15  * You should have received a copy of the GNU Affero General Public License
16  * along with this program. If not, see <http://www.gnu.org/licenses/>.
17  */
18 
19 package org.turro.financials.entity;
20 
21 import javax.persistence.Column;
22 import javax.persistence.Entity;
23 import javax.persistence.GeneratedValue;
24 import javax.persistence.GenerationType;
25 import javax.persistence.Id;
26 import javax.persistence.ManyToOne;
27 import org.turro.string.Strings;
28 import org.turro.jpa.entity.IDaoEntity;
29 
34 @Entity
35 public class Contracted implements java.io.Serializable, IDaoEntity {
36 
37  @Id
38  @GeneratedValue(strategy=GenerationType.IDENTITY)
39  @Column(name="IDENTIFIER")
40  private long id;
41 
42  @ManyToOne
43  private Contract contract;
44 
45  @ManyToOne
46  private Product product;
47 
48  private String concept;
49 
50  private double quantity, price;
51 
52  public long getId() {
53  return id;
54  }
55 
56  public void setId(long id) {
57  this.id = id;
58  }
59 
60  public Contract getContract() {
61  return contract;
62  }
63 
64  public void setContract(Contract contract) {
65  this.contract = contract;
66  }
67 
68  public Product getProduct() {
69  return product;
70  }
71 
72  public void setProduct(Product product) {
73  this.product = product;
74  }
75 
76  public String getConcept() {
77  return concept;
78  }
79 
80  public void setConcept(String concept) {
81  this.concept = concept;
82  }
83 
84  public double getQuantity() {
85  return quantity;
86  }
87 
88  public void setQuantity(double quantity) {
89  this.quantity = quantity;
90  }
91 
92  public double getPrice() {
93  return price;
94  }
95 
96  public void setPrice(double price) {
97  this.price = price;
98  }
99 
100  /* IDaoEntity */
101 
102  @Override
103  public Object entityId() {
104  return id;
105  }
106 
107  @Override
108  public boolean isEmpty() {
109  return product == null && Strings.isBlank(concept);
110  }
111 
112  /* Helpers */
113 
114  public String getProductString() {
115  return product != null ? product.getProductString() : "";
116  }
117 
118  public double getFinalPrice() {
119  return price != 0.0 ? price : (product != null ? product.getPrice() : 0.0);
120  }
121 
122 }
void setContract(Contract contract)
Definition: Contracted.java:64