Пример #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
  private String getFiscalString(PosReceipt posReceipt) {
    String s =
        "\r\n"
            + zeroLead(posReceipt.getNumbeReceipt())
            + " "
            + zeroLead(posReceipt.getNumberDoc())
            + " "
            + posReceipt.getSection()
            + " K"
            + posReceipt.getPassword();

    switch (posReceipt.getReceiptType()) {
      case PosReceipt.TYPE_SALE:
        s = s + " ==" + POSUtil.getReceiptSum(posReceipt.getReceipt());
        break;

      case PosReceipt.TYPE_MONEY_IN:
        s = s + posReceipt.getCash();
        break;

      case PosReceipt.TYPE_MONEY_OUT:
        s = s + posReceipt.getCash();
        break;
    }

    return s;
  }
Пример #3
0
  private String getRecieptRows(PosReceipt posReceipt) {
    String s = "";

    for (ReceiptRow receiptRow : posReceipt.getReceipt().getReceiptRows()) {
      s +=
          receiptRow.getItemName()
              + "\r\n"
              + receiptRow.getPrice()
              + " x "
              + receiptRow.getQuantity()
              + "="
              + Money.MULTIPLY(receiptRow.getPrice(), receiptRow.getQuantity())
              + "\r\n";
    }

    return s;
  }