# How to setup a unit price based on a C# formula

Unit price C# formulas allow for complex conditions for unit pricing.

**Unit price C# formulas are added by the FBO One support team only. Contact ****support@fboone.com**** for guidance.**

**Contents:**

- 1 Information
- 2 Formula specifications
- 2.1 Syntax

- 3 How to set up a product with special unit price calculation formula
- 3.1 1. In Administration, create a custom property 'A/c foot print' and add a few values. Make this custom property available for Aircraft registrations.
- 3.2 2. Create a new product
- 3.3 3. Set up the calculator and formula in the Special price calculation section and then save the settings
- 3.4 4. Create a price agreement. On the details page of the new product, switch to the Price agreement tab and add a new price agreement.
- 3.5 5. Navigate to an aircraft registration page and assign an a/c footprint custom value.
- 3.6 6. Create a new handling order for CSDFD registration
- 3.7 7. Add the Parking fee service created before, and check the calculated price.

- 4 Unit price formula examples
- 4.1 Route Air Navigation Charge
- 4.2 Parking per 24H with MTOW band different unit prices
- 4.3 Parking 24H first 6 tons
- 4.4 Parking 24H > 6 tons
- 4.5 Calculate a fee (for example Parking) based on Aircraft footprint.
- 4.6 Multiply the unit price by the MTOW in tons (rounded up) e.g 22,001Kg = 23 Tons
- 4.7 Multiply the unit price by the aircraft footprint (m2) whereby the length and wingspan are rounded to the nearest meter prior to being multiplied e.g 16.2m = 16m and 16.55m=17m
- 4.8 Replicate TNC charges e.g. unit rate * (MTOWTons/50)^0.7
- 4.9 Calculate landing fees based on the unit price, multiplied by emission values and the MTOW in tonnes
- 4.10 Charge per Tonne, subtracting 3-Tonnes from the MTOW
- 4.11 Multiply the unit price by the MTOW in tons (rounded to the nearest) and then subtract 1 ton e.g. 22,001Kg = 22 Tons

## Information

FBO One typically defines unit price by price agreements for a product, applying a single price agreement to set the unit price of a service on the order. There may be scenarios where additional calculations are required; Price calculators may be used in these instances.

Alternatively, defining custom calculation formulas to calculate the unit price for a product can be used. This article describes how to set up such formulas.

Unit price formulas for unit price calculation receive a number of input arguments. These inputs are:

Value of a

**custom property**that you can choose**Unit price**as based on the price agreements for the product**Maximum takeoff weight of the aircraft****Aircraft footprint**

For example, a service like parking fees may need a unit price that is calculated as

```
1
```

`unit price = (the aircraft square meters) X (a price per square meter)`

The parking fee will then be charged to customers as

```
1
```

`charged amount = no_of_days_of_parking X unit_price`

The quantity (number of days) can be determined using the parking per 24 hours calculator

The unit price can be calculated by using a custom formula. The formula can use the following inputs.

The

**unit price from a****price agreement**indicating the 'price per square meter'A

**custom value assigned to each aircraft type**named 'aircraft square meters'

## Formula specifications

The system is able to process a formula containing the following optional input values and any number value.

**input.CustomValue**: a custom value number assigned to any of the following: order, a/c registration, a/c type, debtor, form of payment.**input.UnitPrice**: a unit price specified in price agreements or a manually entered unit price**input.MtowInKg**(input.MtowInPounds): when available, the maximum take-off weight of the aircraft is expressed in kilograms or pounds,**input.FootprintInM2**(input.FootprintInSqFt): when available, the aircraft footprint in meter square or square feet

A basic formula example adding the unit price, custom value, and MTOW in kg would be:

```
1
```

`input.CustomValue + input.UnitPrice + input.MtowInKg; // the result is the sum of the 3 input values.`

The formula can also be only a number. In this case, the unit price that FBO One will return will be 10:

```
1
```

`10`

Input parameters are optional so the formula can work with fixed numbers

```
1
```

`10+10`

### Syntax

Formulas can only be written with the C# programming language syntax. The mathematical function that can be used is listed here.

Whenever the syntax is not correct, the system will show an error and the formula needs to be fixed.

Errors may show when one of the input parameters is used in the formula but does not have a value. For example, It can be that a price agreement unit price is not available so when used in a calculation, the system shows an error.

To prevent this, you need to write a more complex formula syntax:

```
1
2
3
4
5
6
7
8
```

```
((Func<decimal?>)(() => { // always use this type of declaration
decimal? result = null; // always set a default return value
if (input.CustomValue.HasValue && input.UnitPrice.HasValue) // the formula is applied only when both input parameters have a value
{
result = (input.CustomValue.Value * input.UnitPrice.Value); // the actual formula where the return value is set
}
return (decimal?)result; // return of the value: this will show the result of the calculation or a '?' in the order screen, indicating that something is missing (price agreement unit price or the custom value)
}))(); // always end the formula like this
```

## How to set up a product with special unit price calculation formula

Navigate to the Edit Product page and scroll down to the '

**Special price calculation**' section.(

**Optional**) Select a custom property name to be used in the calculation. One custom value of this custom property should be linked to one of the following tables: order, aircraft registration, aircraft type, form of payment, debtor.**Define the formula**which will calculate the unit price.

In this example, we will:

**Create a custom property**and values 'A/c footprint' to be used by the calculator and assigned to registrations.**Create a product**named Parking Fee**Set-up the formula****Create a price agreement**for the Parking Fee product**Assign the custom property**to an a/c registration**Create one order**with this a/c registration**Check the calculated Parking Fee service**

#### 1. In Administration, create a custom property 'A/c foot print' and add a few values. Make this custom property available for Aircraft registrations.

#### 2. Create a new product

#### 3. Set up the calculator and formula in the Special price calculation section and then save the settings

```
1
```

`input.UnitPrice * input.CustomValue; `

#### 4. Create a price agreement. On the details page of the new product, switch to the Price agreement tab and add a new price agreement.

#### 5. Navigate to an aircraft registration page and assign an a/c footprint custom value.

In this example, we searched for CSDFD registration using the top right search box and clicked on ‘**Edit registration**’ to assign the custom value

#### 6. Create a new handling order for CSDFD registration

#### 7. Add the Parking fee service created before, and check the calculated price.

**Expected amount: 0.36*10*1 day of parking= 3.6**