ALAppExtensions icon indicating copy to clipboard operation
ALAppExtensions copied to clipboard

GET error - Table 37 & Table 39

Open Halilovast opened this issue 8 years ago • 8 comments

Could you change the following code in tables 37 and 39: VAT Prod. Posting Group - OnValidate() TestStatusOpen; // begin //VATPostingSetup.GET("VAT Bus. Posting Group","VAT Prod. Posting Group"); IF NOT VATPostingSetup.GET("VAT Bus. Posting Group","VAT Prod. Posting Group") THEN VATPostingSetup.INIT; // end

Halilovast avatar Sep 18 '18 21:09 Halilovast

Why? You should get an error if the setup does not exist. Just skipping that could lead to hard to solve problems later.

AskeHolst avatar Sep 18 '18 21:09 AskeHolst

Depending on the business transaction, different VAT prod. posting group should be applied per one GL Account being invoiced on the purchase/sales document. If we default the GL Account (by populating VAT prod. posting group on the GL account card), then it is common user mistake to skip changing VAT prod. posting group on the document line. This result in errors in VAT reporting to tax authorities. If the GL account hasn’t got a default VAT prod. posting group, then the user should be prompted to provide it on the sales/purchase document line. Then VAT group is picked by the type of product/service in the business transactions.

Halilovast avatar Sep 19 '18 06:09 Halilovast

Hi @Halilovast , I got your point, there is no need of code changes, just follow the simple below logic: before going to pick VAT prod. posting group instruct user to must provide VAT Bus. posting group first.

nareshbandariD365 avatar Sep 19 '18 09:09 nareshbandariD365

Hi @nareshbandariD365 , Thanks, but "instruct user" doesn't work :(

Halilovast avatar Sep 25 '18 10:09 Halilovast

Why not add some code to supply the instructions to the user for your special case, like this:

[EventSubscriber(ObjectType::Table, 37, 'OnBeforeValidateEvent', 'VAT Prod. Posting Group', false, false)]
local procedure OnBeforeValidateVATProdPostingGroup(var Rec: Record "Sales Line"; var xRec: Record "Sales Line"; CurrFieldNo: Integer)
begin
   if (rec."VAT Bus. Posting Group" = '') and (SomeSpecialConditionApplies(Rec)) then
       error(VATProdPostingGroupMustBeSelectedFirstErr);
end;

AskeHolst avatar Sep 25 '18 11:09 AskeHolst

Because even user select "VAT Prod. Posting Group" before select G/L Account No. for Sales Line, after validate No. (with type G/L Account) "VAT Prod. Posting Group" is filled in function CopyFromGLAccount;

LOCAL CopyFromGLAccount() GLAcc.GET("No."); GLAcc.CheckGLAcc; IF NOT "System-Created Entry" THEN GLAcc.TESTFIELD("Direct Posting",TRUE); Description := GLAcc.Name; "Gen. Prod. Posting Group" := GLAcc."Gen. Prod. Posting Group"; "VAT Prod. Posting Group" := GLAcc."VAT Prod. Posting Group";

Halilovast avatar Sep 26 '18 08:09 Halilovast

VAT Business Posting Group code comes from document header and should not be entered in document lines. VAT Product Posting Group comes from selected Item or G/L Account and should not be entered by user as well in most of scenarios.

AlexanderYakunin avatar Oct 23 '18 14:10 AlexanderYakunin

Issue closed by @AlexanderYakunin.

JesperSchulz avatar Nov 01 '18 15:11 JesperSchulz