5 * @copyright CiviCRM LLC https://civicrm.org/licensing
7 * Generated from xml/schema/CRM/Financial/FinancialItem.xml
8 * DO NOT EDIT. Generated by CRM_Core_CodeGen
9 * (GenCodeChecksum:70be7900a331cb86c9cd6ee76544adc5)
13 * Database access object for the FinancialItem entity.
15 class CRM_Financial_DAO_FinancialItem
extends CRM_Core_DAO
{
16 const EXT
= 'civicrm';
17 const TABLE_ADDED
= '4.3';
18 const COMPONENT
= 'CiviContribute';
21 * Static instance to hold the table name.
25 public static $_tableName = 'civicrm_financial_item';
28 * Should CiviCRM log any modifications to this table in the civicrm_log table.
32 public static $_log = TRUE;
40 * Date and time the item was created
47 * Date and time of the source transaction
51 public $transaction_date;
54 * FK to Contact ID of contact the item is from
61 * Human readable description of this item, to ease display without lookup of source item.
68 * Total amount of this item
75 * Currency for the amount
82 * FK to civicrm_financial_account
86 public $financial_account_id;
89 * Payment status: test, paid, part_paid, unpaid (if empty assume unpaid)
96 * May contain civicrm_line_item, civicrm_financial_trxn etc
100 public $entity_table;
103 * The specific source item that is responsible for the creation of this financial_item
112 public function __construct() {
113 $this->__table
= 'civicrm_financial_item';
114 parent
::__construct();
118 * Returns localized title of this entity.
120 * @param bool $plural
121 * Whether to return the plural version of the title.
123 public static function getEntityTitle($plural = FALSE) {
124 return $plural ?
ts('Financial Items') : ts('Financial Item');
128 * Returns foreign keys and entity references.
131 * [CRM_Core_Reference_Interface]
133 public static function getReferenceColumns() {
134 if (!isset(Civi
::$statics[__CLASS__
]['links'])) {
135 Civi
::$statics[__CLASS__
]['links'] = static::createReferenceColumns(__CLASS__
);
136 Civi
::$statics[__CLASS__
]['links'][] = new CRM_Core_Reference_Basic(self
::getTableName(), 'contact_id', 'civicrm_contact', 'id');
137 Civi
::$statics[__CLASS__
]['links'][] = new CRM_Core_Reference_Basic(self
::getTableName(), 'financial_account_id', 'civicrm_financial_account', 'id');
138 Civi
::$statics[__CLASS__
]['links'][] = new CRM_Core_Reference_Dynamic(self
::getTableName(), 'entity_id', NULL, 'id', 'entity_table');
139 CRM_Core_DAO_AllCoreTables
::invoke(__CLASS__
, 'links_callback', Civi
::$statics[__CLASS__
]['links']);
141 return Civi
::$statics[__CLASS__
]['links'];
145 * Returns all the column names of this table
149 public static function &fields() {
150 if (!isset(Civi
::$statics[__CLASS__
]['fields'])) {
151 Civi
::$statics[__CLASS__
]['fields'] = [
154 'type' => CRM_Utils_Type
::T_INT
,
155 'title' => ts('Financial Item ID'),
157 'where' => 'civicrm_financial_item.id',
158 'table_name' => 'civicrm_financial_item',
159 'entity' => 'FinancialItem',
160 'bao' => 'CRM_Financial_BAO_FinancialItem',
169 'name' => 'created_date',
170 'type' => CRM_Utils_Type
::T_TIMESTAMP
,
171 'title' => ts('Financial Item Created Date'),
172 'description' => ts('Date and time the item was created'),
174 'where' => 'civicrm_financial_item.created_date',
175 'default' => 'CURRENT_TIMESTAMP',
176 'table_name' => 'civicrm_financial_item',
177 'entity' => 'FinancialItem',
178 'bao' => 'CRM_Financial_BAO_FinancialItem',
182 'transaction_date' => [
183 'name' => 'transaction_date',
184 'type' => CRM_Utils_Type
::T_DATE + CRM_Utils_Type
::T_TIME
,
185 'title' => ts('Financial Item Transaction Date'),
186 'description' => ts('Date and time of the source transaction'),
188 'where' => 'civicrm_financial_item.transaction_date',
189 'table_name' => 'civicrm_financial_item',
190 'entity' => 'FinancialItem',
191 'bao' => 'CRM_Financial_BAO_FinancialItem',
196 'name' => 'contact_id',
197 'type' => CRM_Utils_Type
::T_INT
,
198 'title' => ts('Contact ID'),
199 'description' => ts('FK to Contact ID of contact the item is from'),
201 'where' => 'civicrm_financial_item.contact_id',
203 'table_name' => 'civicrm_financial_item',
204 'entity' => 'FinancialItem',
205 'bao' => 'CRM_Financial_BAO_FinancialItem',
207 'FKClassName' => 'CRM_Contact_DAO_Contact',
209 'label' => ts("Contact"),
214 'name' => 'description',
215 'type' => CRM_Utils_Type
::T_STRING
,
216 'title' => ts('Financial Item Description'),
217 'description' => ts('Human readable description of this item, to ease display without lookup of source item.'),
219 'size' => CRM_Utils_Type
::HUGE
,
220 'where' => 'civicrm_financial_item.description',
221 'table_name' => 'civicrm_financial_item',
222 'entity' => 'FinancialItem',
223 'bao' => 'CRM_Financial_BAO_FinancialItem',
229 'type' => CRM_Utils_Type
::T_MONEY
,
230 'title' => ts('Amount'),
231 'description' => ts('Total amount of this item'),
237 'where' => 'civicrm_financial_item.amount',
238 'headerPattern' => '/unit?.?amoun/i',
239 'dataPattern' => '/^\d+(\.\d{2})?$/',
241 'table_name' => 'civicrm_financial_item',
242 'entity' => 'FinancialItem',
243 'bao' => 'CRM_Financial_BAO_FinancialItem',
248 'name' => 'currency',
249 'type' => CRM_Utils_Type
::T_STRING
,
250 'title' => ts('Financial Item Currency'),
251 'description' => ts('Currency for the amount'),
253 'size' => CRM_Utils_Type
::FOUR
,
254 'where' => 'civicrm_financial_item.currency',
256 'table_name' => 'civicrm_financial_item',
257 'entity' => 'FinancialItem',
258 'bao' => 'CRM_Financial_BAO_FinancialItem',
263 'pseudoconstant' => [
264 'table' => 'civicrm_currency',
265 'keyColumn' => 'name',
266 'labelColumn' => 'full_name',
267 'nameColumn' => 'name',
268 'abbrColumn' => 'symbol',
272 'financial_account_id' => [
273 'name' => 'financial_account_id',
274 'type' => CRM_Utils_Type
::T_INT
,
275 'title' => ts('Financial Account ID'),
276 'description' => ts('FK to civicrm_financial_account'),
277 'where' => 'civicrm_financial_item.financial_account_id',
278 'table_name' => 'civicrm_financial_item',
279 'entity' => 'FinancialItem',
280 'bao' => 'CRM_Financial_BAO_FinancialItem',
282 'FKClassName' => 'CRM_Financial_DAO_FinancialAccount',
285 'label' => ts("Financial Account"),
287 'pseudoconstant' => [
288 'table' => 'civicrm_financial_account',
290 'labelColumn' => 'name',
295 'name' => 'status_id',
296 'type' => CRM_Utils_Type
::T_INT
,
297 'title' => ts('Financial Item Status ID'),
298 'description' => ts('Payment status: test, paid, part_paid, unpaid (if empty assume unpaid)'),
299 'where' => 'civicrm_financial_item.status_id',
301 'table_name' => 'civicrm_financial_item',
302 'entity' => 'FinancialItem',
303 'bao' => 'CRM_Financial_BAO_FinancialItem',
308 'pseudoconstant' => [
309 'optionGroupName' => 'financial_item_status',
310 'optionEditPath' => 'civicrm/admin/options/financial_item_status',
315 'name' => 'entity_table',
316 'type' => CRM_Utils_Type
::T_STRING
,
317 'title' => ts('Entity Table'),
318 'description' => ts('May contain civicrm_line_item, civicrm_financial_trxn etc'),
320 'size' => CRM_Utils_Type
::BIG
,
321 'where' => 'civicrm_financial_item.entity_table',
322 'table_name' => 'civicrm_financial_item',
323 'entity' => 'FinancialItem',
324 'bao' => 'CRM_Financial_BAO_FinancialItem',
326 'pseudoconstant' => [
327 'callback' => 'CRM_Financial_BAO_FinancialItem::entityTables',
332 'name' => 'entity_id',
333 'type' => CRM_Utils_Type
::T_INT
,
334 'title' => ts('Entity ID'),
335 'description' => ts('The specific source item that is responsible for the creation of this financial_item'),
336 'where' => 'civicrm_financial_item.entity_id',
337 'table_name' => 'civicrm_financial_item',
338 'entity' => 'FinancialItem',
339 'bao' => 'CRM_Financial_BAO_FinancialItem',
344 CRM_Core_DAO_AllCoreTables
::invoke(__CLASS__
, 'fields_callback', Civi
::$statics[__CLASS__
]['fields']);
346 return Civi
::$statics[__CLASS__
]['fields'];
350 * Return a mapping from field-name to the corresponding key (as used in fields()).
353 * Array(string $name => string $uniqueName).
355 public static function &fieldKeys() {
356 if (!isset(Civi
::$statics[__CLASS__
]['fieldKeys'])) {
357 Civi
::$statics[__CLASS__
]['fieldKeys'] = array_flip(CRM_Utils_Array
::collect('name', self
::fields()));
359 return Civi
::$statics[__CLASS__
]['fieldKeys'];
363 * Returns the names of this table
367 public static function getTableName() {
368 return self
::$_tableName;
372 * Returns if this table needs to be logged
376 public function getLog() {
381 * Returns the list of fields that can be imported
383 * @param bool $prefix
387 public static function &import($prefix = FALSE) {
388 $r = CRM_Core_DAO_AllCoreTables
::getImports(__CLASS__
, 'financial_item', $prefix, []);
393 * Returns the list of fields that can be exported
395 * @param bool $prefix
399 public static function &export($prefix = FALSE) {
400 $r = CRM_Core_DAO_AllCoreTables
::getExports(__CLASS__
, 'financial_item', $prefix, []);
405 * Returns the list of indices
407 * @param bool $localize
411 public static function indices($localize = TRUE) {
413 'IX_created_date' => [
414 'name' => 'IX_created_date',
418 'localizable' => FALSE,
419 'sig' => 'civicrm_financial_item::0::created_date',
421 'IX_transaction_date' => [
422 'name' => 'IX_transaction_date',
424 0 => 'transaction_date',
426 'localizable' => FALSE,
427 'sig' => 'civicrm_financial_item::0::transaction_date',
429 'index_entity_id_entity_table' => [
430 'name' => 'index_entity_id_entity_table',
435 'localizable' => FALSE,
436 'sig' => 'civicrm_financial_item::0::entity_id::entity_table',
439 return ($localize && !empty($indices)) ? CRM_Core_DAO_AllCoreTables
::multilingualize(__CLASS__
, $indices) : $indices;