Developer forum

Forum » Integration » VAT calculation on BC orders

VAT calculation on BC orders

Chris Søgaard
Chris Søgaard
Reply

Hi

We have a weird issue with VAT calculation when creating orders using live integration towards a BC18 running code unit version 1.2.0.13.

It seems that the database columns "OrderPriceBeforeFeesWithoutVAT" and "OrderPriceBeforeFeesVAT" are not getting their correct values, when creating an order although VAT percent seems to be returned correctly from BC. In the below example, I have created 2 identical orders, one with live integration enabled (ORDER779) and one with live integration disabled (ORDER780). The 2 lines seems to be identical except the 2 columns mentioned above

And the orderlines here:

I can't seem to figure out why this occurs. This is the XML exchanged between DW and BC for ORDER779 (customer and product details omitted from the XML example):

Request:

Response:

Could you please check to see if this is an error. We have a customer running a solution where some of their customers pay VAT and some does not, so we really need the fields to be correct. 

Also is there any way to manipulate these 2 columns in a NotificationSubscriber for a quick fix, I can't seem to find their equivalent on the order objects in the subscribers? 

BR Chris


Replies

 
Dmitriy Benyuk Dynamicweb Employee
Dmitriy Benyuk
Reply

Hi Chris,

we will look on this. For a quick solution you can subscribe to:
OnAfterSendingOrderToErp Live integration subscriber and add those xml to the response EcomOrders table xml:
column [@columnName='OrderPriceBeforeFeesWithVat'] and set it to 408.75 (value from OrderPriceWithVat)
column [@columnName='OrderPriceBeforeFeesWithoutVat'] and set it to 327 (value from OrderPriceWithoutVat)

Or you can change your BC extension to return those columns in the response xml instead.

Kind regards, Dmitrij
 

 
Chris Søgaard
Chris Søgaard
Reply

Hi Dmitrij

Thank you for your response. Unfortunately this does not make any difference, the data inserted in the database does not seem to be controlled by the XML for these 2 fields. Maybe the fields are calculated in the live integration frameworrk, and we cannot control them with XML? 

I have added the fields to the response XML on "OnAfterSendingOrderToErp" and this is the response XML after the subscriber (customer details omitted):

 
Dmitriy Benyuk Dynamicweb Employee
Dmitriy Benyuk
Reply
This post has been marked as an answer

Hi Chris,

can you try this code?
 

using Dynamicweb.Extensibility.Notifications;
using Dynamicweb.Ecommerce.DynamicwebLiveIntegration.Notifications;

namespace Dynamicweb.Ecommerce.DynamicwebLiveIntegration.Examples.Notifications
{
    /// <summary>
    /// Class OrderAfterSendToErpSubscriber.
    /// </summary>
    /// <seealso cref="NotificationSubscriber" />
    [Subscribe(Order.OnAfterSendingOrderToErp)]
    public class OrderAfterSendToErpSubscriber : NotificationSubscriber
    {
        /// <summary>
        /// Call to invoke observer.
        /// </summary>
        /// <param name="notification">The notification.</param>
        /// <param name="args">The args.</param>
        public override void OnNotify(string notification, NotificationArgs args)
        {
            var myArgs = (Order.OnAfterSendingOrderToErpArgs)args;
            var doc = myArgs.ResponseDocument;
            var orderNode = doc.SelectSingleNode("//tables/table/item[@table='EcomOrders']");
            var text = orderNode.SelectSingleNode("//item/column[@columnName='OrderPriceWithoutVat']")?.InnerText;
            var node = doc.CreateNode(System.Xml.XmlNodeType.Element, "column", null);
            var attr = doc.CreateAttribute("columnName");
            attr.Value = "OrderPriceBeforeFeesWithoutVat";
            node.Attributes.Append(attr);
            node.InnerText = text;
            orderNode.AppendChild(node);
        }
    }
}



BR, Dmitrij

Votes for this answer: 1
 
Chris Søgaard
Chris Søgaard
Reply

Hi Dmitrij

It was somehow the same thing I did, except I also added the "OrderPriceBeforeFeesVAT", but you code works.

Thank you.

BR Chris

 

You must be logged in to post in the forum