Table of Contents

KVSKBAPurchaseLinePrice

Implements #437dbf0e84ff417a965ded2bb9650972#"Line With Price" .

Procedures

GetTableNo() : Integer

Summary: Returns the table number of the purchase line used by this implementation.

procedure GetTableNo(): Integer

Returns: The database table number for the Purchase Line table.

SetLine(Enum Price Type, Variant) :

procedure SetLine(PriceType: Enum "Price Type"; Line: Variant): 

SetLine(Enum Price Type, Variant, Variant) :

procedure SetLine(PriceType: Enum "Price Type"; Header: Variant; Line: Variant): 

SetSources(Codeunit Price Source List) :

procedure SetSources(var NewPriceSourceList: Codeunit "Price Source List"): 

SetPurchaseQtyInvoice(ErrorInfo) :

Summary: Sets the Qty. to Invoice on the purchase line identified by the error info to the maximum invoiceable quantity.

procedure SetPurchaseQtyInvoice(ErrorInfo: ErrorInfo): 

Parameters:

  • ErrorInfo: The error info record identifying the affected purchase line.

Remarks: Intended as an error action callback to resolve quantity-to-invoice validation errors.

SetPurchaseReceiveQty(ErrorInfo) :

Summary: Sets the Qty. to Receive on the purchase line identified by the error info to the outstanding quantity.

procedure SetPurchaseReceiveQty(ErrorInfo: ErrorInfo): 

Parameters:

  • ErrorInfo: The error info record identifying the affected purchase line.

Remarks: Intended as an error action callback to resolve quantity-to-receive validation errors.

GetLine(Variant) :

Summary: Returns the current purchase line as a Variant.

procedure GetLine(var Line: Variant): 

Parameters:

  • Line: Receives the current purchase line record.

GetLine(Variant, Variant) :

Summary: Returns the current purchase header and purchase line as Variants.

procedure GetLine(var Header: Variant; var Line: Variant): 

Parameters:

  • Header: Receives the current purchase header record.
  • Line: Receives the current purchase line record.

GetPriceType() : Enum

Summary: Returns the current price type assigned to this implementation instance.

procedure GetPriceType(): Enum Price Type

Returns: The current Price Type (Purchase).

IsPriceUpdateNeeded(Enum Price Amount Type, Boolean, Integer) : Boolean

procedure IsPriceUpdateNeeded(AmountType: Enum "Price Amount Type"; FoundPrice: Boolean; CalledByFieldNo: Integer): Boolean

IsDiscountAllowed() : Boolean

Summary: Determines whether a line discount may be applied to the current purchase line.

procedure IsDiscountAllowed(): Boolean

Returns: True if a line discount is allowed; false otherwise.

Remarks: Returns true when discounts are allowed (as set by the last SetPrice call), or when no price has been calculated yet. Raises OnAfterIsDiscountAllowed to allow subscribers to override the result.

Verify() :

Summary: Validates mandatory fields on the purchase line and purchase header before price calculation.

procedure Verify(): 

Remarks: Tests that Qty. per Unit of Measure is populated on the purchase line, and that Currency Factor is present on the header when a Currency Code is set. Raises OnBeforeVerify (IsHandled pattern) to allow subscribers to skip the default validation.

SetAssetSourceForSetup(Record Dtld. Price Calculation Setup) : Boolean

Summary: Fills the detailed price calculation setup record with asset source information from the current purchase line.

procedure SetAssetSourceForSetup(var DtldPriceCalculationSetup: Record "Dtld. Price Calculation Setup"): Boolean

Parameters:

  • DtldPriceCalculationSetup: The setup record to populate with type, method, asset type, and asset number.

Returns: True if a matching price source group was found; false otherwise.

Remarks: Called by the price calculation framework to resolve the applicable calculation method.

GetAssetType() : Enum

Summary: Returns the price asset type corresponding to the line type on the current purchase line.

procedure GetAssetType(): Enum Price Asset Type

Returns: The Price Asset Type (Item, G/L Account, Resource, or blank) derived from the purchase line type.

Remarks: Raises OnAfterGetAssetType to allow subscribers to override the returned asset type.

CopyToBuffer(Codeunit Price Calculation Buffer Mgt.) : Boolean

