📄 managerevents.java
字号:
pos.showDialog("dialog/error/mgrnotloggedin"); return; } XuiSession session = pos.getSession(); PosTransaction trans = PosTransaction.getCurrentTx(session); if (!trans.isOpen()) { pos.showDialog("dialog/error/terminalclosed"); return; } Output output = pos.getOutput(); Input input = pos.getInput(); boolean lookup = false; if (input.isFunctionSet("VOID")) { lookup = true; } else if (UtilValidate.isNotEmpty(input.value())) { lookup = true; } if (lookup) { GenericValue state = trans.getTerminalState(); Timestamp openDate = state.getTimestamp("openedDate"); String orderId = input.value(); GenericValue orderHeader = null; try { orderHeader = session.getDelegator().findByPrimaryKey("OrderHeader", UtilMisc.toMap("orderId", orderId)); } catch (GenericEntityException e) { Debug.logError(e, module); } if (orderHeader == null) { input.clear(); pos.showDialog("dialog/error/ordernotfound"); return; } else { Timestamp orderDate = orderHeader.getTimestamp("orderDate"); if (orderDate.after(openDate)) { LocalDispatcher dispatcher = session.getDispatcher(); Map returnResp = null; try { returnResp = dispatcher.runSync("quickReturnOrder", UtilMisc.toMap("orderId", orderId, "returnHeaderTypeId", "CUSTOMER_RETURN", "userLogin", session.getUserLogin())); } catch (GenericServiceException e) { Debug.logError(e, module); pos.showDialog("dialog/error/exception", e.getMessage()); pos.refresh(); return; } if (returnResp != null && ServiceUtil.isError(returnResp)) { pos.showDialog("dialog/error/exception", ServiceUtil.getErrorMessage(returnResp)); pos.refresh(); return; } // todo print void receipt trans.setTxAsReturn((String) returnResp.get("returnId")); input.clear(); pos.showDialog("dialog/error/salevoided"); pos.refresh(); } else { input.clear(); pos.showDialog("dialog/error/ordernotfound"); return; } } } else { input.setFunction("VOID"); output.print(UtilProperties.getMessage("pos","VOID",Locale.getDefault())); } } public static void reprintLastTx(PosScreen pos) { if (!mgrLoggedIn) { pos.showDialog("dialog/error/mgrnotloggedin"); return; } DeviceLoader.receipt.reprintReceipt(true); pos.refresh(); } public static void popDrawer(PosScreen pos) { if (!mgrLoggedIn) { pos.showDialog("dialog/error/mgrnotloggedin"); } else { PosTransaction trans = PosTransaction.getCurrentTx(pos.getSession()); trans.popDrawer(); pos.refresh(); } } public static void clearCache(PosScreen pos) { if (!mgrLoggedIn) { pos.showDialog("dialog/error/mgrnotloggedin"); } else { UtilCache.clearAllCaches(); pos.refresh(); } } public static void resetXui(PosScreen pos) { if (!mgrLoggedIn) { pos.showDialog("dialog/error/mgrnotloggedin"); } else { XProjectManager.getPageManager().reset(); pos.refresh(); } } public static void shutdown(PosScreen pos) { if (!mgrLoggedIn) { pos.showDialog("dialog/error/mgrnotloggedin"); } else { pos.getOutput().print(UtilProperties.getMessage("pos","Shutting_down",Locale.getDefault())); PosTransaction.getCurrentTx(pos.getSession()).closeTx(); System.exit(0); } } public static void totalsReport(PosScreen pos) { if (!mgrLoggedIn) { pos.showDialog("dialog/error/mgrnotloggedin"); return; } printTotals(pos, null, false); } private static void printTotals(PosScreen pos, GenericValue state, boolean runBalance) { PosTransaction trans = PosTransaction.getCurrentTx(pos.getSession()); if (!trans.isOpen()) { pos.showDialog("dialog/error/terminalclosed"); return; } if (state == null) { state = trans.getTerminalState(); } double checkTotal = 0.00; double cashTotal = 0.00; double gcTotal = 0.00; double ccTotal = 0.00; double othTotal = 0.00; double total = 0.00; GenericDelegator delegator = pos.getSession().getDelegator(); List exprs = UtilMisc.toList(new EntityExpr("originFacilityId", EntityOperator.EQUALS, trans.getFacilityId()), new EntityExpr("terminalId", EntityOperator.EQUALS, trans.getTerminalId())); EntityListIterator eli = null; try { eli = delegator.findListIteratorByCondition("OrderHeaderAndPaymentPref", new EntityConditionList(exprs, EntityOperator.AND), null, null); } catch (GenericEntityException e) { Debug.logError(e, module); } Timestamp dayStart = state.getTimestamp("openedDate"); Timestamp dayEnd = state.getTimestamp("closedDate"); if (dayEnd == null) { dayEnd = UtilDateTime.nowTimestamp(); } if (eli != null) { GenericValue ohpp; while (((ohpp = (GenericValue) eli.next()) != null)) { Timestamp orderDate = ohpp.getTimestamp("orderDate"); if (orderDate.after(dayStart) && orderDate.before(dayEnd)) { String pmt = ohpp.getString("paymentMethodTypeId"); Double amt = ohpp.getDouble("maxAmount"); if ("CASH".equals(pmt)) { cashTotal += amt.doubleValue(); } else if ("CHECK".equals(pmt)) { checkTotal += amt.doubleValue(); } else if ("GIFT_CARD".equals(pmt)) { gcTotal += amt.doubleValue(); } else if ("CREDIT_CARD".equals(pmt)) { ccTotal += amt.doubleValue(); } else { othTotal += amt.doubleValue(); } total += amt.doubleValue(); } } try { eli.close(); } catch (GenericEntityException e) { Debug.logWarning(e, "Trouble closing ELI", module); } } Map reportMap = new HashMap(); String reportTemplate = "totals.txt"; // miscellaneous reportMap.put("term", UtilFormatOut.padString(UtilProperties.getMessage("pos","term",Locale.getDefault()), 20, false, ' ')); reportMap.put("draw", UtilFormatOut.padString(UtilProperties.getMessage("pos","draw",Locale.getDefault()), 20, false, ' ')); reportMap.put("clerk", UtilFormatOut.padString(UtilProperties.getMessage("pos","clerk",Locale.getDefault()), 20, false, ' ')); reportMap.put("total_report", UtilFormatOut.padString(UtilProperties.getMessage("pos","total_report",Locale.getDefault()), 20, false, ' ')); // titles reportMap.put("cashTitle", UtilFormatOut.padString(UtilProperties.getMessage("pos","CASH",Locale.getDefault()), 20, false, ' ')); reportMap.put("checkTitle", UtilFormatOut.padString(UtilProperties.getMessage("pos","CHECK",Locale.getDefault()), 20, false, ' ')); reportMap.put("giftCardTitle", UtilFormatOut.padString(UtilProperties.getMessage("pos","GIFT_CARD",Locale.getDefault()), 20, false, ' ')); reportMap.put("creditCardTitle", UtilFormatOut.padString(UtilProperties.getMessage("pos","CREDIT_CARD",Locale.getDefault()), 20, false, ' ')); reportMap.put("otherTitle", UtilFormatOut.padString(UtilProperties.getMessage("pos","OTHER",Locale.getDefault()), 20, false, ' ')); reportMap.put("grossSalesTitle", UtilFormatOut.padString(UtilProperties.getMessage("pos","GROSS_SALES",Locale.getDefault()), 20, false, ' ')); reportMap.put("+/-", UtilFormatOut.padString("+/-", 20, false, ' ')); reportMap.put("spacer", UtilFormatOut.padString("", 20, false, ' ')); // logged reportMap.put("cashTotal", UtilFormatOut.padString(UtilFormatOut.formatPrice(cashTotal), 8, false, ' ')); reportMap.put("checkTotal", UtilFormatOut.padString(UtilFormatOut.formatPrice(checkTotal), 8, false, ' ')); reportMap.put("ccTotal", UtilFormatOut.padString(UtilFormatOut.formatPrice(ccTotal), 8, false, ' ')); reportMap.put("gcTotal", UtilFormatOut.padString(UtilFormatOut.formatPrice(gcTotal), 8, false, ' ')); reportMap.put("otherTotal", UtilFormatOut.padString(UtilFormatOut.formatPrice(othTotal), 8, false, ' ')); reportMap.put("grossTotal", UtilFormatOut.padString(UtilFormatOut.formatPrice(total), 8, false, ' ')); if (runBalance) { // actuals double cashEnd = state.getDouble("actualEndingCash").doubleValue(); double checkEnd = state.getDouble("actualEndingCheck").doubleValue(); double ccEnd = state.getDouble("actualEndingCc").doubleValue(); double gcEnd = state.getDouble("actualEndingGc").doubleValue(); double othEnd = state.getDouble("actualEndingOther").doubleValue(); double grossEnd = cashEnd + checkEnd + ccEnd + gcEnd + othEnd; reportMap.put("cashEnd", UtilFormatOut.padString(UtilFormatOut.formatPrice(cashEnd), 8, false, ' ')); reportMap.put("checkEnd", UtilFormatOut.padString(UtilFormatOut.formatPrice(checkEnd), 8, false, ' ')); reportMap.put("ccEnd", UtilFormatOut.padString(UtilFormatOut.formatPrice(ccEnd), 8, false, ' ')); reportMap.put("gcEnd", UtilFormatOut.padString(UtilFormatOut.formatPrice(gcEnd), 8, false, ' ')); reportMap.put("otherEnd", UtilFormatOut.padString(UtilFormatOut.formatPrice(othEnd), 8, false, ' ')); reportMap.put("grossEnd", UtilFormatOut.padString(UtilFormatOut.formatPrice(grossEnd), 8, false, ' ')); // diffs double cashDiff = cashEnd - cashTotal; double checkDiff = checkEnd - checkTotal; double ccDiff = ccEnd - ccTotal; double gcDiff = gcEnd - gcTotal; double othDiff = othEnd - othTotal; double grossDiff = cashDiff + checkDiff + ccDiff + gcDiff + othDiff; reportMap.put("cashDiff", UtilFormatOut.padString(UtilFormatOut.formatPrice(cashDiff), 8, false, ' ')); reportMap.put("checkDiff", UtilFormatOut.padString(UtilFormatOut.formatPrice(checkDiff), 8, false, ' ')); reportMap.put("ccDiff", UtilFormatOut.padString(UtilFormatOut.formatPrice(ccDiff), 8, false, ' ')); reportMap.put("gcDiff", UtilFormatOut.padString(UtilFormatOut.formatPrice(gcDiff), 8, false, ' ')); reportMap.put("otherDiff", UtilFormatOut.padString(UtilFormatOut.formatPrice(othDiff), 8, false, ' ')); reportMap.put("grossDiff", UtilFormatOut.padString(UtilFormatOut.formatPrice(grossDiff), 8, false, ' ')); // set the report template reportTemplate = "balance.txt"; } Receipt receipt = DeviceLoader.receipt; if (receipt.isEnabled()) { receipt.printReport(trans, reportTemplate, reportMap); } }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -