Skip to content

Instantly share code, notes, and snippets.

@direvus
Created May 10, 2017 05:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save direvus/bcffbdd1554413431ae8cf272506e62e to your computer and use it in GitHub Desktop.
Save direvus/bcffbdd1554413431ae8cf272506e62e to your computer and use it in GitHub Desktop.
Contact payment terms patch for https://github.com/calcinai/xero-php/issues/181
commit ac5e415d468b655d8c425aef443846dad2fabef7
Author: Brendan Jurd <brendan.jurd@achievecorp.com.au>
Date: Wed May 10 15:09:52 2017 +1000
Manually patch XeroPHP to work with Contact/PaymentTerms properly.
See https://github.com/calcinai/xero-php/issues/181.
diff --git a/src/XeroPHP/Models/Accounting/Contact.php b/src/XeroPHP/Models/Accounting/Contact.php
index a84b15c..2fd0248 100644
--- a/src/XeroPHP/Models/Accounting/Contact.php
+++ b/src/XeroPHP/Models/Accounting/Contact.php
@@ -180,7 +180,7 @@ class Contact extends Remote\Object
/**
* The default payment terms for the contact – see Payment Terms
*
- * @property PaymentTerm[] PaymentTerms
+ * @property PaymentTerm PaymentTerms
*/
/**
@@ -333,7 +333,7 @@ class Contact extends Remote\Object
'PurchasesTrackingCategories' => [false, self::PROPERTY_TYPE_OBJECT, 'Accounting\\TrackingCategory', true, false],
'TrackingCategoryName' => [false, self::PROPERTY_TYPE_STRING, null, false, false],
'TrackingCategoryOption' => [false, self::PROPERTY_TYPE_STRING, null, false, false],
- 'PaymentTerms' => [false, self::PROPERTY_TYPE_OBJECT, 'Accounting\\Organisation\\PaymentTerm', true, false],
+ 'PaymentTerms' => [false, self::PROPERTY_TYPE_OBJECT, 'Accounting\\Organisation\\PaymentTerm', false, false],
'UpdatedDateUTC' => [false, self::PROPERTY_TYPE_TIMESTAMP, '\\DateTimeInterface', false, false],
'ContactGroups' => [false, self::PROPERTY_TYPE_OBJECT, 'Accounting\\ContactGroup', true, false],
'Website' => [false, self::PROPERTY_TYPE_STRING, null, false, false],
@@ -855,8 +855,7 @@ class Contact extends Remote\Object
}
/**
- * @return PaymentTerm[]|Remote\Collection
- * Always returns a collection, switch is for type hinting
+ * @return PaymentTerm
*/
public function getPaymentTerms()
{
@@ -867,13 +866,10 @@ class Contact extends Remote\Object
* @param PaymentTerm $value
* @return Contact
*/
- public function addPaymentTerm(PaymentTerm $value)
+ public function setPaymentTerms(PaymentTerm $value)
{
$this->propertyUpdated('PaymentTerms', $value);
- if (!isset($this->_data['PaymentTerms'])) {
- $this->_data['PaymentTerms'] = new Remote\Collection();
- }
- $this->_data['PaymentTerms'][] = $value;
+ $this->_data['PaymentTerms'] = $value;
return $this;
}
diff --git a/src/XeroPHP/Models/Accounting/Organisation/PaymentTerm.php b/src/XeroPHP/Models/Accounting/Organisation/PaymentTerm.php
index 3615e61..b74425f 100644
--- a/src/XeroPHP/Models/Accounting/Organisation/PaymentTerm.php
+++ b/src/XeroPHP/Models/Accounting/Organisation/PaymentTerm.php
@@ -87,8 +87,8 @@ class PaymentTerm extends Remote\Object
public static function getProperties()
{
return [
- 'Bills' => [false, self::PROPERTY_TYPE_OBJECT, 'Accounting\\Organisation\\Bill', true, false],
- 'Sales' => [false, self::PROPERTY_TYPE_OBJECT, 'Accounting\\Organisation\\Sale', true, false]
+ 'Bills' => [false, self::PROPERTY_TYPE_OBJECT, 'Accounting\\Organisation\\Bill', false, false],
+ 'Sales' => [false, self::PROPERTY_TYPE_OBJECT, 'Accounting\\Organisation\\Sale', false, false]
];
}
@@ -98,8 +98,7 @@ class PaymentTerm extends Remote\Object
}
/**
- * @return Bill[]|Remote\Collection
- * Always returns a collection, switch is for type hinting
+ * @return Bill
*/
public function getBills()
{
@@ -110,19 +109,15 @@ class PaymentTerm extends Remote\Object
* @param Bill $value
* @return PaymentTerm
*/
- public function addBill(Bill $value)
+ public function setBill(Bill $value)
{
$this->propertyUpdated('Bills', $value);
- if (!isset($this->_data['Bills'])) {
- $this->_data['Bills'] = new Remote\Collection();
- }
- $this->_data['Bills'][] = $value;
+ $this->_data['Bills'] = $value;
return $this;
}
/**
- * @return Sale[]|Remote\Collection
- * Always returns a collection, switch is for type hinting
+ * @return Sale
*/
public function getSales()
{
@@ -133,13 +128,10 @@ class PaymentTerm extends Remote\Object
* @param Sale $value
* @return PaymentTerm
*/
- public function addSale(Sale $value)
+ public function setSale(Sale $value)
{
$this->propertyUpdated('Sales', $value);
- if (!isset($this->_data['Sales'])) {
- $this->_data['Sales'] = new Remote\Collection();
- }
- $this->_data['Sales'][] = $value;
+ $this->_data['Sales'] = $value;
return $this;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment