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