Sounds like a simple database solution. Given that the app enters data into SQL compatible DB, the following statement should do the trick without the need of loops of any kind:
SELECT SUM(sales_column_name) FROM table_name
with the table looking something similar to
branch_name | sales_column_name
branch 1 | 5000
branch 2 | 3000
Etc.