|
7 | 7 | use QuickBooksOnline\API\DataService\DataService;
|
8 | 8 | use QuickBooksOnline\API\PlatformService\PlatformService;
|
9 | 9 | use QuickBooksOnline\API\Core\Http\Serialization\XmlObjectSerializer;
|
10 |
| -use QuickBooksOnline\API\Data\IPPTaxRateDetails; |
11 |
| -use QuickBooksOnline\API\Data\IPPTaxService; |
| 10 | +use QuickBooksOnline\API\Facades\TaxService; |
| 11 | +use QuickBooksOnline\API\Facades\TaxRate; |
| 12 | + |
12 | 13 |
|
13 | 14 | // Prep Data Services
|
14 | 15 | $dataService = DataService::Configure(array(
|
|
23 | 24 |
|
24 | 25 | $dataService->setLogLocation("/Users/hlu2/Desktop/newFolderForLog");
|
25 | 26 |
|
| 27 | +$TaxRateDetails = array(); |
26 | 28 | $rnd = rand();
|
27 |
| -$taxRateDetails = new IPPTaxRateDetails(); |
28 |
| -$taxRateDetails->TaxRateName = "myNewTaxRateName_$rnd"; |
29 |
| -$taxRateDetails->RateValue = "7777";//As Invalid number |
30 |
| -$taxRateDetails->TaxAgencyId = "1"; |
31 |
| -$taxRateDetails->TaxApplicableOn = "Sales"; |
32 |
| - |
33 |
| -$taxService = new IPPTaxService(); |
34 |
| -$taxService->TaxCode = 'MyTaxCodeName_' . $rnd; |
35 |
| -$taxService->TaxRateDetails = array($taxRateDetails); |
| 29 | +for($int = 1; $int <=2 ; $int++){ |
| 30 | + $rateValue = $int + 5; |
| 31 | + $currentTaxServiceDetail = TaxRate::create([ |
| 32 | + "TaxRateName" => "myNewTaxRateName_" . $int . "_$rnd", |
| 33 | + "RateValue" => $rateValue, |
| 34 | + "TaxAgencyId" => "1", |
| 35 | + "TaxApplicableOn" => "Sales" |
| 36 | + ]); |
| 37 | + $TaxRateDetails[] = $currentTaxServiceDetail; |
| 38 | +} |
36 | 39 |
|
| 40 | +$TaxService = TaxService::create([ |
| 41 | + "TaxCode" => "TestValue_$rnd", |
| 42 | + "TaxRateDetails" => $TaxRateDetails |
| 43 | +]); |
37 | 44 |
|
38 |
| -$result = $dataService->Add($taxService); |
| 45 | +var_dump($TaxService); |
| 46 | +$result = $dataService->Add($TaxService); |
39 | 47 | $error = $dataService->getLastError();
|
40 | 48 | if ($error != null) {
|
41 | 49 | echo "The Status code is: " . $error->getHttpStatusCode() . "\n";
|
|
45 | 53 | }
|
46 | 54 |
|
47 | 55 |
|
48 |
| -print_r($result); |
| 56 | +print_r($result->TaxService->TaxCodeId); |
49 | 57 |
|
50 | 58 |
|
51 | 59 |
|
|
0 commit comments