Passed
Branch master (8d4084)
by Antony
03:09 queued 01:05
created

UnleashedOrderTest::testTaxRounding2()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 58
Code Lines 45

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 45
nc 1
nop 0
dl 0
loc 58
rs 9.2
c 0
b 0
f 0

How to fix   Long Method   

Long Method

Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.

For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.

Commonly applied refactorings include:

1
<?php
2
3
namespace AntonyThorpe\SilverShopUnleashed\Tests;
4
5
use AntonyThorpe\SilverShopUnleashed\BulkLoader\OrderBulkLoader;
6
use AntonyThorpe\SilverShopUnleashed\Defaults;
7
use SilverShop\Cart\ShoppingCart;
8
use SilverShop\Checkout\OrderProcessor;
9
use SilverShop\Model\Modifiers\OrderModifier;
10
use SilverShop\Model\Modifiers\Shipping\Simple;
11
use SilverShop\Model\Modifiers\Tax\FlatTax;
12
use SilverShop\Model\Order;
13
use SilverShop\Model\Product\OrderItem;
14
use SilverShop\Page\Product;
15
use SilverShop\Shipping\Model\DistanceShippingMethod;
16
use SilverShop\Tests\ShopTest;
17
use SilverStripe\Core\Config\Config;
18
use SilverStripe\Dev\SapphireTest;
19
20
class UnleashedOrderTest extends SapphireTest
21
{
22
    protected static $fixture_file = [
23
        'vendor/silvershop/core/tests/php/Fixtures/ShopMembers.yml',
24
        'vendor/silvershop/core/tests/php/Fixtures/shop.yml',
25
        'vendor/silvershop/shipping/tests/DistanceShippingMethod.yml',
26
        'vendor/silvershop/shipping/tests/Warehouses.yml',
27
        'fixtures/models.yml'
28
    ];
29
30
    public function setUp()
31
    {
32
        Defaults::config()->send_sales_orders_to_unleashed = false;
33
        Defaults::config()->tax_modifier_class_name = 'SilverShop\Model\Modifiers\Tax\FlatTax';
34
        Defaults::config()->shipping_modifier_class_name = 'SilverShop\Model\Modifiers\Shipping\Simple';
35
        parent::setUp();
36
        ShoppingCart::singleton()->clear();
37
        ShopTest::setConfiguration(); //reset config
38
        $this->logInWithPermission('ADMIN');
39
        Config::modify()
40
            ->set(Simple::class, 'default_charge', 8.95)
41
            ->set(Simple::class, 'product_code', 'Freight')
42
            ->set(FlatTax::class, 'rate', 0.15)
43
            ->set(FlatTax::class, 'exclusive', true)
44
            ->set(FlatTax::class, 'name', 'GST')
45
            ->set(FlatTax::class, 'tax_code', 'OUTPUT2')
46
            ->merge(Order::class, 'modifiers', [Simple::class, FlatTax::class]);
47
    }
48
49
    protected $order_status_map = [
50
        'Open' => 'Unpaid',
51
        'Parked' => 'Paid',
52
        'Backordered' => 'Processing',
53
        'Placed' => 'Processing',
54
        'Picking' => 'Processing',
55
        'Picked' => 'Processing',
56
        'Packed' => 'Processing',
57
        'Dispatched' => 'Sent',
58
        'Complete' => 'Complete',
59
        'Deleted' => 'MemberCancelled'
60
    ];
61
62
    public function testChangeOrderStatus()
63
    {
64
        $apidata_array = json_decode($this->jsondata, true);
65
        $apidata_array = reset($apidata_array);
66
        $apidata = $apidata_array['Items'];
67
68
        $loader = OrderBulkLoader::create('SilverShop\Model\Order');
69
        $loader->transforms = [
70
            'Status' => [
71
                'callback' => function ($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

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