Skip to content
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

Volume-based setPricingConfiguration parameter is counterintuitive #2623

Merged
merged 3 commits into from
Apr 1, 2015

Conversation

Goutte
Copy link
Contributor

@Goutte Goutte commented Mar 25, 2015

Look at https://github.com/Sylius/Sylius/blob/master/src/Sylius/Bundle/CoreBundle/Behat/CoreContext.php#L295

If the range is 30+ then the generated pricing configuration for setPricingConfiguration() is

array(
  'min' => null,
  'max' => 30,
  // ...
)

whereas it should be :

array(
  'min' => 30,
  'max' => null,
  // ...
)

What am I missing ?

@stloyd
Copy link
Contributor

stloyd commented Mar 25, 2015

Sounds like an issue. Can you submit PR fixing it? Thanks.

@Goutte
Copy link
Contributor Author

Goutte commented Mar 25, 2015

Yeah, will do. I'll add a new scenario to test for an order greater than 30, while I'm at it.

@Goutte
Copy link
Contributor Author

Goutte commented Mar 25, 2015

That was worth it ! The step definition was also buggy in other unexpected ways.

Consider the difference between (int) $data['price'] * 100 and (int) ($data['price'] * 100) when $data['price'] = '55.99'. The first one returns 5500, instead of 5599.

Also, 30+ range was not including the boundaries (here, 30), and other ranges did, so I fixed that as well.

I added some documentation as well in VolumeBasedCalculator.


The actual code silently ignores absurd ranges (with a null price or null min quantity). I left it as is, but it's worth considering throwing loudly when absurd ranges are met, don't you think ?

@pjedrzejewski
Copy link
Member

@Goutte I agree. Thank you very much for working on this! :)

PS. For some reason travis did not run, let's see on the next push.

…eceiving absurd configuration.

(untranslated exception text remains)
@Goutte
Copy link
Contributor Author

Goutte commented Mar 31, 2015

I added a new Exception, untranslated and very crude, and took the liberty of refactoring the ifs, and slightly make the calculator more tolerant of unset minima of ranges, by assuming it is 1, much like we assume that unset maxima are infinity.

Travis CI build is in progress as I write this.

Don't thank me, thank the spec suite making PRs a pleasure ! ;)

pjedrzejewski pushed a commit that referenced this pull request Apr 1, 2015
Volume-based setPricingConfiguration parameter is counterintuitive
@pjedrzejewski pjedrzejewski merged commit 4a8206c into Sylius:master Apr 1, 2015
@pjedrzejewski
Copy link
Member

Awesome, thank you Antoine! 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants