Fix view errors after upstream changes
Split analytic_department into analytic_base_department to isolate dependency on account
Add tests to analytic_base_department