Hello!
In our case, a web order comes in via API (v2) and it can only set payment terms, so in parallel I set the payment method based on how the customer paid (gets that info via a custom api).
The problem is if I put e.g. card payment and the order is "invoiced", it should register that it has already been paid.
This does not happen if I set the payment method with AL.
However, it works fine if I select it manually one more time on the order.
So my question is, how can I set the payment method on a sales order with AL and everything will be correct all the way.
The example is when I get data to the custom API
trigger OnInsert()
var
OrderH: Record "Sales Header";
begin
OrderH.Get("Sales Document Type"::Order, Rec.bcOrderNr);
if OrderH."No." <> '' then begin
OrderH.webOrderNumber := Rec.webOrderNr;
if Rec.TvingandeFakturatyp <> '' then begin
if LowerCase(Rec.TvingandeFakturatyp) = 'swish' then begin
OrderH."Payment Method Code" := 'SWISH';
OrderH."Payment Terms Code" := 'FÖSRKOTT';
end else
if LowerCase(Rec.TvingandeFakturatyp) = 'kort' then begin
OrderH."Payment Method Code" := 'KORT';
OrderH."Payment Terms Code" := 'FÖSRKOTT';
end;
end;
OrderH.Modify();
end;
end;