Skip to content

Commit

Permalink
Models @ 25e2785
Browse files Browse the repository at this point in the history
  • Loading branch information
calcinai committed Oct 26, 2015
1 parent 25e2785 commit cefb08b
Show file tree
Hide file tree
Showing 6 changed files with 336 additions and 29 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -93,8 +93,8 @@ public static function getSupportedMethods()
public static function getProperties()
{
return array(
'Code' => array (true, self::PROPERTY_TYPE_STRING, null, false, false),
'AccountID' => array (true, self::PROPERTY_TYPE_STRING, null, false, false),
'Code' => array (false, self::PROPERTY_TYPE_STRING, null, false, false),
'AccountID' => array (false, self::PROPERTY_TYPE_STRING, null, false, false),
'Name' => array (false, self::PROPERTY_TYPE_STRING, null, false, false)
);
}
Expand Down
4 changes: 2 additions & 2 deletions src/XeroPHP/Models/Accounting/BankTransfer/ToBankAccount.php
Original file line number Diff line number Diff line change
Expand Up @@ -93,8 +93,8 @@ public static function getSupportedMethods()
public static function getProperties()
{
return array(
'Code' => array (true, self::PROPERTY_TYPE_STRING, null, false, false),
'AccountID' => array (true, self::PROPERTY_TYPE_STRING, null, false, false),
'Code' => array (false, self::PROPERTY_TYPE_STRING, null, false, false),
'AccountID' => array (false, self::PROPERTY_TYPE_STRING, null, false, false),
'Name' => array (false, self::PROPERTY_TYPE_STRING, null, false, false)
);
}
Expand Down
224 changes: 224 additions & 0 deletions src/XeroPHP/Models/Accounting/Item.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,47 @@ class Item extends Remote\Object
* @property string Code
*/

/**
* The inventory asset account for the item. The account must be of type INVENTORY. The
* COGSAccountCode in PurchaseDetails is also required to create a tracked item
*
* @property string InventoryAssetAccountCode
*/

/**
* The name of the item (max length = 50)
*
* @property string Name
*/

/**
* Boolean value, defaults to true. When IsSold is true the item will be available on sales
* transactions in the Xero UI. If IsSold is updated to false then Description and SalesDetails values
* will be nulled.
*
* @property bool IsSold
*/

/**
* Boolean value, defaults to true. When IsPurchased is true the item is available for purchase
* transactions in the Xero UI. If IsPurchased is updated to false then PurchaseDescription and
* PurchaseDetails values will be nulled.
*
* @property bool IsPurchased
*/

/**
* The sales description of the item (max length = 4000)
*
* @property string Description
*/

/**
* The purchase description of the item (max length = 4000)
*
* @property string PurchaseDescription
*/

/**
* See Purchases & Sales
*
Expand All @@ -38,6 +73,25 @@ class Item extends Remote\Object
* @property Sale[] SalesDetails
*/

/**
* True for items that are tracked as inventory. An item will be tracked as inventory if the
* InventoryAssetAccountCode and COGSAccountCode are set.
*
* @property bool IsTrackedAsInventory
*/

/**
* The value of the item on hand. Calculated using average cost accounting.
*
* @property string TotalCostPool
*/

/**
* The quantity of the item on hand
*
* @property string QuantityOnHand
*/

/**
* Last modified date in UTC format
*
Expand Down Expand Up @@ -118,9 +172,17 @@ public static function getProperties()
return array(
'ItemID' => array (false, self::PROPERTY_TYPE_STRING, null, false, false),
'Code' => array (true, self::PROPERTY_TYPE_STRING, null, false, false),
'InventoryAssetAccountCode' => array (true, self::PROPERTY_TYPE_STRING, null, false, false),

This comment has been minimized.

Copy link
@AndrewFeeney

AndrewFeeney Jun 29, 2016

Contributor

Can I ask why InventoryAssetAccountCode is set to mandatory? Xero's API doesn't seem to require it.

This comment has been minimized.

Copy link
@calcinai

calcinai Jun 29, 2016

Author Owner

Good question, it must have found something to suggest it was.

This comment has been minimized.

Copy link
@calcinai

calcinai Jun 29, 2016

Author Owner

Ah:

The following is required for a PUT / POST on a tracked inventory item

It's conditionally required. I'll see what I can ado about this.

This comment has been minimized.

Copy link
@AndrewFeeney

AndrewFeeney Jun 29, 2016

Contributor

Ah, I see. That makes sense. I've worked around it in my project by extending this class and overriding the getProperties() method. I won't submit a pull request since you're looking into a fix that takes into consideration the conditional requirement.

Thanks for looking into it, and thanks for your hard work with this project, it's proved a life saver for me.

'Name' => array (false, self::PROPERTY_TYPE_STRING, null, false, false),
'IsSold' => array (false, self::PROPERTY_TYPE_BOOLEAN, null, false, false),
'IsPurchased' => array (false, self::PROPERTY_TYPE_BOOLEAN, null, false, false),
'Description' => array (false, self::PROPERTY_TYPE_STRING, null, false, false),
'PurchaseDescription' => array (false, self::PROPERTY_TYPE_STRING, null, false, false),
'PurchaseDetails' => array (false, self::PROPERTY_TYPE_OBJECT, 'Accounting\\Item\\Purchase', true, false),
'SalesDetails' => array (false, self::PROPERTY_TYPE_OBJECT, 'Accounting\\Item\\Sale', true, false),
'IsTrackedAsInventory' => array (false, self::PROPERTY_TYPE_BOOLEAN, null, false, false),
'TotalCostPool' => array (false, self::PROPERTY_TYPE_STRING, null, false, false),
'QuantityOnHand' => array (false, self::PROPERTY_TYPE_STRING, null, false, false),
'UpdatedDateUTC' => array (false, self::PROPERTY_TYPE_TIMESTAMP, '\\DateTime', false, false)
);
}
Expand Down Expand Up @@ -168,6 +230,82 @@ public function setCode($value)
return $this;
}

/**
* @return string
*/
public function getInventoryAssetAccountCode()
{
return $this->_data['InventoryAssetAccountCode'];
}

