I have been trying to get this working but I think I am doing something wrong. Basically, i have a custom property on a product called "OVERIDE_VAT" and I am trying to get this value in a function.
So my function is saying:
Public Function CalculateTax(ByVal product As UCommerce.EntitiesV2.Product, ByVal priceGroup As UCommerce.EntitiesV2.PriceGroup, ByVal unitPrice As UCommerce.EntitiesV2.PriceGroupPrice) As UCommerce.Money Implements ITaxService.CalculateTax
Dim taxAmount As Decimal = 0 Dim taxExempt As String = product("OVERIDE_VAT").Value ??
' I want to say if taxExempt return 0 else return something else
Doh! Sorry don't mind me! It was pretty much what i had - posted below in case anyone else needs it.
Public Function CalculateTax(ByVal product As UCommerce.EntitiesV2.Product, ByVal priceGroup As UCommerce.EntitiesV2.PriceGroup, ByVal unitPrice As UCommerce.EntitiesV2.PriceGroupPrice) As UCommerce.Money Implements ITaxService.CalculateTax
Dim taxAmount As Decimal = 0
Try If product.IsVariant Then
If Not product("OVERIDE_VAT").Value Is Nothing Then If product.ParentProduct("OVERIDE_VAT").Value = False Then taxAmount = product.GetPrice(priceGroup).Price * priceGroup.VATRate End If Else taxAmount = product.GetPrice(priceGroup).Price * priceGroup.VATRate End If
Else
If Not product("OVERIDE_VAT").Value Is Nothing Then If product("OVERIDE_VAT").Value = False Then taxAmount = product.GetPrice(priceGroup).Price * priceGroup.VATRate End If Else taxAmount = product.GetPrice(priceGroup).Price * priceGroup.VATRate End If End If Catch
End Try
Return New Money(taxAmount, CultureInfo.InvariantCulture, priceGroup.Currency)
Get a custom property value in .NET
Hi Guys,
I have been trying to get this working but I think I am doing something wrong. Basically, i have a custom property on a product called "OVERIDE_VAT" and I am trying to get this value in a function.
So my function is saying:
Public Function CalculateTax(ByVal product As UCommerce.EntitiesV2.Product, ByVal priceGroup As UCommerce.EntitiesV2.PriceGroup, ByVal unitPrice As UCommerce.EntitiesV2.PriceGroupPrice) As UCommerce.Money Implements ITaxService.CalculateTax
Dim taxAmount As Decimal = 0
Dim taxExempt As String = product("OVERIDE_VAT").Value ??
' I want to say if taxExempt return 0 else return something else
End Function
Please help!
Kenny
Doh! Sorry don't mind me! It was pretty much what i had - posted below in case anyone else needs it.
Public Function CalculateTax(ByVal product As UCommerce.EntitiesV2.Product, ByVal priceGroup As UCommerce.EntitiesV2.PriceGroup, ByVal unitPrice As UCommerce.EntitiesV2.PriceGroupPrice) As UCommerce.Money Implements ITaxService.CalculateTax
Dim taxAmount As Decimal = 0
Try
If product.IsVariant Then
If Not product("OVERIDE_VAT").Value Is Nothing Then
If product.ParentProduct("OVERIDE_VAT").Value = False Then
taxAmount = product.GetPrice(priceGroup).Price * priceGroup.VATRate
End If
Else
taxAmount = product.GetPrice(priceGroup).Price * priceGroup.VATRate
End If
Else
If Not product("OVERIDE_VAT").Value Is Nothing Then
If product("OVERIDE_VAT").Value = False Then
taxAmount = product.GetPrice(priceGroup).Price * priceGroup.VATRate
End If
Else
taxAmount = product.GetPrice(priceGroup).Price * priceGroup.VATRate
End If
End If
Catch
End Try
Return New Money(taxAmount, CultureInfo.InvariantCulture, priceGroup.Currency)
End Function
Thanks for posting your solution. Appreciate it!
Love the "If Not Is Nothing" double negative of VB by the way. Almost forgot about that :)
is working on a reply...
This forum is in read-only mode while we transition to the new forum.
You can continue this topic on the new forum by tapping the "Continue discussion" link below.