Skip to content

KVSKBAPurchPriceCalcLib#

Procedures#

CollectOtherItemsOfPurchDoc(Record Purchase Header, Record Purchase Line, Boolean, Record KVSKBASalesPurchPriceCalcBuf, Boolean) :#

Summary: Collects other associated purchase lines of the purchase document.

procedure CollectOtherItemsOfPurchDoc(PurchaseHeader: Record "Purchase Header"; CurrentPurchaseLine: Record "Purchase Line"; IncludeCurrentPurchaseLine: Boolean; var TempSalesPurchPriceCalcBuf: Record "KVSKBASalesPurchPriceCalcBuf" temporary; DeleteAllBufferRecords: Boolean): 

Parameters:

  • PurchaseHeader: The purchase header record.
  • CurrentPurchaseLine: The current purchase line record.
  • IncludeCurrentPurchaseLine: Indicates whether to include the current purchase line.
  • TempSalesPurchPriceCalcBuf: The temporary sales purchase price calculation buffer.
  • DeleteAllBufferRecords: Indicates whether to delete all buffer records.

Remarks: This procedure collects combinations of item number, variant code, unit of measure code, etc. for purchase lines with different item numbers but the same "KVSKBAItemPriceGroup" as the current purchase line. Only purchase lines that are not excluded from summing up quantity in finding direct unit cost or line discount % are considered.

UpdateItemPurchLinesDirectUnitCost(Record KVSKBASalesPurchPriceCalcBuf, Record Purchase Header) :#

Summary: Updates "Direct Unit Cost" and "Line Discount %" of all item purchase document lines not excluded from summing up quantity in finding direct unit cost or line discount %.

procedure UpdateItemPurchLinesDirectUnitCost(SalesPurchPriceCalcBuf: Record "KVSKBASalesPurchPriceCalcBuf"; PurchaseHeader: Record "Purchase Header"): 

Parameters:

  • SalesPurchPriceCalcBuf: The sales purchase price calculation buffer record.
  • PurchaseHeader: The purchase header record.

Remarks: This procedure updates the "Direct Unit Cost" and "Line Discount %" for all item purchase document lines that are not excluded from summing up quantity in finding direct unit cost or line discount %. It first retrieves the first purchase line that matches the criteria, then recalculates the "Direct Unit Cost" and "Line Discount %", and finally copies these values to all other purchase lines of the same item, variant code, unit of measure code, etc. Raises integration events for extensibility.

UpdatePurchDocLinesDirectUnitCost(Record Purchase Header, Boolean, Boolean) : Boolean#

Summary: Updates "Direct Unit Cost" and "Line Discount %" of all item purchase document lines not excluded from summing up quantity in finding direct unit cost or line discount %.

procedure UpdatePurchDocLinesDirectUnitCost(PurchaseHeader: Record "Purchase Header"; WithConfirm: Boolean; ShowMessage: Boolean): Boolean

Parameters:

  • PurchaseHeader: The purchase header record.
  • WithConfirm: Indicates whether to show a confirmation dialog before updating.
  • ShowMessage: Indicates whether to show a message if no lines are updated.

Returns: Returns TRUE if lines have been updated, otherwise FALSE.

Remarks: This procedure updates the "Direct Unit Cost" and "Line Discount %" for all item purchase document lines not excluded from summing up quantity in finding direct unit cost or line discount %. Returns FALSE if graduated prices are switched off or prepayment orders exist. Collects all relevant items and updates each group of lines. Shows confirmation dialog if WithConfirm is TRUE. Shows message if no lines need updating and ShowMessage is TRUE.

Events#

OnBeforeOnIsDirectUnitCostUpdateOfOtherLinesRequiredOnCompareVariantCode(Boolean, Code[10], Code[10], Code[20]) :#

Summary: Integration event triggered before comparing variant codes in IsDirectUnitCostUpdateOfOtherLinesRequired.

