Hello.

1) I can also agree on that. Having sqlbox as requirement isn't such a great idea in my opinion. The better idea would be to implement accounting in bearerbox itself, one has to design the proper API for that.. Shouldn't be too hard though.

2) I'm not sure that using floats for accounting is such a great idea. I've seen many cases where FP arithmetic fails to produce proper results. I'd go with integers there. You'll just have to make a special note that accounting is performed in cents, not in euro/dollars/whatever.


On 01.08.2010 17:03, Nikos Balkanas wrote:
Hi,

I can see a couple of problems in this approach.

1) Billing should be implemented in bearerbox, since it decides on final
routing, not sqlbox.
2) There is an overuse of the DB. There is no need to put the priceplan
in a DB.

BR,
Nikos
----- Original Message ----- From: "Rene Kluwen" <[email protected]>
To: <[email protected]>
Cc: <[email protected]>
Sent: Sunday, August 01, 2010 4:08 AM
Subject: Discussion: Prepaid counting


Suppose I add 2 tables to sqlbox:

mysql> describe sms_users;
+---------+--------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+---------+--------------+------+-----+---------+-------+
| binfo | varchar(100) | NO | PRI | NULL | |
| balance | float(10,0) | NO | | 0 | |
+---------+--------------+------+-----+---------+-------+
2 rows in set (0.00 sec)

And:

mysql> describe sms_rates;
+---------+--------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+---------+--------------+------+-----+---------+-------+
| prefix | varchar(100) | NO | PRI | | |
| smsc | varchar(100) | NO | PRI | | |
| rate | float(10,4) | NO | | 0.0000 | |
| country | varchar(255) | YES | | | |
+---------+--------------+------+-----+---------+-------+
4 rows in set (0.00 sec)

And suppose I match prefix/smsc against sms_rates and draw the variable
"rate" from it.

Next, I check the sms_users table with the binfo field (not sure if
this is
a good idea or not) and I withdraw "rate" from "balance" if "balance"
is big
enough. Once balance reaches 0, sqlbox will refuse to relay further
messages
to bearerbox.

Attached is a patch that does the trick (for now, only mysql engines).
Note:
This code hasn't been tested yet and probably contains a bug or two.

But I am posting it anyway to see what the almighty Kannel Developers
have
to say about it.

This patch is especially useful if you want your clients to have
access to
an open smppbox with a limited amount of credits. But also it works for
smsboxes and sqlboxes, as you please.

I made a small patch to open smppbox that allows passing of binfo.

== Rene






--
Best regards,
  Victor Luchitz

Reply via email to