$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); // VENDORS $Vendor = new QuickBooks_Object_Vendor(); $Vendor->setName('Test Vendor ' . mt_rand()); $Vendor->setPhone('1.860.634.1602');
// "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); // Invoice #125 $Invoice->setRefNumber($primary_key_of_invoice_in_your_application); // Set some other fields... $Invoice->setMemo('This invoice was created using the QuickBooks PHP API!'); // Now, we need to build each invoice line for the invoice. Each invoice line // will contain at least a reference to an item, and probably a quantity or // the item ordered, and either a total amount or a rate (price per item). // // As with customers above, the items need to be present in QuickBooks before // we can add an invoice that depends on them. You can again refer to the item // in three different ways: // - Name/FullName // - ListID // - a mapped primary key from your application // // For this example, we're going to refer to the items by name, so the items // must already be present in QuickBooks for this invoice to be added.
// 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... $Invoice->setMemo('This invoice was created using the QuickBooks PHP API!'); // Now, we need to build each invoice line for the invoice. Each invoice line // will contain at least a reference to an item, and probably a quantity or // the item ordered, and either a total amount or a rate (price per item). // // As with customers above, the items need to be present in QuickBooks before // we can add an invoice that depends on them. You can again refer to the item // in three different ways: // - Name/FullName // - ListID // - a mapped primary key from your application // // For this example, we're going to refer to the items by name, so the items // must already be present in QuickBooks for this invoice to be added.