![]() |
VOOZH | about |
dotnet add package Pandatech.CommissionCalculator --version 6.0.1
NuGet\Install-Package Pandatech.CommissionCalculator -Version 6.0.1
<PackageReference Include="Pandatech.CommissionCalculator" Version="6.0.1" />
<PackageVersion Include="Pandatech.CommissionCalculator" Version="6.0.1" />Directory.Packages.props
<PackageReference Include="Pandatech.CommissionCalculator" />Project file
paket add Pandatech.CommissionCalculator --version 6.0.1
#r "nuget: Pandatech.CommissionCalculator, 6.0.1"
#:package Pandatech.CommissionCalculator@6.0.1
#addin nuget:?package=Pandatech.CommissionCalculator&version=6.0.1Install as a Cake Addin
#tool nuget:?package=Pandatech.CommissionCalculator&version=6.0.1Install as a Cake Tool
High-performance commission calculation engine for .NET 8+ supporting proportional and absolute commission models with tiered ranges, min/max constraints, and automatic validation.
dotnet add package Pandatech.CommissionCalculator
using CommissionCalculator.DTO;
var rule = new CommissionRule
{
CalculationType = CalculationType.Proportional,
DecimalPlace = 4,
CommissionRangeConfigs = new List<CommissionRangeConfigs>
{
new()
{
RangeStart = 0,
RangeEnd = 500,
Type = CommissionType.FlatRate,
CommissionAmount = 25,
MinCommission = 0,
MaxCommission = 0
},
new()
{
RangeStart = 500,
RangeEnd = 1000,
Type = CommissionType.Percentage,
CommissionAmount = 0.1m,
MinCommission = 70,
MaxCommission = 90
},
new()
{
RangeStart = 1000,
RangeEnd = 10000,
Type = CommissionType.Percentage,
CommissionAmount = 0.2m,
MinCommission = 250,
MaxCommission = 1500
},
new()
{
RangeStart = 10000,
RangeEnd = 0, // 0 = infinity
Type = CommissionType.FlatRate,
CommissionAmount = 2000,
MinCommission = 0,
MaxCommission = 0
}
}
};
Standard (principal-based):
decimal principal = 1000m;
decimal commission = Commission.ComputeCommission(principal, rule);
// Result: 25 (flat) + 70 (min enforced) = 95
Selector-based (different selection and application values):
decimal orderPrice = 2000m; // Amount to calculate commission on
decimal ticketCount = 3m; // Value to select the range
// Select range based on ticketCount, apply commission to orderPrice
decimal commission = Commission.ComputeCommission(orderPrice, ticketCount, rule);
Use case: When the value that determines which range to use (e.g., ticket quantity) differs from the amount you calculate commission on (e.g., order total).
Commission accumulates across tiers as the amount increases:
var proportional = new CommissionRule
{
CalculationType = CalculationType.Proportional,
CommissionRangeConfigs = new List<CommissionRangeConfigs>
{
new() { RangeStart = 0, RangeEnd = 100, Type = CommissionType.Percentage, CommissionAmount = 0.05m },
new() { RangeStart = 100, RangeEnd = 0, Type = CommissionType.Percentage, CommissionAmount = 0.03m }
}
};
// For $200:
// - First $100: $100 * 5% = $5
// - Next $100: $100 * 3% = $3
// Total: $8
Only the matching tier's commission applies:
var absolute = new CommissionRule
{
CalculationType = CalculationType.Absolute,
CommissionRangeConfigs = new List<CommissionRangeConfigs>
{
new() { RangeStart = 0, RangeEnd = 100, Type = CommissionType.FlatRate, CommissionAmount = 10 },
new() { RangeStart = 100, RangeEnd = 0, Type = CommissionType.FlatRate, CommissionAmount = 25 }
}
};
// For $200: $25 (uses second tier only)
| Property | Type | Description |
|---|---|---|
RangeStart |
decimal | Start of range (inclusive) |
RangeEnd |
decimal | End of range (exclusive), 0 = infinity |
Type |
CommissionType | FlatRate or Percentage |
CommissionAmount |
decimal | Commission value (flat amount or percentage like 0.1 for 10%) |
MinCommission |
decimal | Minimum commission for this range |
MaxCommission |
decimal | Maximum commission for this range, 0 = infinity |
CommissionAmount directly (min/max ignored)principal × CommissionAmount, clamped by min/maxFor safety, percentage commissions are limited to ±1000%:
// ✅ Valid: 10% = 0.1
CommissionAmount = 0.1m
// ❌ Invalid: 1500% = 15 (throws exception)
CommissionAmount = 15m
Validation occurs automatically on first use:
decimal commission = Commission.ComputeCommission(1000m, rule);
// Validates rule, caches normalized version, computes result
bool isValid = Commission.ValidateRule(rule);
✅ Required:
MaxCommission ≥ MinCommission (when MaxCommission ≠ 0)❌ Forbidden:
RangeStart and RangeEnd (except single range: both 0)Utility for validating commission period overlaps:
using CommissionCalculator.Helper;
using CommissionCalculator.DTO;
var period1 = new List<DateTimePair>
{
new(new DateTime(2024, 1, 1), new DateTime(2024, 1, 10))
};
var period2 = new List<DateTimePair>
{
new(new DateTime(2024, 1, 5), new DateTime(2024, 1, 15))
};
bool hasOverlap = DateTimeOverlapChecker.HasOverlap(period1, period2);
// Result: true
Performance characteristics:
First calculation: ~50μs (validation + normalization + computation)
Subsequent calculations: ~200ns (cache hit + binary search + math)
Memory: ~1KB per cached rule
var flatRule = new CommissionRule
{
CalculationType = CalculationType.Absolute,
CommissionRangeConfigs = new List<CommissionRangeConfigs>
{
new()
{
RangeStart = 0,
RangeEnd = 0, // Special case: both 0 for single range
Type = CommissionType.FlatRate,
CommissionAmount = 50,
MinCommission = 0,
MaxCommission = 0
}
}
};
// Any amount: $50 commission
var capped = new CommissionRule
{
CalculationType = CalculationType.Proportional,
CommissionRangeConfigs = new List<CommissionRangeConfigs>
{
new()
{
RangeStart = 0,
RangeEnd = 1000,
Type = CommissionType.Percentage,
CommissionAmount = 0.05m,
MinCommission = 10, // At least $10
MaxCommission = 50 // No more than $50 per tier
},
new()
{
RangeStart = 1000,
RangeEnd = 0,
Type = CommissionType.Percentage,
CommissionAmount = 0.02m,
MinCommission = 20,
MaxCommission = 0 // Unlimited on second tier
}
}
};
// Event ticketing: commission based on ticket count, applied to total price
var ticketRule = new CommissionRule
{
CalculationType = CalculationType.Absolute, // Required for selector-based
CommissionRangeConfigs = new List<CommissionRangeConfigs>
{
new() { RangeStart = 0, RangeEnd = 10, Type = CommissionType.Percentage, CommissionAmount = 0.1m },
new() { RangeStart = 10, RangeEnd = 0, Type = CommissionType.Percentage, CommissionAmount = 0.05m }
}
};
decimal orderTotal = 500m;
decimal ticketsSold = 15m;
// Uses second range (15 tickets), applies 5% to $500 order
decimal commission = Commission.ComputeCommission(orderTotal, ticketsSold, ticketRule);
// Result: $25
RangeEnd = 0 or MaxCommission = 0 to represent ∞RangeEnd is exclusive (range is [Start, End))DecimalPlace to control rounding (default: 4)// Higher commission for higher sales
CalculationType = CalculationType.Absolute
Ranges:
$0-$1000: 5%
$1000-$5000: 7%
$5000+: 10%
// Tiered fees that accumulate
CalculationType = CalculationType.Proportional
Ranges:
$0-$10,000: 2.9% + $0.30 min
$10,000+: 1.5%
// Fixed fee per transaction tier
CalculationType = CalculationType.Absolute
Ranges:
$0-$10,000: $9.99
$10,000-$100,000: $19.99
$100,000+: $49.99
MIT
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net8.0 net8.0 is compatible. net8.0-android net8.0-android was computed. net8.0-browser net8.0-browser was computed. net8.0-ios net8.0-ios was computed. net8.0-maccatalyst net8.0-maccatalyst was computed. net8.0-macos net8.0-macos was computed. net8.0-tvos net8.0-tvos was computed. net8.0-windows net8.0-windows was computed. net9.0 net9.0 is compatible. net9.0-android net9.0-android was computed. net9.0-browser net9.0-browser was computed. net9.0-ios net9.0-ios was computed. net9.0-maccatalyst net9.0-maccatalyst was computed. net9.0-macos net9.0-macos was computed. net9.0-tvos net9.0-tvos was computed. net9.0-windows net9.0-windows was computed. net10.0 net10.0 is compatible. net10.0-android net10.0-android was computed. net10.0-browser net10.0-browser was computed. net10.0-ios net10.0-ios was computed. net10.0-maccatalyst net10.0-maccatalyst was computed. net10.0-macos net10.0-macos was computed. net10.0-tvos net10.0-tvos was computed. net10.0-windows net10.0-windows was computed. |
Showing the top 1 NuGet packages that depend on Pandatech.CommissionCalculator:
| Package | Downloads |
|---|---|
|
Pandatech.SharedKernel
Opinionated ASP.NET Core 10 infrastructure kernel: OpenAPI (Swagger + Scalar), Serilog, MediatR, FluentValidation, CORS, SignalR, OpenTelemetry, health checks, maintenance mode, resilience pipelines, and shared utilities. |
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 6.0.1 | 87 | 6/17/2026 |
| 6.0.0 | 225 | 2/28/2026 |
| 5.0.1 | 187 | 1/26/2026 |
| 5.0.0 | 165 | 12/28/2025 |
| 4.1.0 | 353 | 11/13/2025 |
| 4.0.2 | 344 | 11/13/2025 |
| 4.0.1 | 329 | 2/17/2025 |
| 4.0.0 | 250 | 11/21/2024 |
| 3.3.0 | 700 | 3/15/2024 |
| 3.2.1 | 262 | 3/13/2024 |
| 3.2.0 | 287 | 3/13/2024 |
| 3.1.0 | 270 | 3/11/2024 |
| 3.0.0 | 266 | 3/7/2024 |
| 2.1.2 | 278 | 3/5/2024 |
| 2.1.1 | 258 | 3/5/2024 |
| 2.1.0 | 311 | 1/31/2024 |
| 2.0.3 | 245 | 1/30/2024 |
| 2.0.2 | 300 | 1/11/2024 |
| 2.0.1 | 331 | 11/29/2023 |
| 2.0.0 | 257 | 11/29/2023 |
Multi-target net8.0/9.0/10.0, improved documentation, enhanced README with examples