diff --git a/CRM/Contribute/Form/AdditionalPayment.php b/CRM/Contribute/Form/AdditionalPayment.php index c1b4feae3c90bd8cd283e4b0a6b7ccfcacb4e071..633434f744ef9620d4a6fcaae0b6ad695f0be6db 100644 --- a/CRM/Contribute/Form/AdditionalPayment.php +++ b/CRM/Contribute/Form/AdditionalPayment.php @@ -354,7 +354,7 @@ class CRM_Contribute_Form_AdditionalPayment extends CRM_Contribute_Form_Abstract if (!empty($submittedValues['is_email_receipt']) && $sendReceipt) { $statusMsg .= ' ' . ts('A receipt has been emailed to the contributor.'); } - if ($sendReceipt) { + if (isset($sendReceipt)) { $statusMsg .= ' ' . ts('Email has been sent successfully'); } CRM_Core_Session::setStatus($statusMsg, ts('Saved'), 'success'); diff --git a/templates/CRM/Contribute/Form/AdditionalPayment.tpl b/templates/CRM/Contribute/Form/AdditionalPayment.tpl index 39944841a2c4f9eecffb068e39034d9d5d1219d4..959a4fab312e44e60cb8d36a07403e6d87fed811 100644 --- a/templates/CRM/Contribute/Form/AdditionalPayment.tpl +++ b/templates/CRM/Contribute/Form/AdditionalPayment.tpl @@ -30,7 +30,7 @@ {if $paymentType eq 'refund'} <h3>{ts}New Event Refund{/ts}</h3> {else} -<h3>{if $component eq 'event'}{if $contributionMode}{ts}Credit Card Event Payment{/ts}{else}{ts}New Event Payement{/ts}{/if}{/if}</h3> +<h3>{if $component eq 'event'}{if $contributionMode}{ts}Credit Card Event Payment{/ts}{else}{ts}New Event Payment{/ts}{/if}{/if}</h3> {/if} <div class="crm-block crm-form-block crm-payment-form-block"> diff --git a/templates/CRM/Event/Form/Participant.tpl b/templates/CRM/Event/Form/Participant.tpl index 1167e24365da6e64d0c3a6d1b5b75ecc08dd488b..463c4bebe1356be4be1402de84b1fae151ace360 100644 --- a/templates/CRM/Event/Form/Participant.tpl +++ b/templates/CRM/Event/Form/Participant.tpl @@ -164,9 +164,6 @@ </script> {/literal} {/if} - {if $participantId} - {include file="CRM/Contribute/Page/PaymentInfo.tpl" show='event-payment'} - {/if} {include file="CRM/Event/Form/EventFees.tpl"} {elseif $cdType} {include file="CRM/Custom/Form/CustomData.tpl"} @@ -325,6 +322,9 @@ </div> </div> {if $action eq 1 or $action eq 2} + {if $participantId} + {include file="CRM/Contribute/Page/PaymentInfo.tpl" show='event-payment'} + {/if} {literal} <script type="text/javascript"> // event select diff --git a/tests/phpunit/WebTest/Event/AdditionalPaymentTest.php b/tests/phpunit/WebTest/Event/AdditionalPaymentTest.php index 85e5979622354d35e26d07e86bc91c335bd873a9..96eca22382e3937112d002deb364348b51cec26d 100644 --- a/tests/phpunit/WebTest/Event/AdditionalPaymentTest.php +++ b/tests/phpunit/WebTest/Event/AdditionalPaymentTest.php @@ -30,7 +30,7 @@ class WebTest_Event_AdditionalPaymentTest extends CiviSeleniumTestCase { parent::setUp(); } - // CRM-13964 + // CRM-13964 and CRM-13965 function testParticipantParitalPaymentInitiation() { // Log in using webtestLogin() method $this->webtestLogin(); @@ -120,14 +120,9 @@ class WebTest_Event_AdditionalPaymentTest extends CiviSeleniumTestCase { ) ); - // check the fee amount - $feeAmt = 800.00; - $this->assertElementContainsText("xpath=//td[@id='payment-info']/table[@id='info']/tbody/tr[2]/td", "$ {$feeAmt}", 'Missing text: appropriate fee amount'); - // check paid amount - $amtPaid = 400.00; - $this->assertElementContainsText("xpath=//td[@id='payment-info']/table[@id='info']/tbody/tr[2]/td[2]/a", "$ {$amtPaid}", 'Missing text: appropriate fee amount'); - - // check contribution record as well + // check the fee amount and contribution amount + $this->_checkPaymentInfoTable(800.00, 400.00); + $balance = 800.00 - 400.00; //click through to the contribution view screen $this->click("xpath=id('ParticipantView')/div[2]/table[@class='selector']/tbody/tr[1]/td[8]/span/a[text()='View']"); $this->waitForElementPresent('_qf_ContributionView_cancel-bottom'); @@ -142,5 +137,84 @@ class WebTest_Event_AdditionalPaymentTest extends CiviSeleniumTestCase { 'Check Number' => '1044', ) ); + + $this->click('_qf_ContributionView_cancel-top'); + $this->waitForElementPresent("xpath=id('ParticipantView')/div[2]/table[@class='selector']/tbody/tr[1]/td[8]/span/a[text()='View']"); + // make additional payment + // 1 - check for links presence on participant view and edit page + $this->assertElementPresent("xpath=id('Search')/table[@class='selector']/tbody/tr[1]/td[8]/span[2]/ul/li[2]/a[text()='Record Payment']"); + $this->click("xpath=id('Search')/table[@class='selector']/tbody/tr[1]/td[8]/span/a[text()='View']"); + $this->waitForElementPresent("xpath=id('ParticipantView')"); + $this->assertElementPresent("xpath=id('ParticipantView')//td[@id='payment-info']/a/span[contains(text(), 'Record Payment')]"); + + $this->click("xpath=id('ParticipantView')//div[@class='action-link']/div/a/span[contains(text(), 'Edit')]"); + $this->waitForElementPresent("xpath=id('Participant')"); + $this->assertElementPresent("xpath=id('Participant')//td[@id='payment-info']/a/span[contains(text(), 'Record Payment')]"); + $location = $this->getAttribute("xpath=id('Participant')//td[@id='payment-info']/a/span[contains(text(), 'Record Payment')]/../@href"); + + $this->open($location); + $this->waitForElementPresent("xpath=id('AdditionalPayment')"); + $this->assertElementContainsText("xpath=id('AdditionalPayment')/h3", 'New Event Payment'); + + // input data + $this->select('financial_type_id', 'label=Donation'); + // verify balance + $text = $this->getText("xpath=id('AdditionalPayment')/div[2]/table/tbody/tr[4]/td[2]"); + $this->assertTrue((bool)preg_match("/{$balance}/", $text)); + + // check form rule error + $errorBalance = $balance + 1; + $this->type('total_amount', $errorBalance); + $this->select('payment_instrument_id', 'label=Cash'); + $this->click('_qf_AdditionalPayment_upload-bottom'); + $this->waitForText("xpath=//span[@id='totalAmount']/span", 'Payment amount cannot be greater than owed amount'); + $this->type('total_amount', $balance); + $this->click('_qf_AdditionalPayment_upload-bottom'); + $this->waitForText('crm-notification-container', 'The payment record has been processed.'); + + $this->waitForElementPresent("xpath=id('Search')/table[@class='selector']/tbody/tr[1]/td[8]/span/a[text()='View']"); + $this->click("xpath=id('Search')/table[@class='selector']/tbody/tr[1]/td[8]/span/a[text()='View']"); + $this->waitForElementPresent("_qf_ParticipantView_cancel-top"); + + $this->webtestVerifyTabularData( + array( + 'Event' => 'Rain-forest Cup Youth Soccer Tournament', + 'Participant Role' => 'Attendee', + 'Status' => 'Registered', + 'Event Source' => 'Event Partially Paid Webtest', + ) + ); + // check the fee amount and contribution amount + $this->_checkPaymentInfoTable(800.00, 800.00); + + // check for not apprence of record payment button + $this->assertFalse($this->isElementPresent("xpath=id('ParticipantView')//td[@id='payment-info']/a/span[contains(text(), 'Record Payment')]")); + + $this->click("xpath=id('ParticipantView')/div[2]/table[@class='selector']/tbody/tr[1]/td[8]/span/a[text()='View']"); + $this->waitForElementPresent('_qf_ContributionView_cancel-bottom'); + + $this->webtestVerifyTabularData( + array( + 'From' => $displayName, + 'Financial Type' => 'Event Fee', + 'Total Amount' => '$ 800.00', + 'Contribution Status' => 'Completed', + 'Paid By' => 'Check', + 'Check Number' => '1044', + ) + ); + $this->click('_qf_ContributionView_cancel-bottom'); + + // view transaction popup info check + $this->waitForElementPresent("xpath=//td[@id='payment-info']/table[@id='info']/tbody/tr[2]/td[2]/a"); + $this->click("xpath=//td[@id='payment-info']/table[@id='info']/tbody/tr[2]/td[2]/a"); + $this->waitForElementPresent("xpath=//table[@id='info']/tbody/tr/th[contains(text(), 'Amount')]/../../tr[2]/td[contains(text(), '$ 400.00')]/../../tr[3]/td[contains(text(), '$ 400.00')]"); + $this->waitForElementPresent("xpath=//table[@id='info']/tbody/tr/th[3][contains(text(), 'Paid By')]/../../tr[2]/td[3][contains(text(), 'Check')]/../../tr[3]/td[3][contains(text(), 'Cash')]"); + $this->waitForElementPresent("xpath=//table[@id='info']/tbody/tr/th[6][contains(text(), 'Status')]/../../tr[2]/td[6][contains(text(), 'Completed')]/../../tr[3]/td[6][contains(text(), 'Completed')]"); + } + + function _checkPaymentInfoTable($feeAmt, $amtPaid) { + $this->assertElementContainsText("xpath=//td[@id='payment-info']/table[@id='info']/tbody/tr[2]/td", "$ {$feeAmt}", 'Missing text: appropriate fee amount'); + $this->assertElementContainsText("xpath=//td[@id='payment-info']/table[@id='info']/tbody/tr[2]/td[2]/a", "$ {$amtPaid}", 'Missing text: appropriate fee amount'); } } \ No newline at end of file