invoice logic built