Skip to content

Commit

Permalink
[+] Добавлена проверка кода маркировки
Browse files Browse the repository at this point in the history
  • Loading branch information
VitalyKravtsov2016 committed Sep 30, 2024
1 parent 1279e8a commit 9f17edf
Show file tree
Hide file tree
Showing 23 changed files with 213 additions and 235 deletions.
7 changes: 7 additions & 0 deletions History.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,13 @@

Проект : WebPrinter OPOS драйвер

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

OposShtrih_1.13.57.exe
30 сентября 2024 12:45

[+] Добавлена проверка кода маркировки

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

OposShtrih_1.13.56.exe
Expand Down
2 changes: 1 addition & 1 deletion release.ini
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
[releases]
current=1.13.0.056
current=1.13.0.057
last_date=2024-09-09
2 changes: 1 addition & 1 deletion source/Shared/ServiceVersion.pas
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ interface
DeviceService;

const
GenericServiceVersion = deviceVersion113 + 56;
GenericServiceVersion = deviceVersion113 + 57;

implementation

Expand Down
138 changes: 13 additions & 125 deletions source/WebFptr.dsk
Original file line number Diff line number Diff line change
@@ -1,42 +1,20 @@
[Closed Files]
File_0=SourceModule,'D:\Projects\WebPrinter\source\Opos\OposFptrUtils.pas',0,1,39,41,51,0,0
File_1=SourceModule,'D:\Projects\WebPrinter\test\AcceptanceTest\units\duCalculator.pas',0,1,25,77,33,0,0
File_2=SourceModule,'D:\Projects\WebPrinter\test\AcceptanceTest\units\duWebPrinter.pas',0,1,1,1,1,0,0
File_3=SourceModule,'D:\Projects\WebPrinter\test\AcceptanceTest\units\duLogParser.pas',0,1,159,56,186,0,0
File_4=SourceModule,'D:\Projects\WebPrinter\source\Shared\JsonUtils.pas',0,1,681,103,689,0,0
File_5=SourceModule,'D:\Projects\WebPrinter\source\Shared\PrinterParameters.pas',0,1,244,30,254,0,0
File_6=SourceModule,'D:\Projects\WebPrinter\source\Shared\StringUtils.pas',0,1,348,10,350,0,0
File_7=SourceModule,'D:\projects\WebPrinter\source\WebFptrSo\units\ReceiptItem.pas',0,1,362,26,369,0,0
File_0=SourceModule,'D:\Projects\WebPrinter\test\AcceptanceTest\units\duWebPrinter.pas',0,1,366,2,379,0,0
File_1=SourceModule,'D:\Projects\WebPrinter\test\WebFptrSoTest\units\duWebPrinterImpl.pas',0,1,15,5,25,0,0
File_2=SourceModule,'D:\Projects\WebPrinter\test\AcceptanceTest\units\duLogParser.pas',0,1,156,1,167,0,0
File_3=SourceModule,'D:\Projects\WebPrinter\source\WebFptrSo\units\WebPrinterImpl.pas',0,1,2643,101,2658,0,0
File_4=SourceModule,'D:\Projects\WebPrinter\test\WebFptrSoTest\units\duWebPrinter.pas',0,1,1,1,1,0,0
File_5=SourceModule,'D:\Projects\WebPrinter\source\WebFptrSo\Units\WebPrinter.pas',0,1,884,20,903,0,0
File_6=SourceModule,'D:\Projects\WebPrinter\source\Opos\OposFptrUtils.pas',0,1,39,41,51,0,0
File_7=SourceModule,'D:\Projects\WebPrinter\test\AcceptanceTest\units\duCalculator.pas',0,1,25,77,33,0,0
File_8=SourceModule,'D:\Projects\WebPrinter\source\Shared\JsonUtils.pas',0,1,681,103,689,0,0
File_9=SourceModule,'D:\Projects\WebPrinter\source\Shared\PrinterParameters.pas',0,1,244,30,254,0,0

[Modules]
Module0=D:\Projects\WebPrinter\test\WebFptrSoTest\units\duWebPrinterImpl.pas
Module1=D:\Projects\WebPrinter\source\WebFptrSo\units\WebPrinterImpl.pas
Module2=D:\Projects\WebPrinter\test\WebFptrSoTest\units\duWebPrinter.pas
Module3=D:\Projects\WebPrinter\source\WebFptrSo\Units\WebPrinter.pas
Count=4
EditWindowCount=1
Count=0
EditWindowCount=0
TypeLibWindowCount=1

[D:\Projects\WebPrinter\test\WebFptrSoTest\units\duWebPrinterImpl.pas]
ModuleType=SourceModule
FormState=0
FormOnTop=0

[D:\Projects\WebPrinter\source\WebFptrSo\units\WebPrinterImpl.pas]
ModuleType=SourceModule
FormState=0
FormOnTop=0

[D:\Projects\WebPrinter\test\WebFptrSoTest\units\duWebPrinter.pas]
ModuleType=SourceModule
FormState=0
FormOnTop=0

