{"title":"Codeunit 56 Sales - Calc Discount By Type, extension points 29","url":"https://jonas-paprotka.de/ref/codeunit/56-sales-calc-discount-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":56,"name":"Sales - Calc Discount By Type","app":"Base Application","url":"https://jonas-paprotka.de/ref/codeunit/56-sales-calc-discount-by-type/"},"major":29,"source":{"url":"https://jonas-paprotka.de/ref/codeunit/56-sales-calc-discount-by-type/source/","path":"src/Layers/W1/BaseApp/Sales/Document/SalesCalcDiscountByType.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:36":{"name":"Sales Header","url":"https://jonas-paprotka.de/ref/table/36-sales-header/"},"codeunit:65":{"name":"Discount Notification Mgt.","url":"https://jonas-paprotka.de/ref/codeunit/65-discount-notification-mgt/"},"table:37":{"name":"Sales Line","url":"https://jonas-paprotka.de/ref/table/37-sales-line/"},"table:290":{"name":"VAT Amount Line","url":"https://jonas-paprotka.de/ref/table/290-vat-amount-line/"},"codeunit:60":{"name":"Sales-Calc. Discount","url":"https://jonas-paprotka.de/ref/codeunit/60-sales-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":20,"kind":"trigger","steps":[[28,"call","ApplyDefaultInvoiceDiscount",2]]},{"name":"ApplyDefaultInvoiceDiscount","line":48,"kind":"procedure","access":"internal","params":3,"steps":[[52,"call","ShouldRedistributeInvoiceDiscountAmount",1],[56,"event","OnBeforeApplyDefaultInvoiceDiscount",1],[59,"write",36,"Modify"],[62,"call","ApplyInvDiscBasedOnAmt",2],[64,"call","ApplyInvDiscBasedOnPct",1],[67,"call","ResetRecalculateInvoiceDisc",1]]},{"name":"ApplyInvDiscBasedOnAmt","line":75,"kind":"procedure","params":2,"steps":[[83,"event","OnBeforeApplyInvDiscBasedOnAmt",0],[86,"ext","codeunit",65,"NotifyAboutMissingSetup",4],[93,"ext","table",37,"CalcVATAmountLines",4],[95,"ext","table",290,"GetTotalInvDiscBaseAmount",2],[100,"ext","table",290,"SetInvoiceDiscountAmount",4],[103,"ext","table",37,"UpdateVATOnLines",4],[108,"call","ResetRecalculateInvoiceDisc",1],[110,"write",36,"Modify"]]},{"name":"ApplyInvDiscBasedOnPct","line":113,"kind":"procedure","access":"local","params":1,"steps":[[122,"ext","codeunit",60,"CalculateInvoiceDiscountOnLine",1],[124,"run","codeunit",60]]},{"name":"GetCustInvoiceDiscountPct","line":134,"kind":"procedure","params":1,"steps":[[153,"event","OnGetCustInvoiceDiscountPctOnCaseInvDiscCalcPercent",0],[156,"call","CustInvDiscRecExists",1],[166,"call","CalcAmountWithDiscountAllowed",3]]},{"name":"ShouldRedistributeInvoiceDiscountAmount","line":186,"kind":"procedure","params":1,"steps":[[193,"event","OnBeforeShouldRedistributeInvoiceDiscountAmount",1],[206,"call","InvoiceDiscServiceChargeIsAllowed",1],[212,"call","InvoiceDiscServiceChargeIsAllowed",1],[215,"ext","codeunit",9179,"IsFoundationEnabled",0],[218,"call","InvoiceDiscIsAllowed",1],[219,"event","OnShouldRedistributeInvoiceDiscountAmountOnCaseInvDiscCalculationNone",0]]},{"name":"ResetRecalculateInvoiceDisc","line":231,"kind":"procedure","params":1,"steps":[[239,"write",37,"ModifyAll"],[241,"event","OnAfterResetRecalculateInvoiceDisc",0]]},{"name":"InvoiceDiscIsAllowed","line":262,"kind":"procedure","params":1,"steps":[[270,"call","CustInvDiscRecExists",1]]},{"name":"InvoiceDiscServiceChargeIsAllowed","line":285,"kind":"procedure","access":"local","params":1,"steps":[[291,"call","CustInvDiscServiceChargeExists",1]]}]}