procedure CopyToBuffer(var PriceCalculationBufferMgt: Codeunit "Price Calculation Buffer Mgt."): Boolean

SetPrice(Enum Price Amount Type, Record Price List Line) :

procedure SetPrice(AmountType: Enum "Price Amount Type"; PriceListLine: Record "Price List Line"): 

ValidatePrice(Enum Price Amount Type) :

procedure ValidatePrice(AmountType: Enum "Price Amount Type"): 

Update(Enum Price Amount Type) :

procedure Update(AmountType: Enum "Price Amount Type"): 

Events

OnAfterAddSources(Record Purchase Header, Record Purchase Line, Enum Price Type, Codeunit Price Source List) :

[IntegrationEvent(false, false)]
local procedure OnAfterAddSources(PurchaseHeader: Record "Purchase Header"; PurchaseLine: Record "Purchase Line"; PriceType: Enum "Price Type"; var PriceSourceList: Codeunit "Price Source List"): 

OnAfterFillBuffer(Record Price Calculation Buffer, Record Purchase Header, Record Purchase Line) :

Summary: Event is raised after the price calculation buffer has been filled from the purchase header and purchase line.

[IntegrationEvent(false, false)]
local procedure OnAfterFillBuffer(var PriceCalculationBuffer: Record "Price Calculation Buffer"; PurchaseHeader: Record "Purchase Header"; PurchaseLine: Record "Purchase Line"): 

Parameters:

  • PriceCalculationBuffer: The price calculation buffer that was populated.
  • PurchaseHeader: The current purchase header.
  • PurchaseLine: The current purchase line.

Remarks: Subscribe to this event to set additional fields on the price calculation buffer.

OnAfterIsDiscountAllowed(Record Purchase Line, Boolean, Boolean) :

Summary: Event is raised after determining whether a line discount is allowed on the purchase line.

[IntegrationEvent(false, false)]
local procedure OnAfterIsDiscountAllowed(PurchaseLine: Record "Purchase Line"; PriceCalculated: Boolean; var Result: Boolean): 

Parameters:

  • PurchaseLine: The purchase line being evaluated.
  • PriceCalculated: True if a price has already been calculated for this line.
  • Result: The determined result; set to override whether discounts are allowed.

Remarks: Subscribe to this event to override the default discount-allowed logic.

OnAfterGetAssetType(Record Purchase Line, Enum Price Asset Type) :

[IntegrationEvent(false, false)]
local procedure OnAfterGetAssetType(PurchaseLine: Record "Purchase Line"; var AssetType: Enum "Price Asset Type"): 

OnAfterGetDocumentDate(Date, Record Purchase Header, Record Purchase Line) :

Summary: Event is raised after the document date has been determined for price calculation.

[IntegrationEvent(false, false)]
local procedure OnAfterGetDocumentDate(var DocumentDate: Date; PurchaseHeader: Record "Purchase Header"; PurchaseLine: Record "Purchase Line"): 

Parameters:

  • DocumentDate: The resolved document date; can be overridden by subscribers.
  • PurchaseHeader: The purchase header providing the date context.
  • PurchaseLine: The current purchase line.

Remarks: Subscribe to this event to provide a custom document date for price lookups.

OnAfterIsPriceUpdateNeeded(Enum Price Amount Type, Boolean, Integer, Record Purchase Line, Boolean, Boolean) :

[IntegrationEvent(false, false)]
local procedure OnAfterIsPriceUpdateNeeded(AmountType: Enum "Price Amount Type"; FoundPrice: Boolean; CalledByFieldNo: Integer; PurchaseLine: Record "Purchase Line"; var Result: Boolean; IsSKU: Boolean): 

OnAfterValidatePrice(Record Purchase Line, Enum Price Type, Enum Price Amount Type, Record Purchase Header) :

[IntegrationEvent(false, false)]
local procedure OnAfterValidatePrice(var PurchaseLine: Record "Purchase Line"; CurrPriceType: Enum "Price Type"; AmountType: Enum "Price Amount Type"; var PurchaseHeader: Record "Purchase Header"): 

OnBeforeVerify(Record Purchase Header, Record Purchase Line, Boolean) :

