Skip to content

fix: validate dates and draft manual journals - #39

Draft
ryanduguid wants to merge 1 commit into
XeroAPI:mainfrom
ryanduguid:agent/date-journal-validation
Draft

fix: validate dates and draft manual journals#39
ryanduguid wants to merge 1 commit into
XeroAPI:mainfrom
ryanduguid:agent/date-journal-validation

Conversation

@ryanduguid

Copy link
Copy Markdown

Summary

  • validate YYYY-MM-DD values as real UTC calendar dates instead of accepting JavaScript rollover
  • parse complete Xero /Date(...)/ wrappers with signed milliseconds and optional signed display offsets, without applying the offset twice
  • require finite, exact-cent, zero-balanced manual journal lines and conservatively restrict create/update status to DRAFT
  • pass validated/defaulted file input to xero-node

Compatibility

This intentionally rejects malformed dates, sub-cent or imbalanced manual journals, and consequential create/update statuses that were previously accepted locally. Existing valid DRAFT journals remain supported. It is separate from the forthcoming mutation confirmation contract.

Validation

  • npx vitest run test/lib/validators.test.ts test/lib/formatters.test.ts (92 passed)
  • npm test (135 passed)
  • npm run build (passed)
  • git diff --check (passed)

All tests use local synthetic fixtures; no Xero API was called.

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