django-getpaid / django-plans

Django application for managing account plans and quotas
MIT License
509 stars 127 forks source link

Fix invoice duplicates #176

Closed PetrDlouhy closed 1 year ago

PetrDlouhy commented 1 year ago

When two concurrent requests calls order.complete_order() it can lead to creation of Invoice duplicate. This code tests that behavior and creates UniqueConstraint that will prevent the duplicate creation.

The current state of the PR has two problems:

codecov-commenter commented 1 year ago

Codecov Report

Merging #176 (dae5762) into master (4fd8c28) will increase coverage by 0.15%. The diff coverage is 100.00%.

@@            Coverage Diff             @@
##           master     #176      +/-   ##
==========================================
+ Coverage   85.99%   86.15%   +0.15%     
==========================================
  Files          50       63      +13     
  Lines        2242     2318      +76     
==========================================
+ Hits         1928     1997      +69     
- Misses        314      321       +7     
Impacted Files Coverage Δ
plans/base/models.py 94.99% <100.00%> (+0.01%) :arrow_up:
plans/plan_change.py 94.73% <100.00%> (ø)
plans/migrations/0011_auto_20220208_1344.py 100.00% <0.00%> (ø)
plans/migrations/0009_auto_20210303_1134.py 100.00% <0.00%> (ø)
plans/migrations/0005_recurring_payments.py 100.00% <0.00%> (ø)
plans/migrations/0003_make_plans_unique.py 58.82% <0.00%> (ø)
plans/tests/__init__.py 100.00% <0.00%> (ø)
...igrations/0008_recurringuserplan_token_verified.py 100.00% <0.00%> (ø)
plans/migrations/0001_initial.py 100.00% <0.00%> (ø)
plans/migrations/0006_auto_20200504_1541.py 100.00% <0.00%> (ø)
... and 5 more

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.