Commit | Line | Data |
---|---|---|
e501603b TO |
1 | <?php |
2 | /* | |
3 | +--------------------------------------------------------------------+ | |
4 | | CiviCRM version 4.7 | | |
5 | +--------------------------------------------------------------------+ | |
6 | | Copyright CiviCRM LLC (c) 2004-2016 | | |
7 | +--------------------------------------------------------------------+ | |
8 | | This file is a part of CiviCRM. | | |
9 | | | | |
10 | | CiviCRM is free software; you can copy, modify, and distribute it | | |
11 | | under the terms of the GNU Affero General Public License | | |
12 | | Version 3, 19 November 2007 and the CiviCRM Licensing Exception. | | |
13 | | | | |
14 | | CiviCRM is distributed in the hope that it will be useful, but | | |
15 | | WITHOUT ANY WARRANTY; without even the implied warranty of | | |
16 | | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | | |
17 | | See the GNU Affero General Public License for more details. | | |
18 | | | | |
19 | | You should have received a copy of the GNU Affero General Public | | |
20 | | License and the CiviCRM Licensing Exception along | | |
21 | | with this program; if not, contact CiviCRM LLC | | |
22 | | at info[AT]civicrm[DOT]org. If you have questions about the | | |
23 | | GNU Affero General Public License or the licensing of CiviCRM, | | |
24 | | see the CiviCRM license FAQ at http://civicrm.org/licensing | | |
25 | +--------------------------------------------------------------------+ | |
26 | */ | |
27 | /** | |
28 | * @package CRM | |
29 | * @copyright CiviCRM LLC (c) 2004-2016 | |
30 | * | |
31 | * Generated from xml/schema/CRM/Financial/FinancialAccount.xml | |
32 | * DO NOT EDIT. Generated by CRM_Core_CodeGen | |
437fafcf | 33 | * (GenCodeChecksum:f8ca05b54a4b94d2636d0da894b7236f) |
e501603b TO |
34 | */ |
35 | require_once 'CRM/Core/DAO.php'; | |
36 | require_once 'CRM/Utils/Type.php'; | |
37 | class CRM_Financial_DAO_FinancialAccount extends CRM_Core_DAO { | |
38 | /** | |
39 | * static instance to hold the table name | |
40 | * | |
41 | * @var string | |
42 | */ | |
43 | static $_tableName = 'civicrm_financial_account'; | |
44 | /** | |
45 | * static instance to hold the field values | |
46 | * | |
47 | * @var array | |
48 | */ | |
49 | static $_fields = null; | |
50 | /** | |
51 | * static instance to hold the keys used in $_fields for each field. | |
52 | * | |
53 | * @var array | |
54 | */ | |
55 | static $_fieldKeys = null; | |
56 | /** | |
57 | * static instance to hold the FK relationships | |
58 | * | |
59 | * @var string | |
60 | */ | |
61 | static $_links = null; | |
62 | /** | |
63 | * static instance to hold the values that can | |
64 | * be imported | |
65 | * | |
66 | * @var array | |
67 | */ | |
68 | static $_import = null; | |
69 | /** | |
70 | * static instance to hold the values that can | |
71 | * be exported | |
72 | * | |
73 | * @var array | |
74 | */ | |
75 | static $_export = null; | |
76 | /** | |
77 | * static value to see if we should log any modifications to | |
78 | * this table in the civicrm_log table | |
79 | * | |
80 | * @var boolean | |
81 | */ | |
82 | static $_log = true; | |
83 | /** | |
84 | * ID | |
85 | * | |
86 | * @var int unsigned | |
87 | */ | |
88 | public $id; | |
89 | /** | |
90 | * Financial Account Name. | |
91 | * | |
92 | * @var string | |
93 | */ | |
94 | public $name; | |
95 | /** | |
96 | * FK to Contact ID that is responsible for the funds in this account | |
97 | * | |
98 | * @var int unsigned | |
99 | */ | |
100 | public $contact_id; | |
101 | /** | |
102 | * pseudo FK into civicrm_option_value. | |
103 | * | |
104 | * @var int unsigned | |
105 | */ | |
106 | public $financial_account_type_id; | |
107 | /** | |
108 | * Optional value for mapping monies owed and received to accounting system codes. | |
109 | * | |
110 | * @var string | |
111 | */ | |
112 | public $accounting_code; | |
113 | /** | |
114 | * Optional value for mapping account types to accounting system account categories (QuickBooks Account Type Codes for example). | |
115 | * | |
116 | * @var string | |
117 | */ | |
118 | public $account_type_code; | |
119 | /** | |
120 | * Financial Type Description. | |
121 | * | |
122 | * @var string | |
123 | */ | |
124 | public $description; | |
125 | /** | |
126 | * Parent ID in account hierarchy | |
127 | * | |
128 | * @var int unsigned | |
129 | */ | |
130 | public $parent_id; | |
131 | /** | |
132 | * Is this a header account which does not allow transactions to be posted against it directly, but only to its sub-accounts? | |
133 | * | |
134 | * @var boolean | |
135 | */ | |
136 | public $is_header_account; | |
137 | /** | |
138 | * Is this account tax-deductible? | |
139 | * | |
140 | * @var boolean | |
141 | */ | |
142 | public $is_deductible; | |
143 | /** | |
144 | * Is this account for taxes? | |
145 | * | |
146 | * @var boolean | |
147 | */ | |
148 | public $is_tax; | |
149 | /** | |
150 | * The percentage of the total_amount that is due for this tax. | |
151 | * | |
152 | * @var float | |
153 | */ | |
154 | public $tax_rate; | |
155 | /** | |
156 | * Is this a predefined system object? | |
157 | * | |
158 | * @var boolean | |
159 | */ | |
160 | public $is_reserved; | |
161 | /** | |
162 | * Is this property active? | |
163 | * | |
164 | * @var boolean | |
165 | */ | |
166 | public $is_active; | |
167 | /** | |
168 | * Is this account the default one (or default tax one) for its financial_account_type? | |
169 | * | |
170 | * @var boolean | |
171 | */ | |
172 | public $is_default; | |
173 | /** | |
174 | * Contains the opening balance for this financial account | |
175 | * | |
176 | * @var float | |
177 | */ | |
178 | public $opening_balance; | |
179 | /** | |
180 | * Contains the opening balance for the current period for this financial account | |
181 | * | |
182 | * @var float | |
183 | */ | |
184 | public $current_period_opening_balance; | |
185 | /** | |
186 | * class constructor | |
187 | * | |
188 | * @return civicrm_financial_account | |
189 | */ | |
190 | function __construct() { | |
191 | $this->__table = 'civicrm_financial_account'; | |
192 | parent::__construct(); | |
193 | } | |
194 | /** | |
195 | * Returns foreign keys and entity references | |
196 | * | |
197 | * @return array | |
198 | * [CRM_Core_Reference_Interface] | |
199 | */ | |
200 | static function getReferenceColumns() { | |
201 | if (!self::$_links) { | |
202 | self::$_links = static ::createReferenceColumns(__CLASS__); | |
203 | self::$_links[] = new CRM_Core_Reference_Basic(self::getTableName() , 'contact_id', 'civicrm_contact', 'id'); | |
204 | self::$_links[] = new CRM_Core_Reference_Basic(self::getTableName() , 'parent_id', 'civicrm_financial_account', 'id'); | |
205 | } | |
206 | return self::$_links; | |
207 | } | |
208 | /** | |
209 | * Returns all the column names of this table | |
210 | * | |
211 | * @return array | |
212 | */ | |
213 | static function &fields() { | |
214 | if (!(self::$_fields)) { | |
215 | self::$_fields = array( | |
216 | 'id' => array( | |
217 | 'name' => 'id', | |
218 | 'type' => CRM_Utils_Type::T_INT, | |
219 | 'title' => ts('Financial Account ID') , | |
220 | 'description' => 'ID', | |
221 | 'required' => true, | |
222 | ) , | |
223 | 'name' => array( | |
224 | 'name' => 'name', | |
225 | 'type' => CRM_Utils_Type::T_STRING, | |
226 | 'title' => ts('Financial Account Name') , | |
227 | 'description' => 'Financial Account Name.', | |
228 | 'required' => true, | |
229 | 'maxlength' => 255, | |
230 | 'size' => CRM_Utils_Type::HUGE, | |
231 | ) , | |
232 | 'financial_account_contact_id' => array( | |
233 | 'name' => 'contact_id', | |
234 | 'type' => CRM_Utils_Type::T_INT, | |
235 | 'title' => ts('Contact ID') , | |
236 | 'description' => 'FK to Contact ID that is responsible for the funds in this account', | |
237 | 'FKClassName' => 'CRM_Contact_DAO_Contact', | |
238 | ) , | |
239 | 'financial_account_type_id' => array( | |
240 | 'name' => 'financial_account_type_id', | |
241 | 'type' => CRM_Utils_Type::T_INT, | |
242 | 'title' => ts('Financial Account Type') , | |
243 | 'description' => 'pseudo FK into civicrm_option_value.', | |
244 | 'required' => true, | |
245 | 'default' => '3', | |
246 | 'html' => array( | |
247 | 'type' => 'Select', | |
248 | ) , | |
249 | 'pseudoconstant' => array( | |
250 | 'optionGroupName' => 'financial_account_type', | |
251 | 'optionEditPath' => 'civicrm/admin/options/financial_account_type', | |
252 | ) | |
253 | ) , | |
254 | 'accounting_code' => array( | |
255 | 'name' => 'accounting_code', | |
256 | 'type' => CRM_Utils_Type::T_STRING, | |
257 | 'title' => ts('Accounting Code') , | |
258 | 'description' => 'Optional value for mapping monies owed and received to accounting system codes.', | |
259 | 'maxlength' => 64, | |
260 | 'size' => CRM_Utils_Type::BIG, | |
261 | 'export' => true, | |
262 | 'where' => 'civicrm_financial_account.accounting_code', | |
263 | 'headerPattern' => '', | |
264 | 'dataPattern' => '', | |
265 | ) , | |
266 | 'account_type_code' => array( | |
267 | 'name' => 'account_type_code', | |
268 | 'type' => CRM_Utils_Type::T_STRING, | |
269 | 'title' => ts('Account Type Code') , | |
270 | 'description' => 'Optional value for mapping account types to accounting system account categories (QuickBooks Account Type Codes for example).', | |
271 | 'maxlength' => 64, | |
272 | 'size' => CRM_Utils_Type::BIG, | |
273 | 'export' => true, | |
274 | 'where' => 'civicrm_financial_account.account_type_code', | |
275 | 'headerPattern' => '', | |
276 | 'dataPattern' => '', | |
277 | ) , | |
278 | 'description' => array( | |
279 | 'name' => 'description', | |
280 | 'type' => CRM_Utils_Type::T_STRING, | |
281 | 'title' => ts('Financial Account Description') , | |
282 | 'description' => 'Financial Type Description.', | |
283 | 'maxlength' => 255, | |
284 | 'size' => CRM_Utils_Type::HUGE, | |
285 | ) , | |
286 | 'parent_id' => array( | |
287 | 'name' => 'parent_id', | |
288 | 'type' => CRM_Utils_Type::T_INT, | |
289 | 'title' => ts('Financial Account Parent') , | |
290 | 'description' => 'Parent ID in account hierarchy', | |
291 | 'FKClassName' => 'CRM_Financial_DAO_FinancialAccount', | |
292 | ) , | |
293 | 'is_header_account' => array( | |
294 | 'name' => 'is_header_account', | |
295 | 'type' => CRM_Utils_Type::T_BOOLEAN, | |
296 | 'title' => ts('Header Financial Account?') , | |
297 | 'description' => 'Is this a header account which does not allow transactions to be posted against it directly, but only to its sub-accounts?', | |
298 | ) , | |
299 | 'is_deductible' => array( | |
300 | 'name' => 'is_deductible', | |
301 | 'type' => CRM_Utils_Type::T_BOOLEAN, | |
302 | 'title' => ts('Deductible Financial Account?') , | |
303 | 'description' => 'Is this account tax-deductible?', | |
304 | 'default' => '1', | |
305 | ) , | |
306 | 'is_tax' => array( | |
307 | 'name' => 'is_tax', | |
308 | 'type' => CRM_Utils_Type::T_BOOLEAN, | |
309 | 'title' => ts('Tax Financial Account?') , | |
310 | 'description' => 'Is this account for taxes?', | |
311 | ) , | |
312 | 'tax_rate' => array( | |
313 | 'name' => 'tax_rate', | |
314 | 'type' => CRM_Utils_Type::T_MONEY, | |
315 | 'title' => ts('Financial Account Tax Rate') , | |
316 | 'description' => 'The percentage of the total_amount that is due for this tax.', | |
317 | 'precision' => array( | |
318 | 10, | |
319 | 8 | |
320 | ) , | |
321 | ) , | |
322 | 'is_reserved' => array( | |
323 | 'name' => 'is_reserved', | |
324 | 'type' => CRM_Utils_Type::T_BOOLEAN, | |
325 | 'title' => ts('Reserved Financial Account?') , | |
326 | 'description' => 'Is this a predefined system object?', | |
327 | ) , | |
328 | 'is_active' => array( | |
329 | 'name' => 'is_active', | |
330 | 'type' => CRM_Utils_Type::T_BOOLEAN, | |
331 | 'title' => ts('Financial Account is Active') , | |
332 | 'description' => 'Is this property active?', | |
333 | ) , | |
334 | 'is_default' => array( | |
335 | 'name' => 'is_default', | |
336 | 'type' => CRM_Utils_Type::T_BOOLEAN, | |
337 | 'title' => ts('Default Financial Account') , | |
338 | 'description' => 'Is this account the default one (or default tax one) for its financial_account_type?', | |
339 | ) , | |
340 | 'opening_balance' => array( | |
341 | 'name' => 'opening_balance', | |
342 | 'type' => CRM_Utils_Type::T_MONEY, | |
343 | 'title' => ts('Opening Balance') , | |
344 | 'description' => 'Contains the opening balance for this financial account', | |
345 | 'precision' => array( | |
346 | 20, | |
347 | 2 | |
348 | ) , | |
349 | ) , | |
350 | 'current_period_opening_balance' => array( | |
351 | 'name' => 'current_period_opening_balance', | |
352 | 'type' => CRM_Utils_Type::T_MONEY, | |
353 | 'title' => ts('Current period opening Balance') , | |
354 | 'description' => 'Contains the opening balance for the current period for this financial account', | |
355 | 'precision' => array( | |
356 | 20, | |
357 | 2 | |
358 | ) , | |
359 | ) , | |
360 | ); | |
361 | } | |
362 | return self::$_fields; | |
363 | } | |
364 | /** | |
365 | * Returns an array containing, for each field, the arary key used for that | |
366 | * field in self::$_fields. | |
367 | * | |
368 | * @return array | |
369 | */ | |
370 | static function &fieldKeys() { | |
371 | if (!(self::$_fieldKeys)) { | |
372 | self::$_fieldKeys = array( | |
373 | 'id' => 'id', | |
374 | 'name' => 'name', | |
375 | 'contact_id' => 'financial_account_contact_id', | |
376 | 'financial_account_type_id' => 'financial_account_type_id', | |
377 | 'accounting_code' => 'accounting_code', | |
378 | 'account_type_code' => 'account_type_code', | |
379 | 'description' => 'description', | |
380 | 'parent_id' => 'parent_id', | |
381 | 'is_header_account' => 'is_header_account', | |
382 | 'is_deductible' => 'is_deductible', | |
383 | 'is_tax' => 'is_tax', | |
384 | 'tax_rate' => 'tax_rate', | |
385 | 'is_reserved' => 'is_reserved', | |
386 | 'is_active' => 'is_active', | |
387 | 'is_default' => 'is_default', | |
388 | 'opening_balance' => 'opening_balance', | |
389 | 'current_period_opening_balance' => 'current_period_opening_balance', | |
390 | ); | |
391 | } | |
392 | return self::$_fieldKeys; | |
393 | } | |
394 | /** | |
395 | * Returns the names of this table | |
396 | * | |
397 | * @return string | |
398 | */ | |
399 | static function getTableName() { | |
400 | return self::$_tableName; | |
401 | } | |
402 | /** | |
403 | * Returns if this table needs to be logged | |
404 | * | |
405 | * @return boolean | |
406 | */ | |
407 | function getLog() { | |
408 | return self::$_log; | |
409 | } | |
410 | /** | |
411 | * Returns the list of fields that can be imported | |
412 | * | |
413 | * @param bool $prefix | |
414 | * | |
415 | * @return array | |
416 | */ | |
417 | static function &import($prefix = false) { | |
418 | if (!(self::$_import)) { | |
419 | self::$_import = array(); | |
420 | $fields = self::fields(); | |
421 | foreach($fields as $name => $field) { | |
422 | if (CRM_Utils_Array::value('import', $field)) { | |
423 | if ($prefix) { | |
424 | self::$_import['financial_account'] = & $fields[$name]; | |
425 | } else { | |
426 | self::$_import[$name] = & $fields[$name]; | |
427 | } | |
428 | } | |
429 | } | |
430 | } | |
431 | return self::$_import; | |
432 | } | |
433 | /** | |
434 | * Returns the list of fields that can be exported | |
435 | * | |
436 | * @param bool $prefix | |
437 | * | |
438 | * @return array | |
439 | */ | |
440 | static function &export($prefix = false) { | |
441 | if (!(self::$_export)) { | |
442 | self::$_export = array(); | |
443 | $fields = self::fields(); | |
444 | foreach($fields as $name => $field) { | |
445 | if (CRM_Utils_Array::value('export', $field)) { | |
446 | if ($prefix) { | |
447 | self::$_export['financial_account'] = & $fields[$name]; | |
448 | } else { | |
449 | self::$_export[$name] = & $fields[$name]; | |
450 | } | |
451 | } | |
452 | } | |
453 | } | |
454 | return self::$_export; | |
455 | } | |
456 | } |