bug #13731 [Taxation] Add validation of negative tax rate (coldic3)

This PR was merged into the 1.10 branch.

Discussion
----------

| Q               | A
| --------------- | -----
| Branch?         | master <!-- see the comment below -->
| Bug fix?        | yes
| New feature?    | no
| BC breaks?      | no
| Deprecations?   | no
| Related tickets |
| License         | MIT

Commits
-------

f3c7821496 [Taxation][Behat][UI] Add negative tax rate scenario
f4e9a0b1b3 [Taxation] Add validation of negative tax rate
b754ada149 [Taxation] Change validation message
23ddba32b9 [Taxation] Remove redundant translation
43dc7631ac [Taxation] Fix translation keys order
d76ccba31e [Taxation] Fix Missing type hint and return type
523a4eaa9a [Taxation][Behat][UI] Fix typo
This commit is contained in:
Grzegorz Sadowski 2022-03-10 22:41:52 +01:00 committed by GitHub
commit 0ae681c968
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 23 additions and 1 deletions

View file

@ -81,3 +81,12 @@ Feature: Tax rate validation
When I remove its zone
And I try to save my changes
Then I should be notified that zone has to be selected
@ui
Scenario: Trying to add a new tax rate with negative amount
When I want to create a new tax rate
And I name it "Food and Beverage Tax Rates"
And I specify its amount as -20%
And I try to add it
Then I should be notified that amount is invalid
And tax rate with name "Food and Beverage Tax Rates" should not be added

View file

@ -61,7 +61,7 @@ final class ManagingTaxRateContext implements Context
}
/**
* @When I specify its amount as :amount%
* @When /^I specify its amount as ([^"]+)%$/
* @When I do not specify its amount
* @When I remove its amount
*/
@ -238,6 +238,14 @@ final class ManagingTaxRateContext implements Context
$this->assertFieldValidationMessage($element, sprintf('Please enter tax rate %s.', $element));
}
/**
* @Then I should be notified that :element is invalid
*/
public function iShouldBeNotifiedThatIsInvalid(string $element): void
{
$this->assertFieldValidationMessage($element, sprintf('The tax rate %s is invalid.', $element));
}
/**
* @Then tax rate with :element :name should not be added
*/

View file

@ -53,6 +53,10 @@
<option name="message">sylius.tax_rate.amount.not_blank</option>
<option name="groups">sylius</option>
</constraint>
<constraint name="Positive">
<option name="message">sylius.tax_rate.amount.invalid</option>
<option name="groups">sylius</option>
</constraint>
</property>
<property name="calculator">
<constraint name="NotBlank">

View file

@ -12,6 +12,7 @@ sylius:
name:
not_blank: Please enter tax rate name.
amount:
invalid: The tax rate amount is invalid.
not_blank: Please enter tax rate amount.
calculator:
not_blank: Please select tax calculator.