Skip to content

Commit

Permalink
[-] Fixed error with text journal
Browse files Browse the repository at this point in the history
  • Loading branch information
VitalyKravtsov2016 committed Nov 29, 2023
1 parent 552eb5e commit 267c714
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 32 deletions.
7 changes: 7 additions & 0 deletions History.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,13 @@
Company : SHTRIH-M www.shtrih-m.ru (495) 787-6090
Url : https://github.com/shtrih-m/javapos_shtrih

********************************************************************************

29.11.2023
deviceServiceVersion = 1013706

[-] Fixed error with text journal

********************************************************************************

27.10.2023
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,7 @@ public class TextDocumentFilter implements IPrinterEvents {
private static String SDayClosed = "СМЕНА ЗАКРЫТА";
public static final String SINN = "ИНН";
private static String[] docNames = {SSaleText, SBuyText, SRetSaleText, SRetBuyText};
public boolean receiptEnabled = false;
public boolean isDocumentActive = false;
private boolean documentActive = false;
private final List<String> lines = new ArrayList<String>();


Expand Down Expand Up @@ -141,13 +140,13 @@ public void afterCommand(PrinterCommand command) throws Exception {
switch (command.getCode())
{
case 0x17:
if (isDocumentActive){
if (documentActive){
add(((PrintString) command).getLine());
}
break;

case 0x2F:
if (isDocumentActive){
if (documentActive){
add(((PrintStringFont) command).getLine());
}
break;
Expand Down Expand Up @@ -393,40 +392,34 @@ private String getPaymentName(int paymentIndex) throws Exception
}

private void printSale(PrintSale command) throws Exception {
if (!receiptEnabled) return;
operatorNumber = command.getOperator();
openReceipt2(PrinterConst.SMFP_RECTYPE_SALE);
printReceiptItem(command.getItem());
}

private void printSale(FSPrintRecItem command) throws Exception {
if (!receiptEnabled) return;
printReceiptItem(command.getItem());
}

private void printRefund(PrintRefund command) throws Exception {
if (!receiptEnabled) return;
operatorNumber = command.getOperator();
openReceipt2(PrinterConst.SMFP_RECTYPE_BUY);
printReceiptItem(command.getItem());
}

private void printVoidSale(PrintVoidSale command) throws Exception {
if (!receiptEnabled) return;
operatorNumber = command.getOperator();
openReceipt2(PrinterConst.SMFP_RECTYPE_RETSALE);
printReceiptItem(command.getItem());
}

private void printVoidRefund(PrintVoidRefund command) throws Exception {
if (!receiptEnabled) return;
operatorNumber = command.getOperator();
openReceipt2(PrinterConst.SMFP_RECTYPE_RETBUY);
printReceiptItem(command.getItem());
}

private void printVoidItem(PrintVoidItem command) throws Exception {
if (!receiptEnabled) return;
operatorNumber = command.getOperator();
PriceItem item = command.getItem();
// Line 1
Expand Down Expand Up @@ -704,12 +697,12 @@ public void add(String text, long value) throws Exception {

private void beginDocument() throws Exception {
printReceiptHeader();
isDocumentActive = true;
documentActive = true;
lines.clear();
}

private void endDocument() throws Exception {
isDocumentActive = false;
documentActive = false;
}

private void printReceiptHeader() throws Exception {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
package com.shtrih.util;

public class ServiceVersion {
public static final String VERSION = "704-4-g8c32f1c0";
public static final String VERSION = "704-5-g552eb5e3";
}
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,6 @@ public void test_print_sale_command() throws Exception
item.setText("Item 1");
PrintSale command = new PrintSale(30, item);
printer.getOperationRegisters().put(new Integer(156), new Integer(1234));
filter.receiptEnabled = true;
assertEquals(0, filter.getLines().size());

filter.init(printer);
Expand Down Expand Up @@ -105,7 +104,6 @@ public void test_print_refund_command() throws Exception
item.setText("Item 1");
PrintRefund command = new PrintRefund(30, item);
printer.getOperationRegisters().put(new Integer(156), new Integer(1234));
filter.receiptEnabled = true;
assertEquals(0, filter.getLines().size());

filter.init(printer);
Expand Down Expand Up @@ -133,7 +131,6 @@ public void test_print_void_sale_command() throws Exception
item.setText("Item 1");
PrintVoidSale command = new PrintVoidSale(30, item);
printer.getOperationRegisters().put(new Integer(156), new Integer(1234));
filter.receiptEnabled = true;
assertEquals(0, filter.getLines().size());

filter.init(printer);
Expand Down Expand Up @@ -161,7 +158,6 @@ public void test_print_void_refund_command() throws Exception
item.setText("Item 1");
PrintVoidRefund command = new PrintVoidRefund(30, item);
printer.getOperationRegisters().put(new Integer(156), new Integer(1234));
filter.receiptEnabled = true;
assertEquals(0, filter.getLines().size());

filter.init(printer);
Expand Down Expand Up @@ -190,7 +186,6 @@ public void test_print_sale_command2() throws Exception
item.setText("Item 1");
PrintSale command = new PrintSale(30, item);
printer.getOperationRegisters().put(new Integer(156), new Integer(1234));
filter.receiptEnabled = true;
assertEquals(0, filter.getLines().size());

filter.init(printer);
Expand All @@ -207,7 +202,6 @@ public void test_print_sale_command2() throws Exception
public void test_void_receipt_command() throws Exception
{
VoidFiscalReceipt command = new VoidFiscalReceipt();
filter.receiptEnabled = true;
assertEquals(0, filter.getLines().size());

filter.init(printer);
Expand Down
13 changes: 0 additions & 13 deletions Source/FiscalPrinterTest/src/PrinterTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -3974,24 +3974,11 @@ public void printFiscalReceipt145_5() {

public void printFiscalReceipt145_7()
{
String QRCodeData = "010464007801637221AgqLybqxM9MbR\u001d91FFD0\u001d92dGVzdL31KAYL0YT6592MjmW7a2HkF3IY+muf2pVSKdQ=";
byte[] data = QRCodeData.getBytes();

try {
printer.resetPrinter();
printer.setFiscalReceiptType(SmFptrConst.SMFPTR_RT_SALE);
printer.beginFiscalReceipt(false);
printer.printRecMessage("printRecMessage 1");
printer.fsWriteTag(1008, "foo@example.com");

TLVWriter tlvWriter = new TLVWriter();
tlvWriter.add(1227, "БЕТА ООО");
tlvWriter.add(1228, "9705069985");
printer.fsWriteTag(1256, tlvWriter.getBytes());

printer.setItemCode(QRCodeData, true);
printer.printRecItem("1. Item1", 124, 123000, 0, 124, "");
printer.addItemCode(data, true);
printer.printRecItem("2. Item2", 124, 123400, 0, 124, "");
printer.printRecTotal(10000, 10000, "");
printer.endFiscalReceipt(false);
Expand Down

0 comments on commit 267c714

Please sign in to comment.