Merge pull request #18517 from JMAConsulting/financial-issue-150
[civicrm-core.git] / CRM / Financial / DAO / EntityFinancialTrxn.php
1 <?php
2
3 /**
4 * @package CRM
5 * @copyright CiviCRM LLC https://civicrm.org/licensing
6 *
7 * Generated from xml/schema/CRM/Financial/EntityFinancialTrxn.xml
8 * DO NOT EDIT. Generated by CRM_Core_CodeGen
9 * (GenCodeChecksum:fafa322736bff4ccf082449b5e54cd35)
10 */
11
12 /**
13 * Database access object for the EntityFinancialTrxn entity.
14 */
15 class CRM_Financial_DAO_EntityFinancialTrxn extends CRM_Core_DAO {
16 const EXT = 'civicrm';
17 const TABLE_ADDED = '3.2';
18 const COMPONENT = 'CiviContribute';
19
20 /**
21 * Static instance to hold the table name.
22 *
23 * @var string
24 */
25 public static $_tableName = 'civicrm_entity_financial_trxn';
26
27 /**
28 * Should CiviCRM log any modifications to this table in the civicrm_log table.
29 *
30 * @var bool
31 */
32 public static $_log = FALSE;
33
34 /**
35 * ID
36 *
37 * @var int
38 */
39 public $id;
40
41 /**
42 * May contain civicrm_financial_item, civicrm_contribution, civicrm_financial_trxn, civicrm_grant, etc
43 *
44 * @var string
45 */
46 public $entity_table;
47
48 /**
49 * @var int
50 */
51 public $entity_id;
52
53 /**
54 * @var int
55 */
56 public $financial_trxn_id;
57
58 /**
59 * allocated amount of transaction to this entity
60 *
61 * @var float
62 */
63 public $amount;
64
65 /**
66 * Class constructor.
67 */
68 public function __construct() {
69 $this->__table = 'civicrm_entity_financial_trxn';
70 parent::__construct();
71 }
72
73 /**
74 * Returns localized title of this entity.
75 *
76 * @param bool $plural
77 * Whether to return the plural version of the title.
78 */
79 public static function getEntityTitle($plural = FALSE) {
80 return $plural ? ts('Entity Financial Trxns') : ts('Entity Financial Trxn');
81 }
82
83 /**
84 * Returns foreign keys and entity references.
85 *
86 * @return array
87 * [CRM_Core_Reference_Interface]
88 */
89 public static function getReferenceColumns() {
90 if (!isset(Civi::$statics[__CLASS__]['links'])) {
91 Civi::$statics[__CLASS__]['links'] = static::createReferenceColumns(__CLASS__);
92 Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName(), 'financial_trxn_id', 'civicrm_financial_trxn', 'id');
93 Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Dynamic(self::getTableName(), 'entity_id', NULL, 'id', 'entity_table');
94 CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'links_callback', Civi::$statics[__CLASS__]['links']);
95 }
96 return Civi::$statics[__CLASS__]['links'];
97 }
98
99 /**
100 * Returns all the column names of this table
101 *
102 * @return array
103 */
104 public static function &fields() {
105 if (!isset(Civi::$statics[__CLASS__]['fields'])) {
106 Civi::$statics[__CLASS__]['fields'] = [
107 'id' => [
108 'name' => 'id',
109 'type' => CRM_Utils_Type::T_INT,
110 'title' => ts('Entity Financial Transaction ID'),
111 'description' => ts('ID'),
112 'required' => TRUE,
113 'where' => 'civicrm_entity_financial_trxn.id',
114 'table_name' => 'civicrm_entity_financial_trxn',
115 'entity' => 'EntityFinancialTrxn',
116 'bao' => 'CRM_Financial_BAO_EntityFinancialTrxn',
117 'localizable' => 0,
118 'html' => [
119 'type' => 'Number',
120 ],
121 'readonly' => TRUE,
122 'add' => '3.2',
123 ],
124 'entity_table' => [
125 'name' => 'entity_table',
126 'type' => CRM_Utils_Type::T_STRING,
127 'title' => ts('Entity Table'),
128 'description' => ts('May contain civicrm_financial_item, civicrm_contribution, civicrm_financial_trxn, civicrm_grant, etc'),
129 'required' => TRUE,
130 'maxlength' => 64,
131 'size' => CRM_Utils_Type::BIG,
132 'import' => TRUE,
133 'where' => 'civicrm_entity_financial_trxn.entity_table',
134 'export' => TRUE,
135 'table_name' => 'civicrm_entity_financial_trxn',
136 'entity' => 'EntityFinancialTrxn',
137 'bao' => 'CRM_Financial_BAO_EntityFinancialTrxn',
138 'localizable' => 0,
139 'pseudoconstant' => [
140 'callback' => 'CRM_Financial_BAO_EntityFinancialTrxn::entityTables',
141 ],
142 'add' => '3.2',
143 ],
144 'entity_id' => [
145 'name' => 'entity_id',
146 'type' => CRM_Utils_Type::T_INT,
147 'title' => ts('Entity ID'),
148 'required' => TRUE,
149 'where' => 'civicrm_entity_financial_trxn.entity_id',
150 'table_name' => 'civicrm_entity_financial_trxn',
151 'entity' => 'EntityFinancialTrxn',
152 'bao' => 'CRM_Financial_BAO_EntityFinancialTrxn',
153 'localizable' => 0,
154 'add' => '3.2',
155 ],
156 'financial_trxn_id' => [
157 'name' => 'financial_trxn_id',
158 'type' => CRM_Utils_Type::T_INT,
159 'title' => ts('Financial Transaction ID'),
160 'where' => 'civicrm_entity_financial_trxn.financial_trxn_id',
161 'table_name' => 'civicrm_entity_financial_trxn',
162 'entity' => 'EntityFinancialTrxn',
163 'bao' => 'CRM_Financial_BAO_EntityFinancialTrxn',
164 'localizable' => 0,
165 'FKClassName' => 'CRM_Financial_DAO_FinancialTrxn',
166 'html' => [
167 'label' => ts("Financial Transaction"),
168 ],
169 'add' => '3.2',
170 ],
171 'amount' => [
172 'name' => 'amount',
173 'type' => CRM_Utils_Type::T_MONEY,
174 'title' => ts('Amount'),
175 'description' => ts('allocated amount of transaction to this entity'),
176 'required' => TRUE,
177 'precision' => [
178 20,
179 2,
180 ],
181 'import' => TRUE,
182 'where' => 'civicrm_entity_financial_trxn.amount',
183 'headerPattern' => '/amount/i',
184 'dataPattern' => '/^\d+(\.\d{2})?$/',
185 'export' => TRUE,
186 'table_name' => 'civicrm_entity_financial_trxn',
187 'entity' => 'EntityFinancialTrxn',
188 'bao' => 'CRM_Financial_BAO_EntityFinancialTrxn',
189 'localizable' => 0,
190 'add' => '3.2',
191 ],
192 ];
193 CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'fields_callback', Civi::$statics[__CLASS__]['fields']);
194 }
195 return Civi::$statics[__CLASS__]['fields'];
196 }
197
198 /**
199 * Return a mapping from field-name to the corresponding key (as used in fields()).
200 *
201 * @return array
202 * Array(string $name => string $uniqueName).
203 */
204 public static function &fieldKeys() {
205 if (!isset(Civi::$statics[__CLASS__]['fieldKeys'])) {
206 Civi::$statics[__CLASS__]['fieldKeys'] = array_flip(CRM_Utils_Array::collect('name', self::fields()));
207 }
208 return Civi::$statics[__CLASS__]['fieldKeys'];
209 }
210
211 /**
212 * Returns the names of this table
213 *
214 * @return string
215 */
216 public static function getTableName() {
217 return self::$_tableName;
218 }
219
220 /**
221 * Returns if this table needs to be logged
222 *
223 * @return bool
224 */
225 public function getLog() {
226 return self::$_log;
227 }
228
229 /**
230 * Returns the list of fields that can be imported
231 *
232 * @param bool $prefix
233 *
234 * @return array
235 */
236 public static function &import($prefix = FALSE) {
237 $r = CRM_Core_DAO_AllCoreTables::getImports(__CLASS__, 'entity_financial_trxn', $prefix, []);
238 return $r;
239 }
240
241 /**
242 * Returns the list of fields that can be exported
243 *
244 * @param bool $prefix
245 *
246 * @return array
247 */
248 public static function &export($prefix = FALSE) {
249 $r = CRM_Core_DAO_AllCoreTables::getExports(__CLASS__, 'entity_financial_trxn', $prefix, []);
250 return $r;
251 }
252
253 /**
254 * Returns the list of indices
255 *
256 * @param bool $localize
257 *
258 * @return array
259 */
260 public static function indices($localize = TRUE) {
261 $indices = [
262 'UI_entity_financial_trxn_entity_table' => [
263 'name' => 'UI_entity_financial_trxn_entity_table',
264 'field' => [
265 0 => 'entity_table',
266 ],
267 'localizable' => FALSE,
268 'sig' => 'civicrm_entity_financial_trxn::0::entity_table',
269 ],
270 'UI_entity_financial_trxn_entity_id' => [
271 'name' => 'UI_entity_financial_trxn_entity_id',
272 'field' => [
273 0 => 'entity_id',
274 ],
275 'localizable' => FALSE,
276 'sig' => 'civicrm_entity_financial_trxn::0::entity_id',
277 ],
278 ];
279 return ($localize && !empty($indices)) ? CRM_Core_DAO_AllCoreTables::multilingualize(__CLASS__, $indices) : $indices;
280 }
281
282 }