In this paper, we discuss the determination of the optimal due date for a manufacturer who has a
contractual relationship with her customer to supply parts. The rate of production of the parts is constant as long as the production facility which is unreliable is up and running. The production facility itself is leased from a contractor who is also contracted to perform the maintenance of it. As production output is random, the supplier needs to make two important decisions: (i) how much time to allow for production taking into account the trade-off between the overage and underage costs; (ii) how to design the maintenance outsourcing contract to maximize her own profit while satisfying the contractor's reservation (minimum) profit requirements. This is a finite horizon optimization problem. We first provide a general analysis of the operating characteristics of the system under consideration. The analysis clearly reveals that the behaviour of the performance measures are very much parameters-dependent and also complex. The optimization problem is illustrated through numerical examples. The examples show that the supplier and the contractor stand to gain under cooperation. We also highlight some incentive mechanisms that can be used to enforce this cooperation.