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

📄 receipt.java

📁 Sequoia ERP是一个真正的企业级开源ERP解决方案。它提供的模块包括:电子商务应用(e-commerce), POS系统(point of sales),知识管理,存货与仓库管理
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
        return this.custReceiptTmpl;    }    private synchronized String[] readReportTemplate(String resource) {        String[] template = (String[]) reportTmpl.get(resource);        if (template == null) {            template = new String[7];            this.readTemplate(template, resource, 2);            reportTmpl.put(resource, template);        }        return template;    }    private String[] readTemplate(String[] template, String resource, int type) {        int currentPart = 0;        URL fileUrl = UtilURL.fromResource(resource);        StringBuffer buf = new StringBuffer();        try {            InputStream in = fileUrl.openStream();            BufferedReader dis = new BufferedReader(new InputStreamReader(in));            String line;            while ((line = dis.readLine()) != null) {                if (line.trim().startsWith("#")) {                    String[] code = line.trim().split("\\=");                    if ("#description.length".equals(code[0])) {                        try {                            this.descLength[type] = Integer.parseInt(code[1]);                        } catch (NumberFormatException e) {                            Debug.logWarning(e, module);                        }                    } else if ("#productId.length".equals(code[0])) {                        try {                            this.pridLength[type] = Integer.parseInt(code[1]);                        } catch (NumberFormatException e) {                            Debug.logWarning(e, module);                        }                    } else if ("#price.length".equals(code[0])) {                        try {                            this.priceLength[type] = Integer.parseInt(code[1]);                        } catch (NumberFormatException e) {                            Debug.logWarning(e, module);                        }                    } else if ("#quantity.length".equals(code[0])) {                        try {                            this.qtyLength[type] = Integer.parseInt(code[1]);                        } catch (NumberFormatException e) {                            Debug.logWarning(e, module);                        }                    } else if ("#infoString.length".equals(code[0])) {                        try {                            this.infoLength[type] = Integer.parseInt(code[1]);                        } catch (NumberFormatException e) {                            Debug.logWarning(e, module);                        }                    } else if ("#dateFormat".equals(code[0])) {                        this.dateFmtStr[type] = code[1];                    }                } else if (line.trim().startsWith("[BEGIN ITEM LOOP]")) {                    template[currentPart++] = buf.toString();                    buf = new StringBuffer();                    buf.append("[DLOOP]");                } else if (line.trim().startsWith("[END ITEM LOOP]")) {                    template[currentPart++] = buf.toString();                    buf = new StringBuffer();                } else if (line.trim().startsWith("[BEGIN PAY LOOP]")) {                    template[currentPart++] = buf.toString();                    buf = new StringBuffer();                    buf.append("[PLOOP]");                } else if (line.trim().startsWith("[END PAY LOOP]")) {                    template[currentPart++] = buf.toString();                    buf = new StringBuffer();                } else if (line.trim().startsWith("[ORDER BARCODE]")) {                    template[currentPart++] = buf.toString();                    template[currentPart++] = "[ORDER_BARCODE]";                    buf = new StringBuffer();                } else {                    if (UtilValidate.isEmpty(line)) {                        line = " ";                    }                    buf.append(line + "\n");                }            }            in.close();        } catch (IOException e) {            Debug.logError(e, "Unable to open receipt template", module);        }        template[currentPart] = buf.toString();        return template;    }    private synchronized SimpleDateFormat getDateFormat(int type) {        if (dateFormat == null) {            dateFormat = new SimpleDateFormat[3];        }        if (dateFormat[type] == null) {            dateFormat[type] = new SimpleDateFormat(this.dateFmtStr[type]);        }        return dateFormat[type];    }    private void printInfo(String template, Map context, PosTransaction trans, int type) {        Map expandMap = this.makeCodeExpandMap(trans, type);        if (context != null) {            expandMap.putAll(context); // context overrides        }        this.printInfo(template, expandMap);    }    private void printInfo(String template, PosTransaction trans, int type) {        this.printInfo(template, null, trans, type);    }    private void printInfo(String template, Map context) {        String toPrint = FlexibleStringExpander.expandString(template, context);        if (toPrint.indexOf("\n") > -1) {            String[] lines = toPrint.split("\\n");            for (int i = 0; i < lines.length; i++) {                this.println(lines[i]);            }        } else {            this.println(toPrint);        }    }    private void printDetail(String loop, PosTransaction trans, int type) {        String loopStr = loop.substring(7);        int size = trans.size();        for (int i = 0; i < size; i++) {            Map expandMap = this.makeCodeExpandMap(trans, type);            expandMap.putAll(trans.getItemInfo(i));            // adjust the padding            expandMap.put("description", UtilFormatOut.padString((String) expandMap.get("description"), descLength[type], true, ' '));            expandMap.put("productId", UtilFormatOut.padString((String) expandMap.get("productId"), pridLength[type], true, ' '));            expandMap.put("basePrice", UtilFormatOut.padString((String) expandMap.get("basePrice"), priceLength[type], false, ' '));            expandMap.put("subtotal", UtilFormatOut.padString((String) expandMap.get("subtotal"), priceLength[type], false, ' '));            expandMap.put("quantity", UtilFormatOut.padString((String) expandMap.get("quantity"), qtyLength[type], false, ' '));            expandMap.put("adjustments", UtilFormatOut.padString((String) expandMap.get("adjustments"), priceLength[type], false, ' '));            String toPrint = FlexibleStringExpander.expandString(loopStr, expandMap);            if (toPrint.indexOf("\n") > -1) {                String[] lines = toPrint.split("\\n");                for (int x = 0; x < lines.length; x++) {                    this.println(lines[x]);                }            } else {                this.println(toPrint);            }        }    }    private void printPayInfo(String loop, PosTransaction trans, int type) {        String loopStr = loop.substring(7);        int size = trans.getNumberOfPayments();        for (int i = 0; i < size; i++) {            Map payInfoMap = trans.getPaymentInfo(i);            this.printPayInfo(loopStr, trans, type, payInfoMap);        }    }    private void printPayInfo(String template, PosTransaction trans, int type, Map payInfo) {        Map expandMap = this.makeCodeExpandMap(trans, type);        expandMap.putAll(payInfo);        // adjust the padding        expandMap.put("authInfoString", UtilFormatOut.padString((String) expandMap.get("authInfoString"), infoLength[type], false, ' '));        expandMap.put("nameOnCard", UtilFormatOut.padString((String) expandMap.get("nameOnCard"), infoLength[type], false, ' '));        expandMap.put("payInfo", UtilFormatOut.padString((String) expandMap.get("payInfo"), infoLength[type], false, ' '));        expandMap.put("amount", UtilFormatOut.padString((String) expandMap.get("amount"), priceLength[type], false, ' '));        String toPrint = FlexibleStringExpander.expandString(template, expandMap);        if (toPrint.indexOf("\n") > -1) {            String[] lines = toPrint.split("\\n");            for (int x = 0; x < lines.length; x++) {                this.println(lines[x]);            }        } else {            this.println(toPrint);        }    }    private Map makeCodeExpandMap(PosTransaction trans, int type) {        Map expandMap = new HashMap();        SimpleDateFormat fmt = this.getDateFormat(type);        String dateString = fmt.format(new Date());        expandMap.put("DOUBLE_HEIGHT", TEXT_DOUBLE_HEIGHT);        expandMap.put("CENTER", ALIGN_CENTER);        expandMap.put("BOLD", TEXT_BOLD);        expandMap.put("LF", LF);        expandMap.put("transactionId", trans.getTransactionId());        expandMap.put("terminalId", trans.getTerminalId());        expandMap.put("userId", trans.getUserId());        expandMap.put("orderId", trans.getOrderId());        expandMap.put("dateStamp", dateString);        expandMap.put("drawerNo", new Integer(trans.getDrawerNumber()).toString());        expandMap.put("taxTotal", UtilFormatOut.padString(UtilFormatOut.formatPrice(trans.getTaxTotal()), priceLength[type], false, ' '));        expandMap.put("grandTotal", UtilFormatOut.padString(UtilFormatOut.formatPrice(trans.getGrandTotal()), priceLength[type], false, ' '));        expandMap.put("totalPayments", UtilFormatOut.padString(UtilFormatOut.formatPrice(trans.getPaymentTotal()), priceLength[type], false, ' '));        expandMap.put("change", UtilFormatOut.padString((trans.getTotalDue() < 0 ?                UtilFormatOut.formatPrice(trans.getTotalDue() * -1) : "0.00"), priceLength[type], false, ' '));        return expandMap;    }    private boolean checkState(POSPrinter printer) throws JposException {        if (printer.getCoverOpen() == true) {            // printer is not ready            PosScreen.currentScreen.showDialog("main/dialog/error/printernotready", this);            return false;        }        return true;    }    public void receiveDialogCb(PosDialog dialog) {        PosScreen.currentScreen.refresh();        this.reprintReceipt();    }}

⌨️ 快捷键说明

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