[IntegrationEvent(false, false)]
local procedure OnBeforeOnIsDirectUnitCostUpdateOfOtherLinesRequiredOnCompareVariantCode(var ChangedVariantCode: Boolean; OldVariantCode: Code[10]; NewVariantCode: Code[10]; ItemNo: Code[20]): 
[EventSubscriber(ObjectType::Codeunit, Codeunit::"KVSKBAPurchPriceCalcLib", 'OnBeforeOnIsDirectUnitCostUpdateOfOtherLinesRequiredOnCompareVariantCode', '', false, false)]
local procedure DoSomethingOnBeforeOnIsDirectUnitCostUpdateOfOtherLinesRequiredOnCompareVariantCode(var ChangedVariantCode: Boolean; OldVariantCode: Code[10]; NewVariantCode: Code[10]; ItemNo: Code[20])
begin
end;

Parameters:

  • ChangedVariantCode: Indicates if the variant code has changed.
  • OldVariantCode: The old variant code.
  • NewVariantCode: The new variant code.
  • ItemNo: The item number.

Remarks: Allows customization of variant code comparison logic for direct unit cost updates. Set ChangedVariantCode to override standard comparison behavior. Used to determine if other lines need recalculation when variant code changes. Supports item-specific variant handling rules.

OnBeforeOnCollectOtherItemsOfPurchDocOnCompareVariantCode(Boolean, Code[10], Code[10], Code[20]) :#

Summary: Integration event triggered before comparing variant codes in CollectOtherItemsOfPurchDoc.

[IntegrationEvent(false, false)]
local procedure OnBeforeOnCollectOtherItemsOfPurchDocOnCompareVariantCode(var ChangedVariantCode: Boolean; OldVariantCode: Code[10]; NewVariantCode: Code[10]; ItemNo: Code[20]): 
[EventSubscriber(ObjectType::Codeunit, Codeunit::"KVSKBAPurchPriceCalcLib", 'OnBeforeOnCollectOtherItemsOfPurchDocOnCompareVariantCode', '', false, false)]
local procedure DoSomethingOnBeforeOnCollectOtherItemsOfPurchDocOnCompareVariantCode(var ChangedVariantCode: Boolean; OldVariantCode: Code[10]; NewVariantCode: Code[10]; ItemNo: Code[20])
begin
end;

Parameters:

  • ChangedVariantCode: Indicates if the variant code has changed.
  • OldVariantCode: The old variant code.
  • NewVariantCode: The new variant code.
  • ItemNo: The item number.

Remarks: Allows customization of variant code comparison when collecting item lines. Set ChangedVariantCode to override standard comparison behavior. Determines if lines with different variants should be included in price calculations. Supports item-specific variant grouping rules for price/discount calculations.

OnBeforeOnPurchLinesDirectUnitCostOnCompareVariantCode(Boolean, Code[10], Code[10], Code[20]) :#

Summary: Integration event triggered before comparing variant codes in direct unit cost calculations.

[IntegrationEvent(false, false)]
local procedure OnBeforeOnPurchLinesDirectUnitCostOnCompareVariantCode(var ChangedVariantCode: Boolean; OldVariantCode: Code[10]; NewVariantCode: Code[10]; ItemNo: Code[20]): 
[EventSubscriber(ObjectType::Codeunit, Codeunit::"KVSKBAPurchPriceCalcLib", 'OnBeforeOnPurchLinesDirectUnitCostOnCompareVariantCode', '', false, false)]
local procedure DoSomethingOnBeforeOnPurchLinesDirectUnitCostOnCompareVariantCode(var ChangedVariantCode: Boolean; OldVariantCode: Code[10]; NewVariantCode: Code[10]; ItemNo: Code[20])
begin
end;

Parameters:

  • ChangedVariantCode: Indicates if the variant code has changed.
  • OldVariantCode: The old variant code.
  • NewVariantCode: The new variant code.
  • ItemNo: The item number.

Remarks: Allows customization of variant code comparison in price calculations. Set ChangedVariantCode to override standard comparison behavior. Determines if variant code differences affect direct unit cost calculations. Supports custom variant handling for specific items or item groups.

OnIsPriceOrDiscMinQtyPerLineOnBeforeExitFalse(Record Purchase Header, Record Purchase Line, Boolean, Boolean) :#

