From b7a87d1e59b31d256be94af06390e861009508b9 Mon Sep 17 00:00:00 2001 From: DanB Date: Tue, 8 Oct 2013 11:57:06 +0200 Subject: [PATCH] Action bug fixup, fix cost field in stor db --- data/storage/mysql/create_costdetails_tables.sql | 4 ++-- engine/action.go | 3 +++ 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/data/storage/mysql/create_costdetails_tables.sql b/data/storage/mysql/create_costdetails_tables.sql index 868027892..6b2ee5a42 100644 --- a/data/storage/mysql/create_costdetails_tables.sql +++ b/data/storage/mysql/create_costdetails_tables.sql @@ -12,8 +12,8 @@ CREATE TABLE `cost_details` ( `account` varchar(128) NOT NULL, `subject` varchar(128) NOT NULL, `destination` varchar(128) NOT NULL, - `cost` DECIMAL(5,4) NOT NULL, - `connect_fee` DECIMAL(5,4) NOT NULL, + `cost` double(20,4) NOT NULL, + `connect_fee` double(20,4) NOT NULL, `timespans` text, `source` varchar(64) NOT NULL, PRIMARY KEY (`id`), diff --git a/engine/action.go b/engine/action.go index cad58c4d6..d872eca42 100644 --- a/engine/action.go +++ b/engine/action.go @@ -119,6 +119,9 @@ func resetPrepaidAction(ub *UserBalance, a *Action) (err error) { } func topupResetAction(ub *UserBalance, a *Action) (err error) { + if ub.BalanceMap == nil { // Init the map since otherwise will get error if nil + ub.BalanceMap = make(map[string]BalanceChain, 0) + } ub.BalanceMap[a.BalanceId+a.Direction] = BalanceChain{&Balance{Value: 0}} // ToDo: can ub be empty here? genericMakeNegative(a) genericDebit(ub, a)