Skip to content

fix: make coupon consumption atomic during submit#207

Open
my-dev-jour wants to merge 1 commit intoBrainWise-DEV:developfrom
my-dev-jour:fix/198-atomic-coupon-consumption
Open

fix: make coupon consumption atomic during submit#207
my-dev-jour wants to merge 1 commit intoBrainWise-DEV:developfrom
my-dev-jour:fix/198-atomic-coupon-consumption

Conversation

@my-dev-jour
Copy link
Copy Markdown
Contributor

Summary

  • lock the coupon row and revalidate it before consuming usage during invoice submit
  • consume coupon usage inside the submit transaction instead of committing from a helper
  • add regression tests for one-use usage counting and atomic consume behavior

Testing

  • python3 -m py_compile pos_next/pos_next/doctype/pos_coupon/pos_coupon.py pos_next/api/invoices.py pos_next/pos_next/doctype/pos_coupon/test_pos_coupon.py
  • local verification was limited to py_compile in this workspace

Closes #198

@engahmed1190
Copy link
Copy Markdown
Contributor

Code review

No issues found. Checked for bugs and CLAUDE.md compliance.

🤖 Generated with Claude Code

@engahmed1190
Copy link
Copy Markdown
Contributor

Fix Conflicts

@my-dev-jour my-dev-jour force-pushed the fix/198-atomic-coupon-consumption branch from ddea594 to 64a9750 Compare March 28, 2026 12:54
@my-dev-jour
Copy link
Copy Markdown
Contributor Author

Conflicts resolved. I rebased the branch onto current develop, kept the already-merged one-use doctype logic from #205, and retained the atomic coupon-consumption changes plus regression coverage.

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.

[Bug]: Coupon validation and consumption are race-prone under concurrent checkout

2 participants