Skip to content

Commit 3f88685

Browse files
authored
fix(accounting): add missing Item fields to fix CI audit (#18)
Xero added QuantityAvailable and QuantityOnBackOrder to the Item schema. Added both fields the same way as the existing QuantityOnHand and TotalCostPool fields (read only numbers), and added test coverage for them in ItemsTest.
1 parent 3d52ad3 commit 3f88685

2 files changed

Lines changed: 34 additions & 0 deletions

File tree

src/Accounting/Item/Item.php

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,10 @@ public function __construct(
4343

4444
private int|float|null $quantityOnHand = null;
4545

46+
private int|float|null $quantityAvailable = null;
47+
48+
private int|float|null $quantityOnBackOrder = null;
49+
4650
private int|float|null $totalCostPool = null;
4751

4852
private ?string $statusAttributeString = null;
@@ -198,6 +202,30 @@ public function setQuantityOnHand(int|float|null $quantityOnHand): self
198202
return $this;
199203
}
200204

205+
public function getQuantityAvailable(): int|float|null
206+
{
207+
return $this->quantityAvailable;
208+
}
209+
210+
public function setQuantityAvailable(int|float|null $quantityAvailable): self
211+
{
212+
$this->quantityAvailable = $quantityAvailable;
213+
214+
return $this;
215+
}
216+
217+
public function getQuantityOnBackOrder(): int|float|null
218+
{
219+
return $this->quantityOnBackOrder;
220+
}
221+
222+
public function setQuantityOnBackOrder(int|float|null $quantityOnBackOrder): self
223+
{
224+
$this->quantityOnBackOrder = $quantityOnBackOrder;
225+
226+
return $this;
227+
}
228+
201229
public function getTotalCostPool(): int|float|null
202230
{
203231
return $this->totalCostPool;
@@ -267,6 +295,8 @@ protected static function getDefinitions(): array
267295
'PurchaseDetails' => Field::object(Purchase::class),
268296
'SalesDetails' => Field::object(Purchase::class),
269297
'QuantityOnHand' => Field::number(),
298+
'QuantityAvailable' => Field::number(),
299+
'QuantityOnBackOrder' => Field::number(),
270300
'TotalCostPool' => Field::number(),
271301
'StatusAttributeString' => Field::string(),
272302
'UpdatedDateUTC' => Field::string(),

tests/Accounting/ItemsTest.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,8 @@ public function test_it_can_query_and_find_items(): void
4747
'TaxType' => 'OUTPUT2',
4848
],
4949
'QuantityOnHand' => 15,
50+
'QuantityAvailable' => 12,
51+
'QuantityOnBackOrder' => 0,
5052
'TotalCostPool' => 157.5,
5153
'StatusAttributeString' => 'ERROR',
5254
'UpdatedDateUTC' => '2026-04-01T01:00:00',
@@ -81,6 +83,8 @@ public function test_it_can_query_and_find_items(): void
8183
self::assertSame('200', $item->getSalesDetails()->getAccountCode());
8284
self::assertSame('OUTPUT2', $item->getSalesDetails()->getTaxType());
8385
self::assertSame(15, $item->getQuantityOnHand());
86+
self::assertSame(12, $item->getQuantityAvailable());
87+
self::assertSame(0, $item->getQuantityOnBackOrder());
8488
self::assertSame(157.5, $item->getTotalCostPool());
8589
self::assertSame('ERROR', $item->getStatusAttributeString());
8690
self::assertSame('2026-04-01T01:00:00', $item->getUpdatedDateUTC());

0 commit comments

Comments
 (0)