5 * @copyright CiviCRM LLC https://civicrm.org/licensing
7 * Generated from xml/schema/CRM/Financial/FinancialTrxn.xml
8 * DO NOT EDIT. Generated by CRM_Core_CodeGen
9 * (GenCodeChecksum:857c64b471d1872d98141aefa56aecb6)
13 * Database access object for the FinancialTrxn entity.
15 class CRM_Financial_DAO_FinancialTrxn
extends CRM_Core_DAO
{
16 const EXT
= 'civicrm';
17 const TABLE_ADDED
= '1.3';
20 * Static instance to hold the table name.
24 public static $_tableName = 'civicrm_financial_trxn';
27 * Should CiviCRM log any modifications to this table in the civicrm_log table.
31 public static $_log = TRUE;
39 * FK to financial_account table.
43 public $from_financial_account_id;
46 * FK to financial_financial_account table.
50 public $to_financial_account_id;
53 * date transaction occurred
60 * amount of transaction
67 * actual processor fee if known - may be 0.
74 * actual funds transfer amount. total less fees. if processor does not report actual fee during transaction, this is set to total_amount.
81 * 3 character string, value from config setting or input via user.
88 * Is this entry either a payment or a reversal of a payment?
95 * Transaction id supplied by external processor. This may not be unique.
102 * processor result code
106 public $trxn_result_code;
109 * pseudo FK to civicrm_option_value of contribution_status_id option_group
116 * Payment Processor for this financial transaction
120 public $payment_processor_id;
123 * FK to payment_instrument option group values
127 public $payment_instrument_id;
130 * FK to accept_creditcard option group values
134 public $card_type_id;
141 public $check_number;
144 * Last 4 digits of credit card
148 public $pan_truncation;
151 * Payment Processor external order reference
155 public $order_reference;
160 public function __construct() {
161 $this->__table
= 'civicrm_financial_trxn';
162 parent
::__construct();
166 * Returns localized title of this entity.
168 * @param bool $plural
169 * Whether to return the plural version of the title.
171 public static function getEntityTitle($plural = FALSE) {
172 return $plural ?
ts('Financial Trxns') : ts('Financial Trxn');
176 * Returns foreign keys and entity references.
179 * [CRM_Core_Reference_Interface]
181 public static function getReferenceColumns() {
182 if (!isset(Civi
::$statics[__CLASS__
]['links'])) {
183 Civi
::$statics[__CLASS__
]['links'] = static::createReferenceColumns(__CLASS__
);
184 Civi
::$statics[__CLASS__
]['links'][] = new CRM_Core_Reference_Basic(self
::getTableName(), 'from_financial_account_id', 'civicrm_financial_account', 'id');
185 Civi
::$statics[__CLASS__
]['links'][] = new CRM_Core_Reference_Basic(self
::getTableName(), 'to_financial_account_id', 'civicrm_financial_account', 'id');
186 Civi
::$statics[__CLASS__
]['links'][] = new CRM_Core_Reference_Basic(self
::getTableName(), 'payment_processor_id', 'civicrm_payment_processor', 'id');
187 CRM_Core_DAO_AllCoreTables
::invoke(__CLASS__
, 'links_callback', Civi
::$statics[__CLASS__
]['links']);
189 return Civi
::$statics[__CLASS__
]['links'];
193 * Returns all the column names of this table
197 public static function &fields() {
198 if (!isset(Civi
::$statics[__CLASS__
]['fields'])) {
199 Civi
::$statics[__CLASS__
]['fields'] = [
202 'type' => CRM_Utils_Type
::T_INT
,
203 'title' => ts('Financial Transaction ID'),
205 'where' => 'civicrm_financial_trxn.id',
206 'table_name' => 'civicrm_financial_trxn',
207 'entity' => 'FinancialTrxn',
208 'bao' => 'CRM_Financial_DAO_FinancialTrxn',
212 'from_financial_account_id' => [
213 'name' => 'from_financial_account_id',
214 'type' => CRM_Utils_Type
::T_INT
,
215 'title' => ts('Financial Transaction From Account'),
216 'description' => ts('FK to financial_account table.'),
217 'where' => 'civicrm_financial_trxn.from_financial_account_id',
218 'table_name' => 'civicrm_financial_trxn',
219 'entity' => 'FinancialTrxn',
220 'bao' => 'CRM_Financial_DAO_FinancialTrxn',
222 'FKClassName' => 'CRM_Financial_DAO_FinancialAccount',
226 'pseudoconstant' => [
227 'table' => 'civicrm_financial_account',
229 'labelColumn' => 'name',
233 'to_financial_account_id' => [
234 'name' => 'to_financial_account_id',
235 'type' => CRM_Utils_Type
::T_INT
,
236 'title' => ts('Financial Transaction To Account'),
237 'description' => ts('FK to financial_financial_account table.'),
238 'where' => 'civicrm_financial_trxn.to_financial_account_id',
239 'table_name' => 'civicrm_financial_trxn',
240 'entity' => 'FinancialTrxn',
241 'bao' => 'CRM_Financial_DAO_FinancialTrxn',
243 'FKClassName' => 'CRM_Financial_DAO_FinancialAccount',
247 'pseudoconstant' => [
248 'table' => 'civicrm_financial_account',
250 'labelColumn' => 'name',
255 'name' => 'trxn_date',
256 'type' => CRM_Utils_Type
::T_DATE + CRM_Utils_Type
::T_TIME
,
257 'title' => ts('Financial Transaction Date'),
258 'description' => ts('date transaction occurred'),
259 'where' => 'civicrm_financial_trxn.trxn_date',
261 'table_name' => 'civicrm_financial_trxn',
262 'entity' => 'FinancialTrxn',
263 'bao' => 'CRM_Financial_DAO_FinancialTrxn',
266 'type' => 'Select Date',
267 'formatType' => 'activityDateTime',
272 'name' => 'total_amount',
273 'type' => CRM_Utils_Type
::T_MONEY
,
274 'title' => ts('Financial Total Amount'),
275 'description' => ts('amount of transaction'),
281 'where' => 'civicrm_financial_trxn.total_amount',
282 'table_name' => 'civicrm_financial_trxn',
283 'entity' => 'FinancialTrxn',
284 'bao' => 'CRM_Financial_DAO_FinancialTrxn',
289 'name' => 'fee_amount',
290 'type' => CRM_Utils_Type
::T_MONEY
,
291 'title' => ts('Financial Fee Amount'),
292 'description' => ts('actual processor fee if known - may be 0.'),
297 'where' => 'civicrm_financial_trxn.fee_amount',
298 'table_name' => 'civicrm_financial_trxn',
299 'entity' => 'FinancialTrxn',
300 'bao' => 'CRM_Financial_DAO_FinancialTrxn',
305 'name' => 'net_amount',
306 'type' => CRM_Utils_Type
::T_MONEY
,
307 'title' => ts('Financial Net Amount'),
308 'description' => ts('actual funds transfer amount. total less fees. if processor does not report actual fee during transaction, this is set to total_amount.'),
313 'where' => 'civicrm_financial_trxn.net_amount',
314 'table_name' => 'civicrm_financial_trxn',
315 'entity' => 'FinancialTrxn',
316 'bao' => 'CRM_Financial_DAO_FinancialTrxn',
321 'name' => 'currency',
322 'type' => CRM_Utils_Type
::T_STRING
,
323 'title' => ts('Financial Currency'),
324 'description' => ts('3 character string, value from config setting or input via user.'),
326 'size' => CRM_Utils_Type
::FOUR
,
328 'where' => 'civicrm_financial_trxn.currency',
329 'headerPattern' => '/cur(rency)?/i',
330 'dataPattern' => '/^[A-Z]{3}$/',
333 'table_name' => 'civicrm_financial_trxn',
334 'entity' => 'FinancialTrxn',
335 'bao' => 'CRM_Financial_DAO_FinancialTrxn',
340 'pseudoconstant' => [
341 'table' => 'civicrm_currency',
342 'keyColumn' => 'name',
343 'labelColumn' => 'full_name',
344 'nameColumn' => 'name',
345 'abbrColumn' => 'symbol',
350 'name' => 'is_payment',
351 'type' => CRM_Utils_Type
::T_BOOLEAN
,
352 'title' => ts('Is Payment?'),
353 'description' => ts('Is this entry either a payment or a reversal of a payment?'),
355 'where' => 'civicrm_financial_trxn.is_payment',
358 'table_name' => 'civicrm_financial_trxn',
359 'entity' => 'FinancialTrxn',
360 'bao' => 'CRM_Financial_DAO_FinancialTrxn',
366 'type' => CRM_Utils_Type
::T_STRING
,
367 'title' => ts('Transaction ID'),
368 'description' => ts('Transaction id supplied by external processor. This may not be unique.'),
371 'where' => 'civicrm_financial_trxn.trxn_id',
372 'table_name' => 'civicrm_financial_trxn',
373 'entity' => 'FinancialTrxn',
374 'bao' => 'CRM_Financial_DAO_FinancialTrxn',
381 'trxn_result_code' => [
382 'name' => 'trxn_result_code',
383 'type' => CRM_Utils_Type
::T_STRING
,
384 'title' => ts('Transaction Result Code'),
385 'description' => ts('processor result code'),
387 'size' => CRM_Utils_Type
::HUGE
,
388 'where' => 'civicrm_financial_trxn.trxn_result_code',
389 'table_name' => 'civicrm_financial_trxn',
390 'entity' => 'FinancialTrxn',
391 'bao' => 'CRM_Financial_DAO_FinancialTrxn',
396 'name' => 'status_id',
397 'type' => CRM_Utils_Type
::T_INT
,
398 'title' => ts('Financial Transaction Status Id'),
399 'description' => ts('pseudo FK to civicrm_option_value of contribution_status_id option_group'),
401 'where' => 'civicrm_financial_trxn.status_id',
402 'headerPattern' => '/status/i',
404 'table_name' => 'civicrm_financial_trxn',
405 'entity' => 'FinancialTrxn',
406 'bao' => 'CRM_Financial_DAO_FinancialTrxn',
408 'pseudoconstant' => [
409 'optionGroupName' => 'contribution_status',
410 'optionEditPath' => 'civicrm/admin/options/contribution_status',
414 'payment_processor_id' => [
415 'name' => 'payment_processor_id',
416 'type' => CRM_Utils_Type
::T_INT
,
417 'title' => ts('Payment Processor'),
418 'description' => ts('Payment Processor for this financial transaction'),
419 'where' => 'civicrm_financial_trxn.payment_processor_id',
420 'table_name' => 'civicrm_financial_trxn',
421 'entity' => 'FinancialTrxn',
422 'bao' => 'CRM_Financial_DAO_FinancialTrxn',
424 'FKClassName' => 'CRM_Financial_DAO_PaymentProcessor',
427 'financial_trxn_payment_instrument_id' => [
428 'name' => 'payment_instrument_id',
429 'type' => CRM_Utils_Type
::T_INT
,
430 'title' => ts('Payment Method'),
431 'description' => ts('FK to payment_instrument option group values'),
432 'where' => 'civicrm_financial_trxn.payment_instrument_id',
433 'table_name' => 'civicrm_financial_trxn',
434 'entity' => 'FinancialTrxn',
435 'bao' => 'CRM_Financial_DAO_FinancialTrxn',
440 'pseudoconstant' => [
441 'optionGroupName' => 'payment_instrument',
442 'optionEditPath' => 'civicrm/admin/options/payment_instrument',
446 'financial_trxn_card_type_id' => [
447 'name' => 'card_type_id',
448 'type' => CRM_Utils_Type
::T_INT
,
449 'title' => ts('Card Type ID'),
450 'description' => ts('FK to accept_creditcard option group values'),
451 'where' => 'civicrm_financial_trxn.card_type_id',
452 'table_name' => 'civicrm_financial_trxn',
453 'entity' => 'FinancialTrxn',
454 'bao' => 'CRM_Financial_DAO_FinancialTrxn',
459 'pseudoconstant' => [
460 'optionGroupName' => 'accept_creditcard',
461 'optionEditPath' => 'civicrm/admin/options/accept_creditcard',
465 'financial_trxn_check_number' => [
466 'name' => 'check_number',
467 'type' => CRM_Utils_Type
::T_STRING
,
468 'title' => ts('Check Number'),
469 'description' => ts('Check number'),
472 'where' => 'civicrm_financial_trxn.check_number',
473 'table_name' => 'civicrm_financial_trxn',
474 'entity' => 'FinancialTrxn',
475 'bao' => 'CRM_Financial_DAO_FinancialTrxn',
482 'financial_trxn_pan_truncation' => [
483 'name' => 'pan_truncation',
484 'type' => CRM_Utils_Type
::T_STRING
,
485 'title' => ts('PAN Truncation'),
486 'description' => ts('Last 4 digits of credit card'),
489 'where' => 'civicrm_financial_trxn.pan_truncation',
490 'table_name' => 'civicrm_financial_trxn',
491 'entity' => 'FinancialTrxn',
492 'bao' => 'CRM_Financial_DAO_FinancialTrxn',
499 'financial_trxn_order_reference' => [
500 'name' => 'order_reference',
501 'type' => CRM_Utils_Type
::T_STRING
,
502 'title' => ts('Order Reference'),
503 'description' => ts('Payment Processor external order reference'),
506 'where' => 'civicrm_financial_trxn.order_reference',
507 'table_name' => 'civicrm_financial_trxn',
508 'entity' => 'FinancialTrxn',
509 'bao' => 'CRM_Financial_DAO_FinancialTrxn',
517 CRM_Core_DAO_AllCoreTables
::invoke(__CLASS__
, 'fields_callback', Civi
::$statics[__CLASS__
]['fields']);
519 return Civi
::$statics[__CLASS__
]['fields'];
523 * Return a mapping from field-name to the corresponding key (as used in fields()).
526 * Array(string $name => string $uniqueName).
528 public static function &fieldKeys() {
529 if (!isset(Civi
::$statics[__CLASS__
]['fieldKeys'])) {
530 Civi
::$statics[__CLASS__
]['fieldKeys'] = array_flip(CRM_Utils_Array
::collect('name', self
::fields()));
532 return Civi
::$statics[__CLASS__
]['fieldKeys'];
536 * Returns the names of this table
540 public static function getTableName() {
541 return self
::$_tableName;
545 * Returns if this table needs to be logged
549 public function getLog() {
554 * Returns the list of fields that can be imported
556 * @param bool $prefix
560 public static function &import($prefix = FALSE) {
561 $r = CRM_Core_DAO_AllCoreTables
::getImports(__CLASS__
, 'financial_trxn', $prefix, []);
566 * Returns the list of fields that can be exported
568 * @param bool $prefix
572 public static function &export($prefix = FALSE) {
573 $r = CRM_Core_DAO_AllCoreTables
::getExports(__CLASS__
, 'financial_trxn', $prefix, []);
578 * Returns the list of indices
580 * @param bool $localize
584 public static function indices($localize = TRUE) {
586 'UI_ftrxn_trxn_id' => [
587 'name' => 'UI_ftrxn_trxn_id',
591 'localizable' => FALSE,
592 'sig' => 'civicrm_financial_trxn::0::trxn_id',
594 'UI_ftrxn_payment_instrument_id' => [
595 'name' => 'UI_ftrxn_payment_instrument_id',
597 0 => 'payment_instrument_id',
599 'localizable' => FALSE,
600 'sig' => 'civicrm_financial_trxn::0::payment_instrument_id',
602 'UI_ftrxn_check_number' => [
603 'name' => 'UI_ftrxn_check_number',
607 'localizable' => FALSE,
608 'sig' => 'civicrm_financial_trxn::0::check_number',
611 return ($localize && !empty($indices)) ? CRM_Core_DAO_AllCoreTables
::multilingualize(__CLASS__
, $indices) : $indices;