UnleashedOrderTest   A
last analyzed

Complexity

Total Complexity 11

Size/Duplication

Total Lines 410
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 275
dl 0
loc 410
rs 10
c 1
b 0
f 0
wmc 11

11 Methods

Rating   Name   Duplication   Size   Complexity  
A testSetBodyCustomerCodeAndName() 0 20 1
A testSetBodyCurrencyCode() 0 13 1
A testSetBodyAddress() 0 34 1
A testSetBodySalesOrderLinesWithModifiers() 0 37 1
A testSetBodyDeliveryMethodAndDeliveryName() 0 13 1
A testSetBodySalesOrderLines() 0 31 1
A testChangeOrderStatus() 0 36 1
A testSetBodySubTotalAndTax() 0 41 1
A setUp() 0 17 1
A testTaxRounding2() 0 58 1
A testTaxRounding() 0 47 1
1
<?php
2
3
namespace AntonyThorpe\SilverShopUnleashed\Tests;
4
5
use SilverShop\Shipping\ShippingFrameworkModifier;
0 ignored issues
show
Bug introduced by
The type SilverShop\Shipping\ShippingFrameworkModifier was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
6
use AntonyThorpe\SilverShopUnleashed\BulkLoader\OrderBulkLoader;
7
use AntonyThorpe\SilverShopUnleashed\Defaults;
8
use SilverShop\Cart\ShoppingCart;
0 ignored issues
show
Bug introduced by
The type SilverShop\Cart\ShoppingCart was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
9
use SilverShop\Checkout\OrderProcessor;
0 ignored issues
show
Bug introduced by
The type SilverShop\Checkout\OrderProcessor was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
10
use SilverShop\Model\Modifiers\OrderModifier;
0 ignored issues
show
Bug introduced by
The type SilverShop\Model\Modifiers\OrderModifier was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
11
use SilverShop\Model\Modifiers\Shipping\Simple;
0 ignored issues
show
Bug introduced by
The type SilverShop\Model\Modifiers\Shipping\Simple was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
12
use SilverShop\Model\Modifiers\Tax\FlatTax;
0 ignored issues
show
Bug introduced by
The type SilverShop\Model\Modifiers\Tax\FlatTax was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
13
use SilverShop\Model\Order;
0 ignored issues
show
Bug introduced by
The type SilverShop\Model\Order was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
14
use SilverShop\Model\Product\OrderItem;
0 ignored issues
show
Bug introduced by
The type SilverShop\Model\Product\OrderItem was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
15
use SilverShop\Page\Product;
0 ignored issues
show
Bug introduced by
The type SilverShop\Page\Product was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
16
use SilverShop\Shipping\Model\DistanceShippingMethod;
0 ignored issues
show
Bug introduced by
The type SilverShop\Shipping\Model\DistanceShippingMethod was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
17
use SilverShop\Tests\ShopTest;
0 ignored issues
show
Bug introduced by
The type SilverShop\Tests\ShopTest was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
18
use SilverStripe\Core\Config\Config;
0 ignored issues
show
Bug introduced by
The type SilverStripe\Core\Config\Config was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
19
use SilverStripe\Dev\SapphireTest;
0 ignored issues
show
Bug introduced by
The type SilverStripe\Dev\SapphireTest was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
20
21
class UnleashedOrderTest extends SapphireTest
22
{
23
    protected static $fixture_file = [
24
        'vendor/silvershop/core/tests/php/Fixtures/ShopMembers.yml',
25
        'vendor/silvershop/core/tests/php/Fixtures/shop.yml',
26
        'vendor/silvershop/shipping/tests/DistanceShippingMethod.yml',
27
        'vendor/silvershop/shipping/tests/Warehouses.yml',
28
        'fixtures/models.yml'
29
    ];
30
31
    public function setUp(): void
32
    {
33
        Defaults::config()->send_sales_orders_to_unleashed = false;
34
        Defaults::config()->tax_modifier_class_name = FlatTax::class;
35
        Defaults::config()->shipping_modifier_class_name = Simple::class;
36
        parent::setUp();
37
        ShoppingCart::singleton()->clear();
38
        ShopTest::setConfiguration(); //reset config
39
        $this->logInWithPermission('ADMIN');
40
        Config::modify()
41
            ->set(Simple::class, 'default_charge', 8.95)
42
            ->set(Simple::class, 'product_code', 'Freight')
43
            ->set(FlatTax::class, 'rate', 0.15)
44
            ->set(FlatTax::class, 'exclusive', true)
45
            ->set(FlatTax::class, 'name', 'GST')
46
            ->set(FlatTax::class, 'tax_code', 'OUTPUT2')
47
            ->merge(Order::class, 'modifiers', [Simple::class, FlatTax::class]);
48
    }
49
50
    protected array $order_status_map = [
51
        'Open' => 'Unpaid',
52
        'Parked' => 'Paid',
53
        'Backordered' => 'Processing',
54
        'Placed' => 'Processing',
55
        'Picking' => 'Processing',
56
        'Picked' => 'Processing',
57
        'Packed' => 'Processing',
58
        'Dispatched' => 'Sent',
59
        'Complete' => 'Complete',
60
        'Deleted' => 'MemberCancelled'
61
    ];
62
63
    public function testChangeOrderStatus(): void
64
    {
65
        $apidata_array = (array) json_decode($this->jsondata, true);
66
        $apidata_array = reset($apidata_array);
67
        $items = $apidata_array['Items'];
68
69
        $loader = OrderBulkLoader::create(Order::class);
70
        $loader->transforms = [
71
            'Status' => [
72
                'callback' => fn($value, &$placeholder) =>
0 ignored issues
show
Unused Code introduced by
The parameter $placeholder is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

72
                'callback' => fn($value, /** @scrutinizer ignore-unused */ &$placeholder) =>

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
73
                    // convert from Unleashed Sales Order status to Silvershop
74
                    $this->order_status_map[$value]
75
            ]
76
        ];
77
        $results = $loader->updateRecords($items);
78
79
        // Check Results
80
        $this->assertEquals($results->CreatedCount(), 0);
81
        $this->assertEquals($results->UpdatedCount(), 2);
82
        $this->assertEquals($results->DeletedCount(), 0);
83
        $this->assertEquals($results->SkippedCount(), 0);
84
        $this->assertEquals($results->Count(), 2);
85
86
        // Check Dataobjects
87
        $order1 = Order::get()->find('Reference', 'O1');
88
        $this->assertEquals(
89
            'Processing',
90
            $order1->Status,
91
            'OrderStatus of reference O1 is "Processing"'
92
        );
93
94
        $order2 = Order::get()->find('Reference', 'O2');
95
        $this->assertEquals(
96
            'Sent',
97
            $order2->Status,
98
            'OrderStatus of reference O1 is "Sent"'
99
        );
100
    }
101
102
    public function testSetBodyAddress(): void
103
    {
104
        $body = [
105
            'Addresses' => []
106
        ];
107
        $order = $this->objFromFixture(Order::class, "payablecart");
108
        OrderProcessor::create($order)->placeOrder();
109
        $body = $order->setBodyAddress($body, $order, 'Postal');
110
        $result = implode('|', array_values($body['Addresses'][0]));
111
        $this->assertSame(
112
            $result,
113
            '12 Foo Street Bar Farmville|Postal|Farmville|United States||New Sandwich|12 Foo Street|Bar',
114
            'Postal Address added to $body["Address"]'
115
        );
116
117
        $body = $order->setBodyAddress($body, $order, 'Physical');
118
        $result = implode('|', array_values($body['Addresses'][1]));
119
        $this->assertSame(
120
            $result,
121
            '12 Foo Street Bar Farmville|Physical|Farmville|United States||New Sandwich|12 Foo Street|Bar',
122
            'Physical Address added to $body["Address"]'
123
        );
124
        $result = implode('|', array_values($body['Addresses'][2]));
125
        $this->assertSame(
126
            $result,
127
            '12 Foo Street Bar Farmville|Shipping|Farmville|United States||New Sandwich|12 Foo Street|Bar',
128
            'Shipping Address added to $body["Address"]'
129
        );
130
131
        $result = $body['DeliveryCity'] . '|' . $body['DeliveryCountry'] . '|' . $body['DeliveryPostCode'] . '|' . $body['DeliveryRegion'] . '|' . $body['DeliveryStreetAddress'] . '|' . $body['DeliveryStreetAddress2'];
132
        $this->assertSame(
133
            $result,
134
            'Farmville|United States||New Sandwich|12 Foo Street|Bar',
135
            'Delivery Address added to $body'
136
        );
137
    }
138
139
    public function testSetBodyCurrencyCode(): void
140
    {
141
        $body = [
142
            'Currency' => []
143
        ];
144
        $order = $this->objFromFixture(Order::class, "payablecart");
145
        OrderProcessor::create($order)->placeOrder();
146
        $body = $order->setBodyCurrencyCode($body, $order);
147
148
        $this->assertSame(
149
            'NZD',
150
            $body['Currency']['CurrencyCode'],
151
            'Currency Code added to $body'
152
        );
153
    }
154
155
    public function testSetBodyCustomerCodeAndName(): void
156
    {
157
        $body = [];
158
        $order = $this->objFromFixture(Order::class, "payablecart");
159
        OrderProcessor::create($order)->placeOrder();
160
        $body = $order->setBodyCustomerCodeAndName($body, $order);
161
        $result = implode('|', array_values($body));
162
        $this->assertSame(
163
            $result,
164
            'Payable Smith|Payable Smith',
165
            'Set BodyCustomerCodeAndName'
166
        );
167
168
        $order->BillingAddress()->Company = 'Test Company';
169
        $body = $order->setBodyCustomerCodeAndName($body, $order);
170
        $result = implode('|', array_values($body));
171
        $this->assertSame(
172
            $result,
173
            'Test Company|Test Company',
174
            'Set BodyCustomerCodeAndName with Company name'
175
        );
176
    }
177
178
    public function testSetBodySalesOrderLines(): void
179
    {
180
        $order = $this->objFromFixture(Order::class, "paid1");
181
        OrderProcessor::create($order)->placeOrder();
182
        $this->assertEquals(408, $order->Total(), "check totals");
183
        $body = $order->setBodySalesOrderLines(
184
            [
185
                'Tax' => [
186
                    'TaxCode' => 'OUTPUT2'
187
                ]
188
            ],
189
            $order,
190
            FlatTax::class,
191
            2
192
        );
193
        $result = (string) json_encode($body, JSON_HEX_QUOT | JSON_HEX_TAG);
194
        $this->assertStringContainsString(
195
            'SalesOrderLines',
196
            $result,
197
            'Contains SalesOrderLines'
198
        );
199
        $this->assertStringContainsString(
200
            '"LineType":null,"LineTotal":8,"OrderQuantity":1,"Product":{"Guid":"G11"},"UnitPrice":8,"LineTax":1.2,"LineTaxCode":"OUTPUT2"}',
201
            $result,
202
            'Set SetBodySalesOrderLines line 1',
203
        );
204
205
        $this->assertStringContainsString(
206
            '"LineType":null,"LineTotal":400,"OrderQuantity":2,"Product":{"Guid":"G15"},"UnitPrice":200,"LineTax":60,"LineTaxCode":"OUTPUT2"}',
207
            $result,
208
            'Set SetBodySalesOrderLines line 2'
209
        );
210
    }
211
212
    public function testSetBodySalesOrderLinesWithModifiers(): void
213
    {
214
        $urntap = $this->objFromFixture(Product::class, 'urntap');
215
        $urntap->publishSingle();
216
        $cart = ShoppingCart::singleton();
217
        $cart->clear();
218
        $cart->add($urntap);
219
        $order = $cart->current();
220
        $order->calculate();
221
222
        $this->assertEquals(
223
            2,
224
            $order->Modifiers()->count(),
225
            'Shipping & Tax Modifiers in order'
226
        );
227
        $body = $order->setBodySalesOrderLines(
228
            [
229
                'Tax' => [
230
                    'TaxCode' => 'OUTPUT2'
231
                ]
232
            ],
233
            $order,
234
            FlatTax::class,
235
            2
236
        );
237
        $freight_modifier = $body['SalesOrderLines'][1];
238
        $result = $freight_modifier['DiscountRate'] . '|' . $freight_modifier['LineNumber'] . '|' . $freight_modifier['LineTotal'] . '|' . $freight_modifier['LineType'] . '|' . $freight_modifier['OrderQuantity'] . '|' . $freight_modifier['UnitPrice'] . '|' . $freight_modifier['LineTax'] . '|' . $freight_modifier['LineTaxCode'];
239
240
        $this->assertSame(
241
            $result,
242
            '0|2|8.95||1|8.95|1.34|OUTPUT2',
243
            'Modifiers in the SalesOrderLines added to $body'
244
        );
245
        $this->assertSame(
246
            $freight_modifier['Product']['ProductCode'],
247
            'Freight',
248
            'ProductCode of the Freight Modifier in $body is "Freight"'
249
        );
250
    }
251
252
    public function testSetBodySubTotalAndTax(): void
253
    {
254
        $urntap = $this->objFromFixture(Product::class, 'urntap');
255
        $urntap->publishSingle();
256
        $cart = ShoppingCart::singleton();
257
        $cart->clear();
258
        $cart->add($urntap);
259
        $order = $cart->current();
260
        $order->calculate();
261
262
        $body = $order->setBodyTaxCode(
263
            [],
264
            $order,
265
            FlatTax::class
266
        );
267
        $body = $order->setBodySalesOrderLines(
268
            $body,
269
            $order,
270
            FlatTax::class,
271
            2
272
        );
273
        $body = $order->setBodySubTotalAndTax(
274
            $body,
275
            $order,
276
            FlatTax::class,
277
            2
278
        );
279
280
        $this->assertTrue(
281
            $body['Taxable'],
282
            'Taxable is set to true'
283
        );
284
        $this->assertEquals(
285
            $body['TaxTotal'],
286
            11.19,
287
            'TaxTotal is set to $11.19 ((65.65 + 8.95) * .15) in $body'
288
        );
289
        $this->assertEquals(
290
            $body['SubTotal'],
291
            74.60,
292
            'SubTotal is set to $74.60 (65.65 + 8.95) in $body'
293
        );
294
    }
295
296
    public function testTaxRounding(): void
297
    {
298
        $filter = $this->objFromFixture(Product::class, 'filter');
299
        $filter->publishSingle();
300
        $tax_modifier_class_name = FlatTax::class;
301
        $cart = ShoppingCart::singleton();
302
        $cart->clear();
303
        $cart->add($filter);
304
        $order = $cart->current();
305
        $total = $order->calculate();
306
307
        $body = $order->setBodyTaxCode(
308
            [],
309
            $order,
310
            $tax_modifier_class_name
311
        );
312
        $body = $order->setBodySalesOrderLines(
313
            $body,
314
            $order,
315
            $tax_modifier_class_name,
316
            2
317
        );
318
        $body = $order->setBodySubTotalAndTax(
319
            $body,
320
            $order,
321
            $tax_modifier_class_name,
322
            2
323
        );
324
        $this->assertEquals(
325
            $body['TaxTotal'],
326
            '8.39',
327
            'TaxTotal is set to $8.39 ((46.96 + 8.95) * .15) in $body'
328
        );
329
        $this->assertEquals(
330
            $body['SubTotal'],
331
            '55.91',
332
            'SubTotal is set to $55.91 (46.96 + 8.95) in $body'
333
        );
334
        $this->assertEquals(
335
            round($total, 2),
336
            64.3,
337
            'Total equals $64.30'
338
        );
339
        $this->assertEquals(
340
            round(floatval($body['TaxTotal'] + $body['SubTotal']), 2),
341
            64.3,
342
            'TaxTotal plus SubTotal equals $64.30'
343
        );
344
    }
345
346
    public function testTaxRounding2(): void
347
    {
348
        ShopTest::setConfiguration(); //reset config
349
        $this->logInWithPermission('ADMIN');
350
        Config::modify()
351
            ->set(Simple::class, 'default_charge', 15.50)
352
            ->set(Simple::class, 'product_code', 'Freight')
353
            ->set(FlatTax::class, 'rate', 0.15)
354
            ->set(FlatTax::class, 'exclusive', true)
355
            ->set(FlatTax::class, 'name', 'GST')
356
            ->set(FlatTax::class, 'tax_code', 'OUTPUT2')
357
            ->merge(Order::class, 'modifiers', [Simple::class, FlatTax::class]);
358
        $boiler = $this->objFromFixture(Product::class, 'boiler');
359
        $boiler->publishSingle();
360
        $tax_modifier_class_name = FlatTax::class;
361
        $cart = ShoppingCart::singleton();
362
        $cart->clear();
363
        $cart->add($boiler);
364
        $order = $cart->current();
365
        $total = $order->calculate();
366
367
        $body = $order->setBodyTaxCode(
368
            [],
369
            $order,
370
            $tax_modifier_class_name
371
        );
372
        $body = $order->setBodySalesOrderLines(
373
            $body,
374
            $order,
375
            $tax_modifier_class_name,
376
            2
377
        );
378
        $body = $order->setBodySubTotalAndTax(
379
            $body,
380
            $order,
381
            $tax_modifier_class_name,
382
            2
383
        );
384
385
        $this->assertEquals(
386
            $body['TaxTotal'],
387
            '139.15',
388
            'TaxTotal is set to $139.15 ((912.17 + 15.50) * .15) in $body'
389
        );
390
        $this->assertEquals(
391
            $body['SubTotal'],
392
            '927.67',
393
            'SubTotal is set to $927.67 (912.17 + 15.50) in $body'
394
        );
395
        $this->assertEquals(
396
            round($total, 2),
397
            1066.82,
398
            'Total equals $1,066.82'
399
        );
400
        $this->assertEquals(
401
            round(floatval($body['TaxTotal'] + $body['SubTotal']), 2),
402
            1066.82,
403
            'TaxTotal plus SubTotal equals $1,066.82'
404
        );
405
    }
406
407
408
    public function testSetBodyDeliveryMethodAndDeliveryName(): void
409
    {
410
        Defaults::config()->set('shipping_modifier_class_name', ShippingFrameworkModifier::class);
411
        Config::modify()->set(ShippingFrameworkModifier::class, 'product_code', 'Freight');
412
        $body = [];
413
        $defaults = Defaults::config();
414
        $order = $this->objFromFixture(Order::class, "payablecart");
415
        $body = $order->setBodyDeliveryMethodAndDeliveryName($body, $order, $defaults->get('shipping_modifier_class_name'));
416
        $result = implode('|', array_values($body));
417
        $this->assertSame(
418
            $result,
419
            'Freight|Freight',
420
            'Set BodyDeliveryMethodAndDeliveryName'
421
        );
422
    }
423
424
    /**
425
     * JSON data for test
426
     *
427
     * @link (Unleashed Software API Documentation, https://apidocs.unleashedsoftware.com/Products)
428
     * @var string
429
     */
430
    protected $jsondata = '[
431
        {
432
          "Pagination": {
433
            "NumberOfItems": 2,
434
            "PageSize": 200,
435
            "PageNumber": 1,
436
            "NumberOfPages": 1
437
          },
438
          "Items": [
439
            {
440
              "SalesOrderLines": [
441
                {
442
                  "LineNumber": 1,
443
                  "LineType": null,
444
                  "Product": {
445
                    "Guid": "G11",
446
                    "ProductCode": "IIID1",
447
                    "ProductDescription": "Socks"
448
                  },
449
                  "DueDate": "/Date(1473099415000)/",
450
                  "OrderQuantity": 1,
451
                  "UnitPrice": 8,
452
                  "DiscountRate": 0,
453
                  "LineTotal": 8,
454
                  "Volume": null,
455
                  "Weight": null,
456
                  "Comments": null,
457
                  "AverageLandedPriceAtTimeOfSale": 8,
458
                  "TaxRate": 0,
459
                  "LineTax": 0,
460
                  "XeroTaxCode": "G.S.T.",
461
                  "BCUnitPrice": 8,
462
                  "BCLineTotal": 8,
463
                  "BCLineTax": 0,
464
                  "LineTaxCode": "G.S.T.",
465
                  "XeroSalesAccount": null,
466
                  "SerialNumbers": null,
467
                  "BatchNumbers": null,
468
                  "Guid": "G401",
469
                  "LastModifiedOn": "/Date(1473149768263)/"
470
                },
471
                {
472
                  "LineNumber": 2,
473
                  "LineType": null,
474
                  "Product": {
475
                    "Guid": "G15",
476
                    "ProductCode": "IIID5",
477
                    "ProductDescription": "Mp3 Player"
478
                  },
479
                  "DueDate": "/Date(1473099415000)/",
480
                  "OrderQuantity": 2,
481
                  "UnitPrice": 200,
482
                  "DiscountRate": 0,
483
                  "LineTotal": 400,
484
                  "Volume": null,
485
                  "Weight": null,
486
                  "Comments": null,
487
                  "AverageLandedPriceAtTimeOfSale": 200,
488
                  "TaxRate": 0,
489
                  "LineTax": 0,
490
                  "XeroTaxCode": "G.S.T.",
491
                  "BCUnitPrice": 200,
492
                  "BCLineTotal": 400,
493
                  "BCLineTax": 0,
494
                  "LineTaxCode": "G.S.T.",
495
                  "XeroSalesAccount": null,
496
                  "SerialNumbers": null,
497
                  "BatchNumbers": null,
498
                  "Guid": "G402",
499
                  "LastModifiedOn": "/Date(1473149768279)/"
500
                }
501
              ],
502
              "OrderNumber": "O1",
503
              "OrderDate": "/Date(1473116400000)/",
504
              "RequiredDate": "/Date(1473548400000)/",
505
              "OrderStatus": "Placed",
506
              "Customer": {
507
                "CustomerCode": "Jeremy Peremy",
508
                "CustomerName": "Jeremy Peremy",
509
                "CurrencyId": 110,
510
                "Guid": "test",
511
                "LastModifiedOn": "/Date(1472624588017)/"
512
              },
513
              "CustomerRef": null,
514
              "Comments": "Test",
515
              "Warehouse": {
516
                "WarehouseCode": "test",
517
                "WarehouseName": "Queen St",
518
                "IsDefault": true,
519
                "StreetNo": "1",
520
                "AddressLine1": "Queen St",
521
                "AddressLine2": null,
522
                "City": "Invercargill",
523
                "Region": "Southland",
524
                "Country": "New Zealand",
525
                "PostCode": "9999",
526
                "PhoneNumber": "1234 567",
527
                "FaxNumber": null,
528
                "MobileNumber": null,
529
                "DDINumber": null,
530
                "ContactName": "Ed Hillary",
531
                "Obsolete": false,
532
                "Guid": "test",
533
                "LastModifiedOn": "/Date(1471582972964)/"
534
              },
535
              "ReceivedDate": "/Date(1473099415000)/",
536
              "DeliveryName": null,
537
              "DeliveryStreetAddress": "15 Ray St",
538
              "DeliverySuburb": "",
539
              "DeliveryCity": "Kaitaia",
540
              "DeliveryRegion": "Northland",
541
              "DeliveryCountry": "New Zealand",
542
              "DeliveryPostCode": "1111",
543
              "Currency": {
544
                "CurrencyCode": "NZD",
545
                "Description": "New Zealand, Dollars",
546
                "Guid": "test",
547
                "LastModifiedOn": "/Date(1415058050647)/"
548
              },
549
              "ExchangeRate": 1,
550
              "DiscountRate": 0,
551
              "Tax": {
552
                "TaxCode": "G.S.T.",
553
                "Description": null,
554
                "TaxRate": 0,
555
                "CanApplyToExpenses": false,
556
                "CanApplyToRevenue": false,
557
                "Obsolete": false,
558
                "Guid": "00000000-0000-0000-0000-000000000000",
559
                "LastModifiedOn": null
560
              },
561
              "TaxRate": 0,
562
              "XeroTaxCode": "G.S.T.",
563
              "SubTotal": 408,
564
              "TaxTotal": 0,
565
              "Total": 408,
566
              "TotalVolume": 0,
567
              "TotalWeight": 0,
568
              "BCSubTotal": 408,
569
              "BCTaxTotal": 0,
570
              "BCTotal": 408,
571
              "PaymentDueDate": "/Date(1473106568169)/",
572
              "SalesOrderGroup": null,
573
              "DeliveryMethod": null,
574
              "SalesPerson": null,
575
              "SendAccountingJournalOnly": false,
576
              "SourceId": "web",
577
              "CreatedBy": "[email protected]",
578
              "Guid": "G201",
579
              "LastModifiedOn": "/Date(1473149768310)/"
580
            },
581
            {
582
              "SalesOrderLines": [
583
                {
584
                  "LineNumber": 1,
585
                  "LineType": null,
586
                  "Product": {
587
                    "Guid": "G11",
588
                    "ProductCode": "IIID1",
589
                    "ProductDescription": "Socks"
590
                  },
591
                  "DueDate": "/Date(1473099415000)/",
592
                  "OrderQuantity": 1,
593
                  "UnitPrice": 8,
594
                  "DiscountRate": 0,
595
                  "LineTotal": 8,
596
                  "Volume": null,
597
                  "Weight": null,
598
                  "Comments": null,
599
                  "AverageLandedPriceAtTimeOfSale": 8,
600
                  "TaxRate": 0,
601
                  "LineTax": 0,
602
                  "XeroTaxCode": "G.S.T.",
603
                  "BCUnitPrice": 8,
604
                  "BCLineTotal": 8,
605
                  "BCLineTax": 0,
606
                  "LineTaxCode": "G.S.T.",
607
                  "XeroSalesAccount": null,
608
                  "SerialNumbers": null,
609
                  "BatchNumbers": null,
610
                  "Guid": "G403",
611
                  "LastModifiedOn": "/Date(1473149768263)/"
612
                },
613
                {
614
                  "LineNumber": 2,
615
                  "LineType": null,
616
                  "Product": {
617
                    "Guid": "G15",
618
                    "ProductCode": "IIID5",
619
                    "ProductDescription": "Mp3 Player"
620
                  },
621
                  "DueDate": "/Date(1473099415000)/",
622
                  "OrderQuantity": 2,
623
                  "UnitPrice": 200,
624
                  "DiscountRate": 0,
625
                  "LineTotal": 400,
626
                  "Volume": null,
627
                  "Weight": null,
628
                  "Comments": null,
629
                  "AverageLandedPriceAtTimeOfSale": 200,
630
                  "TaxRate": 0,
631
                  "LineTax": 0,
632
                  "XeroTaxCode": "G.S.T.",
633
                  "BCUnitPrice": 200,
634
                  "BCLineTotal": 400,
635
                  "BCLineTax": 0,
636
                  "LineTaxCode": "G.S.T.",
637
                  "XeroSalesAccount": null,
638
                  "SerialNumbers": null,
639
                  "BatchNumbers": null,
640
                  "Guid": "G404",
641
                  "LastModifiedOn": "/Date(1473149768279)/"
642
                }
643
              ],
644
              "OrderNumber": "O2",
645
              "OrderDate": "/Date(1473116400000)/",
646
              "RequiredDate": "/Date(1473548400000)/",
647
              "OrderStatus": "Dispatched",
648
              "Customer": {
649
                "CustomerCode": "Jeremy Peremy",
650
                "CustomerName": "Jeremy Peremy",
651
                "CurrencyId": 110,
652
                "Guid": "test",
653
                "LastModifiedOn": "/Date(1472624588017)/"
654
              },
655
              "CustomerRef": null,
656
              "Comments": "Test",
657
              "Warehouse": {
658
                "WarehouseCode": "test",
659
                "WarehouseName": "Queen St",
660
                "IsDefault": true,
661
                "StreetNo": "1",
662
                "AddressLine1": "Queen St",
663
                "AddressLine2": null,
664
                "City": "Invercargill",
665
                "Region": "Southland",
666
                "Country": "New Zealand",
667
                "PostCode": "9999",
668
                "PhoneNumber": "1234 567",
669
                "FaxNumber": null,
670
                "MobileNumber": null,
671
                "DDINumber": null,
672
                "ContactName": "Ed Hillary",
673
                "Obsolete": false,
674
                "Guid": "test",
675
                "LastModifiedOn": "/Date(1471582972964)/"
676
              },
677
              "ReceivedDate": "/Date(1473099415000)/",
678
              "DeliveryName": null,
679
              "DeliveryStreetAddress": "15 Ray St",
680
              "DeliverySuburb": "",
681
              "DeliveryCity": "Kaitaia",
682
              "DeliveryRegion": "Northland",
683
              "DeliveryCountry": "New Zealand",
684
              "DeliveryPostCode": "1111",
685
              "Currency": {
686
                "CurrencyCode": "NZD",
687
                "Description": "New Zealand, Dollars",
688
                "Guid": "test",
689
                "LastModifiedOn": "/Date(1415058050647)/"
690
              },
691
              "ExchangeRate": 1,
692
              "DiscountRate": 0,
693
              "Tax": {
694
                "TaxCode": "G.S.T.",
695
                "Description": null,
696
                "TaxRate": 0,
697
                "CanApplyToExpenses": false,
698
                "CanApplyToRevenue": false,
699
                "Obsolete": false,
700
                "Guid": "00000000-0000-0000-0000-000000000000",
701
                "LastModifiedOn": null
702
              },
703
              "TaxRate": 0,
704
              "XeroTaxCode": "G.S.T.",
705
              "SubTotal": 408,
706
              "TaxTotal": 0,
707
              "Total": 408,
708
              "TotalVolume": 0,
709
              "TotalWeight": 0,
710
              "BCSubTotal": 408,
711
              "BCTaxTotal": 0,
712
              "BCTotal": 408,
713
              "PaymentDueDate": "/Date(1473106568169)/",
714
              "SalesOrderGroup": null,
715
              "DeliveryMethod": null,
716
              "SalesPerson": null,
717
              "SendAccountingJournalOnly": false,
718
              "SourceId": "web",
719
              "CreatedBy": "[email protected]",
720
              "Guid": "G202",
721
              "LastModifiedOn": "/Date(1473149768310)/"
722
            }
723
          ]
724
        }
725
      ]';
726
}
727