Hello,
We are trying to add a formula in the Sale pack, for the Quote entity.
We want to adapt the calculation of taxes, in order to :
- deal with countries in which multiple taxes apply (ex : Canada)
- deal with different names of taxes for the different countries we work with
We want to implement the following solution :
- in QuoteItem : rename field taxRate to taxRate1 and add taxRate2 (float)
- in Quote : add text fields taxName1 and taxName2
- in Quote : add the formula that would make a loop on items in order to calculate the taxAmount1 and taxAmount2
- Adapt the quote template in order to display taxName1, taxName2, taxAmount1 and taxAmount2
For the formula part of the solution, we are stuck finding the right way to loop over quote items in order to do the tax calculation.
Here is the global shape of the formula we are trying to add :
Can someone help us ?
Thank you in advance
We are trying to add a formula in the Sale pack, for the Quote entity.
We want to adapt the calculation of taxes, in order to :
- deal with countries in which multiple taxes apply (ex : Canada)
- deal with different names of taxes for the different countries we work with
We want to implement the following solution :
- in QuoteItem : rename field taxRate to taxRate1 and add taxRate2 (float)
- in Quote : add text fields taxName1 and taxName2
- in Quote : add the formula that would make a loop on items in order to calculate the taxAmount1 and taxAmount2
- Adapt the quote template in order to display taxName1, taxName2, taxAmount1 and taxAmount2
For the formula part of the solution, we are stuck finding the right way to loop over quote items in order to do the tax calculation.
Here is the global shape of the formula we are trying to add :
Code:
$items = record\findRelatedMany('Quote', id, 'items', 100); $count = array\length($items); ifThen( $count > 0, ( $totalTax1 = 0; $totalTax2 = 0; $i=0; while( $i < $count, ( $itemId = array\at($items, $i); // TODO : get quote item with id $itemId ? // $totalTax1 = $totalTax1 + $item.amount * $item.taxRate1/100; // $totalTax2 = $totalTax2 + $item.amount * $item.taxRate2/100; $i = $i+1; ) ) ) //taxAmount = $totalTax1; //taxAmount2 = $totalTax2; );
Thank you in advance
Comment