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