5 * @copyright CiviCRM LLC (c) 2004-2018
7 * Generated from xml/schema/CRM/Financial/FinancialTrxn.xml
8 * DO NOT EDIT. Generated by CRM_Core_CodeGen
9 * (GenCodeChecksum:21185c4929ef1a8d126c72733cc7ad1d)
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 static $_tableName = 'civicrm_financial_trxn';
25 * Should CiviCRM log any modifications to this table in the civicrm_log table.
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;
151 public function __construct() {
152 $this->__table
= 'civicrm_financial_trxn';
153 parent
::__construct();
157 * Returns foreign keys and entity references.
160 * [CRM_Core_Reference_Interface]
162 public static function getReferenceColumns() {
163 if (!isset(Civi
::$statics[__CLASS__
]['links'])) {
164 Civi
::$statics[__CLASS__
]['links'] = static ::createReferenceColumns(__CLASS__
);
165 Civi
::$statics[__CLASS__
]['links'][] = new CRM_Core_Reference_Basic(self
::getTableName(), 'from_financial_account_id', 'civicrm_financial_account', 'id');
166 Civi
::$statics[__CLASS__
]['links'][] = new CRM_Core_Reference_Basic(self
::getTableName(), 'to_financial_account_id', 'civicrm_financial_account', 'id');
167 Civi
::$statics[__CLASS__
]['links'][] = new CRM_Core_Reference_Basic(self
::getTableName(), 'payment_processor_id', 'civicrm_payment_processor', 'id');
168 CRM_Core_DAO_AllCoreTables
::invoke(__CLASS__
, 'links_callback', Civi
::$statics[__CLASS__
]['links']);
170 return Civi
::$statics[__CLASS__
]['links'];
174 * Returns all the column names of this table
178 public static function &fields() {
179 if (!isset(Civi
::$statics[__CLASS__
]['fields'])) {
180 Civi
::$statics[__CLASS__
]['fields'] = [
183 'type' => CRM_Utils_Type
::T_INT
,
184 'title' => ts('Financial Transaction ID'),
186 'table_name' => 'civicrm_financial_trxn',
187 'entity' => 'FinancialTrxn',
188 'bao' => 'CRM_Financial_DAO_FinancialTrxn',
191 'from_financial_account_id' => [
192 'name' => 'from_financial_account_id',
193 'type' => CRM_Utils_Type
::T_INT
,
194 'title' => ts('Financial Transaction From Account'),
195 'description' => 'FK to financial_account table.',
196 'table_name' => 'civicrm_financial_trxn',
197 'entity' => 'FinancialTrxn',
198 'bao' => 'CRM_Financial_DAO_FinancialTrxn',
200 'FKClassName' => 'CRM_Financial_DAO_FinancialAccount',
204 'pseudoconstant' => [
205 'table' => 'civicrm_financial_account',
207 'labelColumn' => 'name',
210 'to_financial_account_id' => [
211 'name' => 'to_financial_account_id',
212 'type' => CRM_Utils_Type
::T_INT
,
213 'title' => ts('Financial Transaction To Account'),
214 'description' => 'FK to financial_financial_account table.',
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 'name' => 'trxn_date',
231 'type' => CRM_Utils_Type
::T_DATE + CRM_Utils_Type
::T_TIME
,
232 'title' => ts('Financial Transaction Date'),
233 'description' => 'date transaction occurred',
235 'table_name' => 'civicrm_financial_trxn',
236 'entity' => 'FinancialTrxn',
237 'bao' => 'CRM_Financial_DAO_FinancialTrxn',
240 'type' => 'Select Date',
241 'formatType' => 'activityDateTime',
245 'name' => 'total_amount',
246 'type' => CRM_Utils_Type
::T_MONEY
,
247 'title' => ts('Financial Total Amount'),
248 'description' => 'amount of transaction',
254 'table_name' => 'civicrm_financial_trxn',
255 'entity' => 'FinancialTrxn',
256 'bao' => 'CRM_Financial_DAO_FinancialTrxn',
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.',
268 'table_name' => 'civicrm_financial_trxn',
269 'entity' => 'FinancialTrxn',
270 'bao' => 'CRM_Financial_DAO_FinancialTrxn',
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.',
282 'table_name' => 'civicrm_financial_trxn',
283 'entity' => 'FinancialTrxn',
284 'bao' => 'CRM_Financial_DAO_FinancialTrxn',
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.',
293 'size' => CRM_Utils_Type
::FOUR
,
295 'where' => 'civicrm_financial_trxn.currency',
296 'headerPattern' => '/cur(rency)?/i',
297 'dataPattern' => '/^[A-Z]{3}$/',
300 'table_name' => 'civicrm_financial_trxn',
301 'entity' => 'FinancialTrxn',
302 'bao' => 'CRM_Financial_DAO_FinancialTrxn',
307 'pseudoconstant' => [
308 'table' => 'civicrm_currency',
309 'keyColumn' => 'name',
310 'labelColumn' => 'full_name',
311 'nameColumn' => 'name',
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?',
320 'where' => 'civicrm_financial_trxn.is_payment',
321 'headerPattern' => '',
325 'table_name' => 'civicrm_financial_trxn',
326 'entity' => 'FinancialTrxn',
327 'bao' => 'CRM_Financial_DAO_FinancialTrxn',
332 'type' => CRM_Utils_Type
::T_STRING
,
333 'title' => ts('Transaction ID'),
334 'description' => 'Transaction id supplied by external processor. This may not be unique.',
337 'table_name' => 'civicrm_financial_trxn',
338 'entity' => 'FinancialTrxn',
339 'bao' => 'CRM_Financial_DAO_FinancialTrxn',
345 'trxn_result_code' => [
346 'name' => 'trxn_result_code',
347 'type' => CRM_Utils_Type
::T_STRING
,
348 'title' => ts('Transaction Result Code'),
349 'description' => 'processor result code',
351 'size' => CRM_Utils_Type
::HUGE
,
352 'table_name' => 'civicrm_financial_trxn',
353 'entity' => 'FinancialTrxn',
354 'bao' => 'CRM_Financial_DAO_FinancialTrxn',
358 'name' => 'status_id',
359 'type' => CRM_Utils_Type
::T_INT
,
360 'title' => ts('Financial Transaction Status Id'),
361 'description' => 'pseudo FK to civicrm_option_value of contribution_status_id option_group',
363 'where' => 'civicrm_financial_trxn.status_id',
364 'headerPattern' => '/status/i',
367 'table_name' => 'civicrm_financial_trxn',
368 'entity' => 'FinancialTrxn',
369 'bao' => 'CRM_Financial_DAO_FinancialTrxn',
371 'pseudoconstant' => [
372 'optionGroupName' => 'contribution_status',
373 'optionEditPath' => 'civicrm/admin/options/contribution_status',
376 'payment_processor_id' => [
377 'name' => 'payment_processor_id',
378 'type' => CRM_Utils_Type
::T_INT
,
379 'title' => ts('Payment Processor'),
380 'description' => 'Payment Processor for this financial transaction',
381 'table_name' => 'civicrm_financial_trxn',
382 'entity' => 'FinancialTrxn',
383 'bao' => 'CRM_Financial_DAO_FinancialTrxn',
385 'FKClassName' => 'CRM_Financial_DAO_PaymentProcessor',
387 'financial_trxn_payment_instrument_id' => [
388 'name' => 'payment_instrument_id',
389 'type' => CRM_Utils_Type
::T_INT
,
390 'title' => ts('Payment Method'),
391 'description' => 'FK to payment_instrument option group values',
392 'table_name' => 'civicrm_financial_trxn',
393 'entity' => 'FinancialTrxn',
394 'bao' => 'CRM_Financial_DAO_FinancialTrxn',
399 'pseudoconstant' => [
400 'optionGroupName' => 'payment_instrument',
401 'optionEditPath' => 'civicrm/admin/options/payment_instrument',
404 'financial_trxn_card_type_id' => [
405 'name' => 'card_type_id',
406 'type' => CRM_Utils_Type
::T_INT
,
407 'title' => ts('Card Type ID'),
408 'description' => 'FK to accept_creditcard option group values',
409 'table_name' => 'civicrm_financial_trxn',
410 'entity' => 'FinancialTrxn',
411 'bao' => 'CRM_Financial_DAO_FinancialTrxn',
416 'pseudoconstant' => [
417 'optionGroupName' => 'accept_creditcard',
418 'optionEditPath' => 'civicrm/admin/options/accept_creditcard',
421 'financial_trxn_check_number' => [
422 'name' => 'check_number',
423 'type' => CRM_Utils_Type
::T_STRING
,
424 'title' => ts('Check Number'),
425 'description' => 'Check number',
428 'table_name' => 'civicrm_financial_trxn',
429 'entity' => 'FinancialTrxn',
430 'bao' => 'CRM_Financial_DAO_FinancialTrxn',
436 'financial_trxn_pan_truncation' => [
437 'name' => 'pan_truncation',
438 'type' => CRM_Utils_Type
::T_STRING
,
439 'title' => ts('Pan Truncation'),
440 'description' => 'Last 4 digits of credit card',
443 'table_name' => 'civicrm_financial_trxn',
444 'entity' => 'FinancialTrxn',
445 'bao' => 'CRM_Financial_DAO_FinancialTrxn',
452 CRM_Core_DAO_AllCoreTables
::invoke(__CLASS__
, 'fields_callback', Civi
::$statics[__CLASS__
]['fields']);
454 return Civi
::$statics[__CLASS__
]['fields'];
458 * Return a mapping from field-name to the corresponding key (as used in fields()).
461 * Array(string $name => string $uniqueName).
463 public static function &fieldKeys() {
464 if (!isset(Civi
::$statics[__CLASS__
]['fieldKeys'])) {
465 Civi
::$statics[__CLASS__
]['fieldKeys'] = array_flip(CRM_Utils_Array
::collect('name', self
::fields()));
467 return Civi
::$statics[__CLASS__
]['fieldKeys'];
471 * Returns the names of this table
475 public static function getTableName() {
476 return self
::$_tableName;
480 * Returns if this table needs to be logged
484 public function getLog() {
489 * Returns the list of fields that can be imported
491 * @param bool $prefix
495 public static function &import($prefix = FALSE) {
496 $r = CRM_Core_DAO_AllCoreTables
::getImports(__CLASS__
, 'financial_trxn', $prefix, []);
501 * Returns the list of fields that can be exported
503 * @param bool $prefix
507 public static function &export($prefix = FALSE) {
508 $r = CRM_Core_DAO_AllCoreTables
::getExports(__CLASS__
, 'financial_trxn', $prefix, []);
513 * Returns the list of indices
515 * @param bool $localize
519 public static function indices($localize = TRUE) {
521 'UI_ftrxn_trxn_id' => [
522 'name' => 'UI_ftrxn_trxn_id',
526 'localizable' => FALSE,
527 'sig' => 'civicrm_financial_trxn::0::trxn_id',
529 'UI_ftrxn_payment_instrument_id' => [
530 'name' => 'UI_ftrxn_payment_instrument_id',
532 0 => 'payment_instrument_id',
534 'localizable' => FALSE,
535 'sig' => 'civicrm_financial_trxn::0::payment_instrument_id',
537 'UI_ftrxn_check_number' => [
538 'name' => 'UI_ftrxn_check_number',
542 'localizable' => FALSE,
543 'sig' => 'civicrm_financial_trxn::0::check_number',
546 return ($localize && !empty($indices)) ? CRM_Core_DAO_AllCoreTables
::multilingualize(__CLASS__
, $indices) : $indices;