├── .DS_Store ├── .gitignore ├── README.md ├── composer.json ├── composer.lock └── src ├── Contracts └── QBResourceContract.php ├── Facades ├── Account.php ├── Bill.php ├── BillPayment.php ├── Connection.php ├── CreditMemo.php ├── Customer.php ├── Estimate.php ├── Invoice.php ├── Item.php ├── JournalEntry.php ├── Payment.php ├── PaymentMethod.php ├── Purchase.php ├── PurchaseOrder.php ├── QB_Class.php ├── RefundReceipt.php ├── SalesReceipt.php ├── TaxCode.php ├── TaxRate.php ├── Term.php ├── TimeActivity.php └── VendorCredit.php ├── QuickBooksServiceProvider.php ├── Quickbooks.php ├── Services ├── Accounting │ ├── Account.php │ ├── Bill.php │ ├── BillPayment.php │ ├── CreditMemo.php │ ├── Customer.php │ ├── Department.php │ ├── Employee.php │ ├── Estimate.php │ ├── Invoice.php │ ├── Item.php │ ├── JournalEntry.php │ ├── Payment.php │ ├── PaymentMethod.php │ ├── Purchase.php │ ├── PurchaseOrder.php │ ├── QB_Class.php │ ├── RefundReceipt.php │ ├── SalesReceipt.php │ ├── TaxCode.php │ ├── TaxRate.php │ ├── Term.php │ ├── TimeActivity.php │ ├── Vendor.php │ └── VendorCredit.php └── Connection.php └── config └── QuickBooks.php /.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/myleshyson/laravel-quickbooks/7edc4bf2849b67a8b10481a311c6d0fcee4f929a/.DS_Store -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | vendor -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # No Longer Maintained 2 | For two reasons. I don't have the time anymore to work on this (it was only a hobby project) and a few months ago QuicBooks actually came out with it's own PHP SDK [you can see it here](https://github.com/intuit/QuickBooks-V3-PHP-SDK). Though this package should work fine still (as of 09/15/2017) QuickBooks is going to have a much more consistent and higher quality package to work with their own system. It's also documented way better than this or Consolibyte. For those that have used it I hope it's been helpful! If you would like to take over this repo and convert it to use the QuickBooks SDK or something just let me know. 3 | 4 | # laravel-quickbooks 5 | ## A nice wrapper around the Quickbooks Online SDK. 6 | 7 | ### Installation 8 | If you haven't already composer the quickbooks php sdk. If you're using php 7+ then you'll need to require the dev-master version. 9 | ``` 10 | composer require consolibyte/quickbooks 11 | ``` 12 | Then require this package via composer 13 | ``` 14 | composer require myleshyson/laravel-quickbooks 15 | ``` 16 | Add this line to you config/app.php. 17 | 18 | ```php 19 | Myleshyson\LaravelQuickBooks\QuickBooksServiceProvider::class, 20 | ``` 21 | 22 | Finally on the command line publish the config file for the package like so. 23 | 24 | ``` 25 | php artisan vendor:publish --tag=quickbooks 26 | ``` 27 | 28 | These are the variables you need to set in your .env. 29 | 30 | ``` 31 | 32 | 33 | QB_DSN= e.g for mysql...mysqli://db-username:db-password@db-connection/db-name 34 | QB_TOKEN= 35 | QB_OAUTH_CONSUMER_KEY= 36 | QB_OAUTH_CONSUMER_SECRET= 37 | 38 | Make sure tese two url's are different. 39 | QB_OAUTH_URL= url used to connect to quickbooks. 40 | QB_SUCCESS_URL= you are redirected to here when the handshake is successful. 41 | 42 | QB_SANDBOX=true 43 | 44 | These two you shouldn't change unless you know what you're doing. 45 | QB_USERNAME=DO_NOT_CHANGE_ME 46 | QB_TENANT=12345 47 | ``` 48 | After that you should be set to go! 49 | 50 | ### Usage 51 | This package was made for working with the QuickBooks Accounting API in mind. You can look at all of the accounting resources here under 'Transaction' and 'Name list' resources. [QuickBooks Accounting API](https://developer.intuit.com/docs/api/accounting) 52 | 53 | #### Note On Working With QuickBooks 54 | Just because in the QuickBooks documentation something says optional doesn't mean that you don't need it for your request. If your request doesn't go through make sure to dd() to see what error QuickBooks is giving back. It may be asking you to set something that is optional. 55 | 56 | There are a few resources that aren't supported by the QuickBooks SDK and those are listed here: 57 | 58 | * CompanyCurrency 59 | * Budget 60 | * JournalCode 61 | * TaxAgency 62 | * TaxService 63 | * Deposit 64 | * Transfer 65 | 66 | 67 | **Quick Note: Make sure when using this package you import the Facade class you want to use under Myleshyson\LaravelQuickBooks\Facades** 68 | 69 | #### Connecting To QuickBooks 70 | Make sure the success url is differnt than the oauth (connection) url. Otherwise it will continually redirect you after a succsful 71 | 72 | ```php 73 | // routes/web.php 74 | use Myleshyson\LaravelQuickBooks\Facades\Connection; 75 | 76 | Route::get('/connect', function () { 77 | Connection::start(); 78 | }); 79 | ``` 80 | 81 | If you want to disconnect from quickbooks then you can do it like so. 82 | ```php 83 | // routes/web.php 84 | use Myleshyson\LaravelQuickBooks\Facades\Connection; 85 | 86 | Route::get('/disconnect', function () { 87 | Connection::stop(); 88 | }); 89 | ``` 90 | If you want to check if your connected 91 | ```php 92 | // routes/web.php 93 | use Myleshyson\LaravelQuickBooks\Facades\Connection; 94 | 95 | Route::get('/check-connection', function () { 96 | dd(Connection::check()); 97 | //true 98 | }); 99 | ``` 100 | 101 | #### Making Requests 102 | 103 | Every resource that's available has four methods except for TaxRate and TaxCode. Those only have a get, find, and query method. 104 | 105 | ```php 106 | Customer::create(array $data); 107 | 108 | Customer::update($id, array $data); 109 | 110 | Customer::delete($id); 111 | 112 | Customer::find($id); 113 | 114 | Customer::get(); //gets all customers associated with your account. 115 | 116 | Customer::query('SELECT * FROM CUSTOMER WHERE ...') //put in your own custom query for the Customer table. 117 | ``` 118 | 119 | I used the same naming conventions as the QuickBooks API to make things easier. In order to create a resource like Customer for example, you would use it like this... 120 | 121 | ```php 122 | // routes/web.php 123 | 124 | use Myleshyson\LaravelQuickBooks\Facades\Customer; 125 | 126 | Route::get('/', function () { 127 | Customer::create([ 128 | 'Taxable' => false, 129 | 'BillAddr' => [ 130 | 'Line1' => '123 Test Street', 131 | 'City' => 'Dallas', 132 | 'State' => 'Texas', 133 | 'CountrySubDivisionCode' => 'TX', 134 | 'PostalCode' => '12345' 135 | ], 136 | 'GivenName' => 'Bill', 137 | 'FamilyName' => 'Something', 138 | 'FullyQualifiedName' => "Bill's Surf Shop" 139 | ]); 140 | }); 141 | ``` 142 | 143 | To handle any type of line in QuickBooks handle it like so. 144 | 145 | Here are the different line types in quickbooks: 146 | 147 | * SalesItemLineDetail 148 | * ItemBasedExpenseLineDetail 149 | * AccountBasedExpenseLineDetail 150 | * GroupLineDetail 151 | * DescriptionOnly 152 | * DiscountLineDetail 153 | * SubtotalLine 154 | * TaxLineDetail 155 | 156 | ```php 157 | use Myleshyson\LaravelQuickBooks\Facades\Invoice; 158 | 159 | Invoice::create([ 160 | 'CustomerRef' => 1, 161 | 'Lines' => [ 162 | [ 163 | 'DetailType' => 'SalesItemLineDetail', 164 | 'ItemRef' => 1, 165 | 'Amount' => 20, 166 | 'MarkupInfo' => [ 167 | 'PercentBased' => true 168 | ] 169 | ], 170 | [ 171 | 'DetailType' => 'TxnTaxDetail', 172 | 'TxnTaxCodeRef' => 8, 173 | 'Lines' => [ 174 | [ 175 | 'SomeStuff' 176 | ], 177 | [ 178 | 'MoreStuff' 179 | ] 180 | ] 181 | ] 182 | ] 183 | ]); 184 | ``` 185 | -------------------------------------------------------------------------------- /composer.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "myleshyson/laravel-quickbooks", 3 | "description": "A nice wrapper around the consolibyte/quickbooks-php package.", 4 | "license": "MIT", 5 | "minimum-stability": "dev", 6 | "authors": [{ 7 | "name": "Myles Hyson", 8 | "email": "me@myleshyson.com" 9 | }], 10 | "require": { 11 | "consolibyte/quickbooks": "dev-master" 12 | }, 13 | "repositories": [{ 14 | "type": "vcs", 15 | "url": "https://github.com/myleshyson/laravel-quickbooks.git" 16 | }], 17 | "autoload": { 18 | "psr-4": { 19 | "Myleshyson\\LaravelQuickBooks\\": "src/" 20 | } 21 | } 22 | } -------------------------------------------------------------------------------- /composer.lock: -------------------------------------------------------------------------------- 1 | { 2 | "_readme": [ 3 | "This file locks the dependencies of your project to a known state", 4 | "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file", 5 | "This file is @generated automatically" 6 | ], 7 | "hash": "9560472a5850aff08bbeb3ef2171e8ea", 8 | "content-hash": "829db169aa6fd3f795f8347eeecd02e4", 9 | "packages": [ 10 | { 11 | "name": "consolibyte/quickbooks", 12 | "version": "dev-master", 13 | "source": { 14 | "type": "git", 15 | "url": "https://github.com/consolibyte/quickbooks-php.git", 16 | "reference": "06041bdae92480aa202ea3d4350f12778db19281" 17 | }, 18 | "dist": { 19 | "type": "zip", 20 | "url": "https://api.github.com/repos/consolibyte/quickbooks-php/zipball/06041bdae92480aa202ea3d4350f12778db19281", 21 | "reference": "06041bdae92480aa202ea3d4350f12778db19281", 22 | "shasum": "" 23 | }, 24 | "require": { 25 | "php": ">=5.0.0" 26 | }, 27 | "type": "library", 28 | "autoload": { 29 | "files": [ 30 | "QuickBooks.php" 31 | ] 32 | }, 33 | "notification-url": "https://packagist.org/downloads/", 34 | "license": [ 35 | "EPL-1.0" 36 | ], 37 | "authors": [ 38 | { 39 | "name": "Keith Palmer", 40 | "email": "support@consolibyte.com", 41 | "homepage": "http://www.consolibyte.com/", 42 | "role": "Developer" 43 | } 44 | ], 45 | "description": "QuickBooks DevKit with support for Intuit Anywhere, Intuit Partner Platform, Web Connector, QuickBooks Merchant Services, and more.", 46 | "homepage": "http://www.consolibyte.com/", 47 | "keywords": [ 48 | "intuit", 49 | "intuit anywhere", 50 | "intuit data services", 51 | "intuit merchant services", 52 | "intuit partner platform", 53 | "qbxml", 54 | "quickbooks", 55 | "quickbooks merchant services", 56 | "quickbooks web connector", 57 | "web connector" 58 | ], 59 | "time": "2016-12-14 18:33:20" 60 | } 61 | ], 62 | "packages-dev": [], 63 | "aliases": [], 64 | "minimum-stability": "dev", 65 | "stability-flags": { 66 | "consolibyte/quickbooks": 20 67 | }, 68 | "prefer-stable": false, 69 | "prefer-lowest": false, 70 | "platform": [], 71 | "platform-dev": [] 72 | } 73 | -------------------------------------------------------------------------------- /src/Contracts/QBResourceContract.php: -------------------------------------------------------------------------------- 1 | publishes([__DIR__.'/config/QuickBooks.php' => config_path('quickbooks.php')], 'quickbooks'); 12 | } 13 | 14 | public function register() 15 | { 16 | $this->app->bind('account', 'Myleshyson\LaravelQuickBooks\Services\Accounting\Account'); 17 | $this->app->bind('bill', 'Myleshyson\LaravelQuickBooks\Services\Accounting\Bill'); 18 | $this->app->bind('billpayment', 'Myleshyson\LaravelQuickBooks\Services\Accounting\BillPayment'); 19 | $this->app->bind('class', 'Myleshyson\LaravelQuickBooks\Services\Accounting\QB_Class'); 20 | $this->app->bind('connection', 'Myleshyson\LaravelQuickBooks\Services\Connection'); 21 | $this->app->bind('creditmemo', 'Myleshyson\LaravelQuickBooks\Services\Accounting\CreditMemo'); 22 | $this->app->bind('customer', 'Myleshyson\LaravelQuickBooks\Services\Accounting\Customer'); 23 | $this->app->bind('department', 'Myleshyson\LaravelQuickBooks\Services\Accounting\Department'); 24 | $this->app->bind('employee', 'Myleshyson\LaravelQuickBooks\Services\Accounting\Employee'); 25 | $this->app->bind('estimate', 'Myleshyson\LaravelQuickBooks\Services\Accounting\Estimate'); 26 | $this->app->bind('invoice', 'Myleshyson\LaravelQuickBooks\Services\Accounting\Invoice'); 27 | $this->app->bind('item', 'Myleshyson\LaravelQuickBooks\Services\Accounting\Item'); 28 | $this->app->bind('journal_entry', 'Myleshyson\LaravelQuickBooks\Services\Accounting\JournalEntry'); 29 | $this->app->bind('payment', 'Myleshyson\LaravelQuickBooks\Services\Accounting\Payment'); 30 | $this->app->bind('payment_method', 'Myleshyson\LaravelQuickBooks\Services\Accounting\PaymentMethod'); 31 | $this->app->bind('purchase', 'Myleshyson\LaravelQuickBooks\Services\Accounting\Purchase'); 32 | $this->app->bind('purchase_order', 'Myleshyson\LaravelQuickBooks\Services\Accounting\PurchaseOrder'); 33 | $this->app->bind('refund_receipt', 'Myleshyson\LaravelQuickBooks\Services\Accounting\RefundReceipt'); 34 | $this->app->bind('sales_receipt', 'Myleshyson\LaravelQuickBooks\Services\Accounting\SalesReceipt'); 35 | $this->app->bind('tax_code', 'Myleshyson\LaravelQuickBooks\Services\Accounting\TaxCode'); 36 | $this->app->bind('tax_rate', 'Myleshyson\LaravelQuickBooks\Services\Accounting\TaxRate'); 37 | $this->app->bind('term', 'Myleshyson\LaravelQuickBooks\Services\Accounting\Term'); 38 | $this->app->bind('time_activity', 'Myleshyson\LaravelQuickBooks\Services\Accounting\TimeActivity'); 39 | $this->app->bind('vendor', 'Myleshyson\LaravelQuickBooks\Services\Accounting\Vendor'); 40 | $this->app->bind('vendor_credit', 'Myleshyson\LaravelQuickBooks\Services\Accounting\VendorCredit'); 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /src/Quickbooks.php: -------------------------------------------------------------------------------- 1 | config = config('quickbooks'); 44 | 45 | if (!\QuickBooks_Utilities::initialized($this->config['dsn'])) { 46 | \QuickBooks_Utilities::initialize($this->config['dsn']); 47 | } 48 | 49 | $this->IntuitAnywhere = new \QuickBooks_IPP_IntuitAnywhere($this->config['dsn'], $this->config['encryption_key'], $this->config['oauth_consumer_key'], $this->config['oauth_consumer_secret'], $this->config['quickbooks_oauth_url'], $this->config['quickbooks_success_url']); 50 | 51 | // Set up the IPP instance 52 | $IPP = new \QuickBooks_IPP($this->config['dsn']); 53 | if ($this->IntuitAnywhere->check($this->config['the_username'], $this->config['the_tenant']) and 54 | $this->IntuitAnywhere->test($this->config['the_username'], $this->config['the_tenant'])) { 55 | // Get our OAuth credentials from the database 56 | $creds = $this->IntuitAnywhere->load($this->config['the_username'], $this->config['the_tenant']); 57 | 58 | // Tell the framework to load some data from the OAuth store 59 | $IPP->authMode( 60 | \QuickBooks_IPP::AUTHMODE_OAUTH, 61 | $this->config['the_username'], 62 | $creds); 63 | 64 | if ($this->config['sandbox']) { 65 | // Turn on sandbox mode/URLs 66 | $IPP->sandbox(true); 67 | } 68 | 69 | // This is our current realm 70 | $this->realm = $creds['qb_realm']; 71 | 72 | // Load the OAuth information from the database 73 | $this->context = $IPP->context(); 74 | } 75 | } 76 | 77 | /** 78 | * Handles Data from Accounting NameList Resources 79 | * @param [array] $data [array of data passed from resource method.] 80 | * @param [object] $obj [The current resource handling the data.] 81 | */ 82 | protected function handleNameListData($data, $obj) 83 | { 84 | isset($data['AbatementRate']) ? $obj->setAbatementRate($data['AbatementRate']) : ''; 85 | isset($data['AccountAlias']) ? $obj->setAccountAlias($data['AccountAlias']) : ''; 86 | isset($data['AccountSubType']) ? $obj->setAccountSubType($data['AccountSubType']) : ''; 87 | isset($data['AccountType']) ? $obj->setAccountType($data['AccountType']) : ''; 88 | isset($data['AcctNum']) ? $obj->setAcctNum($data['AcctNum']) : ''; 89 | isset($data['Active']) ? $obj->setActive($data['Active']) : ''; 90 | isset($data['AgencyRef']) ? $obj->setAgencyRef($data['AgencyRef']) : ''; 91 | isset($data['APAccountRef']) ? $obj->setAPAccountRef($data['APAccountRef']) : ''; 92 | isset($data['ARAccountRef']) ? $obj->setARAccountRef($data['ARAccountRef']) : ''; 93 | isset($data['AssetAccountRef']) ? $obj->setAssetAccountRef($data['AssetAccountRef']) : ''; 94 | isset($data['Balance']) ? $obj->setBalance($data['Balance']) : ''; 95 | isset($data['BalanceWithJobs']) ? $obj->setBalanceWithJobs($data['BalanceWithJobs']) : ''; 96 | isset($data['BillableTime']) ? $obj->setBillableTime($data['BillableTime']) : ''; 97 | isset($data['BillRate']) ? $obj->setBillRate($data['BillRate']) : ''; 98 | isset($data['BillWithParent']) ? $obj->setBillWithParent($data['BillWithParent']) : ''; 99 | isset($data['BirthDate']) ? $obj->setBirthDate($data['BirthDate']) : ''; 100 | isset($data['Classification']) ? $obj->setClassification($data['Classification']) : ''; 101 | isset($data['CompanyName']) ? $obj->setCompanyName($data['CompanyName']) : ''; 102 | isset($data['CurrencyRef']) ? $obj->setCurrencyRef($data['CurrencyRef']) : ''; 103 | isset($data['CurrentBalance']) ? $obj->setCurrentBalance($data['CurrentBalance']) : ''; 104 | isset($data['CurrentBalanceWithSubAccounts']) ? $obj->setCurrentBalanceWithSubAccounts($data['CurrentBalanceWithSubAccounts']) : ''; 105 | isset($data['DaysOfMonthDue']) ? $obj->setDaysOfMonthDue($data['DaysOfMonthDue']) : ''; 106 | isset($data['DefaultTaxCodeRef']) ? $obj->setDefaultTaxCodeRef($data['DefaultTaxCodeRef']) : ''; 107 | isset($data['Description']) ? $obj->setDescription($data['Description']) : ''; 108 | isset($data['DiscountDayOfMonth']) ? $obj->setDiscountDayOfMonth($data['DiscountDayOfMonth']) : ''; 109 | isset($data['DiscountDays']) ? $obj->setDiscountDays($data['DiscountDays']) : ''; 110 | isset($data['DiscountPercent']) ? $obj->setDiscountPercent($data['DiscountPercent']) : ''; 111 | isset($data['DisplayName']) ? $obj->setDisplayName($data['DisplayName']) : ''; 112 | isset($data['DisplayType']) ? $obj->setDisplayType($data['DisplayType']) : ''; 113 | isset($data['DueDays']) ? $obj->setDueDays($data['DueDays']) : ''; 114 | isset($data['DueNextMonthDays']) ? $obj->setDueNextMonthDays($data['DueNextMonthDays']) : ''; 115 | isset($data['EffectiveTaxRate']) ? $obj->setEffectiveTaxRate($data['EffectiveTaxRate']) : ''; 116 | isset($data['EmployeeNumber']) ? $obj->setEmployeeNumber($data['EmployeeNumber']) : ''; 117 | isset($data['ExpenseAccountRef']) ? $obj->setExpenseAccountRef($data['ExpenseAccountRef']) : ''; 118 | isset($data['FamilyName']) ? $obj->setFamilyName($data['FamilyName']) : ''; 119 | isset($data['FullyQualifiedName']) ? $obj->setFullyQualifiedName($data['FullyQualifiedName']) : ''; 120 | isset($data['Gender']) ? $obj->setGender($data['Gender']) : ''; 121 | isset($data['GivenName']) ? $obj->setGivenName($data['GivenName']) : ''; 122 | isset($data['HiredDate']) ? $obj->setHiredDate($data['HiredDate']) : ''; 123 | isset($data['IncomeAccountRef']) ? $obj->setIncomeAccountRef($data['IncomeAccountRef']) : ''; 124 | isset($data['InvStartDate']) ? $obj->setInvStartDate($data['InvStartDate']) : ''; 125 | isset($data['ItemCategoryType']) ? $obj->setItemCategoryType($data['ItemCategoryType']) : ''; 126 | isset($data['Job']) ? $obj->setJob($data['Job']) : ''; 127 | isset($data['Level']) ? $obj->setLevel($data['Level']) : ''; 128 | isset($data['MiddleName']) ? $obj->setMiddleName($data['MiddleName']) : ''; 129 | isset($data['Name']) ? $obj->setName($data['Name']) : ''; 130 | isset($data['Notes']) ? $obj->setNotes($data['Notes']) : ''; 131 | isset($data['OpenBalanceDate']) ? $obj->setOpenBalanceDate($data['OpenBalanceDate']) : ''; 132 | isset($data['Organization']) ? $obj->setOrganization($data['Organization']) : ''; 133 | isset($data['ParentRef']) ? $obj->setParentRef($data['ParentRef']) : ''; 134 | isset($data['PaymentMethodRef']) ? $obj->setPaymentMethodRef($data['PaymentMethodRef']) : ''; 135 | isset($data['PreferredDeliveryMethod']) ? $obj->setPreferredDeliveryMethod($data['PreferredDeliveryMethod']) : ''; 136 | isset($data['PrintOnCheckName']) ? $obj->setPrintOnCheckName($data['PrintOnCheckName']) : ''; 137 | isset($data['PurchaseCost']) ? $obj->setPurchaseCost($data['PurchaseCost']) : ''; 138 | isset($data['PurchaseDesc']) ? $obj->setPurchaseDesc($data['PurchaseDesc']) : ''; 139 | isset($data['PurchaseTaxCodeRef']) ? $obj->setPurchaseTaxCodeRef($data['PurchaseTaxCodeRef']) : ''; 140 | isset($data['PurchaseTaxIncluded']) ? $obj->setPurchaseTaxIncluded($data['PurchaseTaxIncluded']) : ''; 141 | isset($data['QtyOnHand']) ? $obj->setQtyOnHand($data['QtyOnHand']) : ''; 142 | isset($data['RateValue']) ? $obj->setRateValue($data['RateValue']) : ''; 143 | isset($data['ReleasedDate']) ? $obj->setReleasedDate($data['ReleasedDate']) : ''; 144 | isset($data['ResaleNum']) ? $obj->setResaleNum($data['ResaleNum']) : ''; 145 | isset($data['ReverseChargeRate']) ? $obj->setReverseChargeRate($data['ReverseChargeRate']) : ''; 146 | isset($data['SalesTaxCodeRef']) ? $obj->setSalesTaxCodeRef($data['SalesTaxCodeRef']) : ''; 147 | isset($data['SalesTaxIncluded']) ? $obj->setSalesTaxIncluded($data['SalesTaxIncluded']) : ''; 148 | isset($data['SalesTermRef']) ? $obj->setSalesTermRef($data['SalesTermRef']) : ''; 149 | isset($data['ServiceType']) ? $obj->setServiceType($data['ServiceType']) : ''; 150 | isset($data['SKU']) ? $obj->setSKU($data['SKU']) : ''; 151 | isset($data['SpecialTaxType']) ? $obj->setSpecialTaxType($data['SpecialTaxType']) : ''; 152 | isset($data['SSN']) ? $obj->setSSN($data['SSN']) : ''; 153 | isset($data['SubAccount']) ? $obj->setSubAccount($data['SubAccount']) : ''; 154 | isset($data['SubClass']) ? $obj->setSubClass($data['SubClass']) : ''; 155 | isset($data['SubDepartment']) ? $obj->setSubDepartment($data['SubDepartment']) : ''; 156 | isset($data['SubItem']) ? $obj->setSubItem($data['SubItem']) : ''; 157 | isset($data['Suffix']) ? $obj->setSuffix($data['Suffix']) : ''; 158 | isset($data['Taxable']) ? $obj->setTaxable($data['Taxable']) : ''; 159 | isset($data['TaxCodeRef']) ? $obj->setTaxCodeRef($data['TaxCodeRef']) : ''; 160 | isset($data['TaxGroup']) ? $obj->setTaxGroup($data['TaxGroup']) : ''; 161 | isset($data['TaxIdentifier']) ? $obj->setTaxIdentifier($data['TaxIdentifier']) : ''; 162 | isset($data['TaxReportingBasis']) ? $obj->setTaxReportingBasis($data['TaxReportingBasis']) : ''; 163 | isset($data['TaxReturnLineRef']) ? $obj->setTaxReturnLineRef($data['TaxReturnLineRef']) : ''; 164 | isset($data['TermRef']) ? $obj->setTermRef($data['TermRef']) : ''; 165 | isset($data['Title']) ? $obj->setTitle($data['Title']) : ''; 166 | isset($data['TrackQtyOnHand']) ? $obj->setTrackQtyOnHand($data['TrackQtyOnHand']) : ''; 167 | isset($data['TxnLocationType']) ? $obj->setTxnLocationType($data['TxnLocationType']) : ''; 168 | isset($data['Type']) ? $obj->setType($data['Type']) : ''; 169 | isset($data['UnitPrice']) ? $obj->setUnitPrice($data['UnitPrice']) : ''; 170 | isset($data['Vendor1099']) ? $obj->setVendor1099($data['Vendor1099']) : ''; 171 | 172 | 173 | 174 | if (isset($data['OtherContactInfo'])) { 175 | $OtherContactInfo = new \QuickBooks_IPP_Object_OtherContactInfo(); 176 | isset($data['OtherContactInfo']['Type']) ? $OtherContactInfo->setType($data['OtherContactInfo']['Type']) : ''; 177 | isset($data['OtherContactInfo']['Telephone']) ? $OtherContactInfo->setTelephone($data['OtherContactInfo']['Telephone']) : ''; 178 | $obj->setOtherContactInfo($OtherContactInfo); 179 | } 180 | if (isset($data['SalesTaxRateList'])) { 181 | $SalesTaxRateList = new \QuickBooks_IPP_Object_SalesTaxRateList(); 182 | foreach ($data['SalesTaxRateList'] as $key => $value) { 183 | $TaxRateDetail = new \QuickBooks_IPP_Object_TaxRateDetail(); 184 | isset($value['TaxRateRef']) ? $TaxRateDetail->setTaxRateRef($value['TaxRateRef']) : ''; 185 | isset($value['TaxTypeApplicable']) ? $TaxRateDetail->setTaxTypeApplicable($value['TaxTypeApplicable']) : ''; 186 | isset($value['TaxOrder']) ? $TaxRateDetail->setTaxOrder($value['TaxOrder']) : ''; 187 | $SalesTaxRateList->addTaxRateDetail($TaxRateDetail); 188 | } 189 | $obj->setSalesTaxRateList($SalesTaxRateList); 190 | } 191 | 192 | if (isset($data['PurchaseTaxRateList'])) { 193 | $PurchaseTaxRateList = new \QuickBooks_IPP_Object_PurchaseTaxRateList(); 194 | foreach ($data['PurchaseTaxRateList'] as $key => $value) { 195 | $TaxRateDetail = new \QuickBooks_IPP_Object_TaxRateDetail(); 196 | isset($value['TaxRateRef']) ? $TaxRateDetail->setTaxRateRef($value['TaxRateRef']) : ''; 197 | isset($value['TaxTypeApplicable']) ? $TaxRateDetail->setTaxTypeApplicable($value['TaxTypeApplicable']) : ''; 198 | isset($value['TaxOrder']) ? $TaxRateDetail->setTaxOrder($value['TaxOrder']) : ''; 199 | $PurchaseTaxRateList->addTaxRateDetail($TaxRateDetail); 200 | } 201 | $obj->setPurchaseTaxRateList($PurchaseTaxRateList); 202 | } 203 | if (isset($data['PrimaryPhone'])) { 204 | $PrimaryPhone = new \QuickBooks_IPP_Object_PrimaryPhone(); 205 | $PrimaryPhone->setFreeFormNumber($data['PrimaryPhone']); 206 | $obj->setPrimaryPhone($PrimaryPhone); 207 | } 208 | 209 | if (isset($data['AlternatePhone'])) { 210 | $AlternatePhone = new \QuickBooks_IPP_Object_AlternatePhone(); 211 | $AlternatePhone->setFreeFormNumber($data['AlternatePhone']); 212 | $obj->setAlternatePhone($AlternatePhone); 213 | } 214 | 215 | if (isset($data['Fax'])) { 216 | $Fax = new \QuickBooks_IPP_Object_Fax(); 217 | $Fax->setFreeFormNumber($data['Fax']); 218 | $obj->setFax($Fax); 219 | } 220 | 221 | if (isset($data['Mobile'])) { 222 | $Mobile = new \QuickBooks_IPP_Object_Mobile(); 223 | $Mobile->setFreeFormNumber($data['Mobile']); 224 | $obj->setMobile($Mobile); 225 | } 226 | 227 | if (isset($data['PrimaryEmailAddr'])) { 228 | $PrimaryEmailAddr = new \QuickBooks_IPP_Object_PrimaryEmailAddr(); 229 | $PrimaryEmailAddr->setAddress($data['PrimaryEmailAddr']); 230 | $obj->setPrimaryEmailAddr($PrimaryEmailAddr); 231 | } 232 | 233 | if (isset($data['WebAddr'])) { 234 | $WebAddr = new \QuickBooks_IPP_Object_WebAddr(); 235 | $WebAddr->setURI($data['WebAddr']); 236 | $obj->setWebAddr($WebAddr); 237 | } 238 | 239 | if (isset($data['BillAddr'])) { 240 | $BillAddr = new \QuickBooks_IPP_Object_BillAddr(); 241 | $addrData = $data['BillAddr']; 242 | 243 | isset($addrData['Line1']) ? $BillAddr->setLine1($addrData['Line1']) : ''; 244 | isset($addrData['Line2']) ? $BillAddr->setLine2($addrData['Line2']) : ''; 245 | isset($addrData['Line3']) ? $BillAddr->setLine3($addrData['Line3']) : ''; 246 | isset($addrData['Line4']) ? $BillAddr->setLine4($addrData['Line4']) : ''; 247 | isset($addrData['Line5']) ? $BillAddr->setLine5($addrData['Line5']) : ''; 248 | isset($addrData['City']) ? $BillAddr->setCity($addrData['City']) : ''; 249 | isset($addrData['Country']) ? $BillAddr->setCountry($addrData['Country']) : ''; 250 | isset($addrData['CountrySubDivisionCode']) ? $BillAddr->setCountrySubDivisionCode($addrData['CountrySubDivisionCode']) : ''; 251 | isset($addrData['PostalCode']) ? $BillAddr->setPostalCode($addrData['PostalCode']) : ''; 252 | isset($addrData['Lat']) ? $BillAddr->setLat($addrData['Lat']) : ''; 253 | isset($addrData['Long']) ? $BillAddr->setLong($addrData['Long']) : ''; 254 | 255 | $obj->setBillAddr($BillAddr); 256 | } 257 | 258 | if (isset($data['PrimaryAddr'])) { 259 | $PrimaryAddr = new \QuickBooks_IPP_Object_PrimaryAddr(); 260 | $addrData = $data['PrimaryAddr']; 261 | 262 | isset($addrData['Line1']) ? $PrimaryAddr->setLine1($addrData['Line1']) : ''; 263 | isset($addrData['Line2']) ? $PrimaryAddr->setLine2($addrData['Line2']) : ''; 264 | isset($addrData['Line3']) ? $PrimaryAddr->setLine3($addrData['Line3']) : ''; 265 | isset($addrData['Line4']) ? $PrimaryAddr->setLine4($addrData['Line4']) : ''; 266 | isset($addrData['Line5']) ? $PrimaryAddr->setLine5($addrData['Line5']) : ''; 267 | isset($addrData['City']) ? $PrimaryAddr->setCity($addrData['City']) : ''; 268 | isset($addrData['Country']) ? $PrimaryAddr->setCountry($addrData['Country']) : ''; 269 | isset($addrData['CountrySubDivisionCode']) ? $PrimaryAddr->setCountrySubDivisionCode($addrData['CountrySubDivisionCode']) : ''; 270 | isset($addrData['PostalCode']) ? $PrimaryAddr->setPostalCode($addrData['PostalCode']) : ''; 271 | isset($addrData['Lat']) ? $PrimaryAddr->setLat($addrData['Lat']) : ''; 272 | isset($addrData['Long']) ? $PrimaryAddr->setLong($addrData['Long']) : ''; 273 | 274 | $obj->setPrimaryAddr($PrimaryAddr); 275 | } 276 | 277 | if (isset($data['ShipAddr'])) { 278 | $ShipAddr = new \QuickBooks_IPP_Object_ShipAddr(); 279 | $addrData = $data['ShipAddr']; 280 | isset($addrData['Line1']) ? $ShipAddr->setLine1($addrData['Line1']) : ''; 281 | isset($addrData['Line2']) ? $ShipAddr->setLine2($addrData['Line2']) : ''; 282 | isset($addrData['Line3']) ? $ShipAddr->setLine3($addrData['Line3']) : ''; 283 | isset($addrData['Line4']) ? $ShipAddr->setLine4($addrData['Line4']) : ''; 284 | isset($addrData['Line5']) ? $ShipAddr->setLine5($addrData['Line5']) : ''; 285 | isset($addrData['City']) ? $ShipAddr->setCity($addrData['City']) : ''; 286 | isset($addrData['Country']) ? $ShipAddr->setCountry($addrData['Country']) : ''; 287 | isset($addrData['CountrySubDivisionCode']) ? $ShipAddr->setCountrySubDivisionCode($addrData['CountrySubDivisionCode']) : ''; 288 | isset($addrData['PostalCode']) ? $ShipAddr->setPostalCode($addrData['PostalCode']) : ''; 289 | isset($addrData['Lat']) ? $ShipAddr->setLat($addrData['Lat']) : ''; 290 | isset($addrData['Long']) ? $ShipAddr->setLong($addrData['Long']) : ''; 291 | $obj->setShipAddr($ShipAddr); 292 | } 293 | 294 | return $obj; 295 | } 296 | 297 | 298 | /** 299 | * Handles Data from Accounting Transaction Resources 300 | * @param [array] $data [array of data passed from resource method.] 301 | * @param [object] $obj [The current resource handling the data.] 302 | */ 303 | protected function handleTransactionData($data, $obj) 304 | { 305 | isset($data['AcceptedBy']) ? $obj->setAcceptedBy($data['AcceptedBy']) : ''; 306 | isset($data['AcceptedDate']) ? $obj->setAcceptedDate($data['AcceptedDate']) : ''; 307 | isset($data['Adjustment']) ? $obj->setAdjustment($data['Adjustment']) : ''; 308 | isset($data['ApplyTaxAfterDiscount']) ? $obj->setApplyTaxAfterDiscount($data['ApplyTaxAfterDiscount']) : ''; 309 | isset($data['APAccountRef']) ? $obj->setAPAccountRef($data['APAccountRef']) : ''; 310 | isset($data['Balance']) ? $obj->setBalance($data['Balance']) : ''; 311 | isset($data['ARAccountRef']) ? $obj->setARAccountRef($data['ARAccountRef']) : ''; 312 | isset($data['BreakHours']) ? $obj->setBreakHours($data['BreakHours']) : ''; 313 | isset($data['BreakMinutes']) ? $obj->setBreakMinutes($data['BreakMinutes']) : ''; 314 | isset($data['ClassRef']) ? $obj->setClassRef($data['ClassRef']) : ''; 315 | isset($data['Credit']) ? $obj->setCredit($data['Credit']) : ''; 316 | isset($data['CurrencyRef']) ? $obj->setCurrencyRef($data['CurrencyRef']) : ''; 317 | isset($data['CustomerMemo']) ? $obj->setCustomerMemo($data['CustomerMemo']) : ''; 318 | isset($data['CustomerRef']) ? $obj->setCustomerRef($data['CustomerRef']) : ''; 319 | isset($data['DeliveryInfo']) ? $obj->setDeliveryInfo($data['DeliveryInfo']) : ''; 320 | isset($data['DepartmentRef']) ? $obj->setDepartmentRef($data['DepartmentRef']) : ''; 321 | isset($data['Deposit']) ? $obj->setDeposit($data['Deposit']) : ''; 322 | isset($data['DepositToAccountRef']) ? $obj->setDepositToAccountRef($data['DepositToAccountRef']) : ''; 323 | isset($data['DocNumber']) ? $obj->setDocNumber($data['DocNumber']) : ''; 324 | isset($data['DueDate']) ? $obj->setDueDate($data['DueDate']) : ''; 325 | isset($data['EmailStatus']) ? $obj->setEmailStatus($data['EmailStatus']) : ''; 326 | isset($data['EmployeeRef']) ? $obj->setEmployeeRef($data['EmployeeRef']) : ''; 327 | isset($data['EndTime']) ? $obj->setEndTime($data['EndTime']) : ''; 328 | isset($data['EntityRef']) ? $obj->setEntityRef($data['EntityRef']) : ''; 329 | isset($data['ExchangeRate']) ? $obj->setExchangeRate($data['ExchangeRate']) : ''; 330 | isset($data['ExpirationDate']) ? $obj->setExpirationDate($data['ExpirationDate']) : ''; 331 | isset($data['FromAccountRef']) ? $obj->setFromAccountRef($data['FromAccountRef']) : ''; 332 | isset($data['GlobalTaxCalculation']) ? $obj->setGlobalTaxCalculation($data['GlobalTaxCalculation']) : ''; 333 | isset($data['HomeBalance']) ? $obj->setHomeBalance($data['HomeBalance']) : ''; 334 | isset($data['HomeTotalAmt']) ? $obj->setHomeTotalAmt($data['HomeTotalAmt']) : ''; 335 | isset($data['HourlyRate']) ? $obj->setHourlyRate($data['HourlyRate']) : ''; 336 | isset($data['Hours']) ? $obj->setHours($data['Hours']) : ''; 337 | isset($data['ItemRef']) ? $obj->setItemRef($data['ItemRef']) : ''; 338 | isset($data['Memo']) ? $obj->setMemo($data['Memo']) : ''; 339 | isset($data['Minutes']) ? $obj->setMinutes($data['Minutes']) : ''; 340 | isset($data['NameOf']) ? $obj->setNameOf($data['NameOf']) : ''; 341 | isset($data['PaymentMethodRef']) ? $obj->setPaymentMethodRef($data['PaymentMethodRef']) : ''; 342 | isset($data['PaymentRefNum']) ? $obj->setPaymentRefNum($data['PaymentRefNum']) : ''; 343 | isset($data['PaymentType']) ? $obj->setPaymentType($data['PaymentType']) : ''; 344 | isset($data['PayType']) ? $obj->setPayType($data['PayType']) : ''; 345 | isset($data['POStatus']) ? $obj->setPOStatus($data['POStatus']) : ''; 346 | isset($data['PrintStatus']) ? $obj->setPrintStatus($data['PrintStatus']) : ''; 347 | isset($data['PrivateNote']) ? $obj->setPrivateNote($data['PrivateNote']) : ''; 348 | isset($data['ProcessBillPayment']) ? $obj->setProcessBillPayment($data['ProcessBillPayment']) : ''; 349 | isset($data['PurchaseEx']) ? $obj->setPurchaseEx($data['PurchaseEx']) : ''; 350 | isset($data['RemainingCredit']) ? $obj->setRemainingCredit($data['RemainingCredit']) : ''; 351 | isset($data['SalesTermRef']) ? $obj->setSalesTermRef($data['SalesTermRef']) : ''; 352 | isset($data['ShipDate']) ? $obj->setShipDate($data['ShipDate']) : ''; 353 | isset($data['ShipMethodRef']) ? $obj->setShipMethodRef($data['ShipMethodRef']) : ''; 354 | isset($data['StartTime']) ? $obj->setStartTime($data['StartTime']) : ''; 355 | isset($data['Taxable']) ? $obj->setTaxable($data['Taxable']) : ''; 356 | isset($data['ToAccountRef']) ? $obj->setToAccountRef($data['ToAccountRef']) : ''; 357 | isset($data['TotalAmt']) ? $obj->setTotalAmt($data['TotalAmt']) : ''; 358 | isset($data['TrackingNum']) ? $obj->setTrackingNum($data['TrackingNum']) : ''; 359 | isset($data['TransactionLocationType']) ? $obj->setTransactionLocationType($data['TransactionLocationType']) : ''; 360 | isset($data['TxnDate']) ? $obj->setTxnDate($data['TxnDate']) : $obj->setTxnDate(date('Y-m-d')); 361 | isset($data['TxnSource']) ? $obj->setTxnSource($data['TxnSource']) : ''; 362 | isset($data['UnappliedAmt']) ? $obj->setUnappliedAmt($data['UnappliedAmt']) : ''; 363 | 364 | 365 | 366 | if (isset($data['BillAddr'])) { 367 | $BillAddr = new \QuickBooks_IPP_Object_BillAddr(); 368 | $addrData = $data['BillAddr']; 369 | 370 | isset($addrData['Line1']) ? $BillAddr->setLine1($addrData['Line1']) : ''; 371 | isset($addrData['Line2']) ? $BillAddr->setLine2($addrData['Line2']) : ''; 372 | isset($addrData['Line3']) ? $BillAddr->setLine3($addrData['Line3']) : ''; 373 | isset($addrData['Line4']) ? $BillAddr->setLine4($addrData['Line4']) : ''; 374 | isset($addrData['Line5']) ? $BillAddr->setLine5($addrData['Line5']) : ''; 375 | isset($addrData['City']) ? $BillAddr->setCity($addrData['City']) : ''; 376 | isset($addrData['Country']) ? $BillAddr->setCountry($addrData['Country']) : ''; 377 | isset($addrData['CountrySubDivisionCode']) ? $BillAddr->setCountrySubDivisionCode($addrData['CountrySubDivisionCode']) : ''; 378 | isset($addrData['PostalCode']) ? $BillAddr->setPostalCode($addrData['PostalCode']) : ''; 379 | isset($addrData['Lat']) ? $BillAddr->setLat($addrData['Lat']) : ''; 380 | isset($addrData['Long']) ? $BillAddr->setLong($addrData['Long']) : ''; 381 | 382 | $obj->setBillAddr($BillAddr); 383 | } 384 | 385 | if (isset($data['BillEmail'])) { 386 | $billEmail = new \QuickBooks_IPP_Object_BillEmail(); 387 | $billEmail->setAddress($data['BillEmail']); 388 | $obj->setBillEmail($billEmail); 389 | } 390 | 391 | if (isset($data['CheckPayment'])) { 392 | $CheckPayment = new \Quickbooks_IPP_Object_CheckPayment(); 393 | isset($data['CheckPayment']['BankAccountRef']) ? $CheckPayment->setBankAccountRef($data['CheckPayment']['BankAccountRef']) : ''; 394 | isset($data['CheckPayment']['PrintStatus']) ? $CheckPayment->setPrintStatus($data['CheckPayment']['PrintStatus']) : ''; 395 | $obj->setCheckPayment($CheckPayment); 396 | } 397 | 398 | if (isset($data['CreditCardPayment'])) { 399 | $CreditCardPayment = new \Quickbooks_IPP_Object_CreditCardPayment(); 400 | isset($data['CreditCardPayment']['CCAccountRef']) ? $CreditCardPayment->setCCAccountRef($data['CreditCardPayment']['CCAccountRef']) : ''; 401 | $obj->setCreditCardPayment($CreditCardPayment); 402 | } 403 | 404 | if (isset($data['CustomField'])) { 405 | if (isset($data['CustomField'][0])) { 406 | foreach ($data['CustomField'] as $field) { 407 | $customField = new \QuickBooks_IPP_Object_CustomField(); 408 | $obj->addCustomField($this->generateCustomField($field, $customField)); 409 | } 410 | } else { 411 | $customField = new \QuickBooks_IPP_Object_CustomField(); 412 | $obj->addCustomField($this->generateCustomField($data['CustomField'], $customField)); 413 | } 414 | } 415 | 416 | if (isset($data['Line'])) { 417 | foreach ($data['Line'] as $line) { 418 | $Line = new \QuickBooks_IPP_Object_Line(); 419 | isset($line['Amount']) ? $Line->setAmount($line['Amount']) : ''; 420 | if (isset($line['LinkedTxn'])) { 421 | foreach ($line['LinkedTxn'] as $value) { 422 | $LinkedTxn = new \QuickBooks_IPP_Object_LinkedTxn(); 423 | isset($value['TxnId']) ? $LinkedTxn->setTxnId($value['TxnId']) : ''; 424 | isset($value['TxnType']) ? $LinkedTxn->setTxnType($value['TxnType']) : ''; 425 | isset($value['TxnLineId']) ? $LinkedTxn->setTxnLineId($value['TxnLineId']) : ''; 426 | $Line->setLinkedTxn($LinkedTxn); 427 | } 428 | } 429 | $obj->addLine($Line); 430 | } 431 | } 432 | 433 | if (isset($data['LinkedTxn'])) { 434 | foreach ($data['LinkedTxn'] as $key => $value) { 435 | $LinkedTxn = new \QuickBooks_IPP_Object_LinkedTxn(); 436 | isset($value['TxnId']) ? $LinkedTxn->setTxnId($value['TxnId']) : ''; 437 | isset($value['TxnType']) ? $LinkedTxn->setTxnType($value['TxnType']) : ''; 438 | isset($value['TxnLineId']) ? $LinkedTxn->setTxnLineId($value['TxnLineId']) : ''; 439 | $obj->addLinkedTxn($LinkedTxn); 440 | } 441 | } 442 | 443 | if (isset($data['RemitToAddr'])) { 444 | $RemitToAddr = new \QuickBooks_IPP_Object_RemitToAddr(); 445 | $addrData = $data['RemitToAddr']; 446 | isset($addrData['Line1']) ? $RemitToAddr->setLine1($addrData['Line1']) : ''; 447 | isset($addrData['Line2']) ? $RemitToAddr->setLine2($addrData['Line2']) : ''; 448 | isset($addrData['Line3']) ? $RemitToAddr->setLine3($addrData['Line3']) : ''; 449 | isset($addrData['Line4']) ? $RemitToAddr->setLine4($addrData['Line4']) : ''; 450 | isset($addrData['Line5']) ? $RemitToAddr->setLine5($addrData['Line5']) : ''; 451 | isset($addrData['City']) ? $RemitToAddr->setCity($addrData['City']) : ''; 452 | isset($addrData['Country']) ? $RemitToAddr->setCountry($addrData['Country']) : ''; 453 | isset($addrData['CountrySubDivisionCode']) ? $RemitToAddr->setCountrySubDivisionCode($addrData['CountrySubDivisionCode']) : ''; 454 | isset($addrData['PostalCode']) ? $RemitToAddr->setPostalCode($addrData['PostalCode']) : ''; 455 | isset($addrData['Lat']) ? $RemitToAddr->setLat($addrData['Lat']) : ''; 456 | isset($addrData['Long']) ? $RemitToAddr->setLong($addrData['Long']) : ''; 457 | $obj->setRemitToAddr($RemitToAddr); 458 | } 459 | 460 | if (isset($data['ShipAddr'])) { 461 | $ShipAddr = new \QuickBooks_IPP_Object_ShipAddr(); 462 | $addrData = $data['ShipAddr']; 463 | isset($addrData['Line1']) ? $ShipAddr->setLine1($addrData['Line1']) : ''; 464 | isset($addrData['Line2']) ? $ShipAddr->setLine2($addrData['Line2']) : ''; 465 | isset($addrData['Line3']) ? $ShipAddr->setLine3($addrData['Line3']) : ''; 466 | isset($addrData['Line4']) ? $ShipAddr->setLine4($addrData['Line4']) : ''; 467 | isset($addrData['Line5']) ? $ShipAddr->setLine5($addrData['Line5']) : ''; 468 | isset($addrData['City']) ? $ShipAddr->setCity($addrData['City']) : ''; 469 | isset($addrData['Country']) ? $ShipAddr->setCountry($addrData['Country']) : ''; 470 | isset($addrData['CountrySubDivisionCode']) ? $ShipAddr->setCountrySubDivisionCode($addrData['CountrySubDivisionCode']) : ''; 471 | isset($addrData['PostalCode']) ? $ShipAddr->setPostalCode($addrData['PostalCode']) : ''; 472 | isset($addrData['Lat']) ? $ShipAddr->setLat($addrData['Lat']) : ''; 473 | isset($addrData['Long']) ? $ShipAddr->setLong($addrData['Long']) : ''; 474 | $obj->setShipAddr($ShipAddr); 475 | } 476 | 477 | if (isset($data['TxnTaxDetail'])) { 478 | $taxTxnDetail = new \QuickBooks_IPP_Object_TxnTaxDetail(); 479 | $taxData = $data['TxnTaxDetail']; 480 | isset($taxData['TxnTaxCodeRef']) ? $taxTxnDetail->setTxnTaxCodeRef($taxData['TxnTaxCodeRef']) : ''; 481 | isset($taxData['TotalTax']) ? $taxTxnDetail->setTotalTax($taxData) : ''; 482 | if (isset($taxData['Lines'])) { 483 | $this->createLines($taxData['Lines'], $taxTxnDetail); 484 | } 485 | $obj->setTaxTxnDetail($taxTxnDetail); 486 | } 487 | 488 | if (isset($data['VendorAddr'])) { 489 | $VendorAddr = new \QuickBooks_IPP_Object_VendorAddr(); 490 | $addrData = $data['VendorAddr']; 491 | isset($addrData['Line1']) ? $VendorAddr->setLine1($addrData['Line1']) : ''; 492 | isset($addrData['Line2']) ? $VendorAddr->setLine2($addrData['Line2']) : ''; 493 | isset($addrData['Line3']) ? $VendorAddr->setLine3($addrData['Line3']) : ''; 494 | isset($addrData['Line4']) ? $VendorAddr->setLine4($addrData['Line4']) : ''; 495 | isset($addrData['Line5']) ? $VendorAddr->setLine5($addrData['Line5']) : ''; 496 | isset($addrData['City']) ? $VendorAddr->setCity($addrData['City']) : ''; 497 | isset($addrData['Country']) ? $VendorAddr->setCountry($addrData['Country']) : ''; 498 | isset($addrData['CountrySubDivisionCode']) ? $VendorAddr->setCountrySubDivisionCode($addrData['CountrySubDivisionCode']) : ''; 499 | isset($addrData['PostalCode']) ? $VendorAddr->setPostalCode($addrData['PostalCode']) : ''; 500 | isset($addrData['Lat']) ? $VendorAddr->setLat($addrData['Lat']) : ''; 501 | isset($addrData['Long']) ? $VendorAddr->setLong($addrData['Long']) : ''; 502 | $obj->setVendorAddr($VendorAddr); 503 | } 504 | 505 | return $obj; 506 | } 507 | 508 | /** 509 | * Creates Line data for each QuickBooks Resource. There are multiple types of lines in QuickBooks. There is a mehtod to handle each one since they all have unique data. 510 | * @param array of line data 511 | * @param /QuickBooks_Ipp_Object [The Current resource handling Line data.] 512 | */ 513 | protected function createLines($data, $obj) 514 | { 515 | if ($data) { 516 | foreach ($data as $value) { 517 | $line = new \QuickBooks_IPP_Object_Line(); 518 | $type = $value['DetailType']; 519 | 520 | isset($value['LineNumber']) ? $lnumber = $value['LineNumber'] - 1 : $lnumber = null; 521 | 522 | if ($type != 'DescriptionOnly') { 523 | $accountType = '\\QuickBooks_IPP_Object_'.$type; 524 | $account = new $accountType(); 525 | } 526 | 527 | switch ($type) { 528 | case 'SalesItemLineDetail': 529 | $this->handleSalesItemLineDetail($account, $value, $lnumber, $obj); 530 | break; 531 | case 'ItemBasedExpenseLineDetail': 532 | $this->handleItemBasedExpenseLineDetail($account, $value, $lnumber, $obj); 533 | break; 534 | case 'AccountBasedExpenseLineDetail': 535 | $this->handleAccountBasedExpenseLineDetail($account, $value, $lnumber, $obj); 536 | break; 537 | case 'GroupLineDetail': 538 | $this->handleGroupLineDetail($account, $value, $lnumber, $obj); 539 | break; 540 | case 'DescriptionOnly': 541 | $this->handleDescriptionOnly($value, $lnumber, $obj); 542 | break; 543 | case 'DiscountLineDetail': 544 | $this->handleDiscountLineDetail($account, $value, $lnumber, $obj); 545 | break; 546 | case 'SubtotalLine': 547 | $this->handleSubtotalLineDetail($account, $value, $lnumber, $obj); 548 | break; 549 | case 'TaxLineDetail': 550 | $this->handleTaxLineDetail($account, $value, $lnumber, $obj); 551 | break; 552 | default: 553 | null; 554 | break; 555 | } 556 | } 557 | } 558 | } 559 | 560 | protected function handleSalesItemLineDetail($account, $data, $lnumber = null, $obj) 561 | { 562 | isset($lnumber) ? $line = $obj->getLine($lnumber) : $line = new \QuickBooks_IPP_Object_Line(); 563 | 564 | isset($data['Amount']) ? $line->setAmount($data['Amount']) : ''; 565 | $line->setDetailType('SalesItemLineDetail'); 566 | isset($data['LineNum']) ? $line->setLineNum($data['LineNum']) : ''; 567 | isset($data['Description']) ? $line->setDescription($data['Description']) : ''; 568 | 569 | isset($data['ItemRef']) ? $account->setItemRef($data['ItemRef']) : ''; 570 | isset($data['ClassRef']) ? $account->setClassRef($data['ClassRef']) : ''; 571 | isset($data['UnitPrice']) ? $account->setUnitPrice($data['UnitPrice']) : ''; 572 | isset($data['Qty']) ? $account->setQty($data['Qty']) : ''; 573 | isset($data['TaxCodeRef']) ? $account->setTaxCodeRef($data['TaxCodeRef']) : ''; 574 | isset($data['ServiceDate']) ? $account->setServiceDate($data['ServiceDate']) : ''; 575 | 576 | if (isset($value['MarkupInfo'])) { 577 | $markup = new \QuickBooks_IPP_Object_MarkupInfo(); 578 | $markupData = $value['MarkupInfo']; 579 | isset($markupData) ? $markup->setPercentBased($markupData['PercentBased']) : ''; 580 | isset($markupData) ? $markup->setValue($markupData['Value']) : ''; 581 | isset($markupData) ? $markup->setPercent($markupData['Percent']) : ''; 582 | isset($markupData) ? $markup->setPriceLevelRef($markupData['PriceLevelRef']) : ''; 583 | $account->setMarkupInfo($markup); 584 | } 585 | $line->setSalesItemLineDetail($account); 586 | 587 | isset($lnumber) ? '' : $obj->addLine($line); 588 | } 589 | 590 | protected function handleItemBasedExpenseLineDetail($account, $data, $lnumber = null, $obj) 591 | { 592 | isset($lnumber) ? $line = $obj->getLine($lnumber) : $line = new \QuickBooks_IPP_Object_Line(); 593 | 594 | isset($data['Amount']) ? $line->setAmount($data['Amount']) : ''; 595 | $line->setDetailType('ItemBasedExpenseLineDetail'); 596 | isset($data['LineNum']) ? $line->setLineNum($data['LineNum']) : ''; 597 | isset($data['Description']) ? $line->setDescription($data['Description']) : ''; 598 | 599 | isset($data['ItemRef']) ? $account->setItemRef($data['ItemRef']) : ''; 600 | isset($data['ClassRef']) ? $account->setClassRef($data['ClassRef']) : ''; 601 | isset($data['UnitPrice']) ? $account->setUnitPrice($data['UnitPrice']) : ''; 602 | isset($data['PriceLevelRef']) ? $account->setPriceLevelRef($data['PriceLevelRef']) : ''; 603 | isset($data['Qty']) ? $account->setQty($data['Qty']) : ''; 604 | isset($data['TaxCodeRef']) ? $account->setTaxCodeRef($data['TaxCodeRef']) : ''; 605 | isset($data['CustomerRef']) ? $account->setCustomerRef($data['CustomerRef']) : ''; 606 | isset($data['BillableStatus']) ? $account->setBillableStatus($data['BillableStatus']) : ''; 607 | isset($data['TaxInclusiveAmt']) ? $account->setTaxInclusiveAmt($data['TaxInclusiveAmt']) : ''; 608 | 609 | if (isset($value['MarkupInfo'])) { 610 | $markup = new \QuickBooks_IPP_Object_MarkupInfo(); 611 | $markupData = $value['MarkupInfo']; 612 | isset($markupData) ? $markup->setPercentBased($markupData['PercentBased']) : ''; 613 | isset($markupData) ? $markup->setValue($markupData['Value']) : ''; 614 | isset($markupData) ? $markup->setPercent($markupData['Percent']) : ''; 615 | isset($markupData) ? $markup->setPriceLevelRef($markupData['PriceLevelRef']) : ''; 616 | $account->setMarkupInfo($markup); 617 | } 618 | $line->setItemBasedExpensLineDetail($account); 619 | 620 | isset($lnumber) ? '' : $obj->addLine($line); 621 | } 622 | 623 | protected function handleAccountBasedExpenseLineDetail($account, $data, $lnumber = null, $obj) 624 | { 625 | isset($lnumber) ? $line = $obj->getLine($lnumber) : $line = new \QuickBooks_IPP_Object_Line(); 626 | 627 | isset($data['Amount']) ? $line->setAmount($data['Amount']) : ''; 628 | $line->setDetailType('AccountBasedExpenseLineDetail'); 629 | isset($data['LineNum']) ? $line->setLineNum($data['LineNum']) : ''; 630 | isset($data['Description']) ? $line->setDescription($data['Description']) : ''; 631 | 632 | isset($data['CustomerRef']) ? $account->setCustomerRef($data['CustomerRef']) : ''; 633 | isset($data['ClassRef']) ? $account->setClassRef($data['ClassRef']) : ''; 634 | isset($data['AccountRef']) ? $account->setAccountRef($data['AccountRef']) : ''; 635 | isset($data['BillableStatus']) ? $account->setBillableStatus($data['BillableStatus']) : ''; 636 | isset($data['TaxAmount']) ? $account->setTaxAmount($data['TaxAmount']) : ''; 637 | isset($data['TaxCodeRef']) ? $account->setTaxCodeRef($data['TaxCodeRef']) : ''; 638 | isset($data['TaxInclusiveAmt']) ? $account->setTaxInclusiveAmt($data['TaxInclusiveAmt']) : ''; 639 | 640 | if (isset($value['MarkupInfo'])) { 641 | $markup = new \QuickBooks_IPP_Object_MarkupInfo(); 642 | $markupData = $value['MarkupInfo']; 643 | isset($markupData) ? $markup->setPercentBased($markupData['PercentBased']) : ''; 644 | isset($markupData) ? $markup->setValue($markupData['Value']) : ''; 645 | isset($markupData) ? $markup->setPercent($markupData['Percent']) : ''; 646 | isset($markupData) ? $markup->setPriceLevelRef($markupData['PriceLevelRef']) : ''; 647 | $account->setMarkupInfo($markup); 648 | } 649 | $line->setAccountBasedExpensLineDetail($account); 650 | 651 | isset($lnumber) ? '' : $obj->addLine($line); 652 | } 653 | 654 | protected function handleGroupLineDetail($account, $data, $lnumber = null, $obj) 655 | { 656 | isset($lnumber) ? $line = $obj->getLine($lnumber) : $line = new \QuickBooks_IPP_Object_Line(); 657 | 658 | $line->setDetailType('GroupLineDetail'); 659 | isset($data['Description']) ? $line->setDescription($data['Description']) : ''; 660 | isset($data['LineNum']) ? $line->setLineNum($data['LineNum']) : ''; 661 | isset($data['GroupItemRef']) ? $line->setGroupItemRef($data['GroupItemRef']) : ''; 662 | isset($data['Quantity']) ? $line->setQuantity($data['Quantity']) : ''; 663 | isset($data['Description']) ? $line->setDescription($data['Description']) : ''; 664 | 665 | if (isset($data['Lines'])) { 666 | $this->createLines($data['Lines'], $account); 667 | } 668 | $line->setGroupLineDetail($account); 669 | isset($lnumber) ? '' : $obj->addLine($line); 670 | } 671 | 672 | protected function handleDescriptionOnly($data, $lnumber = null, $obj) 673 | { 674 | $account = new \QuickBooks_IPP_Object_DescriptionLineDetail(); 675 | isset($lnumber) ? $line = $obj->getLine(0) : $line = new \QuickBooks_IPP_Object_Line(); 676 | $line->setDetailType('DescriptionOnly'); 677 | isset($data['Amount']) ? $line->setAmount($data['Amount']) : ''; 678 | isset($data['Description']) ? $line->setDescription($data['Description']) : ''; 679 | isset($data['LineNum']) ? $line->setLineNum($data['LineNum']) : ''; 680 | 681 | isset($data['ServiceDate']) ? $account->setServiceDate($data['ServiceDate']) : ''; 682 | isset($data['TaxCodeRef']) ? $account->setTaxCodeRef($data['TaxCodeRef']) : ''; 683 | 684 | $line->setDescriptionLineDetail($account); 685 | isset($lnumber) ? '' : $obj->addLine($line); 686 | } 687 | 688 | protected function handleDiscountLineDetail($account, $data, $lnumber = null, $obj) 689 | { 690 | isset($lnumber) ? $line = $obj->getLine($lnumber) : $line = new \QuickBooks_IPP_Object_Line(); 691 | $line->setDetailType('DiscountLineDetail'); 692 | isset($data['Amount']) ? $line->setAmount($data['Amount']) : ''; 693 | isset($data['Description']) ? $line->setDescription($data['Description']) : ''; 694 | isset($data['LineNum']) ? $line->setLineNum($data['LineNum']) : ''; 695 | 696 | isset($data['PercentBased']) ? $account->setPercentBased($data['PercentBased']) : ''; 697 | isset($data['DiscountPercent']) ? $account->setDiscountPercent($data['DiscountPercent']) : ''; 698 | isset($data['DiscountAccountRef']) ? $account->setDiscountAccountRef($data['DiscountAccountRef']) : ''; 699 | isset($data['ClassRef']) ? $account->setClassRef($data['ClassRef']) : ''; 700 | isset($data['TaxCodeRef']) ? $account->setTaxCodeRef($data['TaxCodeRef']) : ''; 701 | 702 | $line->setDiscountLineDetail($account); 703 | isset($lnumber) ? '' : $obj->addLine($line); 704 | } 705 | 706 | protected function handleSubtotalLineDetail($account, $data, $lnumber = null, $obj) 707 | { 708 | isset($lnumber) ? $line = $obj->getLine($lnumber) : $line = new \QuickBooks_IPP_Object_Line(); 709 | $line->setDetailType('SubtotalLineDetail'); 710 | isset($data['Amount']) ? $line->setAmount($data['Amount']) : ''; 711 | isset($data['Description']) ? $line->setDescription($data['Description']) : ''; 712 | isset($data['LineNum']) ? $line->setLineNum($data['LineNum']) : ''; 713 | 714 | isset($data['ItemRef']) ? $account->setItemRef($data['ItemRef']) : ''; 715 | 716 | $line->setSubtotalLineDetail($account); 717 | isset($lnumber) ? '' : $obj->addLine($line); 718 | } 719 | 720 | protected function handleTaxLineDetail($account, $data, $lnumber = null, $obj) 721 | { 722 | isset($lnumber) ? $line = $obj->getLine($lnumber) : $line = new \QuickBooks_IPP_Object_TaxLine(); 723 | $line->setDetailType('TaxLineDetail'); 724 | isset($data['TaxRateRef']) ? $account->setTaxRateRef($data['TaxRateRef']) : ''; 725 | isset($data['Amount']) ? $line->setAmount($data['Amount']) : ''; 726 | isset($data['PercentBased']) ? $account->setPercentBased($data['PercentBased']) : ''; 727 | isset($data['NetAmountTaxable']) ? $account->setNetAmountTaxable($data['NetAmountTaxable']) : ''; 728 | isset($data['TaxInclusiveAmount']) ? $account->setTaxInclusiveAmount($data['TaxInclusiveAmount']) : ''; 729 | isset($data['OverrideDeltaAmount']) ? $account->setOverrideDeltaAmount($data['OverrideDeltaAmount']) : ''; 730 | isset($data['TaxPercent']) ? $account->setTaxPercent($data['TaxPercent']) : ''; 731 | $line->setTaxLineDetail($account); 732 | isset($lnumber) ? '' : $obj->addLine($line); 733 | } 734 | 735 | private function generateCustomField($fieldInput, $fieldObj) 736 | { 737 | isset($fieldInput['DefinitionId']) ? $fieldObj->setDefinitionId($fieldInput['DefinitionId']) : ''; 738 | isset($fieldInput['Name']) ? $fieldObj->setName($fieldInput['Name']) : ''; 739 | isset($fieldInput['Type']) ? $fieldObj->setType($fieldInput['Type']) : ''; 740 | isset($fieldInput['StringValue']) ? $fieldObj->setStringValue($fieldInput['StringValue']) : ''; 741 | return $fieldObj; 742 | } 743 | } 744 | -------------------------------------------------------------------------------- /src/Services/Accounting/Account.php: -------------------------------------------------------------------------------- 1 | service = new \QuickBooks_IPP_Service_Account(); 13 | $this->resource = new \QuickBooks_IPP_Object_Account(); 14 | $this->handleNameListData($data, $this->resource); 15 | isset($data['Lines']) ? $this->createLines($data['Lines'], $this->resource) : ''; 16 | 17 | return $this->service->add($this->context, $this->realm, $this->resource) ?: $this->service->lastError(); 18 | } 19 | 20 | public function update($id, array $data) 21 | { 22 | $this->service = new \QuickBooks_IPP_Service_Account(); 23 | $this->resource = $this->find($id); 24 | 25 | $this->handleNameListData($data, $this->resource); 26 | isset($data['Lines']) ? $this->createLines($data['Lines'], $this->resource) : ''; 27 | 28 | return parent::_update($this->context, $this->realm, \QuickBooks_IPP_IDS::RESOURCE_ACCOUNT, $this->resource, $id) ?: $this->service->lastError(); 29 | } 30 | 31 | public function delete($id) 32 | { 33 | $this->service = new \QuickBooks_IPP_Service_Account(); 34 | return parent::_delete($this->context, $this->realm, \QuickBooks_IPP_IDS::RESOURCE_ACCOUNT, $id); 35 | } 36 | 37 | public function find($id) 38 | { 39 | $this->service = new \QuickBooks_IPP_Service_Account(); 40 | $query = $this->service->query($this->context, $this->realm, "SELECT * FROM Account WHERE Id = '$id' "); 41 | if (!empty($query)) { 42 | return $query[0]; 43 | } 44 | return 'Looks like this id does not exist.'; 45 | } 46 | 47 | public function get() 48 | { 49 | $this->service = new \QuickBooks_IPP_Service_Account(); 50 | return $this->service->query($this->context, $this->realm, "SELECT * FROM Account"); 51 | } 52 | 53 | public function query($query) 54 | { 55 | $this->service = new \QuickBooks_IPP_Service_Account(); 56 | 57 | return $this->service->query($this->context, $this->realm, $query); 58 | } 59 | } 60 | -------------------------------------------------------------------------------- /src/Services/Accounting/Bill.php: -------------------------------------------------------------------------------- 1 | service = new \QuickBooks_IPP_Service_Bill(); 13 | $this->resource = new \QuickBooks_IPP_Object_Bill(); 14 | $this->handleTransactionData($data, $this->resource); 15 | isset($data['Lines']) ? $this->createLines($data['Lines'], $this->resource) : ''; 16 | 17 | return $this->service->add($this->context, $this->realm, $this->resource) ?: $this->service->lastError(); 18 | } 19 | 20 | public function update($id, array $data) 21 | { 22 | $this->service = new \QuickBooks_IPP_Service_Bill(); 23 | $this->resource = $this->find($id); 24 | 25 | $this->handleTransactionData($data, $this->resource); 26 | isset($data['Lines']) ? $this->createLines($data['Lines'], $this->resource) : ''; 27 | 28 | return $this->service->update($this->context, $this->realm, $id, $this->resource) ?: $this->service->lastError(); 29 | } 30 | 31 | public function delete($id) 32 | { 33 | $this->service = new \QuickBooks_IPP_Service_Bill(); 34 | return $this->service->delete($this->context, $this->realm, $id); 35 | } 36 | 37 | public function find($id) 38 | { 39 | $this->service = new \QuickBooks_IPP_Service_Bill(); 40 | $query = $this->service->query($this->context, $this->realm, "SELECT * FROM Bill WHERE Id = '$id' "); 41 | if (!empty($query)) { 42 | return $query[0]; 43 | } 44 | return 'Looks like this id does not exist.'; 45 | } 46 | 47 | public function get() 48 | { 49 | $this->service = new \QuickBooks_IPP_Service_Bill(); 50 | return $this->service->query($this->context, $this->realm, "SELECT * FROM Bill"); 51 | } 52 | 53 | public function query($query) 54 | { 55 | $this->service = new \QuickBooks_IPP_Service_Bill(); 56 | 57 | return $this->service->query($this->context, $this->realm, $query); 58 | } 59 | } 60 | -------------------------------------------------------------------------------- /src/Services/Accounting/BillPayment.php: -------------------------------------------------------------------------------- 1 | service = new \QuickBooks_IPP_Service_BillPayment(); 13 | $this->resource = new \QuickBooks_IPP_Object_BillPayment(); 14 | $this->handleTransactionData($data, $this->resource); 15 | isset($data['Lines']) ? $this->createLines($data['Lines'], $this->resource) : ''; 16 | 17 | return $this->service->add($this->context, $this->realm, $this->resource) ?: $this->service->lastError(); 18 | } 19 | 20 | public function update($id, array $data) 21 | { 22 | $this->service = new \QuickBooks_IPP_Service_BillPayment(); 23 | $this->resource = $this->find($id); 24 | 25 | $this->handleTransactionData($data, $this->resource); 26 | isset($data['Lines']) ? $this->createLines($data['Lines'], $this->resource) : ''; 27 | 28 | return $this->service->update($this->context, $this->realm, $id, $this->resource) ?: $this->service->lastError(); 29 | } 30 | 31 | public function delete($id) 32 | { 33 | $this->service = new \QuickBooks_IPP_Service_BillPayment(); 34 | return $this->service->delete($this->context, $this->realm, $id); 35 | } 36 | 37 | public function find($id) 38 | { 39 | $this->service = new \QuickBooks_IPP_Service_BillPayment(); 40 | $query = $this->service->query($this->context, $this->realm, "SELECT * FROM BillPayment WHERE Id = '$id' "); 41 | if (!empty($query)) { 42 | return $query[0]; 43 | } 44 | return 'Looks like this id does not exist.'; 45 | } 46 | 47 | public function get() 48 | { 49 | $this->service = new \QuickBooks_IPP_Service_BillPayment(); 50 | return $this->service->query($this->context, $this->realm, "SELECT * FROM BillPayment"); 51 | } 52 | 53 | public function query($query) 54 | { 55 | $this->service = new \QuickBooks_IPP_Service_BillPayment(); 56 | 57 | return $this->service->query($this->context, $this->realm, $query); 58 | } 59 | } 60 | -------------------------------------------------------------------------------- /src/Services/Accounting/CreditMemo.php: -------------------------------------------------------------------------------- 1 | service = new \QuickBooks_IPP_Service_CreditMemo(); 13 | $this->resource = new \QuickBooks_IPP_Object_CreditMemo(); 14 | $this->handleTransactionData($data, $this->resource); 15 | $this->createLines($data['Lines'], $this->resource); 16 | 17 | return $this->service->add($this->context, $this->realm, $this->resource) ?: $this->service->lastError(); 18 | } 19 | 20 | public function update($id, array $data) 21 | { 22 | $this->service = new \QuickBooks_IPP_Service_CreditMemo(); 23 | $this->resource = $this->find($id); 24 | 25 | $this->handleTransactionData($data, $this->resource); 26 | isset($data['Lines']) ? $this->createLines($data['Lines'], $this->resource) : ''; 27 | 28 | return $this->service->update($this->context, $this->realm, $id, $this->resource) ?: $this->service->lastError(); 29 | } 30 | 31 | public function delete($id) 32 | { 33 | $this->service = new \QuickBooks_IPP_Service_CreditMemo(); 34 | return $this->service->delete($this->context, $this->realm, $id); 35 | } 36 | 37 | public function find($id) 38 | { 39 | $this->service = new \QuickBooks_IPP_Service_CreditMemo(); 40 | $query = $this->service->query($this->context, $this->realm, "SELECT * FROM CreditMemo WHERE Id = '$id' "); 41 | if (!empty($query)) { 42 | return $query[0]; 43 | } 44 | return 'Looks like this id does not exist.'; 45 | } 46 | 47 | public function get() 48 | { 49 | $this->service = new \QuickBooks_IPP_Service_CreditMemo(); 50 | return $this->service->query($this->context, $this->realm, "SELECT * FROM CreditMemo"); 51 | } 52 | 53 | public function query($query) 54 | { 55 | $this->service = new \QuickBooks_IPP_Service_CreditMemo(); 56 | 57 | return $this->service->query($this->context, $this->realm, $query); 58 | } 59 | } 60 | -------------------------------------------------------------------------------- /src/Services/Accounting/Customer.php: -------------------------------------------------------------------------------- 1 | service = new \QuickBooks_IPP_Service_Customer(); 13 | $this->resource = new \QuickBooks_IPP_Object_Customer(); 14 | $this->handleNameListData($data, $this->resource); 15 | isset($data['Lines']) ? $this->createLines($data['Lines'], $this->resource) : ''; 16 | 17 | return $this->service->add($this->context, $this->realm, $this->resource) ?: $this->service->lastError(); 18 | } 19 | 20 | public function update($id, array $data) 21 | { 22 | $this->service = new \QuickBooks_IPP_Service_Customer(); 23 | $this->resource = $this->find($id); 24 | 25 | $this->handleNameListData($data, $this->resource); 26 | isset($data['Lines']) ? $this->createLines($data['Lines'], $this->resource) : ''; 27 | return $this->service->update($this->context, $this->realm, $id, $this->resource) ?: $this->service->lastError(); 28 | } 29 | 30 | public function delete($id) 31 | { 32 | $this->service = new \QuickBooks_IPP_Service_Customer(); 33 | return $this->service->delete($this->context, $this->realm, $id); 34 | } 35 | 36 | public function find($id) 37 | { 38 | $this->service = new \QuickBooks_IPP_Service_Customer(); 39 | $query = $this->service->query($this->context, $this->realm, "SELECT * FROM Customer WHERE Id = '$id' "); 40 | if (!empty($query)) { 41 | return $query[0]; 42 | } 43 | return 'Looks like this id does not exist.'; 44 | } 45 | 46 | public function get() 47 | { 48 | $this->service = new \QuickBooks_IPP_Service_Customer(); 49 | return $this->service->query($this->context, $this->realm, "SELECT * FROM Customer"); 50 | } 51 | 52 | public function query($query) 53 | { 54 | $this->service = new \QuickBooks_IPP_Service_Customer(); 55 | 56 | return $this->service->query($this->context, $this->realm, $query); 57 | } 58 | } 59 | -------------------------------------------------------------------------------- /src/Services/Accounting/Department.php: -------------------------------------------------------------------------------- 1 | service = new \QuickBooks_IPP_Service_Department(); 13 | $this->resource = new \QuickBooks_IPP_Object_Department(); 14 | $this->handleTransactionData($data, $this->resource); 15 | isset($data['Lines']) ? $this->createLines($data['Lines'], $this->resource) : ''; 16 | 17 | return $this->service->add($this->context, $this->realm, $this->resource) ?: $this->service->lastError(); 18 | } 19 | 20 | public function update($id, array $data) 21 | { 22 | $this->service = new \QuickBooks_IPP_Service_Department(); 23 | $this->resource = $this->find($id); 24 | 25 | $this->handleTransactionData($data, $this->resource); 26 | isset($data['Lines']) ? $this->createLines($data['Lines'], $this->resource) : ''; 27 | 28 | return $this->service->update($this->context, $this->realm, $id, $this->resource) ?: $this->service->lastError(); 29 | } 30 | 31 | public function delete($id) 32 | { 33 | $this->service = new \QuickBooks_IPP_Service_Department(); 34 | return $this->service->delete($this->context, $this->realm, $id); 35 | } 36 | 37 | public function find($id) 38 | { 39 | $this->service = new \QuickBooks_IPP_Service_Department(); 40 | $query = $this->service->query($this->context, $this->realm, "SELECT * FROM Department WHERE Id = '$id' "); 41 | if (!empty($query)) { 42 | return $query[0]; 43 | } 44 | return 'Looks like this id does not exist.'; 45 | } 46 | 47 | public function get() 48 | { 49 | $this->service = new \QuickBooks_IPP_Service_Department(); 50 | return $this->service->query($this->context, $this->realm, "SELECT * FROM Department"); 51 | } 52 | 53 | public function query($query) 54 | { 55 | $this->service = new \QuickBooks_IPP_Service_Department(); 56 | 57 | return $this->service->query($this->context, $this->realm, $query); 58 | } 59 | } 60 | -------------------------------------------------------------------------------- /src/Services/Accounting/Employee.php: -------------------------------------------------------------------------------- 1 | service = new \QuickBooks_IPP_Service_Employee(); 13 | $this->resource = new \QuickBooks_IPP_Object_Employee(); 14 | $this->handleNameListData($data, $this->resource); 15 | isset($data['Lines']) ? $this->createLines($data['Lines'], $this->resource) : ''; 16 | 17 | return $this->service->add($this->context, $this->realm, $this->resource) ?: $this->service->lastError(); 18 | } 19 | 20 | public function update($id, array $data) 21 | { 22 | $this->service = new \QuickBooks_IPP_Service_Employee(); 23 | $this->resource = $this->find($id); 24 | 25 | $this->handleNameListData($data, $this->resource); 26 | isset($data['Lines']) ? $this->createLines($data['Lines'], $this->resource) : ''; 27 | 28 | return parent::_update($this->context, $this->realm, \QuickBooks_IPP_IDS::RESOURCE_EMPLOYEE, $this->resource, $id) ?: $this->service->lastError(); 29 | } 30 | 31 | public function delete($id) 32 | { 33 | $this->service = new \QuickBooks_IPP_Service_Employee(); 34 | return parent::_delete($this->context, $this->realm, \QuickBooks_IPP_IDS::RESOURCE_EMPLOYEE, $id); 35 | } 36 | 37 | public function find($id) 38 | { 39 | $this->service = new \QuickBooks_IPP_Service_Employee(); 40 | $query = $this->service->query($this->context, $this->realm, "SELECT * FROM Employee WHERE Id = '$id' "); 41 | if (!empty($query)) { 42 | return $query[0]; 43 | } 44 | return 'Looks like this id does not exist.'; 45 | } 46 | 47 | public function get() 48 | { 49 | $this->service = new \QuickBooks_IPP_Service_Employee(); 50 | return $this->service->query($this->context, $this->realm, "SELECT * FROM Employee"); 51 | } 52 | 53 | public function query($query) 54 | { 55 | $this->service = new \QuickBooks_IPP_Service_Employee(); 56 | 57 | return $this->service->query($this->context, $this->realm, $query); 58 | } 59 | } 60 | -------------------------------------------------------------------------------- /src/Services/Accounting/Estimate.php: -------------------------------------------------------------------------------- 1 | service = new \QuickBooks_IPP_Service_Estimate(); 13 | $this->resource = new \QuickBooks_IPP_Object_Estimate(); 14 | $this->handleTransactionData($data, $this->resource); 15 | isset($data['Lines']) ? $this->createLines($data['Lines'], $this->resource) : ''; 16 | 17 | return $this->service->add($this->context, $this->realm, $this->resource) ?: $this->service->lastError(); 18 | } 19 | 20 | public function update($id, array $data) 21 | { 22 | $this->service = new \QuickBooks_IPP_Service_Estimate(); 23 | $this->resource = $this->find($id); 24 | 25 | $this->handleTransactionData($data, $this->resource); 26 | isset($data['Lines']) ? $this->createLines($data['Lines'], $this->resource) : ''; 27 | 28 | return parent::_update($this->context, $this->realm, \QuickBooks_IPP_IDS::RESOURCE_ESTIMATE, $this->resource, $id) ?: $this->service->lastError(); 29 | } 30 | 31 | public function delete($id) 32 | { 33 | $this->service = new \QuickBooks_IPP_Service_Estimate(); 34 | return parent::_delete($this->context, $this->realm, \QuickBooks_IPP_IDS::RESOURCE_ESTIMATE, $id); 35 | } 36 | 37 | public function find($id) 38 | { 39 | $this->service = new \QuickBooks_IPP_Service_Estimate(); 40 | $query = $this->service->query($this->context, $this->realm, "SELECT * FROM Estimate WHERE Id = '$id' "); 41 | if (!empty($query)) { 42 | return $query[0]; 43 | } 44 | return 'Looks like this id does not exist.'; 45 | } 46 | 47 | public function get() 48 | { 49 | $this->service = new \QuickBooks_IPP_Service_Estimate(); 50 | return $this->service->query($this->context, $this->realm, "SELECT * FROM Estimate"); 51 | } 52 | 53 | public function query($query) 54 | { 55 | $this->service = new \QuickBooks_IPP_Service_Estimate(); 56 | 57 | return $this->service->query($this->context, $this->realm, $query); 58 | } 59 | } 60 | -------------------------------------------------------------------------------- /src/Services/Accounting/Invoice.php: -------------------------------------------------------------------------------- 1 | service = new \QuickBooks_IPP_Service_Invoice(); 13 | $this->resource = new \QuickBooks_IPP_Object_Invoice(); 14 | $this->handleTransactionData($data, $this->resource); 15 | isset($data['Lines']) ? $this->createLines($data['Lines'], $this->resource) : ''; 16 | 17 | return $this->service->add($this->context, $this->realm, $this->resource) ?: $this->service->lastError(); 18 | } 19 | 20 | public function update($id, array $data) 21 | { 22 | $this->service = new \QuickBooks_IPP_Service_Invoice(); 23 | $this->resource = $this->find($id); 24 | 25 | $this->handleTransactionData($data, $this->resource); 26 | isset($data['Lines']) ? $this->createLines($data['Lines'], $this->resource) : ''; 27 | 28 | return $this->service->update($this->context, $this->realm, $id, $this->resource) ?: $this->service->lastError(); 29 | } 30 | 31 | public function delete($id) 32 | { 33 | $this->service = new \QuickBooks_IPP_Service_Invoice(); 34 | return $this->service->delete($this->context, $this->realm, $id); 35 | } 36 | 37 | public function find($id) 38 | { 39 | $this->service = new \QuickBooks_IPP_Service_Invoice(); 40 | $query = $this->service->query($this->context, $this->realm, "SELECT * FROM Invoice WHERE Id = '$id' "); 41 | 42 | if (!empty($query)) { 43 | return $query[0]; 44 | } 45 | return 'Looks like this id does not exist.'; 46 | } 47 | 48 | public function generatePDF($id) 49 | { 50 | $this->service = new \QuickBooks_IPP_Service_Invoice(); 51 | 52 | if ($this->service->pdf($this->context, $this->realm, $id)) { 53 | header("Content-Disposition: attachment; filename=invoice_$id.pdf"); 54 | header("Content-type: application/x-pdf"); 55 | return print $this->service->pdf($this->context, $this->realm, $id); 56 | } 57 | return 'Looks like this id does not exist.'; 58 | } 59 | 60 | public function get() 61 | { 62 | $this->service = new \QuickBooks_IPP_Service_Invoice(); 63 | return $this->service->query($this->context, $this->realm, "SELECT * FROM Invoice"); 64 | } 65 | 66 | public function query($query) 67 | { 68 | $this->service = new \QuickBooks_IPP_Service_Invoice(); 69 | 70 | return $this->service->query($this->context, $this->realm, $query); 71 | } 72 | } 73 | -------------------------------------------------------------------------------- /src/Services/Accounting/Item.php: -------------------------------------------------------------------------------- 1 | service = new \QuickBooks_IPP_Service_Item(); 12 | $this->resource = new \QuickBooks_IPP_Object_Item(); 13 | $this->handleNameListData($data, $this->resource); 14 | isset($data['Lines']) ? $this->createLines($data['Lines'], $this->resource) : ''; 15 | 16 | return $this->service->add($this->context, $this->realm, $this->resource) ?: $this->service->lastError(); 17 | } 18 | 19 | public function update($id, array $data) 20 | { 21 | $this->service = new \QuickBooks_IPP_Service_Item(); 22 | $this->resource = $this->find($id); 23 | 24 | $this->handleNameListData($data, $this->resource); 25 | isset($data['Lines']) ? $this->createLines($data['Lines'], $this->resource) : ''; 26 | 27 | return $this->service->update($this->context, $this->realm, $id, $this->resource) ?: $this->service->lastError(); 28 | } 29 | 30 | public function delete($id) 31 | { 32 | $this->service = new \QuickBooks_IPP_Service_Item(); 33 | return $this->service->delete($this->context, $this->realm, $id); 34 | } 35 | 36 | public function find($id) 37 | { 38 | $this->service = new \QuickBooks_IPP_Service_Item(); 39 | $query = $this->service->query($this->context, $this->realm, "SELECT * FROM Item WHERE Id = '$id' "); 40 | if (!empty($query)) { 41 | return $query[0]; 42 | } 43 | return 'Looks like this id does not exist.'; 44 | } 45 | 46 | public function get() 47 | { 48 | $this->service = new \QuickBooks_IPP_Service_Item(); 49 | return $this->service->query($this->context, $this->realm, "SELECT * FROM Item"); 50 | } 51 | 52 | public function query($query) 53 | { 54 | $this->service = new \QuickBooks_IPP_Service_Item(); 55 | 56 | return $this->service->query($this->context, $this->realm, $query); 57 | } 58 | } 59 | -------------------------------------------------------------------------------- /src/Services/Accounting/JournalEntry.php: -------------------------------------------------------------------------------- 1 | service = new \QuickBooks_IPP_Service_JournalEntry(); 13 | $this->resource = new \QuickBooks_IPP_Object_JournalEntry(); 14 | $this->handleTransactionData($data, $this->resource); 15 | isset($data['Lines']) ? $this->createLines($data['Lines'], $this->resource) : ''; 16 | 17 | return $this->service->add($this->context, $this->realm, $this->resource) ?: $this->service->lastError(); 18 | } 19 | 20 | public function update($id, array $data) 21 | { 22 | $this->service = new \QuickBooks_IPP_Service_JournalEntry(); 23 | $this->resource = $this->find($id); 24 | 25 | $this->handleTransactionData($data, $this->resource); 26 | isset($data['Lines']) ? $this->createLines($data['Lines'], $this->resource) : ''; 27 | 28 | return parent::_update($this->context, $this->realm, \QuickBooks_IPP_IDS::RESOURCE_JOURNALENTRY, $this->resource, $id) ?: $this->service->lastError(); 29 | } 30 | 31 | public function delete($id) 32 | { 33 | $this->service = new \QuickBooks_IPP_Service_JournalEntry(); 34 | return $this->service->delete($this->context, $this->realm, $id); 35 | } 36 | 37 | public function find($id) 38 | { 39 | $this->service = new \QuickBooks_IPP_Service_JournalEntry(); 40 | $query = $this->service->query($this->context, $this->realm, "SELECT * FROM JournalEntry WHERE Id = '$id' "); 41 | 42 | if (!empty($query)) { 43 | return $query[0]; 44 | } 45 | return 'Looks like this id does not exist.'; 46 | } 47 | 48 | public function get() 49 | { 50 | $this->service = new \QuickBooks_IPP_Service_JournalEntry(); 51 | return $this->service->query($this->context, $this->realm, "SELECT * FROM JournalEntry"); 52 | } 53 | 54 | public function query($query) 55 | { 56 | $this->service = new \QuickBooks_IPP_Service_JournalEntry(); 57 | 58 | return $this->service->query($this->context, $this->realm, $query); 59 | } 60 | } 61 | -------------------------------------------------------------------------------- /src/Services/Accounting/Payment.php: -------------------------------------------------------------------------------- 1 | service = new \QuickBooks_IPP_Service_Payment(); 13 | $this->resource = new \QuickBooks_IPP_Object_Payment(); 14 | $this->handleTransactionData($data, $this->resource); 15 | isset($data['Lines']) ? $this->createLines($data['Lines'], $this->resource) : ''; 16 | 17 | return $this->service->add($this->context, $this->realm, $this->resource) ?: $this->service->lastError(); 18 | } 19 | 20 | public function update($id, array $data) 21 | { 22 | $this->service = new \QuickBooks_IPP_Service_Payment(); 23 | $this->resource = $this->find($id); 24 | 25 | $this->handleTransactionData($data, $this->resource); 26 | isset($data['Lines']) ? $this->createLines($data['Lines'], $this->resource) : ''; 27 | 28 | return $this->service->update($this->context, $this->realm, $id, $this->resource) ?: $this->service->lastError(); 29 | } 30 | 31 | public function delete($id) 32 | { 33 | $this->service = new \QuickBooks_IPP_Service_Payment(); 34 | return $this->service->delete($this->context, $this->realm, $id); 35 | } 36 | 37 | public function find($id) 38 | { 39 | $this->service = new \QuickBooks_IPP_Service_Payment(); 40 | $query = $this->service->query($this->context, $this->realm, "SELECT * FROM Payment WHERE Id = '$id' "); 41 | if (!empty($query)) { 42 | return $query[0]; 43 | } 44 | return 'Looks like this id does not exist.'; 45 | } 46 | 47 | public function get() 48 | { 49 | $this->service = new \QuickBooks_IPP_Service_Payment(); 50 | return $this->service->query($this->context, $this->realm, "SELECT * FROM Payment"); 51 | } 52 | 53 | public function query($query) 54 | { 55 | $this->service = new \QuickBooks_IPP_Service_Payment(); 56 | 57 | return $this->service->query($this->context, $this->realm, $query); 58 | } 59 | } 60 | -------------------------------------------------------------------------------- /src/Services/Accounting/PaymentMethod.php: -------------------------------------------------------------------------------- 1 | service = new \QuickBooks_IPP_Service_PaymentMethod(); 13 | $this->resource = new \QuickBooks_IPP_Object_PaymentMethod(); 14 | $this->handleTransactionData($data, $this->resource); 15 | isset($data['Lines']) ? $this->createLines($data['Lines'], $this->resource) : ''; 16 | 17 | return $this->service->add($this->context, $this->realm, $this->resource) ?: $this->service->lastError(); 18 | } 19 | 20 | public function update($id, array $data) 21 | { 22 | $this->service = new \QuickBooks_IPP_Service_PaymentMethod(); 23 | $this->resource = $this->find($id); 24 | 25 | $this->handleTransactionData($data, $this->resource); 26 | isset($data['Lines']) ? $this->createLines($data['Lines'], $this->resource) : ''; 27 | 28 | return parent::_update($this->context, $this->realm, \QuickBooks_IPP_IDS::RESOURCE_PAYMENTMETHOD, $this->resource, $id) ?: $this->service->lastError(); 29 | } 30 | 31 | public function delete($id) 32 | { 33 | $this->service = new \QuickBooks_IPP_Service_PaymentMethod(); 34 | return parent::_delete($this->context, $this->realm, \QuickBooks_IPP_IDS::RESOURCE_PAYMENTMETHOD, $id); 35 | } 36 | 37 | public function find($id) 38 | { 39 | $this->service = new \QuickBooks_IPP_Service_PaymentMethod(); 40 | $query = $this->service->query($this->context, $this->realm, "SELECT * FROM PaymentMethod WHERE Id = '$id' "); 41 | if (!empty($query)) { 42 | return $query[0]; 43 | } 44 | return 'Looks like this id does not exist.'; 45 | } 46 | 47 | public function get() 48 | { 49 | $this->service = new \QuickBooks_IPP_Service_PaymentMethod(); 50 | return $this->service->query($this->context, $this->realm, "SELECT * FROM PaymentMethod"); 51 | } 52 | 53 | public function query($query) 54 | { 55 | $this->service = new \QuickBooks_IPP_Service_PaymentMethod(); 56 | 57 | return $this->service->query($this->context, $this->realm, $query); 58 | } 59 | } 60 | -------------------------------------------------------------------------------- /src/Services/Accounting/Purchase.php: -------------------------------------------------------------------------------- 1 | service = new \QuickBooks_IPP_Service_Purchase(); 13 | $this->resource = new \QuickBooks_IPP_Object_Purchase(); 14 | $this->handleTransactionData($data, $this->resource); 15 | isset($data['Lines']) ? $this->createLines($data['Lines'], $this->resource) : ''; 16 | 17 | return $this->service->add($this->context, $this->realm, $this->resource) ?: $this->service->lastError(); 18 | } 19 | 20 | public function update($id, array $data) 21 | { 22 | $this->service = new \QuickBooks_IPP_Service_Purchase(); 23 | $this->resource = $this->find($id); 24 | 25 | $this->handleTransactionData($data, $this->resource); 26 | isset($data['Lines']) ? $this->createLines($data['Lines'], $this->resource) : ''; 27 | 28 | return $this->service->update($this->context, $this->realm, $id, $this->resource) ?: $this->service->lastError(); 29 | } 30 | 31 | public function delete($id) 32 | { 33 | $this->service = new \QuickBooks_IPP_Service_Purchase(); 34 | return parent::_delete($this->context, $this->realm, QuickBooks_IPP_IDS::RESOURCE_PURCHASE, $id); 35 | } 36 | 37 | public function find($id) 38 | { 39 | $this->service = new \QuickBooks_IPP_Service_Purchase(); 40 | $query = $this->service->query($this->context, $this->realm, "SELECT * FROM Purchase WHERE Id = '$id' "); 41 | 42 | if (!empty($query)) { 43 | return $query[0]; 44 | } 45 | return 'Looks like this id does not exist.'; 46 | } 47 | 48 | public function get() 49 | { 50 | $this->service = new \QuickBooks_IPP_Service_Purchase(); 51 | return $this->service->query($this->context, $this->realm, "SELECT * FROM Purchase"); 52 | } 53 | 54 | public function query($query) 55 | { 56 | $this->service = new \QuickBooks_IPP_Service_Purchase(); 57 | 58 | return $this->service->query($this->context, $this->realm, $query); 59 | } 60 | } 61 | -------------------------------------------------------------------------------- /src/Services/Accounting/PurchaseOrder.php: -------------------------------------------------------------------------------- 1 | service = new \QuickBooks_IPP_Service_PurchaseOrder(); 13 | $this->resource = new \QuickBooks_IPP_Object_PurchaseOrder(); 14 | $this->handleTransactionData($data, $this->resource); 15 | isset($data['Lines']) ? $this->createLines($data['Lines'], $this->resource) : ''; 16 | 17 | return $this->service->add($this->context, $this->realm, $this->resource) ?: $this->service->lastError(); 18 | } 19 | 20 | public function update($id, array $data) 21 | { 22 | $this->service = new \QuickBooks_IPP_Service_PurchaseOrder(); 23 | $this->resource = $this->find($id); 24 | 25 | $this->handleTransactionData($data, $this->resource); 26 | isset($data['Lines']) ? $this->createLines($data['Lines'], $this->resource) : ''; 27 | 28 | return $this->service->update($this->context, $this->realm, $id, $this->resource) ?: $this->service->lastError(); 29 | } 30 | 31 | public function delete($id) 32 | { 33 | $this->service = new \QuickBooks_IPP_Service_PurchaseOrder(); 34 | return $this->service->delete($this->context, $this->realm, $id); 35 | } 36 | 37 | public function find($id) 38 | { 39 | $this->service = new \QuickBooks_IPP_Service_PurchaseOrder(); 40 | $query = $this->service->query($this->context, $this->realm, "SELECT * FROM PurchaseOrder WHERE Id = '$id' "); 41 | if (!empty($query)) { 42 | return $query[0]; 43 | } 44 | return 'Looks like this id does not exist.'; 45 | } 46 | 47 | public function get() 48 | { 49 | $this->service = new \QuickBooks_IPP_Service_PurchaseOrder(); 50 | return $this->service->query($this->context, $this->realm, "SELECT * FROM PurchaseOrder"); 51 | } 52 | 53 | public function query($query) 54 | { 55 | $this->service = new \QuickBooks_IPP_Service_PurchaseOrder(); 56 | 57 | return $this->service->query($this->context, $this->realm, $query); 58 | } 59 | } 60 | -------------------------------------------------------------------------------- /src/Services/Accounting/QB_Class.php: -------------------------------------------------------------------------------- 1 | service = new \QuickBooks_IPP_Service_Class(); 13 | $this->resource = new \QuickBooks_IPP_Object_Class(); 14 | $this->handleTransactionData($data, $this->resource); 15 | isset($data['Lines']) ? $this->createLines($data['Lines'], $this->resource) : ''; 16 | 17 | return $this->service->add($this->context, $this->realm, $this->resource) ?: $this->service->lastError(); 18 | } 19 | 20 | public function update($id, array $data) 21 | { 22 | $this->service = new \QuickBooks_IPP_Service_Class(); 23 | $this->resource = $this->find($id); 24 | 25 | $this->handleTransactionData($data, $this->resource); 26 | isset($data['Lines']) ? $this->createLines($data['Lines'], $this->resource) : ''; 27 | 28 | return parent::_update($this->context, $this->realm, \QuickBooks_IPP_IDS::RESOURCE_CLASS, $this->resource, $id) ?: $this->service->lastError(); 29 | } 30 | 31 | public function delete($id) 32 | { 33 | $this->service = new \QuickBooks_IPP_Service_Class(); 34 | return parent::_update($this->context, $this->realm, \QuickBooks_IPP_IDS::RESOURCE_Class, $id); 35 | } 36 | 37 | public function find($id) 38 | { 39 | $this->service = new \QuickBooks_IPP_Service_Class(); 40 | $query = $this->service->query($this->context, $this->realm, "SELECT * FROM Class WHERE Id = '$id' "); 41 | if (!empty($query)) { 42 | return $query[0]; 43 | } 44 | return 'Looks like this id does not exist.'; 45 | } 46 | 47 | public function get() 48 | { 49 | $this->service = new \QuickBooks_IPP_Service_Class(); 50 | return $this->service->query($this->context, $this->realm, "SELECT * FROM Class"); 51 | } 52 | 53 | public function query($query) 54 | { 55 | $this->service = new \QuickBooks_IPP_Service_Class(); 56 | 57 | return $this->service->query($this->context, $this->realm, $query); 58 | } 59 | } 60 | -------------------------------------------------------------------------------- /src/Services/Accounting/RefundReceipt.php: -------------------------------------------------------------------------------- 1 | service = new \QuickBooks_IPP_Service_RefundReceipt(); 13 | $this->resource = new \QuickBooks_IPP_Object_RefundReceipt(); 14 | $this->handleTransactionData($data, $this->resource); 15 | isset($data['Lines']) ? $this->createLines($data['Lines'], $this->resource) : ''; 16 | 17 | return $this->service->add($this->context, $this->realm, $this->resource) ?: $this->service->lastError(); 18 | } 19 | 20 | public function update($id, array $data) 21 | { 22 | $this->service = new \QuickBooks_IPP_Service_RefundReceipt(); 23 | $this->resource = $this->find($id); 24 | 25 | $this->handleTransactionData($data, $this->resource); 26 | isset($data['Lines']) ? $this->createLines($data['Lines'], $this->resource) : ''; 27 | 28 | return parent::_update($this->context, $this->realm, \QuickBooks_IPP_IDS::RESOURCE_REFUNDRECEIPT, $this->resource, $id) ?: $this->service->lastError(); 29 | } 30 | 31 | public function delete($id) 32 | { 33 | $this->service = new \QuickBooks_IPP_Service_RefundReceipt(); 34 | return $this->service->delete($this->context, $this->realm, $id); 35 | } 36 | 37 | public function find($id) 38 | { 39 | $this->service = new \QuickBooks_IPP_Service_RefundReceipt(); 40 | $query = $this->service->query($this->context, $this->realm, "SELECT * FROM RefundReceipt WHERE Id = '$id' "); 41 | if (!empty($query)) { 42 | return $query[0]; 43 | } 44 | return 'Looks like this id does not exist.'; 45 | } 46 | 47 | public function get() 48 | { 49 | $this->service = new \QuickBooks_IPP_Service_RefundReceipt(); 50 | return $this->service->query($this->context, $this->realm, "SELECT * FROM RefundReceipt"); 51 | } 52 | 53 | public function query($query) 54 | { 55 | $this->service = new \QuickBooks_IPP_Service_RefundReceipt(); 56 | 57 | return $this->service->query($this->context, $this->realm, $query); 58 | } 59 | } 60 | -------------------------------------------------------------------------------- /src/Services/Accounting/SalesReceipt.php: -------------------------------------------------------------------------------- 1 | service = new \QuickBooks_IPP_Service_SalesReceipt(); 13 | $this->resource = new \QuickBooks_IPP_Object_SalesReceipt(); 14 | $this->handleTransactionData($data, $this->resource); 15 | isset($data['Lines']) ? $this->createLines($data['Lines'], $this->resource) : ''; 16 | 17 | return $this->service->add($this->context, $this->realm, $this->resource) ?: $this->service->lastError(); 18 | } 19 | 20 | public function update($id, array $data) 21 | { 22 | $this->service = new \QuickBooks_IPP_Service_SalesReceipt(); 23 | $this->resource = $this->find($id); 24 | 25 | $this->handleTransactionData($data, $this->resource); 26 | isset($data['Lines']) ? $this->createLines($data['Lines'], $this->resource) : ''; 27 | 28 | return $this->service->update($this->context, $this->realm, $id, $this->resource) ?: $this->resource->lastError(); 29 | } 30 | 31 | public function delete($id) 32 | { 33 | $this->service = new \QuickBooks_IPP_Service_SalesReceipt(); 34 | return $this->service->delete($this->context, $this->realm, $id); 35 | } 36 | 37 | public function find($id) 38 | { 39 | $this->service = new \QuickBooks_IPP_Service_SalesReceipt(); 40 | $query = $this->service->query($this->context, $this->realm, "SELECT * FROM SalesReceipt WHERE Id = '$id' "); 41 | if (!empty($query)) { 42 | return $query[0]; 43 | } 44 | return 'Looks like this id does not exist.'; 45 | } 46 | 47 | public function get() 48 | { 49 | $this->service = new \QuickBooks_IPP_Service_SalesReceipt(); 50 | return $this->service->query($this->context, $this->realm, "SELECT * FROM SalesReceipt"); 51 | } 52 | 53 | public function query($query) 54 | { 55 | $this->service = new \QuickBooks_IPP_Service_SalesReceipt(); 56 | 57 | return $this->service->query($this->context, $this->realm, $query); 58 | } 59 | } 60 | -------------------------------------------------------------------------------- /src/Services/Accounting/TaxCode.php: -------------------------------------------------------------------------------- 1 | service = new \QuickBooks_Ipp_Service_TaxCode(); 12 | $query = $this->service->query($this->context, $this->realm, "SELECT * FROM TaxCode WHERE Id = '$id' "); 13 | if (!empty($query)) { 14 | return $query[0]; 15 | } 16 | return 'Looks like this id does not exist.'; 17 | } 18 | 19 | public function get() 20 | { 21 | $this->service = new \QuickBooks_Ipp_Service_TaxCode(); 22 | return $this->service->query($this->context, $this->realm, "SELECT * FROM TaxCode") ?: $this->service->lastError(); 23 | } 24 | 25 | public function query($query) 26 | { 27 | $this->service = new \QuickBooks_Ipp_Service_TaxCode(); 28 | 29 | return $this->service->query($this->context, $this->realm, $query); 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /src/Services/Accounting/TaxRate.php: -------------------------------------------------------------------------------- 1 | service = new \QuickBooks_Ipp_Service_TaxRate(); 12 | $query = $this->service->query($this->context, $this->realm, "SELECT * FROM TaxRate WHERE Id = '$id' "); 13 | if (!empty($query)) { 14 | return $query[0]; 15 | } 16 | return 'Looks like this id does not exist.'; 17 | } 18 | 19 | public function get() 20 | { 21 | $this->service = new \QuickBooks_Ipp_Service_TaxRate(); 22 | return $this->service->query($this->context, $this->realm, "SELECT * FROM TaxRate") ?: $this->service->lastError(); 23 | } 24 | 25 | public function query($query) 26 | { 27 | $this->service = new \QuickBooks_Ipp_Service_TaxRate(); 28 | 29 | return $this->service->query($this->context, $this->realm, $query); 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /src/Services/Accounting/Term.php: -------------------------------------------------------------------------------- 1 | service = new \QuickBooks_IPP_Service_Term(); 13 | $this->resource = new \QuickBooks_IPP_Object_Term(); 14 | $this->handleNameListData($data, $this->resource); 15 | isset($data['Lines']) ? $this->createLines($data['Lines'], $this->resource) : ''; 16 | 17 | return $this->service->add($this->context, $this->realm, $this->resource) ?: $this->service->lastError(); 18 | } 19 | 20 | public function update($id, array $data) 21 | { 22 | $this->service = new \QuickBooks_IPP_Service_Term(); 23 | $this->resource = $this->find($id); 24 | 25 | $this->handleNameListData($data, $this->resource); 26 | isset($data['Lines']) ? $this->createLines($data['Lines'], $this->resource) : ''; 27 | 28 | return parent::_update($this->context, $this->realm, \QuickBooks_IPP_IDS::RESOURCE_TERM, $this->resource, $id) ?: $this->service->lastError(); 29 | } 30 | 31 | public function delete($id) 32 | { 33 | $this->service = new \QuickBooks_IPP_Service_Term(); 34 | return parent::_delete($this->context, $this->realm, \QuickBooks_IPP_IDS::RESOURCE_TERM, $id); 35 | } 36 | 37 | public function find($id) 38 | { 39 | $this->service = new \QuickBooks_IPP_Service_Term(); 40 | $query = $this->service->query($this->context, $this->realm, "SELECT * FROM Term WHERE Id = '$id' "); 41 | if (!empty($query)) { 42 | return $query[0]; 43 | } 44 | return 'Looks like this id does not exist.'; 45 | } 46 | 47 | public function get() 48 | { 49 | $this->service = new \QuickBooks_IPP_Service_Term(); 50 | return $this->service->query($this->context, $this->realm, "SELECT * FROM Term"); 51 | } 52 | 53 | public function query($query) 54 | { 55 | $this->service = new \QuickBooks_IPP_Service_Term(); 56 | 57 | return $this->service->query($this->context, $this->realm, $query); 58 | } 59 | } 60 | -------------------------------------------------------------------------------- /src/Services/Accounting/TimeActivity.php: -------------------------------------------------------------------------------- 1 | service = new \QuickBooks_IPP_Service_TimeActivity(); 13 | $this->resource = new \QuickBooks_IPP_Object_TimeActivity(); 14 | $this->handleTransactionData($data, $this->resource); 15 | isset($data['Lines']) ? $this->createLines($data['Lines'], $this->resource) : ''; 16 | 17 | return $this->service->add($this->context, $this->realm, $this->resource) ?: $this->service->lastError(); 18 | } 19 | 20 | public function update($id, array $data) 21 | { 22 | $this->service = new \QuickBooks_IPP_Service_TimeActivity(); 23 | $this->resource = $this->find($id); 24 | 25 | $this->handleTransactionData($data, $this->resource); 26 | isset($data['Lines']) ? $this->createLines($data['Lines'], $this->resource) : ''; 27 | 28 | return $this->service->update($this->context, $this->realm, $id, $this->resource) ?: $this->service->lastError(); 29 | } 30 | 31 | public function delete($id) 32 | { 33 | $this->service = new \QuickBooks_IPP_Service_TimeActivity(); 34 | return $this->service->delete($this->context, $this->realm, $id); 35 | } 36 | 37 | public function find($id) 38 | { 39 | $this->service = new \QuickBooks_IPP_Service_TimeActivity(); 40 | $query = $this->service->query($this->context, $this->realm, "SELECT * FROM TimeActivity WHERE Id = '$id' "); 41 | if (!empty($query)) { 42 | return $query[0]; 43 | } 44 | return 'Looks like this id does not exist.'; 45 | } 46 | 47 | public function get() 48 | { 49 | $this->service = new \QuickBooks_IPP_Service_TimeActivity(); 50 | return $this->service->query($this->context, $this->realm, "SELECT * FROM TimeActivity"); 51 | } 52 | 53 | public function query($query) 54 | { 55 | $this->service = new \QuickBooks_IPP_Service_TimeActivity(); 56 | 57 | return $this->service->query($this->context, $this->realm, $query); 58 | } 59 | } 60 | -------------------------------------------------------------------------------- /src/Services/Accounting/Vendor.php: -------------------------------------------------------------------------------- 1 | service = new \QuickBooks_IPP_Service_Vendor(); 13 | $this->resource = new \QuickBooks_IPP_Object_Vendor(); 14 | $this->handleNameListData($data, $this->resource); 15 | isset($data['Lines']) ? $this->createLines($data['Lines'], $this->resource) : ''; 16 | 17 | return $this->service->add($this->context, $this->realm, $this->resource) ?: $this->service->lastError(); 18 | } 19 | 20 | public function update($id, array $data) 21 | { 22 | $this->service = new \QuickBooks_IPP_Service_Vendor(); 23 | $this->resource = $this->find($id); 24 | 25 | $this->handleNameListData($data, $this->resource); 26 | isset($data['Lines']) ? $this->createLines($data['Lines'], $this->resource) : ''; 27 | 28 | return parent::_update($this->context, $this->realm, \QuickBooks_IPP_IDS::RESOURCE_VENDOR, $this->resource, $id) ?: $this->service->lastError(); 29 | } 30 | 31 | public function delete($id) 32 | { 33 | $this->service = new \QuickBooks_IPP_Service_Vendor(); 34 | return parent::_delete($this->context, $this->realm, \QuickBooks_IPP_IDS::RESOURCE_VENDOR, $id); 35 | } 36 | 37 | public function find($id) 38 | { 39 | $this->service = new \QuickBooks_IPP_Service_Vendor(); 40 | $query = $this->service->query($this->context, $this->realm, "SELECT * FROM Vendor WHERE Id = '$id' "); 41 | if (!empty($query)) { 42 | return $query[0]; 43 | } 44 | return 'Looks like this id does not exist.'; 45 | } 46 | 47 | public function get() 48 | { 49 | $this->service = new \QuickBooks_IPP_Service_Vendor(); 50 | return $this->service->query($this->context, $this->realm, "SELECT * FROM Vendor"); 51 | } 52 | 53 | public function query($query) 54 | { 55 | $this->service = new \QuickBooks_IPP_Service_Vendor(); 56 | 57 | return $this->service->query($this->context, $this->realm, $query); 58 | } 59 | } 60 | -------------------------------------------------------------------------------- /src/Services/Accounting/VendorCredit.php: -------------------------------------------------------------------------------- 1 | service = new \QuickBooks_IPP_Service_VendorCredit(); 13 | $this->resource = new \QuickBooks_IPP_Object_VendorCredit(); 14 | $this->handleTransactionData($data, $this->resource); 15 | isset($data['Lines']) ? $this->createLines($data['Lines'], $this->resource) : ''; 16 | 17 | return $this->service->add($this->context, $this->realm, $this->resource) ?: $this->service->lastError(); 18 | } 19 | 20 | public function update($id, array $data) 21 | { 22 | $this->service = new \QuickBooks_IPP_Service_VendorCredit(); 23 | $this->resource = $this->find($id); 24 | 25 | $this->handleTransactionData($data, $this->resource); 26 | isset($data['Lines']) ? $this->createLines($data['Lines'], $this->resource) : ''; 27 | 28 | $this->service->update($this->context, $this->realm, $id, $this->resource) ?: $this->service->lastError(); 29 | } 30 | 31 | public function delete($id) 32 | { 33 | $this->service = new \QuickBooks_IPP_Service_VendorCredit(); 34 | return $this->service->delete($this->context, $this->realm, $id); 35 | } 36 | 37 | public function find($id) 38 | { 39 | $this->service = new \QuickBooks_IPP_Service_VendorCredit(); 40 | $query = $this->service->query($this->context, $this->realm, "SELECT * FROM VendorCredit WHERE Id = '$id' "); 41 | if (!empty($query)) { 42 | return $query[0]; 43 | } 44 | return 'Looks like this id does not exist.'; 45 | } 46 | 47 | public function get() 48 | { 49 | $this->service = new \QuickBooks_IPP_Service_VendorCredit(); 50 | return $this->service->query($this->context, $this->realm, "SELECT * FROM VendorCredit"); 51 | } 52 | 53 | public function query($query) 54 | { 55 | $this->service = new \QuickBooks_IPP_Service_VendorCredit(); 56 | 57 | return $this->service->query($this->context, $this->realm, $query); 58 | } 59 | } 60 | -------------------------------------------------------------------------------- /src/Services/Connection.php: -------------------------------------------------------------------------------- 1 | IntuitAnywhere->handle($this->config['the_username'], $this->config['the_tenant'])) { 15 | ; // The user has been connected, and will be redirected to QBO_SUCCESS_URL automatically. 16 | } else { 17 | // If obj happens, something went wrong with the OAuth handshake 18 | die('Oh no, something went wrong with the Oauth handshake: ' . $this->IntuitAnywhere->errorNumber() . ': ' . $this->IntuitAnywhere->errorMessage()); 19 | } 20 | } 21 | 22 | /** 23 | * Disconnects from QuickBooks 24 | */ 25 | public function stop() 26 | { 27 | $this->IntuitAnywhere->disconnect($this->config['the_username'], $this->config['the_tenant'], true); 28 | } 29 | /** 30 | * Checks if Quickbooks is connected 31 | * @return boolean 32 | */ 33 | public function check() 34 | { 35 | return $this->IntuitAnywhere->check($this->config['the_username'], $this->config['the_tenant']); 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /src/config/QuickBooks.php: -------------------------------------------------------------------------------- 1 | env('QB_DSN'), 7 | 'encryption_key' => env('APP_KEY'), 8 | 'sandbox' => env('QBO_SANDBOX'), 9 | 'token' => env('QB_TOKEN'), 10 | 'oauth_consumer_key' => env('QB_OAUTH_CONSUMER_KEY'), 11 | 'oauth_consumer_secret' => env('QB_OAUTH_CONSUMER_SECRET'), 12 | 'quickbooks_oauth_url' => env('QB_OAUTH_URL'), 13 | 'quickbooks_success_url' => env('QB_SUCCESS_URL'), 14 | 'the_username' => env('QB_USERNAME'), 15 | 'the_tenant' => env('QB_TENANT') 16 | 17 | ]; 18 | --------------------------------------------------------------------------------