예제 #1
0
  @Override
  public Result printReceiptMoneyOut(Path receiptsFile) {
    try {
      PosReceipt posReceipt = PosReceipt.getFromJSON(receiptsFile);

      List<String> lines =
          Files.readAllLines(
              rootPath.resolve(Paths.get("templates", "receipt_money_out.txt")),
              Charset.defaultCharset());

      String receipt = "";
      for (String line : lines) {
        line = line.replaceAll("\\{cash\\}", "" + posReceipt.getCash());
        line = line.replaceAll("\\{fiscal\\}", getFiscalString(posReceipt));

        receipt += line + "\r\n";
      }

      printStringList = Arrays.asList(receipt.split("\r\n"));
      printDoc();
      return Result.newEmptySuccess();

    } catch (Exception e) {
      Logger.getGlobal().log(Level.WARNING, null, e);
      return Result.newResultError(e.toString());
    }
  }
예제 #2
0
  @Override
  public Result printXReport(Path xReportFile) {
    try {
      ZReport xReport = ZReport.getFromJSON(xReportFile);

      List<String> lines =
          Files.readAllLines(
              rootPath.resolve(Paths.get("templates", "x-report.txt")), Charset.defaultCharset());

      String zReport = "";
      for (String line : lines) {
        line = line.replaceAll("\\{number\\}", "" + xReport.getNumber());
        line =
            line.replaceAll(
                "\\{date\\}", DateTime.getFormatedDate("dd.MM.yyyy HH:mm:ss", xReport.getDate()));
        line = line.replaceAll("\\{salesCount\\}", "" + xReport.getSalesCount());
        line = line.replaceAll("\\{moneyInCount\\}", "" + xReport.getMoneyInCount());
        line = line.replaceAll("\\{moneyOutCount\\}", "" + xReport.getMoneyOutCount());
        line = line.replaceAll("\\{returnCount\\}", "" + xReport.getReturnCount());
        line = line.replaceAll("\\{stornoCount\\}", "" + xReport.getStornoCount());
        line = line.replaceAll("\\{cancelCount\\}", "" + xReport.getCancelCount());
        line = line.replaceAll("\\{moneyOut\\}", "" + xReport.getMoneyOut());
        line = line.replaceAll("\\{moneyIn\\}", "" + xReport.getMoneyIn());
        line = line.replaceAll("\\{cash\\}", "" + xReport.getCash());
        line = line.replaceAll("\\{sales\\}", "" + xReport.getSalesSum());
        line = line.replaceAll("\\{totalSales\\}", "" + xReport.getTotalSales());
        line = line.replaceAll("\\{totalCash\\}", "" + xReport.getTotalCash());

        zReport += line + "\r\n";
      }

      printStringList = Arrays.asList(zReport.split("\r\n"));
      printDoc();
      return Result.newEmptySuccess();

    } catch (Exception ex) {
      Logger.getLogger(POSPrinter.class.getName()).log(Level.SEVERE, null, ex);
      return Result.newResult(false, ex.toString());
    }
  }
예제 #3
0
  private void savePage(String page) {
    PopupPanel popupPanel = new PopupPanel(getSession());
    popupPanel.setTitle("Сообщение");
    popupPanel.setPanel("Сохранено");

    if (core.isPageExist(selectedPage)) {
      Result r = core.modifyWWWPage(selectedPage, page);
      if (r.isError()) {
        JSMediator.alert(getSession(), r.getReason());
      } else {
        popupPanel.showPanel();
      }

    } else {
      Result r = core.addWWWPage(selectedPage, page);
      if (r.isError()) {
        JSMediator.alert(getSession(), r.getReason());
      } else {
        popupPanel.showPanel();
      }
    }
  }