h1. Balance threshold control *Balance threshold control* is responsible for sending notification e-mails when company's balance reaches some threshold limit. This could be useful to notify your customers that they need to refill their balance as soon as possible or the service provision might will be suspended soon. To configure it, you need to supply threshold values in company's configuration. As far company has 3 balances (their, our and mutual) you can specify balance threshold for any of them. Let's for instance configure +their balance threshold+. This balance threshold will apply to the company's balance. The similar way you could configure +our balance threshold+ which will apply to our balance for this company. To do this, enter _edit mode_ of company and go to +Their Balance+ tab: !balance_threshold.gif! *balance threshold amount* and *balance threshold currency* define the threshold limit for the company's balance. *balance alarm email* defines e-mail to which notification e-mail will be sent. *balance alarm mail template* defines mail template which will be used for sending e-mail. *balance mail time* declares time when *Smartswitch* has sent notification mail last time. _Balance Threshold Controller_ is implemented as application, named [[balance_threshold_controller application|balance_threshold_controller]]. You can schedule it's execution via [[Tasks]]. When the application is invoked by [[Tasks]] scheduling subsystem, it checks all company's that have balance threshold control enabled, and sends e-mails correspondingly. To create e-mail, application uses +balance alarm mail template+. Application passes next variables to the mail template: _${COMPANY}_ - the company's name _${BALANCE}_ - the company's balance You can use these variables inside mail template. When e-mail has been sent, application sets +balance mail time+ for the corresponding peer. In case if current balance doesn't require mail sending, +balance mail time+ is cleared. Each time when _balance threshold controller_ is invoked, it checks if +balance mail time+ is set, and if it's set, it doesn't send email again. This is done to eliminate spam e-mails to customers. So the only case for _balance threshold controller_ to actually send e-mail is when current balance requires e-mail sending and +balance mail time+ is not set.