From 9fd6866073d9edfcf98214736db136700baf79a2 Mon Sep 17 00:00:00 2001 From: DanB Date: Sun, 14 May 2017 19:04:25 +0200 Subject: [PATCH] Adding EventCost to engine --- engine/eventcost.go | 86 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 86 insertions(+) create mode 100644 engine/eventcost.go diff --git a/engine/eventcost.go b/engine/eventcost.go new file mode 100644 index 000000000..994699259 --- /dev/null +++ b/engine/eventcost.go @@ -0,0 +1,86 @@ +/* +Real-time Online/Offline Charging System (OCS) for Telecom & ISP environments +Copyright (C) ITsysCOM GmbH + +This program is free software: you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation, either version 3 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program. If not, see +*/ +package engine + +import ( + "time" + + "github.com/cgrates/cgrates/utils" +) + +// ChargedTiming represents one timing attached to a charge +type ChargedTiming struct { + Years *utils.Years + Months *utils.Months + MonthDays *utils.MonthDays + WeekDays *utils.WeekDays + StartTime string +} + +// RatingUnit represents one unit out of RatingPlan bounded to event +type RatingUnit struct { + ConnectFee float64 + RoudingMethod string + RoundingDecimals int + MaxCost float64 + MaxCostStrategy string + Timing *ChargedTiming // This RatingUnit is bounded to specific timing profile + Rates []*Rate +} + +// BalanceCharge represents one unit charged to a balance +type BalanceCharge struct { + UUID string // balance charged + AccountID string + Rating *RatingUnit // special price applied on this balance + Units float64 // number of units charged + ExtraCharge *BalanceCharge // used in cases when paying *voice with *monetary +} + +// ChargingIncrement represents one unit charged inside an interval +type ChargingIncrement struct { + Usage time.Duration + Cost float64 + Rating *RatingUnit + Balance *BalanceCharge +} + +// ChargingInterval represents one interval out of Usage providing charging info +// eg: PEAK vs OFFPEAK +type ChargingInterval struct { + StartTime *time.Time + Increments []*ChargingIncrement +} + +// EventCost holds cost for an event +type EventCost struct { + CGRID string + RunID string + Cost float64 + Usage time.Duration + Charges []*ChargingInterval +} + +// EventCostDigest is an optimized EventCost with smaller footprint to be sent over network or stored +// not that human friendly as EventCost +type EventCostDigest struct { + CGRID string + RunID string + Cost float64 + Usage time.Duration +}