-
-
Notifications
You must be signed in to change notification settings - Fork 2.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Tax rates with dates #14338
Tax rates with dates #14338
Conversation
everwhatever
commented
Sep 21, 2022
•
edited
Loading
edited
Q | A |
---|---|
Branch? | 1.12 |
Bug fix? | no |
New feature? | yes |
BC breaks? | no |
Deprecations? | no |
Related tickets | jira |
License | MIT |
...res/taxation/applying_taxes/applying_correct_taxes_on_visitor_cart_for_specific_date.feature
Outdated
Show resolved
Hide resolved
src/Sylius/Bundle/CoreBundle/Migrations/Version20220912091947.php
Outdated
Show resolved
Hide resolved
src/Sylius/Component/Taxation/spec/Checker/TaxRateDateCheckerSpec.php
Outdated
Show resolved
Hide resolved
src/Sylius/Component/Taxation/spec/Checker/TaxRateDateCheckerSpec.php
Outdated
Show resolved
Hide resolved
src/Sylius/Component/Taxation/spec/Checker/TaxRateDateCheckerSpec.php
Outdated
Show resolved
Hide resolved
...res/taxation/applying_taxes/applying_correct_taxes_on_visitor_cart_for_specific_date.feature
Outdated
Show resolved
Hide resolved
src/Sylius/Bundle/CoreBundle/Migrations/Version20220912091947.php
Outdated
Show resolved
Hide resolved
Could you also remove |
Can this be reduced to a custom query? |
There isn't a custom repository for tax rates, so there won't be a BC break. class TaxRateRepository extends EntityRepository implements TaxRateRepositoryInterface
{
public function findOneByCategoryAndDate(TaxCategoryInterface $taxCategory, ?\DateTimeInterface $date = null): ?TaxRateInterface {
if (null === $date) {
$date = new \DateTime();
}
$expr = $this->_em->getExpressionBuilder();
return $this->createQueryBuilder('o')
->where(
$expr->andX(
$expr->eq('o.category', ':category'),
$expr->orX(
$expr->isNull('o.startDate'),
$expr->lte('o.startDate', ':date')
),
$expr->orX(
$expr->isNull('o.endDate'),
$expr->gte('o.endDate', ':date')
),
)
)
->setParameter('category', $taxCategory)
->setParameter('date', $date)
->getQuery()
->getOneOrNullResult();
}
} However, a way to add the zone in the core bundle is needed, which complicates things a bit. 🤔 If we keep the date filter logic in PHP, then I suggest transforming the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Missing behat tests for tax rate form validation
src/Sylius/Bundle/CoreBundle/Migrations/Version20220912091947.php
Outdated
Show resolved
Hide resolved
src/Sylius/Component/Taxation/Checker/TaxRateDateCheckerInterface.php
Outdated
Show resolved
Hide resolved
...res/taxation/applying_taxes/applying_correct_taxes_on_visitor_cart_for_specific_date.feature
Outdated
Show resolved
Hide resolved
...res/taxation/applying_taxes/applying_correct_taxes_on_visitor_cart_for_specific_date.feature
Outdated
Show resolved
Hide resolved
...res/taxation/applying_taxes/applying_correct_taxes_on_visitor_cart_for_specific_date.feature
Outdated
Show resolved
Hide resolved
src/Sylius/Component/Taxation/Checker/TaxRateDateEligibilityChecker.php
Outdated
Show resolved
Hide resolved
src/Sylius/Component/Taxation/spec/Checker/TaxRateDateEligibilityCheckerSpec.php
Outdated
Show resolved
Hide resolved
src/Sylius/Component/Taxation/spec/Resolver/TaxRateResolverSpec.php
Outdated
Show resolved
Hide resolved
src/Sylius/Component/Taxation/spec/Checker/TaxRateDateEligibilityCheckerSpec.php
Show resolved
Hide resolved
src/Sylius/Component/Taxation/Checker/TaxRateDateEligibilityChecker.php
Outdated
Show resolved
Hide resolved
🤔 maybe we can avoid the deprecation by decorating the original resolver instead of modifying it? WDYT? Edit:
|
I believe that the deprecation is not a bad option here - of course, it can cause discomfort for the service user, but on the other hand, we transparently inform about important changes in tax rates resolving logic 🚀 Moreover, as the interface allows to return only one tax rate, we could not use the result of the base resolver to filter the ineligible tax rates, as we need an array of them 🖖 |
@Zales0123 my idea was to completely ignore the output from the current resolver, as it remains only for compatibility for those using the service somehow else. Now that I said it out loud it doesn't sound that good anymore. |
849cc85
to
5e6c658
Compare
@@ -39,7 +39,13 @@ | |||
|
|||
<service id="sylius.tax_rate_resolver" class="Sylius\Component\Taxation\Resolver\TaxRateResolver"> | |||
<argument type="service" id="sylius.repository.tax_rate" /> | |||
<argument type="service" id="sylius.tax_rate_date_eligibility_checker" on-invalid="null" /> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
<argument type="service" id="sylius.tax_rate_date_eligibility_checker" on-invalid="null" /> | |
<argument type="service" id="sylius.tax_rate_date_eligibility_checker" /> |
I guess it's not needed.
5e6c658
to
e8dfffe
Compare
fbc52d0
to
7aca21d
Compare
Thanks, @everwhatever! 🎉 |