Developer forum

Forum » Integration » Liveintegration - ERP controls shipping calculations

Liveintegration - ERP controls shipping calculations

Magnus Holmberg
Reply

Hi,

We have setup in Dynamicweb to let BC controll the shipping fee calculactions.
How do we explain to the ERP partner how they need to setup it on the BC side to return shipping fee?
I have looked through doc site but cant find documentation.


Replies

 
Dmitriy Benyuk Dynamicweb Employee
Dmitriy Benyuk
Reply

Hi Magnus,

you can subscriber to the events exposed in the codeunit: codeunit 6211204 DynamicwebOrdersPublisher
and use the events:
CalculateOrderOnBeforeAddSalesHeaderToResponse - for the CalculateOrder request
CreateOrderOnBeforeAddSalesHeaderToResponse - for the CreateOrder request
In the xml field "OrderShippingFee" you can send the custom calculated shipping fee price with VAT, then this shipping price will be used by the Live integration and will be added to the Dynamicweb order.

The implemented custom code can look like that:

var
        DynamicwebXmlHelper: Codeunit DynamicwebXmlHelper;

    [EventSubscriber(ObjectType::Codeunit, Codeunit::DynamicwebOrdersPublisher, 'CalculateOrderOnBeforeAddSalesHeaderToResponse', '', true, true)]
    procedure CalculateOrderOnBeforeAddSalesHeaderToResponse(var salesheader: Record "Sales Header"; var OrderPriceWithVAT: Decimal; var OrderPriceWithoutVAT: Decimal; var OrderPriceVAT: Decimal; var OrderSalesDiscount: Decimal;
    var responseSalesHeaderXml: XmlNode; var requestOrderNode: XmlNode; var customer: Record Customer);
    begin
        DynamicwebXmlHelper.AddField(responseSalesHeaderXml, 'OrderShippingFee', '100');
    end;

    [EventSubscriber(ObjectType::Codeunit, Codeunit::DynamicwebOrdersPublisher, 'CreateOrderOnBeforeAddSalesHeaderToResponse', '', true, true)]
    procedure CreateOrderOnBeforeAddSalesHeaderToResponse(var salesheader: Record "Sales Header"; var OrderPriceWithVAT: Decimal; var OrderPriceWithoutVAT: Decimal; var OrderPriceVAT: Decimal; var OrderSalesDiscount: Decimal;
    var responseSalesHeaderXml: XmlNode; var requestOrderNode: XmlNode; var customer: Record Customer);
    begin
        DynamicwebXmlHelper.AddField(responseSalesHeaderXml, 'OrderShippingFee', '100');
    end;

BR, Dmitrij

 
Magnus Holmberg
Reply

Hi,

Is there any way out of the box to handle the shipping fees in the BC plug-in unit?

BR
Magnus

 
Dmitriy Benyuk Dynamicweb Employee
Dmitriy Benyuk
Reply

Hi Magnus,
you’re not forced to have the remote system to calculate the shipping fees. You can also use Dynamicweb’s built-in shipping providers to calculate the fee directly or with the use of an external system such as UPS or FedEx. When you configure one of the built-in providers, the fee is calculated by Dynamicweb and submitted to the remote system, this is the case when "ERP Controls Shipping" is not checked. Then once the order is created in BC it will have a separate order line with a type selected in the "ERP shipping item type" drop-down (Account/Item/Item Charge/Resource) with an identifier set from  the "ERP shipping item key" option pointing to the shipping information from Dynamicweb.

BR, Dmitrij

 
Magnus Holmberg
Reply

Hi,

So the only way to let BC calculate the shipping fee is to extend through a subscriber as you described above?

BR,
Magnus

 
Dmitriy Benyuk Dynamicweb Employee
Dmitriy Benyuk
Reply

Hi Magnus,
it seems yes. How is the shipping configured in your BC?
BR, Dmitrij

 
Magnus Holmberg
Reply

Hi,

Now the ERP-partner made the changes in BC using the subscriber that you described.

The shipping fee is now presenting as it should but the order total and subtotal subtracts the shipping fee.
Should the shipping fee be added to the total price?
Is there any settings that we missed?


Turning off the live integration shipping calculations it looks like this, it shows the same total and subtotal.

BR,
Magnus

 
Dmitriy Benyuk Dynamicweb Employee
Dmitriy Benyuk
Reply

Hi Magnus,
yes, you need also to configure the Live Integration shippng provider as described here.
BR, Dmitrij

 
Magnus Holmberg
Reply

Hi Dmitriy,

We have aldready configured as described or can you see anything missing?
And why is the Fee subtracted from the price?

BR Magnus

 
Dmitriy Benyuk Dynamicweb Employee
Dmitriy Benyuk
Reply

Hi Magnus,
that looks like a bug in the Live integration. Until it is released to Nuget/new Dynamicweb version you can try to download the new Live integration dll from here and update it in your web site bin folder. Let me know if that helps.
BR, Dmitrij
 

 
Magnus Holmberg
Reply

Hi Dmitriy,

Still same behavior after updated with the dll you provided.
BR, Magnus

 
Dmitriy Benyuk Dynamicweb Employee
Dmitriy Benyuk
Reply

Hi Magnus,
can you send me a link to your solution so I can look on it  (email: dbe@dynamicweb-cms.com)?
BR, Dmitrij

 
Dmitriy Benyuk Dynamicweb Employee
Dmitriy Benyuk
Reply

Hi Magnus,
it looks like the problem is that in the response from the BC the total order price in the xml response is without the shipping fee price, so when the order is calculated by ERP/BC and ERP controls the shipping then Dynamicweb considers the order total price is with all fees/shippings fees. Can you extend the custom code unit subscribers code to update the passed referenced variables:
var OrderPriceWithVAT: Decimal; var OrderPriceWithoutVAT: Decimal; var OrderPriceVAT: Decimal;
to include also the shipping fee price in their values?

BR, Dmitrij

 
Magnus Holmberg
Reply

Hi Dmitriy,

I will forward this to our BC partner and get back to you how it goes.

BR, Magnus

 

You must be logged in to post in the forum