this is pretty sneaky. is this really the right place for this logic? (as opposed to whatever is calling the invoice generation)