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:330be109309bcc6fc543b287c805e606)
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';
18 const COMPONENT
= 'CiviContribute';
21 * Static instance to hold the table name.
25 public static $_tableName = 'civicrm_financial_trxn';
28 * Should CiviCRM log any modifications to this table in the civicrm_log table.
32 public static $_log = TRUE;
40 * FK to financial_account table.
44 public $from_financial_account_id;
47 * FK to financial_financial_account table.
51 public $to_financial_account_id;
54 * date transaction occurred
61 * amount of transaction
68 * actual processor fee if known - may be 0.
75 * actual funds transfer amount. total less fees. if processor does not report actual fee during transaction, this is set to total_amount.
82 * 3 character string, value from config setting or input via user.
89 * Is this entry either a payment or a reversal of a payment?
96 * Transaction id supplied by external processor. This may not be unique.
103 * processor result code
107 public $trxn_result_code;
110 * pseudo FK to civicrm_option_value of contribution_status_id option_group
117 * Payment Processor for this financial transaction
121 public $payment_processor_id;
124 * FK to payment_instrument option group values
128 public $payment_instrument_id;
131 * FK to accept_creditcard option group values
135 public $card_type_id;
142 public $check_number;
145 * Last 4 digits of credit card
149 public $pan_truncation;
152 * Payment Processor external order reference
156 public $order_reference;
161 public function __construct() {
162 $this->__table
= 'civicrm_financial_trxn';
163 parent
::__construct();
167 * Returns localized title of this entity.
169 * @param bool $plural
170 * Whether to return the plural version of the title.
172 public static function getEntityTitle($plural = FALSE) {
173 return $plural ?
ts('Financial Trxns') : ts('Financial Trxn');
177 * Returns foreign keys and entity references.
180 * [CRM_Core_Reference_Interface]
182 public static function getReferenceColumns() {
183 if (!isset(Civi
::$statics[__CLASS__
]['links'])) {
184 Civi
::$statics[__CLASS__
]['links'] = static::createReferenceColumns(__CLASS__
);
185 Civi
::$statics[__CLASS__
]['links'][] = new CRM_Core_Reference_Basic(self
::getTableName(), 'from_financial_account_id', 'civicrm_financial_account', 'id');
186 Civi
::$statics[__CLASS__
]['links'][] = new CRM_Core_Reference_Basic(self
::getTableName(), 'to_financial_account_id', 'civicrm_financial_account', 'id');
187 Civi
::$statics[__CLASS__
]['links'][] = new CRM_Core_Reference_Basic(self
::getTableName(), 'payment_processor_id', 'civicrm_payment_processor', 'id');
188 CRM_Core_DAO_AllCoreTables
::invoke(__CLASS__
, 'links_callback', Civi
::$statics[__CLASS__
]['links']);
190 return Civi
::$statics[__CLASS__
]['links'];
194 * Returns all the column names of this table
198 public static function &fields() {
199 if (!isset(Civi
::$statics[__CLASS__
]['fields'])) {
200 Civi
::$statics[__CLASS__
]['fields'] = [
203 'type' => CRM_Utils_Type
::T_INT
,
204 'title' => ts('Financial Transaction ID'),
206 'where' => 'civicrm_financial_trxn.id',
207 'table_name' => 'civicrm_financial_trxn',
208 'entity' => 'FinancialTrxn',
209 'bao' => 'CRM_Financial_DAO_FinancialTrxn',
217 'from_financial_account_id' => [
218 'name' => 'from_financial_account_id',
219 'type' => CRM_Utils_Type
::T_INT
,
220 'title' => ts('From Account ID'),
221 'description' => ts('FK to financial_account table.'),
222 'where' => 'civicrm_financial_trxn.from_financial_account_id',
223 'table_name' => 'civicrm_financial_trxn',
224 'entity' => 'FinancialTrxn',
225 'bao' => 'CRM_Financial_DAO_FinancialTrxn',
227 'FKClassName' => 'CRM_Financial_DAO_FinancialAccount',
230 'label' => ts("From Account"),
232 'pseudoconstant' => [
233 'table' => 'civicrm_financial_account',
235 'labelColumn' => 'name',
239 'to_financial_account_id' => [
240 'name' => 'to_financial_account_id',
241 'type' => CRM_Utils_Type
::T_INT
,
242 'title' => ts('To Account ID'),
243 'description' => ts('FK to financial_financial_account table.'),
244 'where' => 'civicrm_financial_trxn.to_financial_account_id',
245 'table_name' => 'civicrm_financial_trxn',
246 'entity' => 'FinancialTrxn',
247 'bao' => 'CRM_Financial_DAO_FinancialTrxn',
249 'FKClassName' => 'CRM_Financial_DAO_FinancialAccount',
252 'label' => ts("To Account"),
254 'pseudoconstant' => [
255 'table' => 'civicrm_financial_account',
257 'labelColumn' => 'name',
262 'name' => 'trxn_date',
263 'type' => CRM_Utils_Type
::T_DATE + CRM_Utils_Type
::T_TIME
,
264 'title' => ts('Financial Transaction Date'),
265 'description' => ts('date transaction occurred'),
266 'where' => 'civicrm_financial_trxn.trxn_date',
268 'table_name' => 'civicrm_financial_trxn',
269 'entity' => 'FinancialTrxn',
270 'bao' => 'CRM_Financial_DAO_FinancialTrxn',
273 'type' => 'Select Date',
274 'formatType' => 'activityDateTime',
279 'name' => 'total_amount',
280 'type' => CRM_Utils_Type
::T_MONEY
,
281 'title' => ts('Financial Total Amount'),
282 'description' => ts('amount of transaction'),
288 'where' => 'civicrm_financial_trxn.total_amount',
289 'table_name' => 'civicrm_financial_trxn',
290 'entity' => 'FinancialTrxn',
291 'bao' => 'CRM_Financial_DAO_FinancialTrxn',
296 'name' => 'fee_amount',
297 'type' => CRM_Utils_Type
::T_MONEY
,
298 'title' => ts('Financial Fee Amount'),
299 'description' => ts('actual processor fee if known - may be 0.'),
304 'where' => 'civicrm_financial_trxn.fee_amount',
305 'table_name' => 'civicrm_financial_trxn',
306 'entity' => 'FinancialTrxn',
307 'bao' => 'CRM_Financial_DAO_FinancialTrxn',
312 'name' => 'net_amount',
313 'type' => CRM_Utils_Type
::T_MONEY
,
314 'title' => ts('Financial Net Amount'),
315 'description' => ts('actual funds transfer amount. total less fees. if processor does not report actual fee during transaction, this is set to total_amount.'),
320 'where' => 'civicrm_financial_trxn.net_amount',
321 'table_name' => 'civicrm_financial_trxn',
322 'entity' => 'FinancialTrxn',
323 'bao' => 'CRM_Financial_DAO_FinancialTrxn',
328 'name' => 'currency',
329 'type' => CRM_Utils_Type
::T_STRING
,
330 'title' => ts('Financial Currency'),
331 'description' => ts('3 character string, value from config setting or input via user.'),
333 'size' => CRM_Utils_Type
::FOUR
,
335 'where' => 'civicrm_financial_trxn.currency',
336 'headerPattern' => '/cur(rency)?/i',
337 'dataPattern' => '/^[A-Z]{3}$/',
340 'table_name' => 'civicrm_financial_trxn',
341 'entity' => 'FinancialTrxn',
342 'bao' => 'CRM_Financial_DAO_FinancialTrxn',
347 'pseudoconstant' => [
348 'table' => 'civicrm_currency',
349 'keyColumn' => 'name',
350 'labelColumn' => 'full_name',
351 'nameColumn' => 'name',
352 'abbrColumn' => 'symbol',
357 'name' => 'is_payment',
358 'type' => CRM_Utils_Type
::T_BOOLEAN
,
359 'title' => ts('Is Payment?'),
360 'description' => ts('Is this entry either a payment or a reversal of a payment?'),
362 'where' => 'civicrm_financial_trxn.is_payment',
365 'table_name' => 'civicrm_financial_trxn',
366 'entity' => 'FinancialTrxn',
367 'bao' => 'CRM_Financial_DAO_FinancialTrxn',
373 'type' => CRM_Utils_Type
::T_STRING
,
374 'title' => ts('Transaction ID'),
375 'description' => ts('Transaction id supplied by external processor. This may not be unique.'),
378 'where' => 'civicrm_financial_trxn.trxn_id',
379 'table_name' => 'civicrm_financial_trxn',
380 'entity' => 'FinancialTrxn',
381 'bao' => 'CRM_Financial_DAO_FinancialTrxn',
388 'trxn_result_code' => [
389 'name' => 'trxn_result_code',
390 'type' => CRM_Utils_Type
::T_STRING
,
391 'title' => ts('Transaction Result Code'),
392 'description' => ts('processor result code'),
394 'size' => CRM_Utils_Type
::HUGE
,
395 'where' => 'civicrm_financial_trxn.trxn_result_code',
396 'table_name' => 'civicrm_financial_trxn',
397 'entity' => 'FinancialTrxn',
398 'bao' => 'CRM_Financial_DAO_FinancialTrxn',
403 'name' => 'status_id',
404 'type' => CRM_Utils_Type
::T_INT
,
405 'title' => ts('Financial Transaction Status ID'),
406 'description' => ts('pseudo FK to civicrm_option_value of contribution_status_id option_group'),
408 'where' => 'civicrm_financial_trxn.status_id',
409 'headerPattern' => '/status/i',
411 'table_name' => 'civicrm_financial_trxn',
412 'entity' => 'FinancialTrxn',
413 'bao' => 'CRM_Financial_DAO_FinancialTrxn',
415 'pseudoconstant' => [
416 'optionGroupName' => 'contribution_status',
417 'optionEditPath' => 'civicrm/admin/options/contribution_status',
421 'payment_processor_id' => [
422 'name' => 'payment_processor_id',
423 'type' => CRM_Utils_Type
::T_INT
,
424 'title' => ts('Payment Processor ID'),
425 'description' => ts('Payment Processor for this financial transaction'),
426 'where' => 'civicrm_financial_trxn.payment_processor_id',
427 'table_name' => 'civicrm_financial_trxn',
428 'entity' => 'FinancialTrxn',
429 'bao' => 'CRM_Financial_DAO_FinancialTrxn',
431 'FKClassName' => 'CRM_Financial_DAO_PaymentProcessor',
434 'label' => ts("Payment Processor"),
436 'pseudoconstant' => [
437 'table' => 'civicrm_payment_processor',
439 'labelColumn' => 'name',
443 'financial_trxn_payment_instrument_id' => [
444 'name' => 'payment_instrument_id',
445 'type' => CRM_Utils_Type
::T_INT
,
446 'title' => ts('Payment Method'),
447 'description' => ts('FK to payment_instrument option group values'),
448 'where' => 'civicrm_financial_trxn.payment_instrument_id',
449 'table_name' => 'civicrm_financial_trxn',
450 'entity' => 'FinancialTrxn',
451 'bao' => 'CRM_Financial_DAO_FinancialTrxn',
456 'pseudoconstant' => [
457 'optionGroupName' => 'payment_instrument',
458 'optionEditPath' => 'civicrm/admin/options/payment_instrument',
462 'financial_trxn_card_type_id' => [
463 'name' => 'card_type_id',
464 'type' => CRM_Utils_Type
::T_INT
,
465 'title' => ts('Card Type ID'),
466 'description' => ts('FK to accept_creditcard option group values'),
467 'where' => 'civicrm_financial_trxn.card_type_id',
468 'table_name' => 'civicrm_financial_trxn',
469 'entity' => 'FinancialTrxn',
470 'bao' => 'CRM_Financial_DAO_FinancialTrxn',
475 'pseudoconstant' => [
476 'optionGroupName' => 'accept_creditcard',
477 'optionEditPath' => 'civicrm/admin/options/accept_creditcard',
481 'financial_trxn_check_number' => [
482 'name' => 'check_number',
483 'type' => CRM_Utils_Type
::T_STRING
,
484 'title' => ts('Check Number'),
485 'description' => ts('Check number'),
488 'where' => 'civicrm_financial_trxn.check_number',
489 'table_name' => 'civicrm_financial_trxn',
490 'entity' => 'FinancialTrxn',
491 'bao' => 'CRM_Financial_DAO_FinancialTrxn',
498 'financial_trxn_pan_truncation' => [
499 'name' => 'pan_truncation',
500 'type' => CRM_Utils_Type
::T_STRING
,
501 'title' => ts('PAN Truncation'),
502 'description' => ts('Last 4 digits of credit card'),
505 'where' => 'civicrm_financial_trxn.pan_truncation',
506 'table_name' => 'civicrm_financial_trxn',
507 'entity' => 'FinancialTrxn',
508 'bao' => 'CRM_Financial_DAO_FinancialTrxn',
515 'financial_trxn_order_reference' => [
516 'name' => 'order_reference',
517 'type' => CRM_Utils_Type
::T_STRING
,
518 'title' => ts('Order Reference'),
519 'description' => ts('Payment Processor external order reference'),
522 'where' => 'civicrm_financial_trxn.order_reference',
523 'table_name' => 'civicrm_financial_trxn',
524 'entity' => 'FinancialTrxn',
525 'bao' => 'CRM_Financial_DAO_FinancialTrxn',
533 CRM_Core_DAO_AllCoreTables
::invoke(__CLASS__
, 'fields_callback', Civi
::$statics[__CLASS__
]['fields']);
535 return Civi
::$statics[__CLASS__
]['fields'];
539 * Return a mapping from field-name to the corresponding key (as used in fields()).
542 * Array(string $name => string $uniqueName).
544 public static function &fieldKeys() {
545 if (!isset(Civi
::$statics[__CLASS__
]['fieldKeys'])) {
546 Civi
::$statics[__CLASS__
]['fieldKeys'] = array_flip(CRM_Utils_Array
::collect('name', self
::fields()));
548 return Civi
::$statics[__CLASS__
]['fieldKeys'];
552 * Returns the names of this table
556 public static function getTableName() {
557 return self
::$_tableName;
561 * Returns if this table needs to be logged
565 public function getLog() {
570 * Returns the list of fields that can be imported
572 * @param bool $prefix
576 public static function &import($prefix = FALSE) {
577 $r = CRM_Core_DAO_AllCoreTables
::getImports(__CLASS__
, 'financial_trxn', $prefix, []);
582 * Returns the list of fields that can be exported
584 * @param bool $prefix
588 public static function &export($prefix = FALSE) {
589 $r = CRM_Core_DAO_AllCoreTables
::getExports(__CLASS__
, 'financial_trxn', $prefix, []);
594 * Returns the list of indices
596 * @param bool $localize
600 public static function indices($localize = TRUE) {
602 'UI_ftrxn_trxn_id' => [
603 'name' => 'UI_ftrxn_trxn_id',
607 'localizable' => FALSE,
608 'sig' => 'civicrm_financial_trxn::0::trxn_id',
610 'UI_ftrxn_payment_instrument_id' => [
611 'name' => 'UI_ftrxn_payment_instrument_id',
613 0 => 'payment_instrument_id',
615 'localizable' => FALSE,
616 'sig' => 'civicrm_financial_trxn::0::payment_instrument_id',
618 'UI_ftrxn_check_number' => [
619 'name' => 'UI_ftrxn_check_number',
623 'localizable' => FALSE,
624 'sig' => 'civicrm_financial_trxn::0::check_number',
627 return ($localize && !empty($indices)) ? CRM_Core_DAO_AllCoreTables
::multilingualize(__CLASS__
, $indices) : $indices;