DAOs with singular/plural options for entity titles
[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:09d2e3d6a970fa2413b6f29ab1f580e0)
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 * @param bool $plural
150 * Whether to return the plural version of the title.
151 */
152 public static function getEntityTitle($plural = FALSE) {
153 return $plural ? ts('Financial Accounts') : ts('Financial Account');
154 }
155
156 /**
157 * Returns foreign keys and entity references.
158 *
159 * @return array
160 * [CRM_Core_Reference_Interface]
161 */
162 public static function getReferenceColumns() {
163 if (!isset(Civi::$statics[__CLASS__]['links'])) {
164 Civi::$statics[__CLASS__]['links'] = static::createReferenceColumns(__CLASS__);
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');
167 CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'links_callback', Civi::$statics[__CLASS__]['links']);
168 }
169 return Civi::$statics[__CLASS__]['links'];
170 }
171
172 /**
173 * Returns all the column names of this table
174 *
175 * @return array
176 */
177 public static function &fields() {
178 if (!isset(Civi::$statics[__CLASS__]['fields'])) {
179 Civi::$statics[__CLASS__]['fields'] = [
180 'id' => [
181 'name' => 'id',
182 'type' => CRM_Utils_Type::T_INT,
183 'title' => ts('Financial Account ID'),
184 'description' => ts('ID'),
185 'required' => TRUE,
186 'where' => 'civicrm_financial_account.id',
187 'table_name' => 'civicrm_financial_account',
188 'entity' => 'FinancialAccount',
189 'bao' => 'CRM_Financial_BAO_FinancialAccount',
190 'localizable' => 0,
191 'add' => '3.2',
192 ],
193 'name' => [
194 'name' => 'name',
195 'type' => CRM_Utils_Type::T_STRING,
196 'title' => ts('Financial Account Name'),
197 'description' => ts('Financial Account Name.'),
198 'required' => TRUE,
199 'maxlength' => 255,
200 'size' => CRM_Utils_Type::HUGE,
201 'where' => 'civicrm_financial_account.name',
202 'table_name' => 'civicrm_financial_account',
203 'entity' => 'FinancialAccount',
204 'bao' => 'CRM_Financial_BAO_FinancialAccount',
205 'localizable' => 0,
206 'add' => '3.2',
207 ],
208 'financial_account_contact_id' => [
209 'name' => 'contact_id',
210 'type' => CRM_Utils_Type::T_INT,
211 'title' => ts('Contact ID'),
212 'description' => ts('FK to Contact ID that is responsible for the funds in this account'),
213 'where' => 'civicrm_financial_account.contact_id',
214 'table_name' => 'civicrm_financial_account',
215 'entity' => 'FinancialAccount',
216 'bao' => 'CRM_Financial_BAO_FinancialAccount',
217 'localizable' => 0,
218 'FKClassName' => 'CRM_Contact_DAO_Contact',
219 'add' => '4.3',
220 ],
221 'financial_account_type_id' => [
222 'name' => 'financial_account_type_id',
223 'type' => CRM_Utils_Type::T_INT,
224 'title' => ts('Financial Account Type'),
225 'description' => ts('pseudo FK into civicrm_option_value.'),
226 'required' => TRUE,
227 'where' => 'civicrm_financial_account.financial_account_type_id',
228 'default' => '3',
229 'table_name' => 'civicrm_financial_account',
230 'entity' => 'FinancialAccount',
231 'bao' => 'CRM_Financial_BAO_FinancialAccount',
232 'localizable' => 0,
233 'html' => [
234 'type' => 'Select',
235 ],
236 'pseudoconstant' => [
237 'optionGroupName' => 'financial_account_type',
238 'optionEditPath' => 'civicrm/admin/options/financial_account_type',
239 ],
240 'add' => '4.3',
241 ],
242 'accounting_code' => [
243 'name' => 'accounting_code',
244 'type' => CRM_Utils_Type::T_STRING,
245 'title' => ts('Accounting Code'),
246 'description' => ts('Optional value for mapping monies owed and received to accounting system codes.'),
247 'maxlength' => 64,
248 'size' => CRM_Utils_Type::BIG,
249 'where' => 'civicrm_financial_account.accounting_code',
250 'export' => TRUE,
251 'table_name' => 'civicrm_financial_account',
252 'entity' => 'FinancialAccount',
253 'bao' => 'CRM_Financial_BAO_FinancialAccount',
254 'localizable' => 0,
255 'add' => '4.3',
256 ],
257 'account_type_code' => [
258 'name' => 'account_type_code',
259 'type' => CRM_Utils_Type::T_STRING,
260 'title' => ts('Account Type Code'),
261 'description' => ts('Optional value for mapping account types to accounting system account categories (QuickBooks Account Type Codes for example).'),
262 'maxlength' => 64,
263 'size' => CRM_Utils_Type::BIG,
264 'where' => 'civicrm_financial_account.account_type_code',
265 'export' => TRUE,
266 'table_name' => 'civicrm_financial_account',
267 'entity' => 'FinancialAccount',
268 'bao' => 'CRM_Financial_BAO_FinancialAccount',
269 'localizable' => 0,
270 'add' => '4.3',
271 ],
272 'description' => [
273 'name' => 'description',
274 'type' => CRM_Utils_Type::T_STRING,
275 'title' => ts('Financial Account Description'),
276 'description' => ts('Financial Type Description.'),
277 'maxlength' => 255,
278 'size' => CRM_Utils_Type::HUGE,
279 'where' => 'civicrm_financial_account.description',
280 'table_name' => 'civicrm_financial_account',
281 'entity' => 'FinancialAccount',
282 'bao' => 'CRM_Financial_BAO_FinancialAccount',
283 'localizable' => 0,
284 'add' => '4.3',
285 ],
286 'parent_id' => [
287 'name' => 'parent_id',
288 'type' => CRM_Utils_Type::T_INT,
289 'title' => ts('Financial Account Parent'),
290 'description' => ts('Parent ID in account hierarchy'),
291 'where' => 'civicrm_financial_account.parent_id',
292 'table_name' => 'civicrm_financial_account',
293 'entity' => 'FinancialAccount',
294 'bao' => 'CRM_Financial_BAO_FinancialAccount',
295 'localizable' => 0,
296 'FKClassName' => 'CRM_Financial_DAO_FinancialAccount',
297 'add' => '4.3',
298 ],
299 'is_header_account' => [
300 'name' => 'is_header_account',
301 'type' => CRM_Utils_Type::T_BOOLEAN,
302 'title' => ts('Header Financial Account?'),
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?'),
304 'where' => 'civicrm_financial_account.is_header_account',
305 'default' => '0',
306 'table_name' => 'civicrm_financial_account',
307 'entity' => 'FinancialAccount',
308 'bao' => 'CRM_Financial_BAO_FinancialAccount',
309 'localizable' => 0,
310 'add' => '4.3',
311 ],
312 'is_deductible' => [
313 'name' => 'is_deductible',
314 'type' => CRM_Utils_Type::T_BOOLEAN,
315 'title' => ts('Deductible Financial Account?'),
316 'description' => ts('Is this account tax-deductible?'),
317 'where' => 'civicrm_financial_account.is_deductible',
318 'default' => '1',
319 'table_name' => 'civicrm_financial_account',
320 'entity' => 'FinancialAccount',
321 'bao' => 'CRM_Financial_BAO_FinancialAccount',
322 'localizable' => 0,
323 'add' => '4.3',
324 ],
325 'is_tax' => [
326 'name' => 'is_tax',
327 'type' => CRM_Utils_Type::T_BOOLEAN,
328 'title' => ts('Tax Financial Account?'),
329 'description' => ts('Is this account for taxes?'),
330 'where' => 'civicrm_financial_account.is_tax',
331 'default' => '0',
332 'table_name' => 'civicrm_financial_account',
333 'entity' => 'FinancialAccount',
334 'bao' => 'CRM_Financial_BAO_FinancialAccount',
335 'localizable' => 0,
336 'add' => '4.3',
337 ],
338 'tax_rate' => [
339 'name' => 'tax_rate',
340 'type' => CRM_Utils_Type::T_MONEY,
341 'title' => ts('Financial Account Tax Rate'),
342 'description' => ts('The percentage of the total_amount that is due for this tax.'),
343 'precision' => [
344 10,
345 8,
346 ],
347 'where' => 'civicrm_financial_account.tax_rate',
348 'table_name' => 'civicrm_financial_account',
349 'entity' => 'FinancialAccount',
350 'bao' => 'CRM_Financial_BAO_FinancialAccount',
351 'localizable' => 0,
352 'add' => '4.3',
353 ],
354 'is_reserved' => [
355 'name' => 'is_reserved',
356 'type' => CRM_Utils_Type::T_BOOLEAN,
357 'title' => ts('Reserved Financial Account?'),
358 'description' => ts('Is this a predefined system object?'),
359 'where' => 'civicrm_financial_account.is_reserved',
360 'table_name' => 'civicrm_financial_account',
361 'entity' => 'FinancialAccount',
362 'bao' => 'CRM_Financial_BAO_FinancialAccount',
363 'localizable' => 0,
364 'add' => '4.3',
365 ],
366 'is_active' => [
367 'name' => 'is_active',
368 'type' => CRM_Utils_Type::T_BOOLEAN,
369 'title' => ts('Financial Account is Active'),
370 'description' => ts('Is this property active?'),
371 'where' => 'civicrm_financial_account.is_active',
372 'table_name' => 'civicrm_financial_account',
373 'entity' => 'FinancialAccount',
374 'bao' => 'CRM_Financial_BAO_FinancialAccount',
375 'localizable' => 0,
376 'add' => '4.3',
377 ],
378 'is_default' => [
379 'name' => 'is_default',
380 'type' => CRM_Utils_Type::T_BOOLEAN,
381 'title' => ts('Default Financial Account'),
382 'description' => ts('Is this account the default one (or default tax one) for its financial_account_type?'),
383 'where' => 'civicrm_financial_account.is_default',
384 'table_name' => 'civicrm_financial_account',
385 'entity' => 'FinancialAccount',
386 'bao' => 'CRM_Financial_BAO_FinancialAccount',
387 'localizable' => 0,
388 'add' => '4.3',
389 ],
390 ];
391 CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'fields_callback', Civi::$statics[__CLASS__]['fields']);
392 }
393 return Civi::$statics[__CLASS__]['fields'];
394 }
395
396 /**
397 * Return a mapping from field-name to the corresponding key (as used in fields()).
398 *
399 * @return array
400 * Array(string $name => string $uniqueName).
401 */
402 public static function &fieldKeys() {
403 if (!isset(Civi::$statics[__CLASS__]['fieldKeys'])) {
404 Civi::$statics[__CLASS__]['fieldKeys'] = array_flip(CRM_Utils_Array::collect('name', self::fields()));
405 }
406 return Civi::$statics[__CLASS__]['fieldKeys'];
407 }
408
409 /**
410 * Returns the names of this table
411 *
412 * @return string
413 */
414 public static function getTableName() {
415 return self::$_tableName;
416 }
417
418 /**
419 * Returns if this table needs to be logged
420 *
421 * @return bool
422 */
423 public function getLog() {
424 return self::$_log;
425 }
426
427 /**
428 * Returns the list of fields that can be imported
429 *
430 * @param bool $prefix
431 *
432 * @return array
433 */
434 public static function &import($prefix = FALSE) {
435 $r = CRM_Core_DAO_AllCoreTables::getImports(__CLASS__, 'financial_account', $prefix, []);
436 return $r;
437 }
438
439 /**
440 * Returns the list of fields that can be exported
441 *
442 * @param bool $prefix
443 *
444 * @return array
445 */
446 public static function &export($prefix = FALSE) {
447 $r = CRM_Core_DAO_AllCoreTables::getExports(__CLASS__, 'financial_account', $prefix, []);
448 return $r;
449 }
450
451 /**
452 * Returns the list of indices
453 *
454 * @param bool $localize
455 *
456 * @return array
457 */
458 public static function indices($localize = TRUE) {
459 $indices = [
460 'UI_name' => [
461 'name' => 'UI_name',
462 'field' => [
463 0 => 'name',
464 ],
465 'localizable' => FALSE,
466 'unique' => TRUE,
467 'sig' => 'civicrm_financial_account::1::name',
468 ],
469 ];
470 return ($localize && !empty($indices)) ? CRM_Core_DAO_AllCoreTables::multilingualize(__CLASS__, $indices) : $indices;
471 }
472
473 }