Closed fridrichovsky closed 2 years ago
Hi @fridrichovsky. The OptionA changes the semantic of OnBeforeVIESDeclarationLineInsert event and OptionB implements handle pattern inside the function which is not the best solution. Here is the my optionC.
procedure CopyLineToDeclaration()
begin
CurrPage.SetSelectionFilter(FirstVIESDeclarationLineCZL);
if FirstVIESDeclarationLineCZL.FindSet() then
repeat
CreateLine(FirstVIESDeclarationLineCZL."Line Type"::Cancellation);
CreateLine(FirstVIESDeclarationLineCZL."Line Type"::Correction);
until FirstVIESDeclarationLineCZL.Next() = 0;
end;
local procedure CreateLine(LineType: Option)
var
SecondVIESDeclarationLineCZL: Record "VIES Declaration Line CZL";
IsHandled: Boolean;
begin
OnBeforeCreateLine(FirstVIESDeclarationLineCZL, LineType, LastLineNo, IsHandled);
if IsHandled then
exit;
LastLineNo += 10000;
SecondVIESDeclarationLineCZL.Init();
SecondVIESDeclarationLineCZL."VIES Declaration No." := VIESDeclarationHeaderCZL."No.";
SecondVIESDeclarationLineCZL."Line No." := LastLineNo;
SecondVIESDeclarationLineCZL."Trade Type" := FirstVIESDeclarationLineCZL."Trade Type";
SecondVIESDeclarationLineCZL."Line Type" := LineType;
SecondVIESDeclarationLineCZL."Related Line No." := FirstVIESDeclarationLineCZL."Line No.";
SecondVIESDeclarationLineCZL."Country/Region Code" := FirstVIESDeclarationLineCZL."Country/Region Code";
SecondVIESDeclarationLineCZL."VAT Registration No." := FirstVIESDeclarationLineCZL."VAT Registration No.";
SecondVIESDeclarationLineCZL."Amount (LCY)" := FirstVIESDeclarationLineCZL."Amount (LCY)";
SecondVIESDeclarationLineCZL."EU 3-Party Trade" := FirstVIESDeclarationLineCZL."EU 3-Party Trade";
SecondVIESDeclarationLineCZL."EU Service" := FirstVIESDeclarationLineCZL."EU Service";
SecondVIESDeclarationLineCZL."EU 3-Party Intermediate Role" := FirstVIESDeclarationLineCZL."EU 3-Party Intermediate Role";
SecondVIESDeclarationLineCZL."Trade Role Type" := FirstVIESDeclarationLineCZL."Trade Role Type";
SecondVIESDeclarationLineCZL."Number of Supplies" := FirstVIESDeclarationLineCZL."Number of Supplies";
SecondVIESDeclarationLineCZL."System-Created" :=
SecondVIESDeclarationLineCZL."Line Type" = SecondVIESDeclarationLineCZL."Line Type"::Cancellation;
#if not CLEAN21
#pragma warning disable AL0432
if SecondVIESDeclarationLineCZL."Line Type" = SecondVIESDeclarationLineCZL."Line Type"::Correction then
OnBeforeVIESDeclarationLineInsert(FirstVIESDeclarationLineCZL, SecondVIESDeclarationLineCZL);
#pragma warning restore AL0432
#endif
OnBeforeInsertVIESDeclarationLine(FirstVIESDeclarationLineCZL, SecondVIESDeclarationLineCZL);
SecondVIESDeclarationLineCZL.Insert();
#if not CLEAN21
#pragma warning disable AL0432
if SecondVIESDeclarationLineCZL."Line Type" = SecondVIESDeclarationLineCZL."Line Type"::Correction then
OnAfterVIESDeclarationLineInsert(SecondVIESDeclarationLineCZL, LastLineNo);
#pragma warning restore AL0432
#endif
OnAfterCreateLine(SecondVIESDeclarationLineCZL, LastLineNo);
end;
[IntegrationEvent(false, false)]
local procedure OnBeforeCreateLine(FromVIESDeclarationLineCZL: Record "VIES Declaration Line CZL"; LineType: Option; var LastLineNo: Integer; var IsHandled: Boolean)
begin
end;
[IntegrationEvent(false, false)]
local procedure OnBeforeInsertVIESDeclarationLine(FromVIESDeclarationLineCZL: Record "VIES Declaration Line CZL"; var VIESDeclarationLineCZL: Record "VIES Declaration Line CZL")
begin
end;
[IntegrationEvent(false, false)]
local procedure OnAfterCreateLine(VIESDeclarationLineCZL: Record "VIES Declaration Line CZL"; var LastLineNo: Integer)
begin
end;
#if not CLEAN21
[Obsolete('Replaced by OnBeforeInsertVIESDeclarationLine function.', '21.0')]
[IntegrationEvent(false, false)]
local procedure OnBeforeVIESDeclarationLineInsert(FirstVIESDeclarationLineCZL: Record "VIES Declaration Line CZL"; var SecondVIESDeclarationLineCZL: Record "VIES Declaration Line CZL")
begin
end;
[Obsolete('Replaced by OnAfterCreateLine function.', '21.0')]
[IntegrationEvent(false, false)]
local procedure OnAfterVIESDeclarationLineInsert(SecondVIESDeclarationLineCZL: Record "VIES Declaration Line CZL"; var LastLineNo: Integer)
begin
end;
#endif
is it ok for you?
Thanks for reporting this. We agree, and we’ll publish a fix asap, either in an update for the current version or in the next major release. Please do not reply to this, as we do not monitor closed issues. If you have follow-up questions or requests, please create a new issue where you reference this one.
Build ID: 42968.
Yes it can be done by your Option C.
Please do change in events. If is it possible do it by option A it will be great. Bellow is option B also.
OptionA
OptionB