// We also provide a priority, we want to make sure that this request runs // *before* the request below, because we need to create the customer *before* // we create an invoice for them. Higher priorities run sooner. $primary_key_of_customer_in_your_application = 20; $priority_of_add_customer_request = 25; if ($API->addCustomer($Customer, '_quickbooks_ca_customer_add_callback', $primary_key_of_customer_in_your_application, $priority_of_add_customer_request)) { print 'Queued up a request to add customer #' . $primary_key_of_customer_in_your_application . ', "' . $Customer->getName() . '" to QuickBooks!' . "\n"; } // Adding an invoice to QuickBooks // // This shows an example of queueing up a request to add a new invoice to // QuickBooks. The process for adding estimates, purchase orders, and sales // receipts is *very* similar to the process for adding invoices. $primary_key_of_invoice_in_your_application = 125; // Create the new invoice object $Invoice = new QuickBooks_Object_Invoice(); // We're going to assign this invoice to the customer we created above, #20, // "Shannon Daniels". There are a few ways you can refer to that customer. You // can refer to them by their Name/FullName attribute ("Shannon's Company" in // the example shown above), by their ListID (a primary key within QuickBooks) // or, if you've created a mapping between the customer's primary key within // your application and the customer in QuickBooks, you can refer to them by // the primary key within your application, and the framework will map this // value to a ListID for you. // // For this example, we're going to refer to them by their mapped primar key, // because the callback function "_quickbooks_ca_customer_add_callback" that // we used above when adding Shannon creates this mapping for us. $Invoice->setCustomerApplicationID($primary_key_of_customer_in_your_application); // $Invoice->setCustomerName('The Company Name Here'); // $Invoice->setCustomerListID($ListID_from_QuickBooks);
QuickBooks_Utilities::createUser($api_driver_dsn, 'api', 'password'); } $API = new QuickBooks_API($api_driver_dsn, $user, $source_type, $source_dsn, $api_options, $source_options, $driver_options); // CUSTOMERS $fname = 'Shannon ' . mt_rand(); $lname = 'Daniels'; $Customer = new QuickBooks_Object_Customer(); $Customer->setFirstName($fname); $Customer->setLastName($lname); $Customer->setShipAddress('56 Cowles Road', '', '', '', '', 'Willington', 'CT'); $Customer->setMiddleName('R'); $Customer->setSalutation('Mr.'); $Customer->setPhone('1.860.634.1602'); $API->addCustomer($Customer, '_quickbooks_customer_add_callback', 15); // INVOICES $Invoice = new QuickBooks_Object_Invoice(); //$Invoice->setOther('test of other'); // for some reason this field doesn't work... $Invoice->setMemo('test of a memo'); $Invoice->setCustomerApplicationID(15); $Invoice->setRefNumber(125); $InvoiceLine1 = new QuickBooks_Object_Invoice_InvoiceLine(); $InvoiceLine1->setItemApplicationID(12); $InvoiceLine1->setAmount(300.0); $InvoiceLine1->setQuantity(3); $InvoiceLine2 = new QuickBooks_Object_Invoice_InvoiceLine(); $InvoiceLine2->setItemApplicationID(11); $InvoiceLine2->setAmount(225.0); $InvoiceLine2->setQuantity(5); $Invoice->addInvoiceLine($InvoiceLine1); $Invoice->addInvoiceLine($InvoiceLine2); $API->addInvoice($Invoice, '_quickbooks_invoice_add_callback', 20);
public function listInvoicesModifiedBetween($start_datetime, $end_datetime, $callback = null, $priority = null, $recur = null) { $obj = new QuickBooks_Object_Invoice(); if (!is_null($start_datetime)) { $obj->set('ModifiedDateRangeFilter FromModifiedDate', date('Y-m-d\\TH:i:s', strtotime($start_datetime))); } if (!is_null($end_datetime)) { $obj->set('ModifiedDateRangeFilter ToModifiedDate', date('Y-m-d\\TH:i:s', strtotime($end_datetime))); } $obj->set('IncludeLineItems', 'true'); $obj->set('IncludeLinkedTxns', 'true'); $err = ''; // $method, $action, $type, $obj, $callbacks, $webapp_ID, $priority, &$err, $recur return $this->_doQuery(__METHOD__, QUICKBOOKS_QUERY_INVOICE, QUICKBOOKS_OBJECT_INVOICE, $obj, $callback, null, $priority, $err, $recur); }
$CreditLine2->setAccountName('Sales'); $JournalEntry->addCreditLine($CreditLine2); //print_r($JournalEntry); print $JournalEntry->asQBXML(QUICKBOOKS_ADD_JOURNALENTRY); exit; $Customer = new QuickBooks_Object_Customer(); $Customer->setFirstName('Keith'); $Customer->set('LastName', 'Palmer'); $Customer->set('ShipAddress Addr1', '56 Cowles Road'); $Customer->setShipAddress('56 Cowles Road', '', '', '', '', 'Willington', 'CT'); $defaults = array('ShipAddress Addr2' => 'bla', 'ShipAddress Country' => 'United States'); //print_r($Customer->getShipAddress(null, $defaults)); //print($Customer->asXML(QUICKBOOKS_OBJECT_XML_DROP, "\t", 'CustomerAdd')); print "\n\n"; $arr = array('ModifiedDateRangeFilter' => array('FromModifiedDate' => 'test'), 'ModifiedDateRangeFilter ToModifiedDate' => 'test'); $Invoice = new QuickBooks_Object_Invoice($arr); $qbxml = $Invoice->asQBXML('InvoiceQueryRq'); print $qbxml; print "\n\n"; /* $xml = ' <XML> <Customer> <FirstName>Keith</FirstName> </Customer> </XML> '; $Parser = new QuickBooks_XML($xml); $errnum = 0; $errmsg = '';
QuickBooks_Utilities::initialize($api_driver_dsn); QuickBooks_Utilities::createUser($api_driver_dsn, 'api', 'password'); } $API = new QuickBooks_API($api_driver_dsn, $user, $source_type, $source_dsn, $api_options = array(), $source_options = array(), $driver_options = array()); $fname = 'Shannon ' . mt_rand(1, 1000); $lname = 'Daniels'; $Customer = new QuickBooks_Object_Customer(); $Customer->setParentApplicationID(15); $Customer->setFirstName($fname); $Customer->setLastName($lname); $Customer->setShipAddress('56 Cowles Road', '', '', '', '', 'Willington', 'CT'); $Customer->setMiddleName('R'); $Customer->setSalutation('Mr.'); $Customer->setPhone('1.860.634.1602'); $API->addCustomer($Customer, '_quickbooks_customer_add_callback', 15); $Invoice = new QuickBooks_Object_Invoice(); $Invoice->setOther('test of other'); $Invoice->setMemo('test of a memo'); $Invoice->setCustomerApplicationID(15); $Invoice->setRefNumber(125); $InvoiceLine1 = new QuickBooks_Object_Invoice_InvoiceLine(); $InvoiceLine1->setItemApplicationID(12); $InvoiceLine1->setAmount(300.0); $InvoiceLine1->setQuantity(3); $InvoiceLine2 = new QuickBooks_Object_Invoice_InvoiceLine(); $InvoiceLine2->setItemApplicationID(11); $InvoiceLine2->setAmount(225.0); $InvoiceLine2->setQuantity(5); $Invoice->addInvoiceLine($InvoiceLine1); $Invoice->addInvoiceLine($InvoiceLine2); //print_r($Invoice);
* * * @author Keith Palmer <*****@*****.**> * * @package QuickBooks * @subpackage Documentation */ // include path ini_set('include_path', ini_get('include_path') . PATH_SEPARATOR . '/Users/keithpalmerjr/Projects/QuickBooks'); // error reporting ini_set('display_errors', 1); error_reporting(E_ALL | E_STRICT); // QuickBooks framework classes require_once 'QuickBooks.php'; // Create the new invoice object $Invoice = new QuickBooks_Object_Invoice(); // We need to assign this invoice to a customer. There are a few ways you can // refer to this customer in your qbXML requests. You can refer to them by // their Name/FullName, by their ListID (a primary key within QuickBooks) or, // if you've created a mapping between the customer's primary key within your // application and the customer in QuickBooks *and* you are using the // QuickBooks_API classes, you can refer to them by the primary key within // your application, and the framework will map this value to a ListID for // you. (For an example of this last case you should see // example_api_client.php and example_api_client_canadian.php) // $Invoice->setCustomerName('The Company Name Here'); // $Invoice->setCustomerListID($ListID_from_QuickBooks); // Invoice #A-123 $Invoice->setRefNumber('A-123'); // Set some other fields...