Developer forum

Forum » Development » Performance issue with ReverseChargeForVatEnabled

Performance issue with ReverseChargeForVatEnabled

Anders Ebdrup
Anders Ebdrup
Reply

Dear Dynamicweb,

 

We have some rather serious performance issues when ReverseChargeForVatEnabled is set to true. It is located in 9.6.14.

For every line in the basket, the price is recalculated for each request. We see this issue in a B2B shop where carts have 40-50 lines and most users are from other EU countries needing this setting; ReverseChargeForVatEnabled .

It is caused by the line marked with yellow:

        Public Property UnitPrice As PriceInfo
            Get
                If HasType(OrderLineType.Product) Then
                    If Order.Calculate Then
                        If CachedPrice IsNot Nothing AndAlso CachedPrice.Currency.Equals(Currency) AndAlso Not Common.Context.ReverseChargeForVatEnabled Then
                            Return CachedPrice
                        End If

                        Dim info As New PriceInfo(Currency)

                        'tfc : Refactored the PriceManager to return object. If the Provider implements the ISupportPriceInfo, then you can override the FindPriceInfo
                        If BomOrderLines.Count > 0 Then
                            If Product.PriceType = ProductPriceType.FixedPrice Then
                                info = info.Add(If(FindPrice(includeUnitId:=True), New PriceInfo(Currency)))
                            Else
                                'Adding only the BOM Orderlines
                                info = info.Add(BomOrderLines).Divide(Quantity)
                            End If

                            If Product.PriceType = ProductPriceType.CalculatedWithBase Then
                                info = info.Add(If(FindPrice(includeUnitId:=False), New PriceInfo(Currency)))
                            End If
                        Else
                            info = info.Add(If(FindPrice(includeUnitId:=True), New PriceInfo(Currency)))
                        End If

                        If CachedPrice Is Nothing OrElse Not info.HasSamePrice(CachedPrice) Then
                            _isDirty = True
                        End If

                        CachedPrice = info
                        Return info
                    Else
                        Return _unitPrice
                    End If
                ElseIf HasType(OrderLineType.PointProduct) Then
                    _unitPrice = New PriceInfo(Currency)
                    Return _unitPrice
                Else
                    If Order.Calculate AndAlso Currency IsNot Nothing AndAlso Not String.Equals(_unitPrice.Currency.Code, Currency.Code, StringComparison.Ordinal) Then
                        _isDirty = True
                        Return _unitPrice.ToPrice(Currency)
                    Else
                        Return _unitPrice
                    End If
                End If
            End Get
            Set
                If _unitPrice Is Nothing OrElse Not _unitPrice.HasSamePrice(Value) Then
                    _isDirty = True
                End If
                _unitPrice = Value
                CachedPrice = Nothing
            End Set
        End Property

 

Can you please look into adding some cache when ReverseChargeForVatEnabled is set to true?

 

Best regards, Anders


Replies

 
Nicolai Pedersen
Reply

Hi Anders

Could you set vat to 0% for the countries in EU instead of using reverse vat?

There is no quick fix to the issue above since it is messing with price calculations which needs a thourough analysis and test before we can release anything...

BR Nicolai

 
Anders Ebdrup
Anders Ebdrup
Reply

Dear Nicolai,

 

We are also handling B2C-customers in the shop, which needs to pay the VAT, so I guess that this workaround is not possible?

 

Best regards, Anders

 
Anders Ebdrup
Anders Ebdrup
Reply

Dear Nicolai,

 

Any other thoughts on this one?

 

You must be logged in to post in the forum