Codeunit 18004265 EOS037 Detailed Discounts
Codeunit 18004265 EOS037 Detailed Discounts
Methods
GetDiscountString
procedure GetDiscountString(Document: Variant): Text
Parameters / Return Value
Document
VariantReturns
Text[]
GetDiscountCalcParameters
procedure GetDiscountCalcParameters(DocVariant: Variant): JsonObject
Returns a JSON object with all parameters that are required to calculate detailed discounts for the given record. Please refer to the documentation for details.
Parameters / Return Value
DocVariant
VariantThe record for which to retrieve the parameters.
Returns
JsonObjectA flat JSON object containing all the parameters.
GetDiscountSetId
procedure GetDiscountSetId(DocVariant: Variant): Guid
Returns the discount set ID that is currently in use for the given record. If the record is not supported, an empty GUID is returned. this will search only for field named EOS Discount Set ID or EOS037 Discount Set ID If you have different field name, subscribe to the event: OnGetDiscountSetIdOnBeforeFind
Parameters / Return Value
DocVariant
VariantThe record for which to retrieve the discount set ID.
Returns
GuidThe discount set ID.
EditDiscountSet
procedure EditDiscountSet(var SetId: Guid; Editable: Boolean): Boolean
Opens a page (modal) to allow the user to view or modify the given discount set interactively.
This method issues a Commit() before opening the page.
Parameters / Return Value
SetId
GuidThe ID of the set to be modified. This will be overwritten with the new set ID if the set is modified.
Editable
BooleanSpecifies if the page will be editable.
Returns
Booleantrueif the discount was changed,falseotherwise.
EditDiscountSet
procedure EditDiscountSet(var SetId: Guid; Editable: Boolean; source: Variant): Boolean
Opens a page (modal) to allow the user to view or modify the given discount set interactively.
This method issues a Commit() before opening the page.
Parameters / Return Value
SetId
GuidThe ID of the set to be modified. This will be overwritten with the new set ID if the set is modified.
Editable
BooleanSpecifies if the page will be editable.
source
VariantThe source record for which to open this page.
Returns
Booleantrueif the discount was changed,falseotherwise.
ParseDetailedDiscountString
procedure ParseDetailedDiscountString(var SetId: Guid; DetaildDiscountValue: Decimal)
Parameters / Return Value
SetId
GuidDetaildDiscountValue
Decimal
ParseDetailedDiscountString
procedure ParseDetailedDiscountString(var SetId: Guid; DetaildDiscountValue: Text)
Parameters / Return Value
SetId
GuidDetaildDiscountValue
Text[]
CalcDiscountSetId
procedure CalcDiscountSetId(var TempDiscSetEntry: Record "EOS037 Discount Set Entry"): Guid
Parameters / Return Value
TempDiscSetEntry
Record "EOS037 Discount Set Entry"Returns
Guid
ReadDiscountSet
procedure ReadDiscountSet(SetId: Guid; var TempDiscSetEntry: Record "EOS037 Discount Set Entry"): Boolean
Parameters / Return Value
SetId
GuidTempDiscSetEntry
Record "EOS037 Discount Set Entry"Returns
Boolean
WriteDiscountSet
procedure WriteDiscountSet(var TempDiscSetEntry: Record "EOS037 Discount Set Entry"): Guid
Parameters / Return Value
TempDiscSetEntry
Record "EOS037 Discount Set Entry"Returns
Guid
MergeDiscountSets
procedure MergeDiscountSets(var SetId: Guid; NewSetId: Guid; SourceCode: Code[10]): Boolean
Parameters / Return Value
SetId
GuidNewSetId
GuidSourceCode
Code[10]Returns
Boolean
CalcTotalDiscountPercentage
procedure CalcTotalDiscountPercentage(SetId: Guid; Params: JsonObject): Decimal
Parameters / Return Value
SetId
GuidParams
JsonObjectReturns
Decimal
CalcDiscountAmount
procedure CalcDiscountAmount(SetId: Guid; Params: JsonObject; ExcludePosted: enum "EOS066 TriState Boolean"): Decimal
Parameters / Return Value
SetId
GuidParams
JsonObjectExcludePosted
enum "EOS066 TriState Boolean"Returns
Decimal
CalcRoundedDiscountAmount
procedure CalcRoundedDiscountAmount(SetId: Guid; Params: JsonObject; ExcludePosted: enum "EOS066 TriState Boolean"): Decimal
Parameters / Return Value
SetId
GuidParams
JsonObjectExcludePosted
enum "EOS066 TriState Boolean"Returns
Decimal
InitCurrency
procedure InitCurrency(var Currency: Record Currency; CalcParams: JsonObject)
Initializes a currency from a discount calculation parameter object.
Parameters / Return Value
Currency
Record "Currency"The output currency.
CalcParams
JsonObjectThe discount calculation parameter object.
ApplyPurchHeaderDiscSet
procedure ApplyPurchHeaderDiscSet(var PurchHeader: Record "Purchase Header"; DiscSetId: Guid)
Applies a given discount set to a purchase header, recalculating discounts as needed. Use this instead of directly validating the “EOS Discount Set ID” field on the header.
Parameters / Return Value
PurchHeader
Record "Purchase Header"The purchase header to apply the discount set to.
DiscSetId
GuidThe ID of the discount set to apply.
ApplySalesHeaderDiscSet
procedure ApplySalesHeaderDiscSet(var SalesHeader: Record "Sales Header"; DiscSetId: Guid)
Applies a given discount set to a sales header, recalculating discounts as needed. Use this instead of directly validating the “EOS Discount Set ID” field on the header.
Parameters / Return Value
SalesHeader
Record "Sales Header"The sales header to apply the discount set to.
DiscSetId
GuidThe ID of the discount set to apply.
CalculateDiscountLinesPreview
procedure CalculateDiscountLinesPreview(var TempDiscSetEntry: Record "EOS037 Discount Set Entry"; SourceRec: Variant)
Parameters / Return Value
TempDiscSetEntry
Record "EOS037 Discount Set Entry"SourceRec
Variant
Events
OnBeforeParseDiscountValue
local procedure OnBeforeParseDiscountValue(var TmpDiscSetEntry: Record "EOS037 Discount Set Entry"; StringValue: Text; var Parsed: Boolean; var Handled: Boolean)
Parameters / Return Value
TmpDiscSetEntry
Record "EOS037 Discount Set Entry"StringValue
Text[]Parsed
BooleanHandled
Boolean
OnGetDiscountCalcParameters
local procedure OnGetDiscountCalcParameters(DocumentLine: Variant; var Parameters: JsonObject; var Handled: Boolean)
Parameters / Return Value
DocumentLine
VariantParameters
JsonObjectHandled
Boolean
OnAfterGetDiscountCalcParameters
local procedure OnAfterGetDiscountCalcParameters(DocumentLine: Variant; var Parameters: JsonObject)
Parameters / Return Value
DocumentLine
VariantParameters
JsonObject
OnBeforeParseDetailedDiscountString
local procedure OnBeforeParseDetailedDiscountString(var SetId: Guid; DetaildDiscountValue: Text; FromUserUpdate: Boolean)
Raised before parsing the discount % value(s) in order to search for or insert the discount set.
Parameters / Return Value
SetId
GuidThe Discount Set Id for the parsed discounts.
DetaildDiscountValue
Text[]The string with the detailed discount percents (ex. ‘10 + 5’ or ‘20’).
FromUserUpdate
BooleanSpecifies whether the parsing was triggered by a system update or by user input.
OnGetDiscountSetIdOnBeforeFind
local procedure OnGetDiscountSetIdOnBeforeFind(DocVariant: Variant; var ReturnValue: Guid; var Handled: Boolean)
Raised before find on getting the discount set Id. Use this for getting your custom discount set id
Parameters / Return Value
DocVariant
VariantReturnValue
GuidHandled
Boolean
OnAfterAssignUniqueId
local procedure OnAfterAssignUniqueId(var DiscSetEntry: Record "EOS037 Discount Set Entry")
Raised after a unique ID (if necessary) has been assigned to a discount set entry. Use this to override the default unique ID assignment behaviour. Be extra careful to ensure uniqueness when uniqueness is required.
Parameters / Return Value
DiscSetEntry
Record "EOS037 Discount Set Entry"The discount set entry.
OnAfterWriteDiscountSet
local procedure OnAfterWriteDiscountSet(SetId: Guid)
Raised after a discount set has been written to the database.
Parameters / Return Value
SetId
GuidThe ID of the set that was written.
OnBeforeCalculateDiscountSetEntry
local procedure OnBeforeCalculateDiscountSetEntry(var DiscSetEntry: Record "EOS037 Discount Set Entry"; var Parameters: Record "EOS037 Calc. Parameters"; var BaseAmount: Decimal; var Handled: Boolean)
Integration event raised before calculating a discount set entry to allow custom discount calculation logic. This event allows external code to override the default discount calculation behavior for specific discount types.
Parameters / Return Value
DiscSetEntry
Record "EOS037 Discount Set Entry"The discount set entry being calculated. Contains the discount type, value, and other parameters.
Parameters
Record "EOS037 Calc. Parameters"The calculation parameters including quantities, amounts, and other context data.
BaseAmount
DecimalThe base amount on which the discount calculation is performed.
Handled
BooleanSet to true to indicate that custom calculation logic has been applied and default calculation should be skipped.
OnAfterCalculateDiscountSetEntry
local procedure OnAfterCalculateDiscountSetEntry(var DiscSetEntry: Record "EOS037 Discount Set Entry"; Parameters: Record "EOS037 Calc. Parameters"; BaseAmount: Decimal)
Integration event raised after calculating a discount set entry to allow additional processing or validation. This event allows external code to modify the calculated discount amount or perform additional operations after the default discount calculation has been completed.
Parameters / Return Value
DiscSetEntry
Record "EOS037 Discount Set Entry"The discount set entry that has been calculated. Contains the calculated discount amount and other fields.
Parameters
Record "EOS037 Calc. Parameters"The calculation parameters that were used in the calculation.
BaseAmount
DecimalThe base amount that was used for the discount calculation.
Feedback
Was this page helpful?
Glad to hear it! Please tell us how we can improve.
Sorry to hear that. Please tell us how we can improve.