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