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

Fix Sustainability preview posting subscriber #27775

Merged
merged 2 commits into from
Dec 13, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -61,14 +61,13 @@ codeunit 6225 "Sust. Purchase Subscriber"
[EventSubscriber(ObjectType::Codeunit, Codeunit::"Gen. Jnl.-Post Preview", 'OnAfterBindSubscription', '', false, false)]
local procedure OnAfterBindSubscription()
begin
SustPreviewPostInstance.Initialize();
BindSubscription(SustPreviewPostingHandler);
TryBindPostingPreviewHandler();
end;

[EventSubscriber(ObjectType::Codeunit, Codeunit::"Gen. Jnl.-Post Preview", 'OnAfterUnbindSubscription', '', false, false)]
local procedure OnAfterUnbindSubscription()
begin
UnbindSubscription(SustPreviewPostingHandler);
TryUnbindPostingPreviewHandler();
end;

[EventSubscriber(ObjectType::Codeunit, Codeunit::"Purch.-Post", 'OnPostItemJnlLineOnAfterPrepareItemJnlLine', '', false, false)]
Expand Down Expand Up @@ -284,9 +283,23 @@ codeunit 6225 "Sust. Purchase Subscriber"
exit(true);
end;

local procedure TryBindPostingPreviewHandler(): Boolean
var
SustPreviewPostingHandler: Codeunit "Sust. Preview Posting Handler";
SustPreviewPostInstance: Codeunit "Sust. Preview Post Instance";
begin
SustPreviewPostInstance.Initialize();
exit(BindSubscription(SustPreviewPostingHandler));
end;

local procedure TryUnbindPostingPreviewHandler(): Boolean
var
SustPreviewPostingHandler: Codeunit "Sust. Preview Posting Handler";
begin
exit(UnbindSubscription(SustPreviewPostingHandler));
end;

var
EmissionMustNotBeZeroErr: Label 'The Emission fields must have a value that is not 0.';
NotAllowedToPostSustLedEntryForWaterOrWasteErr: Label 'It is not allowed to post Sustainability Ledger Entry for water or waste in purchase document for Account No. %1', Comment = '%1 = Sustainability Account No.';
}
Loading