API/DAO Metadata - Retain versioning metadata for possible usage in runtime+tooling
[civicrm-core.git] / CRM / Price / DAO / LineItem.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/Price/LineItem.xml
8 * DO NOT EDIT. Generated by CRM_Core_CodeGen
a9d0587b 9 * (GenCodeChecksum:84c128f076238b53a8c0c6dd23a22587)
e501603b 10 */
c3fc2621 11
f41f0342 12/**
c3fc2621 13 * Database access object for the LineItem entity.
f41f0342 14 */
e501603b 15class CRM_Price_DAO_LineItem extends CRM_Core_DAO {
c3fc2621 16
e501603b 17 /**
f41f0342 18 * Static instance to hold the table name.
e501603b
TO
19 *
20 * @var string
21 */
fa45b5b9 22 public static $_tableName = 'civicrm_line_item';
c3fc2621 23
e501603b 24 /**
f41f0342 25 * Should CiviCRM log any modifications to this table in the civicrm_log table.
e501603b 26 *
c3fc2621 27 * @var bool
e501603b 28 */
fa45b5b9 29 public static $_log = TRUE;
c3fc2621 30
e501603b
TO
31 /**
32 * Line Item
33 *
e6ca0a57 34 * @var int
e501603b
TO
35 */
36 public $id;
c3fc2621 37
e501603b
TO
38 /**
39 * table which has the transaction
40 *
41 * @var string
42 */
43 public $entity_table;
c3fc2621 44
e501603b
TO
45 /**
46 * entry in table
47 *
e6ca0a57 48 * @var int
e501603b
TO
49 */
50 public $entity_id;
c3fc2621 51
e501603b
TO
52 /**
53 * FK to civicrm_contribution
54 *
e6ca0a57 55 * @var int
e501603b
TO
56 */
57 public $contribution_id;
c3fc2621 58
e501603b
TO
59 /**
60 * FK to civicrm_price_field
61 *
e6ca0a57 62 * @var int
e501603b
TO
63 */
64 public $price_field_id;
c3fc2621 65
e501603b
TO
66 /**
67 * descriptive label for item - from price_field_value.label
68 *
69 * @var string
70 */
71 public $label;
c3fc2621 72
e501603b
TO
73 /**
74 * How many items ordered
75 *
76 * @var float
77 */
78 public $qty;
c3fc2621 79
e501603b
TO
80 /**
81 * price of each item
82 *
83 * @var float
84 */
85 public $unit_price;
c3fc2621 86
e501603b
TO
87 /**
88 * qty * unit_price
89 *
90 * @var float
91 */
92 public $line_total;
c3fc2621 93
e501603b
TO
94 /**
95 * Participant count for field
96 *
e6ca0a57 97 * @var int
e501603b
TO
98 */
99 public $participant_count;
c3fc2621 100
e501603b
TO
101 /**
102 * FK to civicrm_price_field_value
103 *
e6ca0a57 104 * @var int
e501603b
TO
105 */
106 public $price_field_value_id;
c3fc2621 107
e501603b
TO
108 /**
109 * FK to Financial Type.
110 *
e6ca0a57 111 * @var int
e501603b
TO
112 */
113 public $financial_type_id;
c3fc2621 114
e501603b 115 /**
5afce5ad 116 * Portion of total amount which is NOT tax deductible.
e501603b
TO
117 *
118 * @var float
119 */
5afce5ad 120 public $non_deductible_amount;
c3fc2621 121
e501603b
TO
122 /**
123 * tax of each item
124 *
125 * @var float
126 */
127 public $tax_amount;
c3fc2621 128
e501603b 129 /**
f41f0342 130 * Class constructor.
e501603b 131 */
c3fc2621 132 public function __construct() {
e501603b
TO
133 $this->__table = 'civicrm_line_item';
134 parent::__construct();
135 }
c3fc2621 136
449c4e6b
CW
137 /**
138 * Returns localized title of this entity.
139 */
140 public static function getEntityTitle() {
141 return ts('Line Items');
142 }
143
e501603b 144 /**
f41f0342 145 * Returns foreign keys and entity references.
e501603b
TO
146 *
147 * @return array
148 * [CRM_Core_Reference_Interface]
149 */
c3fc2621 150 public static function getReferenceColumns() {
346aaaba 151 if (!isset(Civi::$statics[__CLASS__]['links'])) {
fa45b5b9 152 Civi::$statics[__CLASS__]['links'] = static::createReferenceColumns(__CLASS__);
c3fc2621
CW
153 Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName(), 'contribution_id', 'civicrm_contribution', 'id');
154 Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName(), 'price_field_id', 'civicrm_price_field', 'id');
155 Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName(), 'price_field_value_id', 'civicrm_price_field_value', 'id');
156 Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName(), 'financial_type_id', 'civicrm_financial_type', 'id');
157 Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Dynamic(self::getTableName(), 'entity_id', NULL, 'id', 'entity_table');
346aaaba 158 CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'links_callback', Civi::$statics[__CLASS__]['links']);
e501603b 159 }
346aaaba 160 return Civi::$statics[__CLASS__]['links'];
e501603b 161 }
c3fc2621 162
e501603b
TO
163 /**
164 * Returns all the column names of this table
165 *
166 * @return array
167 */
c3fc2621 168 public static function &fields() {
346aaaba 169 if (!isset(Civi::$statics[__CLASS__]['fields'])) {
c3fc2621
CW
170 Civi::$statics[__CLASS__]['fields'] = [
171 'id' => [
e501603b
TO
172 'name' => 'id',
173 'type' => CRM_Utils_Type::T_INT,
c3fc2621 174 'title' => ts('Line Item ID'),
215b423e 175 'description' => ts('Line Item'),
c3fc2621 176 'required' => TRUE,
a36434b9 177 'where' => 'civicrm_line_item.id',
522a26c9 178 'table_name' => 'civicrm_line_item',
179 'entity' => 'LineItem',
180 'bao' => 'CRM_Price_BAO_LineItem',
6a7e5e5d 181 'localizable' => 0,
a9d0587b 182 'add' => '1.7',
c3fc2621
CW
183 ],
184 'entity_table' => [
e501603b
TO
185 'name' => 'entity_table',
186 'type' => CRM_Utils_Type::T_STRING,
c3fc2621 187 'title' => ts('Line Item Entity Type'),
215b423e 188 'description' => ts('table which has the transaction'),
c3fc2621 189 'required' => TRUE,
e501603b
TO
190 'maxlength' => 64,
191 'size' => CRM_Utils_Type::BIG,
a36434b9 192 'where' => 'civicrm_line_item.entity_table',
522a26c9 193 'table_name' => 'civicrm_line_item',
194 'entity' => 'LineItem',
195 'bao' => 'CRM_Price_BAO_LineItem',
6a7e5e5d 196 'localizable' => 0,
a9d0587b 197 'add' => '1.7',
c3fc2621
CW
198 ],
199 'entity_id' => [
e501603b
TO
200 'name' => 'entity_id',
201 'type' => CRM_Utils_Type::T_INT,
c3fc2621 202 'title' => ts('Line Item Entity'),
215b423e 203 'description' => ts('entry in table'),
c3fc2621 204 'required' => TRUE,
a36434b9 205 'where' => 'civicrm_line_item.entity_id',
522a26c9 206 'table_name' => 'civicrm_line_item',
207 'entity' => 'LineItem',
208 'bao' => 'CRM_Price_BAO_LineItem',
6a7e5e5d 209 'localizable' => 0,
a9d0587b 210 'add' => '1.7',
c3fc2621
CW
211 ],
212 'contribution_id' => [
e501603b
TO
213 'name' => 'contribution_id',
214 'type' => CRM_Utils_Type::T_INT,
c3fc2621 215 'title' => ts('Line Item Contribution'),
215b423e 216 'description' => ts('FK to civicrm_contribution'),
a36434b9 217 'where' => 'civicrm_line_item.contribution_id',
522a26c9 218 'table_name' => 'civicrm_line_item',
219 'entity' => 'LineItem',
220 'bao' => 'CRM_Price_BAO_LineItem',
6a7e5e5d 221 'localizable' => 0,
e501603b 222 'FKClassName' => 'CRM_Contribute_DAO_Contribution',
a9d0587b 223 'add' => '4.5',
c3fc2621
CW
224 ],
225 'price_field_id' => [
e501603b
TO
226 'name' => 'price_field_id',
227 'type' => CRM_Utils_Type::T_INT,
c3fc2621 228 'title' => ts('Line Item Price Field'),
215b423e 229 'description' => ts('FK to civicrm_price_field'),
a36434b9 230 'where' => 'civicrm_line_item.price_field_id',
522a26c9 231 'table_name' => 'civicrm_line_item',
232 'entity' => 'LineItem',
233 'bao' => 'CRM_Price_BAO_LineItem',
6a7e5e5d 234 'localizable' => 0,
e501603b 235 'FKClassName' => 'CRM_Price_DAO_PriceField',
a9d0587b 236 'add' => '1.7',
c3fc2621
CW
237 ],
238 'label' => [
e501603b
TO
239 'name' => 'label',
240 'type' => CRM_Utils_Type::T_STRING,
c3fc2621 241 'title' => ts('Line Item Label'),
215b423e 242 'description' => ts('descriptive label for item - from price_field_value.label'),
e501603b
TO
243 'maxlength' => 255,
244 'size' => CRM_Utils_Type::HUGE,
a36434b9 245 'where' => 'civicrm_line_item.label',
e501603b 246 'default' => 'NULL',
522a26c9 247 'table_name' => 'civicrm_line_item',
248 'entity' => 'LineItem',
249 'bao' => 'CRM_Price_BAO_LineItem',
6a7e5e5d 250 'localizable' => 0,
c3fc2621 251 'html' => [
e501603b 252 'type' => 'Text',
c3fc2621 253 ],
a9d0587b 254 'add' => '1.7',
c3fc2621
CW
255 ],
256 'qty' => [
e501603b
TO
257 'name' => 'qty',
258 'type' => CRM_Utils_Type::T_MONEY,
c3fc2621 259 'title' => ts('Line Item Quantity'),
215b423e 260 'description' => ts('How many items ordered'),
c3fc2621
CW
261 'required' => TRUE,
262 'precision' => [
e501603b 263 20,
fb607354 264 2,
c3fc2621 265 ],
a36434b9 266 'where' => 'civicrm_line_item.qty',
522a26c9 267 'table_name' => 'civicrm_line_item',
268 'entity' => 'LineItem',
269 'bao' => 'CRM_Price_BAO_LineItem',
6a7e5e5d 270 'localizable' => 0,
c3fc2621 271 'html' => [
e501603b 272 'type' => 'Text',
c3fc2621 273 ],
a9d0587b 274 'add' => '1.7',
c3fc2621
CW
275 ],
276 'unit_price' => [
e501603b
TO
277 'name' => 'unit_price',
278 'type' => CRM_Utils_Type::T_MONEY,
c3fc2621 279 'title' => ts('Unit Price'),
215b423e 280 'description' => ts('price of each item'),
c3fc2621
CW
281 'required' => TRUE,
282 'precision' => [
e501603b 283 20,
fb607354 284 2,
c3fc2621 285 ],
a36434b9 286 'where' => 'civicrm_line_item.unit_price',
522a26c9 287 'table_name' => 'civicrm_line_item',
288 'entity' => 'LineItem',
289 'bao' => 'CRM_Price_BAO_LineItem',
6a7e5e5d 290 'localizable' => 0,
c3fc2621 291 'html' => [
e501603b 292 'type' => 'Text',
c3fc2621 293 ],
a9d0587b 294 'add' => '1.7',
c3fc2621
CW
295 ],
296 'line_total' => [
e501603b
TO
297 'name' => 'line_total',
298 'type' => CRM_Utils_Type::T_MONEY,
c3fc2621 299 'title' => ts('Line Item Total'),
215b423e 300 'description' => ts('qty * unit_price'),
c3fc2621
CW
301 'required' => TRUE,
302 'precision' => [
e501603b 303 20,
fb607354 304 2,
c3fc2621 305 ],
a36434b9 306 'where' => 'civicrm_line_item.line_total',
522a26c9 307 'table_name' => 'civicrm_line_item',
308 'entity' => 'LineItem',
309 'bao' => 'CRM_Price_BAO_LineItem',
6a7e5e5d 310 'localizable' => 0,
a9d0587b 311 'add' => '1.7',
c3fc2621
CW
312 ],
313 'participant_count' => [
e501603b
TO
314 'name' => 'participant_count',
315 'type' => CRM_Utils_Type::T_INT,
c3fc2621 316 'title' => ts('Line Item Participant Count'),
215b423e 317 'description' => ts('Participant count for field'),
a36434b9 318 'where' => 'civicrm_line_item.participant_count',
e501603b 319 'default' => 'NULL',
522a26c9 320 'table_name' => 'civicrm_line_item',
321 'entity' => 'LineItem',
322 'bao' => 'CRM_Price_BAO_LineItem',
6a7e5e5d 323 'localizable' => 0,
c3fc2621 324 'html' => [
e501603b 325 'type' => 'Text',
c3fc2621 326 ],
a9d0587b 327 'add' => '3.2',
c3fc2621
CW
328 ],
329 'price_field_value_id' => [
e501603b
TO
330 'name' => 'price_field_value_id',
331 'type' => CRM_Utils_Type::T_INT,
c3fc2621 332 'title' => ts('Line Item Option'),
215b423e 333 'description' => ts('FK to civicrm_price_field_value'),
a36434b9 334 'where' => 'civicrm_line_item.price_field_value_id',
e501603b 335 'default' => 'NULL',
522a26c9 336 'table_name' => 'civicrm_line_item',
337 'entity' => 'LineItem',
338 'bao' => 'CRM_Price_BAO_LineItem',
6a7e5e5d 339 'localizable' => 0,
e501603b 340 'FKClassName' => 'CRM_Price_DAO_PriceFieldValue',
a9d0587b 341 'add' => '3.3',
c3fc2621
CW
342 ],
343 'financial_type_id' => [
e501603b
TO
344 'name' => 'financial_type_id',
345 'type' => CRM_Utils_Type::T_INT,
c3fc2621 346 'title' => ts('Financial Type'),
215b423e 347 'description' => ts('FK to Financial Type.'),
a36434b9 348 'where' => 'civicrm_line_item.financial_type_id',
e501603b 349 'default' => 'NULL',
522a26c9 350 'table_name' => 'civicrm_line_item',
351 'entity' => 'LineItem',
352 'bao' => 'CRM_Price_BAO_LineItem',
6a7e5e5d 353 'localizable' => 0,
e501603b 354 'FKClassName' => 'CRM_Financial_DAO_FinancialType',
c3fc2621 355 'html' => [
e501603b 356 'type' => 'Select',
c3fc2621
CW
357 ],
358 'pseudoconstant' => [
e501603b
TO
359 'table' => 'civicrm_financial_type',
360 'keyColumn' => 'id',
361 'labelColumn' => 'name',
e6ca0a57 362 ],
a9d0587b 363 'add' => '4.3',
c3fc2621
CW
364 ],
365 'non_deductible_amount' => [
5afce5ad 366 'name' => 'non_deductible_amount',
e501603b 367 'type' => CRM_Utils_Type::T_MONEY,
c3fc2621 368 'title' => ts('Non-deductible Amount'),
215b423e 369 'description' => ts('Portion of total amount which is NOT tax deductible.'),
c3fc2621
CW
370 'required' => TRUE,
371 'precision' => [
e501603b 372 20,
fb607354 373 2,
c3fc2621 374 ],
a36434b9 375 'where' => 'civicrm_line_item.non_deductible_amount',
376 'headerPattern' => '/non?.?deduct/i',
377 'dataPattern' => '/^\d+(\.\d{2})?$/',
e501603b 378 'default' => '0.0',
522a26c9 379 'table_name' => 'civicrm_line_item',
380 'entity' => 'LineItem',
381 'bao' => 'CRM_Price_BAO_LineItem',
6a7e5e5d 382 'localizable' => 0,
c3fc2621 383 'html' => [
e501603b 384 'type' => 'Text',
c3fc2621 385 ],
a9d0587b 386 'add' => '4.7',
c3fc2621
CW
387 ],
388 'tax_amount' => [
e501603b
TO
389 'name' => 'tax_amount',
390 'type' => CRM_Utils_Type::T_MONEY,
c3fc2621 391 'title' => ts('Tax Amount'),
215b423e 392 'description' => ts('tax of each item'),
c3fc2621 393 'precision' => [
e501603b 394 20,
fb607354 395 2,
c3fc2621
CW
396 ],
397 'import' => TRUE,
e501603b
TO
398 'where' => 'civicrm_line_item.tax_amount',
399 'headerPattern' => '/tax(.?am(ou)?nt)?/i',
400 'dataPattern' => '/^\d+(\.\d{2})?$/',
c3fc2621 401 'export' => TRUE,
522a26c9 402 'table_name' => 'civicrm_line_item',
403 'entity' => 'LineItem',
404 'bao' => 'CRM_Price_BAO_LineItem',
6a7e5e5d 405 'localizable' => 0,
c3fc2621 406 'html' => [
e501603b 407 'type' => 'Text',
c3fc2621 408 ],
a9d0587b 409 'add' => '4.6',
c3fc2621
CW
410 ],
411 ];
346aaaba 412 CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'fields_callback', Civi::$statics[__CLASS__]['fields']);
e501603b 413 }
346aaaba 414 return Civi::$statics[__CLASS__]['fields'];
e501603b 415 }
c3fc2621 416
e501603b 417 /**
bd8e0b14 418 * Return a mapping from field-name to the corresponding key (as used in fields()).
e501603b
TO
419 *
420 * @return array
bd8e0b14 421 * Array(string $name => string $uniqueName).
e501603b 422 */
c3fc2621 423 public static function &fieldKeys() {
bd8e0b14
TO
424 if (!isset(Civi::$statics[__CLASS__]['fieldKeys'])) {
425 Civi::$statics[__CLASS__]['fieldKeys'] = array_flip(CRM_Utils_Array::collect('name', self::fields()));
e501603b 426 }
bd8e0b14 427 return Civi::$statics[__CLASS__]['fieldKeys'];
e501603b 428 }
c3fc2621 429
e501603b
TO
430 /**
431 * Returns the names of this table
432 *
433 * @return string
434 */
c3fc2621 435 public static function getTableName() {
e501603b
TO
436 return self::$_tableName;
437 }
c3fc2621 438
e501603b
TO
439 /**
440 * Returns if this table needs to be logged
441 *
c3fc2621 442 * @return bool
e501603b 443 */
c3fc2621 444 public function getLog() {
e501603b
TO
445 return self::$_log;
446 }
c3fc2621 447
e501603b
TO
448 /**
449 * Returns the list of fields that can be imported
450 *
451 * @param bool $prefix
452 *
453 * @return array
454 */
c3fc2621
CW
455 public static function &import($prefix = FALSE) {
456 $r = CRM_Core_DAO_AllCoreTables::getImports(__CLASS__, 'line_item', $prefix, []);
60808919 457 return $r;
e501603b 458 }
c3fc2621 459
e501603b
TO
460 /**
461 * Returns the list of fields that can be exported
462 *
463 * @param bool $prefix
464 *
465 * @return array
466 */
c3fc2621
CW
467 public static function &export($prefix = FALSE) {
468 $r = CRM_Core_DAO_AllCoreTables::getExports(__CLASS__, 'line_item', $prefix, []);
60808919 469 return $r;
e501603b 470 }
c3fc2621 471
e7a6b91a
AS
472 /**
473 * Returns the list of indices
c3fc2621
CW
474 *
475 * @param bool $localize
476 *
477 * @return array
e7a6b91a
AS
478 */
479 public static function indices($localize = TRUE) {
c3fc2621
CW
480 $indices = [
481 'index_entity' => [
e7a6b91a 482 'name' => 'index_entity',
c3fc2621 483 'field' => [
e7a6b91a
AS
484 0 => 'entity_table',
485 1 => 'entity_id',
c3fc2621
CW
486 ],
487 'localizable' => FALSE,
e7a6b91a 488 'sig' => 'civicrm_line_item::0::entity_table::entity_id',
c3fc2621
CW
489 ],
490 'UI_line_item_value' => [
e7a6b91a 491 'name' => 'UI_line_item_value',
c3fc2621 492 'field' => [
e7a6b91a
AS
493 0 => 'entity_table',
494 1 => 'entity_id',
495 2 => 'contribution_id',
496 3 => 'price_field_value_id',
497 4 => 'price_field_id',
c3fc2621
CW
498 ],
499 'localizable' => FALSE,
500 'unique' => TRUE,
e7a6b91a 501 'sig' => 'civicrm_line_item::1::entity_table::entity_id::contribution_id::price_field_value_id::price_field_id',
c3fc2621
CW
502 ],
503 ];
e7a6b91a
AS
504 return ($localize && !empty($indices)) ? CRM_Core_DAO_AllCoreTables::multilingualize(__CLASS__, $indices) : $indices;
505 }
c3fc2621 506
e501603b 507}