[Extensibility Enhancements] Allow extensions to show document number in posting preview
When there are serveral posting series, users want to be able to check if the document will be posted on the correct one. Out app allow users to configure series by location or specific vendors or customers.
Spanish Tax authorities want certain types of invoices to be numbered consecutively, for example: simplified purchases invoices from farmers or unidentifed sales invoices (tickets).
Some customers also want to use several series if they have different activities, for example: shop, petrol station.
There are events on sales and purchase posting codeunits when computing next posting numbers, but codeunit 20 "Posting Preview Event Handler" always replace the document number with the preview token ***.
The small changes on codeunit 20 are show below: a new global variable, a public function to enable this feature, an several if to check whether document numbers must be changed or not.
codeunit 20 "Posting Preview Event Handler"
{
var
// ...
PreserveDocumentNo: Boolean;
procedure SetPreserveDocumentNo(newPreserveDocumentNo: Boolean)
begin
PreserveDocumentNo := newPreserveDocumentNo;
end;
[EventSubscriber(ObjectType::Table, Database::"G/L Entry", 'OnAfterInsertEvent', '', false, false)]
local procedure OnInsertGLEntry(var Rec: Record "G/L Entry"; RunTrigger: Boolean)
begin
if Rec.IsTemporary() then
exit;
PreventCommit();
TempGLEntry := Rec;
if not PreserveDocumentNo then // Check added
TempGLEntry."Document No." := '***';
TempGLEntry.Insert();
end;
}
Then extensions can activate this behavior by suscribing to general journal post preview:
[EventSubscriber(ObjectType::Codeunit, Codeunit::"Gen. Jnl.-Post Preview", 'OnAfterBindSubscription', '', false, false)]
local procedure GenJnlPostPreviewOnAfterBindSubscription(var PostingPreviewEventHandler: Codeunit "Posting Preview Event Handler")
begin
PostingPreviewEventHandler.SetPreserveDocumentNo(true);
end;
Standard
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.