Best approach for shared monetary balance between accounts/group balance

121 views
Skip to first unread message

Marcin Kowalczyk

unread,
May 23, 2019, 5:28:28 PM5/23/19
to CGRateS
Hi,

 I would like to setup CGRateS for following scenario:
0. let's asume that  "tenant" (not sure if tenant usage would be best here) has multiple accounts.
1. accounts within tenant has own minute balance
2. when particular account minute balance goes to 0 we would like to use shared monetary balance 

what would be best setup here ? Creation of n+1 accounts were this extra account keeps monetary balance that is shared to another within group (tenant)?

Regards
Marcin

Dan Christian Bogos

unread,
Jun 2, 2019, 2:21:51 AM6/2/19
to cgr...@googlegroups.com
Hi Marcin,

There should be no need of extra tenant here. Just create one account
for each balance you want to share and then bind them via shared
balances.
Another option would be to directly "share" via account aliases
(attributes) but in that case you cannot say when to start using from
another account.
Please note that the shared balances were only tested in our lab, so
you should pay extra attention to them.

DanB
> --
> You received this message because you are subscribed to the Google
> Groups "CGRateS" group.
> To unsubscribe from this group and stop receiving emails from it,
> send an email to cgrates+u...@googlegroups.com.
> To post to this group, send email to cgr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/cgrates/8e026527-1ea2-4c0c-937f-104e5bacdafb%40googlegroups.com
> .
> For more options, visit https://groups.google.com/d/optout.

Marcin Kowalczyk

unread,
Jun 3, 2019, 11:48:58 AM6/3/19
to CGRateS
Hi Dan,

 Can it be done by API somehow? I mean creation of shared balance?
> send an email to cgr...@googlegroups.com.

Dan Christian Bogos

unread,
Jun 4, 2019, 7:49:35 AM6/4/19
to cgr...@googlegroups.com
Marcin,

Yes, shared balance is just a tag to a normal balance. You can add it
via either SetAccount or SetBalance.

DanB

Marcin Kowalczyk

unread,
Jun 4, 2019, 3:06:27 PM6/4/19
to CGRateS
Hi,

 So in general - add entry to data db 

 insert into tp_shared_groups values ('2','main_plan','shared_balance','*any','*highest','',NOW());

and then following api calls

{"method":"ApierV1.LoadSharedGroup","params":[{"TPid":"main_plan","SharedGroupId":"shared_balance"}]}

{"method":"ApierV1.SetBalance","params":[{"Tenant":"shared_balance","Account":"user1","BalanceType":"*monetary", "BalanceID":"shared","Directions":null,"ExpiryTime":null,"RatingSubject":null,"Categories":null,"DestinationIds":null,"TimingIds":null,"Weight":null,"SharedGroups":"shared_balance","Blocker":null,"Disabled":null,"Cdrlog":null,"ExtraData":null}],"id":10}
{"method":"ApierV1.SetBalance","params":[{"Tenant":"shared_balance","Account":"user2","BalanceType":"*monetary", "BalanceID":"shared","Directions":null,"ExpiryTime":null,"RatingSubject":null,"Categories":null,"DestinationIds":null,"TimingIds":null,"Weight":null,"SharedGroups":"shared_balance","Blocker":null,"Disabled":null,"Cdrlog":null,"ExtraData":null}],"id":10}
{"method":"ApierV1.SetBalance","params":[{"Tenant":"shared_balance","Account":"glowne","BalanceType":"*monetary","BalanceID":"shared","Directions":null,"Value":30000,"ExpiryTime":null,"RatingSubject":null,"Categories":null,"DestinationIds":null,"TimingIds":null,"Weight":null,"SharedGroups":"shared_balance","Blocker":null,"Disabled":null,"Cdrlog":null,"ExtraData":null}],"id":10}


{"method":"ApierV1.GetAccount","params":[{"Account":"main","Tenant":"shared_balance"}]}
{"method":"ApierV1.GetAccount","params":[{"Account":"user1","Tenant":"shared_balance"}]}
{"method":"ApierV1.GetAccount","params":[{"Account":"user2","Tenant":"shared_balance"}]}

Then assign shared monetary balance to account "main"?

Should all balances in users share same "BalanceID" tag?

Thx in advance!

Dan Christian Bogos

