{"title":"Codeunit 5802 Inventory Posting To G/L, extension points 29","url":"https://jonas-paprotka.de/ref/codeunit/5802-inventory-posting-to-g-l/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":5802,"name":"Inventory Posting To G/L","app":"Base Application","url":"https://jonas-paprotka.de/ref/codeunit/5802-inventory-posting-to-g-l/"},"major":29,"source":{"url":"https://jonas-paprotka.de/ref/codeunit/5802-inventory-posting-to-g-l/source/","path":"src/Layers/W1/BaseApp/Inventory/Costing/InventoryPostingToGL.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":{"table:5823":{"name":"G/L - Item Ledger Relation","url":"https://jonas-paprotka.de/ref/table/5823-g-l-item-ledger-relation/"},"codeunit:12":{"name":"Gen. Jnl.-Post Line","url":"https://jonas-paprotka.de/ref/codeunit/12-gen-jnl-post-line/"},"codeunit:5836":{"name":"Cost Calculation Management","url":"https://jonas-paprotka.de/ref/codeunit/5836-cost-calculation-management/"},"table:48":{"name":"Invt. Posting Buffer","url":"https://jonas-paprotka.de/ref/table/48-invt-posting-buffer/"},"table:5813":{"name":"Inventory Posting Setup","url":"https://jonas-paprotka.de/ref/table/5813-inventory-posting-setup/"},"table:252":{"name":"General Posting Setup","url":"https://jonas-paprotka.de/ref/table/252-general-posting-setup/"},"table:5822":{"name":"Invt. Post to G/L Test Buffer","url":"https://jonas-paprotka.de/ref/table/5822-invt-post-to-g-l-test-buffer/"},"table:81":{"name":"Gen. Journal Line","url":"https://jonas-paprotka.de/ref/table/81-gen-journal-line/"},"codeunit:408":{"name":"DimensionManagement","url":"https://jonas-paprotka.de/ref/codeunit/408-dimensionmanagement/"},"table:5802":{"name":"Value Entry","url":"https://jonas-paprotka.de/ref/table/5802-value-entry/"},"codeunit:11":{"name":"Gen. Jnl.-Check Line","url":"https://jonas-paprotka.de/ref/codeunit/11-gen-jnl-check-line/"}},"procs":[{"name":"OnRun","line":27,"kind":"trigger","steps":[[33,"event","OnBeforeOnRun",1],[38,"call","PostInvtPostBuf",5],[40,"call","PostInvtPostBuf",5],[49,"event","OnAfterRun",0]]},{"name":"Initialize","line":105,"kind":"procedure","params":1,"steps":[[110,"event","OnAfterInitialize",0]]},{"name":"SetGenJnlBatch","line":113,"kind":"procedure","params":2,"steps":[[118,"event","OnAfterSetGenJnlBatch",0]]},{"name":"SetRunOnlyCheck","line":121,"kind":"procedure","params":3,"steps":[[128,"write",5823,"DeleteAll"],[130,"event","OnAfterSetRunOnlyCheck",0]]},{"name":"GetGLRegister","line":133,"kind":"procedure","params":3,"steps":[[135,"ext","codeunit",12,"GetGLReg",1],[136,"ext","codeunit",12,"GetNextVATEntryNo",0],[137,"ext","codeunit",12,"GetNextTransactionNo",0]]},{"name":"ResetGLPostingState","line":147,"kind":"procedure","params":0,"steps":[[149,"ext","codeunit",12,"ResetTransactionState",0]]},{"name":"BufferInvtPosting","line":152,"kind":"procedure","params":1,"steps":[[163,"event","OnBeforeBufferInvtPosting",1],[167,"call","GetGLSetup",0],[168,"call","GetInvtSetup",0],[184,"call","CalcCostToPost",4],[185,"call","CalcCostToPost",4],[187,"call","CalcCostToPost",4],[188,"call","CalcCostToPost",4],[189,"event","OnAfterCalcCostToPostFromBuffer",0],[196,"event","OnBeforeBufferPosting",0],[200,"call","BufferPurchPosting",5],[202,"call","BufferSalesPosting",5],[206,"call","BufferAdjmtPosting",5],[208,"call","BufferConsumpPosting",3],[210,"call","BufferOutputPosting",5],[212,"call","BufferAsmConsumpPosting",3],[214,"call","BufferAsmOutputPosting",3],[216,"call","BufferCapacityPosting",3],[218,"call","ErrorNonValidCombination",1],[221,"event","OnAfterBufferPosting",0],[223,"call","UpdateGlobalInvtPostBuf",1]]},{"name":"AdjustPostedWIPForProduction","line":228,"kind":"procedure","params":1,"steps":[[230,"call","AdjustWIPForProduction",3],[231,"call","UpdateGlobalInvtPostBuf",1]]},{"name":"BufferPurchPosting","line":235,"kind":"procedure","access":"local","params":5,"steps":[[239,"event","OnBeforeBufferPurchPosting",1],[247,"call","InitInvtPostBuf",6],[253,"call","InitInvtPostBuf",6],[260,"call","InitInvtPostBuf",6],[268,"call","InitInvtPostBuf",6],[277,"call","InitInvtPostBuf",6],[283,"call","InitInvtPostBuf",6],[290,"call","InitInvtPostBuf",6],[296,"call","ErrorNonValidCombination",1],[299,"event","OnAfterBufferPurchPosting",0]]},{"name":"BufferSalesPosting","line":302,"kind":"procedure","access":"local","params":5,"steps":[[306,"event","OnBeforeBufferSalesPosting",1],[314,"call","InitInvtPostBuf",6],[320,"call","InitInvtPostBuf",6],[329,"call","InitInvtPostBuf",6],[335,"call","InitInvtPostBuf",6],[342,"call","InitInvtPostBuf",6],[348,"call","ErrorNonValidCombination",1],[351,"event","OnAfterBufferSalesPosting",0]]},{"name":"BufferOutputPosting","line":354,"kind":"procedure","access":"local","params":5,"steps":[[358,"event","OnBeforeBufferOutputPosting",1],[366,"call","InitInvtPostBuf",6],[372,"call","InitInvtPostBuf",6],[380,"ext","codeunit",5836,"CanIncNonInvCostIntoProductionItem",0],[381,"call","InitInvtPostBuf",6],[387,"call","InitInvtPostBuf",6],[395,"call","InitInvtPostBuf",6],[401,"ext","codeunit",5836,"CanIncNonInvCostIntoProductionItem",0],[402,"call","InitInvtPostBuf",6],[408,"call","InitInvtPostBuf",6],[414,"call","InitInvtPostBuf",6],[420,"call","InitInvtPostBuf",6],[426,"call","InitInvtPostBuf",6],[432,"call","ErrorNonValidCombination",1],[437,"call","InitInvtPostBuf",6],[443,"call","InitInvtPostBuf",6],[450,"call","InitInvtPostBuf",6],[456,"call","ErrorNonValidCombination",1],[459,"event","OnAfterBufferOutputPosting",0]]},{"name":"BufferConsumpPosting","line":462,"kind":"procedure","access":"local","params":3,"steps":[[467,"event","OnBeforeBufferConsumpPosting",1],[474,"call","InitInvtPostBuf",6],[480,"call","AdjustWIPForProduction",3],[484,"call","InitInvtPostBuf",6],[490,"call","ErrorNonValidCombination",1],[493,"event","OnAfterBufferConsumpPosting",0]]},{"name":"AdjustWIPForProduction","line":496,"kind":"procedure","access":"local","params":3,"steps":[[501,"event","OnBeforeAdjustWIPForProduction",1],[507,"call","InitInvtPostBuf",6],[513,"call","InitInvtPostBuf",6]]},{"name":"BufferCapacityPosting","line":521,"kind":"procedure","access":"local","params":3,"steps":[[526,"event","OnBeforeBufferCapacityPosting",1],[531,"call","InitInvtPostBuf",6],[537,"call","InitInvtPostBuf",6],[543,"call","ErrorNonValidCombination",1],[549,"call","InitInvtPostBuf",6],[555,"call","AdjustWIPForProduction",3],[558,"call","InitInvtPostBuf",6],[564,"call","ErrorNonValidCombination",1],[567,"event","OnAfterBufferCapacityPosting",0]]},{"name":"BufferAsmOutputPosting","line":570,"kind":"procedure","access":"local","params":3,"steps":[[575,"event","OnBeforeBufferAsmOutputPosting",1],[581,"call","InitInvtPostBuf",6],[587,"call","InitInvtPostBuf",6],[595,"call","InitInvtPostBuf",6],[601,"call","InitInvtPostBuf",6],[607,"call","InitInvtPostBuf",6],[613,"call","InitInvtPostBuf",6],[619,"call","InitInvtPostBuf",6],[625,"call","ErrorNonValidCombination",1],[628,"call","InitInvtPostBuf",6],[634,"call","InitInvtPostBuf",6],[640,"call","ErrorNonValidCombination",1]]},{"name":"BufferAsmConsumpPosting","line":644,"kind":"procedure","access":"local","params":3,"steps":[[649,"event","OnBeforeBufferAsmConsumpPosting",1],[655,"call","InitInvtPostBuf",6],[662,"call","InitInvtPostBuf",6],[668,"call","ErrorNonValidCombination",1]]},{"name":"BufferAdjmtPosting","line":672,"kind":"procedure","access":"local","params":5,"steps":[[676,"event","OnBeforeBufferAdjmtPosting",1],[685,"call","InitInvtPostBuf",6],[691,"call","InitInvtPostBuf",6],[699,"call","InitInvtPostBuf",6],[705,"call","ErrorNonValidCombination",1],[708,"event","OnAfterBufferAdjmtPosting",0]]},{"name":"InitInvtPostBuf","line":739,"kind":"procedure","params":6,"steps":[[741,"event","OnBeforeInitInvtPostBuf",0],[743,"call","InitInvtPostBufPerAccount",7],[744,"call","InitInvtPostBufPerAccount",7],[746,"event","OnAfterInitInvtPostBuf",0]]},{"name":"InitInvtPostBufPerAccount","line":749,"kind":"procedure","access":"local","params":7,"steps":[[754,"event","OnBeforeInitInvtPostBufPerAccount",1],[761,"call","SetAccNo",4],[762,"call","SetPostBufAmounts",4],[764,"call","SetAccNo",4],[765,"call","SetPostBufAmounts",4],[770,"event","OnAfterInitTempInvtPostBuf",0]]},{"name":"CheckAccNo","line":773,"kind":"procedure","access":"local","params":1,"steps":[[779,"event","OnBeforeCheckGLAcc",1]]},{"name":"SetAccNo","line":795,"kind":"procedure","access":"local","params":4,"steps":[[806,"call","GetInvPostingGroupCode",3],[812,"event","OnBeforeGetInvtPostSetup",1],[814,"ext","table",48,"UseInvtPostSetup",0],[830,"event","OnSetAccNoOnAfterGetPostingSetup",0],[830,"ext","table",48,"UseInvtPostSetup",0],[833,"event","OnBeforeSetAccNo",1],[838,"ext","table",5813,"GetInventoryAccount",0],[843,"ext","table",5813,"GetInventoryAccountInterim",0],[848,"ext","table",5813,"GetWIPAccount",0],[853,"ext","table",5813,"GetMaterialVarianceAccount",0],[858,"ext","table",5813,"GetMaterialNonInventoryVarianceAccount",0],[863,"ext","table",5813,"GetCapacityVarianceAccount",0],[868,"ext","table",5813,"GetSubcontractedVarianceAccount",0],[873,"ext","table",5813,"GetCapOverheadVarianceAccount",0],[878,"ext","table",5813,"GetMfgOverheadVarianceAccount",0],[883,"ext","table",252,"GetInventoryAdjmtAccount",0],[888,"ext","table",252,"GetDirectCostAppliedAccount",0],[893,"ext","table",252,"GetDirectCostNonInvtAppliedAccount",0],[898,"ext","table",252,"GetOverheadAppliedAccount",0],[903,"ext","table",252,"GetPurchaseVarianceAccount",0],[908,"ext","table",252,"GetCOGSAccount",0],[913,"ext","table",252,"GetCOGSInterimAccount",0],[918,"ext","table",252,"GetInventoryAccrualAccount",0],[924,"event","OnSetAccNoOnBeforeCheckAccNo",0],[925,"call","CheckAccNo",1],[927,"event","OnAfterSetAccNo",0]]},{"name":"UpdateGlobalInvtPostBuf","line":937,"kind":"procedure","access":"local","params":1,"steps":[[943,"event","OnBeforeUpdateGlobalInvtPostBuf",1],[958,"call","UpdateReportAmounts",0],[962,"event","OnUpdateGlobalInvtPostBufOnBeforeModify",0],[963,"write",48,"Modify"],[967,"write",48,"Insert"],[970,"event","OnUpdateGlobalInvtPostBufOnAfterCalcShouldInsertTempGLItemLedgRelation",0],[975,"write",5823,"Insert"],[976,"event","OnAfterBufferGLItemLedgRelation",0]]},{"name":"UpdateReportAmounts","line":983,"kind":"procedure","access":"local","params":0,"steps":[[1011,"event","OnAfteUpdateReportAmounts",0]]},{"name":"ErrorNonValidCombination","line":1014,"kind":"procedure","access":"local","params":1,"steps":[[1017,"call","InsertTempInvtPostToGLTestBuf",1]]},{"name":"InsertTempInvtPostToGLTestBuf","line":1026,"kind":"procedure","access":"local","params":1,"steps":[[1028,"call","GetNextLineNo",0],[1034,"event","OnInsertTempInvtPostToGLTestBufOnBeforeInsert",0],[1035,"write",5822,"Insert"]]},{"name":"PostInvtPostBufPerEntry","line":1052,"kind":"procedure","params":1,"steps":[[1058,"event","OnBeforePostInvtPostBufPerEntry",1],[1062,"call","PostInvtPostBuf",5]]},{"name":"PostInvtPostBufPerPostGrp","line":1072,"kind":"procedure","params":2,"steps":[[1076,"call","PostInvtPostBuf",5]]},{"name":"PostInvtPostBuf","line":1079,"kind":"procedure","access":"local","params":5,"steps":[[1084,"event","OnPostInvtPostBufferOnBeforeFind",0],[1088,"call","PostInvtPostBufInitGenJnlLine",5],[1090,"call","PostInvtPostBufProcessGlobalInvtPostBuf",3],[1093,"event","OnPostInvtPostBufferOnAfterPostInvtPostBuf",0],[1095,"write",48,"DeleteAll"]]},{"name":"PostInvtPostBufInitGenJnlLine","line":1098,"kind":"procedure","access":"local","params":5,"steps":[[1104,"call","GetSourceCodeSetup",0],[1110,"call","GetGLSetup",0],[1116,"call","GetInvtSetup",0],[1121,"event","OnPostInvtPostBufOnAfterInitGenJnlLine",0]]},{"name":"PostInvtPostBufProcessGlobalInvtPostBuf","line":1124,"kind":"procedure","access":"local","params":3,"steps":[[1129,"event","OnBeforePostInvtPostBufProcessGlobalInvtPostBuf",1],[1134,"validate",81,"Posting Date"],[1135,"validate",81,"VAT Reporting Date"],[1136,"event","OnPostInvtPostBufOnBeforeSetAmt",0],[1137,"call","SetAmt",3],[1139,"call","SetDesc",2],[1140,"event","OnPostInvtPostBufProcessGlobalInvtPostBufOnAfterSetDesc",0],[1143,"ext","codeunit",408,"UpdateGlobalDimFromDimSetID",3],[1146,"event","OnPostInvtPostBufOnAfterUpdateGlobalDimFromDimSetID",0],[1150,"ext","codeunit",12,"SetOverDimErr",0],[1151,"event","OnBeforePostInvtPostBuf",0],[1152,"call","PostGenJnlLine",1],[1153,"event","OnAfterPostInvtPostBuf",0],[1155,"event","OnBeforeCheckInvtPostBuf",0],[1156,"call","CheckGenJnlLine",1],[1159,"call","InsertTempInvtPostToGLTestBuf",2],[1161,"event","OnPostInvtPostBufProcessGlobalInvtPostBufOnAfterSetAmt",0],[1164,"call","CreateGLItemLedgerRelation",1]]},{"name":"SetAmt","line":1175,"kind":"procedure","access":"local","params":3,"steps":[[1178,"validate",81,"Amount"],[1180,"call","GetGLSetup",0],[1187,"validate",81,"Amount"],[1193,"event","OnAfterSetAmt",0]]},{"name":"SetDesc","line":1196,"kind":"procedure","params":2,"steps":[[1207,"event","OnAfterSetDesc",0]]},{"name":"InsertTempInvtPostToGLTestBuf","line":1210,"kind":"procedure","access":"local","params":2,"steps":[[1213,"call","GetNextLineNo",0],[1227,"ext","table",48,"UseInvtPostSetup",0],[1230,"call","GetInvPostingGroupCode",3],[1238,"event","OnInsertTempInvtPostToGLTestBufOnBeforeTempInvtPostToGLTestBufInsert",0],[1239,"write",5822,"Insert"]]},{"name":"CreateGLItemLedgerRelation","line":1242,"kind":"procedure","access":"local","params":1,"steps":[[1246,"ext","codeunit",12,"GetGLReg",1],[1253,"call","UpdateValueEntry",1],[1254,"call","CreateGLItemLedgerRelationEntry",1],[1257,"call","UpdateValueEntry",1],[1258,"call","CreateGLItemLedgerRelationEntry",1]]},{"name":"CreateGLItemLedgerRelationEntry","line":1262,"kind":"procedure","access":"local","params":1,"steps":[[1268,"event","OnBeforeCreateGLItemLedgerRelationEntry",1],[1276,"event","OnBeforeGLItemLedgRelationInsert",0],[1277,"write",5823,"Insert"],[1278,"event","OnAfterGLItemLedgRelationInsert",0],[1280,"write",5823,"Delete"]]},{"name":"UpdateValueEntry","line":1283,"kind":"procedure","access":"local","params":1,"steps":[[1292,"event","OnUpdateValueEntryOnBeforeModify",0],[1294,"write",5802,"Modify"]]},{"name":"GetTempInvtPostToGLTestBuf","line":1297,"kind":"procedure","params":1,"steps":[[1299,"write",5822,"DeleteAll"],[1305,"write",5822,"Insert"]]},{"name":"GetAmtToPost","line":1309,"kind":"procedure","params":10,"steps":[[1311,"call","GetAmt",4],[1312,"call","GetAmt",4],[1313,"call","GetAmt",4],[1314,"call","GetAmt",4],[1315,"call","GetAmt",4],[1316,"call","GetAmt",4],[1317,"call","GetAmt",4],[1318,"call","GetAmt",4],[1319,"call","GetAmt",4]]},{"name":"GetInvtPostBuf","line":1333,"kind":"procedure","params":1,"steps":[[1335,"write",48,"DeleteAll"],[1341,"write",48,"Insert"]]},{"name":"GetInvPostingGroupCode","line":1345,"kind":"procedure","access":"local","params":3,"steps":[[1351,"event","OnBeforeGetInvPostingGroupCode",1]]},{"name":"CheckGenJnlLine","line":1364,"kind":"procedure","params":1,"steps":[[1366,"ext","codeunit",11,"RunCheck",1]]},{"name":"PostGenJnlLine","line":1369,"kind":"procedure","params":1,"steps":[[1374,"ext","codeunit",12,"RunWithCheck",1]]}]}