Hi,
I want Markup Rate to have two options. Either a percent either a fixed amount.
Based on my choice the calculation would be different for any of the options.
Before it try to do that i am struggling to understand how it is calculated bellow for the percent case.
Could you please help me understand this ?
Thank you.
|Mark up rate
|{% if y == 0 or y == blank %}{% input custom.costPlus.rate as:percentage default:costPlusMarkUp %}{% endif %}
{% for item in (1..y) %}
|{% input custom.costPlus.rate[item] as:percentage default:costPlusMarkUp %}
{% endfor %}
{% newline %}
|Cost Plus mark up
|
{% for item in (1..y) %}
{% assign markup = custom.costPlus.rate[item] | default:costPlusMarkUp %}
|{%=$10+ markup | times:total_profit[forloop.index0] | currency %}
{% endfor %}
{% if y == 0 or y == blank %}
{% assign markup = custom.costPlus.rate | default:costPlusMarkUp %}
{%$10+ markup*($1+$4) | currency %}
{% endif %}
|{{ $10 | currency }}
|
|{{ $12 | currency }}
{% newline %}
``
Hi Stefan, welcome back!
I could be missing something here, but what I can understand from this code extract is:
Probably, you have defined earlier in the code the amount of ‘items’ you have and stored that count as the ‘y’ variable.
So, in the case that there are no items defined ( y == 0 or blank), you will have the possibility to define a single rate (custom.costPlus.rate) which is going to be applied globally [ markup*($1+$2) ] and store that value in the register $10.
In the other scenario where items are defined (‘y’ is going to be a number different from 0), the for loops are going to be used. In that case, you will have one input field to define the rate to be applied to each item (custom.costPlus.rate[item]). Each of those rates individually defined, will be multiplied by the corresponding item from the ‘total_profit’ array and it will keep the sum in the register $10.
I hope this was useful and clear enough!
Best regards
Hi Augustin,
Thank you for you explanation.
I am still struggling to amend the code in order to have both option available in my template fixed and Percentage Mark up rate.
Could you please help me with this ?
Thank you,
Stefan