Skip to content

Commit

Permalink
Kazoo 6039 4.2 (2600hz#5466)
Browse files Browse the repository at this point in the history
* KAZOO-6039: added system_config option to disable ledger balance rollup

* KAZOO-6039: remove trailing whitespace
  • Loading branch information
k-anderson authored and lazedo committed Feb 1, 2019
1 parent d9bebe6 commit 663159b
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 13 deletions.
5 changes: 5 additions & 0 deletions applications/crossbar/priv/api/swagger.json
Original file line number Diff line number Diff line change
Expand Up @@ -30038,6 +30038,11 @@
"type": "object"
},
"type": "array"
},
"rollover_monthly_balance": {
"default": true,
"description": "ledgers rollover_monthly_balance",
"type": "boolean"
}
},
"type": "object"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,11 @@
"type": "object"
},
"type": "array"
},
"rollover_monthly_balance": {
"default": true,
"description": "ledgers rollover_monthly_balance",
"type": "boolean"
}
},
"type": "object"
Expand Down
30 changes: 17 additions & 13 deletions core/kazoo_transactions/src/wht_util.erl
Original file line number Diff line number Diff line change
Expand Up @@ -249,19 +249,23 @@ get_rollup_from_previous(Account) ->

-spec get_rollup_balance(kz_term:ne_binary(), kazoo_modb:view_options()) -> balance_ret().
get_rollup_balance(Account, Options) ->
View = <<"transactions/credit_remaining">>,
ViewOptions = ['reduce'
,'group'
,{'group_level', 1}
| Options
],
case kazoo_modb:get_results(Account, View, ViewOptions) of
{'ok', []} -> {'error', 'not_found'};
{'ok', [ViewRes|_]} ->
{'ok', kz_json:get_integer_value(<<"value">>, ViewRes, 0)};
{'error', _R}=E ->
lager:warning("unable to get rollup balance for ~s: ~p", [Account, _R]),
E
case kapps_config:get_is_true(<<"ledgers">>, <<"rollover_monthly_balance">>, 'true') of
'false' -> {'ok', 0};
'true' ->
View = <<"transactions/credit_remaining">>,
ViewOptions = ['reduce'
,'group'
,{'group_level', 1}
| Options
],
case kazoo_modb:get_results(Account, View, ViewOptions) of
{'ok', []} -> {'error', 'not_found'};
{'ok', [ViewRes|_]} ->
{'ok', kz_json:get_integer_value(<<"value">>, ViewRes, 0)};
{'error', _R}=E ->
lager:warning("unable to get rollup balance for ~s: ~p", [Account, _R]),
E
end
end.

%%------------------------------------------------------------------------------
Expand Down

0 comments on commit 663159b

Please sign in to comment.