Developer forum

Forum » Integration » Discount Price Calculation Issue In BC

Discount Price Calculation Issue In BC

Ya Min Thu
Reply

Dear Support,

 

We use a standard integration code in BC, but we’ve encountered an issue when creating a standard order discount from DW. When the discounted order syncs to BC, the discount line is not created as a separate order line in BC. Instead, the item’s price is being overwritten by the discount amount, resulting in a negative price.

Below is an example of a 10% Off Order discount created in DW:

 
Here is the data setup in the Live Integration Add-In Settings for Discounts:

image

On the order receipt page, where the data is coming from BC's response, the product price is being overwritten with the negative discount amount:

This is the request that is syncing from DW to BC:

image

And this is the response syncing from BC to DW:

image

We noticed that the discount line is not recorded as an order line in BC. Instead of adding the discount line from the DW request as an order line, BC is overwriting the item's price with the negative discount value.

I have attached the order request and response for your reference. Could you please review this issue and provide suggestions? Thank you.

Best Regards,

Yamin


Replies

 
Dmitriy Benyuk Dynamicweb Employee
Dmitriy Benyuk
Reply

Hi Ya Min,
I was not able to reproduce the problem with the latest version of the codeunit extension which is 1.2.0.39 while yours is a bit old and it is 1.2.0.36.
Could you update to the latest version and check if the issue is solved there?
I was testing on regular prices (New Sales Pricing Experience feature was not activated)
BR, Dmitrij

 
Ya Min Thu
Reply

Dear Dmitrij,

Thank you for the update. We will proceed with the latest version and verify. In the meantime, could you please provide the request and response details of your testing order for our reference?

Best Regards,

Yamin

 
Dmitriy Benyuk Dynamicweb Employee
Dmitriy Benyuk
Reply

Hi Ya Min,
sure, it is almost the same as yours, so I have an item in BC which price is 10 and VAT is 20%. Shipping fee sent in the request: 15
You should also check if you don't use any custom coded subscribers/extensions that can cause the wrong output for the product order line xml.
Request:
<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<tables source="LiveIntegration" submitType="LiveOrderOrCart" referenceName="OrdersPut">
  <table tableName="EcomOrders">
    <item table="EcomOrders">
      <column columnName="OrderCustomerAccessUserExternalId">20000</column>
      <column columnName="OrderCustomerNumber">20000</column>
      <column columnName="CreateOrder">True</column>
      <column columnName="OrderId">ORDER12345-4</column>
      <column columnName="OrderAutoId">166082</column>
      <column columnName="OrderIntegrationOrderId"></column>
      <column columnName="OrderCurrencyCode"></column>
      <column columnName="OrderDate">2017/10/05 13:10:58</column>
      <column columnName="OrderPaymentMethodName" isInformationalOnly="True">PayPal</column>
      <column columnName="OrderPaymentMethodId">PAY8</column>
      <column columnName="OrderCustomerName">Customer name</column>
      <column columnName="OrderCustomerAddress">Address 1</column>
      <column columnName="OrderCustomerAddress2"></column>
      <column columnName="OrderCustomerCity">City</column>
      <column columnName="OrderCustomerState">State</column>
      <column columnName="OrderCustomerZip">Zip</column>
      <column columnName="OrderCustomerCountryCode">US</column>
      <column columnName="OrderCustomerEmail">test@example.com</column>
      <column columnName="OrderCustomerPhone">555-123-4567</column>
      <column columnName="OrderCustomerFax"></column>
      <column columnName="OrderDeliveryName">Delivery name</column>
      <column columnName="OrderDeliveryAddress">Address 1</column>
      <column columnName="OrderDeliveryAddress2"></column>
      <column columnName="OrderDeliveryCity">City</column>
      <column columnName="OrderDeliveryState">State</column>
      <column columnName="OrderDeliveryZip">Zip</column>
      <column columnName="OrderDeliveryCountryCode">US</column>
      <column columnName="OrderDeliveryEmail">test@example.com</column>
      <column columnName="OrderDeliveryPhone">555-123-4567</column>
      <column columnName="OrderDeliveryFax"></column>
      <column columnName="OrderCustomerComment"></column>
      <column columnName="OrderPriceTotal">759.64</column>
      <column columnName="OrderCaptureAmount">0</column>
      <column columnName="OrderVoucherCode"></column>
      <column columnName="OrderTransactionId">23S26030FP8012126</column>
      <column columnName="OrderStateId">OS1</column>
      <column columnName="OrderStateName" isInformationalOnly="True">New</column>
      <column columnName="OrderTransactionCardType" isInformationalOnly="True"></column>
      <column columnName="OrderTransactionCardExpiryDate" isInformationalOnly="True"></column>
      <column columnName="OrderTransactionMaskedCreditCardNumber" isInformationalOnly="True"></column>
      <column columnName="CardHolderFirstName" isInformationalOnly="True"></column>
      <column columnName="CardholderLastName" isInformationalOnly="True"></column>
      <column columnName="ShippingInstructions" isCustomField="True"></column>
      <column columnName="PONumber" isCustomField="True"></column>
      <column columnName="SaveUser" isCustomField="True">False</column>
      <column columnName="IsBackedByIntegration" isCustomField="True">False</column>
      <column columnName="LastSyncDate" isCustomField="True">1970/01/01 00:00:00</column>
      <column columnName="ErpControlsDiscount">False</column>
