19 package org.turro.financials.cart;
21 import java.io.Serializable;
22 import java.util.ArrayList;
23 import java.util.Collection;
24 import java.util.Currency;
25 import java.util.Iterator;
26 import org.turro.action.Contacts;
27 import org.turro.action.IRegisterCallback;
28 import org.turro.elephant.impl.util.Serializer;
29 import org.turro.elephant.security.IUser;
30 import org.turro.plugin.contacts.IContact;
31 import org.turro.util.IdGenerator;
39 private boolean wantBill =
false, pickup =
false;
40 private int status = 0;
42 private String order, contactId, deliveryValue;
50 order = IdGenerator.generateLong().substring(2, 14);
75 this.wantBill = wantBill;
91 this.deliveryValue = deliveryValue;
95 return items.isEmpty();
99 Iterator<CartItem> it = items.iterator();
100 while(it.hasNext()) {
101 if(it.next().isNeedsDelivery()) {
109 Iterator<CartItem> it = items.iterator();
110 while(it.hasNext()) {
111 if(it.next().isDeliveryItem()) {
117 public boolean addDeliveryItem(
long productId,
double quantity,
double tax,
double price) {
128 public boolean addItem(
long productId,
double quantity,
double tax,
double price) {
142 Iterator<CartItem> it = items.iterator();
143 while(it.hasNext()) {
144 if(it.next().getOrder() == order) {
153 Iterator<CartItem> it = items.iterator();
154 while(it.hasNext()) {
165 Iterator<CartItem> it = items.iterator();
166 while(it.hasNext()) {
176 Iterator<CartItem> it = items.iterator();
177 while(it.hasNext()) {
187 ArrayList<CartItem> list =
new ArrayList<>();
189 if(ci.getProductId() ==
id) {
199 value += ci.getAmount();
207 value += ci.getTaxable();
215 value += ci.getTaxAmount();
225 if(contact ==
null) {
242 contactId = contact.
getId();
271 private Currency _currency;
274 if(_currency ==
null) {
static void serialize(String fileName, Object instance)
static void remove(String fileName)
static Object deserialize(String fileName)
boolean addItem(CartItem cartItem)
void setProductId(long productId)
void setQuantity(double quantity)
void setConcept(String concept)
void setDeliveryItem(boolean deliveryItem)
void setPrice(double price)
String getDeliveryValue()
void changeItem(Integer order, double quantity)
Collection< CartItem > getProducts(long id)
static void removeFor(IContact contact)
void onRegister(String email)
static Cart deserializeForOrder(String order)
boolean addItem(long productId, double quantity, double tax, double price)
void setDeliveryValue(String deliveryValue)
void removeItem(Integer order)
void setStatus(int status)
void changeItem(Integer order, String concept)
static Cart deserializeFor(IContact contact)
boolean addDeliveryItem(long productId, double quantity, double tax, double price)
void setPickup(boolean pickup)
void setWantBill(boolean wantBill)
void removeDeliveryItem()
void serializeFor(IContact contact)
void serializeForOrder(IContact contact)
CartItem getItem(Integer order)
void serializeFor(String email)
static ShopContext getInstance()
static final String CONNECTOR_EMAIL