Skip to content

Commit

Permalink
develop-6.0.1 (mollie#763)
Browse files Browse the repository at this point in the history
* develop-6.0.1

* leftover files
  • Loading branch information
mandan2 authored Jul 18, 2023
1 parent 730bae5 commit 74ee7c7
Show file tree
Hide file tree
Showing 111 changed files with 3,603 additions and 1,201 deletions.
14 changes: 12 additions & 2 deletions .github/workflows/E2E_On_PR.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: Cypress E2E Automation
on:
pull_request:
types: [opened, reopened]
branches: [master]
branches: '**'

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
Expand Down Expand Up @@ -59,7 +59,17 @@ jobs:
${{ matrix.make }}
- name: Running ${{ matrix.prestashop }} Cypress E2E tests
run: docker run -i -v $PWD:/e2e -w /e2e -e CYPRESS_baseUrl='${{ matrix.url }}' -e CYPRESS_MOLLIE_TEST_API_KEY=${{ secrets.MOLLIE_TEST_API_KEY }} -e CYPRESS_MOLLIE_TEST_PROFILE_ID=${{ secrets.MOLLIE_TEST_PROFILE_ID }} -e CYPRESS_TESTRAIL_RUN_ID=${{ matrix.TestRailID }} -e CYPRESS_TESTRAIL_DOMAIN=${{ secrets.TESTRAIL_DOMAIN }} -e CYPRESS_TESTRAIL_USERNAME=${{ secrets.TESTRAIL_USERNAME }} -e CYPRESS_TESTRAIL_PASSWORD='${{ secrets.TESTRAIL_PASSWORD }}' cypress/included:cypress-12.14.0-node-18.16.0-chrome-113.0.5672.92-1-ff-113.0-edge-113.0.1774.35-1 --spec "${{ matrix.test_spec }}" --browser chrome
run: |
export CYPRESS_baseUrl='${{ matrix.url }}'
export CYPRESS_MOLLIE_TEST_API_KEY=${{ secrets.MOLLIE_TEST_API_KEY }}
export CYPRESS_MOLLIE_TEST_PROFILE_ID=${{ secrets.MOLLIE_TEST_PROFILE_ID }}
export CYPRESS_TESTRAIL_RUN_ID=${{ matrix.TestRailID }}
export CYPRESS_TESTRAIL_DOMAIN='${{ secrets.TESTRAIL_DOMAIN }}'
export CYPRESS_TESTRAIL_USERNAME='${{ secrets.TESTRAIL_USERNAME }}'
export CYPRESS_TESTRAIL_PASSWORD='${{ secrets.TESTRAIL_PASSWORD }}'
npm install [email protected]
npm ci
npx cypress run --spec "${{ matrix.test_spec }}" --browser chrome
- name: Archive videos and screenshots
if: ${{ always() }}
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,11 @@ jobs:

- run: composer i

- name: Pull PrestaShop files (Tag 1.7.7.0)
- name: Pull PrestaShop files
run: docker run -tid --rm -v ps-volume:/var/www/html -v $PWD/:/var/www/html/modules/mollie --name temp-ps prestashop/prestashop:1.7.8.1-7.4-apache

- name: Run PHPunit
run: docker exec temp-ps php /var/www/html/modules/mollie/vendor/bin/phpunit -c /var/www/html/modules/mollie/tests/phpunit.xml -c /var/www/html/modules/mollie/tests/
run: docker exec temp-ps php /var/www/html/modules/mollie/vendor/bin/phpunit -c /var/www/html/modules/mollie/tests/phpunit.xml
# run: docker run --rm --volumes-from temp-ps --workdir=/var/www/html/modules/mollie php ./vendor/bin/phpunit -c ./tests/phpunit.xml -c tests/

phpstan:
Expand Down
5 changes: 5 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,11 @@ build-ps-8:
npm-package-install:
cd views/assets && npm i && npm run build

run-e2e-tests-locally:
npm install [email protected]
npm ci
npx cypress run

# checking the module upgrading - installs older module then installs from master branch
upgrading-module-test-1784:
git fetch
Expand Down
5 changes: 5 additions & 0 deletions changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@

# Changelog #

## Changes in release 6.0.1 ##
+ Fixed payment fee tax problems and improved fee set-up process.
+ Sync Mollie components and Single click flag to the environment selected.
+ Overall improvements and bug fixes.

## Changes in release 6.0.0 ##
+ Fixed order state duplication on install when single shop instance/ multishop instances were switched during module usage.
+ Upgraded sentry logger to support PHP 8.0 version.
Expand Down
81 changes: 81 additions & 0 deletions controllers/admin/AdminMollieAjaxController.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,14 @@
* @codingStandardsIgnoreStart
*/

use Mollie\Adapter\Context;
use Mollie\Builder\ApiTestFeedbackBuilder;
use Mollie\Config\Config;
use Mollie\Provider\CreditCardLogoProvider;
use Mollie\Provider\TaxCalculatorProvider;
use Mollie\Repository\PaymentMethodRepository;
use Mollie\Service\MolliePaymentMailService;
use Mollie\Utility\NumberUtility;
use Mollie\Utility\TimeUtility;

class AdminMollieAjaxController extends ModuleAdminController
Expand All @@ -41,6 +44,9 @@ public function postProcess()
case 'validateLogo':
$this->validateLogo();
break;
case 'updateFixedPaymentFeePrice':
$this->updateFixedPaymentFeePrice();
break;
default:
break;
}
Expand Down Expand Up @@ -147,4 +153,79 @@ private function validateLogo()

