Romain Derie 7b99c0db92 [FIX] sale_coupon: generate only one coupon per program per SO
Before this commit:
Everytime the SO met a 'on_next_order' program requirements, a coupon would be
generated on that SO. Even if there was already a coupon for that program set to
'expired', for instance when the SO did not met the requirements anymore.

Now:
When the requirements are met, it checks that an `expired` coupon does not
already exist.
It it does, it will set that coupon back to `reserved` state.

Step to reproduce:
  - Create a program on `next_order` with requirements, eg $300 amount
  - Create a SO and add $300 worth of products
  - Update promotion, a coupon is created and set to `reserved`
  - Now update the SO to go below $300
  - Update promotion, the coupon is set to `expired` as it should
  - Update again the SO to meet the $300 requirements again
  - Update promotion, a new `reserved` coupon is generated instead of updating
    the state of the previous one from `expired` to `reserved`

Closes #3062
2018-11-15 15:56:19 +01:00
S
Description
No description provided
LGPL-3.0
3.4 GiB
Languages
Python 49.6%
JavaScript 47.8%
SCSS 2%
CSS 0.3%
HTML 0.2%