Developer forum

Forum » Integration » BC Live Prices with different unit of measure

BC Live Prices with different unit of measure

Chris Søgaard
Chris Søgaard
Reply

Hi DW

We have a request from a client that want to use different unit of measures when calculating live prices. But it seems like the request for getting live prices is always using the base unit (in this case STK) when calculating prices.

The client have the following setup of unit and prices in BC:

1 KASSE - 400 base units - 35.000 DKK - Base unit price 87,5 DKK
1 PAKKE - 144 base units - 12.000 DKK - Base unit price 83,33 DKK
1 PALLE - 5000 base units - 400.000 DKK -Base unit price 80,00 DKK
1 STK - 1 base units - 90,00 DKK - Base unit price 90,00 DKK

When we execute a request for live prices we get the following request/response:

Request:

<GetEcomData AccessUserCustomerNumber="56222000">
  <tables>
    <Products type="filter" unitPrices="true">
      <Product>
        <ProductId>6127201390</ProductId>
        <ProductVariantId></ProductVariantId>
        <ProductNumber>6127201390</ProductNumber>       
        <ProductIdentifier></ProductIdentifier> 
        <CurrencyCode>DKK</CurrencyCode>
        <Quantity>400</Quantity>
      </Product>
    </Products>
  </tables>
</GetEcomData>

Response:

<?xml version="1.0" encoding="utf-16"?>
<tables version="1.2.0.19_NAV19.0.29884.32731">
  <table tableName="EcomProducts">
    <item table="EcomProducts">
      <column columnName="ProductId"><![CDATA[6127201390]]></column>
      <column columnName="ProductVariantId"><![CDATA[]]></column>
      <column columnName="ProductIdentifier"><![CDATA[]]></column>
      <column columnName="ProductNumber"><![CDATA[6127201390]]></column>
      <column columnName="ProductPrice"><![CDATA[90]]></column>
      <column columnName="ProductStock"><![CDATA[0]]></column>
      <column columnName="ProductCurrencyCode"><![CDATA[]]></column>
      <column columnName="ProductDefaultUnitId"><![CDATA[Unit_STK]]></column>
    </item>
  </table>
  <table tableName="EcomPrices">
    <item table="EcomPrices">
      <column columnName="PriceProductId"><![CDATA[6127201390]]></column>
      <column columnName="PriceUserCustomerNumber"><![CDATA[56222000]]></column>
      <column columnName="PriceProductUnitId"><![CDATA[Unit_KASSE]]></column>
      <column columnName="PriceQuantity"><![CDATA[400]]></column>
      <column columnName="PriceAmount"><![CDATA[90]]></column>
    </item>
    <item table="EcomPrices">
      <column columnName="PriceProductId"><![CDATA[6127201390]]></column>
      <column columnName="PriceUserCustomerNumber"><![CDATA[56222000]]></column>
      <column columnName="PriceProductUnitId"><![CDATA[Unit_PAKKE]]></column>
      <column columnName="PriceQuantity"><![CDATA[144]]></column>
      <column columnName="PriceAmount"><![CDATA[90]]></column>
    </item>
    <item table="EcomPrices">
      <column columnName="PriceProductId"><![CDATA[6127201390]]></column>
      <column columnName="PriceUserCustomerNumber"><![CDATA[56222000]]></column>
      <column columnName="PriceProductUnitId"><![CDATA[Unit_PALLE]]></column>
      <column columnName="PriceQuantity"><![CDATA[5,000]]></column>
      <column columnName="PriceAmount"><![CDATA[90]]></column>
    </item>
    <item table="EcomPrices">
      <column columnName="PriceProductId"><![CDATA[6127201390]]></column>
      <column columnName="PriceUserCustomerNumber"><![CDATA[56222000]]></column>
      <column columnName="PriceProductUnitId"><![CDATA[Unit_STK]]></column>
      <column columnName="PriceQuantity"><![CDATA[1]]></column>
      <column columnName="PriceAmount"><![CDATA[90]]></column>
    </item>
  </table>
</tables>

This will calculate the prices based on the base unit (STK) and this correlates with BC standard. So if you create the following sales lines in BC will create the following prices:

  • 400 base units = 36.000 DKK = 90 DKK pr. base unit
  • 1 kasse = 400 base units = 35.000 DKK = 87,5 DKK pr. base unit.

