$note = CRM_Core_DAO_Note::import();
$tmpFields = CRM_Contribute_DAO_Contribution::import();
unset($tmpFields['option_value']);
- $optionFields = CRM_Core_OptionValue::getFields($mode = 'contribute');
$contactFields = CRM_Contact_BAO_Contact::importableFields($contactType, NULL);
// Using new Dedupe rule.
$fields = array_merge($fields, $tmpContactField);
$fields = array_merge($fields, $tmpFields);
$fields = array_merge($fields, $note);
- $fields = array_merge($fields, $optionFields);
- $fields = array_merge($fields, CRM_Financial_DAO_FinancialType::export());
$fields = array_merge($fields, CRM_Core_BAO_CustomField::getFieldsForImport('Contribution'));
self::$_importableFields = $fields;
}
*
* Generated from xml/schema/CRM/Contribute/Contribution.xml
* DO NOT EDIT. Generated by CRM_Core_CodeGen
- * (GenCodeChecksum:edd96be2e997a659ceeee0cf823c6f90)
+ * (GenCodeChecksum:0f869aa62eb1a94aedf6009a988cf01d)
*/
/**
'type' => CRM_Utils_Type::T_INT,
'title' => ts('Financial Type ID'),
'description' => ts('FK to Financial Type for (total_amount - non_deductible_amount).'),
+ 'import' => TRUE,
'where' => 'civicrm_contribution.financial_type_id',
'export' => TRUE,
'table_name' => 'civicrm_contribution',
'type' => CRM_Utils_Type::T_INT,
'title' => ts('Payment Method ID'),
'description' => ts('FK to Payment Instrument'),
+ 'import' => TRUE,
'where' => 'civicrm_contribution.payment_instrument_id',
'headerPattern' => '/^payment|(p(ayment\s)?instrument)$/i',
'export' => TRUE,
$requiredFields = [
$contactORContributionId == 'contribution_id' ? 'contribution_id' : 'contribution_contact_id' => $contactORContributionId == 'contribution_id' ? ts('Contribution ID') : ts('Contact ID'),
'total_amount' => ts('Total Amount'),
- 'financial_type' => ts('Financial Type'),
+ 'financial_type_id' => ts('Financial Type'),
];
foreach ($requiredFields as $field => $title) {
else {
$this->assign('rowDisplayCount', 2);
}
- $highlightedFields = ['financial_type', 'total_amount'];
+ $highlightedFields = ['financial_type_id', 'total_amount'];
//CRM-2219 removing other required fields since for updation only
//invoice id or trxn id or contribution id is required.
if ($this->_onDuplicate == CRM_Import_Parser::DUPLICATE_UPDATE) {
}
break;
- case 'financial_type':
- // @todo add test like testPaymentTypeLabel & remove these lines in favour of 'default' part of switch.
- require_once 'CRM/Contribute/PseudoConstant.php';
- $contriTypes = CRM_Contribute_PseudoConstant::financialType();
- foreach ($contriTypes as $val => $type) {
- if (strtolower($value) == strtolower($type)) {
- $values['financial_type_id'] = $val;
- break;
- }
- }
- if (empty($values['financial_type_id'])) {
- return civicrm_api3_create_error("Financial Type is not valid: $value");
- }
- break;
-
case 'soft_credit':
// import contribution record according to select contact type
// validate contact id and external identifier.
if (isset($fields[$key]) &&
// Yay - just for a surprise we are inconsistent on whether we pass the pseudofield (payment_instrument)
// or the field name (contribution_status_id)
+ // @todo - payment_instrument is goneburger - now payment_instrument_id - how
+ // can we simplify.
(!empty($fields[$key]['is_pseudofield_for']) || !empty($fields[$key]['pseudoconstant']))
) {
$realField = $fields[$key]['is_pseudofield_for'] ?? $key;
$nameTitle = [];
if ($mode == 'contribute') {
+ // @todo - remove this - the only code place that calls
+ // this function in a way that would hit this is commented 'remove this'
// This is part of a move towards standardising option values but we
// should derive them from the fields array so am deprecating it again...
// note that the reason this was needed was that payment_instrument_id was
// Duplicates are being skipped so id matching is not availble.
continue;
}
- $return[$name] = $field['title'];
+ $return[$name] = $field['html']['label'] ?? $field['title'];
}
return $return;
}
$fieldMap[ts('Soft Credit')] = 'soft_credit';
$fieldMap[ts('Pledge Payment')] = 'pledge_payment';
$fieldMap[ts(ts('Pledge ID'))] = 'pledge_id';
+ $fieldMap[ts(ts('Financial Type'))] = 'financial_type_id';
+ $fieldMap[ts(ts('Payment Method'))] = 'payment_instrument_id';
foreach ($mappings as $mapping) {
if (!empty($fieldMap[$mapping['name']])) {
$contact2Id = $this->individualCreate($contact2Params);
$values = [
'total_amount' => $this->formatMoneyInput(1230.99),
- 'financial_type' => 'Donation',
+ 'financial_type_id' => 'Donation',
'external_identifier' => 'ext-1',
'soft_credit' => 'ext-2',
];
$this->addRandomOption();
$contactID = $this->individualCreate();
- $values = ['contribution_contact_id' => $contactID, 'total_amount' => 10, 'financial_type' => 'Donation', 'payment_instrument' => 'Check'];
+ $values = ['contribution_contact_id' => $contactID, 'total_amount' => 10, 'financial_type_id' => 'Donation', 'payment_instrument_id' => 'Check'];
$this->runImport($values, CRM_Import_Parser::DUPLICATE_UPDATE, NULL);
$contribution = $this->callAPISuccessGetSingle('Contribution', ['contact_id' => $contactID]);
$this->assertEquals('Check', $contribution['payment_instrument']);
- $values = ['contribution_contact_id' => $contactID, 'total_amount' => 10, 'financial_type' => 'Donation', 'payment_instrument' => 'not at all random'];
+ $values = ['contribution_contact_id' => $contactID, 'total_amount' => 10, 'financial_type_id' => 'Donation', 'payment_instrument_id' => 'not at all random'];
$this->runImport($values, CRM_Import_Parser::DUPLICATE_UPDATE, NULL);
$contribution = $this->callAPISuccessGetSingle('Contribution', ['contact_id' => $contactID, 'payment_instrument_id' => 'random']);
$this->assertEquals('not at all random', $contribution['payment_instrument']);
*/
public function testContributionStatusLabel(): void {
$contactID = $this->individualCreate();
- $values = ['contribution_contact_id' => $contactID, 'total_amount' => 10, 'financial_type' => 'Donation', 'payment_instrument' => 'Check', 'contribution_status_id' => 'Pending'];
+ $values = ['contribution_contact_id' => $contactID, 'total_amount' => 10, 'financial_type_id' => 'Donation', 'payment_instrument_id' => 'Check', 'contribution_status_id' => 'Pending'];
// Note that the expected result should logically be CRM_Import_Parser::valid but writing test to reflect not fix here
$this->runImport($values, CRM_Import_Parser::DUPLICATE_UPDATE, NULL);
$contribution = $this->callAPISuccessGetSingle('Contribution', ['contact_id' => $contactID]);
public function testParsedCustomOption(): void {
$contactID = $this->individualCreate();
- $values = ['contribution_contact_id' => $contactID, 'total_amount' => 10, 'financial_type' => 'Donation', 'payment_instrument' => 'Check', 'contribution_status_id' => 'Pending'];
+ $values = ['contribution_contact_id' => $contactID, 'total_amount' => 10, 'financial_type_id' => 'Donation', 'payment_instrument_id' => 'Check', 'contribution_status_id' => 'Pending'];
// Note that the expected result should logically be CRM_Import_Parser::valid but writing test to reflect not fix here
$this->runImport($values, CRM_Import_Parser::DUPLICATE_UPDATE, NULL);
$contribution = $this->callAPISuccess('Contribution', 'getsingle', ['contact_id' => $contactID]);
$this->createCustomGroupWithFieldOfType([], 'checkbox');
$customField = $this->getCustomFieldName('checkbox');
$contactID = $this->individualCreate();
- $values = ['contribution_contact_id' => $contactID, 'total_amount' => 10, 'financial_type' => 'Donation', $customField => 'L,V'];
+ $values = ['contribution_contact_id' => $contactID, 'total_amount' => 10, 'financial_type_id' => '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");
<labelColumn>name</labelColumn>
</pseudoconstant>
<export>true</export>
+ <import>true</import>
<html>
<type>Select</type>
<label>Financial Type</label>
<type>int unsigned</type>
<comment>FK to Payment Instrument</comment>
<export>true</export>
+ <import>true</import>
<headerPattern>/^payment|(p(ayment\s)?instrument)$/i</headerPattern>
<pseudoconstant>
<optionGroupName>payment_instrument</optionGroupName>