IPFLang Reference
A Domain-Specific Language for Modern IP Fees Calculation
Overview
Inputs and Fees
The process of describing IP fees in IPFLang consists of determining what the inputs are and how the fee is composed off small amounts that accrue based on rules.
There are five types of inputs available:
- String list with individual choices
- String list with multiple choices
- Number (floating point), with lower and upper bounds as well as a default value
- Boolean (for yes/no types of responses)
- Date (for selecting the number of yers/months/days to a specific date)
Inputs are presented as HTML controls that the user fill in and upon form submission, the values are used to compute the fee. The system displays the full list of steps taken to reach the result, to aid debugging.
Single-Selection Input
Single-selection input displays a list of string choices and allows the user to select one of those. A default choice must be specified. The group to which the input belongs can be specified (optional).
DEFINE LIST EntityType AS 'Select the desired entity type'
GROUP G1 (optional)
CHOICE NormalEntity AS 'Normal'
CHOICE SmallEntity AS 'Small'
CHOICE MicroEntity AS 'Micro'
DEFAULT NormalEntity
ENDDEFINE
Multiple-Selection Input
Multiple-selection input displays a list of string choices and allows the user to select one or more of those. One or more default choices must be specified (separated by comma). The group to which the input belongs can be specified (optional).
DEFINE MULTILIST EntityType AS 'Select the desired entity type'
GROUP G2 (optional)
CHOICE NormalEntity AS 'Normal'
CHOICE SmallEntity AS 'Small'
CHOICE MicroEntity AS 'Micro'
DEFAULT SmallEntity,NormalEntity
ENDDEFINE
To get the number of selected choices, use the !COUNT property, e.g. EntityType!COUNT.
To test user selection, use the IN (regular inclusion test) and NIN (not-in) operators, e.g. YIELD 100 IF MicroEntity IN EntityType or YEILD 200 IF SmallEntity NIN EntityType.
Number Input
Number inputs allow entering a numeric value (floating point), bounded by lower and upper limits. A default value must be specified. The group to which the input belongs can be specified (optional).
DEFINE NUMBER SheetCount AS 'Enter the number of sheets'
GROUP G3 (optional)
BETWEEN 10 AND 1000
DEFAULT 15
ENDDEFINE
Boolean Input
Boolean inputs allow selecting a condition. The default selection can be specified. The group to which the input belongs can be specified (optional).
DEFINE BOOLEAN ContainsDependentClaims AS 'Does this contain dependent claims?'
GROUP G4 (optional)
DEFAULT TRUE
ENDDEFINE
Date Input
Date inputs allow entering a date bounded by lower and upper limits. A default date must be specified. The group to which the input belongs can be specified (optional).
The special value TODAY is replaced at runtime with the actual value. The date format is DD.MM.YYYY.
DEFINE DATE ApplicationDate AS 'Application date'
GROUP G5 (optional)
BETWEEN 01.01.2023 AND TODAY
DEFAULT 01.03.2023
ENDDEFINE
The date type cannot currently be used as such, but it employs several properties, as follows:
- !YEARSTONOW - gets the number of years from a specific date in the past until now (a floating-point number).
- !MONTHSTONOW - gets the number of months from a specific date in the past until now (a floating-point number).
- !MONTHSTONOW_FROMLASTDAY - gets the number of months from the last day of the month of a specific date in the past until now (a floating-point number). For instance, if the supplied date is 01.01.2023, the last day of the month is 31.01.2023 and that will be used to compute the number of months until now.
- !DAYSTONOW - gets the number of days from a specific date in the past until now (a floating-point number).
Input Grouping
Groups assigned to inputs can be assigned individual texts and weights. Upon display on the user interface, all inputs will be grouped by their group and ordered by weight (the heavier an input is, the lower it appears in the list).
Grouping definition is usually declared in an autorun module which gets executed automatically, even if it is not referenced by a fee definition.
DEFINE GROUP G1 AS 'Application date inputs' WITH WEIGHT 100
DEFINE GROUP G2 AS 'Translation related inputs' WITH WEIGHT 150
DEFINE GROUP G3 AS 'Claim related inputs' WITH WEIGHT 200
Fee Definition
Any number of fees can be created and they all account towards the grand total. In it's simplest form, a fee yields a singe value with no condition.
COMPUTE FEE SimplestFee
YIELD 150
ENDCOMPUTE
Optional Fees
Fees can be declared as optional. Option fees still account towards the grand total, but they are marked as such in the final result.
COMPUTE FEE SimplestOptionalFee OPTIONAL
YIELD 150
ENDCOMPUTE
Conditional Fees
Conditions can be added to each YIELD branch. In this case, BasicNationalFee gets calculated according to the user selection in the EntityType input.
The following operators are currently supported: EQ, NEQ, LT, LTE, GT, GTE.
COMPUTE FEE BasicNationalFee
YIELD 320 IF EntityType EQ NormalEntity
YIELD 128 IF EntityType EQ SmallEntity
YIELD 64 IF EntityType EQ MicroEntity
ENDCOMPUTE
Conditional Fees (More Complex)
For more complex scenarios, the CASE clause can be used. In this particular care, certain amounts are added function of the SituationType input. YIELD statements outside the CASE are evaluated normally.
COMPUTE FEE ExaminationFee
CASE SituationType EQ PreparedIPEA AS
YIELD 20 IF EntityType EQ NormalEntity
YIELD 40 IF EntityType EQ SmallEntity
YIELD 60 IF EntityType EQ MicroEntity
ENDCASE
YIELD 800 IF EntityType EQ NormalEntity
YIELD 360 IF EntityType EQ SmallEntity
YIELD 160 IF EntityType EQ MicroEntity
ENDCOMPUTE
Complex Amounts
The YIELDed amount can be computed using a complex formula. If rounding is needed, one of the usual rounding functions can be used (see below).
COMPUTE FEE SheetFee
YIELD 420*((SheetCount-100)/50) IF SheetCount GT 100 AND EntityType EQ NormalEntity
YIELD 168*((SheetCount-100)/50) IF SheetCount GT 100 AND EntityType EQ SmallEntity
YIELD 84*((SheetCount-100)/50) IF SheetCount GT 100 AND EntityType EQ MicroEntity
ENDCOMPUTE
Number Rounding Functions
Rounding is accomplished using FLOOR, ROUND, CEIL functions.
- FLOOR - strips off the decimal part, e.g. 4.7 -> 4
- ROUND - rounds to the nearest integer, e.g. 4.7 -> 5 and 4.3 -> 4
- CEIL - rounds to the largest integer, e.g. 4.3 -> 5
YIELD ROUND(420*((SheetCount-100)/50)) IF SheetCount GT 100 AND EntityType EQ NormalEntity
YIELD FLOOR(168*((SheetCount-100)/50)) IF SheetCount GT 100 AND EntityType EQ SmallEntity
YIELD CEIL(84*((SheetCount-100)/50)) IF SheetCount GT 100 AND EntityType EQ MicroEntity
ENDCOMPUTE
Choice Selection Test
To test for user selection, use the IN and NIN operators.
COMPUTE FEE SheetFee
YIELD 100 IF Country1 IN Countries
YIELD 200 IF Country2 IN Countries
YIELD 25 IF Country1 NIN Countries AND Country2 NIN Countries
ENDCOMPUTE
Date Selection Test
Dates cannot currently be used as such, but rather via properties that compute the number of years/months/days to the current date. The properties are !YEARSTONOW, !MONTHSTONOW, and !DAYSTONOW.
DEFINE DATE D1 AS 'My birthday'
BETWEEN 01.01.1975 AND 31.12.1990
DEFAULT 31.10.1975
ENDDEFINE
COMPUTE FEE Fee1
YIELD 10 * ROUND(D1!YEARSTONOW) IF D1!YEARSTONOW GT 40
ENDCOMPUTE
Fee Local Variables
Local variables can be defined inside the scope of a fee. This is to enhance readability and simplify fee computation.
COMPUTE FEE SheetFee
LET A AS 20
LET B AS 40
YIELD A*200+B
ENDCOMPUTE
Returns
The fee computation engine conveys information back to the caller using the RETURN statements.
RETURN ClaimLimits AS '10 claims included; additional fee as of 11'
RETURN ExReqDate AS 'Examination request due within 7 years after filing'
Example
Use this as a starting point to your own fee computation.
DEFINE LIST EntityType AS 'Select the desired entity type'
CHOICE NormalEntity AS 'Normal'
CHOICE SmallEntity AS 'Small'
CHOICE MicroEntity AS 'Micro'
DEFAULT NormalEntity
ENDDEFINE
DEFINE LIST SituationType AS 'Situation type'
CHOICE PreparedIPEA AS 'IRRP (Chapter II) prepared by the IPEA/US'
CHOICE PaidAsISA AS 'International search fee paid as ISA'
CHOICE PreparedISA AS 'Search report prepared by an ISA other than the US'
CHOICE AllOtherSituations AS 'All other situations'
DEFAULT PreparedIPEA
ENDDEFINE
DEFINE NUMBER SheetCount AS 'Enter the number of sheets'
BETWEEN 10 AND 1000
DEFAULT 15
ENDDEFINE
DEFINE NUMBER ClaimCount AS 'Number of claims'
BETWEEN 0 AND 1000
DEFAULT 0
ENDDEFINE
DEFINE BOOLEAN ContainsDependentClaims AS 'Does this contain dependent claims?'
DEFAULT TRUE
ENDDEFINE
COMPUTE FEE BasicNationalFee
YIELD 320 IF EntityType EQ NormalEntity
YIELD 128 IF EntityType EQ SmallEntity
YIELD 64 IF EntityType EQ MicroEntity
ENDCOMPUTE
COMPUTE FEE SearchFee
CASE SituationType EQ PreparedIPEA AS
YIELD 0 IF EntityType EQ NormalEntity
YIELD 0 IF EntityType EQ SmallEntity
YIELD 0 IF EntityType EQ MicroEntity
ENDCASE
CASE SituationType EQ PaidAsISA AS
YIELD 140 IF EntityType EQ NormalEntity
YIELD 56 IF EntityType EQ SmallEntity
YIELD 28 IF EntityType EQ MicroEntity
ENDCASE
CASE SituationType EQ PreparedISA AS
YIELD 540 IF EntityType EQ NormalEntity
YIELD 216 IF EntityType EQ SmallEntity
YIELD 108 IF EntityType EQ MicroEntity
ENDCASE
YIELD 700 IF EntityType EQ NormalEntity
YIELD 280 IF EntityType EQ SmallEntity
YIELD 140 IF EntityType EQ MicroEntity
ENDCOMPUTE
COMPUTE FEE ExaminationFee
CASE SituationType EQ PreparedIPEA AS
YIELD 0 IF EntityType EQ NormalEntity
YIELD 0 IF EntityType EQ SmallEntity
YIELD 0 IF EntityType EQ MicroEntity
ENDCASE
YIELD 800 IF EntityType EQ NormalEntity
YIELD 360 IF EntityType EQ SmallEntity
YIELD 160 IF EntityType EQ MicroEntity
ENDCOMPUTE
COMPUTE FEE SheetFee
LET A AS 420
LET B AS 420
LET C AS 420
YIELD ROUND(A*((SheetCount-100)/50)) IF SheetCount GT 100 AND EntityType EQ NormalEntity
YIELD ROUND(B*((SheetCount-100)/50)) IF SheetCount GT 100 AND EntityType EQ SmallEntity
YIELD ROUND(C*((SheetCount-100)/50)) IF SheetCount GT 100 AND EntityType EQ MicroEntity
ENDCOMPUTE
COMPUTE FEE ClaimFee
YIELD (480*ClaimCount) IF ClaimCount GT 3 AND EntityType EQ NormalEntity
YIELD (192*ClaimCount) IF ClaimCount GT 3 AND EntityType EQ SmallEntity
YIELD (96*ClaimCount) IF ClaimCount GT 3 AND EntityType EQ MicroEntity
ENDCOMPUTE