{"title":"Codeunit 6406 EDoc Prepare Purch. Draft, extension points 29","url":"https://jonas-paprotka.de/ref/codeunit/6406-edoc-prepare-purch-draft/points/","author":"JOP-AL","license":"Metadata from Microsoft's symbol packages. AL source MIT, Copyright (c) Microsoft Corporation. Selection and wording © 2026 JOP-AL. https://jonas-paprotka.de/licenses/","subject":"Microsoft Dynamics 365 Business Central","checked":"2026-11-20","changed":"2026-10-05","object":{"type":"codeunit","id":6406,"name":"EDoc Prepare Purch. Draft","app":"E-Document Core","url":"https://jonas-paprotka.de/ref/codeunit/6406-edoc-prepare-purch-draft/"},"major":29,"source":{"url":"https://jonas-paprotka.de/ref/codeunit/6406-edoc-prepare-purch-draft/source/","path":"src/Apps/W1/EDocument/App/src/Processing/Import/PrepareDraft/EDocPreparePurchDraft.Codeunit.al","commit":"4303e5e584d3aa5d9e98cbc615525a5396ad6ed7","lines":"a line is <source url>#L<line>"},"steps":{"event":"[line, \"event\", name, handled]: raises an event of this object; handled 1 when it has an IsHandled parameter","call":"[line, \"call\", name, arguments]: calls a procedure of this object","ext":"[line, \"ext\", type, id, name, arguments]: calls a procedure of another object, through a variable declared with that type","write":"[line, \"write\", table id, method, 1 when called with true]: Insert, Modify, ModifyAll, Delete, DeleteAll or Rename","validate":"[line, \"validate\", table id, field name]","run":"[line, \"run\", type, id]: Codeunit.Run, Page.Run, Report.Run and their kin"},"objects":{"codeunit:6175":{"name":"E-Doc. Activity Log Session","url":"https://jonas-paprotka.de/ref/codeunit/6175-e-doc-activity-log-session/"},"table:6100":{"name":"E-Document Purchase Header","url":"https://jonas-paprotka.de/ref/table/6100-e-document-purchase-header/"},"codeunit:6120":{"name":"E-Doc. Purchase Hist. Mapping","url":"https://jonas-paprotka.de/ref/codeunit/6120-e-doc-purchase-hist-mapping/"},"codeunit:6122":{"name":"E-Doc. Imp. Session Telemetry","url":"https://jonas-paprotka.de/ref/codeunit/6122-e-doc-imp-session-telemetry/"},"table:6101":{"name":"E-Document Purchase Line","url":"https://jonas-paprotka.de/ref/table/6101-e-document-purchase-line/"},"codeunit:3111":{"name":"Activity Log Builder","url":"https://jonas-paprotka.de/ref/codeunit/3111-activity-log-builder/"},"codeunit:6402":{"name":"E-Doc. Purch. Doc. Helper","url":"https://jonas-paprotka.de/ref/codeunit/6402-e-doc-purch-doc-helper/"},"codeunit:6177":{"name":"E-Doc. Historical Matching","url":"https://jonas-paprotka.de/ref/codeunit/6177-e-doc-historical-matching/"},"codeunit:6126":{"name":"E-Doc. GL Account Matching","url":"https://jonas-paprotka.de/ref/codeunit/6126-e-doc-gl-account-matching/"},"codeunit:6129":{"name":"E-Doc. Deferral Matching","url":"https://jonas-paprotka.de/ref/codeunit/6129-e-doc-deferral-matching/"}},"procs":[{"name":"PrepareDraft","line":29,"kind":"procedure","params":2,"steps":[[53,"ext","codeunit",6175,"CreateSession",0],[55,"ext","table",6100,"GetFromEDocument",1],[59,"call","GetVendor",2],[67,"write",6100,"Modify"],[69,"ext","codeunit",6120,"FindRelatedPurchaseHeaderInHistory",2],[70,"ext","codeunit",6120,"UpdateMissingHeaderValuesFromHistory",2],[71,"write",6100,"Modify"],[73,"ext","codeunit",6122,"SetBool",2],[77,"ext","codeunit",6122,"SetText",2],[79,"ext","codeunit",6122,"SetText",2],[81,"ext","codeunit",6122,"SetText",2],[83,"ext","codeunit",6122,"SetText",2],[94,"write",6101,"Modify"],[98,"call","ResolveVATProductPostingGroups",2],[100,"call","CopilotLineMatching",1],[111,"ext","codeunit",6122,"SetLine",1],[114,"call","ComputeAndApplyVATAmountDifference",2],[115,"write",6100,"Modify"],[117,"call","LogAllActivitySessionChanges",1],[119,"ext","codeunit",6175,"EndSession",0]]},{"name":"OpenDraftPage","line":130,"kind":"procedure","params":1,"steps":[[134,"call","EnsureDraftHeaderExistsForFailedExtraction",1]]},{"name":"EnsureDraftHeaderExistsForFailedExtraction","line":140,"kind":"procedure","access":"internal","params":1,"steps":[[148,"ext","table",6100,"InsertForEDocument",1]]},{"name":"CleanUpDraft","line":151,"kind":"procedure","params":1,"steps":[[158,"write",6100,"DeleteAll",1],[162,"write",6101,"DeleteAll",1]]},{"name":"LogAllActivitySessionChanges","line":165,"kind":"procedure","access":"local","params":1,"steps":[[167,"call","Log",2],[167,"ext","codeunit",6175,"AccountNumberTok",0],[168,"call","Log",2],[168,"ext","codeunit",6175,"DeferralTok",0],[169,"call","Log",2],[169,"ext","codeunit",6175,"ItemRefTok",0],[170,"call","Log",2],[170,"ext","codeunit",6175,"TextToAccountMappingTok",0],[171,"call","Log",2],[171,"ext","codeunit",6175,"ItemDescriptionTok",0]]},{"name":"Log","line":174,"kind":"procedure","access":"local","params":2,"steps":[[181,"ext","codeunit",6175,"GetAll",3],[183,"ext","codeunit",3111,"Log",0]]},{"name":"ResolveVATProductPostingGroups","line":186,"kind":"procedure","access":"local","params":2,"steps":[[199,"ext","table",6100,"GetBCVendor",0],[225,"call","FindVATProductPostingGroup",2],[226,"write",6101,"Modify"],[228,"ext","table",6101,"LogVATRateMismatch",2],[230,"ext","table",6101,"LogVATRateResolved",2]]},{"name":"FindVATProductPostingGroup","line":235,"kind":"procedure","access":"local","params":2,"steps":[[242,"ext","codeunit",6402,"SetNormalReverseChargeFilter",2]]},{"name":"CopilotLineMatching","line":252,"kind":"procedure","access":"local","params":1,"steps":[[265,"run","codeunit",6177],[274,"run","codeunit",6126],[283,"run","codeunit",6129]]}]}