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