Skip to content

Commit

Permalink
[+] Added method checkItemCode2 to class ShtrihFiscalPrinter113
Browse files Browse the repository at this point in the history
  • Loading branch information
Kravtsov Vitaly committed Jan 26, 2023
1 parent 86cd47a commit cee5215
Show file tree
Hide file tree
Showing 8 changed files with 86 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2479,5 +2479,38 @@ public String[] readCommStatus() throws Exception
public void checkFDOConnection() throws Exception{
directIO(SmFptrConst.SMFPTR_DIO_CHECK_FDO_CONNECTION, null, null);
}

public class CheckItemCodeResponse
{
public int localCheckStatus;
public int localErrorCode;
public int symbolicType;
public int serverErrorCode;
public int serverCheckStatus;
public byte[] serverTLVData;

public CheckItemCodeResponse(){
}
}

public CheckItemCodeResponse checkItemCode2(int itemStatus,
int checkMode, byte[] data, byte[] tlv) throws Exception{

Object[] params = new Object[10];

params[0] = new Integer(itemStatus);
params[1] = new Integer(checkMode);
params[2] = data;
params[3] = tlv;
directIO(SmFptrConst.SMFPTR_DIO_CHECK_ITEM_CODE2, null, params);
CheckItemCodeResponse response = new CheckItemCodeResponse();
response.localCheckStatus = (Integer)params[4];
response.localErrorCode = (Integer)params[5];
response.symbolicType = (Integer)params[6];
response.serverErrorCode = (Integer)params[7];
response.serverCheckStatus = (Integer)params[8];
response.serverTLVData = (byte[])params[9];
return response;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,8 @@ public final String getText() {
public final void encode(CommandOutputStream out) throws Exception {
MethodParameter.checkRange(itemStatus, 0, 0xFF, "itemStatus");
MethodParameter.checkRange(checkMode, 0, 0xFF, "checkMode");
MethodParameter.checkNotNull(mcData, "mcData");
MethodParameter.checkNotNull(tlv, "tlv");

out.writeInt(password);
out.writeByte(itemStatus);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3255,10 +3255,19 @@ public void printDuplicateReceipt() throws Exception {
if (!getCapDuplicateReceipt()) {
throw new JposException(JPOS_E_ILLEGAL, Localizer.getString(Localizer.receiptDuplicationNotSupported));
}
printDocStart();
getPrinter().duplicateReceipt();
receipt.printReceiptEnding();
printEndFiscal();
if (!getDuplicateReceipt()) {
throw new JposException(JPOS_E_ILLEGAL, "THere is no documents to print");
}
if (printer.getParams().duplicateReceiptMethod == SmFptrConst.DUPLICATE_RECEIPT_DEVICE)
{
printDocStart();
getPrinter().duplicateReceipt();
receipt.printReceiptEnding();
printEndFiscal();
} else
{
//textReport. !!!
}
duplicateReceipt = false;
} finally {
printer.getParams().textReportEnabled = filterEnabled;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,7 @@ public class FptrParameters {
public String portNamePrefix = "";
public int portNameTimeout = 3000;
public boolean portNameSingle = true;
public int duplicateReceiptMethod = SmFptrConst.DUPLICATE_RECEIPT_DEVICE;


public FptrParameters() throws Exception {
Expand Down Expand Up @@ -474,6 +475,7 @@ public void load(JposEntry entry) throws Exception {
printItemDiscount = reader.readBoolean("printItemDiscount", false);
fillTextToMinLength = reader.readBoolean("fillTextToMinLength", false);
waitPrintComplete = reader.readBoolean("waitPrintComplete", true);
duplicateReceiptMethod = reader.readInteger("duplicateReceiptMethod", SmFptrConst.DUPLICATE_RECEIPT_DEVICE);

// paymentNames
String paymentName;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,12 @@ public class SmFptrConst {
private SmFptrConst() {
}

///////////////////////////////////////////////////////////////////////////
// Duplicate receipt method

public static final int DUPLICATE_RECEIPT_DEVICE = 0;
public static final int DUPLICATE_RECEIPT_DRIVER = 1;

///////////////////////////////////////////////////////////////////////////
// FDO mode

Expand Down
6 changes: 6 additions & 0 deletions Source/Core/src/com/shtrih/util/MethodParameter.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,12 @@ public final class MethodParameter {
private MethodParameter() {
}

public static void checkNotNull(Object obj, String parameterName) throws Exception {
if (obj == null){
throw new InvalidParameterException(parameterName + " cannot be null");
}
}

public static void checkRange(long parameterValue, long minValue,
long maxValue, String parameterName) throws Exception {
if (parameterValue < minValue) {
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 = "685";
public static final String VERSION = "686";
}
25 changes: 23 additions & 2 deletions Source/FiscalPrinterTest/src/PrinterTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@
import com.shtrih.barcode.PrinterBarcode;
import com.shtrih.jpos.DIOUtils;
import com.shtrih.util.StringUtils;
import com.shtrih.fiscalprinter.ShtrihFiscalPrinter113;
import com.shtrih.fiscalprinter.ShtrihFiscalPrinter113.CheckItemCodeResponse;

class PrinterTest implements FiscalPrinterConst {

Expand Down Expand Up @@ -1071,15 +1073,32 @@ public void printFiscalReceipt() {

//printFiscalReceiptDate();
//testRefundReceipt();
//printFiscalReceipt145_4();

printer.checkFDOConnection();
checkItemCode2();



} catch (Exception e) {
e.printStackTrace();
}
}

public void testRefundReceipt() {
public void checkItemCode2() throws Exception
{
System.out.println("checkItemCode2");
String barcode = "010464007801637221AgqLybqxM9MbR\u001d91FFD0\u001d92dGVzdL31KAYL0YT6592MjmW7a2HkF3IY+muf2pVSKdQ=";
byte[] tlv = new byte[0];
CheckItemCodeResponse response = printer.checkItemCode2(1, 0, barcode.getBytes(), tlv);
System.out.println("response.localCheckStatus: " + response.localCheckStatus);
System.out.println("response.symbolicType: " + response.symbolicType);
System.out.println("response.serverErrorCode: " + response.serverErrorCode);
System.out.println("response.serverCheckStatus: " + response.serverCheckStatus);
System.out.println("response.serverTLVData: " + response.serverTLVData);
System.out.println("checkItemCode2: OK");
}

public void testRefundReceipt() {
try {
printer.resetPrinter();
printer.setFiscalReceiptType(FPTR_RT_REFUND);
Expand Down Expand Up @@ -3867,6 +3886,8 @@ public void printFiscalReceipt145_4() {
byte[] data = QRCodeData.getBytes();
System.out.println("Barcode: " + Hex.toHex(data));

CheckItemCodeResponse response = printer.checkItemCode2(1, 0, data, null);

printer.addItemCode(data);
printer.printRecItem("1. СДОБА ЗАМОСКВОРЕЦКАЯ", 3200, 1000, 2, 3200, "шт");
printer.printRecItemAdjustment(1, " 1206", 320, 2);
Expand Down

0 comments on commit cee5215

Please sign in to comment.