{"title":"Codeunit 131340 Library - Cost Accounting, extension points 29","url":"https://jonas-paprotka.de/ref/codeunit/131340-library-cost-accounting/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":131340,"name":"Library - Cost Accounting","app":"Application Test Library","url":"https://jonas-paprotka.de/ref/codeunit/131340-library-cost-accounting/"},"major":29,"source":{"url":"https://jonas-paprotka.de/ref/codeunit/131340-library-cost-accounting/source/","path":"src/Layers/W1/Tests/ApplicationTestLibrary/LibraryCostAccounting.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:130000":{"name":"Assert","url":"https://jonas-paprotka.de/ref/codeunit/130000-assert/"},"codeunit:131001":{"name":"Library - Dimension","url":"https://jonas-paprotka.de/ref/codeunit/131001-library-dimension/"},"table:349":{"name":"Dimension Value","url":"https://jonas-paprotka.de/ref/table/349-dimension-value/"},"table:1101":{"name":"Cost Journal Line","url":"https://jonas-paprotka.de/ref/table/1101-cost-journal-line/"},"table:1106":{"name":"Cost Allocation Source","url":"https://jonas-paprotka.de/ref/table/1106-cost-allocation-source/"},"codeunit:130440":{"name":"Library - Random","url":"https://jonas-paprotka.de/ref/codeunit/130440-library-random/"},"table:1107":{"name":"Cost Allocation Target","url":"https://jonas-paprotka.de/ref/table/1107-cost-allocation-target/"},"table:1108":{"name":"Cost Accounting Setup","url":"https://jonas-paprotka.de/ref/table/1108-cost-accounting-setup/"},"codeunit:131300":{"name":"Library - ERM","url":"https://jonas-paprotka.de/ref/codeunit/131300-library-erm/"},"table:15":{"name":"G/L Account","url":"https://jonas-paprotka.de/ref/table/15-g-l-account/"},"table:1109":{"name":"Cost Budget Entry","url":"https://jonas-paprotka.de/ref/table/1109-cost-budget-entry/"},"table:1110":{"name":"Cost Budget Name","url":"https://jonas-paprotka.de/ref/table/1110-cost-budget-name/"},"codeunit:131000":{"name":"Library - Utility","url":"https://jonas-paprotka.de/ref/codeunit/131000-library-utility/"},"table:1112":{"name":"Cost Center","url":"https://jonas-paprotka.de/ref/table/1112-cost-center/"},"table:1100":{"name":"Cost Journal Template","url":"https://jonas-paprotka.de/ref/table/1100-cost-journal-template/"},"table:1102":{"name":"Cost Journal Batch","url":"https://jonas-paprotka.de/ref/table/1102-cost-journal-batch/"},"table:1113":{"name":"Cost Object","url":"https://jonas-paprotka.de/ref/table/1113-cost-object/"},"table:1103":{"name":"Cost Type","url":"https://jonas-paprotka.de/ref/table/1103-cost-type/"},"table:81":{"name":"Gen. Journal Line","url":"https://jonas-paprotka.de/ref/table/81-gen-journal-line/"},"report:1139":{"name":"Delete Cost Budget Entries","url":"https://jonas-paprotka.de/ref/report/1139-delete-cost-budget-entries/"},"report:1130":{"name":"Delete Cost Entries","url":"https://jonas-paprotka.de/ref/report/1130-delete-cost-entries/"},"table:350":{"name":"Dimension Combination","url":"https://jonas-paprotka.de/ref/table/350-dimension-combination/"},"table:242":{"name":"Source Code Setup","url":"https://jonas-paprotka.de/ref/table/242-source-code-setup/"},"codeunit:1103":{"name":"CA Jnl.-Post Batch","url":"https://jonas-paprotka.de/ref/codeunit/1103-ca-jnl-post-batch/"},"table:232":{"name":"Gen. Journal Batch","url":"https://jonas-paprotka.de/ref/table/232-gen-journal-batch/"},"codeunit:1105":{"name":"Transfer GL Entries to CA","url":"https://jonas-paprotka.de/ref/codeunit/1105-transfer-gl-entries-to-ca/"}},"procs":[{"name":"CheckAllocTargetSharePercent","line":37,"kind":"procedure","params":1,"steps":[[49,"ext","codeunit",130000,"AreEqual",3]]},{"name":"CheckBlockedDimCombination","line":57,"kind":"procedure","params":0,"steps":[[61,"call","CostCenterDimension",0],[61,"call","CostObjectDimension",0],[62,"call","DeleteBlockedDimCombinations",1],[65,"call","CostCenterDimension",0],[65,"call","CostObjectDimension",0],[66,"call","DeleteBlockedDimCombinations",1]]},{"name":"CheckBlockedDimensionValues","line":69,"kind":"procedure","params":1,"steps":[[76,"ext","codeunit",131001,"FindDefaultDimension",3],[81,"validate",349,"Blocked"],[82,"write",349,"Modify",1]]},{"name":"CheckCostJnlLineConsistency","line":87,"kind":"procedure","params":1,"steps":[[93,"call","CreateCostCenter",1],[94,"validate",1101,"Cost Center Code"],[99,"call","CreateCostCenter",1],[100,"validate",1101,"Bal. Cost Center Code"],[105,"validate",1101,"Cost Object Code"],[109,"validate",1101,"Bal. Cost Object Code"],[111,"write",1101,"Modify",1]]},{"name":"ClearCostJournalLines","line":114,"kind":"procedure","params":1,"steps":[[120,"write",1101,"DeleteAll",1]]},{"name":"CreateAllocSource","line":163,"kind":"procedure","params":2,"steps":[[167,"call","FindCostType",1],[171,"validate",1106,"ID"],[171,"call","LastAllocSourceID",0],[172,"validate",1106,"Level"],[172,"ext","codeunit",130440,"RandInt",1],[173,"validate",1106,"Credit to Cost Type"],[174,"write",1106,"Insert",1]]},{"name":"CreateAllocSourceWithCCenter","line":177,"kind":"procedure","params":2,"steps":[[179,"call","CreateAllocSource",2],[180,"call","UpdateAllocSourceWithCCenter",1]]},{"name":"CreateAllocSourceWithCObject","line":183,"kind":"procedure","params":2,"steps":[[185,"call","CreateAllocSource",2],[186,"call","UpdateAllocSourceWithCObject",1]]},{"name":"CreateAllocTarget","line":189,"kind":"procedure","params":5,"steps":[[193,"call","LastAllocTargetID",1],[196,"validate",1107,"ID"],[197,"validate",1107,"Line No."],[198,"validate",1107,"Target Cost Type"],[199,"validate",1107,"Base"],[200,"validate",1107,"Allocation Target Type"],[201,"write",1107,"Insert",1],[206,"validate",1107,"Share"],[207,"write",1107,"Modify",1]]},{"name":"CreateAllocTargetWithCCenter","line":210,"kind":"procedure","params":5,"steps":[[212,"call","CreateAllocTarget",5],[213,"call","UpdateAllocTargetWithCCenter",1]]},{"name":"CreateAllocTargetWithCObject","line":216,"kind":"procedure","params":5,"steps":[[218,"call","CreateAllocTarget",5],[219,"call","UpdateAllocTargetWithCObject",1]]},{"name":"CreateBalanceSheetGLAccount","line":222,"kind":"procedure","params":1,"steps":[[229,"validate",1108,"Align G/L Account"],[230,"write",1108,"Modify",1],[232,"ext","codeunit",131300,"CreateGLAccount",1],[234,"validate",15,"Income/Balance"],[235,"write",15,"Modify",1],[238,"validate",1108,"Align G/L Account"],[239,"write",1108,"Modify",1]]},{"name":"CreateCostBudgetEntry","line":242,"kind":"procedure","params":2,"steps":[[247,"call","FindCostType",1],[248,"call","FindCostCenter",1],[251,"validate",1109,"Date"],[252,"validate",1109,"Budget Name"],[253,"validate",1109,"Cost Type No."],[254,"validate",1109,"Cost Center Code"],[255,"validate",1109,"Amount"],[255,"ext","codeunit",130440,"RandDec",2],[256,"write",1109,"Insert",1]]},{"name":"CreateCostBudgetName","line":259,"kind":"procedure","params":1,"steps":[[262,"validate",1110,"Name"],[263,"ext","codeunit",131000,"GenerateRandomCode",2],[264,"validate",1110,"Description"],[265,"write",1110,"Insert",1]]},{"name":"CreateCostCenter","line":268,"kind":"procedure","params":1,"steps":[[271,"validate",1112,"Code"],[271,"ext","codeunit",131000,"GenerateRandomCode",2],[272,"validate",1112,"Line Type"],[273,"write",1112,"Insert",1]]},{"name":"CreateCostCenterFromDimension","line":276,"kind":"procedure","params":1,"steps":[[282,"call","SetAlignment",2],[284,"ext","codeunit",131001,"CreateDimensionValue",2]]},{"name":"CreateCostJournalBatch","line":288,"kind":"procedure","params":2,"steps":[[290,"call","CreateCostJnlBatchWithDelOpt",3]]},{"name":"CreateCostJournalTemplate","line":293,"kind":"procedure","params":1,"steps":[[296,"validate",1100,"Name"],[297,"ext","codeunit",131000,"GenerateRandomCode",2],[298,"write",1100,"Insert",1]]},{"name":"CreateCostJnlBatchWithDelOpt","line":301,"kind":"procedure","params":3,"steps":[[304,"validate",1102,"Journal Template Name"],[305,"validate",1102,"Delete after Posting"],[306,"validate",1102,"Name"],[306,"ext","codeunit",131000,"GenerateRandomCode",2],[307,"validate",1102,"Description"],[308,"write",1102,"Insert",1]]},{"name":"CreateCostJournalLine","line":311,"kind":"procedure","params":3,"steps":[[316,"call","FindCostType",1],[317,"call","FindCostType",1],[319,"call","CreateCostJournalLineBasic",6],[322,"call","CheckCostJnlLineConsistency",1]]},{"name":"CreateCostJournalLineBasic","line":325,"kind":"procedure","params":6,"steps":[[330,"validate",1101,"Journal Template Name"],[331,"validate",1101,"Journal Batch Name"],[333,"validate",1101,"Line No."],[333,"ext","codeunit",131000,"GetNewLineNo",2],[334,"write",1101,"Insert",1],[336,"validate",1101,"Posting Date"],[337,"validate",1101,"Document No."],[338,"validate",1101,"Cost Type No."],[339,"validate",1101,"Bal. Cost Type No."],[340,"validate",1101,"Amount"],[340,"ext","codeunit",130440,"RandInt",1],[341,"write",1101,"Modify",1]]},{"name":"CreateCostObject","line":344,"kind":"procedure","params":1,"steps":[[347,"validate",1113,"Code"],[347,"ext","codeunit",131000,"GenerateRandomCode",2],[348,"validate",1113,"Line Type"],[349,"write",1113,"Insert",1]]},{"name":"CreateCostObjectFromDimension","line":352,"kind":"procedure","params":1,"steps":[[358,"call","SetAlignment",2],[360,"ext","codeunit",131001,"CreateDimensionValue",2]]},{"name":"CreateCostType","line":365,"kind":"procedure","params":1,"steps":[[367,"call","CreateCostTypeWithGLRange",2]]},{"name":"CreateCostTypeNoGLRange","line":370,"kind":"procedure","params":1,"steps":[[373,"validate",1103,"No."],[373,"ext","codeunit",131000,"GenerateRandomCode",2],[374,"validate",1103,"Type"],[375,"validate",1103,"Combine Entries"],[376,"write",1103,"Insert",1]]},{"name":"CreateCostTypeWithCombine","line":379,"kind":"procedure","params":2,"steps":[[381,"call","CreateCostTypeWithGLRange",2],[382,"validate",1103,"Combine Entries"],[383,"write",1103,"Modify",1]]},{"name":"CreateCostTypeWithGLRange","line":386,"kind":"procedure","params":2,"steps":[[393,"call","SetAlignment",2],[394,"call","CreateIncomeStmtGLAccount",1],[400,"call","SetAlignment",2],[402,"ext","codeunit",130440,"RandInt",1],[404,"call","CreateIncomeStmtGLAccount",1],[408,"ext","codeunit",130000,"AreEqual",3],[409,"validate",1103,"G/L Account Range"],[410,"write",1103,"Modify",1]]},{"name":"CreateIncomeStmtGLAccount","line":414,"kind":"procedure","params":1,"steps":[[418,"ext","codeunit",131300,"CreateGLAccount",1],[419,"validate",15,"Income/Balance"],[420,"write",15,"Modify",1],[425,"validate",1103,"G/L Account Range"],[426,"write",1103,"Modify",1]]},{"name":"CreateJnlLine","line":431,"kind":"procedure","params":2,"steps":[[435,"call","SetupGeneralJnlBatch",1],[438,"ext","codeunit",131300,"CreateGeneralJnlLine",7],[440,"ext","codeunit",130440,"RandDec",2],[443,"validate",81,"Gen. Posting Type"],[444,"validate",81,"Gen. Bus. Posting Group"],[445,"validate",81,"Gen. Prod. Posting Group"],[446,"write",81,"Modify",1]]},{"name":"DeleteAllCostTypeEntries","line":449,"kind":"procedure","params":0,"steps":[[456,"write",1103,"DeleteAll",1]]},{"name":"DeleteCostBudgetRegEntries","line":459,"kind":"procedure","params":0,"steps":[[464,"call","DeleteCostBudgetRegEntriesFrom",1]]},{"name":"DeleteCostBudgetRegEntriesFrom","line":467,"kind":"procedure","params":1,"steps":[[473,"ext","report",1139,"InitializeRequest",2]]},{"name":"DeleteCostRegisterEntries","line":479,"kind":"procedure","params":0,"steps":[[484,"call","DeleteCostRegisterEntriesFrom",1]]},{"name":"DeleteCostRegisterEntriesFrom","line":487,"kind":"procedure","params":1,"steps":[[493,"ext","report",1130,"InitializeRequest",2]]},{"name":"DeleteBlockedDimCombinations","line":499,"kind":"procedure","params":1,"steps":[[504,"write",350,"Delete",1]]},{"name":"FindAllocSource","line":508,"kind":"procedure","params":1,"steps":[[521,"ext","codeunit",130440,"RandInt",1]]},{"name":"FindCostType","line":524,"kind":"procedure","params":1,"steps":[[526,"call","GetAllCostTypes",1],[530,"ext","codeunit",130440,"RandInt",1]]},{"name":"FindCostTypeLinkedToGLAcc","line":533,"kind":"procedure","params":1,"steps":[[542,"ext","codeunit",130440,"RandInt",1]]},{"name":"FindCostTypeWithCostCenter","line":546,"kind":"procedure","params":1,"steps":[[548,"call","GetAllCostTypes",1],[554,"ext","codeunit",130440,"RandInt",1]]},{"name":"FindCostCenter","line":557,"kind":"procedure","params":1,"steps":[[566,"ext","codeunit",130440,"RandInt",1]]},{"name":"FindCostJournalBatch","line":569,"kind":"procedure","params":2,"steps":[[571,"call","FindCostJnlBatchWithDelOption",3]]},{"name":"FindCostJnlBatchWithDelOption","line":574,"kind":"procedure","params":3,"steps":[[579,"call","CreateCostJournalBatch",2]]},{"name":"FindCostObject","line":589,"kind":"procedure","params":1,"steps":[[598,"ext","codeunit",130440,"RandInt",1]]},{"name":"FindGLAccLinkedToCostType","line":601,"kind":"procedure","params":1,"steps":[[603,"ext","codeunit",131300,"FindGLAccount",1],[608,"ext","codeunit",130440,"RandInt",1]]},{"name":"FindIncomeStmtGLAccount","line":620,"kind":"procedure","params":1,"steps":[[622,"call","GetAllIncomeStmtGLAccounts",1],[623,"ext","codeunit",130440,"RandInt",1]]},{"name":"GetAllIncomeStmtGLAccounts","line":636,"kind":"procedure","params":1,"steps":[[638,"ext","codeunit",131300,"FindGLAccount",1]]},{"name":"InitializeCASetup","line":689,"kind":"procedure","params":0,"steps":[[694,"validate",1108,"Align G/L Account"],[695,"validate",1108,"Align Cost Center Dimension"],[696,"validate",1108,"Align Cost Object Dimension"],[697,"validate",1108,"Auto Transfer from G/L"],[699,"validate",1108,"Last Allocation ID"],[701,"validate",1108,"Last Allocation Doc. No."],[702,"write",1108,"Modify",1],[704,"call","InitializeCASourceCodes",0]]},{"name":"InitializeCASourceCodes","line":707,"kind":"procedure","params":0,"steps":[[716,"ext","codeunit",131300,"CreateSourceCode",1],[717,"validate",242,"G/L Entry to CA"],[721,"ext","codeunit",131300,"CreateSourceCode",1],[722,"validate",242,"Cost Journal"],[726,"ext","codeunit",131300,"CreateSourceCode",1],[727,"validate",242,"Cost Allocation"],[732,"write",242,"Modify",1]]},{"name":"PostCostJournalLine","line":754,"kind":"procedure","params":1,"steps":[[756,"run","codeunit",1103]]},{"name":"PostGenJournalLine","line":759,"kind":"procedure","params":1,"steps":[[763,"call","CreateJnlLine",2],[764,"ext","codeunit",131300,"PostGeneralJnlLine",1]]},{"name":"SetAutotransferFromGL","line":784,"kind":"procedure","params":1,"steps":[[789,"validate",1108,"Auto Transfer from G/L"],[790,"write",1108,"Modify",1]]},{"name":"SetDefaultDimension","line":793,"kind":"procedure","params":1,"steps":[[799,"call","CostCenterDimension",0],[800,"ext","codeunit",131001,"FindDimensionValue",2],[800,"call","CostCenterDimension",0],[801,"ext","codeunit",131001,"CreateDefaultDimensionGLAcc",4],[807,"validate",1112,"Code"],[808,"validate",1112,"Line Type"],[809,"write",1112,"Insert",1],[812,"call","CheckBlockedDimensionValues",1],[813,"call","CheckBlockedDimCombination",0]]},{"name":"SetupGeneralJnlBatch","line":816,"kind":"procedure","params":1,"steps":[[820,"ext","codeunit",131300,"SelectGenJnlBatch",1],[821,"call","CreateBalanceSheetGLAccount",1],[822,"validate",232,"Bal. Account No."],[823,"write",232,"Modify",1],[825,"ext","codeunit",131300,"ClearGenJournalLines",1]]},{"name":"SetupGLAccount","line":828,"kind":"procedure","params":1,"steps":[[830,"call","FindGLAccLinkedToCostType",1],[831,"call","SetDefaultDimension",1]]},{"name":"TransferGLEntries","line":840,"kind":"procedure","params":0,"steps":[[842,"run","codeunit",1105]]},{"name":"UpdateAllocSourceWithCCenter","line":845,"kind":"procedure","params":1,"steps":[[849,"call","FindCostCenter",1],[850,"validate",1106,"Cost Center Code"],[851,"write",1106,"Modify",1]]},{"name":"UpdateAllocSourceWithCObject","line":854,"kind":"procedure","params":1,"steps":[[858,"call","FindCostObject",1],[859,"validate",1106,"Cost Object Code"],[860,"write",1106,"Modify",1]]},{"name":"UpdateAllocTargetWithCCenter","line":863,"kind":"procedure","params":1,"steps":[[867,"call","FindCostCenter",1],[868,"validate",1107,"Target Cost Center"],[869,"write",1107,"Modify",1]]},{"name":"UpdateAllocTargetWithCObject","line":872,"kind":"procedure","params":1,"steps":[[876,"call","FindCostObject",1],[877,"validate",1107,"Target Cost Object"],[878,"write",1107,"Modify",1]]},{"name":"UpdateCostTypeWithCostCenter","line":882,"kind":"procedure","params":1,"steps":[[886,"call","FindCostCenter",1],[887,"validate",1103,"Cost Center Code"],[888,"write",1103,"Modify",1]]},{"name":"UpdateCostTypeWithCostObject","line":892,"kind":"procedure","params":1,"steps":[[896,"call","FindCostObject",1],[897,"validate",1103,"Cost Object Code"],[898,"write",1103,"Modify",1]]},{"name":"ValidateEntriesTransfered","line":901,"kind":"procedure","params":0,"steps":[[917,"ext","codeunit",130000,"AreEqual",3],[919,"ext","codeunit",130000,"AreEqual",3],[920,"ext","codeunit",130000,"AreEqual",3],[924,"ext","codeunit",130000,"AreEqual",3],[925,"ext","codeunit",130000,"AreEqual",3],[927,"ext","codeunit",130000,"AreEqual",3],[929,"ext","codeunit",130000,"AreEqual",3],[931,"ext","codeunit",130000,"AreEqual",3],[933,"ext","codeunit",130000,"AreEqual",3]]},{"name":"ValidateGLAccountCostTypeRef","line":936,"kind":"procedure","params":1,"steps":[[946,"call","FindGLAccountsByCostType",2]]},{"name":"ValidateGLAccountIsIncomeStmt","line":952,"kind":"procedure","params":1,"steps":[[957,"call","FindGLAccountsByCostType",2]]},{"name":"VerifyCostTypeIntegrity","line":964,"kind":"procedure","params":0,"steps":[[969,"call","GetAllCostTypes",1]]}]}