BrightSide Workbench Full Report + Source Code
Breakdown.java
Go to the documentation of this file.
1 /*
2  * TurrĂ³ i Cutiller Foundation. License notice.
3  * Copyright (C) 2012 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.erp.entity;
20 
21 import javax.persistence.*;
22 import org.turro.string.Strings;
23 
28 @Entity
29 public class Breakdown implements java.io.Serializable {
30 
31  @Id
32  @GeneratedValue(strategy=GenerationType.IDENTITY)
33  @Column(name="IDENTIFIER")
34  private long id;
35 
36  private int orderRef;
37 
38  private Double quantity, price;
39 
40  private String description;
41 
42  public String getDescription() {
43  return description;
44  }
45 
46  public void setDescription(String description) {
47  this.description = description;
48  }
49 
50  public long getId() {
51  return id;
52  }
53 
54  public void setId(long id) {
55  this.id = id;
56  }
57 
58  public int getOrderRef() {
59  return orderRef;
60  }
61 
62  public void setOrderRef(int orderRef) {
63  this.orderRef = orderRef;
64  }
65 
66  public Double getPrice() {
67  return price;
68  }
69 
70  public void setPrice(Double price) {
71  this.price = price;
72  }
73 
74  public Double getQuantity() {
75  return quantity;
76  }
77 
78  public void setQuantity(Double quantity) {
79  this.quantity = quantity;
80  }
81 
82  /* Helpers */
83 
84  public boolean isEmpty() {
85  return Strings.isBlank(description);
86  }
87 
88  public double getAmount() {
89  if(price == null) return 0.0d;
90  return (quantity == null || quantity == 0.0) ? price : quantity * price;
91  }
92 
93  @Override
94  public Breakdown clone() {
95  Breakdown b = new Breakdown();
96  b.setOrderRef(orderRef);
97  b.setQuantity(quantity);
98  b.setPrice(price);
99  b.setDescription(description);
100  return b;
101  }
102 
103 }
void setOrderRef(int orderRef)
Definition: Breakdown.java:62
void setDescription(String description)
Definition: Breakdown.java:46
void setPrice(Double price)
Definition: Breakdown.java:70
void setQuantity(Double quantity)
Definition: Breakdown.java:78