Merge pull request #11415 from JMAConsulting/CRM-21567
[civicrm-core.git] / CRM / Financial / DAO / FinancialTrxn.php
CommitLineData
e501603b
TO
1<?php
2/*
3+--------------------------------------------------------------------+
4| CiviCRM version 4.7 |
5+--------------------------------------------------------------------+
0f03f337 6| Copyright CiviCRM LLC (c) 2004-2017 |
e501603b
TO
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
0f03f337 29 * @copyright CiviCRM LLC (c) 2004-2017
e501603b
TO
30 *
31 * Generated from xml/schema/CRM/Financial/FinancialTrxn.xml
32 * DO NOT EDIT. Generated by CRM_Core_CodeGen
a7a8f17d 33 * (GenCodeChecksum:21185c4929ef1a8d126c72733cc7ad1d)
e501603b
TO
34 */
35require_once 'CRM/Core/DAO.php';
36require_once 'CRM/Utils/Type.php';
f41f0342 37/**
38 * CRM_Financial_DAO_FinancialTrxn constructor.
39 */
e501603b
TO
40class CRM_Financial_DAO_FinancialTrxn extends CRM_Core_DAO {
41 /**
f41f0342 42 * Static instance to hold the table name.
e501603b
TO
43 *
44 * @var string
45 */
46 static $_tableName = 'civicrm_financial_trxn';
e501603b 47 /**
f41f0342 48 * Should CiviCRM log any modifications to this table in the civicrm_log table.
e501603b
TO
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;
ea927522
PN
136 /**
137 * FK to accept_creditcard option group values
138 *
139 * @var int unsigned
140 */
5e0343e8 141 public $card_type_id;
e501603b
TO
142 /**
143 * Check number
144 *
145 * @var string
146 */
147 public $check_number;
ea927522
PN
148 /**
149 * Last 4 digits of credit card
150 *
4e0ede5a 151 * @var string
ea927522
PN
152 */
153 public $pan_truncation;
e501603b 154 /**
f41f0342 155 * Class constructor.
e501603b
TO
156 */
157 function __construct() {
158 $this->__table = 'civicrm_financial_trxn';
159 parent::__construct();
160 }
161 /**
f41f0342 162 * Returns foreign keys and entity references.
e501603b
TO
163 *
164 * @return array
165 * [CRM_Core_Reference_Interface]
166 */
167 static function getReferenceColumns() {
346aaaba
TO
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']);
e501603b 174 }
346aaaba 175 return Civi::$statics[__CLASS__]['links'];
e501603b
TO
176 }
177 /**
178 * Returns all the column names of this table
179 *
180 * @return array
181 */
182 static function &fields() {
346aaaba
TO
183 if (!isset(Civi::$statics[__CLASS__]['fields'])) {
184 Civi::$statics[__CLASS__]['fields'] = array(
e501603b
TO
185 'id' => array(
186 'name' => 'id',
187 'type' => CRM_Utils_Type::T_INT,
188 'title' => ts('Financial Transaction ID') ,
189 'required' => true,
522a26c9 190 'table_name' => 'civicrm_financial_trxn',
191 'entity' => 'FinancialTrxn',
192 'bao' => 'CRM_Financial_DAO_FinancialTrxn',
6a7e5e5d 193 'localizable' => 0,
e501603b
TO
194 ) ,
195 'from_financial_account_id' => array(
196 'name' => 'from_financial_account_id',
197 'type' => CRM_Utils_Type::T_INT,
198 'title' => ts('Financial Transaction From Account') ,
199 'description' => 'FK to financial_account table.',
522a26c9 200 'table_name' => 'civicrm_financial_trxn',
201 'entity' => 'FinancialTrxn',
202 'bao' => 'CRM_Financial_DAO_FinancialTrxn',
6a7e5e5d 203 'localizable' => 0,
e501603b
TO
204 'FKClassName' => 'CRM_Financial_DAO_FinancialAccount',
205 'html' => array(
206 'type' => 'Select',
207 ) ,
208 'pseudoconstant' => array(
209 'table' => 'civicrm_financial_account',
210 'keyColumn' => 'id',
211 'labelColumn' => 'name',
212 )
213 ) ,
214 'to_financial_account_id' => array(
215 'name' => 'to_financial_account_id',
216 'type' => CRM_Utils_Type::T_INT,
217 'title' => ts('Financial Transaction To Account') ,
218 'description' => 'FK to financial_financial_account table.',
522a26c9 219 'table_name' => 'civicrm_financial_trxn',
220 'entity' => 'FinancialTrxn',
221 'bao' => 'CRM_Financial_DAO_FinancialTrxn',
6a7e5e5d 222 'localizable' => 0,
e501603b
TO
223 'FKClassName' => 'CRM_Financial_DAO_FinancialAccount',
224 'html' => array(
225 'type' => 'Select',
226 ) ,
227 'pseudoconstant' => array(
228 'table' => 'civicrm_financial_account',
229 'keyColumn' => 'id',
230 'labelColumn' => 'name',
231 )
232 ) ,
233 'trxn_date' => array(
234 'name' => 'trxn_date',
235 'type' => CRM_Utils_Type::T_DATE + CRM_Utils_Type::T_TIME,
236 'title' => ts('Financial Transaction Date') ,
237 'description' => 'date transaction occurred',
238 'default' => 'NULL',
522a26c9 239 'table_name' => 'civicrm_financial_trxn',
240 'entity' => 'FinancialTrxn',
241 'bao' => 'CRM_Financial_DAO_FinancialTrxn',
6a7e5e5d 242 'localizable' => 0,
f7fb5615 243 'html' => array(
244 'type' => 'Select Date',
245 'formatType' => 'activityDateTime',
246 ) ,
e501603b
TO
247 ) ,
248 'total_amount' => array(
249 'name' => 'total_amount',
250 'type' => CRM_Utils_Type::T_MONEY,
251 'title' => ts('Financial Total Amount') ,
252 'description' => 'amount of transaction',
253 'required' => true,
254 'precision' => array(
255 20,
256 2
257 ) ,
522a26c9 258 'table_name' => 'civicrm_financial_trxn',
259 'entity' => 'FinancialTrxn',
260 'bao' => 'CRM_Financial_DAO_FinancialTrxn',
6a7e5e5d 261 'localizable' => 0,
e501603b
TO
262 ) ,
263 'fee_amount' => array(
264 'name' => 'fee_amount',
265 'type' => CRM_Utils_Type::T_MONEY,
266 'title' => ts('Financial Fee Amount') ,
267 'description' => 'actual processor fee if known - may be 0.',
268 'precision' => array(
269 20,
270 2
271 ) ,
522a26c9 272 'table_name' => 'civicrm_financial_trxn',
273 'entity' => 'FinancialTrxn',
274 'bao' => 'CRM_Financial_DAO_FinancialTrxn',
6a7e5e5d 275 'localizable' => 0,
e501603b
TO
276 ) ,
277 'net_amount' => array(
278 'name' => 'net_amount',
279 'type' => CRM_Utils_Type::T_MONEY,
280 'title' => ts('Financial Net Amount') ,
281 'description' => 'actual funds transfer amount. total less fees. if processor does not report actual fee during transaction, this is set to total_amount.',
282 'precision' => array(
283 20,
284 2
285 ) ,
522a26c9 286 'table_name' => 'civicrm_financial_trxn',
287 'entity' => 'FinancialTrxn',
288 'bao' => 'CRM_Financial_DAO_FinancialTrxn',
6a7e5e5d 289 'localizable' => 0,
e501603b
TO
290 ) ,
291 'currency' => array(
292 'name' => 'currency',
293 'type' => CRM_Utils_Type::T_STRING,
294 'title' => ts('Financial Currency') ,
295 'description' => '3 character string, value from config setting or input via user.',
296 'maxlength' => 3,
297 'size' => CRM_Utils_Type::FOUR,
298 'import' => true,
299 'where' => 'civicrm_financial_trxn.currency',
300 'headerPattern' => '/cur(rency)?/i',
301 'dataPattern' => '/^[A-Z]{3}$/',
302 'export' => true,
303 'default' => 'NULL',
522a26c9 304 'table_name' => 'civicrm_financial_trxn',
305 'entity' => 'FinancialTrxn',
306 'bao' => 'CRM_Financial_DAO_FinancialTrxn',
6a7e5e5d 307 'localizable' => 0,
e501603b
TO
308 'html' => array(
309 'type' => 'Select',
310 ) ,
311 'pseudoconstant' => array(
312 'table' => 'civicrm_currency',
313 'keyColumn' => 'name',
314 'labelColumn' => 'full_name',
315 'nameColumn' => 'name',
316 )
317 ) ,
318 'is_payment' => array(
319 'name' => 'is_payment',
320 'type' => CRM_Utils_Type::T_BOOLEAN,
321 'title' => ts('Is Payment?') ,
322 'description' => 'Is this entry either a payment or a reversal of a payment?',
323 'import' => true,
324 'where' => 'civicrm_financial_trxn.is_payment',
325 'headerPattern' => '',
326 'dataPattern' => '',
327 'export' => true,
522a26c9 328 'table_name' => 'civicrm_financial_trxn',
329 'entity' => 'FinancialTrxn',
330 'bao' => 'CRM_Financial_DAO_FinancialTrxn',
6a7e5e5d 331 'localizable' => 0,
e501603b
TO
332 ) ,
333 'trxn_id' => array(
334 'name' => 'trxn_id',
335 'type' => CRM_Utils_Type::T_STRING,
336 'title' => ts('Transaction ID') ,
337 'description' => 'Transaction id supplied by external processor. This may not be unique.',
338 'maxlength' => 255,
a7a8f17d 339 'size' => 10,
522a26c9 340 'table_name' => 'civicrm_financial_trxn',
341 'entity' => 'FinancialTrxn',
342 'bao' => 'CRM_Financial_DAO_FinancialTrxn',
6a7e5e5d 343 'localizable' => 0,
a7a8f17d 344 'html' => array(
345 'type' => 'Text',
346 ) ,
e501603b
TO
347 ) ,
348 'trxn_result_code' => array(
349 'name' => 'trxn_result_code',
350 'type' => CRM_Utils_Type::T_STRING,
351 'title' => ts('Transaction Result Code') ,
352 'description' => 'processor result code',
353 'maxlength' => 255,
354 'size' => CRM_Utils_Type::HUGE,
522a26c9 355 'table_name' => 'civicrm_financial_trxn',
356 'entity' => 'FinancialTrxn',
357 'bao' => 'CRM_Financial_DAO_FinancialTrxn',
6a7e5e5d 358 'localizable' => 0,
e501603b
TO
359 ) ,
360 'status_id' => array(
361 'name' => 'status_id',
362 'type' => CRM_Utils_Type::T_INT,
363 'title' => ts('Financial Transaction Status Id') ,
364 'description' => 'pseudo FK to civicrm_option_value of contribution_status_id option_group',
365 'import' => true,
366 'where' => 'civicrm_financial_trxn.status_id',
367 'headerPattern' => '/status/i',
368 'dataPattern' => '',
369 'export' => true,
522a26c9 370 'table_name' => 'civicrm_financial_trxn',
371 'entity' => 'FinancialTrxn',
372 'bao' => 'CRM_Financial_DAO_FinancialTrxn',
6a7e5e5d 373 'localizable' => 0,
e501603b
TO
374 'pseudoconstant' => array(
375 'optionGroupName' => 'contribution_status',
376 'optionEditPath' => 'civicrm/admin/options/contribution_status',
377 )
378 ) ,
379 'payment_processor_id' => array(
380 'name' => 'payment_processor_id',
381 'type' => CRM_Utils_Type::T_INT,
382 'title' => ts('Payment Processor') ,
383 'description' => 'Payment Processor for this financial transaction',
522a26c9 384 'table_name' => 'civicrm_financial_trxn',
385 'entity' => 'FinancialTrxn',
386 'bao' => 'CRM_Financial_DAO_FinancialTrxn',
6a7e5e5d 387 'localizable' => 0,
e501603b
TO
388 'FKClassName' => 'CRM_Financial_DAO_PaymentProcessor',
389 ) ,
390 'financial_trxn_payment_instrument_id' => array(
391 'name' => 'payment_instrument_id',
392 'type' => CRM_Utils_Type::T_INT,
393 'title' => ts('Payment Method') ,
394 'description' => 'FK to payment_instrument option group values',
522a26c9 395 'table_name' => 'civicrm_financial_trxn',
396 'entity' => 'FinancialTrxn',
397 'bao' => 'CRM_Financial_DAO_FinancialTrxn',
6a7e5e5d 398 'localizable' => 0,
e501603b
TO
399 'html' => array(
400 'type' => 'Select',
401 ) ,
402 'pseudoconstant' => array(
403 'optionGroupName' => 'payment_instrument',
404 'optionEditPath' => 'civicrm/admin/options/payment_instrument',
405 )
406 ) ,
5e0343e8 407 'financial_trxn_card_type_id' => array(
408 'name' => 'card_type_id',
ea927522 409 'type' => CRM_Utils_Type::T_INT,
5e0343e8 410 'title' => ts('Card Type ID') ,
ea927522
PN
411 'description' => 'FK to accept_creditcard option group values',
412 'table_name' => 'civicrm_financial_trxn',
413 'entity' => 'FinancialTrxn',
414 'bao' => 'CRM_Financial_DAO_FinancialTrxn',
6a7e5e5d 415 'localizable' => 0,
ea927522
PN
416 'html' => array(
417 'type' => 'Select',
418 ) ,
419 'pseudoconstant' => array(
420 'optionGroupName' => 'accept_creditcard',
421 'optionEditPath' => 'civicrm/admin/options/accept_creditcard',
422 )
423 ) ,
e501603b
TO
424 'financial_trxn_check_number' => array(
425 'name' => 'check_number',
426 'type' => CRM_Utils_Type::T_STRING,
427 'title' => ts('Check Number') ,
428 'description' => 'Check number',
429 'maxlength' => 255,
430 'size' => 6,
522a26c9 431 'table_name' => 'civicrm_financial_trxn',
432 'entity' => 'FinancialTrxn',
433 'bao' => 'CRM_Financial_DAO_FinancialTrxn',
6a7e5e5d 434 'localizable' => 0,
e501603b
TO
435 'html' => array(
436 'type' => 'Text',
437 ) ,
438 ) ,
ea927522
PN
439 'financial_trxn_pan_truncation' => array(
440 'name' => 'pan_truncation',
4e0ede5a 441 'type' => CRM_Utils_Type::T_STRING,
ea927522
PN
442 'title' => ts('Pan Truncation') ,
443 'description' => 'Last 4 digits of credit card',
4e0ede5a
PN
444 'maxlength' => 4,
445 'size' => 4,
ea927522
PN
446 'table_name' => 'civicrm_financial_trxn',
447 'entity' => 'FinancialTrxn',
448 'bao' => 'CRM_Financial_DAO_FinancialTrxn',
6a7e5e5d 449 'localizable' => 0,
ea927522
PN
450 'html' => array(
451 'type' => 'Text',
452 ) ,
453 ) ,
e501603b 454 );
346aaaba 455 CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'fields_callback', Civi::$statics[__CLASS__]['fields']);
e501603b 456 }
346aaaba 457 return Civi::$statics[__CLASS__]['fields'];
e501603b
TO
458 }
459 /**
bd8e0b14 460 * Return a mapping from field-name to the corresponding key (as used in fields()).
e501603b
TO
461 *
462 * @return array
bd8e0b14 463 * Array(string $name => string $uniqueName).
e501603b
TO
464 */
465 static function &fieldKeys() {
bd8e0b14
TO
466 if (!isset(Civi::$statics[__CLASS__]['fieldKeys'])) {
467 Civi::$statics[__CLASS__]['fieldKeys'] = array_flip(CRM_Utils_Array::collect('name', self::fields()));
e501603b 468 }
bd8e0b14 469 return Civi::$statics[__CLASS__]['fieldKeys'];
e501603b
TO
470 }
471 /**
472 * Returns the names of this table
473 *
474 * @return string
475 */
476 static function getTableName() {
477 return self::$_tableName;
478 }
479 /**
480 * Returns if this table needs to be logged
481 *
482 * @return boolean
483 */
484 function getLog() {
485 return self::$_log;
486 }
487 /**
488 * Returns the list of fields that can be imported
489 *
490 * @param bool $prefix
491 *
492 * @return array
493 */
494 static function &import($prefix = false) {
60808919
TO
495 $r = CRM_Core_DAO_AllCoreTables::getImports(__CLASS__, 'financial_trxn', $prefix, array());
496 return $r;
e501603b
TO
497 }
498 /**
499 * Returns the list of fields that can be exported
500 *
501 * @param bool $prefix
502 *
503 * @return array
504 */
505 static function &export($prefix = false) {
60808919
TO
506 $r = CRM_Core_DAO_AllCoreTables::getExports(__CLASS__, 'financial_trxn', $prefix, array());
507 return $r;
e501603b 508 }
e7a6b91a
AS
509 /**
510 * Returns the list of indices
511 */
512 public static function indices($localize = TRUE) {
513 $indices = array(
514 'UI_ftrxn_trxn_id' => array(
515 'name' => 'UI_ftrxn_trxn_id',
516 'field' => array(
517 0 => 'trxn_id',
518 ) ,
519 'localizable' => false,
520 'sig' => 'civicrm_financial_trxn::0::trxn_id',
521 ) ,
522 'UI_ftrxn_payment_instrument_id' => array(
523 'name' => 'UI_ftrxn_payment_instrument_id',
524 'field' => array(
525 0 => 'payment_instrument_id',
526 ) ,
527 'localizable' => false,
528 'sig' => 'civicrm_financial_trxn::0::payment_instrument_id',
529 ) ,
530 'UI_ftrxn_check_number' => array(
531 'name' => 'UI_ftrxn_check_number',
532 'field' => array(
533 0 => 'check_number',
534 ) ,
535 'localizable' => false,
536 'sig' => 'civicrm_financial_trxn::0::check_number',
537 ) ,
538 );
539 return ($localize && !empty($indices)) ? CRM_Core_DAO_AllCoreTables::multilingualize(__CLASS__, $indices) : $indices;
540 }
e501603b 541}