Developer forum

Forum » Swift » Swift, LI and discount display

Swift, LI and discount display

Imar Spaanjaars Dynamicweb Employee
Imar Spaanjaars
Reply

Hi there,

I have a site with Live Integration. Logged in as a customer with a standard discount percentage, I get prices that are discounted correctly. Yet when I am in the cart, the cart summary seems to apply the discount twice. To see what I mean, take a look at this:

On the left this displays as 155.52 and a discount of 60.48. The original price is 216 (180 + 20% V AT at 36). That all looks as it should.

On the right it displays as 155.52 95.04 which I think is the already discounted price of 155.52 discounted by 60.48 again which is wrong.

This looks like a Swift bug to me, as it seems that the LI data we get is correct:

<tables version="1.2.0.16_NAV9.16.45243">
  <table tableName="EcomOrderLines">
    <item table="EcomOrderLines">
      <column columnName="OrderLineProductNumber"><![CDATA[Item1]]></column>
      <column columnName="OrderLineProductVariantId"><![CDATA[]]></column>
      <column columnName="OrderLineId"><![CDATA[10000]]></column>
      <column columnName="OrderLineQuantity"><![CDATA[1]]></column>
      <column columnName="OrderLineType"><![CDATA[0]]></column>
      <column columnName="OrderLinePriceWithoutVat"><![CDATA[180]]></column>
      <column columnName="OrderLineUnitPriceWithoutVat"><![CDATA[180.00]]></column>
      <column columnName="OrderLinePriceWithVat"><![CDATA[216]]></column>
      <column columnName="OrderLineUnitPriceWithVat"><![CDATA[216]]></column>
      <column columnName="OrderLinePriceVat"><![CDATA[36]]></column>
      <column columnName="OrderLineUnitPriceVat"><![CDATA[36]]></column>
      <column columnName="OrderLinePriceVatPercent"><![CDATA[20]]></column>
      <column columnName="OrderLineUnitPriceVatPercent"><![CDATA[20]]></column>
    </item>
    <item table="EcomOrderLines">
      <column columnName="OrderLineProductNumber"><![CDATA[Item1]]></column>
      <column columnName="OrderLineProductVariantId"><![CDATA[]]></column>
      <column columnName="OrderLineParentLineId"><![CDATA[10000]]></column>
      <column columnName="OrderLineType"><![CDATA[3]]></column>
      <column columnName="OrderLineQuantity"><![CDATA[1]]></column>
      <column columnName="OrderLinePriceWithoutVat"><![CDATA[50.40]]></column>
      <column columnName="OrderLineUnitPriceWithoutVat"><![CDATA[50.40]]></column>
      <column columnName="OrderLinePriceWithVat"><![CDATA[60.48]]></column>
      <column columnName="OrderLineUnitPriceWithVat"><![CDATA[60.48]]></column>
      <column columnName="OrderLineDiscountPercentage"><![CDATA[28]]></column>
      <column columnName="OrderLinePriceVat"><![CDATA[10.08]]></column>
      <column columnName="OrderLineUnitPriceVat"><![CDATA[10.08]]></column>
      <column columnName="OrderLinePriceVatPercent"><![CDATA[20]]></column>
      <column columnName="OrderLineUnitPriceVatPercent"><![CDATA[20]]></column>
    </item>
  </table>
  <table tableName="EcomOrders">
    <item table="EcomOrders">
      <column columnName="OrderShippingMethodName"><![CDATA[]]></column>
      <column columnName="OrderShippingMethodId"><![CDATA[]]></column>
      <column columnName="OrderShippingFee"><![CDATA[0]]></column>
      <column columnName="OrderCreated"><![CDATA[TRUE]]></column>
      <column columnName="OrderId"><![CDATA[]]></column>
      <column columnName="OrderCurrencyCode"><![CDATA[GBP]]></column>
      <column columnName="OrderDate"><![CDATA[]]></column>
      <column columnName="OrderPaymentMethodName"><![CDATA[]]></column>
      <column columnName="OrderCustomerName"><![CDATA[Imar as 201941]]></column>
      <column columnName="OrderCustomerAddress"><![CDATA[Test]]></column>
      <column columnName="OrderCustomerAddress2"><![CDATA[]]></column>
      <column columnName="OrderCustomerCity"><![CDATA[Test]]></column>
      <column columnName="OrderCustomerCountryCode"><![CDATA[GB]]></column>
      <column columnName="OrderCustomerEmail"><![CDATA[]]></column>
      <column columnName="OrderCustomerFax"><![CDATA[]]></column>
      <column columnName="OrderCustomerPhone"><![CDATA[]]></column>
      <column columnName="OrderCustomerZip"><![CDATA[TEST]]></column>
      <column columnName="OrderDeliveryName"><![CDATA[Imar as 201941]]></column>
      <column columnName="OrderDeliveryAddress"><![CDATA[Test]]></column>
      <column columnName="OrderDeliveryAddress2"><![CDATA[Test]]></column>
      <column columnName="OrderDeliveryCity"><![CDATA[Test]]></column>
      <column columnName="OrderDeliveryCountryCode"><![CDATA[GB]]></column>
      <column columnName="OrderDeliveryEmail"><![CDATA[]]></column>
      <column columnName="OrderDeliveryFax"><![CDATA[]]></column>
      <column columnName="OrderDeliveryPhone"><![CDATA[]]></column>
      <column columnName="OrderDeliveryZip"><![CDATA[TEST]]></column>
      <column columnName="OrderPriceWithVat"><![CDATA[155.52]]></column>
      <column columnName="OrderPriceWithoutVat"><![CDATA[129.6]]></column>
      <column columnName="OrderPriceVat"><![CDATA[25.92]]></column>
      <column columnName="OrderSalesDiscount"><![CDATA[50.4]]></column>
    </item>
  </table>