unread,
Jun 7, 2019, 6:17:53 AM6/7/19
to cgr...@googlegroups.com
Hi Marcin,

Please see inline ...

Am Dienstag, den 04.06.2019, 12:06 -0700 schrieb Marcin Kowalczyk:
> Hi,
>
> So in general - add entry to data db
>
> insert into tp_shared_groups values
> ('2','main_plan','shared_balance','*any','*highest','',NOW());
We don't recommend you updating StorDB directly with queries. You
should either use APIs or .csv.
>
> and then following api calls
>
> {"method":"ApierV1.LoadSharedGroup","params":[{"TPid":"main_plan","Sh
> aredGroupId":"shared_balance"}]}
This is only needed in case you want to change the charging for that
particular shared group.
>
> {"method":"ApierV1.SetBalance","params":[{"Tenant":"shared_balance","
> Account":"user1","BalanceType":"*monetary",
> "BalanceID":"shared","Directions":null,"ExpiryTime":null,"RatingSubje
> ct":null,"Categories":null,"DestinationIds":null,"TimingIds":null,"We
> ight":null,"SharedGroups":"shared_balance","Blocker":null,"Disabled":
> null,"Cdrlog":null,"ExtraData":null}],"id":10}
> {"method":"ApierV1.SetBalance","params":[{"Tenant":"shared_balance","
> Account":"user2","BalanceType":"*monetary",
> "BalanceID":"shared","Directions":null,"ExpiryTime":null,"RatingSubje
> ct":null,"Categories":null,"DestinationIds":null,"TimingIds":null,"We
> ight":null,"SharedGroups":"shared_balance","Blocker":null,"Disabled":
> null,"Cdrlog":null,"ExtraData":null}],"id":10}
> {"method":"ApierV1.SetBalance","params":[{"Tenant":"shared_balance","
> Account":"glowne","BalanceType":"*monetary","BalanceID":"shared","Dir
> ections":null,"Value":30000,"ExpiryTime":null,"RatingSubject":null,"C
> ategories":null,"DestinationIds":null,"TimingIds":null,"Weight":null,
> "SharedGroups":"shared_balance","Blocker":null,"Disabled":null,"Cdrlo
> g":null,"ExtraData":null}],"id":10}
>
>
> {"method":"ApierV1.GetAccount","params":[{"Account":"main","Tenant":"
> shared_balance"}]}
> {"method":"ApierV1.GetAccount","params":[{"Account":"user1","Tenant":
> "shared_balance"}]}
> {"method":"ApierV1.GetAccount","params":[{"Account":"user2","Tenant":
> "shared_balance"}]}
>
> Then assign shared monetary balance to account "main"?
I think you are making it too complicated.

All you need to do is have 2 accounts and assign a shared balance tag
to common balances. The rest is standard.

DanB
>
> Should all balances in users share same "BalanceID" tag?
>
> Thx in advance!
>
> W dniu wtorek, 4 czerwca 2019 13:49:35 UTC+2 użytkownik DanB napisał:
> > Marcin,
> >
> > Yes, shared balance is just a tag to a normal balance. You can add
> > it
> > via either SetAccount or SetBalance.
> >
> > DanB
> >
> > On Mon, 2019-06-03 at 08:48 -0700, Marcin Kowalczyk wrote:
> > > Hi Dan,
> > >
> > > Can it be done by API somehow? I mean creation of shared
> > balance?
> > >
> > >
> >
>
> --
> You received this message because you are subscribed to the Google
> Groups "CGRateS" group.
> To unsubscribe from this group and stop receiving emails from it,
> send an email to cgrates+u...@googlegroups.com.
> To post to this group, send email to cgr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/cgrates/4784be39-1e25-4a0c-b574-062c113fa482%40googlegroups.com

Marcin Kowalczyk

unread,
Jun 10, 2019, 7:08:28 AM6/10/19
to CGRateS
Hi Dan,

 Thx! I don't see any API method that will add SharedGroup into db. 

Regards
Marcin
> send an email to cgr...@googlegroups.com.

Dan Christian Bogos

unread,
Jun 10, 2019, 7:44:24 AM6/10/19
to cgr...@googlegroups.com
Hi Marcin,

You don't need to add SharedGroup to db, unless you want to change it's
default config.

DanB
Reply all
Reply to author
Forward
0 new messages