[D:\Projects\WebPrinter\source\WebFptrSo\Units\WebPrinter.pas]
ModuleType=SourceModule
FormState=0
FormOnTop=0

[D:\Projects\WebPrinter\source\WebFptr.bpg]
FormState=0
FormOnTop=0
Expand Down Expand Up @@ -69,64 +47,6 @@ FormOnTop=0
FormState=0
FormOnTop=0

[EditWindow0]
ViewCount=4
CurrentView=0
View0=0
View1=1
View2=2
View3=3
CodeExplorer=CodeExplorer@EditWindow0
MessageView=MessageView@EditWindow0
Create=1
Visible=1
State=2
Left=366
Top=140
Width=1302
Height=682
MaxLeft=-8
MaxTop=107
MaxWidth=1936
MaxHeight=941
ClientWidth=1920
ClientHeight=902
LeftPanelSize=0
LeftPanelClients=CodeExplorer@EditWindow0
LeftPanelData=00000400010000000C000000436F64654578706C6F7265720000000000000000000000000000000000FFFFFFFF
RightPanelSize=0
BottomPanelSize=292
BottomPanelClients=MessageView@EditWindow0
BottomPanelData=000004000000000000000000000000000000000000000000000100000000000000000B0000004D65737361676556696577FFFFFFFF

[View0]
Module=D:\Projects\WebPrinter\test\WebFptrSoTest\units\duWebPrinterImpl.pas
CursorX=19
CursorY=1207
TopLine=1202
LeftCol=1

[View1]
Module=D:\Projects\WebPrinter\source\WebFptrSo\units\WebPrinterImpl.pas
CursorX=101
CursorY=2658
TopLine=2643
LeftCol=1

[View2]
Module=D:\Projects\WebPrinter\test\WebFptrSoTest\units\duWebPrinter.pas
CursorX=1
CursorY=1
TopLine=1
LeftCol=1

[View3]
Module=D:\Projects\WebPrinter\source\WebFptrSo\Units\WebPrinter.pas
CursorX=20
CursorY=903
TopLine=884
LeftCol=1

[TypeLibEditWindow0]
Create=1
Visible=0
Expand Down Expand Up @@ -432,45 +352,13 @@ TBDockHeight=151
LRDockWidth=383
Dockable=1

[CodeExplorer@EditWindow0]
Create=1
Visible=0
State=0
Left=-170
Top=-9
Width=140
Height=305
MaxLeft=-1
MaxTop=-1
ClientWidth=140
ClientHeight=305
TBDockHeight=305
LRDockWidth=140
Dockable=1

[MessageView@EditWindow0]
Create=1
Visible=1
State=0
Left=12
Top=0
Width=1908
Height=292
MaxLeft=-1
MaxTop=-1
ClientWidth=1908
ClientHeight=292
TBDockHeight=292
LRDockWidth=443
Dockable=1

[DockHosts]
DockHostCount=1

[DockSite0]
DockSiteType=0
Create=1
Visible=1
Visible=0
State=0
Left=860
Top=192
Expand Down
4 changes: 2 additions & 2 deletions source/WebFptrCfg/WebFptrCfg.dof
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ AutoIncBuild=1
MajorVer=1
MinorVer=13
Release=0
Build=53
Build=56
Debug=0
PreRelease=0
Special=0
Expand All @@ -126,7 +126,7 @@ CodePage=1252
[Version Info Keys]
CompanyName=SHTRIH-M
FileDescription=WebPrinter OPOS setup utility
FileVersion=1.13.0.53
FileVersion=1.13.0.56
InternalName=WebPrinter OPOS setup
LegalCopyright=SHTRIH-M © 2024
LegalTrademarks=
Expand Down
6 changes: 3 additions & 3 deletions source/WebFptrCfg/WebFptrCfg.rc
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
VS_VERSION_INFO VERSIONINFO
FILEVERSION 1,13,0,56
PRODUCTVERSION 1,13,0,56
FILEVERSION 1,13,0,57
PRODUCTVERSION 1,13,0,57
FILEFLAGSMASK 0x3fL
FILEFLAGS 0x0L
FILEOS 0x4L
Expand All @@ -13,7 +13,7 @@ BEGIN
BEGIN
VALUE "CompanyName", "SHTRIH-M\0"
VALUE "FileDescription", "WebPrinter OPOS setup utility\0"
VALUE "FileVersion", "1.13.0.56\0"
VALUE "FileVersion", "1.13.0.57\0"
VALUE "InternalName", "WebPrinter OPOS setup \0"
VALUE "LegalCopyright", "SHTRIH-M \251 2024 \0"
VALUE "OriginalFilename", "WebFptrCfg.exe\0"
Expand Down
Binary file modified source/WebFptrCfg/WebFptrCfg.res
Binary file not shown.
2 changes: 1 addition & 1 deletion source/WebFptrSo/WebFptrSO_TLB.pas

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions source/WebFptrSo/WebFptrSo.dof
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ AutoIncBuild=1
MajorVer=1
MinorVer=13
Release=0
Build=64
Build=68
Debug=0
PreRelease=0
Special=0
Expand All @@ -133,7 +133,7 @@ CodePage=1252
[Version Info Keys]
CompanyName=SHTRIH-M
FileDescription=WebPrinter OPOS fiscal printer service
FileVersion=1.13.0.64
FileVersion=1.13.0.68
InternalName=WebPrinter OPOS fiscal printer driver
LegalCopyright=SHTRIH-M © 2024
LegalTrademarks=
Expand Down
3 changes: 2 additions & 1 deletion source/WebFptrSo/WebFptrSo.dpr
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,8 @@ uses
WebPrinter in 'units\WebPrinter.pas',
VatRate in '..\Shared\VatRate.pas',
uLkJSON in '..\Shared\uLkJSON.pas',
TLVItem in 'units\TLVItem.pas';
TLVItem in 'units\TLVItem.pas',
MarkCode in 'units\MarkCode.pas';

