wip:initial work for accrual accounting and refactoring