<column columnName="OrderShippingMethodId">SHIP16</column>
<column columnName="OrderShippingFee">15</column>
<column columnName="OrderShippingFeeWithoutVat">15</column>
<column columnName="OrderShippingItemKey">DW-SHIP</column>
    </item>
  </table>
  <table tableName="EcomOrderLines">
    <item table="EcomOrderLines">
      <column columnName="OrderLineId">OL363129</column>
      <column columnName="OrderLineOrderId">ORDER463</column>
      <column columnName="OrderLineParentLineId"></column>
      <column columnName="OrderLineProductId">1000</column>
      <column columnName="OrderLineProductVariantId"></column>
      <column columnName="OrderLineProductNumber">1000</column>
      <column columnName="OrderLineProductName">Product name</column>
      <column columnName="OrderLineQuantity">1</column>
      <column columnName="OrderLinePriceWithoutVat">12</column>
      <column columnName="OrderLineUnitPriceWithoutVat">12</column>
      <column columnName="NetPrice">223</column>
      <column columnName="OrderLineType">0</column>
      <column columnName="OrderLineTypeName" isInformationalOnly="True">Product</column>
      <column columnName="OrderLineBom">False</column>
      <column columnName="OrderLineBomItemId"></column>
      <column columnName="OrderLineGiftCardCode"></column>
      <column columnName="OrderLineIsGiftCardDiscount" isCustomField="True">False</column>
      <column columnName="OrderLineFieldValues">&lt;OrderLineFieldValueCollection /&gt;</column>
    </item>
<item table="EcomOrderLines">
<column columnName="OrderLineId">OL363131</column>
<column columnName="OrderLineOrderId">ORDER463</column>
<column columnName="OrderLineParentLineId"></column>
<column columnName="OrderLineProductId"></column>
<column columnName="OrderLineProductVariantId"></column>
<column columnName="OrderLineProductNumber"></column>
<column columnName="OrderLineProductName">10%OffForCredit</column>
<column columnName="OrderLineProductIdentifier">..</column>
<column columnName="OrderLineQuantity">1</column>
<column columnName="OrderLineUnitId"></column>
<column columnName="OrderLinePriceWithoutVat">-1.2</column>
<column columnName="OrderLineUnitPriceWithoutVat">-1.2</column>
<column columnName="NetPrice"></column>
<column columnName="OrderLineType">1</column>
<column columnName="OrderLineTypeName">Discount</column>
<column columnName="OrderLineBom">False</column>
<column columnName="OrderLineBomItemId"></column>
<column columnName="OrderLineGiftCardCode"></column>
<column columnName="OrderLineIsGiftCardDiscount" isCustomField="True">False</column>
<column columnName="OrderLineFieldValues">&lt;OrderLineFieldValueCollection /&gt;</column>
<column columnName="OrderLineDiscountId">2220</column>
<column columnName="OrderLineDiscountName">10%OffForCredit</column>
<column columnName="OrderLineCampaignName"></column>
<column columnName="OrderLineDiscountType">Percentage</column>
<column columnName="OrderLineDiscountValue">10</column>
</item>
  </table>
</tables>