Summary: Event is raised before the mandatory field validation on the purchase line and purchase header.

[IntegrationEvent(false, false)]
local procedure OnBeforeVerify(PurchaseHeader: Record "Purchase Header"; PurchaseLine: Record "Purchase Line"; var IsHandled: Boolean): 

Parameters:

  • PurchaseHeader: The purchase header to be validated.
  • PurchaseLine: The purchase line to be validated.
  • IsHandled: Set to true to skip the default validation.

Remarks: Set IsHandled to true to prevent the default Qty. per Unit of Measure and Currency Factor checks from executing.

OnBeforeSetPrice(Record Purchase Line, Record Price List Line, Enum Price Amount Type, Boolean, Enum Price Type, Record Purchase Header) :

[IntegrationEvent(false, false)]
local procedure OnBeforeSetPrice(var PurchaseLine: Record "Purchase Line"; PriceListLine: Record "Price List Line"; AmountType: Enum "Price Amount Type"; var IsHandled: Boolean; CurrPriceType: Enum "Price Type"; var PurchaseHeader: Record "Purchase Header"): 

OnBeforeCopyToBuffer(Record Purchase Header, Record Purchase Line) :

Summary: Event is raised before the price calculation buffer is filled from the purchase header and purchase line.

[IntegrationEvent(false, false)]
local procedure OnBeforeCopyToBuffer(var PurchaseHeader: Record "Purchase Header"; var PurchaseLine: Record "Purchase Line"): 

Parameters:

  • PurchaseHeader: The purchase header providing document-level data.
  • PurchaseLine: The purchase line providing line-level data.

Remarks: Subscribe to this event to modify the purchase header or line data before it is copied to the buffer.

OnAfterSetPrice(Record Purchase Line, Record Price List Line, Enum Price Amount Type) :

[IntegrationEvent(false, false)]
local procedure OnAfterSetPrice(var PurchaseLine: Record "Purchase Line"; PriceListLine: Record "Price List Line"; AmountType: Enum "Price Amount Type"): 

OnAfterUpdate(Record Purchase Line, Enum Price Type, Enum Price Amount Type, Record Purchase Header) :

[IntegrationEvent(false, false)]
local procedure OnAfterUpdate(var PurchaseLine: Record "Purchase Line"; CurrPriceType: Enum "Price Type"; AmountType: Enum "Price Amount Type"; var PurchaseHeader: Record "Purchase Header"): 

KVSKBAOnGetVendNoForPurchaseHeader(Record Purchase Header, Code[20]) :

Summary: Event is raised when the vendor number is being resolved for price source lookup on a purchase header.

[IntegrationEvent(false, false)]
local procedure KVSKBAOnGetVendNoForPurchaseHeader(var PurchaseHeader: Record "Purchase Header"; var VendorNo: Code[20]): 

Parameters:

  • PurchaseHeader: The purchase header for which the vendor number is being resolved.
  • VendorNo: The resolved vendor number; set to override with a custom value.

Remarks: Subscribe to this event to provide a custom vendor number for price source resolution, overriding the default Buy-from or Pay-to vendor logic.

KVSKBAOnGetContactNoForPurchaseHeader(Record Purchase Header, Code[20]) :

Summary: Event is raised when the contact number is being resolved for price source lookup on a purchase header.

[IntegrationEvent(false, false)]
local procedure KVSKBAOnGetContactNoForPurchaseHeader(var PurchaseHeader: Record "Purchase Header"; var ContactNo: Code[20]): 

Parameters:

  • PurchaseHeader: The purchase header for which the contact number is being resolved.
  • ContactNo: The resolved contact number; set to override with a custom value.

Remarks: Subscribe to this event to provide a custom contact number for price source resolution, overriding the default Buy-from or Pay-to contact logic.

OnSetPriceOriginFromPriceListLineOnBeforePriceListLineTypeCaseElse(Record Purchase Line, Record Price List Line, Enum Price Amount Type) :

[IntegrationEvent(false, false)]
local procedure OnSetPriceOriginFromPriceListLineOnBeforePriceListLineTypeCaseElse(var PurchaseLine: Record "Purchase Line"; PriceListLine: Record "Price List Line"; AmountType: Enum "Price Amount Type"):