Use Yes-No radio instead of checkbox on search form.
}
$query->_where[$grouping][] = CRM_Contact_BAO_Query::buildClause("civicrm_case.{$name}", $op, $value, "Integer");
- $query->_qill[$grouping][] = self::getQillValue('CRM_Case_DAO_Case', $name, $value, $op, $label);
+ $query->_qill[$grouping][] = CRM_Contact_BAO_Query::getQillValue('CRM_Case_DAO_Case', $name, $value, $op, $label);
$query->_tables['civicrm_case'] = $query->_whereTables['civicrm_case'] = 1;
return;
case 'case_subject':
$query->_where[$grouping][] = CRM_Contact_BAO_Query::buildClause("civicrm_case.subject", $op, $value, 'String');
- $query->_qill[$grouping][] = self::getQillValue('CRM_Case_DAO_Case', $name, $value, $op, 'Case Subject');
+ $query->_qill[$grouping][] = CRM_Contact_BAO_Query::getQillValue('CRM_Case_DAO_Case', $name, $value, $op, 'Case Subject');
$query->_tables['civicrm_case'] = $query->_whereTables['civicrm_case'] = 1;
$query->_tables['civicrm_case_contact'] = $query->_whereTables['civicrm_case_contact'] = 1;
return;
return $from;
}
- /**
- * Get the qill (search description for field) for the specified field.
- *
- * @todo this is private because it is the first step towards generalising rather than
- * the final product IMHO.
- *
- * @param string $daoName
- * @param string $name
- * @param string $value
- * @param string|array $op
- * @param string $label
- *
- * @return string
- */
- private static function getQillValue($daoName, string $name, $value, $op, string $label) {
- list($op, $value) = CRM_Contact_BAO_Query::buildQillForFieldValue($daoName, $name, $value, $op);
- return ts('%1 %2 %3', [1 => $label, 2 => $op, 3 => $value]);
- }
-
/**
* Getter for the qill object.
*
return [CRM_Utils_Array::value($op, $qillOperators, $op), $fieldValue];
}
+ /**
+ * Get the qill (search description for field) for the specified field.
+ *
+ * @param string $daoName
+ * @param string $name
+ * @param string $value
+ * @param string|array $op
+ * @param string $label
+ *
+ * @return string
+ */
+ public static function getQillValue($daoName, string $name, $value, $op, string $label) {
+ list($op, $value) = self::buildQillForFieldValue($daoName, $name, $value, $op);
+ return ts('%1 %2 %3', [1 => $label, 2 => $op, 3 => $value]);
+ }
+
/**
* Alter value to reflect wildcard settings.
*
FROM (
SELECT civicrm_contribution.total_amount, civicrm_contribution.currency
$from
- $where AND civicrm_contribution.cancel_date IS NOT NULL
+ $where AND civicrm_contribution.cancel_date IS NOT NULL
GROUP BY civicrm_contribution.id
) as conts
GROUP BY currency";
}
self::setModeValues();
- if (!array_key_exists($mode, self::$_modeValues)) {
+ // Note $mode might === FALSE because array_search above failed, e.g. for searchPane='location'
+ if (empty(self::$_modeValues[$mode])) {
$mode = CRM_Contact_BAO_Query::MODE_CONTACTS;
}
* @param $feeBlock
* @param array $lineItems
*
+ * @throws \CiviCRM_API3_Exception
*/
public static function changeFeeSelections(
$params,
'entity_id' => $entityID,
'contribution_id' => $contributionID,
]);
- $financialTypeChangeTrxnID = $this->addFinancialItemsOnLineItemChange($trxnID, $lineParams, $updatedContribution);
$lineObj = CRM_Price_BAO_LineItem::retrieve($lineParams);
// insert financial items
// ensure entity_financial_trxn table has a linking of it.
return $adjustedTrxn;
}
- /**
- * Add financial items to reflect line item change.
- *
- * @param bool $isCreateAdditionalFinancialTrxn
- * @param array $lineParams
- * @param \CRM_Contribute_BAO_Contribution $updatedContribution
- */
- protected function addFinancialItemsOnLineItemChange($isCreateAdditionalFinancialTrxn, $lineParams, $updatedContribution) {
- $tempFinancialTrxnID = NULL;
- // don't add financial item for cancelled line item
- if ($lineParams['qty'] == 0) {
- return NULL;
- }
- elseif ($isCreateAdditionalFinancialTrxn) {
- // This routine & the return below is super uncomfortable.
- // I have refactored to here and it is hit from
- // testSubmitUnpaidPriceChangeWhileStillPending
- // but I'm still skeptical it's not covered elsewhere.
- // original comment : add financial item if ONLY financial type is changed
- if ($lineParams['financial_type_id'] != $updatedContribution->financial_type_id) {
- $changedFinancialTypeID = (int) $lineParams['financial_type_id'];
- $adjustedTrxnValues = [
- 'from_financial_account_id' => NULL,
- 'to_financial_account_id' => CRM_Financial_BAO_FinancialTypeAccount::getInstrumentFinancialAccount($updatedContribution->payment_instrument_id),
- 'total_amount' => $lineParams['line_total'],
- 'net_amount' => $lineParams['line_total'],
- 'status_id' => $updatedContribution->contribution_status_id,
- 'payment_instrument_id' => $updatedContribution->payment_instrument_id,
- 'contribution_id' => $updatedContribution->id,
- 'is_payment' => TRUE,
- // since balance is 0, which means contribution is completed
- 'trxn_date' => date('YmdHis'),
- 'currency' => $updatedContribution->currency,
- ];
- $adjustedTrxn = CRM_Core_BAO_FinancialTrxn::create($adjustedTrxnValues);
- return $adjustedTrxn->id;
- }
- }
- }
-
/**
* Get Financial items, culling out any that have already been reversed.
*
/**
* Setup function.
+ *
+ * @throws \CRM_Core_Exception
+ * @throws \CiviCRM_API3_Exception
*/
public function setUp() {
parent::setUp();
/**
* Clean up after each test.
+ *
+ * @throws \CRM_Core_Exception
*/
public function tearDown() {
$this->quickCleanUpFinancialEntities();
- CRM_Core_DAO::executeQuery('DELETE FROM civicrm_mailing_spool ORDER BY id DESC');
+ $this->quickCleanup(['civicrm_mailing_spool']);
parent::tearDown();
}
/**
* Test the submit function that completes the partially paid Contribution using Credit Card.
+ *
+ * @throws \CRM_Core_Exception
+ * @throws \CiviCRM_API3_Exception
*/
- public function testAddPaymentUsingCreditCardForPartialyPaidContribution() {
+ public function testAddPaymentUsingCreditCardForPartiallyPaidContribution() {
$mut = new CiviMailUtils($this, TRUE);
- $this->createContribution('Partially paid');
+ $this->createPartiallyPaidOrder();
// pay additional amount by using Credit Card
$this->submitPayment(70, 'live', TRUE);
/**
* Test the submit function that completes the partially paid Contribution.
+ *
+ * @throws \CRM_Core_Exception
+ * @throws \CiviCRM_API3_Exception
*/
- public function testAddPaymentForPartialyPaidContribution() {
- $this->createContribution('Partially paid');
+ public function testAddPaymentForPartiallyPaidContribution() {
+ $this->createPartiallyPaidOrder();
// pay additional amount
$this->submitPayment(70);
/**
* Test the submit function that completes the partially paid Contribution with multiple payments.
+ *
+ * @throws \CRM_Core_Exception
+ * @throws \CiviCRM_API3_Exception
*/
public function testMultiplePaymentForPartiallyPaidContribution() {
- $this->createContribution('Partially paid');
+ $this->createPartiallyPaidOrder();
// pay additional amount
$this->submitPayment(50);
'sequential' => 1,
'return' => ['target_contact_id', 'assignee_contact_id', 'subject'],
])['values'];
- $this->assertEquals(2, count($activities));
- $this->assertEquals('$ 50.00 - Offline Payment for Contribution', $activities[0]['subject']);
- $this->assertEquals('$ 20.00 - Offline Payment for Contribution', $activities[1]['subject']);
+ $this->assertCount(3, $activities);
+ $this->assertEquals('$ 50.00 - Offline Payment for Contribution', $activities[1]['subject']);
+ $this->assertEquals('$ 20.00 - Offline Payment for Contribution', $activities[2]['subject']);
$this->assertEquals(CRM_Core_Session::singleton()->getLoggedInContactID(), $activities[0]['source_contact_id']);
$this->assertEquals([$this->_individualId], $activities[0]['target_contact_id']);
$this->assertEquals([], $activities[0]['assignee_contact_id']);
* Test the submit function that completes the partially paid Contribution with multiple payments.
*
* @throws \CRM_Core_Exception
+ * @throws \CiviCRM_API3_Exception
*/
public function testMultiplePaymentForPartiallyPaidContributionWithOneCreditCardPayment() {
$mut = new CiviMailUtils($this, TRUE);
- $this->createContribution('Partially paid');
+ $this->createPartiallyPaidOrder();
// In general when there is tpl leakage we try to fix. At the moment, however,
// the tpl leakage on credit card related things is kind of 'by-design' - or
// at least we haven't found a way to replace the way in with Payment.send_confirmation
* Test the submit function that completes the pending pay later Contribution using Credit Card.
*
* @throws \CRM_Core_Exception
+ * @throws \CiviCRM_API3_Exception
*/
public function testAddPaymentUsingCreditCardForPendingPayLaterContribution() {
$mut = new CiviMailUtils($this, TRUE);
- $this->createContribution('Pending');
+ $this->createPendingOrder();
// pay additional amount by using Credit Card
$this->submitPayment(100, 'live', TRUE);
/**
* Test the submit function that completes the pending pay later Contribution.
+ *
+ * @throws \CRM_Core_Exception
+ * @throws \CiviCRM_API3_Exception
*/
public function testAddPaymentForPendingPayLaterContribution() {
- $this->createContribution('Pending');
+ $this->createPendingOrder();
// pay additional amount
$this->submitPayment(70);
/**
* Test the Membership status after completing the pending pay later Contribution.
+ *
+ * @throws \CRM_Core_Exception
+ * @throws \CiviCRM_API3_Exception
*/
public function testMembershipStatusAfterCompletingPayLaterContribution() {
- $this->createContribution('Pending');
+ $this->createPendingOrder();
$membership = $this->createPendingMembershipAndRecordContribution($this->_contributionId);
// pay additional amount
$this->submitPayment(100);
- $contribution = $this->callAPISuccessGetSingle('Contribution', ['id' => $this->_contributionId]);
- $contributionMembership = $this->callAPISuccessGetSingle('Membership', ['id' => $membership["id"]]);
- $membershipStatus = $this->callAPISuccessGetSingle('MembershipStatus', ['id' => $contributionMembership["status_id"]]);
+ $this->callAPISuccessGetSingle('Contribution', ['id' => $this->_contributionId]);
+ $contributionMembership = $this->callAPISuccessGetSingle('Membership', ['id' => $membership['id']]);
+ $membershipStatus = $this->callAPISuccessGetSingle('MembershipStatus', ['id' => $contributionMembership['status_id']]);
$this->assertEquals('New', $membershipStatus['name']);
}
+ /**
+ * @param $contributionId
+ *
+ * @return array|int
+ *
+ * @throws \CRM_Core_Exception
+ */
private function createPendingMembershipAndRecordContribution($contributionId) {
$this->_individualId = $this->individualCreate();
$membershipTypeAnnualFixed = $this->callAPISuccess('membership_type', 'create', [
'domain_id' => 1,
- 'name' => "AnnualFixed",
+ 'name' => 'AnnualFixed',
'member_of_contact_id' => 1,
- 'duration_unit' => "year",
+ 'duration_unit' => 'year',
'duration_interval' => 1,
- 'period_type' => "fixed",
- 'fixed_period_start_day' => "101",
- 'fixed_period_rollover_day' => "1231",
+ 'period_type' => 'fixed',
+ 'fixed_period_start_day' => '101',
+ 'fixed_period_rollover_day' => '1231',
'relationship_type_id' => 20,
'financial_type_id' => 2,
]);
$membershipStatuses = CRM_Member_PseudoConstant::membershipStatus();
- $pendingStatusId = array_search('Pending', $membershipStatuses);
+ $pendingStatusId = array_search('Pending', $membershipStatuses, TRUE);
$membership = $this->callAPISuccess('Membership', 'create', [
'contact_id' => $this->_individualId,
'membership_type_id' => $membershipTypeAnnualFixed['id'],
]);
// Updating Membership status to Pending
$membership = $this->callAPISuccess('Membership', 'create', [
- 'id' => $membership["id"],
+ 'id' => $membership['id'],
'status_id' => $pendingStatusId,
]);
- $membershipPayment = $this->callAPISuccess('MembershipPayment', 'create', [
- 'membership_id' => $membership["id"],
+ $this->callAPISuccess('MembershipPayment', 'create', [
+ 'membership_id' => $membership['id'],
'contribution_id' => $contributionId,
]);
return $membership;
/**
* Test the submit function that completes the pending pay later Contribution with multiple payments.
+ *
+ * @throws \CRM_Core_Exception
+ * @throws \CiviCRM_API3_Exception
*/
public function testMultiplePaymentForPendingPayLaterContribution() {
- $this->createContribution('Pending');
+ $this->createPendingOrder();
// pay additional amount
$this->submitPayment(40);
/**
* Test the submit function that completes the pending pay later Contribution with multiple payments.
+ *
+ * @throws \CRM_Core_Exception
+ * @throws \CiviCRM_API3_Exception
*/
public function testMultiplePaymentForPendingPayLaterContributionWithOneCreditCardPayment() {
- $this->createContribution('Pending');
+ $this->createPendingOrder();
// pay additional amount
$this->submitPayment(50);
$this->checkResults([50, 20, 20, 10], 4);
}
- /**
- * Function to create pending pay later or partially paid conntribution.
- *
- * @param string $typeofContribution
- *
- * @throws \CRM_Core_Exception
- */
- public function createContribution($typeofContribution = 'Pending') {
- if ($typeofContribution == 'Partially paid') {
- $contributionParams = array_merge($this->_params, [
- 'partial_payment_total' => 100.00,
- 'partial_amount_to_pay' => 30,
- 'contribution_status_id' => 1,
- ]);
- }
- elseif ($typeofContribution == 'Pending') {
- $contributionParams = array_merge($this->_params, [
- 'contribution_status_id' => 2,
- 'is_pay_later' => 1,
- ]);
- }
- $contribution = $this->callAPISuccess('Contribution', 'create', $contributionParams);
- $contribution = $this->callAPISuccessGetSingle('Contribution', ['id' => $contribution['id']]);
- $this->assertNotEmpty($contribution);
- $this->assertEquals($typeofContribution, CRM_Core_PseudoConstant::getName('CRM_Contribute_BAO_Contribution', 'contribution_status_id', $contribution['contribution_status_id']));
- $this->_contributionId = $contribution['id'];
- }
-
/**
* Function to submit payments for contribution.
*
* @param string $mode
* Mode of Payment
* @param bool $isEmailReceipt
+ *
+ * @throws \CiviCRM_API3_Exception
*/
public function submitPayment($amount, $mode = NULL, $isEmailReceipt = FALSE) {
$form = new CRM_Contribute_Form_AdditionalPayment();
];
if ($mode) {
$submitParams += [
- 'payment_instrument_id' => array_search('Credit Card', $this->paymentInstruments),
+ 'payment_instrument_id' => array_search('Credit Card', $this->paymentInstruments, TRUE),
'payment_processor_id' => $this->paymentProcessorID,
'credit_card_exp_date' => ['M' => 5, 'Y' => 2025],
'credit_card_number' => '411111111111111',
}
else {
$submitParams += [
- 'payment_instrument_id' => array_search('Check', $this->paymentInstruments),
+ 'payment_instrument_id' => array_search('Check', $this->paymentInstruments, TRUE),
'check_number' => 'check-12345',
];
}
* @param int $count
* Number payment for contribution
*
+ * @throws \CRM_Core_Exception
*/
public function checkResults($amounts, $count) {
$contribution = $this->callAPISuccessGetSingle('Contribution', ['id' => $this->_contributionId]);
$this->assertEquals('Completed', $contribution['contribution_status']);
$this->callAPISuccessGetCount('EntityFinancialTrxn', [
- 'entity_table' => "civicrm_contribution",
+ 'entity_table' => 'civicrm_contribution',
'entity_id' => $this->_contributionId,
'financial_trxn_id.is_payment' => 1,
'financial_trxn_id.total_amount' => ['IN' => $amounts],
], $count);
}
+ /**
+ * Create a pending order.
+ *
+ * @throws \CRM_Core_Exception
+ */
+ protected function createPendingOrder() {
+ $orderParams = array_merge($this->_params, [
+ 'contribution_status_id' => 'Pending',
+ 'is_pay_later' => 1,
+ ]);
+ $contribution = $this->callAPISuccess('Order', 'create', $orderParams);
+ $contribution = $this->callAPISuccessGetSingle('Contribution', ['id' => $contribution['id']]);
+ $this->assertEquals('Pending', CRM_Core_PseudoConstant::getName('CRM_Contribute_BAO_Contribution', 'contribution_status_id', $contribution['contribution_status_id']));
+ $this->_contributionId = $contribution['id'];
+ }
+
+ /**
+ * Create a partially paid order.
+ *
+ * @throws \CRM_Core_Exception
+ */
+ protected function createPartiallyPaidOrder() {
+ $orderParams = array_merge($this->_params, [
+ 'total_amount' => 100.00,
+ 'contribution_status_id' => 'Pending',
+ 'api.Payment.create' => ['total_amount' => 30],
+ ]);
+ $contribution = $this->callAPISuccess('Order', 'create', $orderParams);
+ $contribution = $this->callAPISuccessGetSingle('Contribution', ['id' => $contribution['id']]);
+ $this->assertEquals('Partially paid', CRM_Core_PseudoConstant::getName('CRM_Contribute_BAO_Contribution', 'contribution_status_id', $contribution['contribution_status_id']));
+ $this->_contributionId = $contribution['id'];
+ }
+
}
/**
* Set up for test.
+ *
+ * @throws \CRM_Core_Exception
+ * @throws \CiviCRM_API3_Exception
*/
public function setUp() {
parent::setUp();
* @param string $type
*
* @return int
+ * @throws \CRM_Core_Exception
+ * @throws \CiviCRM_API3_Exception
* @todo resolve this with parent function.
*/
protected function priceSetCreate($type = 'Radio') {
- $feeTotal = 55;
- $minAmt = 0;
$paramsSet['title'] = 'Two Options' . substr(sha1(rand()), 0, 4);
$paramsSet['name'] = CRM_Utils_String::titleToVar('Two Options') . substr(sha1(rand()), 0, 4);
$paramsSet['is_active'] = FALSE;
$priceSet = CRM_Price_BAO_PriceSet::create($paramsSet);
- if ($type == 'Text') {
+ if ($type === 'Text') {
$paramsField = [
'label' => 'Text Price Field',
'name' => CRM_Utils_String::titleToVar('text_price_field'),
];
}
else {
+ /** @noinspection UnNecessaryDoubleQuotesInspection */
$paramsField = [
'label' => 'Price Field',
'name' => CRM_Utils_String::titleToVar('Two Options'),
'html_type' => 'Radio',
//'price' => $feeTotal,
- 'option_label' => ['1' => 'Expensive Room', '2' => "Cheap Room", '3' => 'Very Expensive', '4' => 'No Fee'],
+ 'option_label' => ['1' => 'Expensive Room', '2' => 'Cheap Room', '3' => 'Very Expensive', '4' => 'No Fee'],
'option_value' => ['1' => 'E', '2' => 'C', '3' => 'V', '4' => 'N'],
- 'option_name' => ['1' => 'Expensive', '2' => "Cheap", "3" => "Very Expensive", '3' => 'No Fee'],
+ 'option_name' => ['1' => 'Expensive', '2' => 'Cheap', '3' => 'Very Expensive'],
'option_weight' => ['1' => 1, '2' => 2, '3' => 3, '4' => 4],
'option_amount' => ['1' => $this->_expensiveFee, '2' => $this->_cheapFee, '3' => $this->_veryExpensive, '4' => $this->_noFee],
'option_count' => [1 => 1, 2 => 1, 3 => 1, 4 => 1],
WHERE contribution_id = {$contributionId}";
$dao = CRM_Core_DAO::executeQuery($query);
- $this->assertTrue($dao->fetch(), "Succeeded retrieving invoicetotal");
+ $this->assertTrue($dao->fetch(), 'Succeeded retrieving invoice total');
return $dao->total;
}
";
$dao = CRM_Core_DAO::executeQuery($query);
- $this->assertTrue($dao->fetch(), "Succeeded retrieving total Income");
+ $this->assertTrue($dao->fetch(), 'Succeeded retrieving total Income');
return $dao->total;
}
/**
* Prepare records for editing.
+ *
+ * @param null $actualPaidAmt
+ *
+ * @throws \CRM_Core_Exception
*/
public function registerParticipantAndPay($actualPaidAmt = NULL) {
$params = [
'is_test' => 0,
'is_pay_later' => 0,
'event_id' => $this->_eventId,
- 'register_date' => date('Y-m-d') . " 00:00:00",
+ 'register_date' => date('Y-m-d') . ' 00:00:00',
'role_id' => 1,
'status_id' => 1,
'source' => 'Event_' . $this->_eventId,
$participant = $this->callAPISuccess('Participant', 'create', $params);
$this->_participantId = $participant['id'];
- $actualPaidAmt = $actualPaidAmt ? $actualPaidAmt : $this->_expensiveFee;
+ $actualPaidAmt = $actualPaidAmt ?: $this->_expensiveFee;
$contributionParams = [
'total_amount' => $actualPaidAmt,
- 'source' => 'Testset with information',
+ 'source' => 'Test set with information',
'currency' => 'USD',
- 'receipt_date' => date('Y-m-d') . " 00:00:00",
+ 'receipt_date' => date('Y-m-d') . ' 00:00:00',
'contact_id' => $this->_contactId,
'financial_type_id' => 4,
'payment_instrument_id' => 4,
'contribution_status_id' => 1,
- 'receive_date' => date('Y-m-d') . " 00:00:00",
+ 'receive_date' => date('Y-m-d') . ' 00:00:00',
'skipLineItem' => 1,
'partial_payment_total' => $this->_expensiveFee,
'partial_amount_to_pay' => $actualPaidAmt,
}
+ /**
+ * @throws \CRM_Core_Exception
+ */
public function testCRM19273() {
$this->registerParticipantAndPay();
$priceSetParams['price_' . $this->priceSetFieldID] = $this->cheapFeeValueID;
$lineItem = CRM_Price_BAO_LineItem::getLineItems($this->_participantId, 'participant');
- CRM_Price_BAO_LineItem::changeFeeSelections($priceSetParams, $this->_participantId, 'participant', $this->_contributionId, $this->_feeBlock, $lineItem, $this->_expensiveFee);
+ CRM_Price_BAO_LineItem::changeFeeSelections($priceSetParams, $this->_participantId, 'participant', $this->_contributionId, $this->_feeBlock, $lineItem);
$this->balanceCheck($this->_cheapFee);
$priceSetParams['price_' . $this->priceSetFieldID] = $this->expensiveFeeValueID;
$lineItem = CRM_Price_BAO_LineItem::getLineItems($this->_participantId, 'participant');
- CRM_Price_BAO_LineItem::changeFeeSelections($priceSetParams, $this->_participantId, 'participant', $this->_contributionId, $this->_feeBlock, $lineItem, $this->_expensiveFee);
+ CRM_Price_BAO_LineItem::changeFeeSelections($priceSetParams, $this->_participantId, 'participant', $this->_contributionId, $this->_feeBlock, $lineItem);
$this->balanceCheck($this->_expensiveFee);
$priceSetParams['price_' . $this->priceSetFieldID] = $this->veryExpensiveFeeValueID;
$lineItem = CRM_Price_BAO_LineItem::getLineItems($this->_participantId, 'participant');
- CRM_Price_BAO_LineItem::changeFeeSelections($priceSetParams, $this->_participantId, 'participant', $this->_contributionId, $this->_feeBlock, $lineItem, $this->_expensiveFee);
+ CRM_Price_BAO_LineItem::changeFeeSelections($priceSetParams, $this->_participantId, 'participant', $this->_contributionId, $this->_feeBlock, $lineItem);
$this->balanceCheck($this->_veryExpensive);
}
/**
* CRM-21245: Test that Contribution status doesn't changed to 'Pending Refund' from 'Partially Paid' if the partially paid amount is lower then newly selected fee amount
+ *
+ * @throws \CRM_Core_Exception
*/
public function testCRM21245() {
$this->registerParticipantAndPay(50);
- $partiallyPaidContribuitonStatus = CRM_Core_PseudoConstant::getKey('CRM_Contribute_BAO_Contribution', 'contribution_status_id', 'Partially paid');
- $this->assertEquals($this->callAPISuccessGetValue('Contribution', ['id' => $this->_contributionId, 'return' => 'contribution_status_id']), $partiallyPaidContribuitonStatus);
+ $partiallyPaidContributionStatus = CRM_Core_PseudoConstant::getKey('CRM_Contribute_BAO_Contribution', 'contribution_status_id', 'Partially paid');
+ $this->assertEquals($this->callAPISuccessGetValue('Contribution', ['id' => $this->_contributionId, 'return' => 'contribution_status_id']), $partiallyPaidContributionStatus);
$priceSetParams['price_' . $this->priceSetFieldID] = $this->veryExpensiveFeeValueID;
$lineItem = CRM_Price_BAO_LineItem::getLineItems($this->_participantId, 'participant');
CRM_Price_BAO_LineItem::changeFeeSelections($priceSetParams, $this->_participantId, 'participant', $this->_contributionId, $this->_feeBlock, $lineItem);
- $this->assertEquals($this->callAPISuccessGetValue('Contribution', ['id' => $this->_contributionId, 'return' => 'contribution_status_id']), $partiallyPaidContribuitonStatus);
+ $this->assertEquals($this->callAPISuccessGetValue('Contribution', ['id' => $this->_contributionId, 'return' => 'contribution_status_id']), $partiallyPaidContributionStatus);
}
/**
* Test that proper financial items are recorded for cancelled line items
+ *
+ * @throws \CRM_Core_Exception
*/
public function testCRM20611() {
$this->registerParticipantAndPay();
/**
* Test to ensure that correct financial records are entered on text price field fee change on event registration
+ *
+ * @throws \CRM_Core_Exception
+ * @throws \CiviCRM_API3_Exception
*/
public function testCRM21513() {
$this->_priceSetID = $this->priceSetCreate('Text');
'is_test' => 0,
'is_pay_later' => 0,
'event_id' => $this->_eventId,
- 'register_date' => date('Y-m-d') . " 00:00:00",
+ 'register_date' => date('Y-m-d') . ' 00:00:00',
'role_id' => 1,
'status_id' => 1,
'source' => 'Event_' . $this->_eventId,
$this->_participantId = $participant['id'];
$contributionParams = [
'total_amount' => 10,
- 'source' => 'Testset with information',
+ 'source' => 'Test set with information',
'currency' => 'USD',
- 'receipt_date' => date('Y-m-d') . " 00:00:00",
+ 'receipt_date' => date('Y-m-d') . ' 00:00:00',
'contact_id' => $this->_contactId,
'financial_type_id' => 4,
'payment_instrument_id' => 4,
'contribution_status_id' => CRM_Core_PseudoConstant::getKey('CRM_Contribute_DAO_Contribution', 'contribution_status_id', 'Pending'),
- 'receive_date' => date('Y-m-d') . " 00:00:00",
+ 'receive_date' => date('Y-m-d') . ' 00:00:00',
'skipLineItem' => 1,
];
// CASE 2: Choose text price qty 3 (x$10 = $30 amount)
$priceSetParams['price_' . $this->priceSetFieldID] = 3;
$lineItem = CRM_Price_BAO_LineItem::getLineItems($participant['id'], 'participant');
- CRM_Price_BAO_LineItem::changeFeeSelections($priceSetParams, $participant['id'], 'participant', $this->_contributionId, $this->_feeBlock, $lineItem, 0);
+ CRM_Price_BAO_LineItem::changeFeeSelections($priceSetParams, $participant['id'], 'participant', $this->_contributionId, $this->_feeBlock, $lineItem);
// CASE 3: Choose text price qty 2 (x$10 = $20 amount)
$priceSetParams['price_' . $this->priceSetFieldID] = 2;
$lineItem = CRM_Price_BAO_LineItem::getLineItems($participant['id'], 'participant');
- CRM_Price_BAO_LineItem::changeFeeSelections($priceSetParams, $participant['id'], 'participant', $this->_contributionId, $this->_feeBlock, $lineItem, 0);
+ CRM_Price_BAO_LineItem::changeFeeSelections($priceSetParams, $participant['id'], 'participant', $this->_contributionId, $this->_feeBlock, $lineItem);
$financialItems = $this->callAPISuccess('FinancialItem', 'Get', [
'entity_table' => 'civicrm_line_item',
/**
* CRM-17151: Test that Contribution status change to 'Completed' if balance is zero.
+ *
+ * @throws \CRM_Core_Exception
*/
public function testCRM17151() {
$this->registerParticipantAndPay();
/**
* Test that recording a refund when fee selection is 0 works
+ *
+ * @throws \CRM_Core_Exception
*/
public function testRefundWithFeeAmount0() {
$this->registerParticipantAndPay();
/**
* dev-financial-40: Test that partial payment entries in entity-financial-trxn table to ensure that reverse transaction is entered
+ *
+ * @throws \CRM_Core_Exception
*/
public function testPartialPaymentEntries() {
$this->registerParticipantAndPay($this->_expensiveFee);
/**
* dev-financial-40: Test that refund payment entries in entity-financial-trxn table to ensure that reverse transaction is entered on fee change to lesser amount
+ *
+ * @throws \CRM_Core_Exception
*/
public function testRefundPaymentEntries() {
$this->registerParticipantAndPay($this->_expensiveFee);
$this->assertEquals(55, $sum);
CRM_Price_BAO_LineItem::changeFeeSelections($priceSetParams, $participants['id'], 'participant', $contribution['id'], $this->eventFeeBlock, $lineItem);
+ // Check that no payment records have been created.
+ // In https://lab.civicrm.org/dev/financial/issues/94 we had an issue where payments were created when none happend.
+ $payments = $this->callAPISuccess('Payment', 'get', [])['values'];
+ $this->assertCount(0, $payments);
$lineItem = CRM_Price_BAO_LineItem::getLineItems($participants['id'], 'participant');
// Participants is updated to 0 but line remains.
$this->assertEquals(0, $lineItem[1]['subTotal']);