Merge pull request #12571 from civicrm/5.4
[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,
45a83e42 324 'default' => '0',
522a26c9 325 'table_name' => 'civicrm_financial_trxn',
326 'entity' => 'FinancialTrxn',
327 'bao' => 'CRM_Financial_DAO_FinancialTrxn',
6a7e5e5d 328 'localizable' => 0,
c3fc2621
CW
329 ],
330 'trxn_id' => [
e501603b
TO
331 'name' => 'trxn_id',
332 'type' => CRM_Utils_Type::T_STRING,
c3fc2621 333 'title' => ts('Transaction ID'),
e501603b
TO
334 'description' => 'Transaction id supplied by external processor. This may not be unique.',
335 'maxlength' => 255,
a7a8f17d 336 'size' => 10,
522a26c9 337 'table_name' => 'civicrm_financial_trxn',
338 'entity' => 'FinancialTrxn',
339 'bao' => 'CRM_Financial_DAO_FinancialTrxn',
6a7e5e5d 340 'localizable' => 0,
c3fc2621 341 'html' => [
a7a8f17d 342 'type' => 'Text',
c3fc2621
CW
343 ],
344 ],
345 'trxn_result_code' => [
e501603b
TO
346 'name' => 'trxn_result_code',
347 'type' => CRM_Utils_Type::T_STRING,
c3fc2621 348 'title' => ts('Transaction Result Code'),
e501603b
TO
349 'description' => 'processor result code',
350 'maxlength' => 255,
351 'size' => CRM_Utils_Type::HUGE,
522a26c9 352 'table_name' => 'civicrm_financial_trxn',
353 'entity' => 'FinancialTrxn',
354 'bao' => 'CRM_Financial_DAO_FinancialTrxn',
6a7e5e5d 355 'localizable' => 0,
c3fc2621
CW
356 ],
357 'status_id' => [
e501603b
TO
358 'name' => 'status_id',
359 'type' => CRM_Utils_Type::T_INT,
c3fc2621 360 'title' => ts('Financial Transaction Status Id'),
e501603b 361 'description' => 'pseudo FK to civicrm_option_value of contribution_status_id option_group',
c3fc2621 362 'import' => TRUE,
e501603b
TO
363 'where' => 'civicrm_financial_trxn.status_id',
364 'headerPattern' => '/status/i',
365 'dataPattern' => '',
c3fc2621 366 'export' => TRUE,
522a26c9 367 'table_name' => 'civicrm_financial_trxn',
368 'entity' => 'FinancialTrxn',
369 'bao' => 'CRM_Financial_DAO_FinancialTrxn',
6a7e5e5d 370 'localizable' => 0,
c3fc2621 371 'pseudoconstant' => [
e501603b
TO
372 'optionGroupName' => 'contribution_status',
373 'optionEditPath' => 'civicrm/admin/options/contribution_status',
c3fc2621
CW
374 ]
375 ],
376 'payment_processor_id' => [
e501603b
TO
377 'name' => 'payment_processor_id',
378 'type' => CRM_Utils_Type::T_INT,
c3fc2621 379 'title' => ts('Payment Processor'),
e501603b 380 'description' => 'Payment Processor for this financial transaction',
522a26c9 381 'table_name' => 'civicrm_financial_trxn',
382 'entity' => 'FinancialTrxn',
383 'bao' => 'CRM_Financial_DAO_FinancialTrxn',
6a7e5e5d 384 'localizable' => 0,
e501603b 385 'FKClassName' => 'CRM_Financial_DAO_PaymentProcessor',
c3fc2621
CW
386 ],
387 'financial_trxn_payment_instrument_id' => [
e501603b
TO
388 'name' => 'payment_instrument_id',
389 'type' => CRM_Utils_Type::T_INT,
c3fc2621 390 'title' => ts('Payment Method'),
e501603b 391 'description' => 'FK to payment_instrument option group values',
522a26c9 392 'table_name' => 'civicrm_financial_trxn',
393 'entity' => 'FinancialTrxn',
394 'bao' => 'CRM_Financial_DAO_FinancialTrxn',
6a7e5e5d 395 'localizable' => 0,
c3fc2621 396 'html' => [
e501603b 397 'type' => 'Select',
c3fc2621
CW
398 ],
399 'pseudoconstant' => [
e501603b
TO
400 'optionGroupName' => 'payment_instrument',
401 'optionEditPath' => 'civicrm/admin/options/payment_instrument',
c3fc2621
CW
402 ]
403 ],
404 'financial_trxn_card_type_id' => [
5e0343e8 405 'name' => 'card_type_id',
ea927522 406 'type' => CRM_Utils_Type::T_INT,
c3fc2621 407 'title' => ts('Card Type ID'),
ea927522
PN
408 'description' => 'FK to accept_creditcard option group values',
409 'table_name' => 'civicrm_financial_trxn',
410 'entity' => 'FinancialTrxn',
411 'bao' => 'CRM_Financial_DAO_FinancialTrxn',
6a7e5e5d 412 'localizable' => 0,
c3fc2621 413 'html' => [
ea927522 414 'type' => 'Select',
c3fc2621
CW
415 ],
416 'pseudoconstant' => [
ea927522
PN
417 'optionGroupName' => 'accept_creditcard',
418 'optionEditPath' => 'civicrm/admin/options/accept_creditcard',
c3fc2621
CW
419 ]
420 ],
421 'financial_trxn_check_number' => [
e501603b
TO
422 'name' => 'check_number',
423 'type' => CRM_Utils_Type::T_STRING,
c3fc2621 424 'title' => ts('Check Number'),
e501603b
TO
425 'description' => 'Check number',
426 'maxlength' => 255,
427 'size' => 6,
522a26c9 428 'table_name' => 'civicrm_financial_trxn',
429 'entity' => 'FinancialTrxn',
430 'bao' => 'CRM_Financial_DAO_FinancialTrxn',
6a7e5e5d 431 'localizable' => 0,
c3fc2621 432 'html' => [
e501603b 433 'type' => 'Text',
c3fc2621
CW
434 ],
435 ],
436 'financial_trxn_pan_truncation' => [
ea927522 437 'name' => 'pan_truncation',
4e0ede5a 438 'type' => CRM_Utils_Type::T_STRING,
c3fc2621 439 'title' => ts('Pan Truncation'),
ea927522 440 'description' => 'Last 4 digits of credit card',
4e0ede5a
PN
441 'maxlength' => 4,
442 'size' => 4,
ea927522
PN
443 'table_name' => 'civicrm_financial_trxn',
444 'entity' => 'FinancialTrxn',
445 'bao' => 'CRM_Financial_DAO_FinancialTrxn',
6a7e5e5d 446 'localizable' => 0,
c3fc2621 447 'html' => [
ea927522 448 'type' => 'Text',
c3fc2621
CW
449 ],
450 ],
451 ];
346aaaba 452 CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'fields_callback', Civi::$statics[__CLASS__]['fields']);
e501603b 453 }
346aaaba 454 return Civi::$statics[__CLASS__]['fields'];
e501603b 455 }
c3fc2621 456
e501603b 457 /**
bd8e0b14 458 * Return a mapping from field-name to the corresponding key (as used in fields()).
e501603b
TO
459 *
460 * @return array
bd8e0b14 461 * Array(string $name => string $uniqueName).
e501603b 462 */
c3fc2621 463 public static function &fieldKeys() {
bd8e0b14
TO
464 if (!isset(Civi::$statics[__CLASS__]['fieldKeys'])) {
465 Civi::$statics[__CLASS__]['fieldKeys'] = array_flip(CRM_Utils_Array::collect('name', self::fields()));
e501603b 466 }
bd8e0b14 467 return Civi::$statics[__CLASS__]['fieldKeys'];
e501603b 468 }
c3fc2621 469
e501603b
TO
470 /**
471 * Returns the names of this table
472 *
473 * @return string
474 */
c3fc2621 475 public static function getTableName() {
e501603b
TO
476 return self::$_tableName;
477 }
c3fc2621 478
e501603b
TO
479 /**
480 * Returns if this table needs to be logged
481 *
c3fc2621 482 * @return bool
e501603b 483 */
c3fc2621 484 public function getLog() {
e501603b
TO
485 return self::$_log;
486 }
c3fc2621 487
e501603b
TO
488 /**
489 * Returns the list of fields that can be imported
490 *
491 * @param bool $prefix
492 *
493 * @return array
494 */
c3fc2621
CW
495 public static function &import($prefix = FALSE) {
496 $r = CRM_Core_DAO_AllCoreTables::getImports(__CLASS__, 'financial_trxn', $prefix, []);
60808919 497 return $r;
e501603b 498 }
c3fc2621 499
e501603b
TO
500 /**
501 * Returns the list of fields that can be exported
502 *
503 * @param bool $prefix
504 *
505 * @return array
506 */
c3fc2621
CW
507 public static function &export($prefix = FALSE) {
508 $r = CRM_Core_DAO_AllCoreTables::getExports(__CLASS__, 'financial_trxn', $prefix, []);
60808919 509 return $r;
e501603b 510 }
c3fc2621 511
e7a6b91a
AS
512 /**
513 * Returns the list of indices
c3fc2621
CW
514 *
515 * @param bool $localize
516 *
517 * @return array
e7a6b91a
AS
518 */
519 public static function indices($localize = TRUE) {
c3fc2621
CW
520 $indices = [
521 'UI_ftrxn_trxn_id' => [
e7a6b91a 522 'name' => 'UI_ftrxn_trxn_id',
c3fc2621 523 'field' => [
e7a6b91a 524 0 => 'trxn_id',
c3fc2621
CW
525 ],
526 'localizable' => FALSE,
e7a6b91a 527 'sig' => 'civicrm_financial_trxn::0::trxn_id',
c3fc2621
CW
528 ],
529 'UI_ftrxn_payment_instrument_id' => [
e7a6b91a 530 'name' => 'UI_ftrxn_payment_instrument_id',
c3fc2621 531 'field' => [
e7a6b91a 532 0 => 'payment_instrument_id',
c3fc2621
CW
533 ],
534 'localizable' => FALSE,
e7a6b91a 535 'sig' => 'civicrm_financial_trxn::0::payment_instrument_id',
c3fc2621
CW
536 ],
537 'UI_ftrxn_check_number' => [
e7a6b91a 538 'name' => 'UI_ftrxn_check_number',
c3fc2621 539 'field' => [
e7a6b91a 540 0 => 'check_number',
c3fc2621
CW
541 ],
542 'localizable' => FALSE,
e7a6b91a 543 'sig' => 'civicrm_financial_trxn::0::check_number',
c3fc2621
CW
544 ],
545 ];
e7a6b91a
AS
546 return ($localize && !empty($indices)) ? CRM_Core_DAO_AllCoreTables::multilingualize(__CLASS__, $indices) : $indices;
547 }
c3fc2621 548
e501603b 549}