QuickBooks/Utilities.php
static public function priorityForAction($action, $dependency = null)
	{
		// low priorities up here (*lots* of dependencies)
		static $priorities = array(
			QUICKBOOKS_DELETE_TRANSACTION, 
			
			QUICKBOOKS_VOID_TRANSACTION, 
		
			QUICKBOOKS_DEL_DATAEXT, 
			QUICKBOOKS_MOD_DATAEXT,
			QUICKBOOKS_ADD_DATAEXT, 
		
			QUICKBOOKS_MOD_JOURNALENTRY, 
			QUICKBOOKS_ADD_JOURNALENTRY, 
		
			QUICKBOOKS_MOD_RECEIVEPAYMENT, 
			QUICKBOOKS_ADD_RECEIVEPAYMENT, 
			
			QUICKBOOKS_MOD_BILLPAYMENTCHECK, 
			QUICKBOOKS_ADD_BILLPAYMENTCHECK, 
			
			//QUICKBOOKS_MOD_BILLPAYMENTCREDITCARD, 
			QUICKBOOKS_ADD_BILLPAYMENTCREDITCARD, 
			
			QUICKBOOKS_MOD_BILL, 
			QUICKBOOKS_ADD_BILL, 
			
			QUICKBOOKS_MOD_PURCHASEORDER, 
			QUICKBOOKS_ADD_PURCHASEORDER, 
			
			QUICKBOOKS_MOD_INVOICE,
			QUICKBOOKS_ADD_INVOICE,
			
			QUICKBOOKS_MOD_SALESORDER, 
			QUICKBOOKS_ADD_SALESORDER, 
			
			QUICKBOOKS_MOD_ESTIMATE, 
			QUICKBOOKS_ADD_ESTIMATE, 
			
			QUICKBOOKS_ADD_INVENTORYADJUSTMENT, 

			QUICKBOOKS_ADD_CREDITMEMO, 
			QUICKBOOKS_MOD_CREDITMEMO, 
			
			QUICKBOOKS_ADD_ITEMRECEIPT,
			QUICKBOOKS_MOD_ITEMRECEIPT,

			QUICKBOOKS_MOD_SALESRECEIPT, 
			QUICKBOOKS_ADD_SALESRECEIPT, 

			QUICKBOOKS_ADD_SALESTAXITEM, 
			QUICKBOOKS_MOD_SALESTAXITEM, 
			
			QUICKBOOKS_ADD_DISCOUNTITEM, 
			QUICKBOOKS_MOD_DISCOUNTITEM, 
			
			QUICKBOOKS_ADD_OTHERCHARGEITEM, 
			QUICKBOOKS_MOD_OTHERCHARGEITEM, 
			
			QUICKBOOKS_MOD_NONINVENTORYITEM, 
			QUICKBOOKS_ADD_NONINVENTORYITEM,
			
			QUICKBOOKS_MOD_INVENTORYITEM,  
			QUICKBOOKS_ADD_INVENTORYITEM, 
			
			QUICKBOOKS_MOD_INVENTORYASSEMBLYITEM,
			QUICKBOOKS_ADD_INVENTORYASSEMBLYITEM,
			
			QUICKBOOKS_MOD_SERVICEITEM, 
			QUICKBOOKS_ADD_SERVICEITEM, 
			
			QUICKBOOKS_MOD_PAYMENTITEM, 
			QUICKBOOKS_ADD_PAYMENTITEM, 
			
			QUICKBOOKS_MOD_SALESREP, 
			QUICKBOOKS_ADD_SALESREP, 
			
			QUICKBOOKS_MOD_EMPLOYEE, 
			QUICKBOOKS_ADD_EMPLOYEE, 
			
			//QUICKBOOKS_MOD_SALESTAXCODE, 		// The SDK doesn't support this
			QUICKBOOKS_ADD_SALESTAXCODE, 
			
			QUICKBOOKS_MOD_VENDOR, 
			QUICKBOOKS_ADD_VENDOR, 
			
			QUICKBOOKS_MOD_JOB,
			QUICKBOOKS_ADD_JOB,
			
			QUICKBOOKS_MOD_CUSTOMER,
			QUICKBOOKS_ADD_CUSTOMER,
			
			QUICKBOOKS_MOD_ACCOUNT, 
			QUICKBOOKS_ADD_ACCOUNT, 
			
			//QUICKBOOKS_MOD_CLASS,		(does not exist in qbXML API) 
			QUICKBOOKS_ADD_CLASS, 
			
			QUICKBOOKS_ADD_PAYMENTMETHOD, 
			QUICKBOOKS_ADD_SHIPMETHOD, 
			
			// Queries 
			QUICKBOOKS_QUERY_PURCHASEORDER,
			QUICKBOOKS_QUERY_ITEMRECEIPT,
			QUICKBOOKS_QUERY_SALESORDER, 
			QUICKBOOKS_QUERY_SALESRECEIPT, 
			QUICKBOOKS_QUERY_INVOICE,
			QUICKBOOKS_QUERY_ESTIMATE, 
			QUICKBOOKS_QUERY_RECEIVEPAYMENT, 
			QUICKBOOKS_QUERY_CREDITMEMO, 
			
			QUICKBOOKS_QUERY_BILLPAYMENTCHECK, 
			QUICKBOOKS_QUERY_BILLPAYMENTCREDITCARD, 
			QUICKBOOKS_QUERY_BILLTOPAY, 
			QUICKBOOKS_QUERY_BILL, 
			
			QUICKBOOKS_QUERY_CREDITCARDCHARGE, 
			QUICKBOOKS_QUERY_CREDITCARDCREDIT, 
			QUICKBOOKS_QUERY_CHECK, 
			QUICKBOOKS_QUERY_CHARGE,
			
			QUICKBOOKS_QUERY_DELETEDLISTS,		// This gets all items deleted in the last 90 days
			QUICKBOOKS_QUERY_DELETEDTXNS,		// This gets all transactions deleted in the last 90 days
			
			QUICKBOOKS_QUERY_TIMETRACKING, 
			QUICKBOOKS_QUERY_VENDORCREDIT, 
			
			QUICKBOOKS_QUERY_INVENTORYADJUSTMENT, 
			
			QUICKBOOKS_QUERY_ITEM, 
			QUICKBOOKS_QUERY_DISCOUNTITEM, 
			QUICKBOOKS_QUERY_SALESTAXITEM, 
			QUICKBOOKS_QUERY_SERVICEITEM,
			QUICKBOOKS_QUERY_NONINVENTORYITEM, 
			QUICKBOOKS_QUERY_INVENTORYITEM, 

			QUICKBOOKS_QUERY_SALESREP, 

			QUICKBOOKS_QUERY_VEHICLEMILEAGE, 
			QUICKBOOKS_QUERY_VEHICLE, 

			QUICKBOOKS_QUERY_CUSTOMER,
			QUICKBOOKS_QUERY_VENDOR, 
			QUICKBOOKS_QUERY_EMPLOYEE, 
			QUICKBOOKS_QUERY_JOB,

			QUICKBOOKS_QUERY_WORKERSCOMPCODE, 

			QUICKBOOKS_QUERY_UNITOFMEASURESET,
			
			QUICKBOOKS_QUERY_JOURNALENTRY, 
			QUICKBOOKS_QUERY_DEPOSIT,  

			QUICKBOOKS_QUERY_SHIPMETHOD, 
			QUICKBOOKS_QUERY_PAYMENTMETHOD, 
			QUICKBOOKS_QUERY_PRICELEVEL, 
			QUICKBOOKS_QUERY_DATEDRIVENTERMS, 
			QUICKBOOKS_QUERY_BILLINGRATE, 
			QUICKBOOKS_QUERY_CUSTOMERTYPE, 
			QUICKBOOKS_QUERY_CUSTOMERMSG, 
			QUICKBOOKS_QUERY_TERMS, 
			QUICKBOOKS_QUERY_SALESTAXCODE, 
			QUICKBOOKS_QUERY_ACCOUNT, 
			QUICKBOOKS_QUERY_CLASS, 
			QUICKBOOKS_QUERY_JOBTYPE, 
			QUICKBOOKS_QUERY_VENDORTYPE, 
			
			QUICKBOOKS_QUERY_COMPANY, 
			
			
			QUICKBOOKS_IMPORT_RECEIVEPAYMENT, 
			
			
			QUICKBOOKS_IMPORT_PURCHASEORDER,
			QUICKBOOKS_IMPORT_ITEMRECEIPT,
			QUICKBOOKS_IMPORT_SALESRECEIPT, 
			
			// The ESTIMATE, then INVOICE, then SALES ORDER order is important, 
			//	because we might have events which depend on the estimate being present 
			//	when the invoice is imported, or the sales order being present when 
			//	then invoice is imported, etc. 
			QUICKBOOKS_IMPORT_INVOICE,
			QUICKBOOKS_IMPORT_SALESORDER, 
			QUICKBOOKS_IMPORT_ESTIMATE, 
			
			QUICKBOOKS_IMPORT_BILLPAYMENTCHECK, 
			QUICKBOOKS_IMPORT_BILLPAYMENTCREDITCARD, 
			QUICKBOOKS_IMPORT_BILLTOPAY, 
			QUICKBOOKS_IMPORT_BILL, 
			
			QUICKBOOKS_IMPORT_CREDITCARDCHARGE, 
			QUICKBOOKS_IMPORT_CREDITCARDCREDIT, 
			QUICKBOOKS_IMPORT_CHECK, 
			QUICKBOOKS_IMPORT_CHARGE,
			
			QUICKBOOKS_IMPORT_DELETEDLISTS,    // This gets all items deleted in the last 90 days.
			QUICKBOOKS_IMPORT_DELETEDTXNS,    // This gets all transactions deleted in the last 90 days.
			
			QUICKBOOKS_IMPORT_TIMETRACKING, 
			QUICKBOOKS_IMPORT_VENDORCREDIT, 
			
			QUICKBOOKS_IMPORT_INVENTORYADJUSTMENT, 
			
			QUICKBOOKS_IMPORT_ITEM, 
			QUICKBOOKS_IMPORT_DISCOUNTITEM, 
			QUICKBOOKS_IMPORT_SALESTAXITEM, 
			QUICKBOOKS_IMPORT_SERVICEITEM,
			QUICKBOOKS_IMPORT_NONINVENTORYITEM, 
			QUICKBOOKS_IMPORT_INVENTORYITEM, 
			QUICKBOOKS_IMPORT_INVENTORYASSEMBLYITEM,

			QUICKBOOKS_IMPORT_SALESREP, 

			QUICKBOOKS_IMPORT_VEHICLEMILEAGE, 
			QUICKBOOKS_IMPORT_VEHICLE, 

			QUICKBOOKS_IMPORT_CUSTOMER,
			QUICKBOOKS_IMPORT_VENDOR, 
			QUICKBOOKS_IMPORT_EMPLOYEE, 
			QUICKBOOKS_IMPORT_JOB,

			QUICKBOOKS_IMPORT_WORKERSCOMPCODE, 

			QUICKBOOKS_IMPORT_UNITOFMEASURESET,
			
			QUICKBOOKS_IMPORT_JOURNALENTRY, 
			QUICKBOOKS_IMPORT_DEPOSIT,  

			QUICKBOOKS_IMPORT_SHIPMETHOD, 
			QUICKBOOKS_IMPORT_PAYMENTMETHOD, 
			QUICKBOOKS_IMPORT_PRICELEVEL, 
			QUICKBOOKS_IMPORT_DATEDRIVENTERMS, 
			QUICKBOOKS_IMPORT_BILLINGRATE, 
			QUICKBOOKS_IMPORT_CUSTOMERTYPE, 
			QUICKBOOKS_IMPORT_CUSTOMERMSG, 
			QUICKBOOKS_IMPORT_TERMS, 
			QUICKBOOKS_IMPORT_SALESTAXCODE, 
			QUICKBOOKS_IMPORT_ACCOUNT, 
			QUICKBOOKS_IMPORT_CLASS, 
			QUICKBOOKS_IMPORT_JOBTYPE, 
			QUICKBOOKS_IMPORT_VENDORTYPE, 
			
			QUICKBOOKS_IMPORT_COMPANY, 
		);
		// high priorities down here (no dependencies OR queries)
		
		// Now, let's space those priorities out a little bit, it gives us some 
		//	wiggle room in case we need to add things inbetween the default 
		//	priority values
		static $wiggled = false;
		$wiggle = 6;
		
		if (!$wiggled)
		{
			$count = count($priorities);
			for ($i = $count - 1; $i >= 0; $i--)
			{
				$priorities[$i * $wiggle] = $priorities[$i];
				unset($priorities[$i]);
				
				// with a wiggle multiplier of 2...
				// 	priority 25 goes to 50
				// 	priority 24 goes to 48
				// 	priority 23 goes to 46
				// 	etc. etc. etc. 
			}
			
			$wiggled = true;
			
			//print_r($priorities);
		}
		
		if ($dependency)
		{
			// 
			// This is a list of dependency modifications
			//	For instance, normally, you'd want to send just any  old DataExtAdd 
			//	with a really low priority, because whatever record it applies to 
			//	must be in QuickBooks before you send the DataExtAdd/Mod request. 
			// 
			//	However, if we pass in the $dependency of QUICKBOOKS_ADD_CUSTOMER, 
			//	then we know that this DataExt applies to a CustomerAdd, and can 
			//	therefore be sent with a priority *just barely lower than* than a 
			//	CustomerAdd request, which will ensure this gets run as soon as 
			//	possible, but not sooner than the CustomerAdd.
			// 
			//	This is important because in some cases, this data will be 
			//	automatically used by QuickBooks. For instance, a custom field that 
			//	is placed on an Invoice *must already be populated for the 
			//	Customer* before the invoice is created. 
			//
			// This is an example of a priority list without dependencies, and it's bad: 	
			//	CustomerAdd, InvoiceAdd, DataExtAdd		
			//	(the custom field for the customer doesn't get populated in the invoice)
			//
			// This is an example of a priority list with dependencies, and it's good: 
			// 	CustomerAdd, DataExtAdd, InvoiceAdd
			//	
			$dependencies = array(
				QUICKBOOKS_ADD_DATAEXT => array( 
					QUICKBOOKS_ADD_CUSTOMER => QuickBooks_Utilities::priorityForAction(QUICKBOOKS_ADD_CUSTOMER) - 1, 
					QUICKBOOKS_MOD_CUSTOMER => QuickBooks_Utilities::priorityForAction(QUICKBOOKS_MOD_CUSTOMER) - 1, 
				),
				QUICKBOOKS_MOD_DATAEXT => array(
					QUICKBOOKS_ADD_CUSTOMER => QuickBooks_Utilities::priorityForAction(QUICKBOOKS_ADD_CUSTOMER) - 1, 
					QUICKBOOKS_MOD_CUSTOMER => QuickBooks_Utilities::priorityForAction(QUICKBOOKS_MOD_CUSTOMER) - 1, 
					),
					
				// A *Bill VOID* has a slightly higher priority than a PurchaseOrderMod so that we can IsManuallyClosed POs (we'll get an error if we try to close it and a bill is dependent on it)  
				QUICKBOOKS_VOID_TRANSACTION => array(
					QUICKBOOKS_MOD_PURCHASEORDER => QuickBooks_Utilities::priorityForAction(QUICKBOOKS_MOD_PURCHASEORDER) + 1, 
					), 
				);			
		}
		
		// Check for dependency priorities
		if ($dependency and 
			isset($dependencies[$action]) and 
			isset($dependencies[$action][$dependency]))
		{			
			// Dependency modified priority
			return $dependencies[$action][$dependency];
		}
		else if ($key = array_search($action, $priorities))
		{
			// Regular priority
			return $key;
		}
		
		// Default priority
		return 999;		
	}
