105 lines
2.8 KiB
Java
105 lines
2.8 KiB
Java
|
|
package it.acxent.cart;
|
||
|
|
|
||
|
|
import it.acxent.util.DoubleOperator;
|
||
|
|
import java.util.Enumeration;
|
||
|
|
import java.util.Hashtable;
|
||
|
|
|
||
|
|
public class IvaGroup {
|
||
|
|
private Hashtable ri;
|
||
|
|
|
||
|
|
private DoubleOperator totImponibileDO;
|
||
|
|
|
||
|
|
private double importoRM;
|
||
|
|
|
||
|
|
public void addCartRow(double imponibile, long l_iva, double l_aliquota, boolean isRM) {
|
||
|
|
Object theKey = new Long(l_iva);
|
||
|
|
if (!isRM) {
|
||
|
|
IvaGroupItem rii;
|
||
|
|
if (getRi().containsKey(theKey)) {
|
||
|
|
rii = (IvaGroupItem)getRi().get(theKey);
|
||
|
|
} else {
|
||
|
|
rii = new IvaGroupItem(l_iva, l_aliquota);
|
||
|
|
}
|
||
|
|
rii.addImporto(imponibile);
|
||
|
|
getTotImponibileDO().add(imponibile);
|
||
|
|
getRi().put(theKey, rii);
|
||
|
|
} else {
|
||
|
|
synchronized (this) {
|
||
|
|
DoubleOperator dop = new DoubleOperator(this.importoRM);
|
||
|
|
dop.add(imponibile);
|
||
|
|
this.importoRM = dop.getResult();
|
||
|
|
}
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
public Enumeration elements() {
|
||
|
|
return getRi().elements();
|
||
|
|
}
|
||
|
|
|
||
|
|
private Hashtable getRi() {
|
||
|
|
if (this.ri == null)
|
||
|
|
this.ri = new Hashtable();
|
||
|
|
return this.ri;
|
||
|
|
}
|
||
|
|
|
||
|
|
public double getImportoRM() {
|
||
|
|
return this.importoRM;
|
||
|
|
}
|
||
|
|
|
||
|
|
public void setImportoRM(double importoRM) {
|
||
|
|
this.importoRM = importoRM;
|
||
|
|
}
|
||
|
|
|
||
|
|
public void addCartRowRM(double imponibile, long l_iva, double l_aliquota, boolean isRM, double costo) {
|
||
|
|
Object theKey = new Long(l_iva);
|
||
|
|
if (!isRM) {
|
||
|
|
IvaGroupItem rii;
|
||
|
|
if (getRi().containsKey(theKey)) {
|
||
|
|
rii = (IvaGroupItem)getRi().get(theKey);
|
||
|
|
} else {
|
||
|
|
rii = new IvaGroupItem(l_iva, l_aliquota);
|
||
|
|
}
|
||
|
|
rii.addImporto(imponibile);
|
||
|
|
getTotImponibileDO().add(imponibile);
|
||
|
|
getRi().put(theKey, rii);
|
||
|
|
} else {
|
||
|
|
synchronized (this) {
|
||
|
|
IvaGroupItem rii;
|
||
|
|
DoubleOperator dop = new DoubleOperator(this.importoRM);
|
||
|
|
dop.add(imponibile);
|
||
|
|
this.importoRM = dop.getResult();
|
||
|
|
double l_imponibile = 0.0D;
|
||
|
|
if (getRi().containsKey(theKey)) {
|
||
|
|
rii = (IvaGroupItem)getRi().get(theKey);
|
||
|
|
} else {
|
||
|
|
rii = new IvaGroupItem(l_iva, l_aliquota);
|
||
|
|
}
|
||
|
|
rii.addImporto(l_imponibile);
|
||
|
|
getTotImponibileDO().add(l_imponibile);
|
||
|
|
getRi().put(theKey, rii);
|
||
|
|
}
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
private DoubleOperator getTotImponibileDO() {
|
||
|
|
if (this.totImponibileDO == null)
|
||
|
|
this.totImponibileDO = new DoubleOperator();
|
||
|
|
return this.totImponibileDO;
|
||
|
|
}
|
||
|
|
|
||
|
|
public double getTotImponibile() {
|
||
|
|
return getTotImponibileDO().getResult();
|
||
|
|
}
|
||
|
|
|
||
|
|
public double getTotIva() {
|
||
|
|
Enumeration<IvaGroupItem> enu = getRi().elements();
|
||
|
|
DoubleOperator dIva = new DoubleOperator();
|
||
|
|
dIva.setScale(4, 5);
|
||
|
|
while (enu.hasMoreElements()) {
|
||
|
|
IvaGroupItem row = enu.nextElement();
|
||
|
|
dIva.add(row.getImportoIvaCalc());
|
||
|
|
}
|
||
|
|
dIva.setScale(2, 5);
|
||
|
|
return dIva.getResult();
|
||
|
|
}
|
||
|
|
}
|