function generateScheduledPayments($project_id, $task_id, $frequency, $start_ts, $end_ts, $item_code, $description_format, $amount){
		$months = array( 1 => 'Jan', 'Feb', 'Mar', 'Apr', 'May', 'June', 'July', 'Aug', 'Sept', 'Oct', 'Nov', 'Dec');
		$scheduled_payments = array();
		if($frequency == 'Monthly'){
			$dom = (int)date('d', $start_ts);
			$start_month = (int)date('m', $start_ts);
			$start_year = (int)date('Y', $start_ts);
			$end_month = (int)date('m', $end_ts);
			$end_year = (int)date('Y', $end_ts);
			$current_month = $start_month;
			$current_year = $start_year;
			//print("From $start_month/$start_year to $end_month/$end_year on the $dom\n");
			while($current_year < $end_year || 
			$current_month <= $end_month && $current_year == $end_year){
				//print("Creating payment for $current_month/$dom/$current_year\n");
				$ps = new SI_PaymentSchedule();
				if($task_id > 0){
					$ps->task_id = $task_id;
					$task = $ps->getTask();
					$ps->project_id = $task->project_id;
				}else{
					$ps->project_id = $project_id;
				}
				$ps->amount = $amount;
				$ps->due_ts = strtotime($current_year.'-'.$current_month.'-'.$dom);
				if(stristr($description_format, '|MONTH|')){
					$ps->description = str_replace('|MONTH|', $months[(int)$current_month], $description_format);
				}else{
					$ps->description = $description_format;
				}
				$ps->item_code_id = $item_code;
				if($ps->add()){
					$scheduled_payments[] = $ps;
				}else{
					return FALSE;
				}
				if($current_month == 12){
					$current_month = 1;
					$current_year++;
				}else{
					$current_month++;
				}
				//print("Next date $current_month/$dom/$current_year\n");
			}
		}
		
		return $scheduled_payments;
	}