API/DAO Metadata - Retain versioning metadata for possible usage in runtime+tooling
[civicrm-core.git] / CRM / Financial / DAO / FinancialAccount.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/FinancialAccount.xml
8 * DO NOT EDIT. Generated by CRM_Core_CodeGen
a9d0587b 9 * (GenCodeChecksum:e9c9d66596703d9dfbf411034ce909c4)
e501603b 10 */
c3fc2621 11
f41f0342 12/**
c3fc2621 13 * Database access object for the FinancialAccount entity.
f41f0342 14 */
e501603b 15class CRM_Financial_DAO_FinancialAccount 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_financial_account';
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 * ID
33 *
e6ca0a57 34 * @var int
e501603b
TO
35 */
36 public $id;
c3fc2621 37
e501603b
TO
38 /**
39 * Financial Account Name.
40 *
41 * @var string
42 */
43 public $name;
c3fc2621 44
e501603b
TO
45 /**
46 * FK to Contact ID that is responsible for the funds in this account
47 *
e6ca0a57 48 * @var int
e501603b
TO
49 */
50 public $contact_id;
c3fc2621 51
e501603b
TO
52 /**
53 * pseudo FK into civicrm_option_value.
54 *
e6ca0a57 55 * @var int
e501603b
TO
56 */
57 public $financial_account_type_id;
c3fc2621 58
e501603b
TO
59 /**
60 * Optional value for mapping monies owed and received to accounting system codes.
61 *
62 * @var string
63 */
64 public $accounting_code;
c3fc2621 65
e501603b
TO
66 /**
67 * Optional value for mapping account types to accounting system account categories (QuickBooks Account Type Codes for example).
68 *
69 * @var string
70 */
71 public $account_type_code;
c3fc2621 72
e501603b
TO
73 /**
74 * Financial Type Description.
75 *
76 * @var string
77 */
78 public $description;
c3fc2621 79
e501603b
TO
80 /**
81 * Parent ID in account hierarchy
82 *
e6ca0a57 83 * @var int
e501603b
TO
84 */
85 public $parent_id;
c3fc2621 86
e501603b
TO
87 /**
88 * Is this a header account which does not allow transactions to be posted against it directly, but only to its sub-accounts?
89 *
e6ca0a57 90 * @var bool
e501603b
TO
91 */
92 public $is_header_account;
c3fc2621 93
e501603b
TO
94 /**
95 * Is this account tax-deductible?
96 *
e6ca0a57 97 * @var bool
e501603b
TO
98 */
99 public $is_deductible;
c3fc2621 100
e501603b
TO
101 /**
102 * Is this account for taxes?
103 *
e6ca0a57 104 * @var bool
e501603b
TO
105 */
106 public $is_tax;
c3fc2621 107
e501603b
TO
108 /**
109 * The percentage of the total_amount that is due for this tax.
110 *
111 * @var float
112 */
113 public $tax_rate;
c3fc2621 114
e501603b
TO
115 /**
116 * Is this a predefined system object?
117 *
e6ca0a57 118 * @var bool
e501603b
TO
119 */
120 public $is_reserved;
c3fc2621 121
e501603b
TO
122 /**
123 * Is this property active?
124 *
e6ca0a57 125 * @var bool
e501603b
TO
126 */
127 public $is_active;
c3fc2621 128
e501603b
TO
129 /**
130 * Is this account the default one (or default tax one) for its financial_account_type?
131 *
e6ca0a57 132 * @var bool
e501603b
TO
133 */
134 public $is_default;
c3fc2621 135
e501603b 136 /**
f41f0342 137 * Class constructor.
e501603b 138 */
c3fc2621 139 public function __construct() {
e501603b
TO
140 $this->__table = 'civicrm_financial_account';
141 parent::__construct();
142 }
c3fc2621 143
449c4e6b
CW
144 /**
145 * Returns localized title of this entity.
146 */
147 public static function getEntityTitle() {
148 return ts('Financial Accounts');
149 }
150
e501603b 151 /**
f41f0342 152 * Returns foreign keys and entity references.
e501603b
TO
153 *
154 * @return array
155 * [CRM_Core_Reference_Interface]
156 */
c3fc2621 157 public static function getReferenceColumns() {
346aaaba 158 if (!isset(Civi::$statics[__CLASS__]['links'])) {
fa45b5b9 159 Civi::$statics[__CLASS__]['links'] = static::createReferenceColumns(__CLASS__);
c3fc2621
CW
160 Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName(), 'contact_id', 'civicrm_contact', 'id');
161 Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName(), 'parent_id', 'civicrm_financial_account', 'id');
346aaaba 162 CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'links_callback', Civi::$statics[__CLASS__]['links']);
e501603b 163 }
346aaaba 164 return Civi::$statics[__CLASS__]['links'];
e501603b 165 }
c3fc2621 166
e501603b
TO
167 /**
168 * Returns all the column names of this table
169 *
170 * @return array
171 */
c3fc2621 172 public static function &fields() {
346aaaba 173 if (!isset(Civi::$statics[__CLASS__]['fields'])) {
c3fc2621
CW
174 Civi::$statics[__CLASS__]['fields'] = [
175 'id' => [
e501603b
TO
176 'name' => 'id',
177 'type' => CRM_Utils_Type::T_INT,
c3fc2621 178 'title' => ts('Financial Account ID'),
215b423e 179 'description' => ts('ID'),
c3fc2621 180 'required' => TRUE,
a36434b9 181 'where' => 'civicrm_financial_account.id',
522a26c9 182 'table_name' => 'civicrm_financial_account',
183 'entity' => 'FinancialAccount',
184 'bao' => 'CRM_Financial_BAO_FinancialAccount',
6a7e5e5d 185 'localizable' => 0,
a9d0587b 186 'add' => '3.2',
c3fc2621
CW
187 ],
188 'name' => [
e501603b
TO
189 'name' => 'name',
190 'type' => CRM_Utils_Type::T_STRING,
c3fc2621 191 'title' => ts('Financial Account Name'),
215b423e 192 'description' => ts('Financial Account Name.'),
c3fc2621 193 'required' => TRUE,
e501603b
TO
194 'maxlength' => 255,
195 'size' => CRM_Utils_Type::HUGE,
a36434b9 196 'where' => 'civicrm_financial_account.name',
522a26c9 197 'table_name' => 'civicrm_financial_account',
198 'entity' => 'FinancialAccount',
199 'bao' => 'CRM_Financial_BAO_FinancialAccount',
6a7e5e5d 200 'localizable' => 0,
a9d0587b 201 'add' => '3.2',
c3fc2621
CW
202 ],
203 'financial_account_contact_id' => [
e501603b
TO
204 'name' => 'contact_id',
205 'type' => CRM_Utils_Type::T_INT,
c3fc2621 206 'title' => ts('Contact ID'),
215b423e 207 'description' => ts('FK to Contact ID that is responsible for the funds in this account'),
a36434b9 208 'where' => 'civicrm_financial_account.contact_id',
522a26c9 209 'table_name' => 'civicrm_financial_account',
210 'entity' => 'FinancialAccount',
211 'bao' => 'CRM_Financial_BAO_FinancialAccount',
6a7e5e5d 212 'localizable' => 0,
e501603b 213 'FKClassName' => 'CRM_Contact_DAO_Contact',
a9d0587b 214 'add' => '4.3',
c3fc2621
CW
215 ],
216 'financial_account_type_id' => [
e501603b
TO
217 'name' => 'financial_account_type_id',
218 'type' => CRM_Utils_Type::T_INT,
c3fc2621 219 'title' => ts('Financial Account Type'),
215b423e 220 'description' => ts('pseudo FK into civicrm_option_value.'),
c3fc2621 221 'required' => TRUE,
a36434b9 222 'where' => 'civicrm_financial_account.financial_account_type_id',
e501603b 223 'default' => '3',
522a26c9 224 'table_name' => 'civicrm_financial_account',
225 'entity' => 'FinancialAccount',
226 'bao' => 'CRM_Financial_BAO_FinancialAccount',
6a7e5e5d 227 'localizable' => 0,
c3fc2621 228 'html' => [
e501603b 229 'type' => 'Select',
c3fc2621
CW
230 ],
231 'pseudoconstant' => [
e501603b
TO
232 'optionGroupName' => 'financial_account_type',
233 'optionEditPath' => 'civicrm/admin/options/financial_account_type',
e6ca0a57 234 ],
a9d0587b 235 'add' => '4.3',
c3fc2621
CW
236 ],
237 'accounting_code' => [
e501603b
TO
238 'name' => 'accounting_code',
239 'type' => CRM_Utils_Type::T_STRING,
c3fc2621 240 'title' => ts('Accounting Code'),
215b423e 241 'description' => ts('Optional value for mapping monies owed and received to accounting system codes.'),
e501603b
TO
242 'maxlength' => 64,
243 'size' => CRM_Utils_Type::BIG,
e501603b 244 'where' => 'civicrm_financial_account.accounting_code',
a36434b9 245 'export' => TRUE,
522a26c9 246 'table_name' => 'civicrm_financial_account',
247 'entity' => 'FinancialAccount',
248 'bao' => 'CRM_Financial_BAO_FinancialAccount',
6a7e5e5d 249 'localizable' => 0,
a9d0587b 250 'add' => '4.3',
c3fc2621
CW
251 ],
252 'account_type_code' => [
e501603b
TO
253 'name' => 'account_type_code',
254 'type' => CRM_Utils_Type::T_STRING,
c3fc2621 255 'title' => ts('Account Type Code'),
215b423e 256 'description' => ts('Optional value for mapping account types to accounting system account categories (QuickBooks Account Type Codes for example).'),
e501603b
TO
257 'maxlength' => 64,
258 'size' => CRM_Utils_Type::BIG,
e501603b 259 'where' => 'civicrm_financial_account.account_type_code',
a36434b9 260 'export' => TRUE,
522a26c9 261 'table_name' => 'civicrm_financial_account',
262 'entity' => 'FinancialAccount',
263 'bao' => 'CRM_Financial_BAO_FinancialAccount',
6a7e5e5d 264 'localizable' => 0,
a9d0587b 265 'add' => '4.3',
c3fc2621
CW
266 ],
267 'description' => [
e501603b
TO
268 'name' => 'description',
269 'type' => CRM_Utils_Type::T_STRING,
c3fc2621 270 'title' => ts('Financial Account Description'),
215b423e 271 'description' => ts('Financial Type Description.'),
e501603b
TO
272 'maxlength' => 255,
273 'size' => CRM_Utils_Type::HUGE,
a36434b9 274 'where' => 'civicrm_financial_account.description',
522a26c9 275 'table_name' => 'civicrm_financial_account',
276 'entity' => 'FinancialAccount',
277 'bao' => 'CRM_Financial_BAO_FinancialAccount',
6a7e5e5d 278 'localizable' => 0,
a9d0587b 279 'add' => '4.3',
c3fc2621
CW
280 ],
281 'parent_id' => [
e501603b
TO
282 'name' => 'parent_id',
283 'type' => CRM_Utils_Type::T_INT,
c3fc2621 284 'title' => ts('Financial Account Parent'),
215b423e 285 'description' => ts('Parent ID in account hierarchy'),
a36434b9 286 'where' => 'civicrm_financial_account.parent_id',
522a26c9 287 'table_name' => 'civicrm_financial_account',
288 'entity' => 'FinancialAccount',
289 'bao' => 'CRM_Financial_BAO_FinancialAccount',
6a7e5e5d 290 'localizable' => 0,
e501603b 291 'FKClassName' => 'CRM_Financial_DAO_FinancialAccount',
a9d0587b 292 'add' => '4.3',
c3fc2621
CW
293 ],
294 'is_header_account' => [
e501603b
TO
295 'name' => 'is_header_account',
296 'type' => CRM_Utils_Type::T_BOOLEAN,
c3fc2621 297 'title' => ts('Header Financial Account?'),
215b423e 298 'description' => ts('Is this a header account which does not allow transactions to be posted against it directly, but only to its sub-accounts?'),
a36434b9 299 'where' => 'civicrm_financial_account.is_header_account',
45a83e42 300 'default' => '0',
522a26c9 301 'table_name' => 'civicrm_financial_account',
302 'entity' => 'FinancialAccount',
303 'bao' => 'CRM_Financial_BAO_FinancialAccount',
6a7e5e5d 304 'localizable' => 0,
a9d0587b 305 'add' => '4.3',
c3fc2621
CW
306 ],
307 'is_deductible' => [
e501603b
TO
308 'name' => 'is_deductible',
309 'type' => CRM_Utils_Type::T_BOOLEAN,
c3fc2621 310 'title' => ts('Deductible Financial Account?'),
215b423e 311 'description' => ts('Is this account tax-deductible?'),
a36434b9 312 'where' => 'civicrm_financial_account.is_deductible',
e501603b 313 'default' => '1',
522a26c9 314 'table_name' => 'civicrm_financial_account',
315 'entity' => 'FinancialAccount',
316 'bao' => 'CRM_Financial_BAO_FinancialAccount',
6a7e5e5d 317 'localizable' => 0,
a9d0587b 318 'add' => '4.3',
c3fc2621
CW
319 ],
320 'is_tax' => [
e501603b
TO
321 'name' => 'is_tax',
322 'type' => CRM_Utils_Type::T_BOOLEAN,
c3fc2621 323 'title' => ts('Tax Financial Account?'),
215b423e 324 'description' => ts('Is this account for taxes?'),
a36434b9 325 'where' => 'civicrm_financial_account.is_tax',
45a83e42 326 'default' => '0',
522a26c9 327 'table_name' => 'civicrm_financial_account',
328 'entity' => 'FinancialAccount',
329 'bao' => 'CRM_Financial_BAO_FinancialAccount',
6a7e5e5d 330 'localizable' => 0,
a9d0587b 331 'add' => '4.3',
c3fc2621
CW
332 ],
333 'tax_rate' => [
e501603b
TO
334 'name' => 'tax_rate',
335 'type' => CRM_Utils_Type::T_MONEY,
c3fc2621 336 'title' => ts('Financial Account Tax Rate'),
215b423e 337 'description' => ts('The percentage of the total_amount that is due for this tax.'),
c3fc2621 338 'precision' => [
e501603b 339 10,
fb607354 340 8,
c3fc2621 341 ],
a36434b9 342 'where' => 'civicrm_financial_account.tax_rate',
522a26c9 343 'table_name' => 'civicrm_financial_account',
344 'entity' => 'FinancialAccount',
345 'bao' => 'CRM_Financial_BAO_FinancialAccount',
6a7e5e5d 346 'localizable' => 0,
a9d0587b 347 'add' => '4.3',
c3fc2621
CW
348 ],
349 'is_reserved' => [
e501603b
TO
350 'name' => 'is_reserved',
351 'type' => CRM_Utils_Type::T_BOOLEAN,
c3fc2621 352 'title' => ts('Reserved Financial Account?'),
215b423e 353 'description' => ts('Is this a predefined system object?'),
a36434b9 354 'where' => 'civicrm_financial_account.is_reserved',
522a26c9 355 'table_name' => 'civicrm_financial_account',
356 'entity' => 'FinancialAccount',
357 'bao' => 'CRM_Financial_BAO_FinancialAccount',
6a7e5e5d 358 'localizable' => 0,
a9d0587b 359 'add' => '4.3',
c3fc2621
CW
360 ],
361 'is_active' => [
e501603b
TO
362 'name' => 'is_active',
363 'type' => CRM_Utils_Type::T_BOOLEAN,
c3fc2621 364 'title' => ts('Financial Account is Active'),
215b423e 365 'description' => ts('Is this property active?'),
a36434b9 366 'where' => 'civicrm_financial_account.is_active',
522a26c9 367 'table_name' => 'civicrm_financial_account',
368 'entity' => 'FinancialAccount',
369 'bao' => 'CRM_Financial_BAO_FinancialAccount',
6a7e5e5d 370 'localizable' => 0,
a9d0587b 371 'add' => '4.3',
c3fc2621
CW
372 ],
373 'is_default' => [
e501603b
TO
374 'name' => 'is_default',
375 'type' => CRM_Utils_Type::T_BOOLEAN,
c3fc2621 376 'title' => ts('Default Financial Account'),
215b423e 377 'description' => ts('Is this account the default one (or default tax one) for its financial_account_type?'),
a36434b9 378 'where' => 'civicrm_financial_account.is_default',
522a26c9 379 'table_name' => 'civicrm_financial_account',
380 'entity' => 'FinancialAccount',
381 'bao' => 'CRM_Financial_BAO_FinancialAccount',
6a7e5e5d 382 'localizable' => 0,
a9d0587b 383 'add' => '4.3',
c3fc2621
CW
384 ],
385 ];
346aaaba 386 CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'fields_callback', Civi::$statics[__CLASS__]['fields']);
e501603b 387 }
346aaaba 388 return Civi::$statics[__CLASS__]['fields'];
e501603b 389 }
c3fc2621 390
e501603b 391 /**
bd8e0b14 392 * Return a mapping from field-name to the corresponding key (as used in fields()).
e501603b
TO
393 *
394 * @return array
bd8e0b14 395 * Array(string $name => string $uniqueName).
e501603b 396 */
c3fc2621 397 public static function &fieldKeys() {
bd8e0b14
TO
398 if (!isset(Civi::$statics[__CLASS__]['fieldKeys'])) {
399 Civi::$statics[__CLASS__]['fieldKeys'] = array_flip(CRM_Utils_Array::collect('name', self::fields()));
e501603b 400 }
bd8e0b14 401 return Civi::$statics[__CLASS__]['fieldKeys'];
e501603b 402 }
c3fc2621 403
e501603b
TO
404 /**
405 * Returns the names of this table
406 *
407 * @return string
408 */
c3fc2621 409 public static function getTableName() {
e501603b
TO
410 return self::$_tableName;
411 }
c3fc2621 412
e501603b
TO
413 /**
414 * Returns if this table needs to be logged
415 *
c3fc2621 416 * @return bool
e501603b 417 */
c3fc2621 418 public function getLog() {
e501603b
TO
419 return self::$_log;
420 }
c3fc2621 421
e501603b
TO
422 /**
423 * Returns the list of fields that can be imported
424 *
425 * @param bool $prefix
426 *
427 * @return array
428 */
c3fc2621
CW
429 public static function &import($prefix = FALSE) {
430 $r = CRM_Core_DAO_AllCoreTables::getImports(__CLASS__, 'financial_account', $prefix, []);
60808919 431 return $r;
e501603b 432 }
c3fc2621 433
e501603b
TO
434 /**
435 * Returns the list of fields that can be exported
436 *
437 * @param bool $prefix
438 *
439 * @return array
440 */
c3fc2621
CW
441 public static function &export($prefix = FALSE) {
442 $r = CRM_Core_DAO_AllCoreTables::getExports(__CLASS__, 'financial_account', $prefix, []);
60808919 443 return $r;
e501603b 444 }
c3fc2621 445
e7a6b91a
AS
446 /**
447 * Returns the list of indices
c3fc2621
CW
448 *
449 * @param bool $localize
450 *
451 * @return array
e7a6b91a
AS
452 */
453 public static function indices($localize = TRUE) {
c3fc2621
CW
454 $indices = [
455 'UI_name' => [
e7a6b91a 456 'name' => 'UI_name',
c3fc2621 457 'field' => [
e7a6b91a 458 0 => 'name',
c3fc2621
CW
459 ],
460 'localizable' => FALSE,
461 'unique' => TRUE,
e7a6b91a 462 'sig' => 'civicrm_financial_account::1::name',
c3fc2621
CW
463 ],
464 ];
e7a6b91a
AS
465 return ($localize && !empty($indices)) ? CRM_Core_DAO_AllCoreTables::multilingualize(__CLASS__, $indices) : $indices;
466 }
c3fc2621 467
e501603b 468}