Package org.ofbiz.pos.component

Examples of org.ofbiz.pos.component.Input


            input.appendChar('y');
        }
    }

    public static void triggerZ(PosScreen pos) {
        Input input = pos.getInput();
        if (capsLockSet || input.isFunctionSet("SHIFT")) {
            input.appendChar('Z');
        } else {
            input.appendChar('z');
        }
    }
View Full Code Here


        } else {
            input.appendChar('z');
        }
    }
    public static void triggerAt(PosScreen pos) {
        Input input = pos.getInput();
            input.appendChar('@');
    }
View Full Code Here

        pos.refresh();
    }

    public static synchronized void payCheck(PosScreen pos) {
        PosTransaction trans = PosTransaction.getCurrentTx(pos.getSession());
        Input input = pos.getInput();
        String[] ckInfo = input.getFunction("CHECK");

        // check for no/external payment processing
        int paymentCheck = trans.checkPaymentMethodType("PERSONAL_CHECK");
        if (paymentCheck == PosTransaction.NO_PAYMENT) {
            trans.clearPayment("PERSONAL_CHECK");
            processNoPayment(pos, "PERSONAL_CHECK");
            return;
        } else if (paymentCheck == PosTransaction.EXTERNAL_PAYMENT) {
            if (ckInfo == null) {
                input.setFunction("CHECK");
                pos.getOutput().print(UtilProperties.getMessage(PosTransaction.resource,"PosRefNum",Locale.getDefault()));
                return;
            } else {
                processExternalPayment(pos, "PERSONAL_CHECK", ckInfo[1]);
                return;
View Full Code Here

        pos.showDialog("dialog/error/notyetsupported");
    }

    public static synchronized void payGiftCard(PosScreen pos) {
        PosTransaction trans = PosTransaction.getCurrentTx(pos.getSession());
        Input input = pos.getInput();
        String[] gcInfo = input.getFunction("GIFTCARD");

        // check for no/external payment processing
        int paymentCheck = trans.checkPaymentMethodType("GIFT_CARD");
        if (paymentCheck == PosTransaction.NO_PAYMENT) {
            processNoPayment(pos, "GIFT_CARD");
            return;
        } else if (paymentCheck == PosTransaction.EXTERNAL_PAYMENT) {
            if (gcInfo == null) {
                input.setFunction("GIFTCARD");
                pos.getOutput().print(UtilProperties.getMessage(PosTransaction.resource,"PosRefNum",Locale.getDefault()));
                clearInputPaymentFunctions(pos);
                return;
            } else {
                processExternalPayment(pos, "GIFT_CARD", gcInfo[1]);
View Full Code Here

        clearInputPaymentFunctions(pos);
    }

    public static synchronized void payCredit(PosScreen pos) {
        PosTransaction trans = PosTransaction.getCurrentTx(pos.getSession());
        Input input = pos.getInput();
        String[] msrInfo = input.getFunction("MSRINFO");
        String[] crtInfo = input.getFunction("CREDIT");
        String[] track2Info = input.getFunction("TRACK2");
        String[] securityCodeInfo = input.getFunction("SECURITYCODE");
        String[] postalCodeInfo = input.getFunction("POSTALCODE");
        String[] creditExpirationInfo = input.getFunction("CREDITEXP");

        // check for no/external payment processing
        int paymentCheck = trans.checkPaymentMethodType("CREDIT_CARD");
        if (paymentCheck == PosTransaction.NO_PAYMENT) {
            processNoPayment(pos, "CREDIT_CARD");
            return;
        } else if (paymentCheck == PosTransaction.EXTERNAL_PAYMENT) {
            if (crtInfo == null) {
                input.setFunction("CREDIT");
                pos.getOutput().print(UtilProperties.getMessage(PosTransaction.resource,"PosRefNum",Locale.getDefault()));
                return;
            } else {
                processExternalPayment(pos, "CREDIT_CARD", crtInfo[1]);
                return;
            }
        }

        // now for internal payment processing
        if (crtInfo == null) {
            // set total, if entered
            input.clearLastFunction();
            input.setFunction("TOTAL");
            input.setFunction("CREDIT");
            pos.getOutput().print(UtilProperties.getMessage(PosTransaction.resource,"PosCredNo",Locale.getDefault()));
        } else {
            Debug.log("Credit Func Info : " + crtInfo[1], module);
            if (msrInfo == null && (creditExpirationInfo == null))  {
                //test credit card
                if (UtilValidate.isNotEmpty(input.value()) && UtilValidate.isCreditCard(input.value())) {
                    input.clearLastFunction();
                    input.setFunction("CREDIT");
                    input.setFunction("CREDITEXP");
                    pos.getOutput().print(UtilProperties.getMessage(PosTransaction.resource,"PosCredex",Locale.getDefault()));
                } else {
                    Debug.log("Invalid card number - " + input.value(), module);
                    clearInputPaymentFunctions(pos);
                    input.clearInput();
                    pos.showDialog("dialog/error/invalidcardnumber");
                }
            } else if (msrInfo == null && (securityCodeInfo == null)) {
                // test expiration date
                if (UtilValidate.isNotEmpty(input.value()) && (input.value().length() == 4)) {
                    // ask for Security Code, put in SECURITYCODE
                    input.clearLastFunction();
                    input.setFunction("CREDITEXP");
                    input.setFunction("SECURITYCODE");
                    pos.getOutput().print(UtilProperties.getMessage(PosTransaction.resource,"PosSecurityCode",Locale.getDefault()));
                } else {
                    Debug.log("Invalid expiration date", module);
                    clearInputPaymentFunctions(pos);
                    input.clearInput();
                    pos.showDialog("dialog/error/invalidexpirationdate");
                }
            } else if (msrInfo == null && (postalCodeInfo == null)) {
                // test security code - allow blank for illegible cards
                if (UtilValidate.isEmpty(input.value()) ||
                        (UtilValidate.isNotEmpty(input.value()) && (input.value().length() <= 4))) {
                    // ask for Security Code, put in SECURITYCODE
                    input.clearLastFunction();
                    input.setFunction("SECURITYCODE");
                    input.setFunction("POSTALCODE");
                    pos.getOutput().print(UtilProperties.getMessage(PosTransaction.resource,"PosPostalCode",Locale.getDefault()));
                } else {
                    clearInputPaymentFunctions(pos);
                    input.clearInput();
                    pos.showDialog("dialog/error/invalidsecuritycode");
                }
            } else {
                String msrInfoStr = null;
                if (msrInfo == null) {
                    input.clearLastFunction();
                    input.setFunction("POSTALCODE");
                    postalCodeInfo = input.getFunction("POSTALCODE");
                    if (UtilValidate.isNotEmpty(crtInfo[1])) {
                        if (UtilValidate.isNotEmpty(creditExpirationInfo[1])) {
                            // setup keyed transaction
                            msrInfoStr = crtInfo[1] + "|" + creditExpirationInfo[1];
                        } else {
                            msrInfoStr = crtInfo[1];
                        }
                    }
                } else // is swiped
                    // grab total from input, if available
                    input.setFunction("TOTAL");
                    msrInfoStr = msrInfo[1];
                }
                input.clearFunction("MSRINFO");
                input.setFunction("MSRINFO", msrInfoStr);
                String[] msrInfoArr = msrInfoStr.split("\\|");
                int allInfo = msrInfoArr.length;
                String firstName = null;
                String lastName = null;
                switch (allInfo) {
                    case 4:
                        lastName = msrInfoArr[3];
                    case 3:
                        firstName = msrInfoArr[2];
                    case 2: // card number & exp date found
                        BigDecimal amount = BigDecimal.ZERO;
                        try {
                            String[] totalInfo = input.getFunction("TOTAL");
                            amount = processAmount(trans, pos, totalInfo[1]);
                            Debug.log("Processing Credit Card Amount : " + amount, module);
                        } catch (GeneralException e) {
                            Debug.logError("Exception caught calling processAmount.", module);
                            Debug.logError(e.getMessage(), module);
                        }

                        String cardNumber = msrInfoArr[0];
                        String expDate = msrInfoArr[1];
                        String pmId = trans.makeCreditCardVo(cardNumber, expDate, firstName, lastName);
                        if (pmId != null) {
                            trans.addPayment(pmId, amount);
                        }
                        if (track2Info != null && UtilValidate.isNotEmpty(track2Info[1])) {
                            // if swiped
                            trans.setPaymentTrack2(pmId, null, track2Info[1]);
                        } else { //keyed
                            if (securityCodeInfo != null && UtilValidate.isNotEmpty(securityCodeInfo[1])) {
                                trans.setPaymentSecurityCode(pmId, null, securityCodeInfo[1]);
                            }
                            if (postalCodeInfo != null && UtilValidate.isNotEmpty(postalCodeInfo[1])) {
                                trans.setPaymentPostalCode(pmId, null, postalCodeInfo[1]);
                            }
                        }
                        clearInputPaymentFunctions(pos);
                        pos.refresh();
                        break;
                    case 1: // card number only found
                        pos.getOutput().print(UtilProperties.getMessage(PosTransaction.resource,"PosCredex",Locale.getDefault()));
                        break;
                    default:
                        Debug.log("Hit the default switch case [" + allInfo + "] refreshing.", module);
                        input.clearFunction("MSRINFO");
                        pos.getOutput().print(UtilProperties.getMessage(PosTransaction.resource,"PosCredNo",Locale.getDefault()));
                        break;
                }
            }
        }
View Full Code Here

        pos.refresh();
    }

    private static synchronized void processExternalPayment(PosScreen pos, String paymentMethodTypeId, String amountStr) {
        PosTransaction trans = PosTransaction.getCurrentTx(pos.getSession());
        Input input = pos.getInput();
        String refNum = input.value();
        if (refNum == null) {
            pos.getOutput().print(UtilProperties.getMessage(PosTransaction.resource,"PosRefNum",Locale.getDefault()));
            return;
        }
        input.clearInput();

        try {
            BigDecimal amount = processAmount(trans, pos, amountStr);
            Debug.log("Processing [" + paymentMethodTypeId + "] Amount : " + amount, module);
View Full Code Here

            pos.setNormalCursor();
        }
    }

    private static synchronized BigDecimal processAmount(PosTransaction trans, PosScreen pos, String amountStr) throws GeneralException {
        Input input = pos.getInput();

        if (input.isFunctionSet("TOTAL")) {
            String amtStr = amountStr != null ? amountStr : input.value();
            BigDecimal amount;
            if (UtilValidate.isNotEmpty(amtStr)) {
                try {
                    amount = new BigDecimal(amtStr);
                } catch (NumberFormatException e) {
                    Debug.logError("Invalid number for amount : " + amtStr, module);
                    pos.getOutput().print("Invalid Amount!");
                    input.clearInput();
                    throw new GeneralException();
                }
                amount = amount.movePointLeft(2); // convert to decimal
                Debug.log("Set amount / 100 : " + amount, module);
            } else {
View Full Code Here

    // processed or if an error occurred
    public static synchronized void clearInputPaymentFunctions(PosScreen pos) {
        String[] paymentFuncs = {"CHECK", "CHECKINFO", "CREDIT",
                                    "GIFTCARD", "MSRINFO", "REFNUM", "CREDITEXP",
                                    "TRACK2", "SECURITYCODE", "POSTALCODE" };
        Input input = pos.getInput();
        for (int i = 0; i < paymentFuncs.length; i++) {
            while (input.isFunctionSet(paymentFuncs[i])) {
                input.clearFunction(paymentFuncs[i]);
            }
        }
    }
View Full Code Here

        pos.getInput().setFunction("QTY");
    }

    public static synchronized void triggerEnter(PosScreen pos, AWTEvent event) {
        // enter key maps to various different events; depending on the function
        Input input = pos.getInput();
        String[] lastFunc = input.getLastFunction();
        if (lastFunc != null) {
            if ("MGRLOGIN".equals(lastFunc[0])) {
                SecurityEvents.mgrLogin(pos);
            } else if ("LOGIN".equals(lastFunc[0])) {
                SecurityEvents.login(pos);
            } else if ("OPEN".equals(lastFunc[0])) {
                ManagerEvents.openTerminal(pos);
            } else if ("CLOSE".equals(lastFunc[0])) {
                ManagerEvents.closeTerminal(pos);
            } else if ("PAID_IN".equals(lastFunc[0])) {
                ManagerEvents.paidOutAndIn(pos, "IN");
            } else if ("PAID_OUT".equals(lastFunc[0])) {
                ManagerEvents.paidOutAndIn(pos, "OUT");
            } else if ("VOID".equals(lastFunc[0])) {
                ManagerEvents.voidOrder(pos);
            } else if ("REFNUM".equals(lastFunc[0])) {
                PaymentEvents.setRefNum(pos);
            } else if ("CREDIT".equals(lastFunc[0])) {
                PaymentEvents.payCredit(pos);
            } else if ("CREDITEXP".equals(lastFunc[0])) {
                PaymentEvents.payCredit(pos);
            } else if ("SECURITYCODE".equals(lastFunc[0])) {
                PaymentEvents.payCredit(pos);
            } else if ("POSTALCODE".equals(lastFunc[0])) {
                PaymentEvents.payCredit(pos);
            } else if ("CHECK".equals(lastFunc[0])) {
                PaymentEvents.payCheck(pos);
            } else if ("GIFTCARD".equals(lastFunc[0])) {
                PaymentEvents.payGiftCard(pos);
            } else if ("MSRINFO".equals(lastFunc[0])) {
                if (input.isFunctionSet("CREDIT")) {
                    PaymentEvents.payCredit(pos);
                } else if (input.isFunctionSet("GIFTCARD")) {
                    PaymentEvents.payGiftCard(pos);
                }
            } else if ("SKU".equals(lastFunc[0])) {
                MenuEvents.addItem(pos, event);
            } else if ("PROMOCODE".equals(lastFunc[0])) {
                PromoEvents.addPromoCode(pos);
            }
        } else if (input.value().length() > 0) {
            MenuEvents.addItem(pos, event);
        }
    }
View Full Code Here

        }
    }

    public static synchronized void addItem(PosScreen pos, AWTEvent event) {
        PosTransaction trans = PosTransaction.getCurrentTx(pos.getSession());
        Input input = pos.getInput();
        String[] func = input.getFunction("QTY");
        String value = input.value();

        // no value; just return
        if (event != null && UtilValidate.isEmpty(value)) {
            String buttonName = ButtonEventConfig.getButtonName(event);
            if (UtilValidate.isNotEmpty(buttonName)) {
                if (buttonName.startsWith("SKU.")) {
                    value = buttonName.substring(4);
                }
            }
            if (UtilValidate.isEmpty(value)) {
                return;
            }
        }

        if (!trans.isOpen()) {
            pos.showDialog("dialog/error/terminalclosed");
        } else {

            // check for quantity
            BigDecimal quantity = BigDecimal.ONE;
            if (func != null && "QTY".equals(func[0])) {
                try {
                    quantity = new BigDecimal(func[1]);
                } catch (NumberFormatException e) {
                    quantity = BigDecimal.ONE;
                }
            }

            // locate the product ID
            String productId = null;
            try {
                List<GenericValue> items = trans.lookupItem(value);
                if (items != null) {
                    ListIterator<GenericValue> it = items.listIterator();
                    if (it.hasNext()) {
                        GenericValue product = it.next();
                        productId = product.getString("productId");
                        Hashtable<String, Object> productsMap = new Hashtable<String, Object>();
                        productsMap.put(product.getString("productId"), product.get("internalName"));
                        while (it.hasNext()) {
                            product = it.next();
                            if (!productId.equals(product.getString("productId"))) {
                                productsMap.put(product.getString("productId"), product.get("internalName"));
                            }
                        }
                        if (productsMap.size() > 1 && ButtonEventConfig.getButtonName(event).equals("menuSku")) {
                            SelectProduct SelectProduct = new SelectProduct(productsMap, trans, pos);
                            productId = SelectProduct.openDlg();
                        }
                    }
                }
            } catch (GeneralException e) {
                Debug.logError(e, module);
                pos.showDialog("dialog/error/producterror");
            }

            // Check for Aggregated item
            boolean aggregatedItem = false;
            ProductConfigWrapper pcw = null;
            try {
                aggregatedItem = trans.isAggregatedItem(productId);
                if (aggregatedItem) {
                    pcw = trans.getProductConfigWrapper(productId);
                    pcw.setDefaultConfig();
                    ConfigureItem configureItem = new ConfigureItem(pcw, trans, pos);
                    pcw = configureItem.openDlg();
                    configureItem = null;
                }
            } catch (Exception e) {
                Debug.logError(e, module);
                pos.showDialog("dialog/error/producterror");
            }

            // add the item to the cart; report any errors to the user
            if (productId != null) {
                try {
                    if (!aggregatedItem) {
                        trans.addItem(productId, quantity);
                    } else {
                        trans.addItem(productId, pcw);
                    }
                } catch (CartItemModifyException e) {
                    Debug.logError(e, module);
                    pos.showDialog("dialog/error/producterror");
                } catch (ItemNotFoundException e) {
                    pos.showDialog("dialog/error/productnotfound");
                }
            } else {
                pos.showDialog("dialog/error/productnotfound");
            }
        }

        // clear the qty flag
        input.clearFunction("QTY");

        // re-calc tax
        trans.calcTax();

        // refresh the others
View Full Code Here

TOP

Related Classes of org.ofbiz.pos.component.Input

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.