Hi Silvio,
There are several problems with your question
1 the relation between prices don't match as pointed by Antonio
2 It makes absolutely no sense to have an array of prices, if every single component of the array is the same, just multiplied by the price of a single day.
3 For what i see, from the relation between 1 day and 1 week, It looks like the intention was to provide a discount when the costumer occupies the beach chalet for a specific amount of time. If that is the situation, the 2 easier ways to approach it are:
3.1 Create the array, that it should be created from a table configurable by user, not hard coded... (You may have to use this one, since there is no relationship on prices, from the picture you posted)
- Code: Select all Expand view
prz [1]:= 6 //1 day
prz [2]:= 40 //1 week
prz [3]:= 65 // 2 weeks
prz [4]:= 100 // 4 weeks
Then obtain the number of days more than for example 1 week, multiply by single day charge, then add both ammounts....
- Code: Select all Expand view
days = 9
extra_days = days - 7
nPrice := prz[2] + (extra_days * prz[1])
3.2 Create the array, that it should be created from a table configurable by user, not hard coded with porcentages according to ammount of time (Recommended)
- Code: Select all Expand view
prz [1]:= 6 //1 day Euros
prz [2]:= 0.5 //1 week %
prz [3]:= 0.10 // 2 weeks %
prz [4]:= 0.20 // 4 weeks %
Then modify your logic to something like:
- Code: Select all Expand view
do case
case days >0 and days <2
nPrice: = ngg * prz [1]
case days >1 and days <10 //from more than 1 day, and a little over a week, but less less than 50% of the following week,
nPrice: = (ngg * prz[1]) * (100 - prz [2])
case days >10 and days <21
nPrice: = (ngg * prz[1]) * (100 - prz [3])
case days >21
nPrice: = (ngg * prz[1]) * (100 - prz [4])
endcase
=====>
Bayron Landaverry
(215)2226600 Philadelphia,PA, USA
+(502)46727275 Guatemala
MayaBuilders@gMail.comFWH12.04||Harbour 3.2.0 (18754)||BCC6.5||UEstudio 10.10||
Windows 7 Ultimate
FiveWin, One line of code and it's done...