<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://doc-en-mirror.openflyers.com/index.php?action=history&amp;feed=atom&amp;title=Typical-formula</id>
	<title>Typical formula - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://doc-en-mirror.openflyers.com/index.php?action=history&amp;feed=atom&amp;title=Typical-formula"/>
	<link rel="alternate" type="text/html" href="https://doc-en-mirror.openflyers.com/index.php?title=Typical-formula&amp;action=history"/>
	<updated>2026-05-01T16:31:02Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.39.6</generator>
	<entry>
		<id>https://doc-en-mirror.openflyers.com/index.php?title=Typical-formula&amp;diff=250&amp;oldid=prev</id>
		<title>imported&gt;Claratte: /* Flight hours since one year for a flight type */</title>
		<link rel="alternate" type="text/html" href="https://doc-en-mirror.openflyers.com/index.php?title=Typical-formula&amp;diff=250&amp;oldid=prev"/>
		<updated>2015-01-09T09:55:08Z</updated>

		<summary type="html">&lt;p&gt;&lt;span dir=&quot;auto&quot;&gt;&lt;span class=&quot;autocomment&quot;&gt;Flight hours since one year for a flight type&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;__TOC__&lt;br /&gt;
=Presentation=&lt;br /&gt;
This page gathers some examples of formula with theirs explanations.&lt;br /&gt;
&lt;br /&gt;
Allowed Comparison operators are : '''equal''' (=), '''greater than''' (&amp;gt;), '''lesser than''' (&amp;lt;)&lt;br /&gt;
&lt;br /&gt;
=Various formula for several usage=&lt;br /&gt;
&lt;br /&gt;
==Flight hours done in one year for a given flight type==&lt;br /&gt;
In following examples, replace 'flight type' by the flight type id.&lt;br /&gt;
&lt;br /&gt;
If used in flight hours pricing formula or validity formula:&lt;br /&gt;
&amp;lt;pre&amp;gt;sumFlightTime(%PILOT, formatDate('yyyy',%NOW_DATE)-1, formatDate('M',%NOW_DATE), formatDate('d',%NOW_DATE), 0, 0, 0, 'flight type' )&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If used in product sale formula:&lt;br /&gt;
&amp;lt;pre&amp;gt;sumFlightTime(%USER_ID, formatDate('yyyy',%NOW_DATE)-1, formatDate('M',%NOW_DATE), formatDate('d',%NOW_DATE), 0, 0, 0, 'flight type' )&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Test age==&lt;br /&gt;
Test age in flight hours pricing formula:&lt;br /&gt;
&amp;lt;pre&amp;gt;(getYearsFromDiffDate( getBirthdate(%PILOT), formatDate('yyyy-01-01',%NOW_DATE))&amp;gt;25)?1:0&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Test age in product sale formula:&lt;br /&gt;
&amp;lt;pre&amp;gt;(getYearsFromDiffDate( getBirthdate(%USER_ID), formatDate('yyyy-01-01',%NOW_DATE))&amp;gt;25)?1:0&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=Activity sale engine (=flight hours pricing)=&lt;br /&gt;
==Apply another pricing after a period time==&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
The formula will be :&lt;br /&gt;
&amp;lt;pre&amp;gt;( (formatDate('hmm',%START_DATE) &amp;gt; 659) ? $1 : $2 )&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
*[[CommonFormula#.25START_DATE|%START_DATE]] is an internal variable representing the flight start date. The date is in UTC timezone&lt;br /&gt;
*[[CommonFormula#formatDate.28.27pattern.27.2C.25SOME_DATE.29|formatDate]] is an internal function to format a date into another format&lt;br /&gt;
*'''formatDate('hmm',%START_DATE)''' will format the date by using the pattern '''hmm'''&lt;br /&gt;
**It gives '''1511''' for the date '''2011-01-05 15:11:01'''&lt;br /&gt;
**It gives '''700''' for the date '''2011-01-12 07:00:00'''&lt;br /&gt;
*'''(formatDate('hmm',%START_DATE) &amp;gt; 659)''' is the rule condition we want to apply&lt;br /&gt;
**659 represents 6:59 am&lt;br /&gt;
**659 is used instead of 700 because 7:00 am is included.&lt;br /&gt;
**When comparing a time with this pattern 'hmm', the time range is 0 - 2359&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
The formula will be :&lt;br /&gt;
&amp;lt;pre&amp;gt;( (formatDate( 'hmm',convertTimezone(%START_DATE, 'UTC','Europe/Paris') ) &amp;gt; 1100) ? $1 : $2 )&amp;lt;/pre&amp;gt;&lt;br /&gt;
*[[CommonFormula#convertTimezone.28.25SOME_DATE.2C_.25SOME_TZ1.2C_.25SOME_TZ2.29|convertTimezone]] is an internal function to convert a date from a timezone to another timezone&lt;br /&gt;
**since %START_DATE is already in UTC, we let the timezone '''UTC''' as second parameter of the function&lt;br /&gt;
**'''Europe/Paris''' is the timezone used in France&lt;br /&gt;
*Formula is regardless of daylight saving time&lt;br /&gt;
&lt;br /&gt;
==Apply another pricing after some flight hours within the current year==&lt;br /&gt;
*The following digit &amp;quot;4&amp;quot; should be changed by the right flight type id.&lt;br /&gt;
*the following 600 number should be changed by the sexacentimal flight time step.&lt;br /&gt;
&amp;lt;pre&amp;gt;((sumFlightTime(%PILOT, formatDate('yyyy',%START_DATE), 01, 01, 00, 00, 0, 4 ) &amp;gt; 600) ? $tarifInstruction*%DURATION/600 : 0)&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Apply a reduction when some flight hours are lower than a level==&lt;br /&gt;
*The following digit &amp;quot;4&amp;quot; should be changed by the right flight type id.&lt;br /&gt;
*the following 600 number should be changed by the sexacentimal flight time step.&lt;br /&gt;
&amp;lt;pre&amp;gt;(sumFlightTime(%PILOT, formatDate('yyyy',%START_DATE), 01, 01, 00, 00, 0, 4 )&amp;lt;600)?($tarifInstruction*min(%DURATION,600-sumFlightTime(%PILOT, formatDate('yyyy',%START_DATE), 01, 01, 00, 00, 0, 4 ))/600):0&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Apply a reduction when some flight hours are lower than a level on winter months==&lt;br /&gt;
*Total instruction hours during winter period 1&lt;br /&gt;
@totalInstructionHours:&lt;br /&gt;
&amp;lt;pre&amp;gt;(formatDate('MM',%START_DATE)&amp;gt;10)?(sumFlightTime(%PILOT,formatDate('yyyy',%START_DATE),11,01,00,00,0,4)):0&amp;lt;/pre&amp;gt;&lt;br /&gt;
*Total instruction hours during winter period 2&lt;br /&gt;
@totalInstructionHours:&lt;br /&gt;
&amp;lt;pre&amp;gt;(formatDate('MM',%START_DATE)&amp;lt;4)?(sumFlightTime(%PILOT,(formatDate('yyyy',%START_DATE)-1),11,01,00,00,0,4)):0&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;((@flightMonth&amp;gt;10) OR (@flightMonth&amp;lt;4))?((((@totalInstructionHours+%DURATION)/600)&amp;lt;5)?($tarifInstruction*%DURATION/600):($tarifInstruction*(5-(%DURATION/600)))):0&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Quarter per hour billing with one hour minimum==&lt;br /&gt;
The following formula bills a minimum of one hour then by size of quarter of hour.&lt;br /&gt;
&amp;lt;pre&amp;gt;max(4, roundCeil(%DURATION/150,1))*$price&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=Product sale engine=&lt;br /&gt;
==Apply a reduction according the bill date in the year==&lt;br /&gt;
Example: apply 50% cut off if the bill date is the First of July or later in the year.&lt;br /&gt;
&amp;lt;pre&amp;gt;(formatDate('MM',%NOW_DATE)&amp;gt;6)?($summerRate/100*(@standardPrice)):0&amp;lt;/pre&amp;gt;&lt;/div&gt;</summary>
		<author><name>imported&gt;Claratte</name></author>
	</entry>
</feed>