Developer forum

Forum » Integration » LiveIntegration v1, NAV and GiftCards

LiveIntegration v1, NAV and GiftCards

Kenneth Radoor
Reply

Hi

We have a shop where it is posible to buy a giftcard at any amount > 200.

When a customer buys a giftcard we have to change the OrderLineType (in ProcessResponse) to OrderLineType.GiftCard, otherwise it will not be created in DW. 

So far so good, it seems to work and the order gets created both in DW and in NAV.

The problem is when the Customer wants to redeem the giftcard, then we get some strange behaivor.

We have enabled the "LiveSalesDiscountProvider", so when we submit the order with the giftcard-code the ordertotal is subtracted with the right amount.

If we then update the order, we get the one more orderline with the giftcard as a product and as a discount.

We havn't been able to find any documentation or advice on how to handle this in a best practice way, so please advice !!

We are using a pretty standard LiveIntegration v1, and are looking for sample code or stuff like that, on how to handle this senario in DW and in NAV.

Regards and thanks in advance

/Kenneth


Replies

 
Dmitriy Benyuk Dynamicweb Employee
Dmitriy Benyuk
Reply

Hi Kenneth,
You can try to made some changes in the OrderHandler.cs ProcessResponse method:
Set
order.DisableDiscountCalculation = true;
after the line:
order.AllowOverridePrices = true;

Best regards, Dmitrij

 
Kenneth Radoor
Reply

Hi Dmitrij

That didn't help :(

The thing is that DW has to handle the Giftcard, and send the info to NAV. 

I can see that when a giftcard is redeemed, it is created as a orderdiscount, so my thought is that it would be send this discount as an orderline to NAV. Then the order gets calculated in NAV and it looks ok.

As we are using a single step cart, it is posible to change the amount of products to be purchased. if we change the amount then the orderdiscount disappears from the cart and the database.
But it is stille send via the xml to NAV, thats wierd.

Another problem is that we have an "apply button" below the giftcardcode field, and would like to have the cart updated when its clicked. That works fine for the DW part, but as there is no notification we can hook into, the order is not sent to NAV, unless we do something that trickers the LiveIntegration to run.
In this case i have added observers for AfterPaymentMethodIsChanged and AfterShippingMethodIsChanged, so entering a giftcardcode and changing eg. the paymentmethod does the trick. But just entering a giftcardcode does nothing.

I have tried different other notifications but can't find any that is usefull, my best guess would be AfterDefaultPropertiesValueIsChanged and then check for propertyname "GiftCardCode", but it does'nt do anything.

I need advice on what to do in the LiveIntegration code, to send the proper data to NAV, and what changed that needs to be done in the NAV codeunit, so that i can advise the NAV-consultant on what to do.

Any suggestions will be much appriciated.

I have attached the OrderHandler from my project, and if you like i can send you the complete project. All additions i have made to the code is enclosed in a regions called CustomCodes, and there is a few comments on why they are there

Regards Kenneth

 
Umar Farooq
Reply

Hi,

We are facing the similer issue, When we add gift card voucher code it create's an orderline but none of the notification handler is triggered. I was expecting it to trigger either one of the notification subscriber Cartloaded or Line added. also tried AfterDefaultPropertiesValueIsChanged and OrderValuesChanged but none of these has correct information.

we are running on LiveIntegration V2. If we uncheck the option "Dicount is handled by ERP system" gift cart calculation works but we can't uncheck this option because in some cases discount is coming from the ERP system. If the checkbox is checked and gift card is added then we can see gift card orderline but cart is not calculated correctly and it doesn't take gift card orderline into considration.

Any suggestion on how to solve this issue?

/umar 

 

 
Dan Hørlyck Kristensen
Dan Hørlyck Kristensen
Reply

I will give you a general answer here. Finding the best standard solution or suggesting the best custom approach requires more knowledge of the architectural decisions made in a given customer project. If you need assistance beyond my general answer, then let us take the discussion offline. I will send you the first email.

General Answer

The checkbox 'ERP controls discount calculations' is there for one clear reason. We do not allow you to mix discount calculations from multiple systems. You must decide where your system of record is before anything else. This means you either use NAV for invoice and item discounts or Dynamicweb for order and product discounts. This extends to products as well. You cannot transact products (giftcards) if they do not exist in NAV.

Dynamicweb as System of Record for Discounts

If you choose Dynamicweb as system of record, then you must define all order and product discounts in Dynamicweb. This must work together with Dynamicweb Giftcards. If it does not, then we will fix it as a bug (for Integration Framework v2). Integration framework v1 is in phaseout and requires a special agreement.

The possible downside here is that your end customer wants to use discounts from NAV. If that is the case, then you must batch import discounts and have Dynamicweb apply them. That requires custom work on the codeunit and mapping a new integration activity to batch it to Dynamicweb's database.

ERP/NAV as System of Record for Discounts

If you choose NAV as system of record then you must also use gift cards/vouchers from NAV. These would have to be batch imported to Dynamicweb, so they can be purchased by users. When a NAV gift card is placed in the cart, then NAV can also calculate the correct cart price and it can handle the orderline entries (because all entries originate from NAV).

The possible downside here is that your end customer cannot use gift cards in Dynamicweb. Plus the codeunit would need to be modified. First, the batch reponse to send NAV gift cards over. Second, live order/price calculation would need to recieve and handle gift cards.

My Project is different 

If the general answer does not work for you, then you have these options.

  1. Extend live integration. It will be your responsibility to resolve race conditions when multiple discount types from multiple systems compete to apply discounts with disparate business logic.  If you lack an extensibility point in live integration (which Kenneth might) then let us know and we will create a feature request for you.
  2. Wait for a standard solution. 

 

You must be logged in to post in the forum