# Rounding

## Responsibility

This part of CalculationEngine is responsible for rounding final service's price according to specified rules.

## Input

- Total sales price

## Process

- If all 3 magic number settings are defined (not null) magic number will be used for rounding calculations. This is basically math rounding to tens, hundreds and so on depending on the suffix.
RoundPerType recognized, null defaults to RoundPerType.Booking.

RoundYield_ID ignored, difference stored in MagicNumberFee.

In case the magic number settings are not supplied and RoundType is defined calculations will be rounded according to it's setting.

RoundPerType recognized, null defaults to RoundPerType.Pax or RoundPerType.PaxAndDay for ServiceType.Hotel && RoundType.Ceiling.

RoundYield_ID recognized, if null difference stored in RoundingFee.

Finally, if RoundType is defined cancellations will be rounded accordingly.

RoundPerType ignored, defaults to RoundPerType.Booking.

RoundYield_ID ignored, difference dropped.

## Output

- Rounded total price if rounding was applied, original price otherwise.

## Config

- Codes used in database
- BAS - Base, ADO - Add On
- BPR - Base Price, CPR - Calculated Price
- BOOK - Per Booking (in case of hotels per rate which is a price for room and meal), PAX - Per Passenger,
- Rounding
- Type: H - Hotel, P - Package, C - Car, A - Air
RoundType: FLOOR, MATH, CEILING

RoundPerType: BOOK, BOOK_DAY, PAX, PAX_DAY

## Examples

- Example data
- 4 TW rooms priced at 49,00 EUR each, 8 passengers.
- Base price per rate: 49,00 EUR
- Base price per booking: 196,00 EUR

**Hotel per booking** Calculate yield1 (6%) on base price per booking, add yield2 (12%) to the result and round the calculated price (booking) down to the nearest integer number. **CURRENTLY NOT SUPPORTED, BOOK is treated as sum of all RATES (rooms).**

Yield Calculation Name Type SubType IncludeIn CalculateOn CalculateType Fee1Amount bFee1Percent ===================================================================== ========================== Yield1 BAS NULL BPR BPR BOOK 6,00 1 Yield2 BAS NULL BPR CPR BOOK 12,00 1 Rounding Type MagicNumberSuffix MagicNumberLower MagicNumberUpper RoundType RoundPerType RoundYield_ID =================================================================================================== H NULL NULL NULL FLOOR BOOK Yield1 ID Example =FLOOR(196,00 * 1,06 * 1,12; 1) Result: 232,00 EUR

**Hotel per rate** Calculate yield1 (6%) on base price per **rate**, add yield2 (12%) the result per **rate** and round the calculated price per **rate** down to the nearest integer number.

Yield Calculation Name Type SubType IncludeIn CalculateOn CalculateType Fee1Amount bFee1Percent ===================================================================== ========================== Yield1 BAS NULL BPR BPR BOOK 6,00 1 Yield2 BAS NULL BPR CPR BOOK 12,00 1 Rounding Type MagicNumberSuffix MagicNumberLower MagicNumberUpper RoundType RoundPerType RoundYield_ID =================================================================================================== H NULL NULL NULL FLOOR BOOK Yield1 ID Example =FLOOR(49,00 * 1,06 * 1,12; 1) Final result (per booking): 58,00 * 4 = 232,00 EUR

**Dynamic Packaging per passenger** Calculate yield1 (6%) on base price per passenger, add yield2 (12%) to the result per passenger and round the calculated price per passenger down to the nearest integer number.

Yield Calculation Name Type SubType IncludeIn CalculateOn CalculateType Fee1Amount bFee1Percent ===================================================================== ========================== Yield1 BAS NULL BPR BPR PAX 6,00 1 Yield2 BAS NULL BPR CPR PAX 12,00 1 Rounding Type MagicNumberSuffix MagicNumberLower MagicNumberUpper RoundType RoundPerType RoundYield_ID =================================================================================================== P NULL NULL NULL FLOOR PAX Yield1 ID Example =FLOOR(196,00 * 1,06 * 1,12; 8) Result: 232,00 EUR