Merge pull request #9773 from monishdeb/CRM-19663
[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:68f0081011769a1c3286c7d7a74324e3)
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 ) ,
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 ) ,
254 'table_name' => 'civicrm_financial_trxn',
255 'entity' => 'FinancialTrxn',
256 'bao' => 'CRM_Financial_DAO_FinancialTrxn',
257 'localizable' => 0,
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 ) ,
268 'table_name' => 'civicrm_financial_trxn',
269 'entity' => 'FinancialTrxn',
270 'bao' => 'CRM_Financial_DAO_FinancialTrxn',
271 'localizable' => 0,
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 ) ,
282 'table_name' => 'civicrm_financial_trxn',
283 'entity' => 'FinancialTrxn',
284 'bao' => 'CRM_Financial_DAO_FinancialTrxn',
285 'localizable' => 0,
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',
300 'table_name' => 'civicrm_financial_trxn',
301 'entity' => 'FinancialTrxn',
302 'bao' => 'CRM_Financial_DAO_FinancialTrxn',
303 'localizable' => 0,
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,
324 'table_name' => 'civicrm_financial_trxn',
325 'entity' => 'FinancialTrxn',
326 'bao' => 'CRM_Financial_DAO_FinancialTrxn',
327 'localizable' => 0,
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,
336 'table_name' => 'civicrm_financial_trxn',
337 'entity' => 'FinancialTrxn',
338 'bao' => 'CRM_Financial_DAO_FinancialTrxn',
339 'localizable' => 0,
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,
348 'table_name' => 'civicrm_financial_trxn',
349 'entity' => 'FinancialTrxn',
350 'bao' => 'CRM_Financial_DAO_FinancialTrxn',
351 'localizable' => 0,
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,
363 'table_name' => 'civicrm_financial_trxn',
364 'entity' => 'FinancialTrxn',
365 'bao' => 'CRM_Financial_DAO_FinancialTrxn',
366 'localizable' => 0,
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',
377 'table_name' => 'civicrm_financial_trxn',
378 'entity' => 'FinancialTrxn',
379 'bao' => 'CRM_Financial_DAO_FinancialTrxn',
380 'localizable' => 0,
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',
388 'table_name' => 'civicrm_financial_trxn',
389 'entity' => 'FinancialTrxn',
390 'bao' => 'CRM_Financial_DAO_FinancialTrxn',
391 'localizable' => 0,
392 'html' => array(
393 'type' => 'Select',
394 ) ,
395 'pseudoconstant' => array(
396 'optionGroupName' => 'payment_instrument',
397 'optionEditPath' => 'civicrm/admin/options/payment_instrument',
398 )
399 ) ,
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',
408 'localizable' => 0,
409 'html' => array(
410 'type' => 'Select',
411 ) ,
412 'pseudoconstant' => array(
413 'optionGroupName' => 'accept_creditcard',
414 'optionEditPath' => 'civicrm/admin/options/accept_creditcard',
415 )
416 ) ,
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,
424 'table_name' => 'civicrm_financial_trxn',
425 'entity' => 'FinancialTrxn',
426 'bao' => 'CRM_Financial_DAO_FinancialTrxn',
427 'localizable' => 0,
428 'html' => array(
429 'type' => 'Text',
430 ) ,
431 ) ,
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',
440 'localizable' => 0,
441 'html' => array(
442 'type' => 'Text',
443 ) ,
444 ) ,
445 );
446 CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'fields_callback', Civi::$statics[__CLASS__]['fields']);
447 }
448 return Civi::$statics[__CLASS__]['fields'];
449 }
450 /**
451 * Return a mapping from field-name to the corresponding key (as used in fields()).
452 *
453 * @return array
454 * Array(string $name => string $uniqueName).
455 */
456 static function &fieldKeys() {
457 if (!isset(Civi::$statics[__CLASS__]['fieldKeys'])) {
458 Civi::$statics[__CLASS__]['fieldKeys'] = array_flip(CRM_Utils_Array::collect('name', self::fields()));
459 }
460 return Civi::$statics[__CLASS__]['fieldKeys'];
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) {
486 $r = CRM_Core_DAO_AllCoreTables::getImports(__CLASS__, 'financial_trxn', $prefix, array());
487 return $r;
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) {
497 $r = CRM_Core_DAO_AllCoreTables::getExports(__CLASS__, 'financial_trxn', $prefix, array());
498 return $r;
499 }
500 /**
501 * Returns the list of indices
502 */
503 public static function indices($localize = TRUE) {
504 $indices = array(
505 'UI_ftrxn_trxn_id' => array(
506 'name' => 'UI_ftrxn_trxn_id',
507 'field' => array(
508 0 => 'trxn_id',
509 ) ,
510 'localizable' => false,
511 'sig' => 'civicrm_financial_trxn::0::trxn_id',
512 ) ,
513 'UI_ftrxn_payment_instrument_id' => array(
514 'name' => 'UI_ftrxn_payment_instrument_id',
515 'field' => array(
516 0 => 'payment_instrument_id',
517 ) ,
518 'localizable' => false,
519 'sig' => 'civicrm_financial_trxn::0::payment_instrument_id',
520 ) ,
521 'UI_ftrxn_check_number' => array(
522 'name' => 'UI_ftrxn_check_number',
523 'field' => array(
524 0 => 'check_number',
525 ) ,
526 'localizable' => false,
527 'sig' => 'civicrm_financial_trxn::0::check_number',
528 ) ,
529 );
530 return ($localize && !empty($indices)) ? CRM_Core_DAO_AllCoreTables::multilingualize(__CLASS__, $indices) : $indices;
531 }
532 }