CalculatePercent
Definition
- Namespace
- Resto.Front.PrintTemplates.Cheques.Razor
Calculates the percentage represented by a part of a total.
decimal TemplateBaseCore<T>.CalculatePercent(decimal fullValue, decimal partValue)
- Returns
decimal- Nullability
- Not null
- Declared in
- Resto.Front.PrintTemplates.Cheques.Razor.TemplateBaseCore<T>
- Model purpose
- Base class for RazorEngineCore print templates. Model contains the document data of type T. Provides formatting and markup output methods.
Parameters
decimal fullValue- Total used as the denominator; zero produces a zero result.
decimal partValue- Part of the total; negative values and values exceeding the total are accepted.
Return value
Zero when fullValue is zero; otherwise partValue / fullValue * 100 rounded to two decimal places away from zero at midpoints.
Remarks
No currency rounding or 0–100 clamping is applied. A negative denominator changes the sign of the result.
Exceptions
System.OverflowException- Division or multiplication by 100 exceeds the Decimal range.
Example
CalculatePercent(200m, 25m); // 12.50m CalculatePercent(0m, 25m); // 0m