5 * @copyright CiviCRM LLC https://civicrm.org/licensing
7 * Generated from xml/schema/CRM/Financial/FinancialAccount.xml
8 * DO NOT EDIT. Generated by CRM_Core_CodeGen
9 * (GenCodeChecksum:ae32a35de5bc66a8e230b5595b77810f)
13 * Database access object for the FinancialAccount entity.
15 class CRM_Financial_DAO_FinancialAccount
extends CRM_Core_DAO
{
16 const EXT
= 'civicrm';
17 const TABLE_ADDED
= '3.2';
18 const COMPONENT
= 'CiviContribute';
21 * Static instance to hold the table name.
25 public static $_tableName = 'civicrm_financial_account';
28 * Should CiviCRM log any modifications to this table in the civicrm_log table.
32 public static $_log = TRUE;
37 * @var int|string|null
38 * (SQL type: int unsigned)
39 * Note that values will be retrieved from the database as a string.
44 * Financial Account Name.
47 * (SQL type: varchar(255))
48 * Note that values will be retrieved from the database as a string.
53 * FK to Contact ID that is responsible for the funds in this account
55 * @var int|string|null
56 * (SQL type: int unsigned)
57 * Note that values will be retrieved from the database as a string.
62 * pseudo FK into civicrm_option_value.
65 * (SQL type: int unsigned)
66 * Note that values will be retrieved from the database as a string.
68 public $financial_account_type_id;
71 * Optional value for mapping monies owed and received to accounting system codes.
74 * (SQL type: varchar(64))
75 * Note that values will be retrieved from the database as a string.
77 public $accounting_code;
80 * Optional value for mapping account types to accounting system account categories (QuickBooks Account Type Codes for example).
83 * (SQL type: varchar(64))
84 * Note that values will be retrieved from the database as a string.
86 public $account_type_code;
89 * Financial Type Description.
92 * (SQL type: varchar(255))
93 * Note that values will be retrieved from the database as a string.
98 * Parent ID in account hierarchy
100 * @var int|string|null
101 * (SQL type: int unsigned)
102 * Note that values will be retrieved from the database as a string.
107 * Is this a header account which does not allow transactions to be posted against it directly, but only to its sub-accounts?
109 * @var bool|string|null
110 * (SQL type: tinyint)
111 * Note that values will be retrieved from the database as a string.
113 public $is_header_account;
116 * Is this account tax-deductible?
118 * @var bool|string|null
119 * (SQL type: tinyint)
120 * Note that values will be retrieved from the database as a string.
122 public $is_deductible;
125 * Is this account for taxes?
127 * @var bool|string|null
128 * (SQL type: tinyint)
129 * Note that values will be retrieved from the database as a string.
134 * The percentage of the total_amount that is due for this tax.
136 * @var float|string|null
137 * (SQL type: decimal(10,8))
138 * Note that values will be retrieved from the database as a string.
143 * Is this a predefined system object?
145 * @var bool|string|null
146 * (SQL type: tinyint)
147 * Note that values will be retrieved from the database as a string.
152 * Is this property active?
154 * @var bool|string|null
155 * (SQL type: tinyint)
156 * Note that values will be retrieved from the database as a string.
161 * Is this account the default one (or default tax one) for its financial_account_type?
163 * @var bool|string|null
164 * (SQL type: tinyint)
165 * Note that values will be retrieved from the database as a string.
172 public function __construct() {
173 $this->__table
= 'civicrm_financial_account';
174 parent
::__construct();
178 * Returns localized title of this entity.
180 * @param bool $plural
181 * Whether to return the plural version of the title.
183 public static function getEntityTitle($plural = FALSE) {
184 return $plural ?
ts('Financial Accounts') : ts('Financial Account');
188 * Returns foreign keys and entity references.
191 * [CRM_Core_Reference_Interface]
193 public static function getReferenceColumns() {
194 if (!isset(Civi
::$statics[__CLASS__
]['links'])) {
195 Civi
::$statics[__CLASS__
]['links'] = static::createReferenceColumns(__CLASS__
);
196 Civi
::$statics[__CLASS__
]['links'][] = new CRM_Core_Reference_Basic(self
::getTableName(), 'contact_id', 'civicrm_contact', 'id');
197 Civi
::$statics[__CLASS__
]['links'][] = new CRM_Core_Reference_Basic(self
::getTableName(), 'parent_id', 'civicrm_financial_account', 'id');
198 CRM_Core_DAO_AllCoreTables
::invoke(__CLASS__
, 'links_callback', Civi
::$statics[__CLASS__
]['links']);
200 return Civi
::$statics[__CLASS__
]['links'];
204 * Returns all the column names of this table
208 public static function &fields() {
209 if (!isset(Civi
::$statics[__CLASS__
]['fields'])) {
210 Civi
::$statics[__CLASS__
]['fields'] = [
213 'type' => CRM_Utils_Type
::T_INT
,
214 'title' => ts('Financial Account ID'),
215 'description' => ts('ID'),
217 'where' => 'civicrm_financial_account.id',
218 'table_name' => 'civicrm_financial_account',
219 'entity' => 'FinancialAccount',
220 'bao' => 'CRM_Financial_BAO_FinancialAccount',
230 'type' => CRM_Utils_Type
::T_STRING
,
231 'title' => ts('Financial Account Name'),
232 'description' => ts('Financial Account Name.'),
235 'size' => CRM_Utils_Type
::HUGE
,
236 'where' => 'civicrm_financial_account.name',
237 'table_name' => 'civicrm_financial_account',
238 'entity' => 'FinancialAccount',
239 'bao' => 'CRM_Financial_BAO_FinancialAccount',
243 'financial_account_contact_id' => [
244 'name' => 'contact_id',
245 'type' => CRM_Utils_Type
::T_INT
,
246 'title' => ts('Contact ID'),
247 'description' => ts('FK to Contact ID that is responsible for the funds in this account'),
248 'where' => 'civicrm_financial_account.contact_id',
249 'table_name' => 'civicrm_financial_account',
250 'entity' => 'FinancialAccount',
251 'bao' => 'CRM_Financial_BAO_FinancialAccount',
253 'FKClassName' => 'CRM_Contact_DAO_Contact',
255 'label' => ts("Contact"),
259 'financial_account_type_id' => [
260 'name' => 'financial_account_type_id',
261 'type' => CRM_Utils_Type
::T_INT
,
262 'title' => ts('Financial Account Type'),
263 'description' => ts('pseudo FK into civicrm_option_value.'),
265 'where' => 'civicrm_financial_account.financial_account_type_id',
267 'table_name' => 'civicrm_financial_account',
268 'entity' => 'FinancialAccount',
269 'bao' => 'CRM_Financial_BAO_FinancialAccount',
274 'pseudoconstant' => [
275 'optionGroupName' => 'financial_account_type',
276 'optionEditPath' => 'civicrm/admin/options/financial_account_type',
280 'accounting_code' => [
281 'name' => 'accounting_code',
282 'type' => CRM_Utils_Type
::T_STRING
,
283 'title' => ts('Accounting Code'),
284 'description' => ts('Optional value for mapping monies owed and received to accounting system codes.'),
286 'size' => CRM_Utils_Type
::BIG
,
287 'where' => 'civicrm_financial_account.accounting_code',
289 'table_name' => 'civicrm_financial_account',
290 'entity' => 'FinancialAccount',
291 'bao' => 'CRM_Financial_BAO_FinancialAccount',
295 'account_type_code' => [
296 'name' => 'account_type_code',
297 'type' => CRM_Utils_Type
::T_STRING
,
298 'title' => ts('Account Type Code'),
299 'description' => ts('Optional value for mapping account types to accounting system account categories (QuickBooks Account Type Codes for example).'),
301 'size' => CRM_Utils_Type
::BIG
,
302 'where' => 'civicrm_financial_account.account_type_code',
304 'table_name' => 'civicrm_financial_account',
305 'entity' => 'FinancialAccount',
306 'bao' => 'CRM_Financial_BAO_FinancialAccount',
311 'name' => 'description',
312 'type' => CRM_Utils_Type
::T_STRING
,
313 'title' => ts('Financial Account Description'),
314 'description' => ts('Financial Type Description.'),
316 'size' => CRM_Utils_Type
::HUGE
,
317 'where' => 'civicrm_financial_account.description',
318 'table_name' => 'civicrm_financial_account',
319 'entity' => 'FinancialAccount',
320 'bao' => 'CRM_Financial_BAO_FinancialAccount',
325 'name' => 'parent_id',
326 'type' => CRM_Utils_Type
::T_INT
,
327 'title' => ts('Parent ID'),
328 'description' => ts('Parent ID in account hierarchy'),
329 'where' => 'civicrm_financial_account.parent_id',
330 'table_name' => 'civicrm_financial_account',
331 'entity' => 'FinancialAccount',
332 'bao' => 'CRM_Financial_BAO_FinancialAccount',
334 'FKClassName' => 'CRM_Financial_DAO_FinancialAccount',
336 'label' => ts("Parent"),
340 'is_header_account' => [
341 'name' => 'is_header_account',
342 'type' => CRM_Utils_Type
::T_BOOLEAN
,
343 'title' => ts('Header Financial Account?'),
344 'description' => ts('Is this a header account which does not allow transactions to be posted against it directly, but only to its sub-accounts?'),
345 'where' => 'civicrm_financial_account.is_header_account',
347 'table_name' => 'civicrm_financial_account',
348 'entity' => 'FinancialAccount',
349 'bao' => 'CRM_Financial_BAO_FinancialAccount',
354 'name' => 'is_deductible',
355 'type' => CRM_Utils_Type
::T_BOOLEAN
,
356 'title' => ts('Deductible Financial Account?'),
357 'description' => ts('Is this account tax-deductible?'),
358 'where' => 'civicrm_financial_account.is_deductible',
360 'table_name' => 'civicrm_financial_account',
361 'entity' => 'FinancialAccount',
362 'bao' => 'CRM_Financial_BAO_FinancialAccount',
368 'type' => CRM_Utils_Type
::T_BOOLEAN
,
369 'title' => ts('Tax Financial Account?'),
370 'description' => ts('Is this account for taxes?'),
371 'where' => 'civicrm_financial_account.is_tax',
373 'table_name' => 'civicrm_financial_account',
374 'entity' => 'FinancialAccount',
375 'bao' => 'CRM_Financial_BAO_FinancialAccount',
380 'name' => 'tax_rate',
381 'type' => CRM_Utils_Type
::T_MONEY
,
382 'title' => ts('Financial Account Tax Rate'),
383 'description' => ts('The percentage of the total_amount that is due for this tax.'),
388 'where' => 'civicrm_financial_account.tax_rate',
389 'table_name' => 'civicrm_financial_account',
390 'entity' => 'FinancialAccount',
391 'bao' => 'CRM_Financial_BAO_FinancialAccount',
396 'name' => 'is_reserved',
397 'type' => CRM_Utils_Type
::T_BOOLEAN
,
398 'title' => ts('Reserved Financial Account?'),
399 'description' => ts('Is this a predefined system object?'),
400 'where' => 'civicrm_financial_account.is_reserved',
401 'table_name' => 'civicrm_financial_account',
402 'entity' => 'FinancialAccount',
403 'bao' => 'CRM_Financial_BAO_FinancialAccount',
408 'name' => 'is_active',
409 'type' => CRM_Utils_Type
::T_BOOLEAN
,
410 'title' => ts('Financial Account is Active'),
411 'description' => ts('Is this property active?'),
412 'where' => 'civicrm_financial_account.is_active',
413 'table_name' => 'civicrm_financial_account',
414 'entity' => 'FinancialAccount',
415 'bao' => 'CRM_Financial_BAO_FinancialAccount',
420 'name' => 'is_default',
421 'type' => CRM_Utils_Type
::T_BOOLEAN
,
422 'title' => ts('Default Financial Account'),
423 'description' => ts('Is this account the default one (or default tax one) for its financial_account_type?'),
424 'where' => 'civicrm_financial_account.is_default',
425 'table_name' => 'civicrm_financial_account',
426 'entity' => 'FinancialAccount',
427 'bao' => 'CRM_Financial_BAO_FinancialAccount',
432 CRM_Core_DAO_AllCoreTables
::invoke(__CLASS__
, 'fields_callback', Civi
::$statics[__CLASS__
]['fields']);
434 return Civi
::$statics[__CLASS__
]['fields'];
438 * Return a mapping from field-name to the corresponding key (as used in fields()).
441 * Array(string $name => string $uniqueName).
443 public static function &fieldKeys() {
444 if (!isset(Civi
::$statics[__CLASS__
]['fieldKeys'])) {
445 Civi
::$statics[__CLASS__
]['fieldKeys'] = array_flip(CRM_Utils_Array
::collect('name', self
::fields()));
447 return Civi
::$statics[__CLASS__
]['fieldKeys'];
451 * Returns the names of this table
455 public static function getTableName() {
456 return self
::$_tableName;
460 * Returns if this table needs to be logged
464 public function getLog() {
469 * Returns the list of fields that can be imported
471 * @param bool $prefix
475 public static function &import($prefix = FALSE) {
476 $r = CRM_Core_DAO_AllCoreTables
::getImports(__CLASS__
, 'financial_account', $prefix, []);
481 * Returns the list of fields that can be exported
483 * @param bool $prefix
487 public static function &export($prefix = FALSE) {
488 $r = CRM_Core_DAO_AllCoreTables
::getExports(__CLASS__
, 'financial_account', $prefix, []);
493 * Returns the list of indices
495 * @param bool $localize
499 public static function indices($localize = TRUE) {
506 'localizable' => FALSE,
508 'sig' => 'civicrm_financial_account::1::name',
511 return ($localize && !empty($indices)) ? CRM_Core_DAO_AllCoreTables
::multilingualize(__CLASS__
, $indices) : $indices;