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

Add entity financial account bridge entity #19927

Merged
merged 1 commit into from
Apr 7, 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
32 changes: 32 additions & 0 deletions CRM/Financial/BAO/EntityFinancialAccount.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
<?php
/*
+--------------------------------------------------------------------+
| Copyright CiviCRM LLC. All rights reserved. |
| |
| This work is published under the GNU AGPLv3 license with some |
| permitted exceptions and without any warranty. For full license |
| and copyright information, see https://civicrm.org/licensing |
+--------------------------------------------------------------------+
*/

/**
*
* @package CRM
* @copyright CiviCRM LLC https://civicrm.org/licensing
*/
class CRM_Financial_BAO_EntityFinancialAccount extends CRM_Financial_DAO_EntityFinancialAccount {

/**
* Whitelist of possible values for the entity_table field
*
* @return array
*/
public static function entityTables(): array {
return [
'civicrm_financial_type' => ts('Financial Type'),
'civicrm_option_value' => ts('Payment Instrument'),
'civicrm_payment_processor' => ts('Payment Processor'),
];
}

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

/**
Expand Down Expand Up @@ -117,7 +117,7 @@ public static function &fields() {
'where' => 'civicrm_entity_financial_account.id',
'table_name' => 'civicrm_entity_financial_account',
'entity' => 'EntityFinancialAccount',
'bao' => 'CRM_Financial_DAO_EntityFinancialAccount',
'bao' => 'CRM_Financial_BAO_EntityFinancialAccount',
'localizable' => 0,
'html' => [
'type' => 'Number',
Expand All @@ -138,8 +138,11 @@ public static function &fields() {
'export' => TRUE,
'table_name' => 'civicrm_entity_financial_account',
'entity' => 'EntityFinancialAccount',
'bao' => 'CRM_Financial_DAO_EntityFinancialAccount',
'bao' => 'CRM_Financial_BAO_EntityFinancialAccount',
'localizable' => 0,
'pseudoconstant' => [
'callback' => 'CRM_Financial_BAO_EntityFinancialAccount::entityTables',
],
'add' => '4.3',
],
'entity_id' => [
Expand All @@ -151,7 +154,7 @@ public static function &fields() {
'where' => 'civicrm_entity_financial_account.entity_id',
'table_name' => 'civicrm_entity_financial_account',
'entity' => 'EntityFinancialAccount',
'bao' => 'CRM_Financial_DAO_EntityFinancialAccount',
'bao' => 'CRM_Financial_BAO_EntityFinancialAccount',
'localizable' => 0,
'add' => '4.3',
],
Expand All @@ -164,7 +167,7 @@ public static function &fields() {
'where' => 'civicrm_entity_financial_account.account_relationship',
'table_name' => 'civicrm_entity_financial_account',
'entity' => 'EntityFinancialAccount',
'bao' => 'CRM_Financial_DAO_EntityFinancialAccount',
'bao' => 'CRM_Financial_BAO_EntityFinancialAccount',
'localizable' => 0,
'html' => [
'type' => 'Select',
Expand All @@ -184,7 +187,7 @@ public static function &fields() {
'where' => 'civicrm_entity_financial_account.financial_account_id',
'table_name' => 'civicrm_entity_financial_account',
'entity' => 'EntityFinancialAccount',
'bao' => 'CRM_Financial_DAO_EntityFinancialAccount',
'bao' => 'CRM_Financial_BAO_EntityFinancialAccount',
'localizable' => 0,
'FKClassName' => 'CRM_Financial_DAO_FinancialAccount',
'html' => [
Expand Down
34 changes: 34 additions & 0 deletions Civi/Api4/EntityFinancialAccount.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
<?php

/*
+--------------------------------------------------------------------+
| Copyright CiviCRM LLC. All rights reserved. |
| |
| This work is published under the GNU AGPLv3 license with some |
| permitted exceptions and without any warranty. For full license |
| and copyright information, see https://civicrm.org/licensing |
+--------------------------------------------------------------------+
*/

/**
*
* @package CRM
* @copyright CiviCRM LLC https://civicrm.org/licensing
*/

namespace Civi\Api4;

/**
* EntityFinancialAccount. Joins financial accounts to financial types.
*
* @see https://docs.civicrm.org/dev/en/latest/financial/financialentities/#financial-accounts
*
* @bridge entity_id financial_account_id
* @ui_join_filters account_relationship
*
Copy link
Member

@colemanw colemanw Mar 28, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@eileenmcnaughton if you want the AccountRelationship field automatically shown when adding join in searchKit (like relationship type id is shown for related contacts or activity contact type is shown for activities) do this:

Suggested change
*
* @ui_join_filters account_relationship

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@colemanw I've pushed that up - although note the whole thing doesn't work atm

* @package Civi\Api4
*/
class EntityFinancialAccount extends Generic\DAOEntity {
use Generic\Traits\EntityBridge;

}
2 changes: 1 addition & 1 deletion tests/phpunit/api/v3/PaymentProcessorTypeTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ public function testPaymentProcessorTypeCreateWithoutName($version) {
*
* @param int $version
*/
public function testPaymentProcessorTypeCreate($version) {
public function testPaymentProcessorTypeCreate($version): void {
$this->_apiversion = $version;
$params = [
'sequential' => 1,
Expand Down
3 changes: 3 additions & 0 deletions xml/schema/Financial/EntityFinancialAccount.xml
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,9 @@
<import>true</import>
<add>4.3</add>
<comment>Links to an entity_table like civicrm_financial_type</comment>
<pseudoconstant>
<callback>CRM_Financial_BAO_EntityFinancialAccount::entityTables</callback>
</pseudoconstant>
</field>
<field>
<name>entity_id</name>
Expand Down