f0f1f2.studio Template reference
English
Open application
Method

GetVatSum

Definition

Namespace
Resto.Front.PrintTemplates.Cheques.Razor

Extracts VAT already included in a gross amount.

decimal TemplateBase<T>.GetVatSum(decimal fullSum, decimal vatPercent)
Returns
decimal
Nullability
Not null
Declared in
Resto.Front.PrintTemplates.Cheques.Razor.TemplateBase<T>
Model purpose
Base class for Legacy Razor print templates. Model contains the document data of type T. Provides formatting and markup output methods.

Parameters

decimal fullSum
Gross amount including VAT.
decimal vatPercent
VAT percentage points, for example 20 for 20%.

Return value

fullSum minus the net amount rounded to the current currency fractional precision; zero when either argument is zero.

Remarks

The net amount is fullSum / (1 + vatPercent / 100). Net rounding is away from zero at midpoints and ignores minimum denomination. The VAT result is not rounded again. Rates are not validated as legal tax rates; this method performs arithmetic only.

Exceptions

System.InvalidOperationException
The engine currency provider has not been initialized.
System.Collections.Generic.KeyNotFoundException
The current currency ISO code is absent from the engine currency catalog.
System.DivideByZeroException
vatPercent is -100 and fullSum is nonzero.
System.OverflowException
An intermediate calculation exceeds the Decimal range.

Example

// Current currency precision: 2
GetVatSum(120m, 20m); // 20m