When generating statements, the printed flag is set in the account receivable transactions. Also, a function marks all printed transactions as completed (by customer and with a warning). When it is marked as completed, it updates the customer's previous balance.