DAOs with singular/plural options for entity titles
[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:857c64b471d1872d98141aefa56aecb6)
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 'add' => '4.3',
426 ],
427 'financial_trxn_payment_instrument_id' => [
428 'name' => 'payment_instrument_id',
429 'type' => CRM_Utils_Type::T_INT,
430 'title' => ts('Payment Method'),
431 'description' => ts('FK to payment_instrument option group values'),
432 'where' => 'civicrm_financial_trxn.payment_instrument_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' => 'payment_instrument',
442 'optionEditPath' => 'civicrm/admin/options/payment_instrument',
443 ],
444 'add' => '4.3',
445 ],
446 'financial_trxn_card_type_id' => [
447 'name' => 'card_type_id',
448 'type' => CRM_Utils_Type::T_INT,
449 'title' => ts('Card Type ID'),
450 'description' => ts('FK to accept_creditcard option group values'),
451 'where' => 'civicrm_financial_trxn.card_type_id',
452 'table_name' => 'civicrm_financial_trxn',
453 'entity' => 'FinancialTrxn',
454 'bao' => 'CRM_Financial_DAO_FinancialTrxn',
455 'localizable' => 0,
456 'html' => [
457 'type' => 'Select',
458 ],
459 'pseudoconstant' => [
460 'optionGroupName' => 'accept_creditcard',
461 'optionEditPath' => 'civicrm/admin/options/accept_creditcard',
462 ],
463 'add' => '4.7',
464 ],
465 'financial_trxn_check_number' => [
466 'name' => 'check_number',
467 'type' => CRM_Utils_Type::T_STRING,
468 'title' => ts('Check Number'),
469 'description' => ts('Check number'),
470 'maxlength' => 255,
471 'size' => 6,
472 'where' => 'civicrm_financial_trxn.check_number',
473 'table_name' => 'civicrm_financial_trxn',
474 'entity' => 'FinancialTrxn',
475 'bao' => 'CRM_Financial_DAO_FinancialTrxn',
476 'localizable' => 0,
477 'html' => [
478 'type' => 'Text',
479 ],
480 'add' => '4.3',
481 ],
482 'financial_trxn_pan_truncation' => [
483 'name' => 'pan_truncation',
484 'type' => CRM_Utils_Type::T_STRING,
485 'title' => ts('PAN Truncation'),
486 'description' => ts('Last 4 digits of credit card'),
487 'maxlength' => 4,
488 'size' => 4,
489 'where' => 'civicrm_financial_trxn.pan_truncation',
490 'table_name' => 'civicrm_financial_trxn',
491 'entity' => 'FinancialTrxn',
492 'bao' => 'CRM_Financial_DAO_FinancialTrxn',
493 'localizable' => 0,
494 'html' => [
495 'type' => 'Text',
496 ],
497 'add' => '4.7',
498 ],
499 'financial_trxn_order_reference' => [
500 'name' => 'order_reference',
501 'type' => CRM_Utils_Type::T_STRING,
502 'title' => ts('Order Reference'),
503 'description' => ts('Payment Processor external order reference'),
504 'maxlength' => 255,
505 'size' => 25,
506 'where' => 'civicrm_financial_trxn.order_reference',
507 'table_name' => 'civicrm_financial_trxn',
508 'entity' => 'FinancialTrxn',
509 'bao' => 'CRM_Financial_DAO_FinancialTrxn',
510 'localizable' => 0,
511 'html' => [
512 'type' => 'Text',
513 ],
514 'add' => '5.20',
515 ],
516 ];
517 CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'fields_callback', Civi::$statics[__CLASS__]['fields']);
518 }
519 return Civi::$statics[__CLASS__]['fields'];
520 }
521
522 /**
523 * Return a mapping from field-name to the corresponding key (as used in fields()).
524 *
525 * @return array
526 * Array(string $name => string $uniqueName).
527 */
528 public static function &fieldKeys() {
529 if (!isset(Civi::$statics[__CLASS__]['fieldKeys'])) {
530 Civi::$statics[__CLASS__]['fieldKeys'] = array_flip(CRM_Utils_Array::collect('name', self::fields()));
531 }
532 return Civi::$statics[__CLASS__]['fieldKeys'];
533 }
534
535 /**
536 * Returns the names of this table
537 *
538 * @return string
539 */
540 public static function getTableName() {
541 return self::$_tableName;
542 }
543
544 /**
545 * Returns if this table needs to be logged
546 *
547 * @return bool
548 */
549 public function getLog() {
550 return self::$_log;
551 }
552
553 /**
554 * Returns the list of fields that can be imported
555 *
556 * @param bool $prefix
557 *
558 * @return array
559 */
560 public static function &import($prefix = FALSE) {
561 $r = CRM_Core_DAO_AllCoreTables::getImports(__CLASS__, 'financial_trxn', $prefix, []);
562 return $r;
563 }
564
565 /**
566 * Returns the list of fields that can be exported
567 *
568 * @param bool $prefix
569 *
570 * @return array
571 */
572 public static function &export($prefix = FALSE) {
573 $r = CRM_Core_DAO_AllCoreTables::getExports(__CLASS__, 'financial_trxn', $prefix, []);
574 return $r;
575 }
576
577 /**
578 * Returns the list of indices
579 *
580 * @param bool $localize
581 *
582 * @return array
583 */
584 public static function indices($localize = TRUE) {
585 $indices = [
586 'UI_ftrxn_trxn_id' => [
587 'name' => 'UI_ftrxn_trxn_id',
588 'field' => [
589 0 => 'trxn_id',
590 ],
591 'localizable' => FALSE,
592 'sig' => 'civicrm_financial_trxn::0::trxn_id',
593 ],
594 'UI_ftrxn_payment_instrument_id' => [
595 'name' => 'UI_ftrxn_payment_instrument_id',
596 'field' => [
597 0 => 'payment_instrument_id',
598 ],
599 'localizable' => FALSE,
600 'sig' => 'civicrm_financial_trxn::0::payment_instrument_id',
601 ],
602 'UI_ftrxn_check_number' => [
603 'name' => 'UI_ftrxn_check_number',
604 'field' => [
605 0 => 'check_number',
606 ],
607 'localizable' => FALSE,
608 'sig' => 'civicrm_financial_trxn::0::check_number',
609 ],
610 ];
611 return ($localize && !empty($indices)) ? CRM_Core_DAO_AllCoreTables::multilingualize(__CLASS__, $indices) : $indices;
612 }
613
614 }