/quickbooks/QuickBooks/QBXML/Object/ReceivePayment.php

https://bitbucket.org/211enterprises/laracing · PHP · 549 lines · 274 code · 78 blank · 197 comment · 9 complexity · e0e46fd185e543006d9d988d6bfb2c2c MD5 · raw file

  1. <?php
  2. /**
  3. * QuickBooks ReceivePayment object container
  4. *
  5. * @author Keith Palmer <keith@consolibyte.com>
  6. * @license LICENSE.txt
  7. *
  8. * @package QuickBooks
  9. * @subpackage Object
  10. */
  11. /**
  12. * Base object class
  13. */
  14. QuickBooks_Loader::load('/QuickBooks/QBXML/Object.php');
  15. /**
  16. * Dependency class (applied payment)
  17. */
  18. QuickBooks_Loader::load('/QuickBooks/QBXML/Object/ReceivePayment/AppliedToTxn.php');
  19. /**
  20. * QuickBooks ReceivePayment object
  21. */
  22. class QuickBooks_QBXML_Object_ReceivePayment extends QuickBooks_QBXML_Object
  23. {
  24. /**
  25. * Create a new QuickBooks_Object_ReceivePayment object
  26. *
  27. * @param array $arr
  28. */
  29. public function __construct($arr = array())
  30. {
  31. parent::__construct($arr);
  32. }
  33. /**
  34. * Set the TxnID of the Class
  35. *
  36. * @param string $TxnID
  37. * @return boolean
  38. */
  39. public function setTxnID($TxnID)
  40. {
  41. return $this->set('TxnID', $TxnID);
  42. }
  43. /**
  44. * Alias of {@link QuickBooks_Object_ReceivePayment::setTxnID()}
  45. */
  46. public function setTransactionID($TxnID)
  47. {
  48. return $this->setTxnID($TxnID);
  49. }
  50. /**
  51. * Get the ListID of the Class
  52. *
  53. * @return string
  54. */
  55. public function getTxnID()
  56. {
  57. return $this->get('TxnID');
  58. }
  59. /**
  60. * Alias of {@link QuickBooks_Object_ReceivePayment::getTxnID()}
  61. */
  62. public function getTransactionID()
  63. {
  64. return $this->getTxnID();
  65. }
  66. /**
  67. * Set the customer ListID
  68. *
  69. * @param string $ListID
  70. * @return boolean
  71. */
  72. public function setCustomerListID($ListID)
  73. {
  74. return $this->set('CustomerRef ListID' , $ListID);
  75. }
  76. /**
  77. * Set the customer ApplicationID (auto-replaced by the API with a ListID)
  78. *
  79. * @param mixed $value
  80. * @return boolean
  81. */
  82. public function setCustomerApplicationID($value)
  83. {
  84. return $this->set('CustomerRef ' . QUICKBOOKS_API_APPLICATIONID, $this->encodeApplicationID(QUICKBOOKS_OBJECT_CUSTOMER, QUICKBOOKS_LISTID, $value));
  85. }
  86. public function getCustomerApplicationID()
  87. {
  88. return $this->get('CustomerRef ' . QUICKBOOKS_API_APPLICATIONID);
  89. }
  90. /**
  91. * @deprecated
  92. */
  93. public function setCustomerName($name)
  94. {
  95. return $this->set('CustomerRef FullName', $name);
  96. }
  97. public function setCustomerFullName($name)
  98. {
  99. return $this->set('CustomerRef FullName', $name);
  100. }
  101. /**
  102. * Get the customer ListID
  103. *
  104. * @return string
  105. */
  106. public function getCustomerListID()
  107. {
  108. return $this->get('CustomerRef ListID');
  109. }
  110. /**
  111. * @deprecated
  112. */
  113. public function getCustomerName()
  114. {
  115. return $this->get('CustomerRef FullName');
  116. }
  117. public function getCustomerFullName()
  118. {
  119. return $this->get('CustomerRef FullName');
  120. }
  121. /**
  122. * Set the transaction date
  123. *
  124. * @param string $date
  125. * @return boolean
  126. */
  127. public function setTxnDate($date)
  128. {
  129. return $this->setDateType('TxnDate', $date);
  130. }
  131. /**
  132. * Alias of {@link QuickBooks_Object_Invoice::setTxnDate()}
  133. */
  134. public function setTransactionDate($date)
  135. {
  136. return $this->setTxnDate($date);
  137. }
  138. /**
  139. * Get the transaction date
  140. *
  141. * @return string
  142. */
  143. public function getTxnDate($format = 'Y-m-d')
  144. {
  145. return $this->getDateType('TxnDate');
  146. }
  147. /**
  148. * Set the reference number
  149. *
  150. * @param string $str
  151. * @return boolean
  152. */
  153. public function setRefNumber($str)
  154. {
  155. return $this->set('RefNumber', $str);
  156. }
  157. /**
  158. * Get the reference number
  159. *
  160. * @return string
  161. */
  162. public function getRefNumber()
  163. {
  164. return $this->get('RefNumber');
  165. }
  166. /**
  167. * Alias of {@link QuickBooks_Object_ReceivePayment::addAppliedToTxn()}
  168. */
  169. public function addAppliedToTransaction($obj)
  170. {
  171. return $this->addAppliedToTxn($obj);
  172. }
  173. /**
  174. *
  175. *
  176. */
  177. public function addAppliedToTxn($obj)
  178. {
  179. /*
  180. $lines = $this->get('AppliedToTxn');
  181. if (!is_array($lines))
  182. {
  183. $lines = array();
  184. }
  185. //
  186. $lines[] = $obj;
  187. return $this->set('AppliedToTxn', $lines);*/
  188. return $this->addListItem('AppliedToTxn', $obj);
  189. }
  190. public function getAppliedToTxn($i)
  191. {
  192. return $this->getListItem('AppliedToTxn', $i);
  193. }
  194. public function listAppliedToTxns()
  195. {
  196. return $this->getList('AppliedToTxn');
  197. }
  198. /**
  199. * Alias of {@link QuickBooks_Object_Invoice::getTxnDate()}
  200. */
  201. public function getTransactionDate($format = 'Y-m-d')
  202. {
  203. return $this->getDateType('TxnDate', $format);
  204. }
  205. /**
  206. * Set the total amount of the received payment
  207. *
  208. * @param float $amount
  209. * @return boolean
  210. */
  211. public function setTotalAmount($amount)
  212. {
  213. return $this->setAmountType('TotalAmount', $amount);
  214. }
  215. /**
  216. * Get the total amount of the received payment
  217. *
  218. * @return float
  219. */
  220. public function getTotalAmount()
  221. {
  222. return $this->getAmountType('TotalAmount');
  223. }
  224. public function setARAccountListID($ListID)
  225. {
  226. return $this->set('ARAccountRef ListID', $ListID);
  227. }
  228. /**
  229. * @deprecated
  230. */
  231. public function setARAccountName($name)
  232. {
  233. return $this->set('ARAccountRef FullName', $name);
  234. }
  235. public function setARAccountFullName($name)
  236. {
  237. return $this->set('ARAccountRef FullName', $name);
  238. }
  239. public function setARAccountApplicationID($value)
  240. {
  241. return $this->set('ARAccountRef ' . QUICKBOOKS_API_APPLICATIONID, $this->encodeApplicationID(QUICKBOOKS_OBJECT_ACCOUNT, QUICKBOOKS_LISTID, $value));
  242. }
  243. public function getARAccountApplicationID()
  244. {
  245. return $this->get('ARAccountRef ' . QUICKBOOKS_API_APPLICATIONID);
  246. }
  247. public function getARAccountListID()
  248. {
  249. return $this->get('ARAccountRef ListID');
  250. }
  251. /**
  252. * @deprecated
  253. */
  254. public function getARAccountName()
  255. {
  256. return $this->get('ARAccountRef FullName');
  257. }
  258. public function getARAccountFullName()
  259. {
  260. return $this->get('ARAccountRef FullName');
  261. }
  262. public function setPaymentMethodListID($ListID)
  263. {
  264. return $this->set('PaymentMethodRef ListID', $ListID);
  265. }
  266. /**
  267. * @deprecated
  268. */
  269. public function setPaymentMethodName($name)
  270. {
  271. return $this->set('PaymentMethodRef FullName', $name);
  272. }
  273. public function setPaymentMethodFullName($name)
  274. {
  275. return $this->set('PaymentMethodRef FullName', $name);
  276. }
  277. public function setPaymentMethodApplicationID($value)
  278. {
  279. return $this->set('PaymentMethodRef ' . QUICKBOOKS_API_APPLICATIONID, $this->encodeApplicationID(QUICKBOOKS_OBJECT_PAYMENTMETHOD, QUICKBOOKS_LISTID, $value));
  280. }
  281. public function getPaymentMethodApplicationID()
  282. {
  283. return $this->get('PaymentMethodRef ' . QUICKBOOKS_API_APPLICATIONID);
  284. }
  285. public function getPaymentMethodListID()
  286. {
  287. return $this->get('PaymentMethodRef ListID');
  288. }
  289. /**
  290. * @deprecated
  291. */
  292. public function getPaymentMethodName()
  293. {
  294. return $this->get('PaymentMethodRef FullName');
  295. }
  296. public function getPaymentMethodFullName()
  297. {
  298. return $this->get('PaymentMethodRef FullName');
  299. }
  300. public function setDepositToAccountListID($ListID)
  301. {
  302. return $this->set('DepositToAccountRef ListID', $ListID);
  303. }
  304. /**
  305. * @deprecated
  306. */
  307. public function setDepositToAccountName($name)
  308. {
  309. return $this->set('DepositToAccountRef FullName', $name);
  310. }
  311. public function setDepositToAccountFullName()
  312. {
  313. return $this->set('DepositToAccountRef FullName', $name);
  314. }
  315. public function setDepositToAccountApplicationID($value)
  316. {
  317. return $this->set('DepositToAccountRef ' . QUICKBOOKS_API_APPLICATIONID, $this->encodeApplicationID(QUICKBOOKS_OBJECT_ACCOUNT, QUICKBOOKS_LISTID, $value));
  318. }
  319. public function getDepositToAccountApplicationID()
  320. {
  321. return $this->get('DepositToAccountRef ' . QUICKBOOKS_API_APPLICATIONID);
  322. }
  323. public function getDepositToAccountListID()
  324. {
  325. return $this->get('DepositToAccountRef ListID');
  326. }
  327. /**
  328. * @deprecated
  329. */
  330. public function getDepositToAccountName()
  331. {
  332. return $this->get('DepositToAccountRef FullName');
  333. }
  334. public function getDepositToAccountFullName()
  335. {
  336. return $this->get('DepositToAccountRef FullName');
  337. }
  338. public function setMemo($memo)
  339. {
  340. return $this->set('Memo', $memo);
  341. }
  342. public function getMemo()
  343. {
  344. return $this->get('Memo');
  345. }
  346. /**
  347. * Set whether or not this transaction is an auto-apply transaction
  348. *
  349. * @param boolean $isautoapply
  350. * @return boolean
  351. */
  352. public function setIsAutoApply($isautoapply)
  353. {
  354. if ($isautoapply and strtolower($isautoapply) != 'false')
  355. {
  356. return $this->set('IsAutoApply', 'true');
  357. }
  358. else
  359. {
  360. return $this->set('IsAutoApply', 'false');
  361. }
  362. }
  363. /**
  364. * Get whether or not this transaction is an auto-apply transaction
  365. *
  366. * @return boolean
  367. */
  368. public function getIsAutoApply()
  369. {
  370. return $this->get('IsAutoApply') != 'false';
  371. }
  372. /**
  373. * Perform any needed clean-up of the object data members
  374. *
  375. * @return boolean
  376. */
  377. protected function _cleanup()
  378. {
  379. return true;
  380. }
  381. /**
  382. * Get an array representation of this Class object
  383. *
  384. * @param string $request
  385. * @param boolean $nest
  386. * @return array
  387. */
  388. /*public function asArray($request, $nest = true)
  389. {
  390. $this->_cleanup();
  391. return parent::asArray($request, $nest);
  392. }*/
  393. public function asList($request)
  394. {
  395. switch ($request)
  396. {
  397. case 'ReceivePaymentAddRq':
  398. if (isset($this->_object['AppliedToTxn']))
  399. {
  400. $this->_object['AppliedToTxnAdd'] = $this->_object['AppliedToTxn'];
  401. }
  402. break;
  403. case 'ReceivePaymentModRq':
  404. if (isset($this->_object['AppliedToTxn']))
  405. {
  406. $this->_object['AppliedToTxnMod'] = $this->_object['AppliedToTxn'];
  407. }
  408. break;
  409. }
  410. return parent::asList($request);
  411. }
  412. public function asXML($root = null, $parent = null, $object = null)
  413. {
  414. if (is_null($object))
  415. {
  416. $object = $this->_object;
  417. }
  418. switch ($root)
  419. {
  420. case QUICKBOOKS_ADD_RECEIVEPAYMENT:
  421. /*
  422. if (isset($this->_object['AppliedToTxn']))
  423. {
  424. $this->_object['AppliedToTxnAdd'] = $this->_object['AppliedToTxn'];
  425. }
  426. */
  427. if ($this->exists('AppliedToTxnAdd'))
  428. {
  429. foreach ($object['AppliedToTxnAdd'] as $key => $obj)
  430. {
  431. $obj->setOverride('AppliedToTxnAdd');
  432. }
  433. }
  434. break;
  435. case QUICKBOOKS_MOD_RECEIVEPAYMENT:
  436. // finish me!
  437. break;
  438. }
  439. return parent::asXML($root, $parent, $object);
  440. }
  441. /**
  442. * Convert this object to a valid qbXML request
  443. *
  444. * @param string $request The type of request to convert this to (examples: CustomerAddRq, CustomerModRq, CustomerQueryRq)
  445. * @param boolean $todo_for_empty_elements A constant, one of: QUICKBOOKS_XML_XML_COMPRESS, QUICKBOOKS_XML_XML_DROP, QUICKBOOKS_XML_XML_PRESERVE
  446. * @param string $indent
  447. * @param string $root
  448. * @return string
  449. */
  450. /*
  451. public function asQBXML($request, $todo_for_empty_elements = QUICKBOOKS_OBJECT_XML_DROP, $indent = "\t", $root = null)
  452. {
  453. $this->_cleanup();
  454. return parent::asQBXML($request, $todo_for_empty_elements, $indent, $root);
  455. }
  456. */
  457. /**
  458. * Tell what type of object this is
  459. *
  460. * @return string
  461. */
  462. public function object()
  463. {
  464. return QUICKBOOKS_OBJECT_RECEIVEPAYMENT;
  465. }
  466. }