/**
* @param string $value
* @return Item
*/
public function setInventoryAssetAccountCode($value)
{
$this->propertyUpdated('InventoryAssetAccountCode', $value);
$this->_data['InventoryAssetAccountCode'] = $value;
return $this;
}

/**
* @return string
*/
public function getName()
{
return $this->_data['Name'];
}

/**
* @param string $value
* @return Item
*/
public function setName($value)
{
$this->propertyUpdated('Name', $value);
$this->_data['Name'] = $value;
return $this;
}

/**
* @return bool
*/
public function getIsSold()
{
return $this->_data['IsSold'];
}

/**
* @param bool $value
* @return Item
*/
public function setIsSold($value)
{
$this->propertyUpdated('IsSold', $value);
$this->_data['IsSold'] = $value;
return $this;
}

/**
* @return bool
*/
public function getIsPurchased()
{
return $this->_data['IsPurchased'];
}

/**
* @param bool $value
* @return Item
*/
public function setIsPurchased($value)
{
$this->propertyUpdated('IsPurchased', $value);
$this->_data['IsPurchased'] = $value;
return $this;
}

/**
* @return string
*/
Expand All @@ -187,6 +325,25 @@ public function setDescription($value)
return $this;
}

/**
* @return string
*/
public function getPurchaseDescription()
{
return $this->_data['PurchaseDescription'];
}

/**
* @param string $value
* @return Item
*/
public function setPurchaseDescription($value)
{
$this->propertyUpdated('PurchaseDescription', $value);
$this->_data['PurchaseDescription'] = $value;
return $this;
}

/**
* @return Purchase[]|Remote\Collection
* Always returns a collection, switch is for type hinting
Expand Down Expand Up @@ -233,6 +390,63 @@ public function addSalesDetail(Sale $value)
return $this;
}

/**
* @return bool
*/
public function getIsTrackedAsInventory()
{
return $this->_data['IsTrackedAsInventory'];
}

/**
* @param bool $value
* @return Item
*/
public function setIsTrackedAsInventory($value)
{
$this->propertyUpdated('IsTrackedAsInventory', $value);
$this->_data['IsTrackedAsInventory'] = $value;
return $this;
}

/**
* @return string
*/
public function getTotalCostPool()
{
return $this->_data['TotalCostPool'];
}

/**
* @param string $value
* @return Item
*/
public function setTotalCostPool($value)
{
$this->propertyUpdated('TotalCostPool', $value);
$this->_data['TotalCostPool'] = $value;
return $this;
}

/**
* @return string
*/
public function getQuantityOnHand()
{
return $this->_data['QuantityOnHand'];
}

/**
* @param string $value
* @return Item
*/
public function setQuantityOnHand($value)
{
$this->propertyUpdated('QuantityOnHand', $value);
$this->_data['QuantityOnHand'] = $value;
return $this;
}

/**
* @return \DateTime
*/
Expand All @@ -241,6 +455,16 @@ public function getUpdatedDateUTC()
return $this->_data['UpdatedDateUTC'];
}

/**
* @param \DateTime $value
* @return Item
*/
public function setUpdatedDateUTC(\DateTime $value)
{
$this->propertyUpdated('UpdatedDateUTC', $value);
$this->_data['UpdatedDateUTC'] = $value;
return $this;
}


}
Loading

0 comments on commit cefb08b

Please sign in to comment.