Skip to content

fix: server-mode stock lifecycle - consolidated valid parts of Cursor… - #157

Merged
webiumsk merged 1 commit into
masterfrom
fix/server-stock-lifecycle
Jul 16, 2026
Merged

fix: server-mode stock lifecycle - consolidated valid parts of Cursor…#157
webiumsk merged 1 commit into
masterfrom
fix/server-stock-lifecycle

Conversation

@webiumsk

Copy link
Copy Markdown
Owner

… PRs #64/#65/#67

The June PRs predate the local-first merge; most of their content was re-implemented by the July review (webhook hardening, cancel reversal, idempotency guards). This consolidates what was still missing, all server-mode only (the Evolu client handles local-first stock itself):

Nine new feature tests; PHPStan baseline shrinks by two entries.

… PRs #64/#65/#67

The June PRs predate the local-first merge; most of their content was
re-implemented by the July review (webhook hardening, cancel reversal,
idempotency guards). This consolidates what was still missing, all
server-mode only (the Evolu client handles local-first stock itself):

- issue(): lockForUpdate + canIssue re-check inside the transaction -
  two concurrent issues could burn two numbers and deduct stock twice
  (#64). The caller's instance is refreshed to keep the mutation
  contract.
- cancel returns stock for Paid documents too, not only Issued (#67).
- destroy(): lock + canDelete re-check + stock reversal in one
  transaction - deleting an issued document left its stock deducted
  forever (#67). Movement FK is nullOnDelete, the audit trail stays.
- bulk cancel/delete reverse stock the same way (#67).
- editing an issued document rebuilds its movements (reversal recorded
  as the new document_adjustment source, stale issue rows dropped,
  fresh lines applied) (#65); the source value is also added to the
  Evolu schema union so server-to-local migration exports stay valid.
- stock transfers cannot overdraw the source warehouse (#65).
- warehouses with movement history cannot be deleted - deactivate
  instead (#65).

Nine new feature tests; PHPStan baseline shrinks by two entries.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@cursor

cursor Bot commented Jul 16, 2026

Copy link
Copy Markdown

Bugbot is not enabled for your account, so this pull request was not reviewed.

Enable Bugbot in the Cursor dashboard to get automatic reviews on future PRs.

@coderabbitai

coderabbitai Bot commented Jul 16, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Warning

Review limit reached

@webiumsk, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 45 minutes

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: 8b39c909-8e02-4491-a095-7dd70f2c7e90

📥 Commits

Reviewing files that changed from the base of the PR and between 8389852 and 2ceec53.

📒 Files selected for processing (12)
  • app/Enums/CompanyStockMovementSource.php
  • app/Http/Controllers/Invoicing/BusinessDocumentController.php
  • app/Services/Invoicing/BusinessDocumentBulkService.php
  • app/Services/Invoicing/BusinessDocumentIssueService.php
  • app/Services/Invoicing/CompanyStockBalanceService.php
  • app/Services/Invoicing/CompanyStockMovementService.php
  • app/Services/Invoicing/CompanyWarehouseService.php
  • phpstan-baseline.neon
  • resources/js/evolu/schema.ts
  • tests/Feature/CompanyStockDocumentMovementTest.php
  • tests/Feature/CompanyWarehouseTest.php
  • typecheck-baseline.json
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/server-stock-lifecycle

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@webiumsk

Copy link
Copy Markdown
Owner Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Jul 16, 2026

Copy link
Copy Markdown
Contributor
✅ Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@webiumsk
webiumsk merged commit ae7e19b into master Jul 16, 2026
4 checks passed
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.

1 participant