Response:
<?xml version="1.0" encoding="utf-16"?>
<tables version="1.2.0.39_NAV24.0.22865.0">
  <table tableName="EcomOrderLines">
    <item table="EcomOrderLines">
      <column columnName="OrderLineProductNumber"><![CDATA[1000]]></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[10]]></column>
      <column columnName="OrderLineUnitPriceWithoutVat"><![CDATA[10.00]]></column>
      <column columnName="OrderLinePriceWithVat"><![CDATA[12]]></column>
      <column columnName="OrderLineUnitPriceWithVat"><![CDATA[12]]></column>
      <column columnName="OrderLinePriceVat"><![CDATA[2]]></column>
      <column columnName="OrderLineUnitPriceVat"><![CDATA[2]]></column>
      <column columnName="OrderLinePriceVatPercent"><![CDATA[20]]></column>
      <column columnName="OrderLineUnitPriceVatPercent"><![CDATA[20]]></column>
    </item>
    <item table="EcomOrderLines">
      <column columnName="OrderLineProductNumber"><![CDATA[]]></column>
      <column columnName="OrderLineProductName"><![CDATA[10%OffForCredit]]></column>
      <column columnName="OrderLineProductVariantId"><![CDATA[]]></column>
      <column columnName="OrderLineProductName"><![CDATA[2220]]></column>
      <column columnName="OrderLineQuantity"><![CDATA[1]]></column>
      <column columnName="OrderLineType"><![CDATA[1]]></column>
      <column columnName="OrderLinePriceWithoutVat"><![CDATA[-1.2]]></column>
      <column columnName="OrderLineUnitPriceWithoutVat"><![CDATA[-1.2]]></column>
    </item>
  </table>
  <table tableName="EcomOrders">
    <item table="EcomOrders">
      <column columnName="OrderShippingMethodName"><![CDATA[]]></column>
      <column columnName="OrderShippingMethodId"><![CDATA[SHIP16]]></column>
      <column columnName="OrderShippingFee"><![CDATA[15]]></column>
      <column columnName="OrderCreated"><![CDATA[TRUE]]></column>
      <column columnName="OrderId"><![CDATA[BD00013]]></column>
      <column columnName="OrderCurrencyCode"><![CDATA[]]></column>
      <column columnName="OrderDate"><![CDATA[08/30/24]]></column>
      <column columnName="OrderPaymentMethodName"><![CDATA[]]></column>
      <column columnName="OrderCustomerName"><![CDATA[20000]]></column>
      <column columnName="OrderCustomerAddress"><![CDATA[Address 1]]></column>
      <column columnName="OrderCustomerAddress2"><![CDATA[]]></column>
      <column columnName="OrderCustomerCity"><![CDATA[City]]></column>
      <column columnName="OrderCustomerCountryCode"><![CDATA[]]></column>
      <column columnName="OrderCustomerEmail"><![CDATA[]]></column>
      <column columnName="OrderCustomerFax"><![CDATA[]]></column>
      <column columnName="OrderCustomerPhone"><![CDATA[]]></column>
      <column columnName="OrderCustomerZip"><![CDATA[ZIP]]></column>
      <column columnName="OrderDeliveryName"><![CDATA[Delivery name]]></column>
      <column columnName="OrderDeliveryAddress"><![CDATA[Address 1]]></column>
      <column columnName="OrderDeliveryAddress2"><![CDATA[]]></column>
      <column columnName="OrderDeliveryCity"><![CDATA[City]]></column>
      <column columnName="OrderDeliveryCountryCode"><![CDATA[]]></column>
      <column columnName="OrderDeliveryEmail"><![CDATA[]]></column>
      <column columnName="OrderDeliveryFax"><![CDATA[]]></column>
      <column columnName="OrderDeliveryPhone"><![CDATA[]]></column>
      <column columnName="OrderDeliveryZip"><![CDATA[ZIP]]></column>
      <column columnName="OrderPriceWithVat"><![CDATA[25.8]]></column>
      <column columnName="OrderPriceWithoutVat"><![CDATA[23.8]]></column>
      <column columnName="OrderPriceVat"><![CDATA[2]]></column>
      <column columnName="OrderSalesDiscount"><![CDATA[0]]></column>
    </item>
  </table>
</tables>

BR, Dmitrij

 

You must be logged in to post in the forum