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