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