return CRM_Import_Parser::ERROR;
}
- if ($onDuplicate != CRM_Import_Parser::DUPLICATE_UPDATE) {
- $formatted['custom'] = CRM_Core_BAO_CustomField::postProcess($formatted,
- NULL,
- 'Contribution'
- );
- }
- else {
+ if ($onDuplicate == CRM_Import_Parser::DUPLICATE_UPDATE) {
//fix for CRM-2219 - Update Contribution
// onDuplicate == CRM_Import_Parser::DUPLICATE_UPDATE
if (!empty($paramValues['invoice_id']) || !empty($paramValues['trxn_id']) || !empty($paramValues['contribution_id'])) {
'trxn_id' => $paramValues['trxn_id'] ?? NULL,
'invoice_id' => $paramValues['invoice_id'] ?? NULL,
];
-
$ids['contribution'] = CRM_Contribute_BAO_Contribution::checkDuplicateIds($dupeIds);
if ($ids['contribution']) {
$formatted['id'] = $ids['contribution'];
- $formatted['custom'] = CRM_Core_BAO_CustomField::postProcess($formatted,
- $formatted['id'],
- 'Contribution'
- );
//process note
if (!empty($paramValues['note'])) {
$noteID = [];
}
$formatted['id'] = $ids['contribution'];
- $newContribution = CRM_Contribute_BAO_Contribution::create($formatted);
- $this->_newContributions[] = $newContribution->id;
+
+ $newContribution = civicrm_api3('contribution', 'create', $formatted);
+ $this->_newContributions[] = $newContribution['id'];
//return soft valid since we need to show how soft credits were added
if (!empty($formatted['soft_credit'])) {
if ((strtolower(trim($customLabel['label'])) == strtolower(trim($v1))) ||
(strtolower(trim($customValue)) == strtolower(trim($v1)))
) {
- if ($fieldType == 'CheckBox') {
- $values[$customValue] = 1;
- }
- else {
- $values[] = $customValue;
- }
+ $values[] = $customValue;
}
}
}
$this->assertArrayHasKey('phone', $fields);
}
+ /**
+ * Test custom multi-value checkbox field is imported properly.
+ */
+ public function testCustomSerializedCheckBox(): void {
+ $this->createCustomGroupWithFieldOfType([], 'checkbox');
+ $customField = $this->getCustomFieldName('checkbox');
+ $contactID = $this->individualCreate();
+ $values = ['contribution_contact_id' => $contactID, 'total_amount' => 10, 'financial_type' => 'Donation', $customField => 'L,V'];
+ $this->runImport($values, CRM_Import_Parser::DUPLICATE_SKIP, NULL);
+ $initialContribution = $this->callAPISuccessGetSingle('Contribution', ['contact_id' => $contactID]);
+ $this->assertContains('L', $initialContribution[$customField], "Contribution Duplicate Skip Import contains L");
+ $this->assertContains('V', $initialContribution[$customField], "Contribution Duplicate Skip Import contains V");
+
+ // Now update.
+ $values['contribution_id'] = $initialContribution['id'];
+ $values[$customField] = 'V';
+ $this->runImport($values, CRM_Import_Parser::DUPLICATE_UPDATE, NULL);
+
+ $updatedContribution = $this->callAPISuccessGetSingle('Contribution', ['id' => $initialContribution['id']]);
+ $this->assertNotContains('L', $updatedContribution[$customField], "Contribution Duplicate Update Import does not contain L");
+ $this->assertContains('V', $updatedContribution[$customField], "Contribution Duplicate Update Import contains V");
+
+ }
+
/**
* Run the import parser.
*