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