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