CRM-20312 Add indices to DAO classes
[civicrm-core.git] / CRM / Financial / DAO / FinancialTrxn.php
CommitLineData
e501603b
TO
1<?php
2/*
3+--------------------------------------------------------------------+
4| CiviCRM version 4.7 |
5+--------------------------------------------------------------------+
0f03f337 6| Copyright CiviCRM LLC (c) 2004-2017 |
e501603b
TO
7+--------------------------------------------------------------------+
8| This file is a part of CiviCRM. |
9| |
10| CiviCRM is free software; you can copy, modify, and distribute it |
11| under the terms of the GNU Affero General Public License |
12| Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
13| |
14| CiviCRM is distributed in the hope that it will be useful, but |
15| WITHOUT ANY WARRANTY; without even the implied warranty of |
16| MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
17| See the GNU Affero General Public License for more details. |
18| |
19| You should have received a copy of the GNU Affero General Public |
20| License and the CiviCRM Licensing Exception along |
21| with this program; if not, contact CiviCRM LLC |
22| at info[AT]civicrm[DOT]org. If you have questions about the |
23| GNU Affero General Public License or the licensing of CiviCRM, |
24| see the CiviCRM license FAQ at http://civicrm.org/licensing |
25+--------------------------------------------------------------------+
26*/
27/**
28 * @package CRM
0f03f337 29 * @copyright CiviCRM LLC (c) 2004-2017
e501603b
TO
30 *
31 * Generated from xml/schema/CRM/Financial/FinancialTrxn.xml
32 * DO NOT EDIT. Generated by CRM_Core_CodeGen
022785d8 33 * (GenCodeChecksum:84188ea8db9380a96a74a4e577cb8b93)
e501603b
TO
34 */
35require_once 'CRM/Core/DAO.php';
36require_once 'CRM/Utils/Type.php';
f41f0342 37/**
38 * CRM_Financial_DAO_FinancialTrxn constructor.
39 */
e501603b
TO
40class CRM_Financial_DAO_FinancialTrxn extends CRM_Core_DAO {
41 /**
f41f0342 42 * Static instance to hold the table name.
e501603b
TO
43 *
44 * @var string
45 */
46 static $_tableName = 'civicrm_financial_trxn';
e501603b 47 /**
f41f0342 48 * Should CiviCRM log any modifications to this table in the civicrm_log table.
e501603b
TO
49 *
50 * @var boolean
51 */
52 static $_log = true;
53 /**
54 *
55 * @var int unsigned
56 */
57 public $id;
58 /**
59 * FK to financial_account table.
60 *
61 * @var int unsigned
62 */
63 public $from_financial_account_id;
64 /**
65 * FK to financial_financial_account table.
66 *
67 * @var int unsigned
68 */
69 public $to_financial_account_id;
70 /**
71 * date transaction occurred
72 *
73 * @var datetime
74 */
75 public $trxn_date;
76 /**
77 * amount of transaction
78 *
79 * @var float
80 */
81 public $total_amount;
82 /**
83 * actual processor fee if known - may be 0.
84 *
85 * @var float
86 */
87 public $fee_amount;
88 /**
89 * actual funds transfer amount. total less fees. if processor does not report actual fee during transaction, this is set to total_amount.
90 *
91 * @var float
92 */
93 public $net_amount;
94 /**
95 * 3 character string, value from config setting or input via user.
96 *
97 * @var string
98 */
99 public $currency;
100 /**
101 * Is this entry either a payment or a reversal of a payment?
102 *
103 * @var boolean
104 */
105 public $is_payment;
106 /**
107 * Transaction id supplied by external processor. This may not be unique.
108 *
109 * @var string
110 */
111 public $trxn_id;
112 /**
113 * processor result code
114 *
115 * @var string
116 */
117 public $trxn_result_code;
118 /**
119 * pseudo FK to civicrm_option_value of contribution_status_id option_group
120 *
121 * @var int unsigned
122 */
123 public $status_id;
124 /**
125 * Payment Processor for this financial transaction
126 *
127 * @var int unsigned
128 */
129 public $payment_processor_id;
130 /**
131 * FK to payment_instrument option group values
132 *
133 * @var int unsigned
134 */
135 public $payment_instrument_id;
ea927522
PN
136 /**
137 * FK to accept_creditcard option group values
138 *
139 * @var int unsigned
140 */
141 public $card_type;
e501603b
TO
142 /**
143 * Check number
144 *
145 * @var string
146 */
147 public $check_number;
ea927522
PN
148 /**
149 * Last 4 digits of credit card
150 *
151 * @var int unsigned
152 */
153 public $pan_truncation;
e501603b 154 /**
f41f0342 155 * Class constructor.
e501603b
TO
156 */
157 function __construct() {
158 $this->__table = 'civicrm_financial_trxn';
159 parent::__construct();
160 }
161 /**
f41f0342 162 * Returns foreign keys and entity references.
e501603b
TO
163 *
164 * @return array
165 * [CRM_Core_Reference_Interface]
166 */
167 static function getReferenceColumns() {
346aaaba
TO
168 if (!isset(Civi::$statics[__CLASS__]['links'])) {
169 Civi::$statics[__CLASS__]['links'] = static ::createReferenceColumns(__CLASS__);
170 Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName() , 'from_financial_account_id', 'civicrm_financial_account', 'id');
171 Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName() , 'to_financial_account_id', 'civicrm_financial_account', 'id');
172 Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName() , 'payment_processor_id', 'civicrm_payment_processor', 'id');
173 CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'links_callback', Civi::$statics[__CLASS__]['links']);
e501603b 174 }
346aaaba 175 return Civi::$statics[__CLASS__]['links'];
e501603b
TO
176 }
177 /**
178 * Returns all the column names of this table
179 *
180 * @return array
181 */
182 static function &fields() {
346aaaba
TO
183 if (!isset(Civi::$statics[__CLASS__]['fields'])) {
184 Civi::$statics[__CLASS__]['fields'] = array(
e501603b
TO
185 'id' => array(
186 'name' => 'id',
187 'type' => CRM_Utils_Type::T_INT,
188 'title' => ts('Financial Transaction ID') ,
189 'required' => true,
522a26c9 190 'table_name' => 'civicrm_financial_trxn',
191 'entity' => 'FinancialTrxn',
192 'bao' => 'CRM_Financial_DAO_FinancialTrxn',
6a7e5e5d 193 'localizable' => 0,
e501603b
TO
194 ) ,
195 'from_financial_account_id' => array(
196 'name' => 'from_financial_account_id',
197 'type' => CRM_Utils_Type::T_INT,
198 'title' => ts('Financial Transaction From Account') ,
199 'description' => 'FK to financial_account table.',
522a26c9 200 'table_name' => 'civicrm_financial_trxn',
201 'entity' => 'FinancialTrxn',
202 'bao' => 'CRM_Financial_DAO_FinancialTrxn',
6a7e5e5d 203 'localizable' => 0,
e501603b
TO
204 'FKClassName' => 'CRM_Financial_DAO_FinancialAccount',
205 'html' => array(
206 'type' => 'Select',
207 ) ,
208 'pseudoconstant' => array(
209 'table' => 'civicrm_financial_account',
210 'keyColumn' => 'id',
211 'labelColumn' => 'name',
212 )
213 ) ,
214 'to_financial_account_id' => array(
215 'name' => 'to_financial_account_id',
216 'type' => CRM_Utils_Type::T_INT,
217 'title' => ts('Financial Transaction To Account') ,
218 'description' => 'FK to financial_financial_account table.',
522a26c9 219 'table_name' => 'civicrm_financial_trxn',
220 'entity' => 'FinancialTrxn',
221 'bao' => 'CRM_Financial_DAO_FinancialTrxn',
6a7e5e5d 222 'localizable' => 0,
e501603b
TO
223 'FKClassName' => 'CRM_Financial_DAO_FinancialAccount',
224 'html' => array(
225 'type' => 'Select',
226 ) ,
227 'pseudoconstant' => array(
228 'table' => 'civicrm_financial_account',
229 'keyColumn' => 'id',
230 'labelColumn' => 'name',
231 )
232 ) ,
233 'trxn_date' => array(
234 'name' => 'trxn_date',
235 'type' => CRM_Utils_Type::T_DATE + CRM_Utils_Type::T_TIME,
236 'title' => ts('Financial Transaction Date') ,
237 'description' => 'date transaction occurred',
238 'default' => 'NULL',
522a26c9 239 'table_name' => 'civicrm_financial_trxn',
240 'entity' => 'FinancialTrxn',
241 'bao' => 'CRM_Financial_DAO_FinancialTrxn',
6a7e5e5d 242 'localizable' => 0,
e501603b
TO
243 ) ,
244 'total_amount' => array(
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' => array(
251 20,
252 2
253 ) ,
522a26c9 254 'table_name' => 'civicrm_financial_trxn',
255 'entity' => 'FinancialTrxn',
256 'bao' => 'CRM_Financial_DAO_FinancialTrxn',
6a7e5e5d 257 'localizable' => 0,
e501603b
TO
258 ) ,
259 'fee_amount' => array(
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' => array(
265 20,
266 2
267 ) ,
522a26c9 268 'table_name' => 'civicrm_financial_trxn',
269 'entity' => 'FinancialTrxn',
270 'bao' => 'CRM_Financial_DAO_FinancialTrxn',
6a7e5e5d 271 'localizable' => 0,
e501603b
TO
272 ) ,
273 'net_amount' => array(
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' => array(
279 20,
280 2
281 ) ,
522a26c9 282 'table_name' => 'civicrm_financial_trxn',
283 'entity' => 'FinancialTrxn',
284 'bao' => 'CRM_Financial_DAO_FinancialTrxn',
6a7e5e5d 285 'localizable' => 0,
e501603b
TO
286 ) ,
287 'currency' => array(
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',
522a26c9 300 'table_name' => 'civicrm_financial_trxn',
301 'entity' => 'FinancialTrxn',
302 'bao' => 'CRM_Financial_DAO_FinancialTrxn',
6a7e5e5d 303 'localizable' => 0,
e501603b
TO
304 'html' => array(
305 'type' => 'Select',
306 ) ,
307 'pseudoconstant' => array(
308 'table' => 'civicrm_currency',
309 'keyColumn' => 'name',
310 'labelColumn' => 'full_name',
311 'nameColumn' => 'name',
312 )
313 ) ,
314 'is_payment' => array(
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,
522a26c9 324 'table_name' => 'civicrm_financial_trxn',
325 'entity' => 'FinancialTrxn',
326 'bao' => 'CRM_Financial_DAO_FinancialTrxn',
6a7e5e5d 327 'localizable' => 0,
e501603b
TO
328 ) ,
329 'trxn_id' => array(
330 'name' => 'trxn_id',
331 'type' => CRM_Utils_Type::T_STRING,
332 'title' => ts('Transaction ID') ,
333 'description' => 'Transaction id supplied by external processor. This may not be unique.',
334 'maxlength' => 255,
335 'size' => CRM_Utils_Type::HUGE,
522a26c9 336 'table_name' => 'civicrm_financial_trxn',
337 'entity' => 'FinancialTrxn',
338 'bao' => 'CRM_Financial_DAO_FinancialTrxn',
6a7e5e5d 339 'localizable' => 0,
e501603b
TO
340 ) ,
341 'trxn_result_code' => array(
342 'name' => 'trxn_result_code',
343 'type' => CRM_Utils_Type::T_STRING,
344 'title' => ts('Transaction Result Code') ,
345 'description' => 'processor result code',
346 'maxlength' => 255,
347 'size' => CRM_Utils_Type::HUGE,
522a26c9 348 'table_name' => 'civicrm_financial_trxn',
349 'entity' => 'FinancialTrxn',
350 'bao' => 'CRM_Financial_DAO_FinancialTrxn',
6a7e5e5d 351 'localizable' => 0,
e501603b
TO
352 ) ,
353 'status_id' => array(
354 'name' => 'status_id',
355 'type' => CRM_Utils_Type::T_INT,
356 'title' => ts('Financial Transaction Status Id') ,
357 'description' => 'pseudo FK to civicrm_option_value of contribution_status_id option_group',
358 'import' => true,
359 'where' => 'civicrm_financial_trxn.status_id',
360 'headerPattern' => '/status/i',
361 'dataPattern' => '',
362 'export' => true,
522a26c9 363 'table_name' => 'civicrm_financial_trxn',
364 'entity' => 'FinancialTrxn',
365 'bao' => 'CRM_Financial_DAO_FinancialTrxn',
6a7e5e5d 366 'localizable' => 0,
e501603b
TO
367 'pseudoconstant' => array(
368 'optionGroupName' => 'contribution_status',
369 'optionEditPath' => 'civicrm/admin/options/contribution_status',
370 )
371 ) ,
372 'payment_processor_id' => array(
373 'name' => 'payment_processor_id',
374 'type' => CRM_Utils_Type::T_INT,
375 'title' => ts('Payment Processor') ,
376 'description' => 'Payment Processor for this financial transaction',
522a26c9 377 'table_name' => 'civicrm_financial_trxn',
378 'entity' => 'FinancialTrxn',
379 'bao' => 'CRM_Financial_DAO_FinancialTrxn',
6a7e5e5d 380 'localizable' => 0,
e501603b
TO
381 'FKClassName' => 'CRM_Financial_DAO_PaymentProcessor',
382 ) ,
383 'financial_trxn_payment_instrument_id' => array(
384 'name' => 'payment_instrument_id',
385 'type' => CRM_Utils_Type::T_INT,
386 'title' => ts('Payment Method') ,
387 'description' => 'FK to payment_instrument option group values',
522a26c9 388 'table_name' => 'civicrm_financial_trxn',
389 'entity' => 'FinancialTrxn',
390 'bao' => 'CRM_Financial_DAO_FinancialTrxn',
6a7e5e5d 391 'localizable' => 0,
e501603b
TO
392 'html' => array(
393 'type' => 'Select',
394 ) ,
395 'pseudoconstant' => array(
396 'optionGroupName' => 'payment_instrument',
397 'optionEditPath' => 'civicrm/admin/options/payment_instrument',
398 )
399 ) ,
ea927522
PN
400 'financial_trxn_card_type' => array(
401 'name' => 'card_type',
402 'type' => CRM_Utils_Type::T_INT,
403 'title' => ts('Card Type') ,
404 'description' => 'FK to accept_creditcard option group values',
405 'table_name' => 'civicrm_financial_trxn',
406 'entity' => 'FinancialTrxn',
407 'bao' => 'CRM_Financial_DAO_FinancialTrxn',
6a7e5e5d 408 'localizable' => 0,
ea927522
PN
409 'html' => array(
410 'type' => 'Select',
411 ) ,
412 'pseudoconstant' => array(
413 'optionGroupName' => 'accept_creditcard',
414 'optionEditPath' => 'civicrm/admin/options/accept_creditcard',
415 )
416 ) ,
e501603b
TO
417 'financial_trxn_check_number' => array(
418 'name' => 'check_number',
419 'type' => CRM_Utils_Type::T_STRING,
420 'title' => ts('Check Number') ,
421 'description' => 'Check number',
422 'maxlength' => 255,
423 'size' => 6,
522a26c9 424 'table_name' => 'civicrm_financial_trxn',
425 'entity' => 'FinancialTrxn',
426 'bao' => 'CRM_Financial_DAO_FinancialTrxn',
6a7e5e5d 427 'localizable' => 0,
e501603b
TO
428 'html' => array(
429 'type' => 'Text',
430 ) ,
431 ) ,
ea927522
PN
432 'financial_trxn_pan_truncation' => array(
433 'name' => 'pan_truncation',
434 'type' => CRM_Utils_Type::T_INT,
435 'title' => ts('Pan Truncation') ,
436 'description' => 'Last 4 digits of credit card',
437 'table_name' => 'civicrm_financial_trxn',
438 'entity' => 'FinancialTrxn',
439 'bao' => 'CRM_Financial_DAO_FinancialTrxn',
6a7e5e5d 440 'localizable' => 0,
ea927522
PN
441 'html' => array(
442 'type' => 'Text',
443 ) ,
444 ) ,
e501603b 445 );
346aaaba 446 CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'fields_callback', Civi::$statics[__CLASS__]['fields']);
e501603b 447 }
346aaaba 448 return Civi::$statics[__CLASS__]['fields'];
e501603b
TO
449 }
450 /**
bd8e0b14 451 * Return a mapping from field-name to the corresponding key (as used in fields()).
e501603b
TO
452 *
453 * @return array
bd8e0b14 454 * Array(string $name => string $uniqueName).
e501603b
TO
455 */
456 static function &fieldKeys() {
bd8e0b14
TO
457 if (!isset(Civi::$statics[__CLASS__]['fieldKeys'])) {
458 Civi::$statics[__CLASS__]['fieldKeys'] = array_flip(CRM_Utils_Array::collect('name', self::fields()));
e501603b 459 }
bd8e0b14 460 return Civi::$statics[__CLASS__]['fieldKeys'];
e501603b
TO
461 }
462 /**
463 * Returns the names of this table
464 *
465 * @return string
466 */
467 static function getTableName() {
468 return self::$_tableName;
469 }
470 /**
471 * Returns if this table needs to be logged
472 *
473 * @return boolean
474 */
475 function getLog() {
476 return self::$_log;
477 }
478 /**
479 * Returns the list of fields that can be imported
480 *
481 * @param bool $prefix
482 *
483 * @return array
484 */
485 static function &import($prefix = false) {
60808919
TO
486 $r = CRM_Core_DAO_AllCoreTables::getImports(__CLASS__, 'financial_trxn', $prefix, array());
487 return $r;
e501603b
TO
488 }
489 /**
490 * Returns the list of fields that can be exported
491 *
492 * @param bool $prefix
493 *
494 * @return array
495 */
496 static function &export($prefix = false) {
60808919
TO
497 $r = CRM_Core_DAO_AllCoreTables::getExports(__CLASS__, 'financial_trxn', $prefix, array());
498 return $r;
e501603b
TO
499 }
500}