Merge pull request #13343 from GinkgoFJG/case-issues-w-ufgroup-api
[civicrm-core.git] / CRM / Financial / DAO / FinancialAccount.php
1 <?php
2
3 /**
4 * @package CRM
5 * @copyright CiviCRM LLC (c) 2004-2019
6 *
7 * Generated from xml/schema/CRM/Financial/FinancialAccount.xml
8 * DO NOT EDIT. Generated by CRM_Core_CodeGen
9 * (GenCodeChecksum:99e6943d33c4b4081a8d74e611589dd7)
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 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 static $_log = TRUE;
30
31 /**
32 * ID
33 *
34 * @var int unsigned
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 unsigned
49 */
50 public $contact_id;
51
52 /**
53 * pseudo FK into civicrm_option_value.
54 *
55 * @var int unsigned
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 unsigned
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 boolean
91 */
92 public $is_header_account;
93
94 /**
95 * Is this account tax-deductible?
96 *
97 * @var boolean
98 */
99 public $is_deductible;
100
101 /**
102 * Is this account for taxes?
103 *
104 * @var boolean
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 boolean
119 */
120 public $is_reserved;
121
122 /**
123 * Is this property active?
124 *
125 * @var boolean
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 boolean
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 foreign keys and entity references.
146 *
147 * @return array
148 * [CRM_Core_Reference_Interface]
149 */
150 public static function getReferenceColumns() {
151 if (!isset(Civi::$statics[__CLASS__]['links'])) {
152 Civi::$statics[__CLASS__]['links'] = static ::createReferenceColumns(__CLASS__);
153 Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName(), 'contact_id', 'civicrm_contact', 'id');
154 Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName(), 'parent_id', 'civicrm_financial_account', 'id');
155 CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'links_callback', Civi::$statics[__CLASS__]['links']);
156 }
157 return Civi::$statics[__CLASS__]['links'];
158 }
159
160 /**
161 * Returns all the column names of this table
162 *
163 * @return array
164 */
165 public static function &fields() {
166 if (!isset(Civi::$statics[__CLASS__]['fields'])) {
167 Civi::$statics[__CLASS__]['fields'] = [
168 'id' => [
169 'name' => 'id',
170 'type' => CRM_Utils_Type::T_INT,
171 'title' => ts('Financial Account ID'),
172 'description' => ts('ID'),
173 'required' => TRUE,
174 'table_name' => 'civicrm_financial_account',
175 'entity' => 'FinancialAccount',
176 'bao' => 'CRM_Financial_BAO_FinancialAccount',
177 'localizable' => 0,
178 ],
179 'name' => [
180 'name' => 'name',
181 'type' => CRM_Utils_Type::T_STRING,
182 'title' => ts('Financial Account Name'),
183 'description' => ts('Financial Account Name.'),
184 'required' => TRUE,
185 'maxlength' => 255,
186 'size' => CRM_Utils_Type::HUGE,
187 'table_name' => 'civicrm_financial_account',
188 'entity' => 'FinancialAccount',
189 'bao' => 'CRM_Financial_BAO_FinancialAccount',
190 'localizable' => 0,
191 ],
192 'financial_account_contact_id' => [
193 'name' => 'contact_id',
194 'type' => CRM_Utils_Type::T_INT,
195 'title' => ts('Contact ID'),
196 'description' => ts('FK to Contact ID that is responsible for the funds in this account'),
197 'table_name' => 'civicrm_financial_account',
198 'entity' => 'FinancialAccount',
199 'bao' => 'CRM_Financial_BAO_FinancialAccount',
200 'localizable' => 0,
201 'FKClassName' => 'CRM_Contact_DAO_Contact',
202 ],
203 'financial_account_type_id' => [
204 'name' => 'financial_account_type_id',
205 'type' => CRM_Utils_Type::T_INT,
206 'title' => ts('Financial Account Type'),
207 'description' => ts('pseudo FK into civicrm_option_value.'),
208 'required' => TRUE,
209 'default' => '3',
210 'table_name' => 'civicrm_financial_account',
211 'entity' => 'FinancialAccount',
212 'bao' => 'CRM_Financial_BAO_FinancialAccount',
213 'localizable' => 0,
214 'html' => [
215 'type' => 'Select',
216 ],
217 'pseudoconstant' => [
218 'optionGroupName' => 'financial_account_type',
219 'optionEditPath' => 'civicrm/admin/options/financial_account_type',
220 ]
221 ],
222 'accounting_code' => [
223 'name' => 'accounting_code',
224 'type' => CRM_Utils_Type::T_STRING,
225 'title' => ts('Accounting Code'),
226 'description' => ts('Optional value for mapping monies owed and received to accounting system codes.'),
227 'maxlength' => 64,
228 'size' => CRM_Utils_Type::BIG,
229 'export' => TRUE,
230 'where' => 'civicrm_financial_account.accounting_code',
231 'headerPattern' => '',
232 'dataPattern' => '',
233 'table_name' => 'civicrm_financial_account',
234 'entity' => 'FinancialAccount',
235 'bao' => 'CRM_Financial_BAO_FinancialAccount',
236 'localizable' => 0,
237 ],
238 'account_type_code' => [
239 'name' => 'account_type_code',
240 'type' => CRM_Utils_Type::T_STRING,
241 'title' => ts('Account Type Code'),
242 'description' => ts('Optional value for mapping account types to accounting system account categories (QuickBooks Account Type Codes for example).'),
243 'maxlength' => 64,
244 'size' => CRM_Utils_Type::BIG,
245 'export' => TRUE,
246 'where' => 'civicrm_financial_account.account_type_code',
247 'headerPattern' => '',
248 'dataPattern' => '',
249 'table_name' => 'civicrm_financial_account',
250 'entity' => 'FinancialAccount',
251 'bao' => 'CRM_Financial_BAO_FinancialAccount',
252 'localizable' => 0,
253 ],
254 'description' => [
255 'name' => 'description',
256 'type' => CRM_Utils_Type::T_STRING,
257 'title' => ts('Financial Account Description'),
258 'description' => ts('Financial Type Description.'),
259 'maxlength' => 255,
260 'size' => CRM_Utils_Type::HUGE,
261 'table_name' => 'civicrm_financial_account',
262 'entity' => 'FinancialAccount',
263 'bao' => 'CRM_Financial_BAO_FinancialAccount',
264 'localizable' => 0,
265 ],
266 'parent_id' => [
267 'name' => 'parent_id',
268 'type' => CRM_Utils_Type::T_INT,
269 'title' => ts('Financial Account Parent'),
270 'description' => ts('Parent ID in account hierarchy'),
271 'table_name' => 'civicrm_financial_account',
272 'entity' => 'FinancialAccount',
273 'bao' => 'CRM_Financial_BAO_FinancialAccount',
274 'localizable' => 0,
275 'FKClassName' => 'CRM_Financial_DAO_FinancialAccount',
276 ],
277 'is_header_account' => [
278 'name' => 'is_header_account',
279 'type' => CRM_Utils_Type::T_BOOLEAN,
280 'title' => ts('Header Financial Account?'),
281 'description' => ts('Is this a header account which does not allow transactions to be posted against it directly, but only to its sub-accounts?'),
282 'default' => '0',
283 'table_name' => 'civicrm_financial_account',
284 'entity' => 'FinancialAccount',
285 'bao' => 'CRM_Financial_BAO_FinancialAccount',
286 'localizable' => 0,
287 ],
288 'is_deductible' => [
289 'name' => 'is_deductible',
290 'type' => CRM_Utils_Type::T_BOOLEAN,
291 'title' => ts('Deductible Financial Account?'),
292 'description' => ts('Is this account tax-deductible?'),
293 'default' => '1',
294 'table_name' => 'civicrm_financial_account',
295 'entity' => 'FinancialAccount',
296 'bao' => 'CRM_Financial_BAO_FinancialAccount',
297 'localizable' => 0,
298 ],
299 'is_tax' => [
300 'name' => 'is_tax',
301 'type' => CRM_Utils_Type::T_BOOLEAN,
302 'title' => ts('Tax Financial Account?'),
303 'description' => ts('Is this account for taxes?'),
304 'default' => '0',
305 'table_name' => 'civicrm_financial_account',
306 'entity' => 'FinancialAccount',
307 'bao' => 'CRM_Financial_BAO_FinancialAccount',
308 'localizable' => 0,
309 ],
310 'tax_rate' => [
311 'name' => 'tax_rate',
312 'type' => CRM_Utils_Type::T_MONEY,
313 'title' => ts('Financial Account Tax Rate'),
314 'description' => ts('The percentage of the total_amount that is due for this tax.'),
315 'precision' => [
316 10,
317 8
318 ],
319 'table_name' => 'civicrm_financial_account',
320 'entity' => 'FinancialAccount',
321 'bao' => 'CRM_Financial_BAO_FinancialAccount',
322 'localizable' => 0,
323 ],
324 'is_reserved' => [
325 'name' => 'is_reserved',
326 'type' => CRM_Utils_Type::T_BOOLEAN,
327 'title' => ts('Reserved Financial Account?'),
328 'description' => ts('Is this a predefined system object?'),
329 'table_name' => 'civicrm_financial_account',
330 'entity' => 'FinancialAccount',
331 'bao' => 'CRM_Financial_BAO_FinancialAccount',
332 'localizable' => 0,
333 ],
334 'is_active' => [
335 'name' => 'is_active',
336 'type' => CRM_Utils_Type::T_BOOLEAN,
337 'title' => ts('Financial Account is Active'),
338 'description' => ts('Is this property active?'),
339 'table_name' => 'civicrm_financial_account',
340 'entity' => 'FinancialAccount',
341 'bao' => 'CRM_Financial_BAO_FinancialAccount',
342 'localizable' => 0,
343 ],
344 'is_default' => [
345 'name' => 'is_default',
346 'type' => CRM_Utils_Type::T_BOOLEAN,
347 'title' => ts('Default Financial Account'),
348 'description' => ts('Is this account the default one (or default tax one) for its financial_account_type?'),
349 'table_name' => 'civicrm_financial_account',
350 'entity' => 'FinancialAccount',
351 'bao' => 'CRM_Financial_BAO_FinancialAccount',
352 'localizable' => 0,
353 ],
354 ];
355 CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'fields_callback', Civi::$statics[__CLASS__]['fields']);
356 }
357 return Civi::$statics[__CLASS__]['fields'];
358 }
359
360 /**
361 * Return a mapping from field-name to the corresponding key (as used in fields()).
362 *
363 * @return array
364 * Array(string $name => string $uniqueName).
365 */
366 public static function &fieldKeys() {
367 if (!isset(Civi::$statics[__CLASS__]['fieldKeys'])) {
368 Civi::$statics[__CLASS__]['fieldKeys'] = array_flip(CRM_Utils_Array::collect('name', self::fields()));
369 }
370 return Civi::$statics[__CLASS__]['fieldKeys'];
371 }
372
373 /**
374 * Returns the names of this table
375 *
376 * @return string
377 */
378 public static function getTableName() {
379 return self::$_tableName;
380 }
381
382 /**
383 * Returns if this table needs to be logged
384 *
385 * @return bool
386 */
387 public function getLog() {
388 return self::$_log;
389 }
390
391 /**
392 * Returns the list of fields that can be imported
393 *
394 * @param bool $prefix
395 *
396 * @return array
397 */
398 public static function &import($prefix = FALSE) {
399 $r = CRM_Core_DAO_AllCoreTables::getImports(__CLASS__, 'financial_account', $prefix, []);
400 return $r;
401 }
402
403 /**
404 * Returns the list of fields that can be exported
405 *
406 * @param bool $prefix
407 *
408 * @return array
409 */
410 public static function &export($prefix = FALSE) {
411 $r = CRM_Core_DAO_AllCoreTables::getExports(__CLASS__, 'financial_account', $prefix, []);
412 return $r;
413 }
414
415 /**
416 * Returns the list of indices
417 *
418 * @param bool $localize
419 *
420 * @return array
421 */
422 public static function indices($localize = TRUE) {
423 $indices = [
424 'UI_name' => [
425 'name' => 'UI_name',
426 'field' => [
427 0 => 'name',
428 ],
429 'localizable' => FALSE,
430 'unique' => TRUE,
431 'sig' => 'civicrm_financial_account::1::name',
432 ],
433 ];
434 return ($localize && !empty($indices)) ? CRM_Core_DAO_AllCoreTables::multilingualize(__CLASS__, $indices) : $indices;
435 }
436
437 }