Skip to content

KVSKBASalesPriceCalcLib#

Procedures#

CollectOtherItemsOfSalesDoc(Record Sales Header, Record Sales Line, Boolean, Record KVSKBASalesPurchPriceCalcBuf, Boolean) :#

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

procedure CollectOtherItemsOfSalesDoc(SalesHeader: Record "Sales Header"; CurrentSalesLine: Record "Sales Line"; IncludeCurrentSalesLine: Boolean; var TempSalesPurchPriceCalcBuf: Record "KVSKBASalesPurchPriceCalcBuf" temporary; DeleteAllBufferRecords: Boolean): 

Parameters:

  • SalesHeader: Sales header record.
  • CurrentSalesLine: Current sales line record.
  • IncludeCurrentSalesLine: If true, the current sales line is included in the collection.
  • TempSalesPurchPriceCalcBuf: Temporary buffer for sales/purchase price calculations.
  • DeleteAllBufferRecords: If true, all records in the temporary buffer are deleted before collecting.

Remarks: This procedure collects combinations of item no., variant code, customer price group, etc. for sales lines with different item no. and the same "KVSKBAItemPriceGroup" or "KVSKBAItemDiscGroup" as the current sales line. Only those sales lines are considered which are not excluded from summing up quantity in finding unit price or line discount % (see function IsPriceOrDiscMinQtyPerLine). If IncludeCurrentSalesLine is set, the combination of the current sales line is saved in TempPriceCalcBuffer.

UpdateItemSalesLinesUnitPrice(Record KVSKBASalesPurchPriceCalcBuf, Record Sales Header) :#

Summary: Updates the unit price and line discount % of item sales lines based on the provided sales header and calculation buffer.

procedure UpdateItemSalesLinesUnitPrice(SalesPurchPriceCalcBuf: Record "KVSKBASalesPurchPriceCalcBuf"; SalesHeader: Record "Sales Header"): 

Parameters:

  • SalesPurchPriceCalcBuf: Buffer containing sales/purchase price calculations.
  • SalesHeader: Sales header record.

Remarks: This procedure retrieves the first sales line that matches the item, variant code, customer price group, etc. from the calculation buffer, recalculates the unit price and line discount %, and then copies the results to all other sales lines that match the same criteria.

UpdateSalesDocLinesUnitPrice(Record Sales Header, Boolean, Boolean) : Boolean#

Summary: Updates the unit price and line discount % of all item sales document lines that are not excluded

procedure UpdateSalesDocLinesUnitPrice(SalesHeader: Record "Sales Header"; WithConfirm: Boolean; ShowMessage: Boolean): Boolean

Parameters:

  • SalesHeader: Sales header record.
  • WithConfirm: If true, a confirmation dialog is shown before updating prices.
  • ShowMessage: If true, a message is shown if no lines are updated.

Returns: Returns true if lines have been updated, false if no lines were found or if the update was not performed due to conditions such as prepayment orders or price calculation method.

Remarks: This procedure updates the unit price and line discount % of all item sales document lines that are not excluded from summing up quantity in finding unit price or line discount %. It collects all relevant items in a temporary buffer and processes them to update the sales lines. If the sales header has the "KVSKBAPriceDiscMinQtyperLine" field set to true, it will not perform the update.

Events#

OnBeforeModifyLineOnCopyUnitPriceAndLineDiscToOtherLine(Record Sales Line, Record Sales Line, Record Sales Header, Boolean) :#

Summary: Event triggered before modifying a sales line when copying unit price and line discount to other lines.

[IntegrationEvent(false, false)]
local procedure OnBeforeModifyLineOnCopyUnitPriceAndLineDiscToOtherLine(var ToSalesLine: Record "Sales Line"; FromSalesLine: Record "Sales Line"; SalesHeader: Record "Sales Header"; var ModifyLine: Boolean): 
[EventSubscriber(ObjectType::Codeunit, Codeunit::"KVSKBASalesPriceCalcLib", 'OnBeforeModifyLineOnCopyUnitPriceAndLineDiscToOtherLine', '', false, false)]
local procedure DoSomethingOnBeforeModifyLineOnCopyUnitPriceAndLineDiscToOtherLine(var ToSalesLine: Record "Sales Line"; FromSalesLine: Record "Sales Line"; SalesHeader: Record "Sales Header"; var ModifyLine: Boolean)
begin
end;

