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

📄 managerevents.java

📁 Sequoia ERP是一个真正的企业级开源ERP解决方案。它提供的模块包括:电子商务应用(e-commerce), POS系统(point of sales),知识管理,存货与仓库管理
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
/* * $Id: ManagerEvents.java 6564 2006-01-24 17:02:46Z sichen $ * * Copyright (c) 2004 The Open For Business Project - www.ofbiz.org * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included * in all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT * OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR * THE USE OR OTHER DEALINGS IN THE SOFTWARE. * */package org.ofbiz.pos.event;import java.util.List;import java.util.HashMap;import java.util.Map;import java.sql.Timestamp;import java.util.Locale;import net.xoetrope.xui.XProjectManager;import org.ofbiz.base.util.cache.UtilCache;import org.ofbiz.base.util.Debug;import org.ofbiz.base.util.UtilMisc;import org.ofbiz.base.util.UtilDateTime;import org.ofbiz.base.util.UtilFormatOut;import org.ofbiz.base.util.UtilValidate;import org.ofbiz.pos.device.DeviceLoader;import org.ofbiz.pos.device.impl.Receipt;import org.ofbiz.pos.screen.PosScreen;import org.ofbiz.pos.PosTransaction;import org.ofbiz.pos.adaptor.SyncCallbackAdaptor;import org.ofbiz.pos.component.Input;import org.ofbiz.pos.component.Output;import org.ofbiz.entity.GenericDelegator;import org.ofbiz.entity.GenericEntityException;import org.ofbiz.entity.GenericValue;import org.ofbiz.entity.util.EntityListIterator;import org.ofbiz.entity.condition.EntityExpr;import org.ofbiz.entity.condition.EntityOperator;import org.ofbiz.entity.condition.EntityConditionList;import org.ofbiz.service.LocalDispatcher;import org.ofbiz.service.GenericServiceException;import org.ofbiz.service.ServiceUtil;import org.ofbiz.guiapp.xui.XuiSession;import org.ofbiz.base.util.UtilProperties;/** *  * @author     <a href="mailto:jaz@ofbiz.org">Andy Zeneski</a> * @version    $Rev: 6564 $ * @since      3.1 */public class ManagerEvents {    public static final String module = ManagerEvents.class.getName();    public static boolean mgrLoggedIn = false;    public static void modifyPrice(PosScreen pos) {        PosTransaction trans = PosTransaction.getCurrentTx(pos.getSession());        String sku = null;        try {            sku = MenuEvents.getSelectedItem(pos);        } catch (ArrayIndexOutOfBoundsException e) {        }        if (sku == null) {            pos.getOutput().print(UtilProperties.getMessage("pos","Invalid_Selection",Locale.getDefault()));            pos.getJournal().refresh(pos);            pos.getInput().clear();        }        Input input = pos.getInput();        String value = input.value();        if (UtilValidate.isNotEmpty(value)) {            double price = 0.00;            boolean parsed = false;            try {                price = Double.parseDouble(value);                parsed = true;            } catch (NumberFormatException e) {            }            if (parsed) {                price = price / 100;                trans.modifyPrice(sku, price);                // re-calc tax                trans.calcTax();            }        }        // refresh the other components        pos.refresh();    }    public static void openTerminal(PosScreen pos) {        if (!mgrLoggedIn) {            pos.showDialog("dialog/error/mgrnotloggedin");            return;        }        PosTransaction trans = PosTransaction.getCurrentTx(pos.getSession());        Input input = pos.getInput();        if (!trans.isOpen()) {            if (input.isFunctionSet("OPEN")) {                String amountStr = input.value();                Double amount = null;                if (UtilValidate.isNotEmpty(amountStr)) {                    try {                        double amt = Double.parseDouble(amountStr);                        amt = amt / 100;                        amount = new Double(amt);                    } catch (NumberFormatException e) {                        Debug.logError(e, module);                    }                }                GenericValue state = pos.getSession().getDelegator().makeValue("PosTerminalState", null);                state.set("posTerminalId", pos.getSession().getId());                state.set("openedDate", UtilDateTime.nowTimestamp());                state.set("openedByUserLoginId", pos.getSession().getUserId());                state.set("startingTxId", trans.getTransactionId());                state.set("startingDrawerAmount", amount);                try {                    state.create();                } catch (GenericEntityException e) {                    Debug.logError(e, module);                    pos.showDialog("dialog/error/exception", e.getMessage());                }                NavagationEvents.showPosScreen(pos);            } else {                input.clear();                input.setFunction("OPEN");                pos.getOutput().print(UtilProperties.getMessage("pos","OPDRAM",Locale.getDefault()));                return;            }        } else {            pos.showPage("pospanel");        }    }    public static void closeTerminal(PosScreen pos) {        if (!mgrLoggedIn) {            pos.showDialog("dialog/error/mgrnotloggedin");            return;        }        PosTransaction trans = PosTransaction.getCurrentTx(pos.getSession());        if (!trans.isOpen()) {            pos.showDialog("dialog/error/terminalclosed");            return;        }        Output output = pos.getOutput();        Input input = pos.getInput();        if (input.isFunctionSet("CLOSE")) {            String[] func = input.getFunction("CLOSE");            String lastValue = input.value();            if (UtilValidate.isNotEmpty(lastValue)) {                try {                    double dbl = Double.parseDouble(lastValue);                    dbl = dbl / 100;                    lastValue = UtilFormatOut.formatPrice(dbl);                } catch (NumberFormatException e) {                    Debug.logError(e, module);                }                if (UtilValidate.isNotEmpty(func[1])) {                    func[1] = func[1] + "|";                }                func[1] = func[1] + lastValue;                input.setFunction("CLOSE", func[1]);            }            String[] closeInfo = new String[0];            if (UtilValidate.isNotEmpty(func[1])) {                closeInfo = func[1].split("\\|");            }            switch (closeInfo.length) {                case 0:                    output.print(UtilProperties.getMessage("pos","ENTCAS",Locale.getDefault()));                    break;                case 1:                    output.print(UtilProperties.getMessage("pos","ENTCHK",Locale.getDefault()));                    break;                case 2:                    output.print(UtilProperties.getMessage("pos","ENTCRC",Locale.getDefault()));                    break;                case 3:                    output.print(UtilProperties.getMessage("pos","ENTGFC",Locale.getDefault()));                    break;                case 4:                    output.print(UtilProperties.getMessage("pos","ENTOTH",Locale.getDefault()));                    break;                case 5:                    GenericValue state = trans.getTerminalState();                    state.set("closedDate", UtilDateTime.nowTimestamp());                    state.set("closedByUserLoginId", pos.getSession().getUserId());                    state.set("actualEndingCash", new Double(closeInfo[0]));                    state.set("actualEndingCheck", new Double(closeInfo[1]));                    state.set("actualEndingCc", new Double(closeInfo[2]));                    state.set("actualEndingGc", new Double(closeInfo[3]));                    state.set("actualEndingOther", new Double(closeInfo[4]));                    state.set("endingTxId", trans.getTransactionId());                    Debug.log("Updated State - " + state, module);                    try {                        state.store();                        state.refresh();                    } catch (GenericEntityException e) {                        Debug.logError(e, module);                        pos.showDialog("dialog/error/exception", e.getMessage());                    }                    // print the totals report                    printTotals(pos, state, true);                    // lock the terminal for the moment                    output.print(UtilProperties.getMessage("pos","WaitingFinalSales",Locale.getDefault()));                    pos.getInput().setLock(true);                    pos.getButtons().setLock(true);                    pos.refresh(false);                    // transmit final data to server                    GenericValue terminal = null;                    try {                        terminal = state.getRelatedOne("PosTerminal");                    } catch (GenericEntityException e) {                        Debug.logError(e, module);                        pos.showDialog("dialog/error/exception", e.getMessage());                    }                    if (terminal != null && terminal.get("pushEntitySyncId") != null) {                        String syncId = terminal.getString("pushEntitySyncId");                        SyncCallbackAdaptor cb = new SyncCallbackAdaptor(pos, syncId, state.getTimestamp("lastUpdatedTxStamp"));                        pos.getSession().getDispatcher().registerCallback("runEntitySync", cb);                    } else {                        // no sync setting; just logout                        pos.showDialog("dialog/error/terminalclosed");                        SecurityEvents.logout(pos);                    }            }        } else {            trans.popDrawer();            input.clear();            input.setFunction("CLOSE");            output.print(UtilProperties.getMessage("pos","ENTCAS",Locale.getDefault()));        }    }    public static void voidOrder(PosScreen pos) {        if (!mgrLoggedIn) {

⌨️ 快捷键说明

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