288 lines
7.4 KiB
Java
288 lines
7.4 KiB
Java
|
|
package it.acxent.cart;
|
||
|
|
|
||
|
|
import it.acxent.db.ApplParmFull;
|
||
|
|
import it.acxent.db.DBAdapter;
|
||
|
|
import it.acxent.util.DoubleOperator;
|
||
|
|
import java.io.Serializable;
|
||
|
|
import java.text.NumberFormat;
|
||
|
|
import java.util.Locale;
|
||
|
|
|
||
|
|
public class CartItem implements CartItemIterface, Serializable {
|
||
|
|
public static final long TYPE_ARTICOLO = 0L;
|
||
|
|
|
||
|
|
public static final long TYPE_ARTICOLO_VARIANTE = 1L;
|
||
|
|
|
||
|
|
public static final long TYPE_ARTICOLO_TAGLIA = 2L;
|
||
|
|
|
||
|
|
public static final long TYPE_ARTICOLO_VARIANTE_TAGLIA = 3L;
|
||
|
|
|
||
|
|
public static final long TYPE_ARTICOLO_TAGLIA_KIT = 4L;
|
||
|
|
|
||
|
|
public static final long TYPE_ARTICOLO_VARIANTE_TAGLIA_KIT = 5L;
|
||
|
|
|
||
|
|
private AcCartObject cartObject;
|
||
|
|
|
||
|
|
private NumberFormat nf2;
|
||
|
|
|
||
|
|
private boolean RM;
|
||
|
|
|
||
|
|
private String cartItemTag;
|
||
|
|
|
||
|
|
private Object itemId;
|
||
|
|
|
||
|
|
private double quantity;
|
||
|
|
|
||
|
|
private Class<CartItemIterface> itemClass;
|
||
|
|
|
||
|
|
private ApplParmFull applParmFull;
|
||
|
|
|
||
|
|
private DBAdapter dbItem;
|
||
|
|
|
||
|
|
public CartItem() {
|
||
|
|
this.quantity = 1.0D;
|
||
|
|
}
|
||
|
|
|
||
|
|
public CartItem(AcCartObject l_aco, ApplParmFull theApplParmFull, double newQuantity) {
|
||
|
|
setCartObject(l_aco);
|
||
|
|
setItemId(l_aco.getId());
|
||
|
|
setQuantity(newQuantity);
|
||
|
|
setItemClass(l_aco.getItemClass());
|
||
|
|
setApplParmFull(theApplParmFull);
|
||
|
|
try {
|
||
|
|
CartItemIterface bean = getItemClass().newInstance();
|
||
|
|
this.cartItemTag = bean.getCartItemTag();
|
||
|
|
} catch (Exception e) {
|
||
|
|
e.printStackTrace();
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
public ApplParmFull getApplParmFull() {
|
||
|
|
return this.applParmFull;
|
||
|
|
}
|
||
|
|
|
||
|
|
public DBAdapter getDbItem() {
|
||
|
|
if (this.dbItem == null && this.itemId != null)
|
||
|
|
try {
|
||
|
|
if (getItemId() instanceof Long) {
|
||
|
|
DBAdapter bean = (DBAdapter)getItemClass().newInstance();
|
||
|
|
bean.setApFull(getApplParmFull());
|
||
|
|
bean.findByPrimaryKey(getItemId());
|
||
|
|
if (bean.getDBState() == 1)
|
||
|
|
this.dbItem = bean;
|
||
|
|
} else {
|
||
|
|
CartItemId cii = (CartItemId)getItemId();
|
||
|
|
DBAdapter bean = (DBAdapter)getItemClass().newInstance();
|
||
|
|
bean.setApFull(getApplParmFull());
|
||
|
|
((CartItemIterface)bean).findByCartitemId(cii);
|
||
|
|
if (bean.getDBState() == 1)
|
||
|
|
this.dbItem = bean;
|
||
|
|
}
|
||
|
|
} catch (Exception e) {
|
||
|
|
e.printStackTrace();
|
||
|
|
}
|
||
|
|
try {
|
||
|
|
return (this.dbItem == null) ? (DBAdapter)getItemClass().newInstance() : this.dbItem;
|
||
|
|
} catch (Exception e) {
|
||
|
|
e.printStackTrace();
|
||
|
|
return this.dbItem;
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
public Class<CartItemIterface> getItemClass() {
|
||
|
|
return this.itemClass;
|
||
|
|
}
|
||
|
|
|
||
|
|
public Object getItemId() {
|
||
|
|
return this.itemId;
|
||
|
|
}
|
||
|
|
|
||
|
|
public double getQuantity() {
|
||
|
|
return this.quantity;
|
||
|
|
}
|
||
|
|
|
||
|
|
public void setApplParmFull(ApplParmFull newApplParmFull) {
|
||
|
|
this.applParmFull = newApplParmFull;
|
||
|
|
}
|
||
|
|
|
||
|
|
public void setDbItem(DBAdapter newDbItem) {
|
||
|
|
this.dbItem = newDbItem;
|
||
|
|
}
|
||
|
|
|
||
|
|
public void setItemClass(Class<CartItemIterface> newItemClass) {
|
||
|
|
this.itemClass = newItemClass;
|
||
|
|
}
|
||
|
|
|
||
|
|
public void setItemId(Object newItemId) {
|
||
|
|
this.itemId = newItemId;
|
||
|
|
setDbItem(null);
|
||
|
|
}
|
||
|
|
|
||
|
|
public void setQuantity(double newQuantity) {
|
||
|
|
this.quantity = newQuantity;
|
||
|
|
}
|
||
|
|
|
||
|
|
public double getPriceWVat() {
|
||
|
|
return ((CartItemIterface)getDbItem()).getPriceWVat();
|
||
|
|
}
|
||
|
|
|
||
|
|
public double getPrice() {
|
||
|
|
return ((CartItemIterface)getDbItem()).getPrice();
|
||
|
|
}
|
||
|
|
|
||
|
|
public boolean isItemAvailable() {
|
||
|
|
if (getQuantity() <= getAvailItemQty())
|
||
|
|
return true;
|
||
|
|
return false;
|
||
|
|
}
|
||
|
|
|
||
|
|
public double getTotPrice() {
|
||
|
|
DoubleOperator temp = new DoubleOperator(getQuantity());
|
||
|
|
temp.setScale(4, 5);
|
||
|
|
temp.multiply(getPrice());
|
||
|
|
return temp.getResult();
|
||
|
|
}
|
||
|
|
|
||
|
|
public double getAvailItemQty() {
|
||
|
|
double l_dispo = 0.0D;
|
||
|
|
if (this.itemId != null) {
|
||
|
|
this.dbItem = null;
|
||
|
|
l_dispo = ((CartItemIterface)getDbItem()).getAvail();
|
||
|
|
return l_dispo;
|
||
|
|
}
|
||
|
|
return l_dispo;
|
||
|
|
}
|
||
|
|
|
||
|
|
public double getAvail() {
|
||
|
|
return ((CartItemIterface)getDbItem()).getAvail();
|
||
|
|
}
|
||
|
|
|
||
|
|
public String getCartItemDescriptionUrl() {
|
||
|
|
return ((CartItemIterface)getDbItem()).getCartItemDescriptionUrl();
|
||
|
|
}
|
||
|
|
|
||
|
|
public String getCartItemDescription3(String lang) {
|
||
|
|
return ((CartItemIterface)getDbItem()).getCartItemDescription3(lang);
|
||
|
|
}
|
||
|
|
|
||
|
|
public String getCartItemDescription2(String lang) {
|
||
|
|
return ((CartItemIterface)getDbItem()).getCartItemDescription2(lang);
|
||
|
|
}
|
||
|
|
|
||
|
|
public String getCartItemImage() {
|
||
|
|
return ((CartItemIterface)getDbItem()).getCartItemImage();
|
||
|
|
}
|
||
|
|
|
||
|
|
public double getCost() {
|
||
|
|
return ((CartItemIterface)getDbItem()).getCost();
|
||
|
|
}
|
||
|
|
|
||
|
|
public double getDiscount() {
|
||
|
|
return ((CartItemIterface)getDbItem()).getDiscount();
|
||
|
|
}
|
||
|
|
|
||
|
|
public boolean isSale() {
|
||
|
|
return ((CartItemIterface)getDbItem()).isSale();
|
||
|
|
}
|
||
|
|
|
||
|
|
public double getIvaAliquota(long l_id_users) {
|
||
|
|
return ((CartItemIterface)getDbItem()).getIvaAliquota(l_id_users);
|
||
|
|
}
|
||
|
|
|
||
|
|
public Object getId_iva() {
|
||
|
|
return null;
|
||
|
|
}
|
||
|
|
|
||
|
|
public boolean isRM() {
|
||
|
|
return this.RM;
|
||
|
|
}
|
||
|
|
|
||
|
|
public long getIvaItemId(long l_id_users) {
|
||
|
|
return ((CartItemIterface)getDbItem()).getIvaItemId(l_id_users);
|
||
|
|
}
|
||
|
|
|
||
|
|
public long getCartItemUdm() {
|
||
|
|
return ((CartItemIterface)getDbItem()).getCartItemUdm();
|
||
|
|
}
|
||
|
|
|
||
|
|
public double getPrice(long l_id_users) {
|
||
|
|
return ((CartItemIterface)getDbItem()).getPrice(l_id_users);
|
||
|
|
}
|
||
|
|
|
||
|
|
public String getCartItemDescription(String lang) {
|
||
|
|
return ((CartItemIterface)getDbItem()).getCartItemDescription(lang);
|
||
|
|
}
|
||
|
|
|
||
|
|
public double getTotPrice(long l_id_users) {
|
||
|
|
DoubleOperator temp = new DoubleOperator(getQuantity());
|
||
|
|
temp.setScale(4, 5);
|
||
|
|
temp.multiply(getPrice(l_id_users));
|
||
|
|
return temp.getResult();
|
||
|
|
}
|
||
|
|
|
||
|
|
public String getCartItemTag() {
|
||
|
|
return (this.cartItemTag == null) ? "" : this.cartItemTag.trim();
|
||
|
|
}
|
||
|
|
|
||
|
|
public void setRM(boolean rM) {
|
||
|
|
this.RM = rM;
|
||
|
|
}
|
||
|
|
|
||
|
|
public NumberFormat getNf() {
|
||
|
|
if (this.nf2 == null) {
|
||
|
|
this.nf2 = NumberFormat.getInstance(Locale.ITALY);
|
||
|
|
this.nf2.setMaximumFractionDigits(2);
|
||
|
|
this.nf2.setMinimumFractionDigits(2);
|
||
|
|
}
|
||
|
|
return this.nf2;
|
||
|
|
}
|
||
|
|
|
||
|
|
public double getTotPriceWVat() {
|
||
|
|
DoubleOperator temp = new DoubleOperator(getQuantity());
|
||
|
|
temp.setScale(4, 5);
|
||
|
|
temp.multiply(getPriceWVat());
|
||
|
|
return temp.getResult();
|
||
|
|
}
|
||
|
|
|
||
|
|
public double getTotPriceWVat(long l_id_users) {
|
||
|
|
DoubleOperator temp = new DoubleOperator(getQuantity());
|
||
|
|
temp.setScale(4, 5);
|
||
|
|
temp.multiply(getPriceWVat(l_id_users));
|
||
|
|
return temp.getResult();
|
||
|
|
}
|
||
|
|
|
||
|
|
public double getPriceWVat(long l_id_users) {
|
||
|
|
return ((CartItemIterface)getDbItem()).getPriceWVat(l_id_users);
|
||
|
|
}
|
||
|
|
|
||
|
|
public AcCartObject getCartObject() {
|
||
|
|
return this.cartObject;
|
||
|
|
}
|
||
|
|
|
||
|
|
public void setCartObject(AcCartObject cartObject) {
|
||
|
|
this.cartObject = cartObject;
|
||
|
|
}
|
||
|
|
|
||
|
|
public String getCartItemDescriptionCC(String lang) {
|
||
|
|
return ((CartItemIterface)getDbItem()).getCartItemDescriptionCC(lang);
|
||
|
|
}
|
||
|
|
|
||
|
|
public void findByCartitemId(CartItemId cii) {
|
||
|
|
((CartItemIterface)getDbItem()).findByCartitemId(cii);
|
||
|
|
}
|
||
|
|
|
||
|
|
public boolean isCostoSpedizionePreventivo(String l_id_nazione) {
|
||
|
|
return ((CartItemIterface)getDbItem()).isCostoSpedizionePreventivo(l_id_nazione);
|
||
|
|
}
|
||
|
|
|
||
|
|
public double getDeliveryCost(String l_id_nazione) {
|
||
|
|
return ((CartItemIterface)getDbItem()).getDeliveryCost(l_id_nazione);
|
||
|
|
}
|
||
|
|
|
||
|
|
public long getPercentileSpedizione() {
|
||
|
|
return ((CartItemIterface)getDbItem()).getPercentileSpedizione();
|
||
|
|
}
|
||
|
|
|
||
|
|
public boolean isScontoTroppoAlto() {
|
||
|
|
return ((CartItemIterface)getDbItem()).isScontoTroppoAlto();
|
||
|
|
}
|
||
|
|
}
|