Codeunit 18004265 EOS037 Detailed Discounts

Codeunit 18004265 EOS037 Detailed Discounts

Methods

GetDiscountString

procedure GetDiscountString(Document: Variant): Text

Parameters / Return Value

  • Document Variant

  • Returns 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 Variant

    The record for which to retrieve the parameters.

  • Returns JsonObject

    A 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 Variant

    The record for which to retrieve the discount set ID.

  • Returns Guid

    The 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 Guid

    The ID of the set to be modified. This will be overwritten with the new set ID if the set is modified.

  • Editable Boolean

    Specifies if the page will be editable.

  • Returns Boolean

    true if the discount was changed, false otherwise.


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 Guid

    The ID of the set to be modified. This will be overwritten with the new set ID if the set is modified.

  • Editable Boolean

    Specifies if the page will be editable.

  • source Variant

    The source record for which to open this page.

  • Returns Boolean

    true if the discount was changed, false otherwise.


ParseDetailedDiscountString

procedure ParseDetailedDiscountString(var SetId: Guid; DetaildDiscountValue: Decimal)

Parameters / Return Value

  • SetId Guid

  • DetaildDiscountValue Decimal


ParseDetailedDiscountString

procedure ParseDetailedDiscountString(var SetId: Guid; DetaildDiscountValue: Text)

Parameters / Return Value

  • SetId Guid

  • DetaildDiscountValue 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 Guid

  • TempDiscSetEntry 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 Guid

  • NewSetId Guid

  • SourceCode Code[10]

  • Returns Boolean


CalcTotalDiscountPercentage

procedure CalcTotalDiscountPercentage(SetId: Guid; Params: JsonObject): Decimal

Parameters / Return Value

  • SetId Guid

  • Params JsonObject

  • Returns Decimal


CalcDiscountAmount

procedure CalcDiscountAmount(SetId: Guid; Params: JsonObject; ExcludePosted: enum "EOS066 TriState Boolean"): Decimal

Parameters / Return Value

  • SetId Guid

  • Params JsonObject

  • ExcludePosted enum "EOS066 TriState Boolean"

  • Returns Decimal


CalcRoundedDiscountAmount

procedure CalcRoundedDiscountAmount(SetId: Guid; Params: JsonObject; ExcludePosted: enum "EOS066 TriState Boolean"): Decimal

Parameters / Return Value

  • SetId Guid

  • Params JsonObject

  • ExcludePosted 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 JsonObject

    The 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 Guid

    The 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 Guid

    The 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 Boolean

  • Handled Boolean


OnGetDiscountCalcParameters

local procedure OnGetDiscountCalcParameters(DocumentLine: Variant; var Parameters: JsonObject; var Handled: Boolean)

Parameters / Return Value

  • DocumentLine Variant

  • Parameters JsonObject

  • Handled Boolean


OnAfterGetDiscountCalcParameters

local procedure OnAfterGetDiscountCalcParameters(DocumentLine: Variant; var Parameters: JsonObject)

Parameters / Return Value

  • DocumentLine Variant

  • Parameters 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 Guid

    The Discount Set Id for the parsed discounts.

  • DetaildDiscountValue Text

    The string with the detailed discount percents (ex. ‘10 + 5’ or ‘20’).

  • FromUserUpdate Boolean

    Specifies 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 Variant

  • ReturnValue Guid

  • Handled 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 Guid

    The ID of the set that was written.



EOS Labs -