BrightSide Workbench Full Report + Source Code
AmountSet.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.financials.model;
19
20
import
java.util.Iterator;
21
import
java.util.TreeSet;
22
27
public
class
AmountSet
extends
TreeSet<Amount> {
28
29
@Override
30
public
boolean
add
(
Amount
e) {
31
e.
setAmountSet
(
this
);
32
return
super.add(e);
33
}
34
35
public
void
addAmount
(
Amount
e) {
36
Amount
a =
getAmount
(e.
getTax
());
37
if
(a ==
null
) {
38
add
(e);
39
}
else
{
40
a.
addTax
(e.
getTax
(), e.
getSubtotal
(), e.
getDiscount
(), e.
getRetained
());
41
}
42
}
43
44
public
double
getTaxable
() {
45
double
amount = 0;
46
for
(
Amount
a :
this
) {
47
amount += a.
getTaxable
();
48
}
49
return
amount;
50
}
51
52
public
double
getTaxValue
() {
53
double
amount = 0;
54
for
(
Amount
a :
this
) {
55
amount += a.
getTaxValue
();
56
}
57
return
amount;
58
}
59
60
public
Amount
getAmount
(Double tax) {
61
for
(
Amount
a :
this
) {
62
if
(a.
getTax
().equals(tax)) {
63
return
a;
64
}
65
}
66
return
null
;
67
}
68
69
public
double
getAmount
() {
70
double
amount = 0;
71
for
(
Amount
a :
this
) {
72
amount += a.
getAmount
();
73
}
74
return
amount;
75
}
76
77
public
void
clearEmpty
() {
78
Iterator<Amount> it = iterator();
79
while
(it.hasNext()) {
80
if
(it.next().isEmpty()) {
81
it.remove();
82
}
83
}
84
}
85
86
}
org.turro.financials.model.AmountSet
Definition:
AmountSet.java:27
org.turro.financials.model.AmountSet.add
boolean add(Amount e)
Definition:
AmountSet.java:30
org.turro.financials.model.AmountSet.getTaxValue
double getTaxValue()
Definition:
AmountSet.java:52
org.turro.financials.model.AmountSet.clearEmpty
void clearEmpty()
Definition:
AmountSet.java:77
org.turro.financials.model.AmountSet.getTaxable
double getTaxable()
Definition:
AmountSet.java:44
org.turro.financials.model.AmountSet.getAmount
double getAmount()
Definition:
AmountSet.java:69
org.turro.financials.model.AmountSet.getAmount
Amount getAmount(Double tax)
Definition:
AmountSet.java:60
org.turro.financials.model.AmountSet.addAmount
void addAmount(Amount e)
Definition:
AmountSet.java:35
org.turro.financials.model.Amount
Definition:
Amount.java:26
org.turro.financials.model.Amount.setAmountSet
void setAmountSet(AmountSet amountSet)
Definition:
Amount.java:40
org.turro.financials.model.Amount.getTax
Double getTax()
Definition:
Amount.java:55
org.turro.financials.model.Amount.addTax
void addTax(Double tax, Double subtotal, Double discount, Double retained)
Definition:
Amount.java:48
org.turro.financials.model.Amount.getRetained
Double getRetained()
Definition:
Amount.java:59
org.turro.financials.model.Amount.getDiscount
Double getDiscount()
Definition:
Amount.java:63
org.turro.financials.model.Amount.getTaxable
Double getTaxable()
Definition:
Amount.java:71
org.turro.financials.model.Amount.getSubtotal
Double getSubtotal()
Definition:
Amount.java:67
org.turro.financials.model.Amount.getTaxValue
Double getTaxValue()
Definition:
Amount.java:75
org.turro.financials.model.Amount.getAmount
Double getAmount()
Definition:
Amount.java:79
TurroProjects
Public
BrightSide
bsfinancials-core
src
main
java
org
turro
financials
model
AmountSet.java
Generated on Tue Mar 12 2024 07:01:17 for BrightSide by
1.9.1