Can ZP calculate percentages?

shabbysquire

Client
Регистрация
25.11.2012
Сообщения
544
Благодарностей
26
Баллы
28
Would like to know how to get ZP to calculate percentages. i.e. I need to take a price, then add, say, 13.5% to the total.

Is this possible?
 

lokiys

Moderator
Регистрация
01.02.2012
Сообщения
4 771
Благодарностей
1 184
Баллы
113
Any math is possible mate.

Price = 100 Eur
Add = 13%

Final = 100 x 0.13 = 13 Eur = 100 + 13 = 113 Eur

Answer final price with 13% added will be 113 Eur in this case

Cheers
 

VladZen

Administrator
Команда форума
Регистрация
05.11.2014
Сообщения
22 267
Благодарностей
5 853
Баллы
113
Код:
double price= 200;
double percent =13.5;
double total = price+price*percent/100;
return total;
 
  • Спасибо
Реакции: shabbysquire

shabbysquire

Client
Регистрация
25.11.2012
Сообщения
544
Благодарностей
26
Баллы
28
Код:
double price= 200;
double percent =13.5;
double total = price+price*percent/100;
return total;
Thanks man, that works a treat!

Just one more question. Once I've use the c# to calculate the %, how do I add, say, £5 to the sum (which action)? I'm not familiar with maths in ZP! 8-)
 
Последнее редактирование:
  • Спасибо
Реакции: LightWood

VladZen

Administrator
Команда форума
Регистрация
05.11.2014
Сообщения
22 267
Благодарностей
5 853
Баллы
113

shabbysquire

Client
Регистрация
25.11.2012
Сообщения
544
Благодарностей
26
Баллы
28
Sorry, I don't mean to add the currency; just add 5 to the percent total.
 

shabbysquire

Client
Регистрация
25.11.2012
Сообщения
544
Благодарностей
26
Баллы
28
Vlad; that solution that you gave me is causing major bugs in my template. When I delete the c#, everything works as normal.

I'm gonna stick this into bugs section.
 

VladZen

Administrator
Команда форума
Регистрация
05.11.2014
Сообщения
22 267
Благодарностей
5 853
Баллы
113

shabbysquire

Client
Регистрация
25.11.2012
Сообщения
544
Благодарностей
26
Баллы
28
I've added it here.
 

VladZen

Administrator
Команда форума
Регистрация
05.11.2014
Сообщения
22 267
Благодарностей
5 853
Баллы
113
  • Спасибо
Реакции: shabbysquire

shabbysquire

Client
Регистрация
25.11.2012
Сообщения
544
Благодарностей
26
Баллы
28
Many thanks, has done the job!
 

ssXXXss

Client
Регистрация
23.12.2014
Сообщения
7 379
Благодарностей
2 039
Баллы
113
..
C#:
int price = int.Parse(project.Variables["price"].Value);
return price*13.5/100+price;
 
  • Спасибо
Реакции: shabbysquire

shabbysquire

Client
Регистрация
25.11.2012
Сообщения
544
Благодарностей
26
Баллы
28
Ok, just to add additional elements to the above:

Item price = 15.00;
My profit margin = 5.00;

So total of above: 20.00

Then to add in the following:
ebay fees = 10%
Paypal fees = 3.4% + 0.20;
Total =
 

VladZen

Administrator
Команда форума
Регистрация
05.11.2014
Сообщения
22 267
Благодарностей
5 853
Баллы
113
I suppose it should be like this:
Код:
double price= 200;
double percent =13.5;
double total = price+price*percent/100+5; // calculating price+percent+profit margin
double extratotal = total+0.1*total+0.034*total+0.2; // calculating total price+ebay fee+paypal fee
return extratotal;
 
Последнее редактирование:

ssXXXss

Client
Регистрация
23.12.2014
Сообщения
7 379
Благодарностей
2 039
Баллы
113
..
C#:
int price= 200;
double total = price+price*13.5/100+5;
return total+0.1*total+0.034*total+0.2;
 

shabbysquire

Client
Регистрация
25.11.2012
Сообщения
544
Благодарностей
26
Баллы
28
Ok, I messed around with it (I don't know c#!), but I came up with this:

Код:
double price= double.Parse(project.Variables["amazon_price"].Value); //Amazon item price
double profit = 5.0;  // My profit margin
double ebay = 10.00;  // ebay's final  selling fees (%)
double paypal = 3.4+0.20; // Paypal fee of 3.4% and 0.20
double total = price+price*ebay*paypal/100+profit; // calculating price+percent+profit margin
return total;
The amazon product price is: £15.39 with my £5 profit.

Then add ebay fee at 10%, and Paypal fee at: 3.4 + 0.20. The total is supposed to be: £17.63, but my alteration to the code job shows: £18.90.

Can anyone see the mistake in the code?

Btw, I need to keep everything in the above format, as sometimes ebay/paypal fees change (so I can simply change it quickly!)
Thanks.
 

lokiys

Moderator
Регистрация
01.02.2012
Сообщения
4 771
Благодарностей
1 184
Баллы
113
Most probably problem is there double paypal = 3.4+0.20; // Paypal fee of 3.4% and 0.20

As I see there is percents added to cents.
And another thing is you have to know what % counts first, because if you add 10% first and then 3,4% after that or 3,4% first and 10% after that then result will be different also...
 

shabbysquire

Client
Регистрация
25.11.2012
Сообщения
544
Благодарностей
26
Баллы
28
Ok, so you mention possible double paypal, so I've added to ebay as a total of: 13.4:

Код:
double price= double.Parse(project.Variables["amazon_price"].Value); //Amazon item price
double profit = 5.0;  // My profit margin
double fees = 13.4;  // ebay's 10%, and Paypal's 3.4% (the 20p part of Paypal is in total)
double total = price+price*fees/100+profit+0.2; // calculating price+percent+profit margin, and 20p part for the Paypal fee
return total;
But now the calculation is off; supposed to be £17.63, but this displays: £16.98.
 

lokiys

Moderator
Регистрация
01.02.2012
Сообщения
4 771
Благодарностей
1 184
Баллы
113

Кто просматривает тему: (Всего: 1, Пользователи: 0, Гости: 1)