Summary: Integration event triggered before IsPriceOrDiscMinQtyPerLine returns FALSE.

[IntegrationEvent(false, false)]
local procedure OnIsPriceOrDiscMinQtyPerLineOnBeforeExitFalse(PurchaseHeader: Record "Purchase Header"; PurchaseLine: Record "Purchase Line"; var MinQtyIsPerLine: Boolean; var IsHandled: Boolean): 
[EventSubscriber(ObjectType::Codeunit, Codeunit::"KVSKBAPurchPriceCalcLib", 'OnIsPriceOrDiscMinQtyPerLineOnBeforeExitFalse', '', false, false)]
local procedure DoSomethingOnIsPriceOrDiscMinQtyPerLineOnBeforeExitFalse(PurchaseHeader: Record "Purchase Header"; PurchaseLine: Record "Purchase Line"; var MinQtyIsPerLine: Boolean; var IsHandled: Boolean)
begin
end;

Parameters:

  • PurchaseHeader: The purchase header record.
  • PurchaseLine: The purchase line record.
  • MinQtyIsPerLine: Indicates if the minimum quantity is per line.
  • IsHandled: Set to TRUE to override standard behavior.

Remarks: Allows customization of the logic determining if a line is included in quantity summing. Set IsHandled to TRUE and MinQtyIsPerLine to the desired value to override. Used to implement custom rules for graduated price calculation. Called after all standard checks pass (line would normally be included in summing).

OnBeforeSetFilterPurchLineToSumUpQty(Record Purchase Line, Record Purchase Line) :#

Summary: Integration event triggered before setting filters on purchase lines for quantity summing.

[IntegrationEvent(false, false)]
local procedure OnBeforeSetFilterPurchLineToSumUpQty(CurrentPurchaseLine: Record "Purchase Line"; var PurchaseLine: Record "Purchase Line"): 
[EventSubscriber(ObjectType::Codeunit, Codeunit::"KVSKBAPurchPriceCalcLib", 'OnBeforeSetFilterPurchLineToSumUpQty', '', false, false)]
local procedure DoSomethingOnBeforeSetFilterPurchLineToSumUpQty(CurrentPurchaseLine: Record "Purchase Line"; var PurchaseLine: Record "Purchase Line")
begin
end;

Parameters:

  • CurrentPurchaseLine: The current purchase line record.
  • PurchaseLine: The purchase line record to which filters are applied.

Remarks: Allows customization of filter logic when summing up quantities for graduated pricing. Modify PurchaseLine filters to include/exclude specific lines from quantity calculation. Called before standard filters (unit of measure, qty per UOM) are applied. Used to implement custom criteria for grouping lines in price calculations.

OnCopyDirectUnitCostAndLineDiscToOtherLineOnBeforeModifyLine(Record Purchase Line, Record Purchase Line, Boolean) :#

Summary: Integration event triggered before modifying a purchase line when copying price and discount.

[IntegrationEvent(false, false)]
local procedure OnCopyDirectUnitCostAndLineDiscToOtherLineOnBeforeModifyLine(FromPurchaseLine: Record "Purchase Line"; var ToPurchaseLine: Record "Purchase Line"; var ModifyLine: Boolean): 
[EventSubscriber(ObjectType::Codeunit, Codeunit::"KVSKBAPurchPriceCalcLib", 'OnCopyDirectUnitCostAndLineDiscToOtherLineOnBeforeModifyLine', '', false, false)]
local procedure DoSomethingOnCopyDirectUnitCostAndLineDiscToOtherLineOnBeforeModifyLine(FromPurchaseLine: Record "Purchase Line"; var ToPurchaseLine: Record "Purchase Line"; var ModifyLine: Boolean)
begin
end;

Parameters:

  • FromPurchaseLine: The purchase line from which values are copied.
  • ToPurchaseLine: The purchase line to which values are copied.
  • ModifyLine: Set to FALSE to prevent line modification.

Remarks: Allows subscribers to: - Prevent line modification by setting ModifyLine to FALSE - Add custom field copying logic - Perform validation before modification - Log or audit price/discount changes Called after direct unit cost, line discount %, and origin fields are copied.