Merge pull request #11868 from eileenmcnaughton/cust_url
[civicrm-core.git] / CRM / Contribute / DAO / Contribution.php
1 <?php
2
3 /**
4 * @package CRM
5 * @copyright CiviCRM LLC (c) 2004-2018
6 *
7 * Generated from xml/schema/CRM/Contribute/Contribution.xml
8 * DO NOT EDIT. Generated by CRM_Core_CodeGen
9 * (GenCodeChecksum:45a20d00d01766a61687cbac5cef1482)
10 */
11
12 /**
13 * Database access object for the Contribution entity.
14 */
15 class CRM_Contribute_DAO_Contribution extends CRM_Core_DAO {
16
17 /**
18 * Static instance to hold the table name.
19 *
20 * @var string
21 */
22 static $_tableName = 'civicrm_contribution';
23
24 /**
25 * Should CiviCRM log any modifications to this table in the civicrm_log table.
26 *
27 * @var bool
28 */
29 static $_log = TRUE;
30
31 /**
32 * Contribution ID
33 *
34 * @var int unsigned
35 */
36 public $id;
37
38 /**
39 * FK to Contact ID
40 *
41 * @var int unsigned
42 */
43 public $contact_id;
44
45 /**
46 * FK to Financial Type for (total_amount - non_deductible_amount).
47 *
48 * @var int unsigned
49 */
50 public $financial_type_id;
51
52 /**
53 * The Contribution Page which triggered this contribution
54 *
55 * @var int unsigned
56 */
57 public $contribution_page_id;
58
59 /**
60 * FK to Payment Instrument
61 *
62 * @var int unsigned
63 */
64 public $payment_instrument_id;
65
66 /**
67 * Date contribution was received - not necessarily the creation date of the record
68 *
69 * @var datetime
70 */
71 public $receive_date;
72
73 /**
74 * Portion of total amount which is NOT tax deductible. Equal to total_amount for non-deductible financial types.
75 *
76 * @var float
77 */
78 public $non_deductible_amount;
79
80 /**
81 * Total amount of this contribution. Use market value for non-monetary gifts.
82 *
83 * @var float
84 */
85 public $total_amount;
86
87 /**
88 * actual processor fee if known - may be 0.
89 *
90 * @var float
91 */
92 public $fee_amount;
93
94 /**
95 * actual funds transfer amount. total less fees. if processor does not report actual fee during transaction, this is set to total_amount.
96 *
97 * @var float
98 */
99 public $net_amount;
100
101 /**
102 * unique transaction id. may be processor id, bank id + trans id, or account number + check number... depending on payment_method
103 *
104 * @var string
105 */
106 public $trxn_id;
107
108 /**
109 * unique invoice id, system generated or passed in
110 *
111 * @var string
112 */
113 public $invoice_id;
114
115 /**
116 * Human readable invoice number
117 *
118 * @var string
119 */
120 public $invoice_number;
121
122 /**
123 * 3 character string, value from config setting or input via user.
124 *
125 * @var string
126 */
127 public $currency;
128
129 /**
130 * when was gift cancelled
131 *
132 * @var datetime
133 */
134 public $cancel_date;
135
136 /**
137 * @var text
138 */
139 public $cancel_reason;
140
141 /**
142 * when (if) receipt was sent. populated automatically for online donations w/ automatic receipting
143 *
144 * @var datetime
145 */
146 public $receipt_date;
147
148 /**
149 * when (if) was donor thanked
150 *
151 * @var datetime
152 */
153 public $thankyou_date;
154
155 /**
156 * Origin of this Contribution.
157 *
158 * @var string
159 */
160 public $source;
161
162 /**
163 * @var text
164 */
165 public $amount_level;
166
167 /**
168 * Conditional foreign key to civicrm_contribution_recur id. Each contribution made in connection with a recurring contribution carries a foreign key to the recurring contribution record. This assumes we can track these processor initiated events.
169 *
170 * @var int unsigned
171 */
172 public $contribution_recur_id;
173
174 /**
175 * @var boolean
176 */
177 public $is_test;
178
179 /**
180 * @var boolean
181 */
182 public $is_pay_later;
183
184 /**
185 * @var int unsigned
186 */
187 public $contribution_status_id;
188
189 /**
190 * Conditional foreign key to civicrm_address.id. We insert an address record for each contribution when we have associated billing name and address data.
191 *
192 * @var int unsigned
193 */
194 public $address_id;
195
196 /**
197 * @var string
198 */
199 public $check_number;
200
201 /**
202 * The campaign for which this contribution has been triggered.
203 *
204 * @var int unsigned
205 */
206 public $campaign_id;
207
208 /**
209 * unique credit note id, system generated or passed in
210 *
211 * @var string
212 */
213 public $creditnote_id;
214
215 /**
216 * Total tax amount of this contribution.
217 *
218 * @var float
219 */
220 public $tax_amount;
221
222 /**
223 * Stores the date when revenue should be recognized.
224 *
225 * @var datetime
226 */
227 public $revenue_recognition_date;
228
229 /**
230 * Class constructor.
231 */
232 public function __construct() {
233 $this->__table = 'civicrm_contribution';
234 parent::__construct();
235 }
236
237 /**
238 * Returns foreign keys and entity references.
239 *
240 * @return array
241 * [CRM_Core_Reference_Interface]
242 */
243 public static function getReferenceColumns() {
244 if (!isset(Civi::$statics[__CLASS__]['links'])) {
245 Civi::$statics[__CLASS__]['links'] = static ::createReferenceColumns(__CLASS__);
246 Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName(), 'contact_id', 'civicrm_contact', 'id');
247 Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName(), 'financial_type_id', 'civicrm_financial_type', 'id');
248 Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName(), 'contribution_page_id', 'civicrm_contribution_page', 'id');
249 Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName(), 'contribution_recur_id', 'civicrm_contribution_recur', 'id');
250 Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName(), 'address_id', 'civicrm_address', 'id');
251 Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName(), 'campaign_id', 'civicrm_campaign', 'id');
252 CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'links_callback', Civi::$statics[__CLASS__]['links']);
253 }
254 return Civi::$statics[__CLASS__]['links'];
255 }
256
257 /**
258 * Returns all the column names of this table
259 *
260 * @return array
261 */
262 public static function &fields() {
263 if (!isset(Civi::$statics[__CLASS__]['fields'])) {
264 Civi::$statics[__CLASS__]['fields'] = [
265 'contribution_id' => [
266 'name' => 'id',
267 'type' => CRM_Utils_Type::T_INT,
268 'title' => ts('Contribution ID'),
269 'description' => 'Contribution ID',
270 'required' => TRUE,
271 'import' => TRUE,
272 'where' => 'civicrm_contribution.id',
273 'headerPattern' => '',
274 'dataPattern' => '',
275 'export' => TRUE,
276 'table_name' => 'civicrm_contribution',
277 'entity' => 'Contribution',
278 'bao' => 'CRM_Contribute_BAO_Contribution',
279 'localizable' => 0,
280 ],
281 'contribution_contact_id' => [
282 'name' => 'contact_id',
283 'type' => CRM_Utils_Type::T_INT,
284 'title' => ts('Contact ID'),
285 'description' => 'FK to Contact ID',
286 'required' => TRUE,
287 'import' => TRUE,
288 'where' => 'civicrm_contribution.contact_id',
289 'headerPattern' => '/contact(.?id)?/i',
290 'dataPattern' => '/^\d+$/',
291 'export' => TRUE,
292 'table_name' => 'civicrm_contribution',
293 'entity' => 'Contribution',
294 'bao' => 'CRM_Contribute_BAO_Contribution',
295 'localizable' => 0,
296 'FKClassName' => 'CRM_Contact_DAO_Contact',
297 'html' => [
298 'type' => 'EntityRef',
299 ],
300 ],
301 'financial_type_id' => [
302 'name' => 'financial_type_id',
303 'type' => CRM_Utils_Type::T_INT,
304 'title' => ts('Financial Type'),
305 'description' => 'FK to Financial Type for (total_amount - non_deductible_amount).',
306 'export' => TRUE,
307 'where' => 'civicrm_contribution.financial_type_id',
308 'headerPattern' => '',
309 'dataPattern' => '',
310 'table_name' => 'civicrm_contribution',
311 'entity' => 'Contribution',
312 'bao' => 'CRM_Contribute_BAO_Contribution',
313 'localizable' => 0,
314 'FKClassName' => 'CRM_Financial_DAO_FinancialType',
315 'html' => [
316 'type' => 'Select',
317 ],
318 'pseudoconstant' => [
319 'table' => 'civicrm_financial_type',
320 'keyColumn' => 'id',
321 'labelColumn' => 'name',
322 ]
323 ],
324 'contribution_page_id' => [
325 'name' => 'contribution_page_id',
326 'type' => CRM_Utils_Type::T_INT,
327 'title' => ts('Contribution Page ID'),
328 'description' => 'The Contribution Page which triggered this contribution',
329 'import' => TRUE,
330 'where' => 'civicrm_contribution.contribution_page_id',
331 'headerPattern' => '',
332 'dataPattern' => '',
333 'export' => TRUE,
334 'table_name' => 'civicrm_contribution',
335 'entity' => 'Contribution',
336 'bao' => 'CRM_Contribute_BAO_Contribution',
337 'localizable' => 0,
338 'FKClassName' => 'CRM_Contribute_DAO_ContributionPage',
339 'html' => [
340 'type' => 'Select',
341 ],
342 'pseudoconstant' => [
343 'table' => 'civicrm_contribution_page',
344 'keyColumn' => 'id',
345 'labelColumn' => 'title',
346 ]
347 ],
348 'payment_instrument_id' => [
349 'name' => 'payment_instrument_id',
350 'type' => CRM_Utils_Type::T_INT,
351 'title' => ts('Payment Method ID'),
352 'description' => 'FK to Payment Instrument',
353 'export' => TRUE,
354 'where' => 'civicrm_contribution.payment_instrument_id',
355 'headerPattern' => '/^payment|(p(ayment\s)?instrument)$/i',
356 'dataPattern' => '',
357 'table_name' => 'civicrm_contribution',
358 'entity' => 'Contribution',
359 'bao' => 'CRM_Contribute_BAO_Contribution',
360 'localizable' => 0,
361 'html' => [
362 'type' => 'Select',
363 ],
364 'pseudoconstant' => [
365 'optionGroupName' => 'payment_instrument',
366 'optionEditPath' => 'civicrm/admin/options/payment_instrument',
367 ]
368 ],
369 'receive_date' => [
370 'name' => 'receive_date',
371 'type' => CRM_Utils_Type::T_DATE + CRM_Utils_Type::T_TIME,
372 'title' => ts('Date Received'),
373 'description' => 'Date contribution was received - not necessarily the creation date of the record',
374 'import' => TRUE,
375 'where' => 'civicrm_contribution.receive_date',
376 'headerPattern' => '/receive(.?date)?/i',
377 'dataPattern' => '/^\d{4}-?\d{2}-?\d{2} ?(\d{2}:?\d{2}:?(\d{2})?)?$/',
378 'export' => TRUE,
379 'table_name' => 'civicrm_contribution',
380 'entity' => 'Contribution',
381 'bao' => 'CRM_Contribute_BAO_Contribution',
382 'localizable' => 0,
383 'html' => [
384 'type' => 'Select Date',
385 'formatType' => 'activityDateTime',
386 ],
387 ],
388 'non_deductible_amount' => [
389 'name' => 'non_deductible_amount',
390 'type' => CRM_Utils_Type::T_MONEY,
391 'title' => ts('Non-deductible Amount'),
392 'description' => 'Portion of total amount which is NOT tax deductible. Equal to total_amount for non-deductible financial types.',
393 'precision' => [
394 20,
395 2
396 ],
397 'import' => TRUE,
398 'where' => 'civicrm_contribution.non_deductible_amount',
399 'headerPattern' => '/non?.?deduct/i',
400 'dataPattern' => '/^\d+(\.\d{2})?$/',
401 'export' => TRUE,
402 'table_name' => 'civicrm_contribution',
403 'entity' => 'Contribution',
404 'bao' => 'CRM_Contribute_BAO_Contribution',
405 'localizable' => 0,
406 'html' => [
407 'type' => 'Text',
408 ],
409 ],
410 'total_amount' => [
411 'name' => 'total_amount',
412 'type' => CRM_Utils_Type::T_MONEY,
413 'title' => ts('Total Amount'),
414 'description' => 'Total amount of this contribution. Use market value for non-monetary gifts.',
415 'required' => TRUE,
416 'precision' => [
417 20,
418 2
419 ],
420 'import' => TRUE,
421 'where' => 'civicrm_contribution.total_amount',
422 'headerPattern' => '/^total|(.?^am(ou)?nt)/i',
423 'dataPattern' => '/^\d+(\.\d{2})?$/',
424 'export' => TRUE,
425 'table_name' => 'civicrm_contribution',
426 'entity' => 'Contribution',
427 'bao' => 'CRM_Contribute_BAO_Contribution',
428 'localizable' => 0,
429 'html' => [
430 'type' => 'Text',
431 ],
432 ],
433 'fee_amount' => [
434 'name' => 'fee_amount',
435 'type' => CRM_Utils_Type::T_MONEY,
436 'title' => ts('Fee Amount'),
437 'description' => 'actual processor fee if known - may be 0.',
438 'precision' => [
439 20,
440 2
441 ],
442 'import' => TRUE,
443 'where' => 'civicrm_contribution.fee_amount',
444 'headerPattern' => '/fee(.?am(ou)?nt)?/i',
445 'dataPattern' => '/^\d+(\.\d{2})?$/',
446 'export' => TRUE,
447 'table_name' => 'civicrm_contribution',
448 'entity' => 'Contribution',
449 'bao' => 'CRM_Contribute_BAO_Contribution',
450 'localizable' => 0,
451 'html' => [
452 'type' => 'Text',
453 ],
454 ],
455 'net_amount' => [
456 'name' => 'net_amount',
457 'type' => CRM_Utils_Type::T_MONEY,
458 'title' => ts('Net Amount'),
459 'description' => 'actual funds transfer amount. total less fees. if processor does not report actual fee during transaction, this is set to total_amount.',
460 'precision' => [
461 20,
462 2
463 ],
464 'import' => TRUE,
465 'where' => 'civicrm_contribution.net_amount',
466 'headerPattern' => '/net(.?am(ou)?nt)?/i',
467 'dataPattern' => '/^\d+(\.\d{2})?$/',
468 'export' => TRUE,
469 'table_name' => 'civicrm_contribution',
470 'entity' => 'Contribution',
471 'bao' => 'CRM_Contribute_BAO_Contribution',
472 'localizable' => 0,
473 'html' => [
474 'type' => 'Text',
475 ],
476 ],
477 'trxn_id' => [
478 'name' => 'trxn_id',
479 'type' => CRM_Utils_Type::T_STRING,
480 'title' => ts('Transaction ID'),
481 'description' => 'unique transaction id. may be processor id, bank id + trans id, or account number + check number... depending on payment_method',
482 'maxlength' => 255,
483 'size' => CRM_Utils_Type::HUGE,
484 'import' => TRUE,
485 'where' => 'civicrm_contribution.trxn_id',
486 'headerPattern' => '/tr(ansactio|x)n(.?id)?/i',
487 'dataPattern' => '',
488 'export' => TRUE,
489 'table_name' => 'civicrm_contribution',
490 'entity' => 'Contribution',
491 'bao' => 'CRM_Contribute_BAO_Contribution',
492 'localizable' => 0,
493 'html' => [
494 'type' => 'Text',
495 ],
496 ],
497 'invoice_id' => [
498 'name' => 'invoice_id',
499 'type' => CRM_Utils_Type::T_STRING,
500 'title' => ts('Invoice Reference'),
501 'description' => 'unique invoice id, system generated or passed in',
502 'maxlength' => 255,
503 'size' => CRM_Utils_Type::HUGE,
504 'import' => TRUE,
505 'where' => 'civicrm_contribution.invoice_id',
506 'headerPattern' => '/invoice(.?id)?/i',
507 'dataPattern' => '',
508 'export' => TRUE,
509 'table_name' => 'civicrm_contribution',
510 'entity' => 'Contribution',
511 'bao' => 'CRM_Contribute_BAO_Contribution',
512 'localizable' => 0,
513 'html' => [
514 'type' => 'Text',
515 ],
516 ],
517 'invoice_number' => [
518 'name' => 'invoice_number',
519 'type' => CRM_Utils_Type::T_STRING,
520 'title' => ts('Invoice Number'),
521 'description' => 'Human readable invoice number',
522 'maxlength' => 255,
523 'size' => CRM_Utils_Type::HUGE,
524 'import' => TRUE,
525 'where' => 'civicrm_contribution.invoice_number',
526 'headerPattern' => '/invoice(.?number)?/i',
527 'dataPattern' => '',
528 'export' => TRUE,
529 'table_name' => 'civicrm_contribution',
530 'entity' => 'Contribution',
531 'bao' => 'CRM_Contribute_BAO_Contribution',
532 'localizable' => 0,
533 'html' => [
534 'type' => 'Text',
535 ],
536 ],
537 'currency' => [
538 'name' => 'currency',
539 'type' => CRM_Utils_Type::T_STRING,
540 'title' => ts('Currency'),
541 'description' => '3 character string, value from config setting or input via user.',
542 'maxlength' => 3,
543 'size' => CRM_Utils_Type::FOUR,
544 'import' => TRUE,
545 'where' => 'civicrm_contribution.currency',
546 'headerPattern' => '/cur(rency)?/i',
547 'dataPattern' => '/^[A-Z]{3}$/i',
548 'export' => TRUE,
549 'default' => 'NULL',
550 'table_name' => 'civicrm_contribution',
551 'entity' => 'Contribution',
552 'bao' => 'CRM_Contribute_BAO_Contribution',
553 'localizable' => 0,
554 'html' => [
555 'type' => 'Select',
556 ],
557 'pseudoconstant' => [
558 'table' => 'civicrm_currency',
559 'keyColumn' => 'name',
560 'labelColumn' => 'full_name',
561 'nameColumn' => 'name',
562 ]
563 ],
564 'cancel_date' => [
565 'name' => 'cancel_date',
566 'type' => CRM_Utils_Type::T_DATE + CRM_Utils_Type::T_TIME,
567 'title' => ts('Cancel Date'),
568 'description' => 'when was gift cancelled',
569 'import' => TRUE,
570 'where' => 'civicrm_contribution.cancel_date',
571 'headerPattern' => '/cancel(.?date)?/i',
572 'dataPattern' => '/^\d{4}-?\d{2}-?\d{2} ?(\d{2}:?\d{2}:?(\d{2})?)?$/',
573 'export' => TRUE,
574 'table_name' => 'civicrm_contribution',
575 'entity' => 'Contribution',
576 'bao' => 'CRM_Contribute_BAO_Contribution',
577 'localizable' => 0,
578 'html' => [
579 'type' => 'Select Date',
580 'formatType' => 'activityDateTime',
581 ],
582 ],
583 'cancel_reason' => [
584 'name' => 'cancel_reason',
585 'type' => CRM_Utils_Type::T_TEXT,
586 'title' => ts('Cancel Reason'),
587 'import' => TRUE,
588 'where' => 'civicrm_contribution.cancel_reason',
589 'headerPattern' => '/(cancel.?)?reason/i',
590 'dataPattern' => '',
591 'export' => TRUE,
592 'table_name' => 'civicrm_contribution',
593 'entity' => 'Contribution',
594 'bao' => 'CRM_Contribute_BAO_Contribution',
595 'localizable' => 0,
596 'html' => [
597 'type' => 'Text',
598 ],
599 ],
600 'receipt_date' => [
601 'name' => 'receipt_date',
602 'type' => CRM_Utils_Type::T_DATE + CRM_Utils_Type::T_TIME,
603 'title' => ts('Receipt Date'),
604 'description' => 'when (if) receipt was sent. populated automatically for online donations w/ automatic receipting',
605 'import' => TRUE,
606 'where' => 'civicrm_contribution.receipt_date',
607 'headerPattern' => '/receipt(.?date)?/i',
608 'dataPattern' => '/^\d{4}-?\d{2}-?\d{2} ?(\d{2}:?\d{2}:?(\d{2})?)?$/',
609 'export' => TRUE,
610 'table_name' => 'civicrm_contribution',
611 'entity' => 'Contribution',
612 'bao' => 'CRM_Contribute_BAO_Contribution',
613 'localizable' => 0,
614 'html' => [
615 'type' => 'Select Date',
616 'formatType' => 'activityDateTime',
617 ],
618 ],
619 'thankyou_date' => [
620 'name' => 'thankyou_date',
621 'type' => CRM_Utils_Type::T_DATE + CRM_Utils_Type::T_TIME,
622 'title' => ts('Thank-you Date'),
623 'description' => 'when (if) was donor thanked',
624 'import' => TRUE,
625 'where' => 'civicrm_contribution.thankyou_date',
626 'headerPattern' => '/thank(s|(.?you))?(.?date)?/i',
627 'dataPattern' => '/^\d{4}-?\d{2}-?\d{2} ?(\d{2}:?\d{2}:?(\d{2})?)?$/',
628 'export' => TRUE,
629 'table_name' => 'civicrm_contribution',
630 'entity' => 'Contribution',
631 'bao' => 'CRM_Contribute_BAO_Contribution',
632 'localizable' => 0,
633 'html' => [
634 'type' => 'Select Date',
635 'formatType' => 'activityDateTime',
636 ],
637 ],
638 'contribution_source' => [
639 'name' => 'source',
640 'type' => CRM_Utils_Type::T_STRING,
641 'title' => ts('Contribution Source'),
642 'description' => 'Origin of this Contribution.',
643 'maxlength' => 255,
644 'size' => CRM_Utils_Type::HUGE,
645 'import' => TRUE,
646 'where' => 'civicrm_contribution.source',
647 'headerPattern' => '/source/i',
648 'dataPattern' => '',
649 'export' => TRUE,
650 'table_name' => 'civicrm_contribution',
651 'entity' => 'Contribution',
652 'bao' => 'CRM_Contribute_BAO_Contribution',
653 'localizable' => 0,
654 'html' => [
655 'type' => 'Text',
656 ],
657 ],
658 'amount_level' => [
659 'name' => 'amount_level',
660 'type' => CRM_Utils_Type::T_TEXT,
661 'title' => ts('Amount Label'),
662 'import' => TRUE,
663 'where' => 'civicrm_contribution.amount_level',
664 'headerPattern' => '',
665 'dataPattern' => '',
666 'export' => TRUE,
667 'table_name' => 'civicrm_contribution',
668 'entity' => 'Contribution',
669 'bao' => 'CRM_Contribute_BAO_Contribution',
670 'localizable' => 0,
671 'html' => [
672 'type' => 'Text',
673 ],
674 ],
675 'contribution_recur_id' => [
676 'name' => 'contribution_recur_id',
677 'type' => CRM_Utils_Type::T_INT,
678 'title' => ts('Recurring Contribution ID'),
679 'description' => 'Conditional foreign key to civicrm_contribution_recur id. Each contribution made in connection with a recurring contribution carries a foreign key to the recurring contribution record. This assumes we can track these processor initiated events.',
680 'export' => TRUE,
681 'where' => 'civicrm_contribution.contribution_recur_id',
682 'headerPattern' => '',
683 'dataPattern' => '',
684 'table_name' => 'civicrm_contribution',
685 'entity' => 'Contribution',
686 'bao' => 'CRM_Contribute_BAO_Contribution',
687 'localizable' => 0,
688 'FKClassName' => 'CRM_Contribute_DAO_ContributionRecur',
689 ],
690 'is_test' => [
691 'name' => 'is_test',
692 'type' => CRM_Utils_Type::T_BOOLEAN,
693 'title' => ts('Test'),
694 'import' => TRUE,
695 'where' => 'civicrm_contribution.is_test',
696 'headerPattern' => '',
697 'dataPattern' => '',
698 'export' => TRUE,
699 'table_name' => 'civicrm_contribution',
700 'entity' => 'Contribution',
701 'bao' => 'CRM_Contribute_BAO_Contribution',
702 'localizable' => 0,
703 'html' => [
704 'type' => 'CheckBox',
705 ],
706 ],
707 'is_pay_later' => [
708 'name' => 'is_pay_later',
709 'type' => CRM_Utils_Type::T_BOOLEAN,
710 'title' => ts('Is Pay Later'),
711 'import' => TRUE,
712 'where' => 'civicrm_contribution.is_pay_later',
713 'headerPattern' => '',
714 'dataPattern' => '',
715 'export' => TRUE,
716 'table_name' => 'civicrm_contribution',
717 'entity' => 'Contribution',
718 'bao' => 'CRM_Contribute_BAO_Contribution',
719 'localizable' => 0,
720 'html' => [
721 'type' => 'CheckBox',
722 ],
723 ],
724 'contribution_status_id' => [
725 'name' => 'contribution_status_id',
726 'type' => CRM_Utils_Type::T_INT,
727 'title' => ts('Contribution Status ID'),
728 'import' => TRUE,
729 'where' => 'civicrm_contribution.contribution_status_id',
730 'headerPattern' => '/status/i',
731 'dataPattern' => '',
732 'export' => TRUE,
733 'default' => '1',
734 'table_name' => 'civicrm_contribution',
735 'entity' => 'Contribution',
736 'bao' => 'CRM_Contribute_BAO_Contribution',
737 'localizable' => 0,
738 'html' => [
739 'type' => 'Select',
740 ],
741 'pseudoconstant' => [
742 'optionGroupName' => 'contribution_status',
743 'optionEditPath' => 'civicrm/admin/options/contribution_status',
744 ]
745 ],
746 'contribution_address_id' => [
747 'name' => 'address_id',
748 'type' => CRM_Utils_Type::T_INT,
749 'title' => ts('Contribution Address'),
750 'description' => 'Conditional foreign key to civicrm_address.id. We insert an address record for each contribution when we have associated billing name and address data.',
751 'export' => TRUE,
752 'where' => 'civicrm_contribution.address_id',
753 'headerPattern' => '',
754 'dataPattern' => '',
755 'table_name' => 'civicrm_contribution',
756 'entity' => 'Contribution',
757 'bao' => 'CRM_Contribute_BAO_Contribution',
758 'localizable' => 0,
759 'FKClassName' => 'CRM_Core_DAO_Address',
760 ],
761 'contribution_check_number' => [
762 'name' => 'check_number',
763 'type' => CRM_Utils_Type::T_STRING,
764 'title' => ts('Check Number'),
765 'maxlength' => 255,
766 'size' => 6,
767 'import' => TRUE,
768 'where' => 'civicrm_contribution.check_number',
769 'headerPattern' => '/check(.?number)?/i',
770 'dataPattern' => '',
771 'export' => TRUE,
772 'table_name' => 'civicrm_contribution',
773 'entity' => 'Contribution',
774 'bao' => 'CRM_Contribute_BAO_Contribution',
775 'localizable' => 0,
776 'html' => [
777 'type' => 'Text',
778 ],
779 ],
780 'contribution_campaign_id' => [
781 'name' => 'campaign_id',
782 'type' => CRM_Utils_Type::T_INT,
783 'title' => ts('Campaign'),
784 'description' => 'The campaign for which this contribution has been triggered.',
785 'import' => TRUE,
786 'where' => 'civicrm_contribution.campaign_id',
787 'headerPattern' => '',
788 'dataPattern' => '',
789 'export' => TRUE,
790 'table_name' => 'civicrm_contribution',
791 'entity' => 'Contribution',
792 'bao' => 'CRM_Contribute_BAO_Contribution',
793 'localizable' => 0,
794 'FKClassName' => 'CRM_Campaign_DAO_Campaign',
795 'html' => [
796 'type' => 'Select',
797 ],
798 'pseudoconstant' => [
799 'table' => 'civicrm_campaign',
800 'keyColumn' => 'id',
801 'labelColumn' => 'title',
802 ]
803 ],
804 'creditnote_id' => [
805 'name' => 'creditnote_id',
806 'type' => CRM_Utils_Type::T_STRING,
807 'title' => ts('Credit Note ID'),
808 'description' => 'unique credit note id, system generated or passed in',
809 'maxlength' => 255,
810 'size' => CRM_Utils_Type::HUGE,
811 'import' => TRUE,
812 'where' => 'civicrm_contribution.creditnote_id',
813 'headerPattern' => '/creditnote(.?id)?/i',
814 'dataPattern' => '',
815 'export' => TRUE,
816 'table_name' => 'civicrm_contribution',
817 'entity' => 'Contribution',
818 'bao' => 'CRM_Contribute_BAO_Contribution',
819 'localizable' => 0,
820 'html' => [
821 'type' => 'Text',
822 ],
823 ],
824 'tax_amount' => [
825 'name' => 'tax_amount',
826 'type' => CRM_Utils_Type::T_MONEY,
827 'title' => ts('Tax Amount'),
828 'description' => 'Total tax amount of this contribution.',
829 'precision' => [
830 20,
831 2
832 ],
833 'import' => TRUE,
834 'where' => 'civicrm_contribution.tax_amount',
835 'headerPattern' => '/tax(.?am(ou)?nt)?/i',
836 'dataPattern' => '/^\d+(\.\d{2})?$/',
837 'export' => TRUE,
838 'table_name' => 'civicrm_contribution',
839 'entity' => 'Contribution',
840 'bao' => 'CRM_Contribute_BAO_Contribution',
841 'localizable' => 0,
842 'html' => [
843 'type' => 'Text',
844 ],
845 ],
846 'revenue_recognition_date' => [
847 'name' => 'revenue_recognition_date',
848 'type' => CRM_Utils_Type::T_DATE + CRM_Utils_Type::T_TIME,
849 'title' => ts('Revenue Recognition Date'),
850 'description' => 'Stores the date when revenue should be recognized.',
851 'import' => TRUE,
852 'where' => 'civicrm_contribution.revenue_recognition_date',
853 'headerPattern' => '/revenue(.?date)?/i',
854 'dataPattern' => '/^\d{4}-?\d{2}-?\d{2} ?(\d{2}:?\d{2}:?(\d{2})?)?$/',
855 'export' => TRUE,
856 'table_name' => 'civicrm_contribution',
857 'entity' => 'Contribution',
858 'bao' => 'CRM_Contribute_BAO_Contribution',
859 'localizable' => 0,
860 'html' => [
861 'type' => 'Select Date',
862 'formatType' => 'activityDateTime',
863 ],
864 ],
865 ];
866 CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'fields_callback', Civi::$statics[__CLASS__]['fields']);
867 }
868 return Civi::$statics[__CLASS__]['fields'];
869 }
870
871 /**
872 * Return a mapping from field-name to the corresponding key (as used in fields()).
873 *
874 * @return array
875 * Array(string $name => string $uniqueName).
876 */
877 public static function &fieldKeys() {
878 if (!isset(Civi::$statics[__CLASS__]['fieldKeys'])) {
879 Civi::$statics[__CLASS__]['fieldKeys'] = array_flip(CRM_Utils_Array::collect('name', self::fields()));
880 }
881 return Civi::$statics[__CLASS__]['fieldKeys'];
882 }
883
884 /**
885 * Returns the names of this table
886 *
887 * @return string
888 */
889 public static function getTableName() {
890 return self::$_tableName;
891 }
892
893 /**
894 * Returns if this table needs to be logged
895 *
896 * @return bool
897 */
898 public function getLog() {
899 return self::$_log;
900 }
901
902 /**
903 * Returns the list of fields that can be imported
904 *
905 * @param bool $prefix
906 *
907 * @return array
908 */
909 public static function &import($prefix = FALSE) {
910 $r = CRM_Core_DAO_AllCoreTables::getImports(__CLASS__, 'contribution', $prefix, []);
911 return $r;
912 }
913
914 /**
915 * Returns the list of fields that can be exported
916 *
917 * @param bool $prefix
918 *
919 * @return array
920 */
921 public static function &export($prefix = FALSE) {
922 $r = CRM_Core_DAO_AllCoreTables::getExports(__CLASS__, 'contribution', $prefix, []);
923 return $r;
924 }
925
926 /**
927 * Returns the list of indices
928 *
929 * @param bool $localize
930 *
931 * @return array
932 */
933 public static function indices($localize = TRUE) {
934 $indices = [
935 'UI_contrib_payment_instrument_id' => [
936 'name' => 'UI_contrib_payment_instrument_id',
937 'field' => [
938 0 => 'payment_instrument_id',
939 ],
940 'localizable' => FALSE,
941 'sig' => 'civicrm_contribution::0::payment_instrument_id',
942 ],
943 'index_total_amount_receive_date' => [
944 'name' => 'index_total_amount_receive_date',
945 'field' => [
946 0 => 'total_amount',
947 1 => 'receive_date',
948 ],
949 'localizable' => FALSE,
950 'sig' => 'civicrm_contribution::0::total_amount::receive_date',
951 ],
952 'index_source' => [
953 'name' => 'index_source',
954 'field' => [
955 0 => 'source',
956 ],
957 'localizable' => FALSE,
958 'sig' => 'civicrm_contribution::0::source',
959 ],
960 'UI_contrib_trxn_id' => [
961 'name' => 'UI_contrib_trxn_id',
962 'field' => [
963 0 => 'trxn_id',
964 ],
965 'localizable' => FALSE,
966 'unique' => TRUE,
967 'sig' => 'civicrm_contribution::1::trxn_id',
968 ],
969 'UI_contrib_invoice_id' => [
970 'name' => 'UI_contrib_invoice_id',
971 'field' => [
972 0 => 'invoice_id',
973 ],
974 'localizable' => FALSE,
975 'unique' => TRUE,
976 'sig' => 'civicrm_contribution::1::invoice_id',
977 ],
978 'index_contribution_status' => [
979 'name' => 'index_contribution_status',
980 'field' => [
981 0 => 'contribution_status_id',
982 ],
983 'localizable' => FALSE,
984 'sig' => 'civicrm_contribution::0::contribution_status_id',
985 ],
986 'received_date' => [
987 'name' => 'received_date',
988 'field' => [
989 0 => 'receive_date',
990 ],
991 'localizable' => FALSE,
992 'sig' => 'civicrm_contribution::0::receive_date',
993 ],
994 'check_number' => [
995 'name' => 'check_number',
996 'field' => [
997 0 => 'check_number',
998 ],
999 'localizable' => FALSE,
1000 'sig' => 'civicrm_contribution::0::check_number',
1001 ],
1002 'index_creditnote_id' => [
1003 'name' => 'index_creditnote_id',
1004 'field' => [
1005 0 => 'creditnote_id',
1006 ],
1007 'localizable' => FALSE,
1008 'sig' => 'civicrm_contribution::0::creditnote_id',
1009 ],
1010 ];
1011 return ($localize && !empty($indices)) ? CRM_Core_DAO_AllCoreTables::multilingualize(__CLASS__, $indices) : $indices;
1012 }
1013
1014 }