exports
DllGetClassObject,
Expand Down
6 changes: 3 additions & 3 deletions source/WebFptrSo/WebFptrSo.rc
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
VS_VERSION_INFO VERSIONINFO
FILEVERSION 1,13,0,56
PRODUCTVERSION 1,13,0,56
FILEVERSION 1,13,0,57
PRODUCTVERSION 1,13,0,57
FILEFLAGSMASK 0x3fL
FILEFLAGS 0x0L
FILEOS 0x4L
Expand All @@ -13,7 +13,7 @@ BEGIN
BEGIN
VALUE "CompanyName", "SHTRIH-M\0"
VALUE "FileDescription", "WebPrinter OPOS fiscal printer service\0"
VALUE "FileVersion", "1.13.0.56\0"
VALUE "FileVersion", "1.13.0.57\0"
VALUE "InternalName", "WebPrinter OPOS fiscal printer driver\0"
VALUE "LegalCopyright", "SHTRIH-M \251 2024 \0"
VALUE "OriginalFilename", "WebFptrSo.dll\0"
Expand Down
Binary file modified source/WebFptrSo/WebFptrSo.res
Binary file not shown.
77 changes: 77 additions & 0 deletions source/WebFptrSo/units/MarkCode.pas
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
unit MarkCode;

interface

uses
// VCL
SysUtils,
// Opos
OposException,
// This
RegExpr;

procedure CheckMarkCode(const MarkCode: AnsiString);
function ValidMarkCode(const MarkCode: AnsiString): Boolean;
function GetMarkCode(const MarkCode: AnsiString): AnsiString;

implementation

function FindRegExpr(const ARegExpr, AInputStr: AnsiString;
var S: AnsiString): Boolean;
var
R: TRegExpr;
begin
S := AInputStr;
R := TRegExpr.Create;
try
R.Expression := ARegExpr;
Result := R.Exec (AInputStr);
if Result then
S := Copy(AInputStr, 1, R.MatchLen[0]);
finally
R.Free;
end;
end;

function ValidMarkCode(const MarkCode: AnsiString): Boolean;
var
L: Integer;
S1, S2: AnsiString;
begin
S1 := StringReplace(MarkCode, #$1D, '', [rfReplaceAll, rfIgnoreCase]);
Result := FindRegExpr('^01[0-9]{14}', S1, S2);
if not Result then
begin
L := Length(S1);
if L > 14 then L := 14;
Result := FindRegExpr(Format('^[0-9]{%d}', [L]), S1, S2);
end;
end;

procedure CheckMarkCode(const MarkCode: AnsiString);
begin
if not ValidMarkCode(MarkCode) then
raiseIllegalError('Invalid markcode, ' + MarkCode);
end;

function GetMarkCode(const MarkCode: AnsiString): AnsiString;
var
S: AnsiString;
begin
Result := StringReplace(MarkCode, #$1D, '', [rfReplaceAll, rfIgnoreCase]);
if FindRegExpr('^01[0-9]{14}', Result, S) then
begin
if FindRegExpr('^01[0-9]{14}21.{7,20}93', Result, S) or
FindRegExpr('^01[0-9]{14}21.{7,20}91', Result, S) then
begin
Result := Copy(S, 1, Length(S)-2);
end;
end else
begin
Result := Copy(Result, 1, 21);
if Length(Result) < 14 then
Result := StringOfChar('0', 14-Length(Result)) + Result;
end;
end;

end.
3 changes: 2 additions & 1 deletion source/WebFptrSo/units/SalesReceipt.pas
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ interface
TntClasses,
// This
CustomReceipt, ReceiptItem, gnugettext, WException, MathUtils,
TextDocument, PrinterTypes;
TextDocument, PrinterTypes, MarkCode;

const
MaxPayments = 4;
Expand Down Expand Up @@ -678,6 +678,7 @@ procedure TSalesReceipt.PrintRecMessage(const Message: WideString);

procedure TSalesReceipt.AddMarkCode(const MarkCode: string);
begin
CheckMarkCode(MarkCode);
FMarkCodes.Add(MarkCode);
end;

Expand Down
Loading

0 comments on commit 9f17edf

Please sign in to comment.