Skip to content

Add billing adjustments application - #44

Merged
mingzhulex merged 2 commits into
mainfrom
add-billing-adjustments-application
Aug 4, 2026
Merged

Add billing adjustments application#44
mingzhulex merged 2 commits into
mainfrom
add-billing-adjustments-application

Conversation

@mingzhulex

Copy link
Copy Markdown
Collaborator

Issue #, if available:

Description of changes:

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

Ming Zhu added 2 commits August 3, 2026 18:08
…guard, poll backoff, and input hardening

Ports the latest billing-adjustments engine work from the working repo:

engine:
- Pipeline processing by invoice_id: the same invoice is serialized (never two
  requests in flight at once) while different invoices run concurrently, replacing
  the global phase barrier.
- Pre-validate adjustmentAmount to at most 2 decimals at the universal submit gate.
- Poll interval now backs off (5s to 60s cap, resets on progress) instead of flat 60s.
- Recover an existing request on a reused client-token error instead of failing.
- Fail-closed duplicate pre-check: hold rows as NEED_REVIEW when listing cannot
  verify; never submit unverified.
- Reference columns optional (REFERENCE_COLUMNS); only agreement_id, invoice_id,
  and amount required.

webapp: bound the credential wait (default 30m) with a credentials_timeout state
and a heartbeat so a paused job cannot hang forever.

cli/docs: surface NEED_REVIEW and document the guards and column requirements.
… ERROR

When GetBillingAdjustmentRequest itself fails during polling (a transient network
blip, throttle, or 5xx), the request's real status is unknown. Previously
get_adjustment_status returned 'ERROR' for any exception, which the poller treated
as terminal, so a transient poll failure could mark an already-submitted refund as
failed even though it had actually completed server-side.

- get_adjustment_status now returns the sentinel 'POLL_ERROR' (status unknown) for
  call failures; a genuine service-returned 'ERROR' status stays terminal.
- The poll sweep treats 'POLL_ERROR' as retryable: keep the request in flight and
  retry on the next sweep, bounded by the existing per-request deadline.
- If the deadline is reached while status is still unconfirmed, TIMEOUT now says the
  status could not be confirmed and to re-run to reconcile (the pre-check will detect
  an existing refund and never duplicate).
@mingzhulex
mingzhulex merged commit 3af474b into main Aug 4, 2026
4 checks passed
@mingzhulex
mingzhulex deleted the add-billing-adjustments-application branch August 4, 2026 20:03
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