Skip to content

KVSKBASalesContractLinePrice#

Implements [#437dbf0e84ff417a965ded2bb9650972#Shipment Method ](https://github.com/search?q=Table+%23437dbf0e84ff417a965ded2bb9650972%23Shipment+Method+repo%3AStefanMaron%2FMSDyn365BC.Code.History&type=Code) .

Procedures#

GetTableNo() : Integer#

Summary: Gets the table number for the sales contract line.

procedure GetTableNo(): Integer

Returns: Integer representing the database table number for Sales Contract Line

Remarks: This procedure is part of the "Line With Price" interface implementation and returns the table ID (Database::KVSKBASalesContractLine) to identify which document line type this price calculation handler supports. The price calculation framework uses this to route price calculations to the correct handler for KUMAVISION sales contract lines.

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"): 

GetLine(Variant) :#

Summary: Retrieves the current sales contract line with updated price information.

procedure GetLine(var Line: Variant): 

Parameters:

  • Line: Output variant that will receive the Sales Contract Line record

Remarks: This procedure returns the sales contract line that was set via SetLine, potentially with updated price, discount, or price unit information after price calculation. The price calculation framework uses this to retrieve the modified line after applying prices. The line is returned as a variant to maintain interface compatibility with the "Line With Price" interface.

GetLine(Variant, Variant) :#

Summary: Retrieves the current sales contract header and line with updated price information.

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

Parameters:

  • Header: Output variant that will receive the Sales Contract Header record
  • Line: Output variant that will receive the Sales Contract Line record

Remarks: This procedure returns both the sales contract header and line that were set via SetLine. The header provides document-level context while the line contains the updated price information. This overload is used when both header and line context are needed after price calculation, such as for validations or further processing that requires document-level information.

GetPriceType() : Enum#

Summary: Gets the current price type being used for price calculation.

procedure GetPriceType(): Enum Price Type

Returns: Price Type enum indicating Sale or Purchase

Remarks: This procedure returns the price type (Sale or Purchase) that was set via SetLine. For sales contracts, this is typically Sale price type. The price calculation framework uses this to identify which price lists and calculation methods to apply. The price type determines whether sales prices (Unit Price) or purchase costs are calculated.

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 line discounts are allowed for the sales contract line.

procedure IsDiscountAllowed(): Boolean

Returns: Boolean indicating whether discounts are allowed

Remarks: This procedure returns true if no price has been calculated yet (GlobalPriceCalculated is false), allowing discounts to be applied before or independently of price calculation. Once a price is calculated, discount allowance is determined by other factors. The OnAfterIsDiscountAllowed event allows customization of this behavior. This is used by the price calculation framework to determine whether to search for and apply discount price list lines.

Verify() :#

Summary: Verifies that the sales contract line has required fields populated for price calculation.

procedure Verify(): 

Remarks: This procedure validates that the Qty. per Unit of Measure field is filled on the sales contract line. This field is essential for price calculation as it's used to convert quantities between different units of measure. The OnBeforeVerify event allows subscribers to bypass or extend this validation. The price calculation framework calls this before performing calculations to ensure data integrity. If the field is blank, a test field error is raised.

SetAssetSourceForSetup(Record Dtld. Price Calculation Setup) : Boolean#

Summary: Sets up the asset source information for price calculation setup selection.

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

Parameters:

  • DtldPriceCalculationSetup: Detailed Price Calculation Setup record to populate with asset source information

Returns: Boolean indicating whether a valid source group was found

Remarks: This procedure initializes the Detailed Price Calculation Setup record with the price type, calculation method from the contract line, asset type (Item, Resource, G/L Account, or Item Price Group), and asset number. It then calls GetSourceGroup to determine the appropriate source group from the price source list. The price calculation framework uses this to identify which price calculation implementation to use (e.g., Best Price, Lowest Price) based on the configuration for the asset and source combination.

GetAssetType() : Enum#

Summary: Gets the asset type for price calculation based on the contract line type.

procedure GetAssetType(): Enum Price Asset Type

Returns: Price Asset Type enum value (Item, Resource, G/L Account, Item Price Group, or blank)

Remarks: This procedure maps the sales contract line type to the corresponding price asset type used by the price calculation framework. It supports Item, Resource, G/L Account, and KUMAVISION-specific Item Price Group types. The OnAfterGetAssetType event allows customization of the asset type mapping. The price calculation framework uses the asset type to determine which price list lines are applicable, making it a key identifier in the price calculation architecture for sales contracts.

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#

OnAfterGetAssetType(Record KVSKBASalesContractLine, Enum Price Asset Type) :#

[IntegrationEvent(false, false)]
local procedure OnAfterGetAssetType(KVSKBASalesContractLine: Record "KVSKBASalesContractLine"; var AssetType: Enum "Price Asset Type"): 
[EventSubscriber(ObjectType::Codeunit, Codeunit::"KVSKBASalesContractLinePrice", 'OnAfterGetAssetType', '', false, false)]
local procedure DoSomethingOnAfterGetAssetType(KVSKBASalesContractLine: Record "KVSKBASalesContractLine"; var AssetType: Enum "Price Asset Type")
begin
end;

OnAfterAddSources(Record KVSKBASalesContractHeader, Record KVSKBASalesContractLine, Enum Price Type, Codeunit Price Source List) :#

[IntegrationEvent(false, false)]
local procedure OnAfterAddSources(SalesContractHeader: Record "KVSKBASalesContractHeader"; KVSKBASalesContractLine: Record "KVSKBASalesContractLine"; PriceType: Enum "Price Type"; var PriceSourceList: Codeunit "Price Source List"): 
[EventSubscriber(ObjectType::Codeunit, Codeunit::"KVSKBASalesContractLinePrice", 'OnAfterAddSources', '', false, false)]
local procedure DoSomethingOnAfterAddSources(SalesContractHeader: Record "KVSKBASalesContractHeader"; KVSKBASalesContractLine: Record "KVSKBASalesContractLine"; PriceType: Enum "Price Type"; var PriceSourceList: Codeunit "Price Source List")
begin
end;

OnAfterFillBuffer(Record Price Calculation Buffer, Record KVSKBASalesContractHeader, Record KVSKBASalesContractLine) :#

Summary: Integration event raised after the price calculation buffer has been filled with sales contract data.

[IntegrationEvent(false, false)]
local procedure OnAfterFillBuffer(var PriceCalculationBuffer: Record "Price Calculation Buffer"; SalesContractHeader: Record "KVSKBASalesContractHeader"; KVSKBASalesContractLine: Record "KVSKBASalesContractLine"): 
[EventSubscriber(ObjectType::Codeunit, Codeunit::"KVSKBASalesContractLinePrice", 'OnAfterFillBuffer', '', false, false)]
local procedure DoSomethingOnAfterFillBuffer(var PriceCalculationBuffer: Record "Price Calculation Buffer"; SalesContractHeader: Record "KVSKBASalesContractHeader"; KVSKBASalesContractLine: Record "KVSKBASalesContractLine")
begin
end;

Parameters:

  • PriceCalculationBuffer: The Price Calculation Buffer record that has been populated
  • SalesContractHeader: The source sales contract header record
  • KVSKBASalesContractLine: The source sales contract line record

Remarks: This integration event allows subscribers to modify or extend the price calculation buffer after it has been populated with standard sales contract information. Subscribers can add custom fields, modify calculation settings, adjust buffer values, or add KUMAVISION-specific data before the buffer is passed to the price calculation engine. This is useful for implementing custom price calculation logic or extending the buffer for custom price calculation implementations.

OnAfterGetDocumentDate(Date, Record KVSKBASalesContractHeader, Record KVSKBASalesContractLine) :#

Summary: Integration event raised after determining the document date for price calculation.

[IntegrationEvent(false, false)]
local procedure OnAfterGetDocumentDate(var DocumentDate: Date; SalesContractHeader: Record "KVSKBASalesContractHeader"; KVSKBASalesContractLine: Record "KVSKBASalesContractLine"): 
[EventSubscriber(ObjectType::Codeunit, Codeunit::"KVSKBASalesContractLinePrice", 'OnAfterGetDocumentDate', '', false, false)]
local procedure DoSomethingOnAfterGetDocumentDate(var DocumentDate: Date; SalesContractHeader: Record "KVSKBASalesContractHeader"; KVSKBASalesContractLine: Record "KVSKBASalesContractLine")
begin
end;

Parameters:

  • DocumentDate: The determined document date that can be modified
  • SalesContractHeader: The sales contract header record
  • KVSKBASalesContractLine: The sales contract line record

Remarks: This integration event allows subscribers to modify the document date used for price calculation. The standard logic uses the Document Date from the sales contract header, or WorkDate if blank. Subscribers can override this to use alternative dates based on custom business rules, such as using a specific validity date, price effective date, or KUMAVISION-specific date fields. The document date is critical for determining which prices are valid at calculation time.

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

[IntegrationEvent(false, false)]
local procedure OnAfterSetPrice(var KVSKBASalesContractLine: Record "KVSKBASalesContractLine"; PriceListLine: Record "Price List Line"; AmountType: Enum "Price Amount Type"): 
[EventSubscriber(ObjectType::Codeunit, Codeunit::"KVSKBASalesContractLinePrice", 'OnAfterSetPrice', '', false, false)]
local procedure DoSomethingOnAfterSetPrice(var KVSKBASalesContractLine: Record "KVSKBASalesContractLine"; PriceListLine: Record "Price List Line"; AmountType: Enum "Price Amount Type")
begin
end;

OnBeforeSetPrice(Record KVSKBASalesContractLine, Record Price List Line, Enum Price Amount Type, Boolean, Record KVSKBASalesContractHeader, Enum Price Type) :#

[IntegrationEvent(false, false)]
local procedure OnBeforeSetPrice(var SalesContractLine: Record "KVSKBASalesContractLine"; PriceListLine: Record "Price List Line"; AmountType: Enum "Price Amount Type"; var IsHandled: Boolean; var SalesContractHeader: Record "KVSKBASalesContractHeader"; CurrPriceType: Enum "Price Type"): 
[EventSubscriber(ObjectType::Codeunit, Codeunit::"KVSKBASalesContractLinePrice", 'OnBeforeSetPrice', '', false, false)]
local procedure DoSomethingOnBeforeSetPrice(var SalesContractLine: Record "KVSKBASalesContractLine"; PriceListLine: Record "Price List Line"; AmountType: Enum "Price Amount Type"; var IsHandled: Boolean; var SalesContractHeader: Record "KVSKBASalesContractHeader"; CurrPriceType: Enum "Price Type")
begin
end;

OnBeforeVerify(Record KVSKBASalesContractHeader, Record KVSKBASalesContractLine, Boolean) :#

Summary: Integration event raised before verifying the sales contract line for price calculation.

[IntegrationEvent(false, false)]
local procedure OnBeforeVerify(SalesContractHeader: Record "KVSKBASalesContractHeader"; SalesContractLine: Record "KVSKBASalesContractLine"; var IsHandled: Boolean): 
[EventSubscriber(ObjectType::Codeunit, Codeunit::"KVSKBASalesContractLinePrice", 'OnBeforeVerify', '', false, false)]
local procedure DoSomethingOnBeforeVerify(SalesContractHeader: Record "KVSKBASalesContractHeader"; SalesContractLine: Record "KVSKBASalesContractLine"; var IsHandled: Boolean)
begin
end;

Parameters:

  • SalesContractHeader: The sales contract header record
  • SalesContractLine: The sales contract line record being verified
  • IsHandled: Flag to indicate if the verification is handled by the subscriber

Remarks: This integration event allows subscribers to bypass or extend the standard verification logic before price calculation. The standard verification checks that Qty. per Unit of Measure is filled. Subscribers can implement custom validations, skip verification in specific scenarios, or add additional field checks by setting IsHandled to true. This is useful for implementing KUMAVISION-specific validation rules or alternative verification logic for sales contracts.

OnCopyToBufferOnAfterPriceCalculationBufferMgtSet(Codeunit Price Calculation Buffer Mgt., Record Price Calculation Buffer, Codeunit Price Source List) :#

[IntegrationEvent(false, false)]
local procedure OnCopyToBufferOnAfterPriceCalculationBufferMgtSet(var PriceCalculationBufferMgt: Codeunit "Price Calculation Buffer Mgt."; PriceCalculationBuffer: Record "Price Calculation Buffer"; var PriceSourceList: Codeunit "Price Source List"): 
[EventSubscriber(ObjectType::Codeunit, Codeunit::"KVSKBASalesContractLinePrice", 'OnCopyToBufferOnAfterPriceCalculationBufferMgtSet', '', false, false)]
local procedure DoSomethingOnCopyToBufferOnAfterPriceCalculationBufferMgtSet(var PriceCalculationBufferMgt: Codeunit "Price Calculation Buffer Mgt."; PriceCalculationBuffer: Record "Price Calculation Buffer"; var PriceSourceList: Codeunit "Price Source List")
begin
end;

OnAfterIsDiscountAllowed(Record KVSKBASalesContractLine, Boolean, Boolean) :#

Summary: Integration event raised after determining if discounts are allowed for the sales contract line.

[IntegrationEvent(false, false)]
local procedure OnAfterIsDiscountAllowed(KVSKBASalesContractLine: Record "KVSKBASalesContractLine"; PriceCalculated: Boolean; var Result: Boolean): 
[EventSubscriber(ObjectType::Codeunit, Codeunit::"KVSKBASalesContractLinePrice", 'OnAfterIsDiscountAllowed', '', false, false)]
local procedure DoSomethingOnAfterIsDiscountAllowed(KVSKBASalesContractLine: Record "KVSKBASalesContractLine"; PriceCalculated: Boolean; var Result: Boolean)
begin
end;

Parameters:

  • KVSKBASalesContractLine: The sales contract line record
  • PriceCalculated: Boolean indicating whether a price has been calculated
  • Result: The result indicating whether discounts are allowed (can be modified)

Remarks: This integration event allows subscribers to override or modify the discount allowance logic. The standard logic allows discounts when no price has been calculated yet. Subscribers can implement custom rules based on customer, item, contract type, or KUMAVISION-specific discount policies by modifying the Result parameter. This is useful for enforcing special discount restrictions or enabling discounts in specific scenarios for sales contracts.

OnAfterValidatePrice(Record KVSKBASalesContractLine, Enum Price Type, Enum Price Amount Type) :#

[IntegrationEvent(false, false)]
local procedure OnAfterValidatePrice(var KVSKBASalesContractLine: Record "KVSKBASalesContractLine"; CurrPriceType: Enum "Price Type"; AmountType: Enum "Price Amount Type"): 
[EventSubscriber(ObjectType::Codeunit, Codeunit::"KVSKBASalesContractLinePrice", 'OnAfterValidatePrice', '', false, false)]
local procedure DoSomethingOnAfterValidatePrice(var KVSKBASalesContractLine: Record "KVSKBASalesContractLine"; CurrPriceType: Enum "Price Type"; AmountType: Enum "Price Amount Type")
begin
end;

OnAfterIsPriceUpdateNeeded(Enum Price Amount Type, Boolean, Integer, Boolean, Record KVSKBASalesContractLine) :#

[IntegrationEvent(false, false)]
local procedure OnAfterIsPriceUpdateNeeded(AmountType: Enum "Price Amount Type"; FoundPrice: Boolean; CalledByFieldNo: Integer; var Result: Boolean; KVSKBASalesContractLine: Record "KVSKBASalesContractLine"): 
[EventSubscriber(ObjectType::Codeunit, Codeunit::"KVSKBASalesContractLinePrice", 'OnAfterIsPriceUpdateNeeded', '', false, false)]
local procedure DoSomethingOnAfterIsPriceUpdateNeeded(AmountType: Enum "Price Amount Type"; FoundPrice: Boolean; CalledByFieldNo: Integer; var Result: Boolean; KVSKBASalesContractLine: Record "KVSKBASalesContractLine")
begin
end;