⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 postransaction.java

📁 Sequoia ERP是一个真正的企业级开源ERP解决方案。它提供的模块包括:电子商务应用(e-commerce), POS系统(point of sales),知识管理,存货与仓库管理
💻 JAVA
📖 第 1 页 / 共 3 页
字号:
            payInfo.put("payInfo", infValue.getString("description"));            payInfo.put("amount", UtilFormatOut.formatPrice(inf.amount));        } else {            String paymentMethodTypeId = infValue.getString("paymentMethodTypeId");            GenericValue pmt = null;            try {                 pmt = infValue.getRelatedOne("PaymentMethodType");            } catch (GenericEntityException e) {                Debug.logError(e, module);            }            if (pmt != null) {                payInfo.put("description", pmt.getString("description"));                payInfo.put("amount", UtilFormatOut.formatPrice(inf.amount));            }            if ("CREDIT_CARD".equals(paymentMethodTypeId)) {                GenericValue cc = null;                try {                    cc = infValue.getRelatedOne("CreditCard");                } catch (GenericEntityException e) {                    Debug.logError(e, module);                }                String nameOnCard = cc.getString("firstNameOnCard") + " " + cc.getString("lastNameOnCard");                nameOnCard.trim();                payInfo.put("nameOnCard", nameOnCard);                String cardNum = cc.getString("cardNumber");                String cardStr = cardNum.substring(0, 2);                cardStr = cardStr + "****";                cardStr = cardStr + cardNum.substring(cardNum.length() - 4);                String expDate = cc.getString("expireDate");                String infoString = cardStr + " " + expDate;                payInfo.put("payInfo", infoString);                payInfo.putAll(cc);            } else if ("GIFT_CARD".equals(paymentMethodTypeId)) {                GenericValue gc = null;                try {                    gc = infValue.getRelatedOne("GiftCard");                } catch (GenericEntityException e) {                    Debug.logError(e, module);                }            }        }        return payInfo;    }    public double getItemQuantity(String productId) {        trace("request item quantity", productId);        ShoppingCartItem item = cart.findCartItem(productId, null, null, null, 0.00);        if (item != null) {            return item.getQuantity();        } else {            trace("item not found", productId);            return 0;        }    }            public void addItem(String productId, double quantity) throws CartItemModifyException, ItemNotFoundException {        trace("add item", productId + "/" + quantity);        try {            cart.addOrIncreaseItem(productId, quantity, session.getDispatcher());        } catch (ItemNotFoundException e) {            trace("item not found", e);            throw e;        } catch (CartItemModifyException e) {            trace("add item error", e);            throw e;        }    }    public void modifyQty(String productId, double quantity) throws CartItemModifyException {        trace("modify item quantity", productId + "/" + quantity);        ShoppingCartItem item = cart.findCartItem(productId, null, null, null, 0.00);        if (item != null) {            try {                item.setQuantity(quantity, session.getDispatcher(), cart, true);            } catch (CartItemModifyException e) {                Debug.logError(e, module);                trace("modify item error", e);                throw e;            }        } else {            trace("item not found", productId);        }    }    public void modifyPrice(String productId, double price) {        trace("modify item price", productId + "/" + price);        ShoppingCartItem item = cart.findCartItem(productId, null, null, null, 0.00);        if (item != null) {            item.setBasePrice(price);        } else {            trace("item not found", productId);        }    }    public void addDiscount(String productId, double discount, boolean percent) {        GenericValue adjustment = session.getDelegator().makeValue("OrderAdjustment", null);        adjustment.set("orderAdjustmentTypeId", "DISCOUNT_ADJUSTMENT");        if (percent) {            adjustment.set("percentage", new Double(discount));        } else {            adjustment.set("amount", new Double(discount));        }        if (productId != null) {            trace("add item adjustment");            ShoppingCartItem item = cart.findCartItem(productId, null, null, null, 0.00);            Integer itemAdj = (Integer) skuDiscounts.get(productId);            if (itemAdj != null) {                item.removeAdjustment(itemAdj.intValue());            }            int idx = item.addAdjustment(adjustment);            skuDiscounts.put(productId, new Integer(idx));        } else {            trace("add sale adjustment");            if (cartDiscount > -1) {                cart.removeAdjustment(cartDiscount);            }            cartDiscount = cart.addAdjustment(adjustment);        }    }    public void clearDiscounts() {        if (cartDiscount > -1) {            cart.removeAdjustment(cartDiscount);            cartDiscount = -1;        }        if (skuDiscounts.size() > 0) {            Iterator i = skuDiscounts.keySet().iterator();            while (i.hasNext()) {                String productId = (String) i.next();                ShoppingCartItem item = cart.findCartItem(productId, null, null, null, 0.00);                Integer itemAdj = (Integer) skuDiscounts.remove(productId);                if (itemAdj != null) {                    item.removeAdjustment(itemAdj.intValue());                }            }        }    }    public void voidItem(String productId) throws CartItemModifyException {        trace("void item", productId);        ShoppingCartItem item = cart.findCartItem(productId, null, null, null, 0.00);        if (item != null) {            try {                int itemIdx = cart.getItemIndex(item);                cart.removeCartItem(itemIdx, session.getDispatcher());            } catch (CartItemModifyException e) {                Debug.logError(e, module);                trace("void item error", productId, e);                throw e;            }        } else {            trace("item not found", productId);        }    }    public void voidSale() {        trace("void sale");        txLog.set("statusId", "POSTX_VOIDED");        txLog.set("itemCount", new Long(cart.size()));        txLog.set("logEndDateTime", UtilDateTime.nowTimestamp());        try {            txLog.store();        } catch (GenericEntityException e) {            Debug.logError(e, "Unable to store TX log - not fatal", module);        }        cart.clear();        currentTx = null;    }            public void closeTx() {        trace("transaction closed");        txLog.set("statusId", "POSTX_CLOSED");        txLog.set("itemCount", new Long(cart.size()));        txLog.set("logEndDateTime", UtilDateTime.nowTimestamp());        try {            txLog.store();        } catch (GenericEntityException e) {            Debug.logError(e, "Unable to store TX log - not fatal", module);        }        cart.clear();        currentTx = null;    }    public void calcTax() {        try {            ch.calcAndAddTax(this.getStoreOrgAddress());        } catch (GeneralException e) {            Debug.logError(e, module);        }    }    public void clearTax() {        cart.removeAdjustmentByType("SALES_TAX");    }    public int checkPaymentMethodType(String paymentMethodTypeId) {        Map fields = UtilMisc.toMap("paymentMethodTypeId", paymentMethodTypeId, "productStoreId", productStoreId);        List values = null;        try {            values = session.getDelegator().findByAndCache("ProductStorePaymentSetting", fields);        } catch (GenericEntityException e) {            Debug.logError(e, module);        }        final String externalCode = "PRDS_PAY_EXTERNAL";        if (values == null || values.size() == 0) {            return NO_PAYMENT;        } else {            boolean isExternal = true;            Iterator i = values.iterator();            while (i.hasNext() && isExternal) {                GenericValue v = (GenericValue) i.next();                Debug.log("Testing [" + paymentMethodTypeId + "] - " + v, module);                if (!externalCode.equals(v.getString("paymentServiceTypeEnumId"))) {                    isExternal = false;                }            }            if (isExternal) {                return EXTERNAL_PAYMENT;            } else {                return INTERNAL_PAYMENT;            }        }    }    public double addPayment(String id, double amount) {        return this.addPayment(id, amount, null, null);    }    public double addPayment(String id, double amount, String refNum, String authCode) {        trace("added payment", id + "/" + amount);        if ("CASH".equals(id)) {            // clear cash payments first; so there is only one            cart.clearPayment(id);        }        cart.addPaymentAmount(id, new Double(amount), refNum, authCode, true, true, false);        return this.getTotalDue();    }    public void setPaymentRefNum(int paymentIndex, String refNum, String authCode) {        trace("setting payment index reference number", paymentIndex + " / " + refNum + " / " + authCode);        ShoppingCart.CartPaymentInfo inf = cart.getPaymentInfo(paymentIndex);        inf.refNum[0] = refNum;        inf.refNum[1] = authCode;    }    public void clearPayments() {        trace("all payments cleared from sale");        cart.clearPayments();    }    public void clearPayment(int index) {        trace("removing payment", "" + index);        cart.clearPayment(index);    }    public void clearPayment(String id) {        trace("removing payment", id);        cart.clearPayment(id);    }    public int selectedPayments() {        return cart.selectedPayments();    }    public void setTxAsReturn(String returnId) {        trace("returned sale");        txLog.set("statusId", "POSTX_RETURNED");        txLog.set("returnId", returnId);        txLog.set("logEndDateTime", UtilDateTime.nowTimestamp());        try {            txLog.store();        } catch (GenericEntityException e) {            Debug.logError(e, "Unable to store TX log - not fatal", module);        }        cart.clear();        currentTx = null;    }    public double processSale(Output output) throws GeneralException {        trace("process sale");        double grandTotal = this.getGrandTotal();        double paymentAmt = this.getPaymentTotal();        if (grandTotal > paymentAmt) {            throw new IllegalStateException();        }

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -