Skip to content

Commit

Permalink
Added FS fiscalization commands to ShtrihFiscalPrinter
Browse files Browse the repository at this point in the history
  • Loading branch information
nyxiscoo1 committed Mar 15, 2017
1 parent 8af6e39 commit 75df868
Show file tree
Hide file tree
Showing 7 changed files with 130 additions and 139 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
@@ -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 *
*/
Expand Down Expand Up @@ -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);
}

Expand All @@ -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);
}
Expand All @@ -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);
}
Expand Down Expand Up @@ -1667,7 +1653,7 @@ public void disablePrint() throws JposException {
}

/**
Печать СКЛ за текущую смену
* Печать СКЛ за текущую смену
*/
public void printJournalCurrentDay() throws JposException {
int[] params = new int[1];
Expand All @@ -1676,7 +1662,7 @@ public void printJournalCurrentDay() throws JposException {
}

/**
Печать СКЛ за указанную смену
* Печать СКЛ за указанную смену
*/
public void printJournalDayNumber(int dayNumber) throws JposException {
int[] params = new int[2];
Expand All @@ -1686,7 +1672,7 @@ public void printJournalDayNumber(int dayNumber) throws JposException {
}

/**
Печать документа из СКЛ с указанным номером
* Печать документа из СКЛ с указанным номером
*/
public void printJournalDocNumber(int docNumber) throws JposException {
int[] params = new int[2];
Expand All @@ -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];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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 {
Expand Down
Original file line number Diff line number Diff line change
@@ -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;
}
}

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
Original file line number Diff line number Diff line change
@@ -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);
}
}

0 comments on commit 75df868

Please sign in to comment.