Difference between revisions of "Typical formula"

Jump to: navigation, search
(Apply another pricing after some flight hours within the current year)
Line 5: Line 5:
 
Allowed Comparison operators are : '''equal''' (=), '''greater than''' (>), '''lesser than''' (<)
 
Allowed Comparison operators are : '''equal''' (=), '''greater than''' (>), '''lesser than''' (<)
  
 +
=Various formula for several usage=
 +
==Test age==
 +
<pre>(getYearsFromDiffDate( getBirthdate(%PILOT), formatDate('yyyy-01-01',%NOW_DATE))>25)?1:0</pre>
 +
 +
=Flight hours pricing=
 
==Apply another pricing after a period time==
 
==Apply another pricing after a period time==
  

Revision as of 13:38, 17 January 2013

Presentation

This page gathers some examples of formula with theirs explanations.

Allowed Comparison operators are : equal (=), greater than (>), lesser than (<)

Various formula for several usage

Test age

(getYearsFromDiffDate( getBirthdate(%PILOT), formatDate('yyyy-01-01',%NOW_DATE))>25)?1:0

Flight hours pricing

Apply another pricing after a period time

The pricing rule is as followed : If a flight starts after 7:00 am UTC (7:00 am included), we apply a pricing of $1. Otherwise, we apply a pricing of $2.

The formula will be :

( (formatDate('hmm',%START_DATE) > 659) ? $1 : $2 )
  • %START_DATE is an internal variable representing the flight start date. The date is in UTC timezone
  • formatDate is an internal function to format a date into another format
  • formatDate('hmm',%START_DATE) will format the date by using the pattern hmm
    • It gives 1511 for the date 2011-01-05 15:11:01
    • It gives 700 for the date 2011-01-12 07:00:00
  • (formatDate('hmm',%START_DATE) > 659) is the rule condition we want to apply
    • 659 represents 6:59 am
    • 659 is used instead of 700 because 7:00 am is included.
    • When comparing a time with this pattern 'hmm', the time range is 0 - 2359


The pricing rule is as followed : All flights are always done into France. If a flight starts after 11:00 am (11:00 am included), we apply a pricing of $1. Otherwise, we apply a pricing of $2. The formula will be :

( (formatDate( 'hmm',convertTimezone(%START_DATE, 'UTC','Europe/Paris') ) > 1100) ? $1 : $2 )
  • convertTimezone is an internal function to convert a date from a timezone to another timezone
    • since %START_DATE is already in UTC, we let the timezone UTC as second parameter of the function
    • Europe/Paris is the timezone used in France
  • Formula is regardless of daylight saving time

Apply another pricing after some flight hours within the current year

  • The following digit "4" should be changed by the right flight type id.
  • the following 600 number should be changed by the sexacentimal flight time step.
((sumFlightTime(%PILOT, formatDate('yyyy',%START_DATE), 01, 01, 00, 00, 0, 4 ) > 600) ? $tarifInstruction*%DURATION/600 : 0)

Apply a reduction when some flight hours are lower than a level

  • The following digit "4" should be changed by the right flight type id.
  • the following 600 number should be changed by the sexacentimal flight time step.
(sumFlightTime(%PILOT, formatDate('yyyy',%START_DATE), 01, 01, 00, 00, 0, 4 )<600)?($tarifInstruction*min(%DURATION,600-sumFlightTime(%PILOT, formatDate('yyyy',%START_DATE), 01, 01, 00, 00, 0, 4 ))/600):0