Annotate DAO files with COMPONENT, exclude disabled components' entities from APIv4...
[civicrm-core.git] / CRM / Financial / DAO / FinancialItem.php
CommitLineData
e501603b 1<?php
c3fc2621 2
e501603b
TO
3/**
4 * @package CRM
ca5cec67 5 * @copyright CiviCRM LLC https://civicrm.org/licensing
e501603b
TO
6 *
7 * Generated from xml/schema/CRM/Financial/FinancialItem.xml
8 * DO NOT EDIT. Generated by CRM_Core_CodeGen
d31fb4e3 9 * (GenCodeChecksum:b3bc1270d0d0769da2bd49b49585ac61)
e501603b 10 */
c3fc2621 11
f41f0342 12/**
c3fc2621 13 * Database access object for the FinancialItem entity.
f41f0342 14 */
e501603b 15class CRM_Financial_DAO_FinancialItem extends CRM_Core_DAO {
929a1c14
CW
16 const EXT = 'civicrm';
17 const TABLE_ADDED = '4.3';
d31fb4e3 18 const COMPONENT = 'CiviContribute';
c3fc2621 19
e501603b 20 /**
f41f0342 21 * Static instance to hold the table name.
e501603b
TO
22 *
23 * @var string
24 */
fa45b5b9 25 public static $_tableName = 'civicrm_financial_item';
c3fc2621 26
e501603b 27 /**
f41f0342 28 * Should CiviCRM log any modifications to this table in the civicrm_log table.
e501603b 29 *
c3fc2621 30 * @var bool
e501603b 31 */
fa45b5b9 32 public static $_log = TRUE;
c3fc2621 33
e501603b 34 /**
e6ca0a57 35 * @var int
e501603b
TO
36 */
37 public $id;
c3fc2621 38
e501603b
TO
39 /**
40 * Date and time the item was created
41 *
42 * @var timestamp
43 */
44 public $created_date;
c3fc2621 45
e501603b
TO
46 /**
47 * Date and time of the source transaction
48 *
49 * @var datetime
50 */
51 public $transaction_date;
c3fc2621 52
e501603b
TO
53 /**
54 * FK to Contact ID of contact the item is from
55 *
e6ca0a57 56 * @var int
e501603b
TO
57 */
58 public $contact_id;
c3fc2621 59
e501603b
TO
60 /**
61 * Human readable description of this item, to ease display without lookup of source item.
62 *
63 * @var string
64 */
65 public $description;
c3fc2621 66
e501603b
TO
67 /**
68 * Total amount of this item
69 *
70 * @var float
71 */
72 public $amount;
c3fc2621 73
e501603b
TO
74 /**
75 * Currency for the amount
76 *
77 * @var string
78 */
79 public $currency;
c3fc2621 80
e501603b
TO
81 /**
82 * FK to civicrm_financial_account
83 *
e6ca0a57 84 * @var int
e501603b
TO
85 */
86 public $financial_account_id;
c3fc2621 87
e501603b
TO
88 /**
89 * Payment status: test, paid, part_paid, unpaid (if empty assume unpaid)
90 *
e6ca0a57 91 * @var int
e501603b
TO
92 */
93 public $status_id;
c3fc2621 94
e501603b
TO
95 /**
96 * The table providing the source of this item such as civicrm_line_item
97 *
98 * @var string
99 */
100 public $entity_table;
c3fc2621 101
e501603b
TO
102 /**
103 * The specific source item that is responsible for the creation of this financial_item
104 *
e6ca0a57 105 * @var int
e501603b
TO
106 */
107 public $entity_id;
c3fc2621 108
e501603b 109 /**
f41f0342 110 * Class constructor.
e501603b 111 */
c3fc2621 112 public function __construct() {
e501603b
TO
113 $this->__table = 'civicrm_financial_item';
114 parent::__construct();
115 }
c3fc2621 116
449c4e6b
CW
117 /**
118 * Returns localized title of this entity.
7b66c3b5
AH
119 *
120 * @param bool $plural
121 * Whether to return the plural version of the title.
449c4e6b 122 */
7b66c3b5
AH
123 public static function getEntityTitle($plural = FALSE) {
124 return $plural ? ts('Financial Items') : ts('Financial Item');
449c4e6b
CW
125 }
126
e501603b 127 /**
f41f0342 128 * Returns foreign keys and entity references.
e501603b
TO
129 *
130 * @return array
131 * [CRM_Core_Reference_Interface]
132 */
c3fc2621 133 public static function getReferenceColumns() {
346aaaba 134 if (!isset(Civi::$statics[__CLASS__]['links'])) {
fa45b5b9 135 Civi::$statics[__CLASS__]['links'] = static::createReferenceColumns(__CLASS__);
c3fc2621
CW
136 Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName(), 'contact_id', 'civicrm_contact', 'id');
137 Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName(), 'financial_account_id', 'civicrm_financial_account', 'id');
138 Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Dynamic(self::getTableName(), 'entity_id', NULL, 'id', 'entity_table');
346aaaba 139 CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'links_callback', Civi::$statics[__CLASS__]['links']);
e501603b 140 }
346aaaba 141 return Civi::$statics[__CLASS__]['links'];
e501603b 142 }
c3fc2621 143
e501603b
TO
144 /**
145 * Returns all the column names of this table
146 *
147 * @return array
148 */
c3fc2621 149 public static function &fields() {
346aaaba 150 if (!isset(Civi::$statics[__CLASS__]['fields'])) {
c3fc2621
CW
151 Civi::$statics[__CLASS__]['fields'] = [
152 'id' => [
e501603b
TO
153 'name' => 'id',
154 'type' => CRM_Utils_Type::T_INT,
c3fc2621
CW
155 'title' => ts('Financial Item ID'),
156 'required' => TRUE,
a36434b9 157 'where' => 'civicrm_financial_item.id',
522a26c9 158 'table_name' => 'civicrm_financial_item',
159 'entity' => 'FinancialItem',
160 'bao' => 'CRM_Financial_BAO_FinancialItem',
6a7e5e5d 161 'localizable' => 0,
a9d0587b 162 'add' => '4.3',
c3fc2621
CW
163 ],
164 'created_date' => [
e501603b
TO
165 'name' => 'created_date',
166 'type' => CRM_Utils_Type::T_TIMESTAMP,
c3fc2621 167 'title' => ts('Financial Item Created Date'),
215b423e 168 'description' => ts('Date and time the item was created'),
c3fc2621 169 'required' => TRUE,
a36434b9 170 'where' => 'civicrm_financial_item.created_date',
e501603b 171 'default' => 'CURRENT_TIMESTAMP',
522a26c9 172 'table_name' => 'civicrm_financial_item',
173 'entity' => 'FinancialItem',
174 'bao' => 'CRM_Financial_BAO_FinancialItem',
6a7e5e5d 175 'localizable' => 0,
a9d0587b 176 'add' => '4.3',
c3fc2621
CW
177 ],
178 'transaction_date' => [
e501603b
TO
179 'name' => 'transaction_date',
180 'type' => CRM_Utils_Type::T_DATE + CRM_Utils_Type::T_TIME,
c3fc2621 181 'title' => ts('Financial Item Transaction Date'),
215b423e 182 'description' => ts('Date and time of the source transaction'),
c3fc2621 183 'required' => TRUE,
a36434b9 184 'where' => 'civicrm_financial_item.transaction_date',
522a26c9 185 'table_name' => 'civicrm_financial_item',
186 'entity' => 'FinancialItem',
187 'bao' => 'CRM_Financial_BAO_FinancialItem',
6a7e5e5d 188 'localizable' => 0,
a9d0587b 189 'add' => '4.3',
c3fc2621
CW
190 ],
191 'contact_id' => [
e501603b
TO
192 'name' => 'contact_id',
193 'type' => CRM_Utils_Type::T_INT,
c3fc2621 194 'title' => ts('Financial Item Contact ID'),
215b423e 195 'description' => ts('FK to Contact ID of contact the item is from'),
c3fc2621 196 'required' => TRUE,
e501603b 197 'where' => 'civicrm_financial_item.contact_id',
a36434b9 198 'export' => TRUE,
522a26c9 199 'table_name' => 'civicrm_financial_item',
200 'entity' => 'FinancialItem',
201 'bao' => 'CRM_Financial_BAO_FinancialItem',
6a7e5e5d 202 'localizable' => 0,
e501603b 203 'FKClassName' => 'CRM_Contact_DAO_Contact',
a9d0587b 204 'add' => '4.3',
c3fc2621
CW
205 ],
206 'description' => [
e501603b
TO
207 'name' => 'description',
208 'type' => CRM_Utils_Type::T_STRING,
c3fc2621 209 'title' => ts('Financial Item Description'),
215b423e 210 'description' => ts('Human readable description of this item, to ease display without lookup of source item.'),
e501603b
TO
211 'maxlength' => 255,
212 'size' => CRM_Utils_Type::HUGE,
a36434b9 213 'where' => 'civicrm_financial_item.description',
522a26c9 214 'table_name' => 'civicrm_financial_item',
215 'entity' => 'FinancialItem',
216 'bao' => 'CRM_Financial_BAO_FinancialItem',
6a7e5e5d 217 'localizable' => 0,
a9d0587b 218 'add' => '4.3',
c3fc2621
CW
219 ],
220 'amount' => [
e501603b
TO
221 'name' => 'amount',
222 'type' => CRM_Utils_Type::T_MONEY,
c3fc2621 223 'title' => ts('Amount'),
215b423e 224 'description' => ts('Total amount of this item'),
c3fc2621
CW
225 'required' => TRUE,
226 'precision' => [
e501603b 227 20,
fb607354 228 2,
c3fc2621 229 ],
a36434b9 230 'where' => 'civicrm_financial_item.amount',
231 'headerPattern' => '/unit?.?amoun/i',
232 'dataPattern' => '/^\d+(\.\d{2})?$/',
45a83e42 233 'default' => '0',
522a26c9 234 'table_name' => 'civicrm_financial_item',
235 'entity' => 'FinancialItem',
236 'bao' => 'CRM_Financial_BAO_FinancialItem',
6a7e5e5d 237 'localizable' => 0,
a9d0587b 238 'add' => '4.3',
c3fc2621
CW
239 ],
240 'currency' => [
e501603b
TO
241 'name' => 'currency',
242 'type' => CRM_Utils_Type::T_STRING,
c3fc2621 243 'title' => ts('Financial Item Currency'),
215b423e 244 'description' => ts('Currency for the amount'),
e501603b
TO
245 'maxlength' => 3,
246 'size' => CRM_Utils_Type::FOUR,
e501603b 247 'where' => 'civicrm_financial_item.currency',
a36434b9 248 'export' => TRUE,
522a26c9 249 'table_name' => 'civicrm_financial_item',
250 'entity' => 'FinancialItem',
251 'bao' => 'CRM_Financial_BAO_FinancialItem',
6a7e5e5d 252 'localizable' => 0,
c3fc2621 253 'html' => [
e501603b 254 'type' => 'Select',
c3fc2621
CW
255 ],
256 'pseudoconstant' => [
e501603b
TO
257 'table' => 'civicrm_currency',
258 'keyColumn' => 'name',
259 'labelColumn' => 'full_name',
260 'nameColumn' => 'name',
a8fdb24e 261 'abbrColumn' => 'symbol',
e6ca0a57 262 ],
a9d0587b 263 'add' => '4.3',
c3fc2621
CW
264 ],
265 'financial_account_id' => [
e501603b
TO
266 'name' => 'financial_account_id',
267 'type' => CRM_Utils_Type::T_INT,
c3fc2621 268 'title' => ts('Financial Account ID'),
215b423e 269 'description' => ts('FK to civicrm_financial_account'),
a36434b9 270 'where' => 'civicrm_financial_item.financial_account_id',
522a26c9 271 'table_name' => 'civicrm_financial_item',
272 'entity' => 'FinancialItem',
273 'bao' => 'CRM_Financial_BAO_FinancialItem',
6a7e5e5d 274 'localizable' => 0,
e501603b 275 'FKClassName' => 'CRM_Financial_DAO_FinancialAccount',
c3fc2621 276 'html' => [
e501603b 277 'type' => 'Select',
c3fc2621
CW
278 ],
279 'pseudoconstant' => [
e501603b
TO
280 'table' => 'civicrm_financial_account',
281 'keyColumn' => 'id',
282 'labelColumn' => 'name',
e6ca0a57 283 ],
a9d0587b 284 'add' => '4.3',
c3fc2621
CW
285 ],
286 'status_id' => [
e501603b
TO
287 'name' => 'status_id',
288 'type' => CRM_Utils_Type::T_INT,
c3fc2621 289 'title' => ts('Financial Item Status ID'),
215b423e 290 'description' => ts('Payment status: test, paid, part_paid, unpaid (if empty assume unpaid)'),
e501603b 291 'where' => 'civicrm_financial_item.status_id',
a36434b9 292 'export' => TRUE,
522a26c9 293 'table_name' => 'civicrm_financial_item',
294 'entity' => 'FinancialItem',
295 'bao' => 'CRM_Financial_BAO_FinancialItem',
6a7e5e5d 296 'localizable' => 0,
c3fc2621 297 'html' => [
e501603b 298 'type' => 'Select',
c3fc2621
CW
299 ],
300 'pseudoconstant' => [
e501603b
TO
301 'optionGroupName' => 'financial_item_status',
302 'optionEditPath' => 'civicrm/admin/options/financial_item_status',
e6ca0a57 303 ],
a9d0587b 304 'add' => '4.3',
c3fc2621
CW
305 ],
306 'entity_table' => [
e501603b
TO
307 'name' => 'entity_table',
308 'type' => CRM_Utils_Type::T_STRING,
c3fc2621 309 'title' => ts('Entity Table'),
215b423e 310 'description' => ts('The table providing the source of this item such as civicrm_line_item'),
e501603b
TO
311 'maxlength' => 64,
312 'size' => CRM_Utils_Type::BIG,
a36434b9 313 'where' => 'civicrm_financial_item.entity_table',
522a26c9 314 'table_name' => 'civicrm_financial_item',
315 'entity' => 'FinancialItem',
316 'bao' => 'CRM_Financial_BAO_FinancialItem',
6a7e5e5d 317 'localizable' => 0,
a9d0587b 318 'add' => '4.3',
c3fc2621
CW
319 ],
320 'entity_id' => [
e501603b
TO
321 'name' => 'entity_id',
322 'type' => CRM_Utils_Type::T_INT,
c3fc2621 323 'title' => ts('Entity ID'),
215b423e 324 'description' => ts('The specific source item that is responsible for the creation of this financial_item'),
a36434b9 325 'where' => 'civicrm_financial_item.entity_id',
522a26c9 326 'table_name' => 'civicrm_financial_item',
327 'entity' => 'FinancialItem',
328 'bao' => 'CRM_Financial_BAO_FinancialItem',
6a7e5e5d 329 'localizable' => 0,
a9d0587b 330 'add' => '4.3',
c3fc2621
CW
331 ],
332 ];
346aaaba 333 CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'fields_callback', Civi::$statics[__CLASS__]['fields']);
e501603b 334 }
346aaaba 335 return Civi::$statics[__CLASS__]['fields'];
e501603b 336 }
c3fc2621 337
e501603b 338 /**
bd8e0b14 339 * Return a mapping from field-name to the corresponding key (as used in fields()).
e501603b
TO
340 *
341 * @return array
bd8e0b14 342 * Array(string $name => string $uniqueName).
e501603b 343 */
c3fc2621 344 public static function &fieldKeys() {
bd8e0b14
TO
345 if (!isset(Civi::$statics[__CLASS__]['fieldKeys'])) {
346 Civi::$statics[__CLASS__]['fieldKeys'] = array_flip(CRM_Utils_Array::collect('name', self::fields()));
e501603b 347 }
bd8e0b14 348 return Civi::$statics[__CLASS__]['fieldKeys'];
e501603b 349 }
c3fc2621 350
e501603b
TO
351 /**
352 * Returns the names of this table
353 *
354 * @return string
355 */
c3fc2621 356 public static function getTableName() {
e501603b
TO
357 return self::$_tableName;
358 }
c3fc2621 359
e501603b
TO
360 /**
361 * Returns if this table needs to be logged
362 *
c3fc2621 363 * @return bool
e501603b 364 */
c3fc2621 365 public function getLog() {
e501603b
TO
366 return self::$_log;
367 }
c3fc2621 368
e501603b
TO
369 /**
370 * Returns the list of fields that can be imported
371 *
372 * @param bool $prefix
373 *
374 * @return array
375 */
c3fc2621
CW
376 public static function &import($prefix = FALSE) {
377 $r = CRM_Core_DAO_AllCoreTables::getImports(__CLASS__, 'financial_item', $prefix, []);
60808919 378 return $r;
e501603b 379 }
c3fc2621 380
e501603b
TO
381 /**
382 * Returns the list of fields that can be exported
383 *
384 * @param bool $prefix
385 *
386 * @return array
387 */
c3fc2621
CW
388 public static function &export($prefix = FALSE) {
389 $r = CRM_Core_DAO_AllCoreTables::getExports(__CLASS__, 'financial_item', $prefix, []);
60808919 390 return $r;
e501603b 391 }
c3fc2621 392
e7a6b91a
AS
393 /**
394 * Returns the list of indices
c3fc2621
CW
395 *
396 * @param bool $localize
397 *
398 * @return array
e7a6b91a
AS
399 */
400 public static function indices($localize = TRUE) {
c3fc2621
CW
401 $indices = [
402 'IX_created_date' => [
e7a6b91a 403 'name' => 'IX_created_date',
c3fc2621 404 'field' => [
e7a6b91a 405 0 => 'created_date',
c3fc2621
CW
406 ],
407 'localizable' => FALSE,
e7a6b91a 408 'sig' => 'civicrm_financial_item::0::created_date',
c3fc2621
CW
409 ],
410 'IX_transaction_date' => [
e7a6b91a 411 'name' => 'IX_transaction_date',
c3fc2621 412 'field' => [
e7a6b91a 413 0 => 'transaction_date',
c3fc2621
CW
414 ],
415 'localizable' => FALSE,
e7a6b91a 416 'sig' => 'civicrm_financial_item::0::transaction_date',
c3fc2621
CW
417 ],
418 'index_entity_id_entity_table' => [
e7a6b91a 419 'name' => 'index_entity_id_entity_table',
c3fc2621 420 'field' => [
e7a6b91a
AS
421 0 => 'entity_id',
422 1 => 'entity_table',
c3fc2621
CW
423 ],
424 'localizable' => FALSE,
e7a6b91a 425 'sig' => 'civicrm_financial_item::0::entity_id::entity_table',
c3fc2621
CW
426 ],
427 ];
e7a6b91a
AS
428 return ($localize && !empty($indices)) ? CRM_Core_DAO_AllCoreTables::multilingualize(__CLASS__, $indices) : $indices;
429 }
c3fc2621 430
e501603b 431}