{"title":"Codeunit 66 Purch - Calc Disc. By Type, extension points 29","url":"https://jonas-paprotka.de/ref/codeunit/66-purch-calc-disc-by-type/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":66,"name":"Purch - Calc Disc. By Type","app":"Base Application","url":"https://jonas-paprotka.de/ref/codeunit/66-purch-calc-disc-by-type/"},"major":29,"source":{"url":"https://jonas-paprotka.de/ref/codeunit/66-purch-calc-disc-by-type/source/","path":"src/Layers/W1/BaseApp/Purchases/Document/PurchCalcDiscByType.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:65":{"name":"Discount Notification Mgt.","url":"https://jonas-paprotka.de/ref/codeunit/65-discount-notification-mgt/"},"table:39":{"name":"Purchase Line","url":"https://jonas-paprotka.de/ref/table/39-purchase-line/"},"table:290":{"name":"VAT Amount Line","url":"https://jonas-paprotka.de/ref/table/290-vat-amount-line/"},"table:38":{"name":"Purchase Header","url":"https://jonas-paprotka.de/ref/table/38-purchase-header/"},"codeunit:70":{"name":"Purch.-Calc.Discount","url":"https://jonas-paprotka.de/ref/codeunit/70-purch-calc-discount/"},"codeunit:9179":{"name":"Application Area Mgmt. Facade","url":"https://jonas-paprotka.de/ref/codeunit/9179-application-area-mgmt-facade/"}},"procs":[{"name":"OnRun","line":17,"kind":"trigger","steps":[[25,"call","ApplyDefaultInvoiceDiscount",2]]},{"name":"ApplyDefaultInvoiceDiscount","line":34,"kind":"procedure","params":2,"steps":[[38,"call","ShouldRedistributeInvoiceDiscountAmount",1],[42,"event","OnBeforeApplyDefaultInvoiceDiscount",1],[45,"call","ApplyInvDiscBasedOnAmt",2],[47,"call","ApplyInvDiscBasedOnPct",1],[49,"call","ResetRecalculateInvoiceDisc",1]]},{"name":"ApplyInvDiscBasedOnAmt","line":52,"kind":"procedure","params":2,"steps":[[61,"ext","codeunit",65,"NotifyAboutMissingSetup",4],[68,"ext","table",39,"CalcVATAmountLines",4],[70,"ext","table",290,"GetTotalInvDiscBaseAmount",2],[75,"ext","table",290,"SetInvoiceDiscountAmount",4],[78,"ext","table",39,"UpdateVATOnLines",4],[83,"call","ResetRecalculateInvoiceDisc",1],[85,"write",38,"Modify"]]},{"name":"ApplyInvDiscBasedOnPct","line":88,"kind":"procedure","access":"local","params":1,"steps":[[95,"run","codeunit",70]]},{"name":"GetVendInvoiceDiscountPct","line":100,"kind":"procedure","params":1,"steps":[[118,"call","VendorInvDiscRecExists",1],[128,"call","CalcAmountWithDiscountAllowed",3]]},{"name":"ShouldRedistributeInvoiceDiscountAmount","line":143,"kind":"procedure","params":1,"steps":[[150,"event","OnBeforeShouldRedistributeInvoiceDiscountAmount",1],[164,"ext","codeunit",9179,"IsFoundationEnabled",0]]},{"name":"ResetRecalculateInvoiceDisc","line":173,"kind":"procedure","params":1,"steps":[[178,"event","OnResetRecalculateInvoiceDiscOnAfterSetLoadFields",0],[182,"write",39,"ModifyAll"],[184,"event","OnAfterResetRecalculateInvoiceDisc",0]]},{"name":"InvoiceDiscIsAllowed","line":195,"kind":"procedure","params":1,"steps":[[203,"call","VendorInvDiscRecExists",1],[204,"event","OnAfterInvoiceDiscIsAllowed",0]]}]}