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:fc57b040c59579f712c08578967559e5)
13 * Database access object for the FinancialTrxn entity.
15 class CRM_Financial_DAO_FinancialTrxn
extends CRM_Core_DAO
{
18 * Static instance to hold the table name.
22 public static $_tableName = 'civicrm_financial_trxn';
25 * Should CiviCRM log any modifications to this table in the civicrm_log table.
29 public static $_log = TRUE;
37 * FK to financial_account table.
41 public $from_financial_account_id;
44 * FK to financial_financial_account table.
48 public $to_financial_account_id;
51 * date transaction occurred
58 * amount of transaction
65 * actual processor fee if known - may be 0.
72 * actual funds transfer amount. total less fees. if processor does not report actual fee during transaction, this is set to total_amount.
79 * 3 character string, value from config setting or input via user.
86 * Is this entry either a payment or a reversal of a payment?
93 * Transaction id supplied by external processor. This may not be unique.
100 * processor result code
104 public $trxn_result_code;
107 * pseudo FK to civicrm_option_value of contribution_status_id option_group
114 * Payment Processor for this financial transaction
118 public $payment_processor_id;
121 * FK to payment_instrument option group values
125 public $payment_instrument_id;
128 * FK to accept_creditcard option group values
132 public $card_type_id;
139 public $check_number;
142 * Last 4 digits of credit card
146 public $pan_truncation;
149 * Payment Processor external order reference
153 public $order_reference;
158 public function __construct() {
159 $this->__table
= 'civicrm_financial_trxn';
160 parent
::__construct();
164 * Returns localized title of this entity.
166 public static function getEntityTitle() {
167 return ts('Financial Trxns');
171 * Returns foreign keys and entity references.
174 * [CRM_Core_Reference_Interface]
176 public static function getReferenceColumns() {
177 if (!isset(Civi
::$statics[__CLASS__
]['links'])) {
178 Civi
::$statics[__CLASS__
]['links'] = static::createReferenceColumns(__CLASS__
);
179 Civi
::$statics[__CLASS__
]['links'][] = new CRM_Core_Reference_Basic(self
::getTableName(), 'from_financial_account_id', 'civicrm_financial_account', 'id');
180 Civi
::$statics[__CLASS__
]['links'][] = new CRM_Core_Reference_Basic(self
::getTableName(), 'to_financial_account_id', 'civicrm_financial_account', 'id');
181 Civi
::$statics[__CLASS__
]['links'][] = new CRM_Core_Reference_Basic(self
::getTableName(), 'payment_processor_id', 'civicrm_payment_processor', 'id');
182 CRM_Core_DAO_AllCoreTables
::invoke(__CLASS__
, 'links_callback', Civi
::$statics[__CLASS__
]['links']);
184 return Civi
::$statics[__CLASS__
]['links'];
188 * Returns all the column names of this table
192 public static function &fields() {
193 if (!isset(Civi
::$statics[__CLASS__
]['fields'])) {
194 Civi
::$statics[__CLASS__
]['fields'] = [
197 'type' => CRM_Utils_Type
::T_INT
,
198 'title' => ts('Financial Transaction ID'),
200 'where' => 'civicrm_financial_trxn.id',
201 'table_name' => 'civicrm_financial_trxn',
202 'entity' => 'FinancialTrxn',
203 'bao' => 'CRM_Financial_DAO_FinancialTrxn',
206 'from_financial_account_id' => [
207 'name' => 'from_financial_account_id',
208 'type' => CRM_Utils_Type
::T_INT
,
209 'title' => ts('Financial Transaction From Account'),
210 'description' => ts('FK to financial_account table.'),
211 'where' => 'civicrm_financial_trxn.from_financial_account_id',
212 'table_name' => 'civicrm_financial_trxn',
213 'entity' => 'FinancialTrxn',
214 'bao' => 'CRM_Financial_DAO_FinancialTrxn',
216 'FKClassName' => 'CRM_Financial_DAO_FinancialAccount',
220 'pseudoconstant' => [
221 'table' => 'civicrm_financial_account',
223 'labelColumn' => 'name',
226 'to_financial_account_id' => [
227 'name' => 'to_financial_account_id',
228 'type' => CRM_Utils_Type
::T_INT
,
229 'title' => ts('Financial Transaction To Account'),
230 'description' => ts('FK to financial_financial_account table.'),
231 'where' => 'civicrm_financial_trxn.to_financial_account_id',
232 'table_name' => 'civicrm_financial_trxn',
233 'entity' => 'FinancialTrxn',
234 'bao' => 'CRM_Financial_DAO_FinancialTrxn',
236 'FKClassName' => 'CRM_Financial_DAO_FinancialAccount',
240 'pseudoconstant' => [
241 'table' => 'civicrm_financial_account',
243 'labelColumn' => 'name',
247 'name' => 'trxn_date',
248 'type' => CRM_Utils_Type
::T_DATE + CRM_Utils_Type
::T_TIME
,
249 'title' => ts('Financial Transaction Date'),
250 'description' => ts('date transaction occurred'),
251 'where' => 'civicrm_financial_trxn.trxn_date',
253 'table_name' => 'civicrm_financial_trxn',
254 'entity' => 'FinancialTrxn',
255 'bao' => 'CRM_Financial_DAO_FinancialTrxn',
258 'type' => 'Select Date',
259 'formatType' => 'activityDateTime',
263 'name' => 'total_amount',
264 'type' => CRM_Utils_Type
::T_MONEY
,
265 'title' => ts('Financial Total Amount'),
266 'description' => ts('amount of transaction'),
272 'where' => 'civicrm_financial_trxn.total_amount',
273 'table_name' => 'civicrm_financial_trxn',
274 'entity' => 'FinancialTrxn',
275 'bao' => 'CRM_Financial_DAO_FinancialTrxn',
279 'name' => 'fee_amount',
280 'type' => CRM_Utils_Type
::T_MONEY
,
281 'title' => ts('Financial Fee Amount'),
282 'description' => ts('actual processor fee if known - may be 0.'),
287 'where' => 'civicrm_financial_trxn.fee_amount',
288 'table_name' => 'civicrm_financial_trxn',
289 'entity' => 'FinancialTrxn',
290 'bao' => 'CRM_Financial_DAO_FinancialTrxn',
294 'name' => 'net_amount',
295 'type' => CRM_Utils_Type
::T_MONEY
,
296 'title' => ts('Financial Net Amount'),
297 'description' => ts('actual funds transfer amount. total less fees. if processor does not report actual fee during transaction, this is set to total_amount.'),
302 'where' => 'civicrm_financial_trxn.net_amount',
303 'table_name' => 'civicrm_financial_trxn',
304 'entity' => 'FinancialTrxn',
305 'bao' => 'CRM_Financial_DAO_FinancialTrxn',
309 'name' => 'currency',
310 'type' => CRM_Utils_Type
::T_STRING
,
311 'title' => ts('Financial Currency'),
312 'description' => ts('3 character string, value from config setting or input via user.'),
314 'size' => CRM_Utils_Type
::FOUR
,
316 'where' => 'civicrm_financial_trxn.currency',
317 'headerPattern' => '/cur(rency)?/i',
318 'dataPattern' => '/^[A-Z]{3}$/',
321 'table_name' => 'civicrm_financial_trxn',
322 'entity' => 'FinancialTrxn',
323 'bao' => 'CRM_Financial_DAO_FinancialTrxn',
328 'pseudoconstant' => [
329 'table' => 'civicrm_currency',
330 'keyColumn' => 'name',
331 'labelColumn' => 'full_name',
332 'nameColumn' => 'name',
333 'abbrColumn' => 'symbol',
337 'name' => 'is_payment',
338 'type' => CRM_Utils_Type
::T_BOOLEAN
,
339 'title' => ts('Is Payment?'),
340 'description' => ts('Is this entry either a payment or a reversal of a payment?'),
342 'where' => 'civicrm_financial_trxn.is_payment',
345 'table_name' => 'civicrm_financial_trxn',
346 'entity' => 'FinancialTrxn',
347 'bao' => 'CRM_Financial_DAO_FinancialTrxn',
352 'type' => CRM_Utils_Type
::T_STRING
,
353 'title' => ts('Transaction ID'),
354 'description' => ts('Transaction id supplied by external processor. This may not be unique.'),
357 'where' => 'civicrm_financial_trxn.trxn_id',
358 'table_name' => 'civicrm_financial_trxn',
359 'entity' => 'FinancialTrxn',
360 'bao' => 'CRM_Financial_DAO_FinancialTrxn',
366 'trxn_result_code' => [
367 'name' => 'trxn_result_code',
368 'type' => CRM_Utils_Type
::T_STRING
,
369 'title' => ts('Transaction Result Code'),
370 'description' => ts('processor result code'),
372 'size' => CRM_Utils_Type
::HUGE
,
373 'where' => 'civicrm_financial_trxn.trxn_result_code',
374 'table_name' => 'civicrm_financial_trxn',
375 'entity' => 'FinancialTrxn',
376 'bao' => 'CRM_Financial_DAO_FinancialTrxn',
380 'name' => 'status_id',
381 'type' => CRM_Utils_Type
::T_INT
,
382 'title' => ts('Financial Transaction Status Id'),
383 'description' => ts('pseudo FK to civicrm_option_value of contribution_status_id option_group'),
385 'where' => 'civicrm_financial_trxn.status_id',
386 'headerPattern' => '/status/i',
388 'table_name' => 'civicrm_financial_trxn',
389 'entity' => 'FinancialTrxn',
390 'bao' => 'CRM_Financial_DAO_FinancialTrxn',
392 'pseudoconstant' => [
393 'optionGroupName' => 'contribution_status',
394 'optionEditPath' => 'civicrm/admin/options/contribution_status',
397 'payment_processor_id' => [
398 'name' => 'payment_processor_id',
399 'type' => CRM_Utils_Type
::T_INT
,
400 'title' => ts('Payment Processor'),
401 'description' => ts('Payment Processor for this financial transaction'),
402 'where' => 'civicrm_financial_trxn.payment_processor_id',
403 'table_name' => 'civicrm_financial_trxn',
404 'entity' => 'FinancialTrxn',
405 'bao' => 'CRM_Financial_DAO_FinancialTrxn',
407 'FKClassName' => 'CRM_Financial_DAO_PaymentProcessor',
409 'financial_trxn_payment_instrument_id' => [
410 'name' => 'payment_instrument_id',
411 'type' => CRM_Utils_Type
::T_INT
,
412 'title' => ts('Payment Method'),
413 'description' => ts('FK to payment_instrument option group values'),
414 'where' => 'civicrm_financial_trxn.payment_instrument_id',
415 'table_name' => 'civicrm_financial_trxn',
416 'entity' => 'FinancialTrxn',
417 'bao' => 'CRM_Financial_DAO_FinancialTrxn',
422 'pseudoconstant' => [
423 'optionGroupName' => 'payment_instrument',
424 'optionEditPath' => 'civicrm/admin/options/payment_instrument',
427 'financial_trxn_card_type_id' => [
428 'name' => 'card_type_id',
429 'type' => CRM_Utils_Type
::T_INT
,
430 'title' => ts('Card Type ID'),
431 'description' => ts('FK to accept_creditcard option group values'),
432 'where' => 'civicrm_financial_trxn.card_type_id',
433 'table_name' => 'civicrm_financial_trxn',
434 'entity' => 'FinancialTrxn',
435 'bao' => 'CRM_Financial_DAO_FinancialTrxn',
440 'pseudoconstant' => [
441 'optionGroupName' => 'accept_creditcard',
442 'optionEditPath' => 'civicrm/admin/options/accept_creditcard',
445 'financial_trxn_check_number' => [
446 'name' => 'check_number',
447 'type' => CRM_Utils_Type
::T_STRING
,
448 'title' => ts('Check Number'),
449 'description' => ts('Check number'),
452 'where' => 'civicrm_financial_trxn.check_number',
453 'table_name' => 'civicrm_financial_trxn',
454 'entity' => 'FinancialTrxn',
455 'bao' => 'CRM_Financial_DAO_FinancialTrxn',
461 'financial_trxn_pan_truncation' => [
462 'name' => 'pan_truncation',
463 'type' => CRM_Utils_Type
::T_STRING
,
464 'title' => ts('PAN Truncation'),
465 'description' => ts('Last 4 digits of credit card'),
468 'where' => 'civicrm_financial_trxn.pan_truncation',
469 'table_name' => 'civicrm_financial_trxn',
470 'entity' => 'FinancialTrxn',
471 'bao' => 'CRM_Financial_DAO_FinancialTrxn',
477 'financial_trxn_order_reference' => [
478 'name' => 'order_reference',
479 'type' => CRM_Utils_Type
::T_STRING
,
480 'title' => ts('Order Reference'),
481 'description' => ts('Payment Processor external order reference'),
484 'where' => 'civicrm_financial_trxn.order_reference',
485 'table_name' => 'civicrm_financial_trxn',
486 'entity' => 'FinancialTrxn',
487 'bao' => 'CRM_Financial_DAO_FinancialTrxn',
494 CRM_Core_DAO_AllCoreTables
::invoke(__CLASS__
, 'fields_callback', Civi
::$statics[__CLASS__
]['fields']);
496 return Civi
::$statics[__CLASS__
]['fields'];
500 * Return a mapping from field-name to the corresponding key (as used in fields()).
503 * Array(string $name => string $uniqueName).
505 public static function &fieldKeys() {
506 if (!isset(Civi
::$statics[__CLASS__
]['fieldKeys'])) {
507 Civi
::$statics[__CLASS__
]['fieldKeys'] = array_flip(CRM_Utils_Array
::collect('name', self
::fields()));
509 return Civi
::$statics[__CLASS__
]['fieldKeys'];
513 * Returns the names of this table
517 public static function getTableName() {
518 return self
::$_tableName;
522 * Returns if this table needs to be logged
526 public function getLog() {
531 * Returns the list of fields that can be imported
533 * @param bool $prefix
537 public static function &import($prefix = FALSE) {
538 $r = CRM_Core_DAO_AllCoreTables
::getImports(__CLASS__
, 'financial_trxn', $prefix, []);
543 * Returns the list of fields that can be exported
545 * @param bool $prefix
549 public static function &export($prefix = FALSE) {
550 $r = CRM_Core_DAO_AllCoreTables
::getExports(__CLASS__
, 'financial_trxn', $prefix, []);
555 * Returns the list of indices
557 * @param bool $localize
561 public static function indices($localize = TRUE) {
563 'UI_ftrxn_trxn_id' => [
564 'name' => 'UI_ftrxn_trxn_id',
568 'localizable' => FALSE,
569 'sig' => 'civicrm_financial_trxn::0::trxn_id',
571 'UI_ftrxn_payment_instrument_id' => [
572 'name' => 'UI_ftrxn_payment_instrument_id',
574 0 => 'payment_instrument_id',
576 'localizable' => FALSE,
577 'sig' => 'civicrm_financial_trxn::0::payment_instrument_id',
579 'UI_ftrxn_check_number' => [
580 'name' => 'UI_ftrxn_check_number',
584 'localizable' => FALSE,
585 'sig' => 'civicrm_financial_trxn::0::check_number',
588 return ($localize && !empty($indices)) ? CRM_Core_DAO_AllCoreTables
::multilingualize(__CLASS__
, $indices) : $indices;