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