echo json_encode(['status' => $isUploaded, 'message' => $returnText]);
}

private function updateFixedPaymentFeePrice(): void
{
$paymentFeeTaxIncl = (float) Tools::getValue('paymentFeeTaxIncl');
$paymentFeeTaxExcl = (float) Tools::getValue('paymentFeeTaxExcl');

$taxRulesGroupId = (int) Tools::getValue('taxRulesGroupId');

if (empty($paymentFeeTaxIncl) && empty($paymentFeeTaxExcl)) {
$this->ajaxRender(
json_encode([
'error' => true,
'message' => $this->module->l('No fee was submitted.'),
])
);

return;
}

if ($paymentFeeTaxIncl < 0.00 || $paymentFeeTaxExcl < 0.00) {
$this->ajaxRender(
json_encode([
'error' => true,
'message' => $this->module->l('Invalid fee'),
])
);

return;
}

if ($taxRulesGroupId < 1) {
$this->ajaxRender(
json_encode([
'error' => true,
'message' => $this->module->l('Missing tax rules group ID'),
])
);

return;
}

/** @var TaxCalculatorProvider $taxCalculatorProvider */
$taxCalculatorProvider = $this->module->getService(TaxCalculatorProvider::class);

/** @var Context $context */
$context = $this->module->getService(Context::class);

$taxCalculator = $taxCalculatorProvider->getTaxCalculator(
$taxRulesGroupId,
$context->getCountryId(),
0 // NOTE: there is no default state for back office so setting no state
);

if ($paymentFeeTaxIncl === 0.00) {
$paymentFeeTaxIncl = $taxCalculator->addTaxes($paymentFeeTaxExcl);
}

if ($paymentFeeTaxExcl === 0.00) {
$paymentFeeTaxExcl = $taxCalculator->removeTaxes($paymentFeeTaxIncl);
}

$this->ajaxRender(
json_encode([
'error' => false,
'paymentFeeTaxIncl' => NumberUtility::toPrecision(
$paymentFeeTaxIncl,
NumberUtility::FLOAT_PRECISION
),
'paymentFeeTaxExcl' => NumberUtility::toPrecision(
$paymentFeeTaxExcl,
NumberUtility::FLOAT_PRECISION
),
])
);
}
}
Loading

0 comments on commit 74ee7c7

Please sign in to comment.