So we need a way to calculate live prices based on unit of measure instead of base unit. Do we have any way to do that: I have checked the documentation here and cannot seem to find any way to control the unit of measure when calculating the price: https://doc.dynamicweb.com/documentation-9/integration/integration-framework-2/requests-responses#sideNavTitle1-3

Client is running BC Cloud version 19 with code unit version 1.2.0.19.

Best regards

Chris Søgaard

 


Replies

 
Mads Knudsen
Reply

any news regarding this?

 
Dmitriy Benyuk Dynamicweb Employee
Dmitriy Benyuk
Reply

Hi Chris and Mads,
this requires a new feature to be implemented.
Do you only need to fix the prices in the fields EcomPrices/"PriceAmount" so it will output the correct unit prices?
Or is it needed smth else to be implemented?
Kind regards, Dmitrij

 

 
Chris Søgaard
Chris Søgaard
Reply

Hi Dmitrij

We will tell the customer, that this is currently not supported, but it would be great to have it included in an upcoming release.

Ideally it would be great if we have an input parameter for the unit that should be used for calculation on both Live Integration (https://doc.dynamicweb.com/documentation-9/integration/integration-framework-2/requests-responses#10083) and batch import (https://doc.dynamicweb.com/documentation-9/integration/integration-framework-2/requests-responses#10612).

If the response would then return the following

  • Unit used for calculation.
  • Unit price of the unit used for calculation
  • Either base unit quantity (number of base units in the unit used for calculation) or the base unit price or both.

This should of course also be taken into consideration when calculating order, if not already (I guess create order will just create the order according to BC standard)

This would be great for this specific customer's requirement, but I don't know how that would fit into your solution.

BR Chris

 
Dmitriy Benyuk Dynamicweb Employee
Dmitriy Benyuk
Reply

Hi Chris,
It is unclear why do you need this new feature?
If we will go for this new feature then how will it help you? It will also require some special customizations on the live integration probably,
I can not find out since I don't see the purpose of this change.

The current feature outputs all prices for all available Units of measure per product, if the output prices are not correct they can be fixed.
Then on the frontend you can use the "Product.Prices" loop to output all available prices depending on the unit and quantity.
If you need to find out specific unit price you can look in the Live integration productInfo["Prices"] object and all returned prices will be available there.

For the Orders we already have the field called "OrderLineUnitId" so you can pass the selected unit there.

So if we will include the "ProductUnitId" into the request it would be like that:
 <Product>
        <ProductId>1</ProductId>
        <Quantity>123</Quantity>
        <ProductUnitId>Unit_PALLE</ProductUnitId>
      </Product>
 <Product>
        <ProductId>2</ProductId>
        <Quantity>321</Quantity>
        <ProductUnitId>Unit_PAKKE</ProductUnitId>
      </Product>
and the response will output the unit price into the "ProductPrice" fields:

<?xml version="1.0" encoding="utf-16"?>
<tables version="1.2.0.19_NAV19.0.29884.32731">
  <table tableName="EcomProducts">
    <item table="EcomProducts">
      <column columnName="ProductId"><![CDATA[1]]></column>
      <column columnName="ProductPrice"><![CDATA[80]]></column>
      
<column columnName="ProductUnitId"><![CDATA[Unit_PALLE]]></column>
      <column columnName="ProductDefaultUnitId"><![CDATA[Unit_STK]]></column>
    </item>
....output all EcomPrices if unitPrices="true"...
    <item table="EcomProducts">
      <column columnName="ProductId"><![CDATA[2]]></column>
      <column columnName="ProductPrice"><![CDATA[83]]></column>
      
<column columnName="ProductUnitId"><![CDATA[Unit_PAKKE]]></column>
      <column columnName="ProductDefaultUnitId"><![CDATA[Unit_STK]]></column>
    </item>
....output all EcomPrices if unitPrices="true"...


The price for the DefaultUnit will be in the EcomPrices output as it is today:
 <item table="EcomPrices">
      <column columnName="PriceProductId"><![CDATA[6127201390]]></column>
      <column columnName="PriceUserCustomerNumber"><![CDATA[56222000]]></column>
      <column columnName="PriceProductUnitId"><![CDATA[Unit_STK]]></column>
      <column columnName="PriceQuantity"><![CDATA[1]]></column>
      <column columnName="PriceAmount"><![CDATA[90]]></column>
    </item>

BR, Dmitrij

 
Chris Søgaard
Chris Søgaard
Reply

Hi Dmitrij

I think we misunderstand each other.

Regarding the live integration, I was just brainstorming on how it could be solved, but of course you know better about implementation in code unit here. It will work just as fine if the live integration just outputs all unit prices like it does today, with the UnitId, the BaseQuantity and the price of that unit (not the base price). So going back to my original comment which started this thread, if we have the following example:

1 KASSE - 400 base units - 35.000 DKK - Base unit price 87,5 DKK
1 PAKKE - 144 base units - 12.000 DKK - Base unit price 83,33 DKK
1 PALLE - 5000 base units - 400.000 DKK -Base unit price 80,00 DKK
1 STK - 1 base units - 90,00 DKK - Base unit price 90,00 DKK

We would need a response with this data (please don't emphasize on the field naming, but only the data in the fields):

<?xml version="1.0" encoding="utf-16"?>
<tables version="1.2.0.19_NAV19.0.29884.32731">
  <table tableName="EcomProducts">
    <item table="EcomProducts">
      <column columnName="ProductId"><![CDATA[6127201390]]></column>
      <column columnName="ProductVariantId"><![CDATA[]]></column>
      <column columnName="ProductIdentifier"><![CDATA[]]></column>
      <column columnName="ProductNumber"><![CDATA[6127201390]]></column>
      <column columnName="ProductPrice"><![CDATA[90]]></column>
      <column columnName="ProductStock"><![CDATA[0]]></column>
      <column columnName="ProductCurrencyCode"><![CDATA[]]></column>
      <column columnName="ProductDefaultUnitId"><![CDATA[Unit_STK]]></column>
    </item>
  </table>
  <table tableName="EcomPrices">
    <item table="EcomPrices">
      <column columnName="PriceProductId"><![CDATA[6127201390]]></column>
      <column columnName="PriceUserCustomerNumber"><![CDATA[56222000]]></column>
      <column columnName="PriceProductUnitId"><![CDATA[Unit_KASSE]]></column>
      <column columnName="PriceQuantity"><![CDATA[400]]></column>
      <column columnName="PriceAmount"><![CDATA[35,000]]></column>
    </item>
    <item table="EcomPrices">
      <column columnName="PriceProductId"><![CDATA[6127201390]]></column>
      <column columnName="PriceUserCustomerNumber"><![CDATA[56222000]]></column>
      <column columnName="PriceProductUnitId"><![CDATA[Unit_PAKKE]]></column>
      <column columnName="PriceQuantity"><![CDATA[144]]></column>
      <column columnName="PriceAmount"><![CDATA[12,000]]></column>
    </item>
    <item table="EcomPrices">
      <column columnName="PriceProductId"><![CDATA[6127201390]]></column>
      <column columnName="PriceUserCustomerNumber"><![CDATA[56222000]]></column>
      <column columnName="PriceProductUnitId"><![CDATA[Unit_PALLE]]></column>
      <column columnName="PriceQuantity"><![CDATA[5,000]]></column>
      <column columnName="PriceAmount"><![CDATA[400,000]]></column>
    </item>
    <item table="EcomPrices">
      <column columnName="PriceProductId"><![CDATA[6127201390]]></column>
      <column columnName="PriceUserCustomerNumber"><![CDATA[56222000]]></column>
      <column columnName="PriceProductUnitId"><![CDATA[Unit_STK]]></column>
      <column columnName="PriceQuantity"><![CDATA[1]]></column>
      <column columnName="PriceAmount"><![CDATA[90]]></column>
    </item>
  </table>
</tables>

The problem here would then be, that the way (as I understand) this is calculated today would be Amount * Quantity = Total price, but I think that we would need the price amount to be the price of the entire unit and not the price of the base unit in that unit, because you would end up in some rounding issues, if you only get the base unit price from response. 

E.g. if a unit consists of 41 base units and this unit costs 100 DKK, then the base unit price would be (rounded) 2,44 DKK but 2,44 DKK * 41 base units would not be 100 DKK.

Furthermore it would be great if this feature could be implemented when batch importing prices as well for customers using this feature but are not (or cannot) using Live Integration, but this is not required on this specific customer. 

 

 

You must be logged in to post in the forum