@@ -139,37 +139,45 @@ WHERE entity_value = '' OR entity_value IS NULL
$postUpgradeMessage.='<br />'.ts("If you are interested in trying out the new Accounting Integration features, please review user permissions and assign the new 'manual batch' permissions as appropriate.");
// CRM-12155
$query="SELECT ceft.id FROM `civicrm_financial_trxn` cft
LEFT JOIN civicrm_entity_financial_trxn ceft
ON ceft.financial_trxn_id = cft.id AND ceft.entity_table = 'civicrm_contribution'
LEFT JOIN civicrm_contribution cc ON cc.id = ceft.entity_id AND ceft.entity_table = 'civicrm_contribution'
WHERE cc.id IS NULL";
$query="
SELECT ceft.id FROM `civicrm_financial_trxn` cft
LEFT JOIN civicrm_entity_financial_trxn ceft
ON ceft.financial_trxn_id = cft.id AND ceft.entity_table = 'civicrm_contribution'
LEFT JOIN civicrm_contribution cc
ON cc.id = ceft.entity_id AND ceft.entity_table = 'civicrm_contribution'
WHERE cc.id IS NULL
";
$dao=CRM_Core_DAO::executeQuery($query);
$isOrphanData=TRUE;
if(!$dao->N){
$query="SELECT cli.id FROM civicrm_line_item cli
$query="
SELECT cli.id FROM civicrm_line_item cli
LEFT JOIN civicrm_contribution cc ON cli.entity_id = cc.id AND cli.entity_table = 'civicrm_contribution'
LEFT JOIN civicrm_participant cp ON cli.entity_id = cp.id AND cli.entity_table = 'civicrm_participant'
WHERE CASE WHEN cli.entity_table = 'civicrm_contribution'
SELECT con.id as contribution_id, con.payment_instrument_id, IF(con.currency IN ('{$validCurrencyCodes}'), con.currency, '{$defaultCurrency}') as currency,
con.total_amount, con.net_amount, con.fee_amount, con.trxn_id, con.contribution_status_id, con.check_number, NULL as from_financial_account_id,
$sql="
SELECT con.id as contribution_id, con.payment_instrument_id,
IF(con.currency IN ('{$validCurrencyCodes}'), con.currency, '{$defaultCurrency}') as currency,
con.check_number, NULL as from_financial_account_id,
REPLACE(REPLACE(REPLACE(
CASE
WHEN con.receive_date IS NOT NULL THEN
...
...
@@ -441,13 +486,15 @@ SELECT con.id as contribution_id, con.payment_instrument_id, IF(con.currency IN
tpi.financial_account_id
END as to_financial_account_id,
IF(eft.financial_trxn_id IS NULL, 'insert', eft.financial_trxn_id) as action
FROM civicrm_contribution con
LEFT JOIN civicrm_entity_financial_trxn eft
ON (eft.entity_table = 'civicrm_contribution' AND eft.entity_id = con.id)
LEFT JOIN {$tempTableName1} tpi
ON con.payment_instrument_id = tpi.instrument_id
WHERE con.contribution_status_id IN ({$completedStatus}, {$cancelledStatus})";
FROM civicrm_contribution con
LEFT JOIN civicrm_entity_financial_trxn eft
ON (eft.entity_table = 'civicrm_contribution' AND eft.entity_id = con.id)
LEFT JOIN {$tempTableName1} tpi
ON con.payment_instrument_id = tpi.instrument_id
WHERE con.contribution_status_id IN ({$completedStatus}, {$cancelledStatus})
";
CRM_Core_DAO::executeQuery($sql);
// CRM-12141
$sql="ALTER TABLE {$tempTableName2} ADD INDEX index_action (action);";
CRM_Core_DAO::executeQuery($sql);
...
...
@@ -656,13 +703,15 @@ FROM civicrm_financial_item fi";
functioncreateDomainContacts(){
$domainParams=$context=array();
$query="
ALTER TABLE `civicrm_domain` ADD `contact_id` INT( 10 ) UNSIGNED NULL DEFAULT NULL COMMENT 'FK to Contact ID. This is specifically not an FK to avoid circular constraints',
ALTER TABLE civicrm_domain ADD contact_id INT( 10 ) UNSIGNED NULL DEFAULT NULL COMMENT 'FK to Contact ID. This is specifically not an FK to avoid circular constraints',