Some code cleanup.
Compute invoice terms..etc