a9d9ab0791c542bcf2b60d0bccd450451fc7b8f5
[civicrm-core.git] / CRM / Financial / DAO / FinancialTrxn.php
1 <?php
2 /*
3 +--------------------------------------------------------------------+
4 | CiviCRM version 4.7 |
5 +--------------------------------------------------------------------+
6 | Copyright CiviCRM LLC (c) 2004-2017 |
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
29 * @copyright CiviCRM LLC (c) 2004-2017
30 *
31 * Generated from xml/schema/CRM/Financial/FinancialTrxn.xml
32 * DO NOT EDIT. Generated by CRM_Core_CodeGen
33 * (GenCodeChecksum:505b36cf7c6c052f88ab1ca0f0fc82a0)
34 */
35 require_once 'CRM/Core/DAO.php';
36 require_once 'CRM/Utils/Type.php';
37 /**
38 * CRM_Financial_DAO_FinancialTrxn constructor.
39 */
40 class CRM_Financial_DAO_FinancialTrxn extends CRM_Core_DAO {
41 /**
42 * Static instance to hold the table name.
43 *
44 * @var string
45 */
46 static $_tableName = 'civicrm_financial_trxn';
47 /**
48 * Should CiviCRM log any modifications to this table in the civicrm_log table.
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;
136 /**
137 * FK to accept_creditcard option group values
138 *
139 * @var int unsigned
140 */
141 public $card_type;
142 /**
143 * Check number
144 *
145 * @var string
146 */
147 public $check_number;
148 /**
149 * Last 4 digits of credit card
150 *
151 * @var int unsigned
152 */
153 public $pan_truncation;
154 /**
155 * Class constructor.
156 */
157 function __construct() {
158 $this->__table = 'civicrm_financial_trxn';
159 parent::__construct();
160 }
161 /**
162 * Returns foreign keys and entity references.
163 *
164 * @return array
165 * [CRM_Core_Reference_Interface]
166 */
167 static function getReferenceColumns() {
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']);
174 }
175 return Civi::$statics[__CLASS__]['links'];
176 }
177 /**
178 * Returns all the column names of this table
179 *
180 * @return array
181 */
182 static function &fields() {
183 if (!isset(Civi::$statics[__CLASS__]['fields'])) {
184 Civi::$statics[__CLASS__]['fields'] = array(
185 'id' => array(
186 'name' => 'id',
187 'type' => CRM_Utils_Type::T_INT,
188 'title' => ts('Financial Transaction ID') ,
189 'required' => true,
190 'table_name' => 'civicrm_financial_trxn',
191 'entity' => 'FinancialTrxn',
192 'bao' => 'CRM_Financial_DAO_FinancialTrxn',
193 'localizable' => 0,
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.',
200 'table_name' => 'civicrm_financial_trxn',
201 'entity' => 'FinancialTrxn',
202 'bao' => 'CRM_Financial_DAO_FinancialTrxn',
203 'localizable' => 0,
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.',
219 'table_name' => 'civicrm_financial_trxn',
220 'entity' => 'FinancialTrxn',
221 'bao' => 'CRM_Financial_DAO_FinancialTrxn',
222 'localizable' => 0,
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',
239 'table_name' => 'civicrm_financial_trxn',
240 'entity' => 'FinancialTrxn',
241 'bao' => 'CRM_Financial_DAO_FinancialTrxn',
242 'localizable' => 0,
243 'html' => array(
244 'type' => 'Select Date',
245 'formatType' => 'activityDateTime',
246 ) ,
247 ) ,
248 'total_amount' => array(
249 'name' => 'total_amount',
250 'type' => CRM_Utils_Type::T_MONEY,
251 'title' => ts('Financial Total Amount') ,
252 'description' => 'amount of transaction',
253 'required' => true,
254 'precision' => array(
255 20,
256 2
257 ) ,
258 'table_name' => 'civicrm_financial_trxn',
259 'entity' => 'FinancialTrxn',
260 'bao' => 'CRM_Financial_DAO_FinancialTrxn',
261 'localizable' => 0,
262 ) ,
263 'fee_amount' => array(
264 'name' => 'fee_amount',
265 'type' => CRM_Utils_Type::T_MONEY,
266 'title' => ts('Financial Fee Amount') ,
267 'description' => 'actual processor fee if known - may be 0.',
268 'precision' => array(
269 20,
270 2
271 ) ,
272 'table_name' => 'civicrm_financial_trxn',
273 'entity' => 'FinancialTrxn',
274 'bao' => 'CRM_Financial_DAO_FinancialTrxn',
275 'localizable' => 0,
276 ) ,
277 'net_amount' => array(
278 'name' => 'net_amount',
279 'type' => CRM_Utils_Type::T_MONEY,
280 'title' => ts('Financial Net Amount') ,
281 'description' => 'actual funds transfer amount. total less fees. if processor does not report actual fee during transaction, this is set to total_amount.',
282 'precision' => array(
283 20,
284 2
285 ) ,
286 'table_name' => 'civicrm_financial_trxn',
287 'entity' => 'FinancialTrxn',
288 'bao' => 'CRM_Financial_DAO_FinancialTrxn',
289 'localizable' => 0,
290 ) ,
291 'currency' => array(
292 'name' => 'currency',
293 'type' => CRM_Utils_Type::T_STRING,
294 'title' => ts('Financial Currency') ,
295 'description' => '3 character string, value from config setting or input via user.',
296 'maxlength' => 3,
297 'size' => CRM_Utils_Type::FOUR,
298 'import' => true,
299 'where' => 'civicrm_financial_trxn.currency',
300 'headerPattern' => '/cur(rency)?/i',
301 'dataPattern' => '/^[A-Z]{3}$/',
302 'export' => true,
303 'default' => 'NULL',
304 'table_name' => 'civicrm_financial_trxn',
305 'entity' => 'FinancialTrxn',
306 'bao' => 'CRM_Financial_DAO_FinancialTrxn',
307 'localizable' => 0,
308 'html' => array(
309 'type' => 'Select',
310 ) ,
311 'pseudoconstant' => array(
312 'table' => 'civicrm_currency',
313 'keyColumn' => 'name',
314 'labelColumn' => 'full_name',
315 'nameColumn' => 'name',
316 )
317 ) ,
318 'is_payment' => array(
319 'name' => 'is_payment',
320 'type' => CRM_Utils_Type::T_BOOLEAN,
321 'title' => ts('Is Payment?') ,
322 'description' => 'Is this entry either a payment or a reversal of a payment?',
323 'import' => true,
324 'where' => 'civicrm_financial_trxn.is_payment',
325 'headerPattern' => '',
326 'dataPattern' => '',
327 'export' => true,
328 'table_name' => 'civicrm_financial_trxn',
329 'entity' => 'FinancialTrxn',
330 'bao' => 'CRM_Financial_DAO_FinancialTrxn',
331 'localizable' => 0,
332 ) ,
333 'trxn_id' => array(
334 'name' => 'trxn_id',
335 'type' => CRM_Utils_Type::T_STRING,
336 'title' => ts('Transaction ID') ,
337 'description' => 'Transaction id supplied by external processor. This may not be unique.',
338 'maxlength' => 255,
339 'size' => CRM_Utils_Type::HUGE,
340 'table_name' => 'civicrm_financial_trxn',
341 'entity' => 'FinancialTrxn',
342 'bao' => 'CRM_Financial_DAO_FinancialTrxn',
343 'localizable' => 0,
344 ) ,
345 'trxn_result_code' => array(
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' => array(
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' => array(
372 'optionGroupName' => 'contribution_status',
373 'optionEditPath' => 'civicrm/admin/options/contribution_status',
374 )
375 ) ,
376 'payment_processor_id' => array(
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' => array(
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' => array(
397 'type' => 'Select',
398 ) ,
399 'pseudoconstant' => array(
400 'optionGroupName' => 'payment_instrument',
401 'optionEditPath' => 'civicrm/admin/options/payment_instrument',
402 )
403 ) ,
404 'financial_trxn_card_type' => array(
405 'name' => 'card_type',
406 'type' => CRM_Utils_Type::T_INT,
407 'title' => ts('Card Type') ,
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' => array(
414 'type' => 'Select',
415 ) ,
416 'pseudoconstant' => array(
417 'optionGroupName' => 'accept_creditcard',
418 'optionEditPath' => 'civicrm/admin/options/accept_creditcard',
419 )
420 ) ,
421 'financial_trxn_check_number' => array(
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' => array(
433 'type' => 'Text',
434 ) ,
435 ) ,
436 'financial_trxn_pan_truncation' => array(
437 'name' => 'pan_truncation',
438 'type' => CRM_Utils_Type::T_INT,
439 'title' => ts('Pan Truncation') ,
440 'description' => 'Last 4 digits of credit card',
441 'table_name' => 'civicrm_financial_trxn',
442 'entity' => 'FinancialTrxn',
443 'bao' => 'CRM_Financial_DAO_FinancialTrxn',
444 'localizable' => 0,
445 'html' => array(
446 'type' => 'Text',
447 ) ,
448 ) ,
449 );
450 CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'fields_callback', Civi::$statics[__CLASS__]['fields']);
451 }
452 return Civi::$statics[__CLASS__]['fields'];
453 }
454 /**
455 * Return a mapping from field-name to the corresponding key (as used in fields()).
456 *
457 * @return array
458 * Array(string $name => string $uniqueName).
459 */
460 static function &fieldKeys() {
461 if (!isset(Civi::$statics[__CLASS__]['fieldKeys'])) {
462 Civi::$statics[__CLASS__]['fieldKeys'] = array_flip(CRM_Utils_Array::collect('name', self::fields()));
463 }
464 return Civi::$statics[__CLASS__]['fieldKeys'];
465 }
466 /**
467 * Returns the names of this table
468 *
469 * @return string
470 */
471 static function getTableName() {
472 return self::$_tableName;
473 }
474 /**
475 * Returns if this table needs to be logged
476 *
477 * @return boolean
478 */
479 function getLog() {
480 return self::$_log;
481 }
482 /**
483 * Returns the list of fields that can be imported
484 *
485 * @param bool $prefix
486 *
487 * @return array
488 */
489 static function &import($prefix = false) {
490 $r = CRM_Core_DAO_AllCoreTables::getImports(__CLASS__, 'financial_trxn', $prefix, array());
491 return $r;
492 }
493 /**
494 * Returns the list of fields that can be exported
495 *
496 * @param bool $prefix
497 *
498 * @return array
499 */
500 static function &export($prefix = false) {
501 $r = CRM_Core_DAO_AllCoreTables::getExports(__CLASS__, 'financial_trxn', $prefix, array());
502 return $r;
503 }
504 /**
505 * Returns the list of indices
506 */
507 public static function indices($localize = TRUE) {
508 $indices = array(
509 'UI_ftrxn_trxn_id' => array(
510 'name' => 'UI_ftrxn_trxn_id',
511 'field' => array(
512 0 => 'trxn_id',
513 ) ,
514 'localizable' => false,
515 'sig' => 'civicrm_financial_trxn::0::trxn_id',
516 ) ,
517 'UI_ftrxn_payment_instrument_id' => array(
518 'name' => 'UI_ftrxn_payment_instrument_id',
519 'field' => array(
520 0 => 'payment_instrument_id',
521 ) ,
522 'localizable' => false,
523 'sig' => 'civicrm_financial_trxn::0::payment_instrument_id',
524 ) ,
525 'UI_ftrxn_check_number' => array(
526 'name' => 'UI_ftrxn_check_number',
527 'field' => array(
528 0 => 'check_number',
529 ) ,
530 'localizable' => false,
531 'sig' => 'civicrm_financial_trxn::0::check_number',
532 ) ,
533 );
534 return ($localize && !empty($indices)) ? CRM_Core_DAO_AllCoreTables::multilingualize(__CLASS__, $indices) : $indices;
535 }
536 }