refactoring billing period code