Parameters:

  • ToSalesLine: The sales line to modify.
  • FromSalesLine: The sales line from which unit price and line discount are copied.
  • SalesHeader: The sales header associated with the sales lines.
  • ModifyLine: Indicates whether the line should be modified.

Remarks: This event allows customization of the behavior before a sales line is modified when copying unit price and line discount from one sales line to another.

OnAfterCopyUnitPriceAndLineDiscToOtherLines(Record Sales Line, Record Sales Line, Record Sales Header) :#

Summary: Event triggered after copying unit price and line discount to other sales lines.

[IntegrationEvent(false, false)]
local procedure OnAfterCopyUnitPriceAndLineDiscToOtherLines(var ToSalesLine: Record "Sales Line"; FromSalesLine: Record "Sales Line"; SalesHeader: Record "Sales Header"): 
[EventSubscriber(ObjectType::Codeunit, Codeunit::"KVSKBASalesPriceCalcLib", 'OnAfterCopyUnitPriceAndLineDiscToOtherLines', '', false, false)]
local procedure DoSomethingOnAfterCopyUnitPriceAndLineDiscToOtherLines(var ToSalesLine: Record "Sales Line"; FromSalesLine: Record "Sales Line"; SalesHeader: Record "Sales Header")
begin
end;

Parameters:

  • ToSalesLine: The sales line to which unit price and line discount were copied.
  • FromSalesLine: The sales line from which unit price and line discount were copied.
  • SalesHeader: The sales header associated with the sales lines.

Remarks: This event allows for additional processing after the unit price and line discount have been copied.

OnAfterValidateLineDiscPctOnCopyUnitPriceAndLineDiscToOtherLine(Record Sales Line, Record Sales Line, Record Sales Header, Boolean) :#

Summary: Event triggered after validating the line discount percentage when copying unit price and line discount to another line.

[IntegrationEvent(false, false)]
local procedure OnAfterValidateLineDiscPctOnCopyUnitPriceAndLineDiscToOtherLine(var ToSalesLine: Record "Sales Line"; FromSalesLine: Record "Sales Line"; SalesHeader: Record "Sales Header"; var ModifyLine: Boolean): 
[EventSubscriber(ObjectType::Codeunit, Codeunit::"KVSKBASalesPriceCalcLib", 'OnAfterValidateLineDiscPctOnCopyUnitPriceAndLineDiscToOtherLine', '', false, false)]
local procedure DoSomethingOnAfterValidateLineDiscPctOnCopyUnitPriceAndLineDiscToOtherLine(var ToSalesLine: Record "Sales Line"; FromSalesLine: Record "Sales Line"; SalesHeader: Record "Sales Header"; var ModifyLine: Boolean)
begin
end;

Parameters:

  • ToSalesLine: The sales line to which unit price and line discount are copied.
  • FromSalesLine: The sales line from which unit price and line discount are copied.
  • SalesHeader: The sales header associated with the sales lines.
  • ModifyLine: Indicates whether the line should be modified.

Remarks: This event allows for additional processing after validating the line discount percentage when copying unit price and line discount to another sales line.

OnAfterSetFilterSalesLineToSumUpQty2(Record Sales Line) :#

Summary: Event triggered after setting the filter on sales lines to sum up quantities.

[IntegrationEvent(false, false)]
local procedure OnAfterSetFilterSalesLineToSumUpQty2(var SalesLine: Record "Sales Line"): 
[EventSubscriber(ObjectType::Codeunit, Codeunit::"KVSKBASalesPriceCalcLib", 'OnAfterSetFilterSalesLineToSumUpQty2', '', false, false)]
local procedure DoSomethingOnAfterSetFilterSalesLineToSumUpQty2(var SalesLine: Record "Sales Line")
begin
end;

