Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Event Request] Table 81 "Gen. Journal Line" - OnBeforeValidateAppliestoDocType, OnBeforeValidateAppliestoDocNo, OnAfterValidateAppliestoDocNo #27709

Open
skuchana93 opened this issue Nov 27, 2024 · 0 comments

Comments

@skuchana93
Copy link

Describe the request

In Table 81, please include the OnBeforeValidateAppliestoDocType event within the OnValidate trigger of the "Applies-to Doc. Type" field and OnBeforeValidateAppliestoDocNo, OnAfterValidateAppliestoDocNo event within the OnValidate trigger of the "Applies-to Doc. No." field.

Actual Code of OnValidate of "Applies-to Doc. Type"
trigger OnValidate()
begin
if "Applies-to Doc. Type" <> xRec."Applies-to Doc. Type" then
Validate("Applies-to Doc. No.", '');
end;

Required Code with a new event request for OnValidate of "Applies-to Doc. Type"
trigger OnValidate()
var
IsHandled: Boolean;

begin
IsHandled := false;
OnBeforeValidateAppliestoDocType(Rec, xRec, CurrFieldNo, IsHandled);
if IsHandled then
exit;

if "Applies-to Doc. Type" <> xRec."Applies-to Doc. Type" then
Validate("Applies-to Doc. No.", '');
end;

[IntegrationEvent(false, false)]
local procedure OnBeforeValidateAppliestoDocType(var GenJnlLine: Record "Gen. Journal Line"; xGenJnlLine: Record "Gen. Journal Line"; CurrentFieldNo: Integer; var IsHandled: Boolean)
begin
end;

Actual Code of OnValidate of "Applies-to Doc. No."
trigger OnValidate()
var
CustLedgEntry: Record "Cust. Ledger Entry";
VendLedgEntry: Record "Vendor Ledger Entry";
TempGenJnlLine: Record "Gen. Journal Line" temporary;
begin
if SuppressCommit then
PaymentToleranceMgt.SetSuppressCommit(true);
if "Applies-to Doc. No." <> xRec."Applies-to Doc. No." then
ClearCustVendApplnEntry();
if ("Applies-to Doc. No." = '') and (xRec."Applies-to Doc. No." <> '') then begin
PaymentToleranceMgt.DelPmtTolApllnDocNo(Rec, xRec."Applies-to Doc. No.");
TempGenJnlLine := Rec;
if (TempGenJnlLine."Bal. Account Type" = TempGenJnlLine."Bal. Account Type"::Customer) or
(TempGenJnlLine."Bal. Account Type" = TempGenJnlLine."Bal. Account Type"::Vendor) or
(TempGenJnlLine."Bal. Account Type" = TempGenJnlLine."Bal. Account Type"::Employee)
then
CODEUNIT.Run(CODEUNIT::"Exchange Acc. G/L Journal Line", TempGenJnlLine);
OnAppliesToDocNoOnValidateOnBeforeUpdAmtToEntries(Rec, TempGenJnlLine);
case TempGenJnlLine."Account Type" of
TempGenJnlLine."Account Type"::Customer:
begin
CustLedgEntry.SetCurrentKey("Document No.");
CustLedgEntry.SetRange("Document No.", xRec."Applies-to Doc. No.");
if not (xRec."Applies-to Doc. Type" = "Document Type"::" ") then
CustLedgEntry.SetRange("Document Type", xRec."Applies-to Doc. Type");
CustLedgEntry.SetRange("Customer No.", TempGenJnlLine."Account No.");
CustLedgEntry.SetRange(Open, true);
OnAppliesToDocNoOnValidateOnAfterCustLedgEntrySetFilters(Rec, CustLedgEntry, TempGenJnlLine);
if CustLedgEntry.FindFirst() then begin
if CustLedgEntry."Amount to Apply" <> 0 then begin
CustLedgEntry."Amount to Apply" := 0;
CODEUNIT.Run(CODEUNIT::"Cust. Entry-Edit", CustLedgEntry);
end;
"Exported to Payment File" := CustLedgEntry."Exported to Payment File";
"Applies-to Ext. Doc. No." := '';
end;
end;
TempGenJnlLine."Account Type"::Vendor:
begin
VendLedgEntry.SetCurrentKey("Document No.");
VendLedgEntry.SetRange("Document No.", xRec."Applies-to Doc. No.");
if not (xRec."Applies-to Doc. Type" = "Document Type"::" ") then
VendLedgEntry.SetRange("Document Type", xRec."Applies-to Doc. Type");
VendLedgEntry.SetRange("Vendor No.", TempGenJnlLine."Account No.");
VendLedgEntry.SetRange(Open, true);
OnAppliesToDocNoOnValidateOnAfterVendLedgEntrySetFilters(Rec, VendLedgEntry);
if VendLedgEntry.FindFirst() then begin
if VendLedgEntry."Amount to Apply" <> 0 then begin
VendLedgEntry."Amount to Apply" := 0;
CODEUNIT.Run(CODEUNIT::"Vend. Entry-Edit", VendLedgEntry);
end;
"Exported to Payment File" := VendLedgEntry."Exported to Payment File";
end;
"Applies-to Ext. Doc. No." := '';
end;
TempGenJnlLine."Account Type"::Employee:
begin
EmplLedgEntry.SetCurrentKey("Document No.");
EmplLedgEntry.SetRange("Document No.", xRec."Applies-to Doc. No.");
if not (xRec."Applies-to Doc. Type" = "Document Type"::" ") then
EmplLedgEntry.SetRange("Document Type", xRec."Applies-to Doc. Type");
EmplLedgEntry.SetRange("Employee No.", TempGenJnlLine."Account No.");
EmplLedgEntry.SetRange(Open, true);
OnAppliesToDocNoValidateOnAfterEmplLedgEntrySetFilters(Rec, EmplLedgEntry);
if EmplLedgEntry.FindFirst() then begin
if EmplLedgEntry."Amount to Apply" <> 0 then begin
EmplLedgEntry."Amount to Apply" := 0;
CODEUNIT.Run(CODEUNIT::"Empl. Entry-Edit", EmplLedgEntry);
end;
"Exported to Payment File" := EmplLedgEntry."Exported to Payment File";
end;
end;
else
OnAppliesToDocNoOnValidateOnCaseElse(Rec, xRec, TempGenJnlLine);
end;
OnAppliesToDocNoOnValidateOnAfterUpdAmtToEntries(Rec, TempGenJnlLine);
end;
if ("Applies-to Doc. No." <> xRec."Applies-to Doc. No.") and (Amount <> 0) then begin
if xRec."Applies-to Doc. No." <> '' then begin
PaymentToleranceMgt.DelPmtTolApllnDocNo(Rec, xRec."Applies-to Doc. No.");
OnValidateAppliesToDocNoOnAfterDelPmtToApplnDocNo(Rec, xRec);
end;
SetApplyToAmount();
PaymentToleranceMgt.PmtTolGenJnl(Rec);
xRec.ClearAppliedGenJnlLine();
end;
case "Account Type" of
"Account Type"::Customer:
GetCustLedgerEntry();
"Account Type"::Vendor:
GetVendLedgerEntry();
"Account Type"::Employee:
GetEmplLedgerEntry();
end;
OnAppliesToDocNoOnValidateOnBeforeValidateApplyRequirements(Rec);
ValidateApplyRequirements(Rec);
SetJournalLineFieldsFromApplication();
if "Applies-to Doc. Type" = "Applies-to Doc. Type"::Invoice then
UpdateAppliesToInvoiceID();
end;

