Helper for queries that only return a single row.
Merge branch 'trustlevel-repo'
To determine how much permission a customer account should have to take risky
actions. Seperate from their plan, this is not how much they could do in
theory, but how much the system will allow in practise due to perceived risk.
Starts out with a simple model based on amount of settled payments, and being
used to decide what is an "expensive" route for outbound calls.
Transaction amounts are negative, but cdr charge is positive
Make sure from and to are in correct direction
Doesn't affect any current code paths, but should be correct in case we ever
start using it in the inbound case.
Also from does not have to be a formatted phone number, can be a string like
Try auto top up / low balance notify when not enough balance for a call
There is an edge case where a customer might not have auto-topped up yet but
they don't have enough balance for this call, so try to charge their card first
before telling them the call is a no go.
Also supports limits on inbound calls
Outbound call logic for overages
If cannot find an acceptable rate for the number, cannot call.
If balance is too low, cannot call.
If too close to limit, warn.