BrightSide Workbench Full Report + Source Code
Budget.java
Go to the documentation of this file.
1 /*
2  * TurrĂ³ i Cutiller Foundation. License notice.
3  * Copyright (C) 2011 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 package org.turro.erp.entity;
19 
20 import java.util.Date;
21 import java.util.HashSet;
22 import java.util.Set;
23 import javax.persistence.*;
24 
29 @Entity
30 public class Budget implements java.io.Serializable {
31 
32  @Id
33  @GeneratedValue(strategy=GenerationType.IDENTITY)
34  @Column(name="IDENTIFIER")
35  private long id;
36 
37  @Column(name="BUDGET_DATE")
38  @Temporal(value = TemporalType.DATE)
39  private Date budgetDate;
40 
41  private long budgetNumber;
42 
43  @Lob
44  @Column(length=4096)
45  private String description;
46 
47  private boolean delivered, accepted, refused;
48 
49  private double units, price;
50 
51  @OneToOne
52  private org.turro.erp.entity.OrderReference orderReference;
53 
54  @OneToMany(fetch = FetchType.EAGER, cascade= CascadeType.ALL, orphanRemoval=true)
55  @OrderBy("orderRef")
56  private Set<Breakdown> breakdowns = new HashSet<Breakdown>();
57 
58  public boolean isAccepted() {
59  return accepted;
60  }
61 
62  public void setAccepted(boolean accepted) {
63  this.accepted = accepted;
64  }
65 
66  public Set<Breakdown> getBreakdowns() {
67  return breakdowns;
68  }
69 
70  public void setBreakdowns(Set<Breakdown> breakdowns) {
71  this.breakdowns = breakdowns;
72  }
73 
74  public Date getBudgetDate() {
75  return budgetDate;
76  }
77 
78  public void setBudgetDate(Date budgetDate) {
79  this.budgetDate = budgetDate;
80  }
81 
82  public long getBudgetNumber() {
83  return budgetNumber;
84  }
85 
86  public void setBudgetNumber(long budgetNumber) {
87  this.budgetNumber = budgetNumber;
88  }
89 
90  public boolean isDelivered() {
91  return delivered;
92  }
93 
94  public void setDelivered(boolean delivered) {
95  this.delivered = delivered;
96  }
97 
98  public String getDescription() {
99  return description;
100  }
101 
102  public void setDescription(String description) {
103  this.description = description;
104  }
105 
106  public long getId() {
107  return id;
108  }
109 
110  public void setId(long id) {
111  this.id = id;
112  }
113 
115  return orderReference;
116  }
117 
118  public void setOrderReference(OrderReference orderReference) {
119  this.orderReference = orderReference;
120  }
121 
122  public double getPrice() {
123  return price;
124  }
125 
126  public void setPrice(double price) {
127  this.price = price;
128  }
129 
130  public boolean isRefused() {
131  return refused;
132  }
133 
134  public void setRefused(boolean refused) {
135  this.refused = refused;
136  }
137 
138  public double getUnits() {
139  return units;
140  }
141 
142  public void setUnits(double units) {
143  this.units = units;
144  }
145 
146  /* Helpers */
147 
148  public void initFrom(OrderReference orderReference, long number) {
149  setOrderReference(orderReference);
150  setBudgetDate(new Date());
151  setBudgetNumber(number);
152  setDescription(orderReference.getSomeDescription());
153  setAccepted(false);
154  setRefused(false);
155  setDelivered(false);
156  setUnits(orderReference.getQuantity());
157  setPrice(orderReference.getPrice());
158  for(Breakdown breakdown : orderReference.getBreakdowns()) {
159  breakdowns.add(breakdown.clone());
160  }
161  }
162 
163 }
void setPrice(double price)
Definition: Budget.java:126
void setUnits(double units)
Definition: Budget.java:142
void setDescription(String description)
Definition: Budget.java:102
void setAccepted(boolean accepted)
Definition: Budget.java:62
void setBreakdowns(Set< Breakdown > breakdowns)
Definition: Budget.java:70
void setRefused(boolean refused)
Definition: Budget.java:134
Set< Breakdown > getBreakdowns()
Definition: Budget.java:66
void initFrom(OrderReference orderReference, long number)
Definition: Budget.java:148
OrderReference getOrderReference()
Definition: Budget.java:114
void setOrderReference(OrderReference orderReference)
Definition: Budget.java:118
void setBudgetNumber(long budgetNumber)
Definition: Budget.java:86
void setDelivered(boolean delivered)
Definition: Budget.java:94
void setBudgetDate(Date budgetDate)
Definition: Budget.java:78