Row.php 9.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236
  1. <?php
  2. /**
  3. * Copyright © Magento, Inc. All rights reserved.
  4. * See COPYING.txt for license details.
  5. */
  6. namespace Magento\Paypal\Model\Report\Settlement;
  7. /**
  8. * Model for report rows
  9. * @method int getReportId()
  10. * @method Row setReportId(int $value)
  11. * @method string getTransactionId()
  12. * @method Row setTransactionId(string $value)
  13. * @method string getInvoiceId()
  14. * @method Row setInvoiceId(string $value)
  15. * @method string getPaypalReferenceId()
  16. * @method Row setPaypalReferenceId(string $value)
  17. * @method string getPaypalReferenceIdType()
  18. * @method Row setPaypalReferenceIdType(string $value)
  19. * @method string getTransactionEventCode()
  20. * @method Row setTransactionEventCode(string $value)
  21. * @method string getTransactionInitiationDate()
  22. * @method Row setTransactionInitiationDate(string $value)
  23. * @method string getTransactionCompletionDate()
  24. * @method Row setTransactionCompletionDate(string $value)
  25. * @method string getTransactionDebitOrCredit()
  26. * @method Row setTransactionDebitOrCredit(string $value)
  27. * @method float getGrossTransactionAmount()
  28. * @method Row setGrossTransactionAmount(float $value)
  29. * @method string getGrossTransactionCurrency()
  30. * @method Row setGrossTransactionCurrency(string $value)
  31. * @method string getFeeDebitOrCredit()
  32. * @method Row setFeeDebitOrCredit(string $value)
  33. * @method float getFeeAmount()
  34. * @method Row setFeeAmount(float $value)
  35. * @method string getFeeCurrency()
  36. * @method Row setFeeCurrency(string $value)
  37. * @method string getCustomField()
  38. * @method Row setCustomField(string $value)
  39. * @method string getConsumerId()
  40. * @method Row setConsumerId(string $value)
  41. *
  42. * @author Magento Core Team <core@magentocommerce.com>
  43. */
  44. class Row extends \Magento\Framework\Model\AbstractModel
  45. {
  46. /**
  47. * Assoc array event code => label
  48. *
  49. * @var array
  50. */
  51. private $eventLabelsList = [];
  52. /**
  53. * Cast amount relation
  54. *
  55. * @var array
  56. */
  57. private $castAmountRelation = [
  58. 'fee_amount' => 'fee_debit_or_credit',
  59. 'gross_transaction_amount' => 'transaction_debit_or_credit',
  60. ];
  61. /**
  62. * Initialize resource model
  63. *
  64. * @return void
  65. */
  66. protected function _construct()
  67. {
  68. $this->_init(\Magento\Paypal\Model\ResourceModel\Report\Settlement\Row::class);
  69. }
  70. /**
  71. * Return description of Reference ID Type
  72. * If no code specified, return full list of codes with their description
  73. *
  74. * @param string $code
  75. * @return string
  76. */
  77. public function getReferenceType($code)
  78. {
  79. $types = [
  80. 'ODR' => __('Order ID'),
  81. 'PAP' => __('Preapproved Payment ID'),
  82. 'TXN' => __('Transaction ID'),
  83. 'SUB' => __('Subscription ID'),
  84. ];
  85. return !empty($types[$code]) ? $types[$code] : $code;
  86. }
  87. /**
  88. * Get native description for transaction code
  89. *
  90. * @param string $code
  91. * @return string
  92. */
  93. public function getTransactionEvent($code)
  94. {
  95. $events = $this->getTransactionEvents();
  96. return !empty($events[$code]) ? $events[$code] : $code;
  97. }
  98. /**
  99. * Return description of "Debit or Credit" value
  100. *
  101. * @param string $code
  102. * @return string
  103. */
  104. public function getDebitCreditText($code)
  105. {
  106. $options = ['CR' => __('Credit'), 'DR' => __('Debit')];
  107. return !empty($options[$code]) ? $options[$code] : $code;
  108. }
  109. /**
  110. * Cast amounts of the specified keys
  111. *
  112. * If the "credit" value is detected, it will be casted to negative amount
  113. *
  114. * @param string $key
  115. * @return float|null
  116. */
  117. public function getCastedAmount($key)
  118. {
  119. if (empty($this->castAmountRelation[$key])) {
  120. return null;
  121. }
  122. if (empty($this->_data[$key]) || empty($this->_data[$this->castAmountRelation[$key]])) {
  123. return null;
  124. }
  125. $amount = $this->_data[$key];
  126. if ('CR' == $this->_data[$this->castAmountRelation[$key]]) {
  127. $amount = -1 * $amount;
  128. }
  129. return $amount;
  130. }
  131. /**
  132. * Get full list of codes with their description
  133. *
  134. * @return array
  135. */
  136. public function getTransactionEvents()
  137. {
  138. if (empty($this->eventLabelsList)) {
  139. $this->eventLabelsList = [
  140. 'T1502' => __('ACH Deposit (Hold for Dispute or Other Investigation)'),
  141. 'T1104' => __('ACH Deposit (Reversal)'),
  142. 'T0302' => __('ACH Funding for Funds Recovery from Account Balance'),
  143. 'T1101' => __('ACH Withdrawal'),
  144. 'T1106' => __('Account-to-Account Payment, initiated by PayPal'),
  145. 'T0010' => __('Auction Payment other than through eBay'),
  146. 'T0401' => __('AutoSweep'),
  147. 'T1503' => __('Available Balance'),
  148. 'T0803' => __('Balance Manager Account Bonus'),
  149. 'T0806' => __('Bonus for first ACH Use'),
  150. 'T1800' => __('Buyer Credit Payment'),
  151. 'T1203' => __('Charge-off'),
  152. 'T1201' => __('Chargeback'),
  153. 'T0903' => __('Coupon Redemption'),
  154. 'T0202' => __('Currency Conversion required to cover negative balance'),
  155. 'T0801' => __('Debit Card Cash Back'),
  156. 'T1102' => __('Debit Card Transaction'),
  157. 'T0005' => __('Direct Payment API'),
  158. 'T0303' => __('EFT Funding (German banking)'),
  159. 'T0006' => __('Express Checkout APIs'),
  160. 'T1108' => __('Fee Reversal'),
  161. 'T0102' => __('Fee: Foreign ACH Withdrawal'),
  162. 'T0104' => __('Fee: Mass Pay Request'),
  163. 'T0101' => __('Fee: Web Site Payments Pro Account Monthly'),
  164. 'T0103' => __('Fee: WorldLink Check Withdrawal'),
  165. 'T1600' => __('Funding'),
  166. 'T1300' => __('General (Authorization)'),
  167. 'T1400' => __('General (Dividend)'),
  168. 'T2000' => __('General (Funds Transfer from PayPal Account to Another)'),
  169. 'T0700' => __('General (Purchase with a credit card)'),
  170. 'T1900' => __('General Adjustment without businessrelated event'),
  171. 'T0200' => __('General Currency Conversion'),
  172. 'T0300' => __('General Funding of PayPal Account '),
  173. 'T0900' => __('General Redemption'),
  174. 'T0400' => __('General Withdrawal from PayPal Account'),
  175. 'T1000' => __('General. Product no longer supported'),
  176. 'T0500' => __('General: Use of PayPal account for purchasing as well as receiving payments'),
  177. 'T0600' => __('General: Withdrawal from PayPal Account'),
  178. 'T1700' => __('General: Withdrawal to Non-Bank Entity'),
  179. 'T1200' => __('General: adjustment of a type not belonging to the other T12xx categories'),
  180. 'T0800' => __('General: bonus of a type not belonging to the other T08xx categories'),
  181. 'T9900' => __('General: event not yet categorized'),
  182. 'T0100' => __('General: non-payment fee of a type not belonging to the other T01xx categories'),
  183. 'T0000' => __('General: received payment of a type not belonging to the other T00xx categories'),
  184. 'T1100' => __('General: reversal of a type not belonging to the other T11xx categories'),
  185. 'T1500' => __('General: temporary hold of a type not belonging to the other T15xx categories'),
  186. 'T0009' => __('Gift Certificate Payment: purchase of Gift Certificate'),
  187. 'T0901' => __('Gift Certificate Redemption'),
  188. 'T0503' => __('Hidden Virtual PayPal Debit Card Transaction'),
  189. 'T1110' => __('Hold for Dispute Investigation'),
  190. 'T1204' => __('Incentive'),
  191. 'T0001' => __('Mass Pay Payment'),
  192. 'T0802' => __('Merchant Referral Bonus'),
  193. 'T0011' => __('Mobile Payment (made via a mobile phone)'),
  194. 'T0701' => __('Negative Balance'),
  195. 'T1501' => __('Open Authorization'),
  196. 'T0301' => __('PayPal Balance Manager function of PayPal account'),
  197. 'T0804' => __('PayPal Buyer Warranty Bonus'),
  198. 'T0504' => __('PayPal Debit Card Cash Advance'),
  199. 'T0502' => __('PayPal Debit Card Withdrawal from ATM'),
  200. 'T0805' => __('PayPal Protection Bonus'),
  201. 'T1107' => __('Payment Refund initiated by merchant'),
  202. 'T0902' => __('Points Incentive Redemption'),
  203. 'T0008' => __('Postage Payment to either USPS or UPS'),
  204. 'T0003' => __('Preapproved Payment (BillUser API, either sent or received'),
  205. 'T1301' => __('Reauthorization'),
  206. 'T1205' => __('Reimbursement of Chargeback'),
  207. 'T1202' => __('Reversal'),
  208. 'T1105' => __('Reversal of General Account Hold'),
  209. 'T1103' => __('Reversal of Points Usage'),
  210. 'T1111' => __('Reversal of hold for Dispute Investigation'),
  211. 'T0904' => __('Reward Voucher Redemption'),
  212. 'T2001' => __('Settlement Consolidation'),
  213. 'T0002' => __('Subscription Payment, either payment sent or payment received'),
  214. 'T0201' => __('User-initiated Currency Conversion'),
  215. 'T0501' => __('Virtual PayPal Debit Card Transaction'),
  216. 'T0012' => __('Virtual Terminal Payment'),
  217. 'T1302' => __('Void'),
  218. 'T1701' => __('WorldLink Withdrawal'),
  219. 'T0004' => __('eBay Auction Payment'),
  220. ];
  221. }
  222. return $this->eventLabelsList;
  223. }
  224. }