<?php
class AccountantComponent extends Object {
	
		var $controller;
	
		function startup(&$controller) {
			
			$this->controller = $controller;
		}
		
		function chargeForBid( $bidId ) {
			
			$Campiagn =& new Campiagn();
			$camp = $Campiagn->get( $bidId );
			
			if( $camp ) {
				$Account =& new Account();
				$key = $Account->getCreditKey( $camp['account_id'] );
				if( $key ) {
					if( $this->_charge( $key, $camp['bid'] ) {
											   
						if( !$Campiagn->adjustBalance( $bidId ) ) {
							// log error adjustment failed
						}
					} else {
						//log error charge failed	
					}
				} else {
					//log error account is not billable no credit info on file
				}
			} else {
				//log error no campiagn found
			}
		}
		
		//private
		function _charge( $key, $amount ) {
			
			// all of the logic needed to bill an account via a 
			// third party credit card storage and billing company
			// would go here
			//record transaction on general ledger	
		}
		
		//private
		function _refund( $key, $amount ) {
			
			// all of the logic needed to bill an account via a 
			// third party credit card storage and billing company
			// would go here
			//record transaction on general ledger				
		}
	
}
?>