Parameters:

  • SalesLine: The sales line record that has been filtered.

Remarks: This event allows for additional processing after the sales line filter has been set to sum up quantities for price calculations.

SetFilterInAddItemToPriceCalcBuffer(Record KVSKBASalesPurchPriceCalcBuf, Record Sales Line, Record Sales Header) :#

Summary: Event triggered before setting the filter in the AddItemToPriceCalcBuffer procedure.

[IntegrationEvent(false, false)]
local procedure SetFilterInAddItemToPriceCalcBuffer(var TempKVSKBASalesPurchPriceCalcBuf: Record "KVSKBASalesPurchPriceCalcBuf" temporary; SalesLine: Record "Sales Line"; SalesHeader: Record "Sales Header"): 
[EventSubscriber(ObjectType::Codeunit, Codeunit::"KVSKBASalesPriceCalcLib", 'SetFilterInAddItemToPriceCalcBuffer', '', false, false)]
local procedure DoSomethingSetFilterInAddItemToPriceCalcBuffer(var TempKVSKBASalesPurchPriceCalcBuf: Record "KVSKBASalesPurchPriceCalcBuf" temporary; SalesLine: Record "Sales Line"; SalesHeader: Record "Sales Header")
begin
end;

Parameters:

  • TempKVSKBASalesPurchPriceCalcBuf: Temporary buffer for sales/purchase price calculations.
  • SalesLine: The sales line record.
  • SalesHeader: The sales header record.

Remarks: This event allows customization of the filter settings before adding an item to the price calculation buffer.

OnBeforeInsertInAddItemToPriceCalcBuffer(Record KVSKBASalesPurchPriceCalcBuf, Record Sales Line, Record Sales Header) :#

Summary: Event triggered before inserting an item into the price calculation buffer.

[IntegrationEvent(false, false)]
local procedure OnBeforeInsertInAddItemToPriceCalcBuffer(var TempKVSKBASalesPurchPriceCalcBuf: Record "KVSKBASalesPurchPriceCalcBuf" temporary; SalesLine: Record "Sales Line"; SalesHeader: Record "Sales Header"): 
[EventSubscriber(ObjectType::Codeunit, Codeunit::"KVSKBASalesPriceCalcLib", 'OnBeforeInsertInAddItemToPriceCalcBuffer', '', false, false)]
local procedure DoSomethingOnBeforeInsertInAddItemToPriceCalcBuffer(var TempKVSKBASalesPurchPriceCalcBuf: Record "KVSKBASalesPurchPriceCalcBuf" temporary; SalesLine: Record "Sales Line"; SalesHeader: Record "Sales Header")
begin
end;

Parameters:

  • TempKVSKBASalesPurchPriceCalcBuf: Temporary buffer for sales/purchase price calculations.
  • SalesLine: The sales line record.
  • SalesHeader: The sales header record.

Remarks: This event allows customization of the behavior before an item is inserted into the price calculation buffer.

OnBeforeTestFieldVariantCodeInCopyUnitPriceAndLineDiscToOtherLine(Record Sales Header, Record Sales Line, Record Sales Line, Boolean) :#

Summary: Event triggered before testing the variant code in the CopyUnitPriceAndLineDiscToOtherLine procedure.

[IntegrationEvent(false, false)]
local procedure OnBeforeTestFieldVariantCodeInCopyUnitPriceAndLineDiscToOtherLine(SalesHeader: Record "Sales Header"; FromSalesLine: Record "Sales Line"; ToSalesLine: Record "Sales Line"; var IsHandled: Boolean): 
[EventSubscriber(ObjectType::Codeunit, Codeunit::"KVSKBASalesPriceCalcLib", 'OnBeforeTestFieldVariantCodeInCopyUnitPriceAndLineDiscToOtherLine', '', false, false)]
local procedure DoSomethingOnBeforeTestFieldVariantCodeInCopyUnitPriceAndLineDiscToOtherLine(SalesHeader: Record "Sales Header"; FromSalesLine: Record "Sales Line"; ToSalesLine: Record "Sales Line"; var IsHandled: Boolean)
begin
end;

