Skip to content

Commit

Permalink
Merge pull request #20312 from seamuslee001/improve_sample_data_trxn_…
Browse files Browse the repository at this point in the history
…id_payment_procesor_link

Improve Sample data by ensuring all Credit Card Contributions have a …
  • Loading branch information
seamuslee001 authored May 16, 2021
2 parents 436a4ca + 47ca44f commit 966fbbe
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 40 deletions.
8 changes: 4 additions & 4 deletions CRM/Core/CodeGen/GenerateData.php
Original file line number Diff line number Diff line change
Expand Up @@ -1917,8 +1917,8 @@ private function addMembershipPayment() {
$maxContribution = CRM_Core_DAO::singleValueQuery("select max(id) from civicrm_contribution");
$financialTypeID = CRM_Core_DAO::singleValueQuery("select id from civicrm_financial_type where name = 'Member Dues'");
$paymentInstrumentID = CRM_Core_DAO::singleValueQuery("select value from civicrm_option_value where name = 'Credit Card' AND option_group_id = (SELECT id from civicrm_option_group where name = 'payment_instrument')");
$sql = "INSERT INTO civicrm_contribution (contact_id,financial_type_id,payment_instrument_id, receive_date, total_amount, currency, source, contribution_status_id)
SELECT cm.contact_id, $financialTypeID, $paymentInstrumentID, now(), cmt.minimum_fee, 'USD', CONCAT(cmt.name, ' Membership: Offline signup'), 1 FROM `civicrm_membership` cm
$sql = "INSERT INTO civicrm_contribution (contact_id,financial_type_id,payment_instrument_id, receive_date, total_amount, currency, source, contribution_status_id, trxn_id)
SELECT cm.contact_id, $financialTypeID, $paymentInstrumentID, now(), cmt.minimum_fee, 'USD', CONCAT(cmt.name, ' Membership: Offline signup'), 1, SUBSTRING(MD5(RAND()) FROM 1 FOR 16) FROM `civicrm_membership` cm
LEFT JOIN civicrm_membership_type cmt ON cmt.id = cm.membership_type_id;";

$this->_query($sql);
Expand Down Expand Up @@ -1957,8 +1957,8 @@ private function addParticipantPayment() {
$maxContribution = CRM_Core_DAO::singleValueQuery("select max(id) from civicrm_contribution");
$financialTypeID = CRM_Core_DAO::singleValueQuery("select id from civicrm_financial_type where name = 'Event Fee'");
$paymentInstrumentID = CRM_Core_DAO::singleValueQuery("select value from civicrm_option_value where name = 'Credit Card' AND option_group_id = (SELECT id from civicrm_option_group where name = 'payment_instrument')");
$sql = "INSERT INTO civicrm_contribution (contact_id, financial_type_id, payment_instrument_id, receive_date, total_amount, currency, receipt_date, source, contribution_status_id)
SELECT `contact_id`, $financialTypeID, $paymentInstrumentID, now(), `fee_amount`, 'USD', now(), CONCAT(ce.title, ' : Offline registration'), 1 FROM `civicrm_participant` cp
$sql = "INSERT INTO civicrm_contribution (contact_id, financial_type_id, payment_instrument_id, receive_date, total_amount, currency, receipt_date, source, contribution_status_id, trxn_id)
SELECT `contact_id`, $financialTypeID, $paymentInstrumentID, now(), `fee_amount`, 'USD', now(), CONCAT(ce.title, ' : Offline registration'), 1, SUBSTRING(MD5(RAND()) FROM 1 FOR 16) FROM `civicrm_participant` cp
LEFT JOIN civicrm_event ce ON ce.id = cp.event_id
group by `contact_id`, `fee_amount`, `title`;";

Expand Down
2 changes: 2 additions & 0 deletions sql/civicrm_dummy_processor.mysql
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,5 @@ INSERT INTO `civicrm_entity_financial_account` (`entity_table`, `entity_id`, `ac
UPDATE `civicrm_contribution_page` SET payment_processor = @dp;

UPDATE `civicrm_event` SET payment_processor = @dp;

UPDATE `civicrm_financial_trxn` SET payment_processor_id = @dp WHERE trxn_id IS NOT NULL;
75 changes: 39 additions & 36 deletions sql/civicrm_generated.mysql

Large diffs are not rendered by default.

0 comments on commit 966fbbe

Please sign in to comment.