diff --git a/Source/Core/src/com/shtrih/fiscalprinter/SMFiscalPrinterImpl.java b/Source/Core/src/com/shtrih/fiscalprinter/SMFiscalPrinterImpl.java index f00361db..b2f41b6d 100644 --- a/Source/Core/src/com/shtrih/fiscalprinter/SMFiscalPrinterImpl.java +++ b/Source/Core/src/com/shtrih/fiscalprinter/SMFiscalPrinterImpl.java @@ -2756,12 +2756,6 @@ public FSReadVersion fsReadVersion() throws Exception { return command; } - public FSStartFiscalization fsStartFiscalization(int reportType) throws Exception { - FSStartFiscalization command = new FSStartFiscalization(sysPassword, reportType); - execute(command); - return command; - } - public FSResetState fsResetState(int code) throws Exception { FSResetState command = new FSResetState(); command.setSysPassword(sysPassword); diff --git a/Source/Core/src/com/shtrih/fiscalprinter/ShtrihFiscalPrinter113.java b/Source/Core/src/com/shtrih/fiscalprinter/ShtrihFiscalPrinter113.java index b05e48b6..31812480 100644 --- a/Source/Core/src/com/shtrih/fiscalprinter/ShtrihFiscalPrinter113.java +++ b/Source/Core/src/com/shtrih/fiscalprinter/ShtrihFiscalPrinter113.java @@ -1,35 +1,14 @@ package com.shtrih.fiscalprinter; -/* - * ShtrihFiscalPrinter.java - * - * Created on 23 Ноябрь 2009 г., 22:32 - * - * To change this template, choose Tools | Template Manager - * and open the template in the editor. - */ -/** - * @author V.Kravtsov - */ - import com.shtrih.barcode.PrinterBarcode; - -import jpos.BaseControl; -import jpos.FiscalPrinter; -import jpos.FiscalPrinterConst; -import jpos.FiscalPrinterControl113; -import jpos.JposConst; -import jpos.JposException; +import com.shtrih.fiscalprinter.command.*; +import com.shtrih.jpos.fiscalprinter.SmFptrConst; +import jpos.*; import jpos.events.DirectIOListener; import jpos.events.ErrorListener; import jpos.events.OutputCompleteListener; import jpos.events.StatusUpdateListener; -import com.shtrih.fiscalprinter.command.*; -import com.shtrih.jpos.fiscalprinter.SmFptrConst; - -import static jpos.FiscalPrinterConst.FPTR_PS_FISCAL_RECEIPT; - /** * Wrapper class to help using directIO codes * */ @@ -1536,7 +1515,18 @@ public void fsReadVersion(FSReadVersion command) throws JposException { executeCommand(command); } - public void fsFiscalization(FSFiscalization command) throws JposException { + public void fsStartFiscalization(int reportType) throws Exception { + FSStartFiscalization command = new FSStartFiscalization(getSysPassword(), reportType); + executeCommand(command); + } + + public void fsFiscalization(String inn, String rnm, int taxSystemCode, int operationMode) throws JposException { + FSFiscalization command = new FSFiscalization(getSysPassword(), inn, rnm, taxSystemCode, operationMode); + executeCommand(command); + } + + public void fsReFiscalization(String inn, String rnm, int taxSystemCode, int operationMode, int reasonCode) throws JposException { + FSReFiscalization command = new FSReFiscalization(getSysPassword(), inn, rnm, taxSystemCode, operationMode, reasonCode); executeCommand(command); } @@ -1560,10 +1550,6 @@ public void fsOpenDay(FSOpenDay command) throws JposException { executeCommand(command); } - public void fsRegistrationReport(FSRegistrationReport command) throws JposException { - executeCommand(command); - } - public void fsStartCorrectionReceipt(FSStartCorrectionReceipt command) throws JposException { executeCommand(command); } @@ -1575,7 +1561,7 @@ public void fsPrintCorrectionReceipt(FSPrintCorrectionReceipt command) throws Jp public void fsPrintCorrectionReceipt2(FSPrintCorrectionReceipt2 command) throws JposException { executeCommand(command); } - + public void fsStartCalcReport(FSStartCalcReport command) throws JposException { executeCommand(command); } @@ -1667,7 +1653,7 @@ public void disablePrint() throws JposException { } /** - Печать СКЛ за текущую смену + * Печать СКЛ за текущую смену */ public void printJournalCurrentDay() throws JposException { int[] params = new int[1]; @@ -1676,7 +1662,7 @@ public void printJournalCurrentDay() throws JposException { } /** - Печать СКЛ за указанную смену + * Печать СКЛ за указанную смену */ public void printJournalDayNumber(int dayNumber) throws JposException { int[] params = new int[2]; @@ -1686,7 +1672,7 @@ public void printJournalDayNumber(int dayNumber) throws JposException { } /** - Печать документа из СКЛ с указанным номером + * Печать документа из СКЛ с указанным номером */ public void printJournalDocNumber(int docNumber) throws JposException { int[] params = new int[2]; @@ -1696,7 +1682,7 @@ public void printJournalDocNumber(int docNumber) throws JposException { } /** - Печать документа из СКЛ с указанным номером + * Печать документа из СКЛ с указанным номером */ public void printJournalDocRange(int docNumber1, int docNumber2) throws JposException { int[] params = new int[3]; diff --git a/Source/Core/src/com/shtrih/fiscalprinter/command/FSFiscalization.java b/Source/Core/src/com/shtrih/fiscalprinter/command/FSFiscalization.java index 81290b61..dcb3f1dc 100644 --- a/Source/Core/src/com/shtrih/fiscalprinter/command/FSFiscalization.java +++ b/Source/Core/src/com/shtrih/fiscalprinter/command/FSFiscalization.java @@ -16,7 +16,7 @@ public class FSFiscalization extends PrinterCommand { // in - private final int sysPassword; // System sdministrator password (4 bytes) + private final int sysPassword; // System administrator password (4 bytes) private final String taxID; private final String regID; @@ -39,7 +39,7 @@ public final int getCode() { } public final String getText() { - return "Fiscal storage: start fiscalization"; + return "Fiscal storage: fiscalization"; } public void encode(CommandOutputStream out) throws Exception { diff --git a/Source/Core/src/com/shtrih/fiscalprinter/command/FSReFiscalization.java b/Source/Core/src/com/shtrih/fiscalprinter/command/FSReFiscalization.java new file mode 100644 index 00000000..c99368f2 --- /dev/null +++ b/Source/Core/src/com/shtrih/fiscalprinter/command/FSReFiscalization.java @@ -0,0 +1,60 @@ +/* + * To change this license header, choose License Headers in Project Properties. + * To change this template file, choose Tools | Templates + * and open the template in the editor. + */ +package com.shtrih.fiscalprinter.command; + +public class FSReFiscalization extends PrinterCommand { + + // in + private final int sysPassword; // System administrator password (4 bytes) + + private final String taxID; + private final String regID; + private final int taxSystemCode; + private final int operationMode; + private final int reasonCode; + // out + private long docNumber; + private long macNumber; + + public FSReFiscalization(int sysPassword, String taxID, String regID, int taxSystemCode, int operationMode, int reasonCode) { + this.sysPassword = sysPassword; + this.taxID = taxID; + this.regID = regID; + this.taxSystemCode = taxSystemCode; + this.operationMode = operationMode; + this.reasonCode = reasonCode; + } + + public final int getCode() { + return 0xFF34; + } + + public final String getText() { + return "Fiscal storage: refiscalization"; + } + + public void encode(CommandOutputStream out) throws Exception { + out.writeInt(sysPassword); + out.writeString(taxID, 12); + out.writeString(regID, 20); + out.writeByte(taxSystemCode); + out.writeByte(operationMode); + out.writeByte(reasonCode); + } + + public void decode(CommandInputStream in) throws Exception { + docNumber = in.readLong(4); + macNumber = in.readLong(4); + } + + public long getDocNumber() { + return docNumber; + } + + public long getMacNumber() { + return macNumber; + } +} diff --git a/Source/Core/src/com/shtrih/fiscalprinter/command/FSRegistrationReport.java b/Source/Core/src/com/shtrih/fiscalprinter/command/FSRegistrationReport.java deleted file mode 100644 index da3b869e..00000000 --- a/Source/Core/src/com/shtrih/fiscalprinter/command/FSRegistrationReport.java +++ /dev/null @@ -1,97 +0,0 @@ -/* - * To change this license header, choose License Headers in Project Properties. - * To change this template file, choose Tools | Templates - * and open the template in the editor. - */ -package com.shtrih.fiscalprinter.command; - -import com.shtrih.ej.EJDate; -import com.shtrih.util.BitUtils; - -/** - * - * @author V.Kravtsov - */ -/** - -*/ - -public class FSRegistrationReport extends PrinterCommand { - - // in - private int sysPassword = 0; // System sdministrator password (4 bytes) - private int code = 0; // Code: 1 byte - // out - private int docNumber = 0; // Document number: 4 bytes - private int docDigest = 0; // Document digest: 4 bytes - - public FSRegistrationReport() { - } - - public final int getCode() { - return 0xFF34; - } - - public final String getText() { - return "Fiscal storage: reset state"; - } - - public void encode(CommandOutputStream out) throws Exception { - out.writeInt(sysPassword); - out.writeByte(code); - } - - public void decode(CommandInputStream in) throws Exception { - docNumber = in.readInt(); - docDigest = in.readInt(); - } - - /** - * @return the sysPassword - */ - public int getSysPassword() { - return sysPassword; - } - - /** - * @param sysPassword the sysPassword to set - */ - public void setSysPassword(int sysPassword) { - this.sysPassword = sysPassword; - } - - /** - * @param code the code to set - */ - public void setCode(int code) { - this.code = code; - } - - /** - * @return the docNumber - */ - public int getDocNumber() { - return docNumber; - } - - /** - * @param docNumber the docNumber to set - */ - public void setDocNumber(int docNumber) { - this.docNumber = docNumber; - } - - /** - * @return the docDigest - */ - public int getDocDigest() { - return docDigest; - } - - /** - * @param docDigest the docDigest to set - */ - public void setDocDigest(int docDigest) { - this.docDigest = docDigest; - } -} diff --git a/Source/FiscalPrinterService/test/com/shtrih/fiscalprinter/command/FSFiscalizationTests.java b/Source/FiscalPrinterService/test/com/shtrih/fiscalprinter/command/FSFiscalizationTests.java index 3b2b2b9a..54ecf8a4 100644 --- a/Source/FiscalPrinterService/test/com/shtrih/fiscalprinter/command/FSFiscalizationTests.java +++ b/Source/FiscalPrinterService/test/com/shtrih/fiscalprinter/command/FSFiscalizationTests.java @@ -26,4 +26,22 @@ public void should_serialize() throws Exception { assertArrayEquals(expectedData, data); } + + @Test + public void should_serialize_not_full_numbers() throws Exception { + FSFiscalization cmd = new FSFiscalization( + 30, "7701234567", "0000000221017090", 17, 24); + + byte[] data = cmd.encodeData(); + + byte[] expectedData = byteArray( + 0xFF, 0x06, + 0x1E, 0x00, 0x00, 0x00, + 0x37, 0x37, 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x00, 0x00, + 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x32, 0x32, 0x31, 0x30, 0x31, 0x37, 0x30, 0x39, 0x30, 0x00, 0x00, 0x00, 0x00, + 0x11, + 0x18); + + assertArrayEquals(expectedData, data); + } } diff --git a/Source/FiscalPrinterService/test/com/shtrih/fiscalprinter/command/FSReFiscalizationTests.java b/Source/FiscalPrinterService/test/com/shtrih/fiscalprinter/command/FSReFiscalizationTests.java new file mode 100644 index 00000000..421fb45f --- /dev/null +++ b/Source/FiscalPrinterService/test/com/shtrih/fiscalprinter/command/FSReFiscalizationTests.java @@ -0,0 +1,30 @@ +package com.shtrih.fiscalprinter.command; + +import org.junit.Test; + +import static com.shtrih.util.ByteUtils.byteArray; +import static org.junit.Assert.assertArrayEquals; + +/** + * @author P.Zhirkov + */ +public class FSReFiscalizationTests { + @Test + public void should_serialize() throws Exception { + FSReFiscalization cmd = new FSReFiscalization( + 30, "7701234567", "0000000221017090", 17, 24, 4); + + byte[] data = cmd.encodeData(); + + byte[] expectedData = byteArray( + 0xFF, 0x34, + 0x1E, 0x00, 0x00, 0x00, + 0x37, 0x37, 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x00, 0x00, + 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x32, 0x32, 0x31, 0x30, 0x31, 0x37, 0x30, 0x39, 0x30, 0x00, 0x00, 0x00, 0x00, + 0x11, + 0x18, + 0x04); + + assertArrayEquals(expectedData, data); + } +}