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