Thanks to norman a month or so ago I managed to get actinic to do some php calculation for me when the site is generated.
The above php solution gives me a cost per unit ex vat
I now need to take this one step further.
I know that this is a complex one but any help would be appreciated.
<actinic:block php="true">
$units = '<actinic:variable name="CUST_UNITS_PER_OUTER" encoding="perl" selectable="false" />'; // load as string in case variable empty
if ( $units != '' )
{
$cost = '<actinic:variable name="ProductPriceRaw" encoding="perl" selectable="false" />'; // load as string in case variable empty
$cost = preg_replace('/£|,/', '', $cost); // remove any £ and ,
$unitcost = $cost / $units; // do the arithmetic
printf(' £%.2f', $unitcost);
}
</actinic:block>
$units = '<actinic:variable name="CUST_UNITS_PER_OUTER" encoding="perl" selectable="false" />'; // load as string in case variable empty
if ( $units != '' )
{
$cost = '<actinic:variable name="ProductPriceRaw" encoding="perl" selectable="false" />'; // load as string in case variable empty
$cost = preg_replace('/£|,/', '', $cost); // remove any £ and ,
$unitcost = $cost / $units; // do the arithmetic
printf(' £%.2f', $unitcost);
}
</actinic:block>
I now need to take this one step further.
- work out the unit cost + vat if applicable = UNIT COST INC
- Minus the UNIT COST INC from my variable <actinic:variable name="CUST_SELL_AT" /> = PROFIT
- then divide the PROFIT by the variable <actinic:variable name="CUST_SELL_AT" /> to give me the PROFIT ON RETURN
I know that this is a complex one but any help would be appreciated.
Comment