erp java源代码_receipt.java 源代码在线查看 - Sequoia ERP是一个真正的企业级开源ERP解决方案。它提供的模块包括:电子商务应用(e-commerce), POS系统(...

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(); }}

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值