Cleanup variables in event/contribution register forms
[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:5a4324ffe222bf724ab9d4cde26eb4c2)
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 public static function getEntityTitle() {
169 return ts('Financial Trxns');
170 }
171
172 /**
173 * Returns foreign keys and entity references.
174 *
175 * @return array
176 * [CRM_Core_Reference_Interface]
177 */
178 public static function getReferenceColumns() {
179 if (!isset(Civi::$statics[__CLASS__]['links'])) {
180 Civi::$statics[__CLASS__]['links'] = static::createReferenceColumns(__CLASS__);
181 Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName(), 'from_financial_account_id', 'civicrm_financial_account', 'id');
182 Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName(), 'to_financial_account_id', 'civicrm_financial_account', 'id');
183 Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName(), 'payment_processor_id', 'civicrm_payment_processor', 'id');
184 CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'links_callback', Civi::$statics[__CLASS__]['links']);
185 }
186 return Civi::$statics[__CLASS__]['links'];
187 }
188
189 /**
190 * Returns all the column names of this table
191 *
192 * @return array
193 */
194 public static function &fields() {
195 if (!isset(Civi::$statics[__CLASS__]['fields'])) {
196 Civi::$statics[__CLASS__]['fields'] = [
197 'id' => [
198 'name' => 'id',
199 'type' => CRM_Utils_Type::T_INT,
200 'title' => ts('Financial Transaction ID'),
201 'required' => TRUE,
202 'where' => 'civicrm_financial_trxn.id',
203 'table_name' => 'civicrm_financial_trxn',
204 'entity' => 'FinancialTrxn',
205 'bao' => 'CRM_Financial_DAO_FinancialTrxn',
206 'localizable' => 0,
207 'add' => '1.3',
208 ],
209 'from_financial_account_id' => [
210 'name' => 'from_financial_account_id',
211 'type' => CRM_Utils_Type::T_INT,
212 'title' => ts('Financial Transaction From Account'),
213 'description' => ts('FK to financial_account table.'),
214 'where' => 'civicrm_financial_trxn.from_financial_account_id',
215 'table_name' => 'civicrm_financial_trxn',
216 'entity' => 'FinancialTrxn',
217 'bao' => 'CRM_Financial_DAO_FinancialTrxn',
218 'localizable' => 0,
219 'FKClassName' => 'CRM_Financial_DAO_FinancialAccount',
220 'html' => [
221 'type' => 'Select',
222 ],
223 'pseudoconstant' => [
224 'table' => 'civicrm_financial_account',
225 'keyColumn' => 'id',
226 'labelColumn' => 'name',
227 ],
228 'add' => '4.3',
229 ],
230 'to_financial_account_id' => [
231 'name' => 'to_financial_account_id',
232 'type' => CRM_Utils_Type::T_INT,
233 'title' => ts('Financial Transaction To Account'),
234 'description' => ts('FK to financial_financial_account table.'),
235 'where' => 'civicrm_financial_trxn.to_financial_account_id',
236 'table_name' => 'civicrm_financial_trxn',
237 'entity' => 'FinancialTrxn',
238 'bao' => 'CRM_Financial_DAO_FinancialTrxn',
239 'localizable' => 0,
240 'FKClassName' => 'CRM_Financial_DAO_FinancialAccount',
241 'html' => [
242 'type' => 'Select',
243 ],
244 'pseudoconstant' => [
245 'table' => 'civicrm_financial_account',
246 'keyColumn' => 'id',
247 'labelColumn' => 'name',
248 ],
249 'add' => '4.3',
250 ],
251 'trxn_date' => [
252 'name' => 'trxn_date',
253 'type' => CRM_Utils_Type::T_DATE + CRM_Utils_Type::T_TIME,
254 'title' => ts('Financial Transaction Date'),
255 'description' => ts('date transaction occurred'),
256 'where' => 'civicrm_financial_trxn.trxn_date',
257 'default' => 'NULL',
258 'table_name' => 'civicrm_financial_trxn',
259 'entity' => 'FinancialTrxn',
260 'bao' => 'CRM_Financial_DAO_FinancialTrxn',
261 'localizable' => 0,
262 'html' => [
263 'type' => 'Select Date',
264 'formatType' => 'activityDateTime',
265 ],
266 'add' => '1.3',
267 ],
268 'total_amount' => [
269 'name' => 'total_amount',
270 'type' => CRM_Utils_Type::T_MONEY,
271 'title' => ts('Financial Total Amount'),
272 'description' => ts('amount of transaction'),
273 'required' => TRUE,
274 'precision' => [
275 20,
276 2,
277 ],
278 'where' => 'civicrm_financial_trxn.total_amount',
279 'table_name' => 'civicrm_financial_trxn',
280 'entity' => 'FinancialTrxn',
281 'bao' => 'CRM_Financial_DAO_FinancialTrxn',
282 'localizable' => 0,
283 'add' => '1.3',
284 ],
285 'fee_amount' => [
286 'name' => 'fee_amount',
287 'type' => CRM_Utils_Type::T_MONEY,
288 'title' => ts('Financial Fee Amount'),
289 'description' => ts('actual processor fee if known - may be 0.'),
290 'precision' => [
291 20,
292 2,
293 ],
294 'where' => 'civicrm_financial_trxn.fee_amount',
295 'table_name' => 'civicrm_financial_trxn',
296 'entity' => 'FinancialTrxn',
297 'bao' => 'CRM_Financial_DAO_FinancialTrxn',
298 'localizable' => 0,
299 'add' => '1.3',
300 ],
301 'net_amount' => [
302 'name' => 'net_amount',
303 'type' => CRM_Utils_Type::T_MONEY,
304 'title' => ts('Financial Net Amount'),
305 'description' => ts('actual funds transfer amount. total less fees. if processor does not report actual fee during transaction, this is set to total_amount.'),
306 'precision' => [
307 20,
308 2,
309 ],
310 'where' => 'civicrm_financial_trxn.net_amount',
311 'table_name' => 'civicrm_financial_trxn',
312 'entity' => 'FinancialTrxn',
313 'bao' => 'CRM_Financial_DAO_FinancialTrxn',
314 'localizable' => 0,
315 'add' => '1.3',
316 ],
317 'currency' => [
318 'name' => 'currency',
319 'type' => CRM_Utils_Type::T_STRING,
320 'title' => ts('Financial Currency'),
321 'description' => ts('3 character string, value from config setting or input via user.'),
322 'maxlength' => 3,
323 'size' => CRM_Utils_Type::FOUR,
324 'import' => TRUE,
325 'where' => 'civicrm_financial_trxn.currency',
326 'headerPattern' => '/cur(rency)?/i',
327 'dataPattern' => '/^[A-Z]{3}$/',
328 'export' => TRUE,
329 'default' => 'NULL',
330 'table_name' => 'civicrm_financial_trxn',
331 'entity' => 'FinancialTrxn',
332 'bao' => 'CRM_Financial_DAO_FinancialTrxn',
333 'localizable' => 0,
334 'html' => [
335 'type' => 'Select',
336 ],
337 'pseudoconstant' => [
338 'table' => 'civicrm_currency',
339 'keyColumn' => 'name',
340 'labelColumn' => 'full_name',
341 'nameColumn' => 'name',
342 'abbrColumn' => 'symbol',
343 ],
344 'add' => '1.3',
345 ],
346 'is_payment' => [
347 'name' => 'is_payment',
348 'type' => CRM_Utils_Type::T_BOOLEAN,
349 'title' => ts('Is Payment?'),
350 'description' => ts('Is this entry either a payment or a reversal of a payment?'),
351 'import' => TRUE,
352 'where' => 'civicrm_financial_trxn.is_payment',
353 'export' => TRUE,
354 'default' => '0',
355 'table_name' => 'civicrm_financial_trxn',
356 'entity' => 'FinancialTrxn',
357 'bao' => 'CRM_Financial_DAO_FinancialTrxn',
358 'localizable' => 0,
359 'add' => '4.7',
360 ],
361 'trxn_id' => [
362 'name' => 'trxn_id',
363 'type' => CRM_Utils_Type::T_STRING,
364 'title' => ts('Transaction ID'),
365 'description' => ts('Transaction id supplied by external processor. This may not be unique.'),
366 'maxlength' => 255,
367 'size' => 10,
368 'where' => 'civicrm_financial_trxn.trxn_id',
369 'table_name' => 'civicrm_financial_trxn',
370 'entity' => 'FinancialTrxn',
371 'bao' => 'CRM_Financial_DAO_FinancialTrxn',
372 'localizable' => 0,
373 'html' => [
374 'type' => 'Text',
375 ],
376 'add' => '1.3',
377 ],
378 'trxn_result_code' => [
379 'name' => 'trxn_result_code',
380 'type' => CRM_Utils_Type::T_STRING,
381 'title' => ts('Transaction Result Code'),
382 'description' => ts('processor result code'),
383 'maxlength' => 255,
384 'size' => CRM_Utils_Type::HUGE,
385 'where' => 'civicrm_financial_trxn.trxn_result_code',
386 'table_name' => 'civicrm_financial_trxn',
387 'entity' => 'FinancialTrxn',
388 'bao' => 'CRM_Financial_DAO_FinancialTrxn',
389 'localizable' => 0,
390 'add' => '1.3',
391 ],
392 'status_id' => [
393 'name' => 'status_id',
394 'type' => CRM_Utils_Type::T_INT,
395 'title' => ts('Financial Transaction Status Id'),
396 'description' => ts('pseudo FK to civicrm_option_value of contribution_status_id option_group'),
397 'import' => TRUE,
398 'where' => 'civicrm_financial_trxn.status_id',
399 'headerPattern' => '/status/i',
400 'export' => TRUE,
401 'table_name' => 'civicrm_financial_trxn',
402 'entity' => 'FinancialTrxn',
403 'bao' => 'CRM_Financial_DAO_FinancialTrxn',
404 'localizable' => 0,
405 'pseudoconstant' => [
406 'optionGroupName' => 'contribution_status',
407 'optionEditPath' => 'civicrm/admin/options/contribution_status',
408 ],
409 'add' => '4.3',
410 ],
411 'payment_processor_id' => [
412 'name' => 'payment_processor_id',
413 'type' => CRM_Utils_Type::T_INT,
414 'title' => ts('Payment Processor'),
415 'description' => ts('Payment Processor for this financial transaction'),
416 'where' => 'civicrm_financial_trxn.payment_processor_id',
417 'table_name' => 'civicrm_financial_trxn',
418 'entity' => 'FinancialTrxn',
419 'bao' => 'CRM_Financial_DAO_FinancialTrxn',
420 'localizable' => 0,
421 'FKClassName' => 'CRM_Financial_DAO_PaymentProcessor',
422 'add' => '4.3',
423 ],
424 'financial_trxn_payment_instrument_id' => [
425 'name' => 'payment_instrument_id',
426 'type' => CRM_Utils_Type::T_INT,
427 'title' => ts('Payment Method'),
428 'description' => ts('FK to payment_instrument option group values'),
429 'where' => 'civicrm_financial_trxn.payment_instrument_id',
430 'table_name' => 'civicrm_financial_trxn',
431 'entity' => 'FinancialTrxn',
432 'bao' => 'CRM_Financial_DAO_FinancialTrxn',
433 'localizable' => 0,
434 'html' => [
435 'type' => 'Select',
436 ],
437 'pseudoconstant' => [
438 'optionGroupName' => 'payment_instrument',
439 'optionEditPath' => 'civicrm/admin/options/payment_instrument',
440 ],
441 'add' => '4.3',
442 ],
443 'financial_trxn_card_type_id' => [
444 'name' => 'card_type_id',
445 'type' => CRM_Utils_Type::T_INT,
446 'title' => ts('Card Type ID'),
447 'description' => ts('FK to accept_creditcard option group values'),
448 'where' => 'civicrm_financial_trxn.card_type_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' => 'accept_creditcard',
458 'optionEditPath' => 'civicrm/admin/options/accept_creditcard',
459 ],
460 'add' => '4.7',
461 ],
462 'financial_trxn_check_number' => [
463 'name' => 'check_number',
464 'type' => CRM_Utils_Type::T_STRING,
465 'title' => ts('Check Number'),
466 'description' => ts('Check number'),
467 'maxlength' => 255,
468 'size' => 6,
469 'where' => 'civicrm_financial_trxn.check_number',
470 'table_name' => 'civicrm_financial_trxn',
471 'entity' => 'FinancialTrxn',
472 'bao' => 'CRM_Financial_DAO_FinancialTrxn',
473 'localizable' => 0,
474 'html' => [
475 'type' => 'Text',
476 ],
477 'add' => '4.3',
478 ],
479 'financial_trxn_pan_truncation' => [
480 'name' => 'pan_truncation',
481 'type' => CRM_Utils_Type::T_STRING,
482 'title' => ts('PAN Truncation'),
483 'description' => ts('Last 4 digits of credit card'),
484 'maxlength' => 4,
485 'size' => 4,
486 'where' => 'civicrm_financial_trxn.pan_truncation',
487 'table_name' => 'civicrm_financial_trxn',
488 'entity' => 'FinancialTrxn',
489 'bao' => 'CRM_Financial_DAO_FinancialTrxn',
490 'localizable' => 0,
491 'html' => [
492 'type' => 'Text',
493 ],
494 'add' => '4.7',
495 ],
496 'financial_trxn_order_reference' => [
497 'name' => 'order_reference',
498 'type' => CRM_Utils_Type::T_STRING,
499 'title' => ts('Order Reference'),
500 'description' => ts('Payment Processor external order reference'),
501 'maxlength' => 255,
502 'size' => 25,
503 'where' => 'civicrm_financial_trxn.order_reference',
504 'table_name' => 'civicrm_financial_trxn',
505 'entity' => 'FinancialTrxn',
506 'bao' => 'CRM_Financial_DAO_FinancialTrxn',
507 'localizable' => 0,
508 'html' => [
509 'type' => 'Text',
510 ],
511 'add' => '5.20',
512 ],
513 ];
514 CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'fields_callback', Civi::$statics[__CLASS__]['fields']);
515 }
516 return Civi::$statics[__CLASS__]['fields'];
517 }
518
519 /**
520 * Return a mapping from field-name to the corresponding key (as used in fields()).
521 *
522 * @return array
523 * Array(string $name => string $uniqueName).
524 */
525 public static function &fieldKeys() {
526 if (!isset(Civi::$statics[__CLASS__]['fieldKeys'])) {
527 Civi::$statics[__CLASS__]['fieldKeys'] = array_flip(CRM_Utils_Array::collect('name', self::fields()));
528 }
529 return Civi::$statics[__CLASS__]['fieldKeys'];
530 }
531
532 /**
533 * Returns the names of this table
534 *
535 * @return string
536 */
537 public static function getTableName() {
538 return self::$_tableName;
539 }
540
541 /**
542 * Returns if this table needs to be logged
543 *
544 * @return bool
545 */
546 public function getLog() {
547 return self::$_log;
548 }
549
550 /**
551 * Returns the list of fields that can be imported
552 *
553 * @param bool $prefix
554 *
555 * @return array
556 */
557 public static function &import($prefix = FALSE) {
558 $r = CRM_Core_DAO_AllCoreTables::getImports(__CLASS__, 'financial_trxn', $prefix, []);
559 return $r;
560 }
561
562 /**
563 * Returns the list of fields that can be exported
564 *
565 * @param bool $prefix
566 *
567 * @return array
568 */
569 public static function &export($prefix = FALSE) {
570 $r = CRM_Core_DAO_AllCoreTables::getExports(__CLASS__, 'financial_trxn', $prefix, []);
571 return $r;
572 }
573
574 /**
575 * Returns the list of indices
576 *
577 * @param bool $localize
578 *
579 * @return array
580 */
581 public static function indices($localize = TRUE) {
582 $indices = [
583 'UI_ftrxn_trxn_id' => [
584 'name' => 'UI_ftrxn_trxn_id',
585 'field' => [
586 0 => 'trxn_id',
587 ],
588 'localizable' => FALSE,
589 'sig' => 'civicrm_financial_trxn::0::trxn_id',
590 ],
591 'UI_ftrxn_payment_instrument_id' => [
592 'name' => 'UI_ftrxn_payment_instrument_id',
593 'field' => [
594 0 => 'payment_instrument_id',
595 ],
596 'localizable' => FALSE,
597 'sig' => 'civicrm_financial_trxn::0::payment_instrument_id',
598 ],
599 'UI_ftrxn_check_number' => [
600 'name' => 'UI_ftrxn_check_number',
601 'field' => [
602 0 => 'check_number',
603 ],
604 'localizable' => FALSE,
605 'sig' => 'civicrm_financial_trxn::0::check_number',
606 ],
607 ];
608 return ($localize && !empty($indices)) ? CRM_Core_DAO_AllCoreTables::multilingualize(__CLASS__, $indices) : $indices;
609 }
610
611 }