diff --git a/src/XeroPHP/Models/Accounting/PurchaseOrder.php b/src/XeroPHP/Models/Accounting/PurchaseOrder.php index e82a1bfd..46556707 100644 --- a/src/XeroPHP/Models/Accounting/PurchaseOrder.php +++ b/src/XeroPHP/Models/Accounting/PurchaseOrder.php @@ -1,8 +1,166 @@ array (true, self::PROPERTY_TYPE_OBJECT, 'Accounting\\Contact', false, false), + 'LineItems' => array (true, self::PROPERTY_TYPE_OBJECT, 'Accounting\\PurchaseOrder\\LineItem', true, false), + 'Date' => array (false, self::PROPERTY_TYPE_DATE, '\\DateTime', false, false), + 'DeliveryDate' => array (false, self::PROPERTY_TYPE_DATE, '\\DateTime', false, false), + 'LineAmountTypes' => array (false, self::PROPERTY_TYPE_ENUM, null, false, false), + 'PurchaseOrderNumber' => array (false, self::PROPERTY_TYPE_STRING, null, false, false), + 'Reference' => array (false, self::PROPERTY_TYPE_STRING, null, false, false), + 'BrandingThemeID' => array (false, self::PROPERTY_TYPE_STRING, null, false, false), + 'CurrencyCode' => array (false, self::PROPERTY_TYPE_STRING, null, false, false), + 'CurrencyRate' => array (false, self::PROPERTY_TYPE_FLOAT, null, false, false), + 'Status' => array (false, self::PROPERTY_TYPE_STRING, null, false, false), + 'SentToContact' => array (false, self::PROPERTY_TYPE_BOOLEAN, null, false, false), + 'DeliveryAddress' => array (false, self::PROPERTY_TYPE_STRING, null, false, false), + 'AttentionTo' => array (false, self::PROPERTY_TYPE_STRING, null, false, false), + 'Telephone' => array (false, self::PROPERTY_TYPE_STRING, null, false, false), + 'DeliveryInstructions' => array (false, self::PROPERTY_TYPE_STRING, null, false, false), + 'ExpectedArrivalDate' => array (false, self::PROPERTY_TYPE_DATE, '\\DateTime', false, false), + 'PurchaseOrderID' => array (false, self::PROPERTY_TYPE_STRING, null, false, false), + 'SubTotal' => array (false, self::PROPERTY_TYPE_FLOAT, null, false, false), + 'TotalTax' => array (false, self::PROPERTY_TYPE_FLOAT, null, false, false), + 'Total' => array (false, self::PROPERTY_TYPE_FLOAT, null, false, false), + 'TotalDiscount' => array (false, self::PROPERTY_TYPE_FLOAT, null, false, false), + 'HasAttachments' => array (false, self::PROPERTY_TYPE_BOOLEAN, null, false, false), + 'UpdatedDateUTC' => array (false, self::PROPERTY_TYPE_TIMESTAMP, '\\DateTime', false, false) + ); + } + + public static function isPageable() + { + return true; + } + + /** + * @return Contact + */ + public function getContact() + { + return $this->_data['Contact']; + } + + /** + * @param Contact $value + * @return PurchaseOrder + */ + public function setContact(Contact $value) + { + $this->propertyUpdated('Contact', $value); + $this->_data['Contact'] = $value; + return $this; + } + + /** + * @return LineItem[]|Remote\Collection + * Always returns a collection, switch is for type hinting + */ + public function getLineItems() + { + return $this->_data['LineItems']; + } + + /** + * @param LineItem $value + * @return PurchaseOrder + */ + public function addLineItem(LineItem $value) + { + $this->propertyUpdated('LineItems', $value); + if(!isset($this->_data['LineItems'])){ + $this->_data['LineItems'] = new Remote\Collection(); + } + $this->_data['LineItems'][] = $value; + return $this; + } + + /** + * @return \DateTime + */ + public function getDate() + { + return $this->_data['Date']; + } + + /** + * @param \DateTime $value + * @return PurchaseOrder + */ + public function setDate(\DateTime $value) + { + $this->propertyUpdated('Date', $value); + $this->_data['Date'] = $value; + return $this; + } + + /** + * @return \DateTime + */ + public function getDeliveryDate() + { + return $this->_data['DeliveryDate']; + } + + /** + * @param \DateTime $value + * @return PurchaseOrder + */ + public function setDeliveryDate(\DateTime $value) + { + $this->propertyUpdated('DeliveryDate', $value); + $this->_data['DeliveryDate'] = $value; + return $this; + } + + /** + * @return string + */ + public function getLineAmountTypes() + { + return $this->_data['LineAmountTypes']; + } + + /** + * @param string $value + * @return PurchaseOrder + */ + public function setLineAmountType($value) + { + $this->propertyUpdated('LineAmountTypes', $value); + $this->_data['LineAmountTypes'] = $value; + return $this; + } + + /** + * @return string + */ + public function getPurchaseOrderNumber() + { + return $this->_data['PurchaseOrderNumber']; + } + + /** + * @param string $value + * @return PurchaseOrder + */ + public function setPurchaseOrderNumber($value) + { + $this->propertyUpdated('PurchaseOrderNumber', $value); + $this->_data['PurchaseOrderNumber'] = $value; + return $this; + } + + /** + * @return string + */ + public function getReference() + { + return $this->_data['Reference']; + } + + /** + * @param string $value + * @return PurchaseOrder + */ + public function setReference($value) + { + $this->propertyUpdated('Reference', $value); + $this->_data['Reference'] = $value; + return $this; + } + + /** + * @return string + */ + public function getBrandingThemeID() + { + return $this->_data['BrandingThemeID']; + } + + /** + * @param string $value + * @return PurchaseOrder + */ + public function setBrandingThemeID($value) + { + $this->propertyUpdated('BrandingThemeID', $value); + $this->_data['BrandingThemeID'] = $value; + return $this; + } + + /** + * @return string + */ + public function getCurrencyCode() + { + return $this->_data['CurrencyCode']; + } + + /** + * @param string $value + * @return PurchaseOrder + */ + public function setCurrencyCode($value) + { + $this->propertyUpdated('CurrencyCode', $value); + $this->_data['CurrencyCode'] = $value; + return $this; + } + + /** + * @return float + */ + public function getCurrencyRate() + { + return $this->_data['CurrencyRate']; + } + + /** + * @param float $value + * @return PurchaseOrder + */ + public function setCurrencyRate($value) + { + $this->propertyUpdated('CurrencyRate', $value); + $this->_data['CurrencyRate'] = $value; + return $this; + } + + /** + * @return string + */ + public function getStatus() + { + return $this->_data['Status']; + } + + /** + * @param string $value + * @return PurchaseOrder + */ + public function setStatus($value) + { + $this->propertyUpdated('Status', $value); + $this->_data['Status'] = $value; + return $this; + } + + /** + * @return bool + */ + public function getSentToContact() + { + return $this->_data['SentToContact']; + } + + /** + * @param bool $value + * @return PurchaseOrder + */ + public function setSentToContact($value) + { + $this->propertyUpdated('SentToContact', $value); + $this->_data['SentToContact'] = $value; + return $this; + } + + /** + * @return string + */ + public function getDeliveryAddress() + { + return $this->_data['DeliveryAddress']; + } + + /** + * @param string $value + * @return PurchaseOrder + */ + public function setDeliveryAddress($value) + { + $this->propertyUpdated('DeliveryAddress', $value); + $this->_data['DeliveryAddress'] = $value; + return $this; + } + + /** + * @return string + */ + public function getAttentionTo() + { + return $this->_data['AttentionTo']; + } + + /** + * @param string $value + * @return PurchaseOrder + */ + public function setAttentionTo($value) + { + $this->propertyUpdated('AttentionTo', $value); + $this->_data['AttentionTo'] = $value; + return $this; + } + + /** + * @return string + */ + public function getTelephone() + { + return $this->_data['Telephone']; + } + + /** + * @param string $value + * @return PurchaseOrder + */ + public function setTelephone($value) + { + $this->propertyUpdated('Telephone', $value); + $this->_data['Telephone'] = $value; + return $this; + } + + /** + * @return string + */ + public function getDeliveryInstructions() + { + return $this->_data['DeliveryInstructions']; + } + + /** + * @param string $value + * @return PurchaseOrder + */ + public function setDeliveryInstruction($value) + { + $this->propertyUpdated('DeliveryInstructions', $value); + $this->_data['DeliveryInstructions'] = $value; + return $this; + } + + /** + * @return \DateTime + */ + public function getExpectedArrivalDate() + { + return $this->_data['ExpectedArrivalDate']; + } + + /** + * @param \DateTime $value + * @return PurchaseOrder + */ + public function setExpectedArrivalDate(\DateTime $value) + { + $this->propertyUpdated('ExpectedArrivalDate', $value); + $this->_data['ExpectedArrivalDate'] = $value; + return $this; + } + + /** + * @return string + */ + public function getPurchaseOrderID() + { + return $this->_data['PurchaseOrderID']; + } + + /** + * @param string $value + * @return PurchaseOrder + */ + public function setPurchaseOrderID($value) + { + $this->propertyUpdated('PurchaseOrderID', $value); + $this->_data['PurchaseOrderID'] = $value; + return $this; + } + + /** + * @return float + */ + public function getSubTotal() + { + return $this->_data['SubTotal']; + } + + + /** + * @return float + */ + public function getTotalTax() + { + return $this->_data['TotalTax']; + } + + + /** + * @return float + */ + public function getTotal() + { + return $this->_data['Total']; + } + + + /** + * @return float + */ + public function getTotalDiscount() + { + return $this->_data['TotalDiscount']; + } + + + /** + * @return bool + */ + public function getHasAttachments() + { + return $this->_data['HasAttachments']; + } + + + /** + * @return \DateTime + */ + public function getUpdatedDateUTC() + { + return $this->_data['UpdatedDateUTC']; + } + + + +} diff --git a/src/XeroPHP/Models/Accounting/PurchaseOrder/LineItem.php b/src/XeroPHP/Models/Accounting/PurchaseOrder/LineItem.php new file mode 100644 index 00000000..deee5cd1 --- /dev/null +++ b/src/XeroPHP/Models/Accounting/PurchaseOrder/LineItem.php @@ -0,0 +1,383 @@ + is not correct – see + * TaxTypes. + * + * @property string TaxType + */ + + /** + * Percentage discount being applied to a line item + * + * @property string DiscountRate + */ + + /** + * Optional Tracking Category – see Tracking. Any LineItem can have a maximum of 2 + * elements. + * + * @property TrackingCategory[] Tracking + */ + + /** + * The Xero generated identifier for a LineItem. If LineItemIDs are not included with line items in an + * update request then the line items are deleted and recreated. + * + * @property string LineItemID + */ + + /** + * The tax amount is auto calculated as a percentage of the line amount based on the tax rate. + * + * @property float TaxAmount + */ + + /** + * The line amount reflects the discounted price if a DiscountRate has been used . i.e LineAmount = + * Quantity * Unit Amount * ((100 – DiscountRate)/100) + * + * @property float LineAmount + */ + + + + /** + * Get the resource uri of the class (Contacts) etc + * + * @return string + */ + public static function getResourceURI() + { + return 'LineItems'; + } + + + /** + * Get the root node name. Just the unqualified classname + * + * @return string + */ + public static function getRootNodeName() + { + return 'LineItem'; + } + + + /** + * Get the guid property + * + * @return string + */ + public static function getGUIDProperty() + { + return 'LineItemID'; + } + + + /** + * Get the stem of the API (core.xro) etc + * + * @return string|null + */ + public static function getAPIStem() + { + return Remote\URL::API_CORE; + } + + + /** + * Get the supported methods + */ + public static function getSupportedMethods() + { + return array( + ); + } + + /** + * + * Get the properties of the object. Indexed by constants + * [0] - Mandatory + * [1] - Type + * [2] - PHP type + * [3] - Is an Array + * [4] - Saves directly + * + * @return array + */ + public static function getProperties() + { + return array( + 'Description' => array (false, self::PROPERTY_TYPE_FLOAT, null, false, false), + 'Quantity' => array (false, self::PROPERTY_TYPE_FLOAT, null, false, false), + 'UnitAmount' => array (false, self::PROPERTY_TYPE_FLOAT, null, false, false), + 'ItemCode' => array (false, self::PROPERTY_TYPE_STRING, null, false, false), + 'AccountCode' => array (false, self::PROPERTY_TYPE_STRING, null, false, false), + 'TaxType' => array (false, self::PROPERTY_TYPE_ENUM, null, false, false), + 'DiscountRate' => array (false, self::PROPERTY_TYPE_STRING, null, false, false), + 'Tracking' => array (false, self::PROPERTY_TYPE_OBJECT, 'Accounting\\TrackingCategory', true, false), + 'LineItemID' => array (false, self::PROPERTY_TYPE_STRING, null, false, false), + 'TaxAmount' => array (false, self::PROPERTY_TYPE_FLOAT, null, false, false), + 'LineAmount' => array (false, self::PROPERTY_TYPE_FLOAT, null, false, false) + ); + } + + public static function isPageable() + { + return false; + } + + /** + * @return float + */ + public function getDescription() + { + return $this->_data['Description']; + } + + /** + * @param float $value + * @return LineItem + */ + public function setDescription($value) + { + $this->propertyUpdated('Description', $value); + $this->_data['Description'] = $value; + return $this; + } + + /** + * @return float + */ + public function getQuantity() + { + return $this->_data['Quantity']; + } + + /** + * @param float $value + * @return LineItem + */ + public function setQuantity($value) + { + $this->propertyUpdated('Quantity', $value); + $this->_data['Quantity'] = $value; + return $this; + } + + /** + * @return float + */ + public function getUnitAmount() + { + return $this->_data['UnitAmount']; + } + + /** + * @param float $value + * @return LineItem + */ + public function setUnitAmount($value) + { + $this->propertyUpdated('UnitAmount', $value); + $this->_data['UnitAmount'] = $value; + return $this; + } + + /** + * @return string + */ + public function getItemCode() + { + return $this->_data['ItemCode']; + } + + /** + * @param string $value + * @return LineItem + */ + public function setItemCode($value) + { + $this->propertyUpdated('ItemCode', $value); + $this->_data['ItemCode'] = $value; + return $this; + } + + /** + * @return string + */ + public function getAccountCode() + { + return $this->_data['AccountCode']; + } + + /** + * @param string $value + * @return LineItem + */ + public function setAccountCode($value) + { + $this->propertyUpdated('AccountCode', $value); + $this->_data['AccountCode'] = $value; + return $this; + } + + /** + * @return string + */ + public function getTaxType() + { + return $this->_data['TaxType']; + } + + /** + * @param string $value + * @return LineItem + */ + public function setTaxType($value) + { + $this->propertyUpdated('TaxType', $value); + $this->_data['TaxType'] = $value; + return $this; + } + + /** + * @return string + */ + public function getDiscountRate() + { + return $this->_data['DiscountRate']; + } + + /** + * @param string $value + * @return LineItem + */ + public function setDiscountRate($value) + { + $this->propertyUpdated('DiscountRate', $value); + $this->_data['DiscountRate'] = $value; + return $this; + } + + /** + * @return TrackingCategory[]|Remote\Collection + * Always returns a collection, switch is for type hinting + */ + public function getTracking() + { + return $this->_data['Tracking']; + } + + /** + * @param TrackingCategory $value + * @return LineItem + */ + public function addTracking(TrackingCategory $value) + { + $this->propertyUpdated('Tracking', $value); + if(!isset($this->_data['Tracking'])){ + $this->_data['Tracking'] = new Remote\Collection(); + } + $this->_data['Tracking'][] = $value; + return $this; + } + + /** + * @return string + */ + public function getLineItemID() + { + return $this->_data['LineItemID']; + } + + /** + * @param string $value + * @return LineItem + */ + public function setLineItemID($value) + { + $this->propertyUpdated('LineItemID', $value); + $this->_data['LineItemID'] = $value; + return $this; + } + + /** + * @return float + */ + public function getTaxAmount() + { + return $this->_data['TaxAmount']; + } + + /** + * @param float $value + * @return LineItem + */ + public function setTaxAmount($value) + { + $this->propertyUpdated('TaxAmount', $value); + $this->_data['TaxAmount'] = $value; + return $this; + } + + /** + * @return float + */ + public function getLineAmount() + { + return $this->_data['LineAmount']; + } + + /** + * @param float $value + * @return LineItem + */ + public function setLineAmount($value) + { + $this->propertyUpdated('LineAmount', $value); + $this->_data['LineAmount'] = $value; + return $this; + } + + +}