Developer forum

Forum » Development » Order price does not match in DIBS

Order price does not match in DIBS


Reply

Jeg har lavet en OrderTemplateExtender, der siger at kunder i DK der køber for mindre end 80 kr. skal ikke betale moms ellers er den 5%. Denne kode har jeg udviklet i samarbejde med Lars Sørensen på Forum siden. Link til forum tråden: http://engage.dynamicweb-cms.com/Forum-5.aspx?PID=34&action=ShowThread&ThreadID=2133

if (RenderingState == TemplateExtenderRenderingState.Before)
{
 if (base.Order.PriceBeforeFees.Price < 80 && Base.ChkString(base.Order.CustomerCountryCode).ToLower() == "dk")
 {
  foreach (OrderLine ol in base.Order.OrderLines)
  {
   ol.Price.PriceWithVAT = ol.Price.PriceWithoutVAT;
   ol.Save(base.Order.ID);
  }

  base.Order.Price.VAT = 0.0;
  base.Order.Price.PriceWithVAT = base.Order.Price.PriceWithoutVAT;
  base.Order.Save(base.Order.ID);
 }
}

Koden virker fint inde på hjemmesiden, men når kunden kommer ind på DIBS betalingen, så kommer momsen på igen.
Har forsøgt at købe 3x http://www.stamps.fo/Default.aspx?ID=1128&ProductID=PROD210 på den danske version af hjemmesiden.
3x PROD210 = 66 kr. + fragt og gebyr = 91 kr. på hjemmesiden (alt fint her). Klikker jeg så videre til DIBS, så er beløbet 94,30 kr.

Hvorfor er beløbene ikke overens ?
Hvilken parameter bliver overført til DIBS ?


Replies

 
Reply
 
Please write in english.
 
Instead of using a template extender to change VAT, you could try implementing a custom VatProvider...
 
 
public class CustomVatProvider : Dynamicweb.eCommerce.Orders.VatProvider
{
private const double DefaultVat = double.NaN;
 
        public override double FindVatPercent(double defaultVatPercent, Product product)
        {
            if (Dynamicweb.Permissions.Security.Environment.IsInBackend()) return DefaultVat;
 
            var cart = Dynamicweb.eCommerce.Common.Context.Cart;
            if (cart == null) return DefaultVat;
 
            if (cart.PriceBeforeFees.Price < 80 && Base.ChkString(cart.CustomerCountryCode).ToLower() == "dk")
                return 0.0;
 
            return DefaultVat;
        }
}

/Morten
 
Reply

Your code is invalid in DW 19.2.0.2 in several ways. Several deadlocks :(
The code looked nice at first glance, but i cant use it at all.

Its something going on backstage, that i cant control.

 
Reply

Sorry about that... I didn't actually test it :)

Another option: http://engage.dynamicweb-cms.com/Forum-5.aspx?action=ShowThread&ThreadID=2410

Or use a Discount?

It is usually the value of Order.Price.PricePIP that is transfered to the payment service.

/Morten 
 
Reply

The discount solution is not fitted.

The code always fails when fetching cart object, i.e. Dynamicweb.eCommerce.Common.Context.Cart
why is that ?

This code is what im trying to implement, see article from Morten: http://engage.dynamicweb-cms.com/Forum-5.aspx?action=ShowThread&ThreadID=2410

public PriceInfo FindPriceInfo(Dynamicweb.eCommerce.Products.Product Product, double Quantity, string VariantID,
            Dynamicweb.eCommerce.International.Currency Currency, string UnitID, Dynamicweb.Frontend.Extranet User)
        {
            if (Dynamicweb.eCommerce.Common.Context.LanguageID.Equals("LANG1"))
            {
                if (Dynamicweb.eCommerce.Common.Context.Cart.PriceBeforeFees.Price < 80)
                {
                    Dynamicweb.eCommerce.Prices.PriceInfo info = new Dynamicweb.eCommerce.Prices.PriceInfo();
                    info.Currency = Dynamicweb.eCommerce.Common.Context.Currency;
                    info.PriceWithoutVAT = Product.Price.PriceWithoutVAT;
                    info.PriceWithVAT = Product.Price.PriceWithVAT;
                    info.VAT = Product.Price.VAT;
                    info.VATPercent = Product.Price.VATPercent;
                    return info;
                }
            }

            return null;
        }

 
Reply
 Hello,

Dynamicweb.eCommerce.Common.Context.Cart could be null if user does not add product into his cart. Method ISupportPriceInfo.FindPriceInfo is called in Product catalogs and Ecom Cart. 

 

You must be logged in to post in the forum