18 package org.turro.financials.model;
20 import org.turro.math.Round;
26 public class Amount implements Comparable<Amount> {
28 private Double tax, subtotal, discount, retained;
29 private int fractionDigits;
32 public Amount(Double tax, Double subtotal, Double discount, Double retained,
int fractionDigits) {
34 this.subtotal = subtotal;
35 this.discount = discount;
36 this.retained = retained;
37 this.fractionDigits = fractionDigits;
41 this.amountSet = amountSet;
45 return subtotal ==
null || subtotal == 0 || subtotal.isNaN();
48 public void addTax(Double tax, Double subtotal, Double discount, Double retained) {
50 this.subtotal += subtotal;
51 this.discount += discount;
52 this.retained += retained;
72 return new Round(subtotal - discount).
decimals(fractionDigits).value();
92 if (getClass() != obj.getClass()) {
96 if (this.tax != other.tax && (
this.tax ==
null || !
this.tax.equals(other.tax))) {
105 hash = 97 * hash + (this.tax !=
null ? this.tax.hashCode() : 0);
111 return tax.compareTo(o.
getTax());
void setAmountSet(AmountSet amountSet)
boolean equals(Object obj)
Amount(Double tax, Double subtotal, Double discount, Double retained, int fractionDigits)
void addTax(Double tax, Double subtotal, Double discount, Double retained)
Round decimals(int digits)