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