Skip to content

Commit

Permalink
Add financial_type_id field to SepaTransactionGroup entity
Browse files Browse the repository at this point in the history
  • Loading branch information
jensschuppe committed Sep 13, 2024
1 parent 4a875cf commit d4d95ed
Show file tree
Hide file tree
Showing 4 changed files with 80 additions and 23 deletions.
29 changes: 29 additions & 0 deletions CRM/Sepa/DAO/SEPATransactionGroup.php
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,16 @@ class CRM_Sepa_DAO_SEPATransactionGroup extends CRM_Core_DAO {
*/
public $collection_date;

/**
* Financial type of contained contributions if CiviSEPA is generating groups
* matching financial types.
*
* @var int|string|null
* (SQL type: int unsigned)
* Note that values will be retrieved from the database as a string.
*/
public $financial_type_id;

/**
* Latest submission date
*
Expand Down Expand Up @@ -233,6 +243,25 @@ public static function &fields() {
'localizable' => 0,
'add' => NULL,
],
'financial_type_id' => [
'name' => 'financial_type_id',
'type' => CRM_Utils_Type::T_INT,
'title' => E::ts('Financial Type ID'),
'description' => E::ts('Financial type of contained contributions if CiviSEPA is generating groups matching financial types.'),
'required' => FALSE,
'usage' => [
'import' => FALSE,
'export' => FALSE,
'duplicate_matching' => FALSE,
'token' => FALSE,
],
'where' => 'civicrm_sdd_txgroup.financial_type_id',
'table_name' => 'civicrm_sdd_txgroup',
'entity' => 'SEPATransactionGroup',
'bao' => 'CRM_Sepa_DAO_SEPATransactionGroup',
'localizable' => 0,
'add' => NULL,
],
'latest_submission_date' => [
'name' => 'latest_submission_date',
'type' => CRM_Utils_Type::T_DATE + CRM_Utils_Type::T_TIME,
Expand Down
22 changes: 21 additions & 1 deletion CRM/Sepa/Upgrader.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
+--------------------------------------------------------*/

use CRM_Sepa_ExtensionUtil as E;

/**
* Collection of upgrade steps.
*/
Expand Down Expand Up @@ -491,4 +491,24 @@ public function upgrade_1804() {
$customData->syncOptionGroup(E::path('resources/formats_option_group.json'));
return TRUE;
}

public function upgrade_11301() {
$this->ctx->log->info('Adding financial_type_id column to civicrm_sdd_txgroup table.');
$column = CRM_Core_DAO::singleValueQuery(
<<<SQL
SHOW COLUMNS FROM `civicrm_sdd_txgroup` LIKE 'financial_type_id';
SQL
);
if (!$column) {
$this->executeSql(
<<<SQL
ALTER TABLE civicrm_sdd_txgroup
ADD COLUMN `financial_type_id`
int unsigned
COMMENT 'Financial type of contained contributions if CiviSEPA is generating groups matching financial types.';
SQL
);
}
return TRUE;
}
}
1 change: 1 addition & 0 deletions sql/sepa.sql
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@ CREATE TABLE IF NOT EXISTS `civicrm_sdd_txgroup` (
`reference` varchar(64) COMMENT 'End-to-end reference for this tx group.',
`type` char(4) COMMENT 'FRST, RCUR, OOFF or RTRY',
`collection_date` datetime COMMENT 'Target collection date',
`financial_type_id` int unsigned COMMENT 'Financial type of contained contributions if CiviSEPA is generating groups matching financial types.',
`latest_submission_date` datetime COMMENT 'Latest submission date',
`created_date` datetime COMMENT 'When was this item created',
`status_id` int unsigned NOT NULL COMMENT 'fk to Batch Status options in civicrm_option_values',
Expand Down
51 changes: 29 additions & 22 deletions xml/schema/CRM/Sepa/TransactionGroup.xml
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
<?xml version="1.0" encoding="iso-8859-1" ?>
<?xml version="1.0" encoding="iso-8859-1" ?>
<table>
<base>CRM/Sepa</base>
<class>SEPATransactionGroup</class>
<name>civicrm_sdd_txgroup</name>
<base>CRM/Sepa</base>
<class>SEPATransactionGroup</class>
<name>civicrm_sdd_txgroup</name>
<log>true</log>

<field>
<name>id</name>
<type>int unsigned</type>
<required>true</required>
<comment>ID</comment>
<field>
<name>id</name>
<type>int unsigned</type>
<required>true</required>
<comment>ID</comment>
<export>true</export>
</field>
<primaryKey>
<name>id</name>
<autoincrement>true</autoincrement>
</primaryKey>
</field>
<primaryKey>
<name>id</name>
<autoincrement>true</autoincrement>
</primaryKey>

<field>
<name>reference</name>
Expand All @@ -41,6 +41,13 @@
<type>datetime</type>
<comment>Target collection date</comment>
</field>

<field>
<name>financial_type_id</name>
<type>int unsigned</type>
<comment>Financial type of contained contributions if CiviSEPA is generating groups matching financial types.</comment>
</field>

<field>
<name>latest_submission_date</name>
<type>datetime</type>
Expand All @@ -67,10 +74,10 @@
<fieldName>sdd_creditor_id</fieldName>
<add>4.3</add>
</index>
<foreignKey>
<name>sdd_creditor_id</name>
<table>civicrm_sdd_creditor</table>
<key>id</key>
<foreignKey>
<name>sdd_creditor_id</name>
<table>civicrm_sdd_creditor</table>
<key>id</key>
<onDelete>SET NULL</onDelete>
</foreignKey>

Expand All @@ -83,10 +90,10 @@
<name>file_id</name>
<fieldName>sdd_file_id</fieldName>
</index>
<foreignKey>
<name>sdd_file_id</name>
<table>civicrm_sdd_file</table>
<key>id</key>
<foreignKey>
<name>sdd_file_id</name>
<table>civicrm_sdd_file</table>
<key>id</key>
<onDelete>SET NULL</onDelete>
</foreignKey>

Expand Down

0 comments on commit d4d95ed

Please sign in to comment.