Parameters:

  • SalesHeader: The sales header record.
  • FromSalesLine: The sales line from which unit price and line discount are copied.
  • ToSalesLine: The sales line to which unit price and line discount are copied.
  • IsHandled: Indicates whether the event has been handled.

Remarks: This event allows customization of the behavior before testing the variant code when copying unit price and line discount from one sales line to another.

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

Summary: Event triggered before comparing variant codes in the IsPriceUpdateOfOtherLinesRequired procedure.

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

Parameters:

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

Remarks: This event allows customization of the behavior before comparing variant codes to determine if a price update is required for other lines.

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

Summary: Event triggered before comparing variant codes in the CollectOtherItemsOfSalesDoc procedure.

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

Parameters:

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

Remarks: This event allows customization of the behavior before comparing variant codes to determine if a price update is required for other lines.

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

Summary: Event triggered before comparing variant codes in the CollectOtherItemsOfSalesDoc procedure.

[IntegrationEvent(false, false)]
local procedure OnBeforeCompareVariantCodeInCompareVariantCodeInCollectOtherItemsOfSalesDoc(var ChangedVariantCode: Boolean; VariantCode: Code[10]; CurrentVariantCode: Code[10]; ItemNo: Code[20]): 
[EventSubscriber(ObjectType::Codeunit, Codeunit::"KVSKBASalesPriceCalcLib", 'OnBeforeCompareVariantCodeInCompareVariantCodeInCollectOtherItemsOfSalesDoc', '', false, false)]
local procedure DoSomethingOnBeforeCompareVariantCodeInCompareVariantCodeInCollectOtherItemsOfSalesDoc(var ChangedVariantCode: Boolean; VariantCode: Code[10]; CurrentVariantCode: Code[10]; ItemNo: Code[20])
begin
end;

Parameters:

  • ChangedVariantCode: Indicates whether the variant code has changed.
  • VariantCode: The variant code to compare.
  • CurrentVariantCode: The current variant code.
  • ItemNo: The item number.

Remarks: This event allows customization of the behavior before comparing variant codes to determine if a price update is required for other lines.

OnAfterIsPriceOrDiscMinQtyPerLine(Record Sales Header, Record Sales Line, Boolean) :#

Summary: Event triggered after checking if a sales line is excluded from summing up quantity in finding unit price or line discount %.

[IntegrationEvent(false, false)]
local procedure OnAfterIsPriceOrDiscMinQtyPerLine(SalesHeader: Record "Sales Header"; SalesLine: Record "Sales Line"; var Result: Boolean): 
[EventSubscriber(ObjectType::Codeunit, Codeunit::"KVSKBASalesPriceCalcLib", 'OnAfterIsPriceOrDiscMinQtyPerLine', '', false, false)]
local procedure DoSomethingOnAfterIsPriceOrDiscMinQtyPerLine(SalesHeader: Record "Sales Header"; SalesLine: Record "Sales Line"; var Result: Boolean)
begin
end;

Parameters:

  • SalesHeader: The sales header record.
  • SalesLine: The sales line record.
  • Result: The result indicating if the sales line is excluded.

Remarks: This event allows customization of the behavior after checking if a sales line is excluded from summing up quantity in finding unit price or line discount %.

OnGetTotalItemQtyOnAfterSetFilterSalesLine(Record Sales Line, Record Sales Line, Decimal, Boolean) :#

Summary: Event triggered after setting the filter on sales lines to sum up quantities.

[IntegrationEvent(false, false)]
local procedure OnGetTotalItemQtyOnAfterSetFilterSalesLine(CurrentSalesLine: Record "Sales Line"; var SalesLine: Record "Sales Line"; var TotalQty: Decimal; var IsHandled: Boolean): 
[EventSubscriber(ObjectType::Codeunit, Codeunit::"KVSKBASalesPriceCalcLib", 'OnGetTotalItemQtyOnAfterSetFilterSalesLine', '', false, false)]
local procedure DoSomethingOnGetTotalItemQtyOnAfterSetFilterSalesLine(CurrentSalesLine: Record "Sales Line"; var SalesLine: Record "Sales Line"; var TotalQty: Decimal; var IsHandled: Boolean)
begin
end;

Parameters:

  • CurrentSalesLine: The current sales line record.
  • SalesLine: The sales line record.
  • TotalQty: The total quantity.
  • IsHandled: Indicates if the event has been handled.

Remarks: This event allows customization of the behavior after setting the filter on sales lines to sum up quantities.

OnGetTotalItemPriceGrpQtyOnAfterSetFilterSalesLine(Record Sales Line, Record Sales Line, Decimal, Boolean) :#

Summary: Event triggered after setting the filter on sales lines to sum up quantities for item price group.

[IntegrationEvent(false, false)]
local procedure OnGetTotalItemPriceGrpQtyOnAfterSetFilterSalesLine(CurrentSalesLine: Record "Sales Line"; var SalesLine: Record "Sales Line"; var TotalQty: Decimal; var IsHandled: Boolean): 
[EventSubscriber(ObjectType::Codeunit, Codeunit::"KVSKBASalesPriceCalcLib", 'OnGetTotalItemPriceGrpQtyOnAfterSetFilterSalesLine', '', false, false)]
local procedure DoSomethingOnGetTotalItemPriceGrpQtyOnAfterSetFilterSalesLine(CurrentSalesLine: Record "Sales Line"; var SalesLine: Record "Sales Line"; var TotalQty: Decimal; var IsHandled: Boolean)
begin
end;

Parameters:

  • CurrentSalesLine: The current sales line record.
  • SalesLine: The sales line record.
  • TotalQty: The total quantity.
  • IsHandled: Indicates if the event has been handled.

Remarks: This event allows customization of the behavior after setting the filter on sales lines to sum up quantities for item price group.

GetTotalItemDiscGrpQtyOnAfterSetFilterSalesLine(Record Sales Line, Record Sales Line, Decimal, Boolean) :#

Summary: Event triggered after setting the filter on sales lines to sum up quantities for item discount group.

[IntegrationEvent(false, false)]
local procedure GetTotalItemDiscGrpQtyOnAfterSetFilterSalesLine(CurrentSalesLine: Record "Sales Line"; var SalesLine: Record "Sales Line"; var TotalQty: Decimal; var IsHandled: Boolean): 
[EventSubscriber(ObjectType::Codeunit, Codeunit::"KVSKBASalesPriceCalcLib", 'GetTotalItemDiscGrpQtyOnAfterSetFilterSalesLine', '', false, false)]
local procedure DoSomethingGetTotalItemDiscGrpQtyOnAfterSetFilterSalesLine(CurrentSalesLine: Record "Sales Line"; var SalesLine: Record "Sales Line"; var TotalQty: Decimal; var IsHandled: Boolean)
begin
end;

Parameters:

  • CurrentSalesLine: The current sales line record.
  • SalesLine: The sales line record.
  • TotalQty: The total quantity.
  • IsHandled: Indicates if the event has been handled.

Remarks: This event allows customization of the behavior after setting the filter on sales lines to sum up quantities for item discount group.

OnAfterFilterSalesLineToSumUpQty(Record Sales Line, Record Sales Line) :#

Summary: Event triggered after filtering sales lines to sum up quantities.

[IntegrationEvent(false, false)]
local procedure OnAfterFilterSalesLineToSumUpQty(var SalesLine: Record "Sales Line"; CurrentSalesLine: Record "Sales Line"): 
[EventSubscriber(ObjectType::Codeunit, Codeunit::"KVSKBASalesPriceCalcLib", 'OnAfterFilterSalesLineToSumUpQty', '', false, false)]
local procedure DoSomethingOnAfterFilterSalesLineToSumUpQty(var SalesLine: Record "Sales Line"; CurrentSalesLine: Record "Sales Line")
begin
end;

Parameters:

  • SalesLine: The sales line record.
  • CurrentSalesLine: The current sales line record.

Remarks: This event allows customization of the behavior after filtering sales lines to sum up quantities.