We're using a slightly older version of Swift (1.22) but comparing the code in OrderSummary.cshtml with the latest on Github didn't bring up any relevant differences.

Any ideas?

Imar

 


Replies

 
Nicolai Pedersen Dynamicweb Employee
Nicolai Pedersen
Reply

I do not think this is a swift issue.

Swift uses TotalPriceWithoutDiscountsFeesAndTaxes which is defined like this:

TotalPriceWithoutTaxes.Substract(TotalDiscount).Substract(PaymentFee).Substract(ShippingFee);

TotalPriceWithoutTaxes is defined like this:

Price.Substract(TotalTax);

So I think the problem is that the OrderPriceWithVat from the XML response is put into Order.Price. And when that happens in the subtotal calculation the discount is deducted again (once because the XML already deducted it, and second because it is removed in Order.TotalPriceWithoutTaxes), but only for the display.

If this is a liveintegration issue or BC issue or something else, we need to look further into.

I'll add integration team to this thread.

BR Nicolai

 
Dmitriy Benyuk Dynamicweb Employee
Dmitriy Benyuk
Reply

Hi Imar,
do you have the Live integration option "ERP controls discount calculations" ON?
Was this solution working before and then started to show wrong prices after some upgrade? Swift or Dynamicweb or Live integration package?
You can also share the solution url to investigate more
BR, Dmitrij

 
Imar Spaanjaars Dynamicweb Employee
Imar Spaanjaars
Reply

>> do you have the Live integration option "ERP controls discount calculations" ON?

Yes, I do:

 

It's a new setup. We did recently upgrade to resolve some other issues you and I discussed related to multiple LI calls for the same data.

I'll send you the URL and a frontend log-in.

Cheers,

Imar

 
Dmitriy Benyuk Dynamicweb Employee
Dmitriy Benyuk
Reply

Hi Imar,

that is a bug and will be fixed in #21473

BR, Dmitrij

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

Hi Imar,
this is now fixed in the new Live integration 10.4.6.
BR, Dmitrij

Votes for this answer: 1
 
Imar Spaanjaars Dynamicweb Employee
Imar Spaanjaars
Reply

Thanks Dmitrij! I downloaded 7.4.11 (I'm on 9.18) and that has fixed the issue:

Thanks!

Imar

 

You must be logged in to post in the forum