mirror of
https://github.com/QuantumNous/new-api.git
synced 2026-09-03 13:01:00 +00:00
- Added support for tiered billing expressions in the billing system. - Introduced new types and functions for handling billing expressions, including caching and execution. - Updated existing billing logic to accommodate tiered billing scenarios. - Enhanced request handling to support incoming billing expression requests. - Added tests for tiered billing functionality to ensure correctness.
11 lines
329 B
Go
11 lines
329 B
Go
package billingexpr
|
|
|
|
import "math"
|
|
|
|
// QuotaRound converts a float64 quota value to int using half-away-from-zero
|
|
// rounding. Every tiered billing path (pre-consume, settlement, breakdown
|
|
// validation, log fields) MUST use this function to avoid +-1 discrepancies.
|
|
func QuotaRound(f float64) int {
|
|
return int(math.Round(f))
|
|
}
|