Merge pull request #9072 from jeromelebleu/patch-19386
[civicrm-core.git] / CRM / Financial / DAO / FinancialTrxn.php
1 <?php
2 /*
3 +--------------------------------------------------------------------+
4 | CiviCRM version 4.7 |
5 +--------------------------------------------------------------------+
6 | Copyright CiviCRM LLC (c) 2004-2017 |
7 +--------------------------------------------------------------------+
8 | This file is a part of CiviCRM. |
9 | |
10 | CiviCRM is free software; you can copy, modify, and distribute it |
11 | under the terms of the GNU Affero General Public License |
12 | Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
13 | |
14 | CiviCRM is distributed in the hope that it will be useful, but |
15 | WITHOUT ANY WARRANTY; without even the implied warranty of |
16 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
17 | See the GNU Affero General Public License for more details. |
18 | |
19 | You should have received a copy of the GNU Affero General Public |
20 | License and the CiviCRM Licensing Exception along |
21 | with this program; if not, contact CiviCRM LLC |
22 | at info[AT]civicrm[DOT]org. If you have questions about the |
23 | GNU Affero General Public License or the licensing of CiviCRM, |
24 | see the CiviCRM license FAQ at http://civicrm.org/licensing |
25 +--------------------------------------------------------------------+
26 */
27 /**
28 * @package CRM
29 * @copyright CiviCRM LLC (c) 2004-2017
30 *
31 * Generated from xml/schema/CRM/Financial/FinancialTrxn.xml
32 * DO NOT EDIT. Generated by CRM_Core_CodeGen
33 * (GenCodeChecksum:52a627d344bca95d30eb8b22aad1e245)
34 */
35 require_once 'CRM/Core/DAO.php';
36 require_once 'CRM/Utils/Type.php';
37 /**
38 * CRM_Financial_DAO_FinancialTrxn constructor.
39 */
40 class CRM_Financial_DAO_FinancialTrxn extends CRM_Core_DAO {
41 /**
42 * Static instance to hold the table name.
43 *
44 * @var string
45 */
46 static $_tableName = 'civicrm_financial_trxn';
47 /**
48 * Should CiviCRM log any modifications to this table in the civicrm_log table.
49 *
50 * @var boolean
51 */
52 static $_log = true;
53 /**
54 *
55 * @var int unsigned
56 */
57 public $id;
58 /**
59 * FK to financial_account table.
60 *
61 * @var int unsigned
62 */
63 public $from_financial_account_id;
64 /**
65 * FK to financial_financial_account table.
66 *
67 * @var int unsigned
68 */
69 public $to_financial_account_id;
70 /**
71 * date transaction occurred
72 *
73 * @var datetime
74 */
75 public $trxn_date;
76 /**
77 * amount of transaction
78 *
79 * @var float
80 */
81 public $total_amount;
82 /**
83 * actual processor fee if known - may be 0.
84 *
85 * @var float
86 */
87 public $fee_amount;
88 /**
89 * actual funds transfer amount. total less fees. if processor does not report actual fee during transaction, this is set to total_amount.
90 *
91 * @var float
92 */
93 public $net_amount;
94 /**
95 * 3 character string, value from config setting or input via user.
96 *
97 * @var string
98 */
99 public $currency;
100 /**
101 * Is this entry either a payment or a reversal of a payment?
102 *
103 * @var boolean
104 */
105 public $is_payment;
106 /**
107 * Transaction id supplied by external processor. This may not be unique.
108 *
109 * @var string
110 */
111 public $trxn_id;
112 /**
113 * processor result code
114 *
115 * @var string
116 */
117 public $trxn_result_code;
118 /**
119 * pseudo FK to civicrm_option_value of contribution_status_id option_group
120 *
121 * @var int unsigned
122 */
123 public $status_id;
124 /**
125 * Payment Processor for this financial transaction
126 *
127 * @var int unsigned
128 */
129 public $payment_processor_id;
130 /**
131 * FK to payment_instrument option group values
132 *
133 * @var int unsigned
134 */
135 public $payment_instrument_id;
136 /**
137 * FK to accept_creditcard option group values
138 *
139 * @var int unsigned
140 */
141 public $card_type;
142 /**
143 * Check number
144 *
145 * @var string
146 */
147 public $check_number;
148 /**
149 * Last 4 digits of credit card
150 *
151 * @var int unsigned
152 */
153 public $pan_truncation;
154 /**
155 * Class constructor.
156 */
157 function __construct() {
158 $this->__table = 'civicrm_financial_trxn';
159 parent::__construct();
160 }
161 /**
162 * Returns foreign keys and entity references.
163 *
164 * @return array
165 * [CRM_Core_Reference_Interface]
166 */
167 static function getReferenceColumns() {
168 if (!isset(Civi::$statics[__CLASS__]['links'])) {
169 Civi::$statics[__CLASS__]['links'] = static ::createReferenceColumns(__CLASS__);
170 Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName() , 'from_financial_account_id', 'civicrm_financial_account', 'id');
171 Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName() , 'to_financial_account_id', 'civicrm_financial_account', 'id');
172 Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName() , 'payment_processor_id', 'civicrm_payment_processor', 'id');
173 CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'links_callback', Civi::$statics[__CLASS__]['links']);
174 }
175 return Civi::$statics[__CLASS__]['links'];
176 }
177 /**
178 * Returns all the column names of this table
179 *
180 * @return array
181 */
182 static function &fields() {
183 if (!isset(Civi::$statics[__CLASS__]['fields'])) {
184 Civi::$statics[__CLASS__]['fields'] = array(
185 'id' => array(
186 'name' => 'id',
187 'type' => CRM_Utils_Type::T_INT,
188 'title' => ts('Financial Transaction ID') ,
189 'required' => true,
190 'table_name' => 'civicrm_financial_trxn',
191 'entity' => 'FinancialTrxn',
192 'bao' => 'CRM_Financial_DAO_FinancialTrxn',
193 ) ,
194 'from_financial_account_id' => array(
195 'name' => 'from_financial_account_id',
196 'type' => CRM_Utils_Type::T_INT,
197 'title' => ts('Financial Transaction From Account') ,
198 'description' => 'FK to financial_account table.',
199 'table_name' => 'civicrm_financial_trxn',
200 'entity' => 'FinancialTrxn',
201 'bao' => 'CRM_Financial_DAO_FinancialTrxn',
202 'FKClassName' => 'CRM_Financial_DAO_FinancialAccount',
203 'html' => array(
204 'type' => 'Select',
205 ) ,
206 'pseudoconstant' => array(
207 'table' => 'civicrm_financial_account',
208 'keyColumn' => 'id',
209 'labelColumn' => 'name',
210 )
211 ) ,
212 'to_financial_account_id' => array(
213 'name' => 'to_financial_account_id',
214 'type' => CRM_Utils_Type::T_INT,
215 'title' => ts('Financial Transaction To Account') ,
216 'description' => 'FK to financial_financial_account table.',
217 'table_name' => 'civicrm_financial_trxn',
218 'entity' => 'FinancialTrxn',
219 'bao' => 'CRM_Financial_DAO_FinancialTrxn',
220 'FKClassName' => 'CRM_Financial_DAO_FinancialAccount',
221 'html' => array(
222 'type' => 'Select',
223 ) ,
224 'pseudoconstant' => array(
225 'table' => 'civicrm_financial_account',
226 'keyColumn' => 'id',
227 'labelColumn' => 'name',
228 )
229 ) ,
230 'trxn_date' => array(
231 'name' => 'trxn_date',
232 'type' => CRM_Utils_Type::T_DATE + CRM_Utils_Type::T_TIME,
233 'title' => ts('Financial Transaction Date') ,
234 'description' => 'date transaction occurred',
235 'default' => 'NULL',
236 'table_name' => 'civicrm_financial_trxn',
237 'entity' => 'FinancialTrxn',
238 'bao' => 'CRM_Financial_DAO_FinancialTrxn',
239 ) ,
240 'total_amount' => array(
241 'name' => 'total_amount',
242 'type' => CRM_Utils_Type::T_MONEY,
243 'title' => ts('Financial Total Amount') ,
244 'description' => 'amount of transaction',
245 'required' => true,
246 'precision' => array(
247 20,
248 2
249 ) ,
250 'table_name' => 'civicrm_financial_trxn',
251 'entity' => 'FinancialTrxn',
252 'bao' => 'CRM_Financial_DAO_FinancialTrxn',
253 ) ,
254 'fee_amount' => array(
255 'name' => 'fee_amount',
256 'type' => CRM_Utils_Type::T_MONEY,
257 'title' => ts('Financial Fee Amount') ,
258 'description' => 'actual processor fee if known - may be 0.',
259 'precision' => array(
260 20,
261 2
262 ) ,
263 'table_name' => 'civicrm_financial_trxn',
264 'entity' => 'FinancialTrxn',
265 'bao' => 'CRM_Financial_DAO_FinancialTrxn',
266 ) ,
267 'net_amount' => array(
268 'name' => 'net_amount',
269 'type' => CRM_Utils_Type::T_MONEY,
270 'title' => ts('Financial Net Amount') ,
271 'description' => 'actual funds transfer amount. total less fees. if processor does not report actual fee during transaction, this is set to total_amount.',
272 'precision' => array(
273 20,
274 2
275 ) ,
276 'table_name' => 'civicrm_financial_trxn',
277 'entity' => 'FinancialTrxn',
278 'bao' => 'CRM_Financial_DAO_FinancialTrxn',
279 ) ,
280 'currency' => array(
281 'name' => 'currency',
282 'type' => CRM_Utils_Type::T_STRING,
283 'title' => ts('Financial Currency') ,
284 'description' => '3 character string, value from config setting or input via user.',
285 'maxlength' => 3,
286 'size' => CRM_Utils_Type::FOUR,
287 'import' => true,
288 'where' => 'civicrm_financial_trxn.currency',
289 'headerPattern' => '/cur(rency)?/i',
290 'dataPattern' => '/^[A-Z]{3}$/',
291 'export' => true,
292 'default' => 'NULL',
293 'table_name' => 'civicrm_financial_trxn',
294 'entity' => 'FinancialTrxn',
295 'bao' => 'CRM_Financial_DAO_FinancialTrxn',
296 'html' => array(
297 'type' => 'Select',
298 ) ,
299 'pseudoconstant' => array(
300 'table' => 'civicrm_currency',
301 'keyColumn' => 'name',
302 'labelColumn' => 'full_name',
303 'nameColumn' => 'name',
304 )
305 ) ,
306 'is_payment' => array(
307 'name' => 'is_payment',
308 'type' => CRM_Utils_Type::T_BOOLEAN,
309 'title' => ts('Is Payment?') ,
310 'description' => 'Is this entry either a payment or a reversal of a payment?',
311 'import' => true,
312 'where' => 'civicrm_financial_trxn.is_payment',
313 'headerPattern' => '',
314 'dataPattern' => '',
315 'export' => true,
316 'table_name' => 'civicrm_financial_trxn',
317 'entity' => 'FinancialTrxn',
318 'bao' => 'CRM_Financial_DAO_FinancialTrxn',
319 ) ,
320 'trxn_id' => array(
321 'name' => 'trxn_id',
322 'type' => CRM_Utils_Type::T_STRING,
323 'title' => ts('Transaction ID') ,
324 'description' => 'Transaction id supplied by external processor. This may not be unique.',
325 'maxlength' => 255,
326 'size' => CRM_Utils_Type::HUGE,
327 'table_name' => 'civicrm_financial_trxn',
328 'entity' => 'FinancialTrxn',
329 'bao' => 'CRM_Financial_DAO_FinancialTrxn',
330 ) ,
331 'trxn_result_code' => array(
332 'name' => 'trxn_result_code',
333 'type' => CRM_Utils_Type::T_STRING,
334 'title' => ts('Transaction Result Code') ,
335 'description' => 'processor result code',
336 'maxlength' => 255,
337 'size' => CRM_Utils_Type::HUGE,
338 'table_name' => 'civicrm_financial_trxn',
339 'entity' => 'FinancialTrxn',
340 'bao' => 'CRM_Financial_DAO_FinancialTrxn',
341 ) ,
342 'status_id' => array(
343 'name' => 'status_id',
344 'type' => CRM_Utils_Type::T_INT,
345 'title' => ts('Financial Transaction Status Id') ,
346 'description' => 'pseudo FK to civicrm_option_value of contribution_status_id option_group',
347 'import' => true,
348 'where' => 'civicrm_financial_trxn.status_id',
349 'headerPattern' => '/status/i',
350 'dataPattern' => '',
351 'export' => true,
352 'table_name' => 'civicrm_financial_trxn',
353 'entity' => 'FinancialTrxn',
354 'bao' => 'CRM_Financial_DAO_FinancialTrxn',
355 'pseudoconstant' => array(
356 'optionGroupName' => 'contribution_status',
357 'optionEditPath' => 'civicrm/admin/options/contribution_status',
358 )
359 ) ,
360 'payment_processor_id' => array(
361 'name' => 'payment_processor_id',
362 'type' => CRM_Utils_Type::T_INT,
363 'title' => ts('Payment Processor') ,
364 'description' => 'Payment Processor for this financial transaction',
365 'table_name' => 'civicrm_financial_trxn',
366 'entity' => 'FinancialTrxn',
367 'bao' => 'CRM_Financial_DAO_FinancialTrxn',
368 'FKClassName' => 'CRM_Financial_DAO_PaymentProcessor',
369 ) ,
370 'financial_trxn_payment_instrument_id' => array(
371 'name' => 'payment_instrument_id',
372 'type' => CRM_Utils_Type::T_INT,
373 'title' => ts('Payment Method') ,
374 'description' => 'FK to payment_instrument option group values',
375 'table_name' => 'civicrm_financial_trxn',
376 'entity' => 'FinancialTrxn',
377 'bao' => 'CRM_Financial_DAO_FinancialTrxn',
378 'html' => array(
379 'type' => 'Select',
380 ) ,
381 'pseudoconstant' => array(
382 'optionGroupName' => 'payment_instrument',
383 'optionEditPath' => 'civicrm/admin/options/payment_instrument',
384 )
385 ) ,
386 'financial_trxn_card_type' => array(
387 'name' => 'card_type',
388 'type' => CRM_Utils_Type::T_INT,
389 'title' => ts('Card Type') ,
390 'description' => 'FK to accept_creditcard option group values',
391 'table_name' => 'civicrm_financial_trxn',
392 'entity' => 'FinancialTrxn',
393 'bao' => 'CRM_Financial_DAO_FinancialTrxn',
394 'html' => array(
395 'type' => 'Select',
396 ) ,
397 'pseudoconstant' => array(
398 'optionGroupName' => 'accept_creditcard',
399 'optionEditPath' => 'civicrm/admin/options/accept_creditcard',
400 )
401 ) ,
402 'financial_trxn_check_number' => array(
403 'name' => 'check_number',
404 'type' => CRM_Utils_Type::T_STRING,
405 'title' => ts('Check Number') ,
406 'description' => 'Check number',
407 'maxlength' => 255,
408 'size' => 6,
409 'table_name' => 'civicrm_financial_trxn',
410 'entity' => 'FinancialTrxn',
411 'bao' => 'CRM_Financial_DAO_FinancialTrxn',
412 'html' => array(
413 'type' => 'Text',
414 ) ,
415 ) ,
416 'financial_trxn_pan_truncation' => array(
417 'name' => 'pan_truncation',
418 'type' => CRM_Utils_Type::T_INT,
419 'title' => ts('Pan Truncation') ,
420 'description' => 'Last 4 digits of credit card',
421 'table_name' => 'civicrm_financial_trxn',
422 'entity' => 'FinancialTrxn',
423 'bao' => 'CRM_Financial_DAO_FinancialTrxn',
424 'html' => array(
425 'type' => 'Text',
426 ) ,
427 ) ,
428 );
429 CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'fields_callback', Civi::$statics[__CLASS__]['fields']);
430 }
431 return Civi::$statics[__CLASS__]['fields'];
432 }
433 /**
434 * Return a mapping from field-name to the corresponding key (as used in fields()).
435 *
436 * @return array
437 * Array(string $name => string $uniqueName).
438 */
439 static function &fieldKeys() {
440 if (!isset(Civi::$statics[__CLASS__]['fieldKeys'])) {
441 Civi::$statics[__CLASS__]['fieldKeys'] = array_flip(CRM_Utils_Array::collect('name', self::fields()));
442 }
443 return Civi::$statics[__CLASS__]['fieldKeys'];
444 }
445 /**
446 * Returns the names of this table
447 *
448 * @return string
449 */
450 static function getTableName() {
451 return self::$_tableName;
452 }
453 /**
454 * Returns if this table needs to be logged
455 *
456 * @return boolean
457 */
458 function getLog() {
459 return self::$_log;
460 }
461 /**
462 * Returns the list of fields that can be imported
463 *
464 * @param bool $prefix
465 *
466 * @return array
467 */
468 static function &import($prefix = false) {
469 $r = CRM_Core_DAO_AllCoreTables::getImports(__CLASS__, 'financial_trxn', $prefix, array());
470 return $r;
471 }
472 /**
473 * Returns the list of fields that can be exported
474 *
475 * @param bool $prefix
476 *
477 * @return array
478 */
479 static function &export($prefix = false) {
480 $r = CRM_Core_DAO_AllCoreTables::getExports(__CLASS__, 'financial_trxn', $prefix, array());
481 return $r;
482 }
483 }