ALAppExtensions icon indicating copy to clipboard operation
ALAppExtensions copied to clipboard

[Event Request] Codeunit 140 "EC Sales List Suggest Lines" OnBeforePopulateVatEntryLines

Open JesperAtGitHub opened this issue 2 years ago • 2 comments

Describe the request

Please add this integrationevent in codeunit 140:

local procedure PopulateVatEntryLines()
var
    CompanyInformation: Record "Company Information";
    EUVATEntries: Query "EU VAT Entries";
begin
    CompanyInformation.Get();
    EUVATEntries.SetRange(VATReportingDate, VATReportHeader."Start Date", VATReportHeader."End Date");
    EUVATEntries.SetFilter(CountryCode, '<>%1', CompanyInformation."Country/Region Code");
    // ->
    OnBeforePopulateVatEntryLines(VATReportHeader, EUVATEntries);
    // <-
    EUVATEntries.Open();
    while EUVATEntries.Read() do
        AddOrUpdateECLLine(EUVATEntries);
    RowsTotalCorrection();
    DeleteZeroAmountLines();
end;

(...)

// ->  (EUVATEntries has to be a 'var' parameter)
[IntegrationEvent(false, false)]
local procedure OnBeforePopulateVatEntryLines(var VATReportHeader: Record "VAT Report Header"; var EUVATEntries: Query "EU VAT Entries")
begin
end;
// <-

[IntegrationEvent(false, false)]
local procedure OnBeforeAddOrUpdateECLLine(EUVATEntries: Query "EU VAT Entries"; var ECSLVATReportLine: Record "ECSL VAT Report Line"; var IsHandled: Boolean)
begin
end;

Please also add these columns/fields in query 141 "EU VAT Entries" (the reason is described under "Additional Context"):

        column(EU_Service; "EU Service")
        {
        }
        // ->
        column(GenBusPostingGroup; "Gen. Bus. Posting Group")
        {
        }
        column(GenProdPostingGroup; "Gen. Prod. Posting Group")
        {
        }
        column(VATBusPostingGroup; "VAT Bus. Posting Group")
        {
        }
        column(VATProdPostingGroup; "VAT Prod. Posting Group")
        {
        }
        // <-
        column(Entry_No; "Entry No.")
        {
        }

Additional context

The purpose is to enable setting additional filters (mainly on the posting groups) on the EUVATEntries (query 141 "EU VAT Entries") before the query is opened.

Currently the only integrationevent available is:

OnBeforeAddOrUpdateECLLine(EUVATEntries: Query "EU VAT Entries"; var ECSLVATReportLine: Record "ECSL VAT Report Line"; var IsHandled: Boolean)

In generel, its useability is quite limited for the following reasons:

  • There are no reference (or GlobalVarAccess) to the "VAT Report Header" in use.

  • The ECSLVATReportLine record is a blank record (no data or filters)

  • If any fieldvalue is set on the ECSLVATReportLine record it is most likely replaced/cleared (by FindFirst or Init) after the event, by the procedure GetECLine.

  • One could use this event to skip (IsHandled = True) certain records if all the parameters for the criteria(s) available. But in cases where you instead could use filters beforehand to limit the records fetched by SQL - the latter is, by far, preferred.

In the actual business case there is a need to be able to filter out (avoid) VAT Entries with certain posting groups, which is likely to also be the fields one, in general, would like to set filters on in other/similar cases when subscribing to the hereby proposed new event.

Internal work item: AB#522690

JesperAtGitHub avatar Mar 26 '24 14:03 JesperAtGitHub

Hello @JesperAtGitHub This request will be used for new event publisher. For updating query, please create new request.

AleksandricMarko avatar Apr 03 '24 09:04 AleksandricMarko

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: 18286.

JesperSchulz avatar Apr 09 '24 18:04 JesperSchulz