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:5a4324ffe222bf724ab9d4cde26eb4c2)
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 public static function getEntityTitle() {
169 return ts('Financial Trxns');
173 * Returns foreign keys and entity references.
176 * [CRM_Core_Reference_Interface]
178 public static function getReferenceColumns() {
179 if (!isset(Civi
::$statics[__CLASS__
]['links'])) {
180 Civi
::$statics[__CLASS__
]['links'] = static::createReferenceColumns(__CLASS__
);
181 Civi
::$statics[__CLASS__
]['links'][] = new CRM_Core_Reference_Basic(self
::getTableName(), 'from_financial_account_id', 'civicrm_financial_account', 'id');
182 Civi
::$statics[__CLASS__
]['links'][] = new CRM_Core_Reference_Basic(self
::getTableName(), 'to_financial_account_id', 'civicrm_financial_account', 'id');
183 Civi
::$statics[__CLASS__
]['links'][] = new CRM_Core_Reference_Basic(self
::getTableName(), 'payment_processor_id', 'civicrm_payment_processor', 'id');
184 CRM_Core_DAO_AllCoreTables
::invoke(__CLASS__
, 'links_callback', Civi
::$statics[__CLASS__
]['links']);
186 return Civi
::$statics[__CLASS__
]['links'];
190 * Returns all the column names of this table
194 public static function &fields() {
195 if (!isset(Civi
::$statics[__CLASS__
]['fields'])) {
196 Civi
::$statics[__CLASS__
]['fields'] = [
199 'type' => CRM_Utils_Type
::T_INT
,
200 'title' => ts('Financial Transaction ID'),
202 'where' => 'civicrm_financial_trxn.id',
203 'table_name' => 'civicrm_financial_trxn',
204 'entity' => 'FinancialTrxn',
205 'bao' => 'CRM_Financial_DAO_FinancialTrxn',
209 'from_financial_account_id' => [
210 'name' => 'from_financial_account_id',
211 'type' => CRM_Utils_Type
::T_INT
,
212 'title' => ts('Financial Transaction From Account'),
213 'description' => ts('FK to financial_account table.'),
214 'where' => 'civicrm_financial_trxn.from_financial_account_id',
215 'table_name' => 'civicrm_financial_trxn',
216 'entity' => 'FinancialTrxn',
217 'bao' => 'CRM_Financial_DAO_FinancialTrxn',
219 'FKClassName' => 'CRM_Financial_DAO_FinancialAccount',
223 'pseudoconstant' => [
224 'table' => 'civicrm_financial_account',
226 'labelColumn' => 'name',
230 'to_financial_account_id' => [
231 'name' => 'to_financial_account_id',
232 'type' => CRM_Utils_Type
::T_INT
,
233 'title' => ts('Financial Transaction To Account'),
234 'description' => ts('FK to financial_financial_account table.'),
235 'where' => 'civicrm_financial_trxn.to_financial_account_id',
236 'table_name' => 'civicrm_financial_trxn',
237 'entity' => 'FinancialTrxn',
238 'bao' => 'CRM_Financial_DAO_FinancialTrxn',
240 'FKClassName' => 'CRM_Financial_DAO_FinancialAccount',
244 'pseudoconstant' => [
245 'table' => 'civicrm_financial_account',
247 'labelColumn' => 'name',
252 'name' => 'trxn_date',
253 'type' => CRM_Utils_Type
::T_DATE + CRM_Utils_Type
::T_TIME
,
254 'title' => ts('Financial Transaction Date'),
255 'description' => ts('date transaction occurred'),
256 'where' => 'civicrm_financial_trxn.trxn_date',
258 'table_name' => 'civicrm_financial_trxn',
259 'entity' => 'FinancialTrxn',
260 'bao' => 'CRM_Financial_DAO_FinancialTrxn',
263 'type' => 'Select Date',
264 'formatType' => 'activityDateTime',
269 'name' => 'total_amount',
270 'type' => CRM_Utils_Type
::T_MONEY
,
271 'title' => ts('Financial Total Amount'),
272 'description' => ts('amount of transaction'),
278 'where' => 'civicrm_financial_trxn.total_amount',
279 'table_name' => 'civicrm_financial_trxn',
280 'entity' => 'FinancialTrxn',
281 'bao' => 'CRM_Financial_DAO_FinancialTrxn',
286 'name' => 'fee_amount',
287 'type' => CRM_Utils_Type
::T_MONEY
,
288 'title' => ts('Financial Fee Amount'),
289 'description' => ts('actual processor fee if known - may be 0.'),
294 'where' => 'civicrm_financial_trxn.fee_amount',
295 'table_name' => 'civicrm_financial_trxn',
296 'entity' => 'FinancialTrxn',
297 'bao' => 'CRM_Financial_DAO_FinancialTrxn',
302 'name' => 'net_amount',
303 'type' => CRM_Utils_Type
::T_MONEY
,
304 'title' => ts('Financial Net Amount'),
305 'description' => ts('actual funds transfer amount. total less fees. if processor does not report actual fee during transaction, this is set to total_amount.'),
310 'where' => 'civicrm_financial_trxn.net_amount',
311 'table_name' => 'civicrm_financial_trxn',
312 'entity' => 'FinancialTrxn',
313 'bao' => 'CRM_Financial_DAO_FinancialTrxn',
318 'name' => 'currency',
319 'type' => CRM_Utils_Type
::T_STRING
,
320 'title' => ts('Financial Currency'),
321 'description' => ts('3 character string, value from config setting or input via user.'),
323 'size' => CRM_Utils_Type
::FOUR
,
325 'where' => 'civicrm_financial_trxn.currency',
326 'headerPattern' => '/cur(rency)?/i',
327 'dataPattern' => '/^[A-Z]{3}$/',
330 'table_name' => 'civicrm_financial_trxn',
331 'entity' => 'FinancialTrxn',
332 'bao' => 'CRM_Financial_DAO_FinancialTrxn',
337 'pseudoconstant' => [
338 'table' => 'civicrm_currency',
339 'keyColumn' => 'name',
340 'labelColumn' => 'full_name',
341 'nameColumn' => 'name',
342 'abbrColumn' => 'symbol',
347 'name' => 'is_payment',
348 'type' => CRM_Utils_Type
::T_BOOLEAN
,
349 'title' => ts('Is Payment?'),
350 'description' => ts('Is this entry either a payment or a reversal of a payment?'),
352 'where' => 'civicrm_financial_trxn.is_payment',
355 'table_name' => 'civicrm_financial_trxn',
356 'entity' => 'FinancialTrxn',
357 'bao' => 'CRM_Financial_DAO_FinancialTrxn',
363 'type' => CRM_Utils_Type
::T_STRING
,
364 'title' => ts('Transaction ID'),
365 'description' => ts('Transaction id supplied by external processor. This may not be unique.'),
368 'where' => 'civicrm_financial_trxn.trxn_id',
369 'table_name' => 'civicrm_financial_trxn',
370 'entity' => 'FinancialTrxn',
371 'bao' => 'CRM_Financial_DAO_FinancialTrxn',
378 'trxn_result_code' => [
379 'name' => 'trxn_result_code',
380 'type' => CRM_Utils_Type
::T_STRING
,
381 'title' => ts('Transaction Result Code'),
382 'description' => ts('processor result code'),
384 'size' => CRM_Utils_Type
::HUGE
,
385 'where' => 'civicrm_financial_trxn.trxn_result_code',
386 'table_name' => 'civicrm_financial_trxn',
387 'entity' => 'FinancialTrxn',
388 'bao' => 'CRM_Financial_DAO_FinancialTrxn',
393 'name' => 'status_id',
394 'type' => CRM_Utils_Type
::T_INT
,
395 'title' => ts('Financial Transaction Status Id'),
396 'description' => ts('pseudo FK to civicrm_option_value of contribution_status_id option_group'),
398 'where' => 'civicrm_financial_trxn.status_id',
399 'headerPattern' => '/status/i',
401 'table_name' => 'civicrm_financial_trxn',
402 'entity' => 'FinancialTrxn',
403 'bao' => 'CRM_Financial_DAO_FinancialTrxn',
405 'pseudoconstant' => [
406 'optionGroupName' => 'contribution_status',
407 'optionEditPath' => 'civicrm/admin/options/contribution_status',
411 'payment_processor_id' => [
412 'name' => 'payment_processor_id',
413 'type' => CRM_Utils_Type
::T_INT
,
414 'title' => ts('Payment Processor'),
415 'description' => ts('Payment Processor for this financial transaction'),
416 'where' => 'civicrm_financial_trxn.payment_processor_id',
417 'table_name' => 'civicrm_financial_trxn',
418 'entity' => 'FinancialTrxn',
419 'bao' => 'CRM_Financial_DAO_FinancialTrxn',
421 'FKClassName' => 'CRM_Financial_DAO_PaymentProcessor',
424 'financial_trxn_payment_instrument_id' => [
425 'name' => 'payment_instrument_id',
426 'type' => CRM_Utils_Type
::T_INT
,
427 'title' => ts('Payment Method'),
428 'description' => ts('FK to payment_instrument option group values'),
429 'where' => 'civicrm_financial_trxn.payment_instrument_id',
430 'table_name' => 'civicrm_financial_trxn',
431 'entity' => 'FinancialTrxn',
432 'bao' => 'CRM_Financial_DAO_FinancialTrxn',
437 'pseudoconstant' => [
438 'optionGroupName' => 'payment_instrument',
439 'optionEditPath' => 'civicrm/admin/options/payment_instrument',
443 'financial_trxn_card_type_id' => [
444 'name' => 'card_type_id',
445 'type' => CRM_Utils_Type
::T_INT
,
446 'title' => ts('Card Type ID'),
447 'description' => ts('FK to accept_creditcard option group values'),
448 'where' => 'civicrm_financial_trxn.card_type_id',
449 'table_name' => 'civicrm_financial_trxn',
450 'entity' => 'FinancialTrxn',
451 'bao' => 'CRM_Financial_DAO_FinancialTrxn',
456 'pseudoconstant' => [
457 'optionGroupName' => 'accept_creditcard',
458 'optionEditPath' => 'civicrm/admin/options/accept_creditcard',
462 'financial_trxn_check_number' => [
463 'name' => 'check_number',
464 'type' => CRM_Utils_Type
::T_STRING
,
465 'title' => ts('Check Number'),
466 'description' => ts('Check number'),
469 'where' => 'civicrm_financial_trxn.check_number',
470 'table_name' => 'civicrm_financial_trxn',
471 'entity' => 'FinancialTrxn',
472 'bao' => 'CRM_Financial_DAO_FinancialTrxn',
479 'financial_trxn_pan_truncation' => [
480 'name' => 'pan_truncation',
481 'type' => CRM_Utils_Type
::T_STRING
,
482 'title' => ts('PAN Truncation'),
483 'description' => ts('Last 4 digits of credit card'),
486 'where' => 'civicrm_financial_trxn.pan_truncation',
487 'table_name' => 'civicrm_financial_trxn',
488 'entity' => 'FinancialTrxn',
489 'bao' => 'CRM_Financial_DAO_FinancialTrxn',
496 'financial_trxn_order_reference' => [
497 'name' => 'order_reference',
498 'type' => CRM_Utils_Type
::T_STRING
,
499 'title' => ts('Order Reference'),
500 'description' => ts('Payment Processor external order reference'),
503 'where' => 'civicrm_financial_trxn.order_reference',
504 'table_name' => 'civicrm_financial_trxn',
505 'entity' => 'FinancialTrxn',
506 'bao' => 'CRM_Financial_DAO_FinancialTrxn',
514 CRM_Core_DAO_AllCoreTables
::invoke(__CLASS__
, 'fields_callback', Civi
::$statics[__CLASS__
]['fields']);
516 return Civi
::$statics[__CLASS__
]['fields'];
520 * Return a mapping from field-name to the corresponding key (as used in fields()).
523 * Array(string $name => string $uniqueName).
525 public static function &fieldKeys() {
526 if (!isset(Civi
::$statics[__CLASS__
]['fieldKeys'])) {
527 Civi
::$statics[__CLASS__
]['fieldKeys'] = array_flip(CRM_Utils_Array
::collect('name', self
::fields()));
529 return Civi
::$statics[__CLASS__
]['fieldKeys'];
533 * Returns the names of this table
537 public static function getTableName() {
538 return self
::$_tableName;
542 * Returns if this table needs to be logged
546 public function getLog() {
551 * Returns the list of fields that can be imported
553 * @param bool $prefix
557 public static function &import($prefix = FALSE) {
558 $r = CRM_Core_DAO_AllCoreTables
::getImports(__CLASS__
, 'financial_trxn', $prefix, []);
563 * Returns the list of fields that can be exported
565 * @param bool $prefix
569 public static function &export($prefix = FALSE) {
570 $r = CRM_Core_DAO_AllCoreTables
::getExports(__CLASS__
, 'financial_trxn', $prefix, []);
575 * Returns the list of indices
577 * @param bool $localize
581 public static function indices($localize = TRUE) {
583 'UI_ftrxn_trxn_id' => [
584 'name' => 'UI_ftrxn_trxn_id',
588 'localizable' => FALSE,
589 'sig' => 'civicrm_financial_trxn::0::trxn_id',
591 'UI_ftrxn_payment_instrument_id' => [
592 'name' => 'UI_ftrxn_payment_instrument_id',
594 0 => 'payment_instrument_id',
596 'localizable' => FALSE,
597 'sig' => 'civicrm_financial_trxn::0::payment_instrument_id',
599 'UI_ftrxn_check_number' => [
600 'name' => 'UI_ftrxn_check_number',
604 'localizable' => FALSE,
605 'sig' => 'civicrm_financial_trxn::0::check_number',
608 return ($localize && !empty($indices)) ? CRM_Core_DAO_AllCoreTables
::multilingualize(__CLASS__
, $indices) : $indices;