cancel
Showing results for 
Search instead for 
Did you mean: 

How to calculate tax in product detail page?

Former Member
0 Kudos
1,351

How to calculate taxe in product detail page? Which method does hybris provide to calculate tax in product detail page not in cart page?

I tried to with Euro1PriceFactory to get tax information but it returned both taxes which are in online catalog and staged catalog as well. How can I fix it?

Thank you.

Accepted Solutions (0)

Answers (3)

Answers (3)

Former Member
0 Kudos

Anyone could fix this problem? I see all the right informations in Cart Page but in PDP is applying the tax twice (I believe it is the same problem mentioned) and I'm using the latest version 6.3.0.2

former_member634278
Participant
0 Kudos

Hello,

Did you fix the issue! i have the same issue on details page?

Thanks

Former Member
0 Kudos

Hi Hoa,

If you want to obtain tax value assigned calculated for the product probably you will have to extend Europe1PriceFactory implementation or use existing methods in conjunction with some extra filtering rules for appropriate price information selection. Generally you should have a look at Europe1PriceFactory. There is an example how to get tax values for the product and how to do gross to net (and in the opposite direction) calculation.

 protected List getPriceInformations(SessionContext ctx, Product product, EnumerationValue productGroup, User user, EnumerationValue userGroup, Currency curr, boolean net, Date date, Collection taxValues)
     throws JaloPriceFactoryException{
     //....
 PriceInformation pInfo = Europe1Tools.createPriceInformation(row, curr);
 
 if (pInfo.getPriceValue().isNet() != net){
  if (theTaxValues == null){
          theTaxValues = Europe1Tools.getTaxValues(getTaxInformations(product, getPTG(ctx, product), user, 
             getUTG(ctx, user), date));
  }
  
  pInfo = new PriceInformation(pInfo.getQualifiers(), pInfo.getPriceValue().getOtherPrice(theTaxValues));
     //....
 }


If someone knows better way I am keen to find out how it could be simplified

Cheers, Michal

Former Member
0 Kudos

Have a look at what the DefaultCalculationService does, specifically the method calculateTotalTaxValues:

     protected void calculateTotalTaxValues(final AbstractOrderEntryModel entry)
     {
         final AbstractOrderModel order = entry.getOrder();
         final double quantity = entry.getQuantity().doubleValue();
         final double totalPrice = entry.getTotalPrice().doubleValue();
         final CurrencyModel curr = order.getCurrency();
         final int digits = curr.getDigits().intValue();
 
         entry.setTaxValues(TaxValue.apply(quantity, totalPrice, digits, entry.getTaxValues(), order.getNet().booleanValue(),
                 curr.getIsocode()));
     }