Ejemplo n.º 1
0
$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);
// VENDORS
$Vendor = new QuickBooks_Object_Vendor();
$Vendor->setName('Test Vendor ' . mt_rand());
$Vendor->setPhone('1.860.634.1602');
$Vendor->setFirstName('Test');
$Vendor->setFax('1.860.429.5183');
$API->addVendor($Vendor, '_quickbooks_vendor_add_callback', 19);
// SERVICE ITEMS
$ServiceItem = new QuickBooks_Object_ServiceItem();
$ServiceItem->isSalesOrPurchase(true);
$ServiceItem->setName('My Service Item ' . mt_rand());
$ServiceItem->setPrice(250);
$ServiceItem->setDescription('My Test Item Description');
$ServiceItem->setAccountName('Sales');
$API->addServiceItem($ServiceItem, '_quickbooks_serviceitem_add_callback', 12);
$InvoiceLine1 = new QuickBooks_Object_Invoice_InvoiceLine();
$InvoiceLine1->setItemName('Item Type 1');
$InvoiceLine1->setRate(10.0);
$InvoiceLine1->setQuantity(3);
// 5 items of type "Item Type 2", for a total amount of $225.00 ($45.00 each)
$InvoiceLine2 = new QuickBooks_Object_Invoice_InvoiceLine();
$InvoiceLine2->setItemName('Item Type 2');
$InvoiceLine2->setAmount(225.0);
$InvoiceLine2->setQuantity(5);
// Make sure you add those invoice lines on to the invoice
$Invoice->addInvoiceLine($InvoiceLine1);
$Invoice->addInvoiceLine($InvoiceLine2);
// Queue up the request to be sent to QuickBooks
$priority_of_add_invoice_request = 10;
// Make sure this is lower than the customer add it depends on
if ($API->addInvoice($Invoice, '_quickbooks_ca_invoice_add_callback', $primary_key_of_invoice_in_your_application, $priority_of_add_invoice_request)) {
    print 'Queued up a request to add invoice #' . $primary_key_of_invoice_in_your_application . ' to QuickBooks!' . "\n";
}
// Adding an estimate for a customer
$primary_key_of_estimate_in_your_application = 'ABC-123';
// Adding an estimate is very similar to adding an invoice, as most of the
//	estimate data within QuickBooks closely mirrors the invoice data.
$Estimate = new QuickBooks_Object_Estimate();
// Set the customer that this estimate belongs to
$Estimate->setCustomerName($name);
// Set some other estimate data
$Estimate->setTxnDate('4/2/1999');
$Estimate->setRefNumber($primary_key_of_estimate_in_your_application);
// Billing address
$Estimate->setBillAddress('134 Stonemill Road', '', '', '', '', 'Quebec City', '', 'Quebec', 'H12 ABC', 'Canada');
// Estimate line items
Ejemplo n.º 3
0
$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);
//exit;
//print($Invoice->asQBXML());
print 'trying to add invoice...';
$API->addInvoice($Invoice, 'my_invoice_callback', 20);
exit;
/*
$API->getCustomerByName($fname . ' ' . $lname, '_quickbooks_customer_get_callback');


$API->getCustomer('1234', 'my_get_customer_callback');


$API->getCustomerByName('Keith Palmer', 'my_get_customer_byname_callback');
*/
/*
$API->searchInvoices(array(), 'my_search_invoices_callback');

$API->searchClasses(array(), 'my_search_classes_callback');