Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

dev/core#2486 Add pseudoconstant callback for LineItem and Financial item entity #20464

Merged
merged 1 commit into from
Jun 1, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions CRM/Financial/BAO/FinancialItem.php
Original file line number Diff line number Diff line change
Expand Up @@ -289,4 +289,16 @@ public static function getPreviousFinancialItem($entityId) {
return civicrm_api3('FinancialItem', 'getsingle', $params);
}

/**
* Whitelist of possible values for the entity_table field
*
* @return array
*/
public static function entityTables(): array {
return [
'civicrm_line_item' => ts('Line Item'),
'civicrm_financial_trxn' => ts('Financial Trxn'),
];
}

}
9 changes: 6 additions & 3 deletions CRM/Financial/DAO/FinancialItem.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
*
* Generated from xml/schema/CRM/Financial/FinancialItem.xml
* DO NOT EDIT. Generated by CRM_Core_CodeGen
* (GenCodeChecksum:b63c826a61c494010c7628672e82fc27)
* (GenCodeChecksum:c9deaca104b5b1126ad3a064c520d0c3)
*/

/**
Expand Down Expand Up @@ -93,7 +93,7 @@ class CRM_Financial_DAO_FinancialItem extends CRM_Core_DAO {
public $status_id;

/**
* The table providing the source of this item such as civicrm_line_item
* May contain civicrm_line_item, civicrm_financial_trxn etc
*
* @var string
*/
Expand Down Expand Up @@ -315,14 +315,17 @@ public static function &fields() {
'name' => 'entity_table',
'type' => CRM_Utils_Type::T_STRING,
'title' => ts('Entity Table'),
'description' => ts('The table providing the source of this item such as civicrm_line_item'),
'description' => ts('May contain civicrm_line_item, civicrm_financial_trxn etc'),
'maxlength' => 64,
'size' => CRM_Utils_Type::BIG,
'where' => 'civicrm_financial_item.entity_table',
'table_name' => 'civicrm_financial_item',
'entity' => 'FinancialItem',
'bao' => 'CRM_Financial_BAO_FinancialItem',
'localizable' => 0,
'pseudoconstant' => [
'callback' => 'CRM_Financial_BAO_FinancialItem::entityTables',
],
'add' => '4.3',
],
'entity_id' => [
Expand Down
13 changes: 13 additions & 0 deletions CRM/Price/BAO/LineItem.php
Original file line number Diff line number Diff line change
Expand Up @@ -1229,4 +1229,17 @@ protected function getSalesTaxTerm() {
return CRM_Contribute_BAO_Contribution::checkContributeSettings('tax_term');
}

/**
* Whitelist of possible values for the entity_table field
*
* @return array
*/
public static function entityTables(): array {
return [
'civicrm_contribution' => ts('Contribution'),
'civicrm_participant' => ts('Participant'),
'civicrm_membership' => ts('Membership'),
];
}

}
9 changes: 6 additions & 3 deletions CRM/Price/DAO/LineItem.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
*
* Generated from xml/schema/CRM/Price/LineItem.xml
* DO NOT EDIT. Generated by CRM_Core_CodeGen
* (GenCodeChecksum:1c10b6b406bb73014b2fbe6ceb95fda3)
* (GenCodeChecksum:cffc97712c8823323cbeb39a0851363a)
*/

/**
Expand Down Expand Up @@ -39,7 +39,7 @@ class CRM_Price_DAO_LineItem extends CRM_Core_DAO {
public $id;

/**
* table which has the transaction
* May contain civicrm_contribution, civicrm_participant or civicrm_membership
*
* @var string
*/
Expand Down Expand Up @@ -195,7 +195,7 @@ public static function &fields() {
'name' => 'entity_table',
'type' => CRM_Utils_Type::T_STRING,
'title' => ts('Line Item Entity Type'),
'description' => ts('table which has the transaction'),
'description' => ts('May contain civicrm_contribution, civicrm_participant or civicrm_membership'),
'required' => TRUE,
'maxlength' => 64,
'size' => CRM_Utils_Type::BIG,
Expand All @@ -204,6 +204,9 @@ public static function &fields() {
'entity' => 'LineItem',
'bao' => 'CRM_Price_BAO_LineItem',
'localizable' => 0,
'pseudoconstant' => [
'callback' => 'CRM_Price_BAO_LineItem::entityTables',
],
'add' => '1.7',
],
'entity_id' => [
Expand Down
5 changes: 4 additions & 1 deletion xml/schema/Financial/FinancialItem.xml
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,10 @@
<type>varchar</type>
<title>Entity Table</title>
<length>64</length>
<comment>The table providing the source of this item such as civicrm_line_item</comment>
<pseudoconstant>
<callback>CRM_Financial_BAO_FinancialItem::entityTables</callback>
</pseudoconstant>
<comment>May contain civicrm_line_item, civicrm_financial_trxn etc</comment>
<add>4.3</add>
</field>
<field>
Expand Down
6 changes: 4 additions & 2 deletions xml/schema/Price/LineItem.xml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,10 @@
<type>varchar</type>
<length>64</length>
<required>true</required>
<comment>table which has the transaction</comment>
<pseudoconstant>
<callback>CRM_Price_BAO_LineItem::entityTables</callback>
</pseudoconstant>
<comment>May contain civicrm_contribution, civicrm_participant or civicrm_membership</comment>
<add>1.7</add>
</field>
<field>
Expand Down Expand Up @@ -225,4 +228,3 @@
</html>
</field>
</table>