static public function priorityForAction($action, $dependency = null)
	{
		// low priorities up here (*lots* of dependencies)
		static $priorities = array(
			QUICKBOOKS_DELETE_TRANSACTION, 
			
			QUICKBOOKS_VOID_TRANSACTION, 
		
			QUICKBOOKS_DEL_DATAEXT, 
			QUICKBOOKS_MOD_DATAEXT,
			QUICKBOOKS_ADD_DATAEXT, 
		
			QUICKBOOKS_MOD_JOURNALENTRY, 
			QUICKBOOKS_ADD_JOURNALENTRY, 
		
			QUICKBOOKS_MOD_RECEIVEPAYMENT, 
			QUICKBOOKS_ADD_RECEIVEPAYMENT, 
			
			QUICKBOOKS_MOD_BILLPAYMENTCHECK, 
			QUICKBOOKS_ADD_BILLPAYMENTCHECK, 
			
			//QUICKBOOKS_MOD_BILLPAYMENTCREDITCARD, 
			QUICKBOOKS_ADD_BILLPAYMENTCREDITCARD, 
			
			QUICKBOOKS_MOD_BILL, 
			QUICKBOOKS_ADD_BILL, 
			
			QUICKBOOKS_MOD_PURCHASEORDER, 
			QUICKBOOKS_ADD_PURCHASEORDER, 
			
			QUICKBOOKS_MOD_INVOICE,
			QUICKBOOKS_ADD_INVOICE,
			
			QUICKBOOKS_MOD_SALESORDER, 
			QUICKBOOKS_ADD_SALESORDER, 
			
			QUICKBOOKS_MOD_ESTIMATE, 
			QUICKBOOKS_ADD_ESTIMATE, 
			
			QUICKBOOKS_ADD_INVENTORYADJUSTMENT, 

			QUICKBOOKS_ADD_CREDITMEMO, 
			QUICKBOOKS_MOD_CREDITMEMO, 
			
			QUICKBOOKS_ADD_ITEMRECEIPT,
			QUICKBOOKS_MOD_ITEMRECEIPT,

			QUICKBOOKS_MOD_SALESRECEIPT, 
			QUICKBOOKS_ADD_SALESRECEIPT, 

			QUICKBOOKS_ADD_SALESTAXITEM, 
			QUICKBOOKS_MOD_SALESTAXITEM, 
			
			QUICKBOOKS_ADD_DISCOUNTITEM, 
			QUICKBOOKS_MOD_DISCOUNTITEM, 
			
			QUICKBOOKS_ADD_OTHERCHARGEITEM, 
			QUICKBOOKS_MOD_OTHERCHARGEITEM, 
			
			QUICKBOOKS_MOD_NONINVENTORYITEM, 
			QUICKBOOKS_ADD_NONINVENTORYITEM,
			
			QUICKBOOKS_MOD_INVENTORYITEM,  
			QUICKBOOKS_ADD_INVENTORYITEM, 
			
			QUICKBOOKS_MOD_INVENTORYASSEMBLYITEM,
			QUICKBOOKS_ADD_INVENTORYASSEMBLYITEM,
			
			QUICKBOOKS_MOD_SERVICEITEM, 
			QUICKBOOKS_ADD_SERVICEITEM, 
			
			QUICKBOOKS_MOD_PAYMENTITEM, 
			QUICKBOOKS_ADD_PAYMENTITEM, 
			
			QUICKBOOKS_MOD_SALESREP, 
			QUICKBOOKS_ADD_SALESREP, 
			
			QUICKBOOKS_MOD_EMPLOYEE, 
			QUICKBOOKS_ADD_EMPLOYEE, 
			
			//QUICKBOOKS_MOD_SALESTAXCODE, 		// The SDK doesn't support this
			QUICKBOOKS_ADD_SALESTAXCODE, 
			
			QUICKBOOKS_MOD_VENDOR, 
			QUICKBOOKS_ADD_VENDOR, 
			
			QUICKBOOKS_MOD_JOB,
			QUICKBOOKS_ADD_JOB,
			
			QUICKBOOKS_MOD_CUSTOMER,
			QUICKBOOKS_ADD_CUSTOMER,
			
			QUICKBOOKS_MOD_ACCOUNT, 
			QUICKBOOKS_ADD_ACCOUNT, 
			
			//QUICKBOOKS_MOD_CLASS,		(does not exist in qbXML API) 
			QUICKBOOKS_ADD_CLASS, 
			
			QUICKBOOKS_ADD_PAYMENTMETHOD, 
			QUICKBOOKS_ADD_SHIPMETHOD, 
			
			// Queries 
			QUICKBOOKS_QUERY_PURCHASEORDER,
			QUICKBOOKS_QUERY_ITEMRECEIPT,
			QUICKBOOKS_QUERY_SALESORDER, 
			QUICKBOOKS_QUERY_SALESRECEIPT, 
			QUICKBOOKS_QUERY_INVOICE,
			QUICKBOOKS_QUERY_ESTIMATE, 
			QUICKBOOKS_QUERY_RECEIVEPAYMENT, 
			QUICKBOOKS_QUERY_CREDITMEMO, 
			
			QUICKBOOKS_QUERY_BILLPAYMENTCHECK, 
			QUICKBOOKS_QUERY_BILLPAYMENTCREDITCARD, 
			QUICKBOOKS_QUERY_BILLTOPAY, 
			QUICKBOOKS_QUERY_BILL, 
			
			QUICKBOOKS_QUERY_CREDITCARDCHARGE, 
			QUICKBOOKS_QUERY_CREDITCARDCREDIT, 
			QUICKBOOKS_QUERY_CHECK, 
			QUICKBOOKS_QUERY_CHARGE,
			
			QUICKBOOKS_QUERY_DELETEDLISTS,		// This gets all items deleted in the last 90 days
			QUICKBOOKS_QUERY_DELETEDTXNS,		// This gets all transactions deleted in the last 90 days
			
			QUICKBOOKS_QUERY_TIMETRACKING, 
			QUICKBOOKS_QUERY_VENDORCREDIT, 
			
			QUICKBOOKS_QUERY_INVENTORYADJUSTMENT, 
			
			QUICKBOOKS_QUERY_ITEM, 
			QUICKBOOKS_QUERY_DISCOUNTITEM, 
			QUICKBOOKS_QUERY_SALESTAXITEM, 
			QUICKBOOKS_QUERY_SERVICEITEM,
			QUICKBOOKS_QUERY_NONINVENTORYITEM, 
			QUICKBOOKS_QUERY_INVENTORYITEM, 

			QUICKBOOKS_QUERY_SALESREP, 

			QUICKBOOKS_QUERY_VEHICLEMILEAGE, 
			QUICKBOOKS_QUERY_VEHICLE, 

			QUICKBOOKS_QUERY_CUSTOMER,
			QUICKBOOKS_QUERY_VENDOR, 
			QUICKBOOKS_QUERY_EMPLOYEE, 
			QUICKBOOKS_QUERY_JOB,

			QUICKBOOKS_QUERY_WORKERSCOMPCODE, 

			QUICKBOOKS_QUERY_UNITOFMEASURESET,
			
			QUICKBOOKS_QUERY_JOURNALENTRY, 
			QUICKBOOKS_QUERY_DEPOSIT,  

			QUICKBOOKS_QUERY_SHIPMETHOD, 
			QUICKBOOKS_QUERY_PAYMENTMETHOD, 
			QUICKBOOKS_QUERY_PRICELEVEL, 
			QUICKBOOKS_QUERY_DATEDRIVENTERMS, 
			QUICKBOOKS_QUERY_BILLINGRATE, 
			QUICKBOOKS_QUERY_CUSTOMERTYPE, 
			QUICKBOOKS_QUERY_CUSTOMERMSG, 
			QUICKBOOKS_QUERY_TERMS, 
			QUICKBOOKS_QUERY_SALESTAXCODE, 
			QUICKBOOKS_QUERY_ACCOUNT, 
			QUICKBOOKS_QUERY_CLASS, 
			QUICKBOOKS_QUERY_JOBTYPE, 
			QUICKBOOKS_QUERY_VENDORTYPE, 
			
			QUICKBOOKS_QUERY_COMPANY, 
			
			
			QUICKBOOKS_IMPORT_RECEIVEPAYMENT, 
			
			
			QUICKBOOKS_IMPORT_PURCHASEORDER,
			QUICKBOOKS_IMPORT_ITEMRECEIPT,
			QUICKBOOKS_IMPORT_SALESRECEIPT, 
			
			// The ESTIMATE, then INVOICE, then SALES ORDER order is important, 
			//	because we might have events which depend on the estimate being present 
			//	when the invoice is imported, or the sales order being present when 
			//	then invoice is imported, etc. 
			QUICKBOOKS_IMPORT_INVOICE,
			QUICKBOOKS_IMPORT_SALESORDER, 
			QUICKBOOKS_IMPORT_ESTIMATE, 
			
			QUICKBOOKS_IMPORT_BILLPAYMENTCHECK, 
			QUICKBOOKS_IMPORT_BILLPAYMENTCREDITCARD, 
			QUICKBOOKS_IMPORT_BILLTOPAY, 
			QUICKBOOKS_IMPORT_BILL, 
			
			QUICKBOOKS_IMPORT_CREDITCARDCHARGE, 
			QUICKBOOKS_IMPORT_CREDITCARDCREDIT, 
			QUICKBOOKS_IMPORT_CHECK, 
			QUICKBOOKS_IMPORT_CHARGE,
			
			QUICKBOOKS_IMPORT_DELETEDLISTS,    // This gets all items deleted in the last 90 days.
			QUICKBOOKS_IMPORT_DELETEDTXNS,    // This gets all transactions deleted in the last 90 days.
			
			QUICKBOOKS_IMPORT_TIMETRACKING, 
			QUICKBOOKS_IMPORT_VENDORCREDIT, 
			
			QUICKBOOKS_IMPORT_INVENTORYADJUSTMENT, 
			
			QUICKBOOKS_IMPORT_ITEM, 
			QUICKBOOKS_IMPORT_DISCOUNTITEM, 
			QUICKBOOKS_IMPORT_SALESTAXITEM, 
			QUICKBOOKS_IMPORT_SERVICEITEM,
			QUICKBOOKS_IMPORT_NONINVENTORYITEM, 
			QUICKBOOKS_IMPORT_INVENTORYITEM, 
			QUICKBOOKS_IMPORT_INVENTORYASSEMBLYITEM,

			QUICKBOOKS_IMPORT_SALESREP, 

			QUICKBOOKS_IMPORT_VEHICLEMILEAGE, 
			QUICKBOOKS_IMPORT_VEHICLE, 

			QUICKBOOKS_IMPORT_CUSTOMER,
			QUICKBOOKS_IMPORT_VENDOR, 
			QUICKBOOKS_IMPORT_EMPLOYEE, 
			QUICKBOOKS_IMPORT_JOB,

			QUICKBOOKS_IMPORT_WORKERSCOMPCODE, 

			QUICKBOOKS_IMPORT_UNITOFMEASURESET,
			
			QUICKBOOKS_IMPORT_JOURNALENTRY, 
			QUICKBOOKS_IMPORT_DEPOSIT,  

			QUICKBOOKS_IMPORT_SHIPMETHOD, 
			QUICKBOOKS_IMPORT_PAYMENTMETHOD, 
			QUICKBOOKS_IMPORT_PRICELEVEL, 
			QUICKBOOKS_IMPORT_DATEDRIVENTERMS, 
			QUICKBOOKS_IMPORT_BILLINGRATE, 
			QUICKBOOKS_IMPORT_CUSTOMERTYPE, 
			QUICKBOOKS_IMPORT_CUSTOMERMSG, 
			QUICKBOOKS_IMPORT_TERMS, 
			QUICKBOOKS_IMPORT_SALESTAXCODE, 
			QUICKBOOKS_IMPORT_ACCOUNT, 
			QUICKBOOKS_IMPORT_CLASS, 
			QUICKBOOKS_IMPORT_JOBTYPE, 
			QUICKBOOKS_IMPORT_VENDORTYPE, 
			
			QUICKBOOKS_IMPORT_COMPANY, 
		);
		// high priorities down here (no dependencies OR queries)
		
		// Now, let's space those priorities out a little bit, it gives us some 
		//	wiggle room in case we need to add things inbetween the default 
		//	priority values
		static $wiggled = false;
		$wiggle = 6;
		
		if (!$wiggled)
		{
			$count = count($priorities);
			for ($i = $count - 1; $i >= 0; $i--)
			{
				$priorities[$i * $wiggle] = $priorities[$i];
				unset($priorities[$i]);
				
				// with a wiggle multiplier of 2...
				// 	priority 25 goes to 50
				// 	priority 24 goes to 48
				// 	priority 23 goes to 46
				// 	etc. etc. etc. 
			}
			
			$wiggled = true;
			
			//print_r($priorities);
		}
		
		if ($dependency)
		{
			// 
			// This is a list of dependency modifications
			//	For instance, normally, you'd want to send just any  old DataExtAdd 
			//	with a really low priority, because whatever record it applies to 
			//	must be in QuickBooks before you send the DataExtAdd/Mod request. 
			// 
			//	However, if we pass in the $dependency of QUICKBOOKS_ADD_CUSTOMER, 
			//	then we know that this DataExt applies to a CustomerAdd, and can 
			//	therefore be sent with a priority *just barely lower than* than a 
			//	CustomerAdd request, which will ensure this gets run as soon as 
			//	possible, but not sooner than the CustomerAdd.
			// 
			//	This is important because in some cases, this data will be 
			//	automatically used by QuickBooks. For instance, a custom field that 
			//	is placed on an Invoice *must already be populated for the 
			//	Customer* before the invoice is created. 
			//
			// This is an example of a priority list without dependencies, and it's bad: 	
			//	CustomerAdd, InvoiceAdd, DataExtAdd		
			//	(the custom field for the customer doesn't get populated in the invoice)
			//
			// This is an example of a priority list with dependencies, and it's good: 
			// 	CustomerAdd, DataExtAdd, InvoiceAdd
			//	
			$dependencies = array(
				QUICKBOOKS_ADD_DATAEXT => array( 
					QUICKBOOKS_ADD_CUSTOMER => QuickBooks_Utilities::priorityForAction(QUICKBOOKS_ADD_CUSTOMER) - 1, 
					QUICKBOOKS_MOD_CUSTOMER => QuickBooks_Utilities::priorityForAction(QUICKBOOKS_MOD_CUSTOMER) - 1, 
				),
				QUICKBOOKS_MOD_DATAEXT => array(
					QUICKBOOKS_ADD_CUSTOMER => QuickBooks_Utilities::priorityForAction(QUICKBOOKS_ADD_CUSTOMER) - 1, 
					QUICKBOOKS_MOD_CUSTOMER => QuickBooks_Utilities::priorityForAction(QUICKBOOKS_MOD_CUSTOMER) - 1, 
					),
					
				// A *Bill VOID* has a slightly higher priority than a PurchaseOrderMod so that we can IsManuallyClosed POs (we'll get an error if we try to close it and a bill is dependent on it)  
				QUICKBOOKS_VOID_TRANSACTION => array(
					QUICKBOOKS_MOD_PURCHASEORDER => QuickBooks_Utilities::priorityForAction(QUICKBOOKS_MOD_PURCHASEORDER) + 1, 
					), 
				);			
		}
		
		// Check for dependency priorities
		if ($dependency and 
			isset($dependencies[$action]) and 
			isset($dependencies[$action][$dependency]))
		{			
			// Dependency modified priority
			return $dependencies[$action][$dependency];
		}
		else if ($key = array_search($action, $priorities))
		{
			// Regular priority
			return $key;
		}
		
		// Default priority
		return 999;		
	}
Try to guess the queueing priority for this action

@param string $action		The action you're trying to guess for
@param string $dependency	If the action depends on another action (i.e. a DataExtAdd for a CustomerAdd) you can pass the dependency here
@return integer				A best guess at the proper priority