webform_civicrm icon indicating copy to clipboard operation
webform_civicrm copied to clipboard

use form's currency, not system default, for displaying line items/total

Open MegaphoneJon opened this issue 2 years ago • 9 comments

Overview

See https://www.drupal.org/project/webform_civicrm/issues/3340955.

Before

The line items and total on the payment page display in the system default currency.

After

The line items and total on the payment page display in the webform's currency.

Comments

The PHP fix is the primary fix. The JS fix works because the PHP fix is providing the correct format.

MegaphoneJon avatar Feb 10 '23 17:02 MegaphoneJon

@MegaphoneJon The test failure seems to be related. There seems to be js error when the default currency is selected on the Contribution tab.

image

The console error is probably due to the usage of uppercase FALSE in js. Should be fixed by replacing it to false.

jitendrapurohit avatar Feb 11 '23 07:02 jitendrapurohit

Hi @MegaphoneJon - that looks like a real failure:

5) Drupal\Tests\webform_civicrm\FunctionalJavascript\ContributionDummyTest::testAssignContributionSecondContactSelectByUserPaymentProcessor
Behat\Mink\Exception\ElementTextException: The text "10.00" was not found in the text of the element matching css "#wf-crm-billing-total".

KarinG avatar Feb 20 '23 20:02 KarinG

A question (unrelated to the currently failing test):

I've written a new JavaScript function that really needs unit testing with a large number of inputs. FunctionalJavascript seems way too heavy, since I want to do a pure unit test. Is there existing support for JS unit tests?

The values I want to test:

€275.00 EUR
$4,000.00 EUR
€275 EUR
$4,000.00
$4,000,000.00
$4 000 000.00
275€ EUR
275.00€ EUR
1'275.00€ EUR
$4_000_000.00
$1
$1.00
£9,500
$2.000,75

MegaphoneJon avatar Feb 27 '23 15:02 MegaphoneJon

Hi Jon -> if I understand your questions correctly -> yes we support non Functional JS tests ->

image

KarinG avatar Feb 28 '23 19:02 KarinG

test this please

MegaphoneJon avatar Jun 07 '23 21:06 MegaphoneJon

I’ll hit re-run tests

KarinG avatar Jun 07 '23 21:06 KarinG

I got stuck with the same issue/situation as @MegaphoneJon : I have a couple of available currencies but the payment screen shows the default site currency.

I can confirm that with this patch, my issue got resolved. @KarinG could we merge this one ?

Thanks for the work @MegaphoneJon !!

VangelisP avatar Jun 15 '24 06:06 VangelisP

It really needs to pass the existing battery of tests before we can merge this.

KarinG avatar Jun 15 '24 12:06 KarinG

Coming back to this PR as I've recently upgraded webform_civicrm to version 6.2.5. I have a different behaviour with 6.2.5 vs 6.2.4:

I believe this line should be taken out. It replaces the line item amount with the total amount

Before removing/commenting the pointed line:

image

After commenting it:

image

PS. Please ignore the total amount which is 26 in one screenshot and 21 in the other..

VangelisP avatar Jul 12 '24 15:07 VangelisP