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