Hello Silvio,
I had a look at the table and understand it like this :
There is a special offering >= 15 Days = 63 Euro and a price for one Day = 7 Euro.
If You rent < 15 Days, the price of 7 Euro each day is used.
If You calculate until 9 Days with 7 Euro a Day, You reach the price of the special offering.
That means :
If somebody stays > 9 Days and < 15 Days, the price will be higher > 63 Euro.
The Day-price after using the special offering 63 Euro = 63 / 15 would be 4,20 Euro up to 30 Days.
To stay 18 Days = 63 + ( 3 * 4,20 ) = 75,60 Euro => Fix-price 15 Days + 3 * Day-price ( 4,20 Euro ).
It is possible, to include this logic in my function.
The calculation :
< 15 Days = 7 Euro * Days
18 Days = 63 Euro + ( 3 * 4,20 Euro ) = 75,60 Euro.
Maybe You can speek to Your customer, if my understanding is correct, using 4,20 Euro a day after 14 days ( 15 ) ?
Days.....Price
--------------
1--------7
..
9--------
6314-------98
-----------------------
15-------
63..
30------
126- Code: Select all Expand view RUN
FUNCTION PRICE_TEST(oWnd)
LOCAL oDlg, oGET
PRIVATE aPRICE[3][3]
aPRICE[1] := { 1, 0, 7 } // 1 day
aPRICE[2] := { 1, 15, 63 } // min 15 Days
aPRICE[3] := { 16, 30, 126 } // min >= 16 Days
nDAYS := 1
DEFINE DIALOG oDlg TITLE "Price Test"
@ 1, 2 GET oGet VAR nDAYS OF oDlg SIZE 30, 15 PICTURE "99"
@ 2, 2 BUTTON "Price-Test" size 50, 25 OF oDlg ;
ACTION ( oGet:Refresh(), ;
nPRICE := GETPRICE3( nDAYS, aPRICE ), ;
MsgAlert( nPrice ) )
ACTIVATE DIALOG oDlg CENTERED
RETURN ( NIL )
// -----------------------
FUNCTION GETPRICE3( nDAYS, aPRICE )
nPRICE := 0
IF nDAYS = 0
MsgAlert( "Day-value missing !","Error" )
RETURN( NIL )
ENDIF
I := 1
FOR I := 1 to nDAYS
// Days < 15 ( max 14 * 7 = 98 Euro )
// ---------------------------------------
IF nDAYS < aPRICE[2][2]
nPRICE := aPRICE[1][3] * nDAYS
ENDIF
// longer >= 15 Days
// --------------------
IF nDAYS >= aPRICE[2][2] .and. nDAYS <= aPRICE[3][2]
// 63 Euro / 15 = 4,20 Euro
// --------------------------------
nPRICE := ( aPRICE[2][3] / aPRICE[2][2] ) * nDAYS
ENDIF
// longer > 30 Days same calculation of 4,20 Euro each day
// ------------------------------------------------------------------
IF nDAYS > aPRICE[3][2]
// 63 Euro / 15 Days = 4,20 Euro
// -----------------------------------
nPRICE := ( aPRICE[2][3] / aPRICE[2][2] ) * nDAYS
ENDIF
NEXT
RETURN ( nPRICE )
Regards
Uwe