Add entity financial account
authoreileen <emcnaughton@wikimedia.org>
Sun, 28 Mar 2021 02:39:33 +0000 (15:39 +1300)
committereileen <emcnaughton@wikimedia.org>
Wed, 7 Apr 2021 02:13:18 +0000 (14:13 +1200)
CRM/Financial/BAO/EntityFinancialAccount.php [new file with mode: 0644]
CRM/Financial/DAO/EntityFinancialAccount.php
Civi/Api4/EntityFinancialAccount.php [new file with mode: 0644]
tests/phpunit/api/v3/PaymentProcessorTypeTest.php
xml/schema/Financial/EntityFinancialAccount.xml

diff --git a/CRM/Financial/BAO/EntityFinancialAccount.php b/CRM/Financial/BAO/EntityFinancialAccount.php
new file mode 100644 (file)
index 0000000..1449091
--- /dev/null
@@ -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'),
+    ];
+  }
+
+}
index 03e3669020e188cc98ada19334b71b976f34734c..90320f8ab9f60c7be1075a52355b494ebf3de19e 100644 (file)
@@ -6,7 +6,7 @@
  *
  * Generated from xml/schema/CRM/Financial/EntityFinancialAccount.xml
  * DO NOT EDIT.  Generated by CRM_Core_CodeGen
- * (GenCodeChecksum:caf02136c148fe50dbc39d8d29605f72)
+ * (GenCodeChecksum:ac2a0a2e8eae1471b71da25e95b52d55)
  */
 
 /**
@@ -117,7 +117,7 @@ class CRM_Financial_DAO_EntityFinancialAccount extends CRM_Core_DAO {
           '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',
@@ -138,8 +138,11 @@ class CRM_Financial_DAO_EntityFinancialAccount extends CRM_Core_DAO {
           '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' => [
@@ -151,7 +154,7 @@ class CRM_Financial_DAO_EntityFinancialAccount extends CRM_Core_DAO {
           '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',
         ],
@@ -164,7 +167,7 @@ class CRM_Financial_DAO_EntityFinancialAccount extends CRM_Core_DAO {
           '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',
@@ -184,7 +187,7 @@ class CRM_Financial_DAO_EntityFinancialAccount extends CRM_Core_DAO {
           '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' => [
diff --git a/Civi/Api4/EntityFinancialAccount.php b/Civi/Api4/EntityFinancialAccount.php
new file mode 100644 (file)
index 0000000..0963f73
--- /dev/null
@@ -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
+ *
+ * @package Civi\Api4
+ */
+class EntityFinancialAccount extends Generic\DAOEntity {
+  use Generic\Traits\EntityBridge;
+
+}
index 4e5709831e7b7440ff4fd99e1dffbe37df75a85e..0b880963da90ce7222c588ba3c7ea83dc1334987 100644 (file)
@@ -53,7 +53,7 @@ class api_v3_PaymentProcessorTypeTest extends CiviUnitTestCase {
    *
    * @param int $version
    */
-  public function testPaymentProcessorTypeCreate($version) {
+  public function testPaymentProcessorTypeCreate($version): void {
     $this->_apiversion = $version;
     $params = [
       'sequential' => 1,
index 95e3111928b3db2e9ea8fc4b46b7ec8e099a5e05..8c70d4c706e0793f611a000e363482049cf6b71f 100644 (file)
@@ -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>