Required Code with a new event request for OnValidate of "Applies-to Doc. No."
trigger OnValidate()
var
CustLedgEntry: Record "Cust. Ledger Entry";
VendLedgEntry: Record "Vendor Ledger Entry";
TempGenJnlLine: Record "Gen. Journal Line" temporary;
IsHandled: Boolean;
begin
OnBeforeValidateAppliestoDocNo(Rec, xRec, CurrFieldNo, SuppressCommit, IsHandled);
if IsHandled then
exit;

if SuppressCommit then
PaymentToleranceMgt.SetSuppressCommit(true);
if "Applies-to Doc. No." <> xRec."Applies-to Doc. No." then
ClearCustVendApplnEntry();
if ("Applies-to Doc. No." = '') and (xRec."Applies-to Doc. No." <> '') then begin
PaymentToleranceMgt.DelPmtTolApllnDocNo(Rec, xRec."Applies-to Doc. No.");
TempGenJnlLine := Rec;
if (TempGenJnlLine."Bal. Account Type" = TempGenJnlLine."Bal. Account Type"::Customer) or
(TempGenJnlLine."Bal. Account Type" = TempGenJnlLine."Bal. Account Type"::Vendor) or
(TempGenJnlLine."Bal. Account Type" = TempGenJnlLine."Bal. Account Type"::Employee)
then
CODEUNIT.Run(CODEUNIT::"Exchange Acc. G/L Journal Line", TempGenJnlLine);
OnAppliesToDocNoOnValidateOnBeforeUpdAmtToEntries(Rec, TempGenJnlLine);
case TempGenJnlLine."Account Type" of
TempGenJnlLine."Account Type"::Customer:
begin
CustLedgEntry.SetCurrentKey("Document No.");
CustLedgEntry.SetRange("Document No.", xRec."Applies-to Doc. No.");
if not (xRec."Applies-to Doc. Type" = "Document Type"::" ") then
CustLedgEntry.SetRange("Document Type", xRec."Applies-to Doc. Type");
CustLedgEntry.SetRange("Customer No.", TempGenJnlLine."Account No.");
CustLedgEntry.SetRange(Open, true);
OnAppliesToDocNoOnValidateOnAfterCustLedgEntrySetFilters(Rec, CustLedgEntry, TempGenJnlLine);
if CustLedgEntry.FindFirst() then begin
if CustLedgEntry."Amount to Apply" <> 0 then begin
CustLedgEntry."Amount to Apply" := 0;
CODEUNIT.Run(CODEUNIT::"Cust. Entry-Edit", CustLedgEntry);
end;
"Exported to Payment File" := CustLedgEntry."Exported to Payment File";
"Applies-to Ext. Doc. No." := '';
end;
end;
TempGenJnlLine."Account Type"::Vendor:
begin
VendLedgEntry.SetCurrentKey("Document No.");
VendLedgEntry.SetRange("Document No.", xRec."Applies-to Doc. No.");
if not (xRec."Applies-to Doc. Type" = "Document Type"::" ") then
VendLedgEntry.SetRange("Document Type", xRec."Applies-to Doc. Type");
VendLedgEntry.SetRange("Vendor No.", TempGenJnlLine."Account No.");
VendLedgEntry.SetRange(Open, true);
OnAppliesToDocNoOnValidateOnAfterVendLedgEntrySetFilters(Rec, VendLedgEntry);
if VendLedgEntry.FindFirst() then begin
if VendLedgEntry."Amount to Apply" <> 0 then begin
VendLedgEntry."Amount to Apply" := 0;
CODEUNIT.Run(CODEUNIT::"Vend. Entry-Edit", VendLedgEntry);
end;
"Exported to Payment File" := VendLedgEntry."Exported to Payment File";
end;
"Applies-to Ext. Doc. No." := '';
end;
TempGenJnlLine."Account Type"::Employee:
begin
EmplLedgEntry.SetCurrentKey("Document No.");
EmplLedgEntry.SetRange("Document No.", xRec."Applies-to Doc. No.");
if not (xRec."Applies-to Doc. Type" = "Document Type"::" ") then
EmplLedgEntry.SetRange("Document Type", xRec."Applies-to Doc. Type");
EmplLedgEntry.SetRange("Employee No.", TempGenJnlLine."Account No.");
EmplLedgEntry.SetRange(Open, true);
OnAppliesToDocNoValidateOnAfterEmplLedgEntrySetFilters(Rec, EmplLedgEntry);
if EmplLedgEntry.FindFirst() then begin
if EmplLedgEntry."Amount to Apply" <> 0 then begin
EmplLedgEntry."Amount to Apply" := 0;
CODEUNIT.Run(CODEUNIT::"Empl. Entry-Edit", EmplLedgEntry);
end;
"Exported to Payment File" := EmplLedgEntry."Exported to Payment File";
end;
end;
else
OnAppliesToDocNoOnValidateOnCaseElse(Rec, xRec, TempGenJnlLine);
end;
OnAppliesToDocNoOnValidateOnAfterUpdAmtToEntries(Rec, TempGenJnlLine);
end;
if ("Applies-to Doc. No." <> xRec."Applies-to Doc. No.") and (Amount <> 0) then begin
if xRec."Applies-to Doc. No." <> '' then begin
PaymentToleranceMgt.DelPmtTolApllnDocNo(Rec, xRec."Applies-to Doc. No.");
OnValidateAppliesToDocNoOnAfterDelPmtToApplnDocNo(Rec, xRec);
end;
SetApplyToAmount();
PaymentToleranceMgt.PmtTolGenJnl(Rec);
xRec.ClearAppliedGenJnlLine();
end;
case "Account Type" of
"Account Type"::Customer:
GetCustLedgerEntry();
"Account Type"::Vendor:
GetVendLedgerEntry();
"Account Type"::Employee:
GetEmplLedgerEntry();
end;
OnAppliesToDocNoOnValidateOnBeforeValidateApplyRequirements(Rec);
ValidateApplyRequirements(Rec);
SetJournalLineFieldsFromApplication();
if "Applies-to Doc. Type" = "Applies-to Doc. Type"::Invoice then
UpdateAppliesToInvoiceID();
OnAfterValidateAppliestoDocNo(Rec, xRec, CurrFieldNo, SuppressCommit);
end;

[IntegrationEvent(false, false)]
local procedure OnBeforeValidateAppliestoDocNo(var GenJnlLine: Record "Gen. Journal Line"; xGenJnlLine: Record "Gen. Journal Line"; CurrentFieldNo: Integer; var SuppressCommit: Boolean; var IsHandled: Boolean)
begin
end;

[IntegrationEvent(false, false)]
local procedure OnAfterValidateAppliestoDocNo(var GenJnlLine: Record "Gen. Journal Line"; xGenJnlLine: Record "Gen. Journal Line"; CurrentFieldNo: Integer; var SuppressCommit: Boolean;)
begin
end;

Additional context

This new event is necessary to enable subscription for implementing custom code and to provide the option to bypass the base code when needed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant