Dear All,
I do have a extra charge for some customers which I want to add to the unit price of item for that customer.
let say I have an Item : 1000
item 1000 unit price : 10$
I have customer : A
and Customer : B
Extra charge for Customer A : 12 $
Now in sales order if I choose customer A and item 1000 unit price should be 22$ and for same item for customer A should be 10$
I have more than 300 customer and over 2000 items.
Don’t want to create a sales price list for every customer and every item
I added a field in customer card called Customer Freight and in that I put 12$
and make a flow field in sales line with this code :
tableextension 50301 “CustomerFrieght” extends “Sales Line”
{
fields
{
field(50301; CustomerFreight; Decimal)
{
Caption = ‘Customer Freight Charge’;
FieldClass = FlowField;
CalcFormula = lookup(Customer.CustomerFreight where(“No.” = field(“Sell-to Customer No.”)));
trigger OnValidate()
var
PriceCalculation: Interface “Price Calculation”;
begin
GetPriceCalculationHandler(PriceCalculation);
ApplyPrice(FieldNo(CustomerFreight), PriceCalculation);
end;
}
}
local procedure GetPriceCalculationHandler(var PriceCalculation: Interface “Price Calculation”)
var
SalesHeader: Record “Sales Header”;
PriceCalculationMgt: codeunit “Price Calculation Mgt.”;
SalesLinePrice: Codeunit “Sales Line - Price”;
PriceType: Enum “Price Type”;
begin
SalesHeader.Get(“Document Type”, “Document No.”);
SalesLinePrice.SetLine(PriceType::Sale, SalesHeader, Rec);
PriceCalculationMgt.GetHandler(SalesLinePrice, PriceCalculation);
end;
}
But it does not add the value to the unit price
any suggestions?