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