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:f0c54d50618e54bd122e14fab50402be)
13 * Database access object for the FinancialItem entity.
15 class CRM_Financial_DAO_FinancialItem
extends CRM_Core_DAO
{
18 * Static instance to hold the table name.
22 public static $_tableName = 'civicrm_financial_item';
25 * Should CiviCRM log any modifications to this table in the civicrm_log table.
29 public static $_log = TRUE;
37 * Date and time the item was created
44 * Date and time of the source transaction
48 public $transaction_date;
51 * FK to Contact ID of contact the item is from
58 * Human readable description of this item, to ease display without lookup of source item.
65 * Total amount of this item
72 * Currency for the amount
79 * FK to civicrm_financial_account
83 public $financial_account_id;
86 * Payment status: test, paid, part_paid, unpaid (if empty assume unpaid)
93 * The table providing the source of this item such as civicrm_line_item
100 * The specific source item that is responsible for the creation of this financial_item
109 public function __construct() {
110 $this->__table
= 'civicrm_financial_item';
111 parent
::__construct();
115 * Returns localized title of this entity.
117 public static function getEntityTitle() {
118 return ts('Financial Items');
122 * Returns foreign keys and entity references.
125 * [CRM_Core_Reference_Interface]
127 public static function getReferenceColumns() {
128 if (!isset(Civi
::$statics[__CLASS__
]['links'])) {
129 Civi
::$statics[__CLASS__
]['links'] = static::createReferenceColumns(__CLASS__
);
130 Civi
::$statics[__CLASS__
]['links'][] = new CRM_Core_Reference_Basic(self
::getTableName(), 'contact_id', 'civicrm_contact', 'id');
131 Civi
::$statics[__CLASS__
]['links'][] = new CRM_Core_Reference_Basic(self
::getTableName(), 'financial_account_id', 'civicrm_financial_account', 'id');
132 Civi
::$statics[__CLASS__
]['links'][] = new CRM_Core_Reference_Dynamic(self
::getTableName(), 'entity_id', NULL, 'id', 'entity_table');
133 CRM_Core_DAO_AllCoreTables
::invoke(__CLASS__
, 'links_callback', Civi
::$statics[__CLASS__
]['links']);
135 return Civi
::$statics[__CLASS__
]['links'];
139 * Returns all the column names of this table
143 public static function &fields() {
144 if (!isset(Civi
::$statics[__CLASS__
]['fields'])) {
145 Civi
::$statics[__CLASS__
]['fields'] = [
148 'type' => CRM_Utils_Type
::T_INT
,
149 'title' => ts('Financial Item ID'),
151 'where' => 'civicrm_financial_item.id',
152 'table_name' => 'civicrm_financial_item',
153 'entity' => 'FinancialItem',
154 'bao' => 'CRM_Financial_BAO_FinancialItem',
158 'name' => 'created_date',
159 'type' => CRM_Utils_Type
::T_TIMESTAMP
,
160 'title' => ts('Financial Item Created Date'),
161 'description' => ts('Date and time the item was created'),
163 'where' => 'civicrm_financial_item.created_date',
164 'default' => 'CURRENT_TIMESTAMP',
165 'table_name' => 'civicrm_financial_item',
166 'entity' => 'FinancialItem',
167 'bao' => 'CRM_Financial_BAO_FinancialItem',
170 'transaction_date' => [
171 'name' => 'transaction_date',
172 'type' => CRM_Utils_Type
::T_DATE + CRM_Utils_Type
::T_TIME
,
173 'title' => ts('Financial Item Transaction Date'),
174 'description' => ts('Date and time of the source transaction'),
176 'where' => 'civicrm_financial_item.transaction_date',
177 'table_name' => 'civicrm_financial_item',
178 'entity' => 'FinancialItem',
179 'bao' => 'CRM_Financial_BAO_FinancialItem',
183 'name' => 'contact_id',
184 'type' => CRM_Utils_Type
::T_INT
,
185 'title' => ts('Financial Item Contact ID'),
186 'description' => ts('FK to Contact ID of contact the item is from'),
188 'where' => 'civicrm_financial_item.contact_id',
190 'table_name' => 'civicrm_financial_item',
191 'entity' => 'FinancialItem',
192 'bao' => 'CRM_Financial_BAO_FinancialItem',
194 'FKClassName' => 'CRM_Contact_DAO_Contact',
197 'name' => 'description',
198 'type' => CRM_Utils_Type
::T_STRING
,
199 'title' => ts('Financial Item Description'),
200 'description' => ts('Human readable description of this item, to ease display without lookup of source item.'),
202 'size' => CRM_Utils_Type
::HUGE
,
203 'where' => 'civicrm_financial_item.description',
204 'table_name' => 'civicrm_financial_item',
205 'entity' => 'FinancialItem',
206 'bao' => 'CRM_Financial_BAO_FinancialItem',
211 'type' => CRM_Utils_Type
::T_MONEY
,
212 'title' => ts('Amount'),
213 'description' => ts('Total amount of this item'),
219 'where' => 'civicrm_financial_item.amount',
220 'headerPattern' => '/unit?.?amoun/i',
221 'dataPattern' => '/^\d+(\.\d{2})?$/',
223 'table_name' => 'civicrm_financial_item',
224 'entity' => 'FinancialItem',
225 'bao' => 'CRM_Financial_BAO_FinancialItem',
229 'name' => 'currency',
230 'type' => CRM_Utils_Type
::T_STRING
,
231 'title' => ts('Financial Item Currency'),
232 'description' => ts('Currency for the amount'),
234 'size' => CRM_Utils_Type
::FOUR
,
235 'where' => 'civicrm_financial_item.currency',
237 'table_name' => 'civicrm_financial_item',
238 'entity' => 'FinancialItem',
239 'bao' => 'CRM_Financial_BAO_FinancialItem',
244 'pseudoconstant' => [
245 'table' => 'civicrm_currency',
246 'keyColumn' => 'name',
247 'labelColumn' => 'full_name',
248 'nameColumn' => 'name',
249 'abbrColumn' => 'symbol',
252 'financial_account_id' => [
253 'name' => 'financial_account_id',
254 'type' => CRM_Utils_Type
::T_INT
,
255 'title' => ts('Financial Account ID'),
256 'description' => ts('FK to civicrm_financial_account'),
257 'where' => 'civicrm_financial_item.financial_account_id',
258 'table_name' => 'civicrm_financial_item',
259 'entity' => 'FinancialItem',
260 'bao' => 'CRM_Financial_BAO_FinancialItem',
262 'FKClassName' => 'CRM_Financial_DAO_FinancialAccount',
266 'pseudoconstant' => [
267 'table' => 'civicrm_financial_account',
269 'labelColumn' => 'name',
273 'name' => 'status_id',
274 'type' => CRM_Utils_Type
::T_INT
,
275 'title' => ts('Financial Item Status ID'),
276 'description' => ts('Payment status: test, paid, part_paid, unpaid (if empty assume unpaid)'),
277 'where' => 'civicrm_financial_item.status_id',
279 'table_name' => 'civicrm_financial_item',
280 'entity' => 'FinancialItem',
281 'bao' => 'CRM_Financial_BAO_FinancialItem',
286 'pseudoconstant' => [
287 'optionGroupName' => 'financial_item_status',
288 'optionEditPath' => 'civicrm/admin/options/financial_item_status',
292 'name' => 'entity_table',
293 'type' => CRM_Utils_Type
::T_STRING
,
294 'title' => ts('Entity Table'),
295 'description' => ts('The table providing the source of this item such as civicrm_line_item'),
297 'size' => CRM_Utils_Type
::BIG
,
298 'where' => 'civicrm_financial_item.entity_table',
299 'table_name' => 'civicrm_financial_item',
300 'entity' => 'FinancialItem',
301 'bao' => 'CRM_Financial_BAO_FinancialItem',
305 'name' => 'entity_id',
306 'type' => CRM_Utils_Type
::T_INT
,
307 'title' => ts('Entity ID'),
308 'description' => ts('The specific source item that is responsible for the creation of this financial_item'),
309 'where' => 'civicrm_financial_item.entity_id',
310 'table_name' => 'civicrm_financial_item',
311 'entity' => 'FinancialItem',
312 'bao' => 'CRM_Financial_BAO_FinancialItem',
316 CRM_Core_DAO_AllCoreTables
::invoke(__CLASS__
, 'fields_callback', Civi
::$statics[__CLASS__
]['fields']);
318 return Civi
::$statics[__CLASS__
]['fields'];
322 * Return a mapping from field-name to the corresponding key (as used in fields()).
325 * Array(string $name => string $uniqueName).
327 public static function &fieldKeys() {
328 if (!isset(Civi
::$statics[__CLASS__
]['fieldKeys'])) {
329 Civi
::$statics[__CLASS__
]['fieldKeys'] = array_flip(CRM_Utils_Array
::collect('name', self
::fields()));
331 return Civi
::$statics[__CLASS__
]['fieldKeys'];
335 * Returns the names of this table
339 public static function getTableName() {
340 return self
::$_tableName;
344 * Returns if this table needs to be logged
348 public function getLog() {
353 * Returns the list of fields that can be imported
355 * @param bool $prefix
359 public static function &import($prefix = FALSE) {
360 $r = CRM_Core_DAO_AllCoreTables
::getImports(__CLASS__
, 'financial_item', $prefix, []);
365 * Returns the list of fields that can be exported
367 * @param bool $prefix
371 public static function &export($prefix = FALSE) {
372 $r = CRM_Core_DAO_AllCoreTables
::getExports(__CLASS__
, 'financial_item', $prefix, []);
377 * Returns the list of indices
379 * @param bool $localize
383 public static function indices($localize = TRUE) {
385 'IX_created_date' => [
386 'name' => 'IX_created_date',
390 'localizable' => FALSE,
391 'sig' => 'civicrm_financial_item::0::created_date',
393 'IX_transaction_date' => [
394 'name' => 'IX_transaction_date',
396 0 => 'transaction_date',
398 'localizable' => FALSE,
399 'sig' => 'civicrm_financial_item::0::transaction_date',
401 'index_entity_id_entity_table' => [
402 'name' => 'index_entity_id_entity_table',
407 'localizable' => FALSE,
408 'sig' => 'civicrm_financial_item::0::entity_id::entity_table',
411 return ($localize && !empty($indices)) ? CRM_Core_DAO_AllCoreTables
::multilingualize(__CLASS__
, $indices) : $indices;