This commit is contained in:
DanB
2015-10-05 08:49:37 +02:00
5 changed files with 53 additions and 27 deletions

View File

@@ -37,6 +37,7 @@ information, please see the [`CONTRIBUTING.md`](CONTRIBUTING.md) file.
| @danbogos | Dan Christian Bogos |
| @eloycoto | Eloy Coto Pereiro |
| @nikbyte | Nick Altmann |
| @kjcsb1 | Cameron Beattie |
<!-- to sign, include a single line above this comment containing the following text:
| @username | First Last |

View File

@@ -6,7 +6,7 @@
drop table if exists cgrates.cdrs_primary;
create table cgrates.cdrs_primary (
id uuid,
cgrid ascii,
cgrid text,
tor text,
accid text,
cdrhost text,
@@ -26,7 +26,7 @@ create table cgrates.cdrs_primary (
disconnect_cause text,
created_at timestamp,
deleted_at timestamp,
PRIMARY KEY (id),
PRIMARY KEY (id, cgrid),
);
--
@@ -36,11 +36,11 @@ create table cgrates.cdrs_primary (
DROP TABLE IF EXISTS cgrates.cdrs_extra;
CREATE TABLE cgrates.cdrs_extra (
id uuid,
cgrid ascii,
cgrid text,
extra_fields text,
created_at timestamp,
deleted_at timestamp,
PRIMARY KEY (id),
PRIMARY KEY (id, cgrid),
);
--
@@ -50,7 +50,7 @@ CREATE TABLE cgrates.cdrs_extra (
DROP TABLE IF EXISTS cgrates.cost_details;
CREATE TABLE cgrates.cost_details (
id uuid,
cgrid ascii,
cgrid text,
runid text,
tor text,
direction text,
@@ -65,7 +65,7 @@ CREATE TABLE cgrates.cost_details (
created_at timestamp,
updated_at timestamp,
deleted_at timestamp,
PRIMARY KEY (id),
PRIMARY KEY (id, cgrid),
);
--
@@ -74,7 +74,7 @@ CREATE TABLE cgrates.cost_details (
DROP TABLE IF EXISTS cgrates.rated_cdrs;
CREATE TABLE cgrates.rated_cdrs (
id uuid,
cgrid ascii,
cgrid text,
runid text,
reqtype text,
direction text,
@@ -94,5 +94,29 @@ CREATE TABLE cgrates.rated_cdrs (
created_at timestamp,
updated_at timestamp,
deleted_at timestamp,
PRIMARY KEY (id),
PRIMARY KEY (id, cgrid),
);
DROP TABLE IF EXISTS cgrates.string_index;
CREATE TABLE cgrates.string_index (
field text,
value text,
id uuid,
PRIMARY KEY((field, value), id)
);
DROP TABLE IF EXISTS cgrates.decimal_index;
CREATE TABLE cgrates.decimal_index (
field text,
value decimal,
id uuid,
PRIMARY KEY((field, value), id)
);
DROP TABLE IF EXISTS cgrates.time_index;
CREATE TABLE cgrates.time_index (
field text,
value timestamp,
id uuid,
PRIMARY KEY((field, value), id)
);

View File

@@ -25,8 +25,8 @@ Index 2 - *RatesTag*
References profile defined in Rates.csv_.
.. _Destinations.csv: csv_tpdestinations.html
.. _Rates.csv: csv_tprates.html
.. _Destinations.csv: csv_tpdestinations.rst
.. _Rates.csv: csv_tprates.rst

View File

@@ -110,6 +110,7 @@ func (ub *Account) debitBalanceAction(a *Action, reset bool) error {
if b.IsExpired() {
continue // just to be safe (cleaned expired balances above)
}
b.account = ub
if b.MatchFilter(a.Balance) {
if reset {
b.SetValue(0)

View File

@@ -312,27 +312,27 @@ func (b *Balance) SetValue(amount float64) {
accountId := ""
allowNegative := ""
disabled := ""
if b.account != nil {
if b.account != nil { // only publish modifications for balances with account set
accountId = b.account.Id
allowNegative = strconv.FormatBool(b.account.AllowNegative)
disabled = strconv.FormatBool(b.account.Disabled)
Publish(CgrEvent{
"EventName": utils.EVT_ACCOUNT_BALANCE_MODIFIED,
"Uuid": b.Uuid,
"Id": b.Id,
"Value": strconv.FormatFloat(b.Value, 'f', -1, 64),
"ExpirationDate": b.ExpirationDate.String(),
"Weight": strconv.FormatFloat(b.Weight, 'f', -1, 64),
"DestinationIds": b.DestinationIds,
"RatingSubject": b.RatingSubject,
"Category": b.Category,
"SharedGroup": b.SharedGroup,
"TimingIDs": b.TimingIDs,
"Account": accountId,
"AccountAllowNegative": allowNegative,
"AccountDisabled": disabled,
})
}
Publish(CgrEvent{
"EventName": utils.EVT_ACCOUNT_BALANCE_MODIFIED,
"Uuid": b.Uuid,
"Id": b.Id,
"Value": strconv.FormatFloat(b.Value, 'f', -1, 64),
"ExpirationDate": b.ExpirationDate.String(),
"Weight": strconv.FormatFloat(b.Weight, 'f', -1, 64),
"DestinationIds": b.DestinationIds,
"RatingSubject": b.RatingSubject,
"Category": b.Category,
"SharedGroup": b.SharedGroup,
"TimingIDs": b.TimingIDs,
"Account": accountId,
"AccountAllowNegative": allowNegative,
"AccountDisabled": disabled,
})
}
func (b *Balance) DebitUnits(cd *CallDescriptor, ub *Account, moneyBalances BalanceChain, count bool, dryRun bool) (cc *CallCost, err error) {