-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[+] Добавлена проверка кода маркировки
- Loading branch information
1 parent
1279e8a
commit 9f17edf
Showing
23 changed files
with
213 additions
and
235 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.