Skip to content

feat: add buildCreateDocumentPayload + normalizeCreateDocumentResponse#13

Merged
BenKalsky merged 1 commit into
mainfrom
feat/create-document-payload
May 12, 2026
Merged

feat: add buildCreateDocumentPayload + normalizeCreateDocumentResponse#13
BenKalsky merged 1 commit into
mainfrom
feat/create-document-payload

Conversation

@BenKalsky
Copy link
Copy Markdown
Member

Summary

  • Adds buildCreateDocumentPayload + normalizeCreateDocumentResponse for POST /accounting/documents/create/, so consumers can issue SUMIT accounting documents (חשבון עסקה / Transaction Invoice, חשבונית מס, etc.) without going through a card charge.
  • Exports SUMIT_DOCUMENT_TYPE (currently TransactionInvoice = 1) and currencyToSumitString (the documents endpoint takes literal "ILS"/"USD"/"EUR" strings, unlike the charge endpoints' numeric codes).
  • Extends NormalizedSumitEvent with documentNumber and documentDownloadUrl, and adds "document.created" / "document.failed" to SumitNormalizedEventType.
  • Zero new runtime dependencies.

Why

This unlocks Quoty's "convert accepted proposal → חשבון עסקה in SUMIT" integration. Without a builder for /accounting/documents/create/, consumers had to fall back to hand-rolled payloads (with all the redaction/typing risks).

Test plan

  • pnpm test — 23 passing (9 new)
  • pnpm typecheck
  • pnpm build
  • Smoke test against SUMIT sandbox once the consumer is wired up

🤖 Generated with Claude Code

Adds support for POST /accounting/documents/create/ so consumers can
issue SUMIT accounting documents (חשבון עסקה / Transaction Invoice,
חשבונית מס, etc.) without going through a card charge. Useful for
proposal/quote → invoice flows where the document is generated up front
and payment is collected separately.

- buildCreateDocumentPayload(params): assembles the request body. Items
  default TotalPrice to UnitPrice * Quantity; Customer.SearchMode
  defaults to 0 (this endpoint differs from the charge endpoints where
  SearchMode=2 is the typical upsert).
- normalizeCreateDocumentResponse(response): surfaces success as
  eventType="document.created" with documentId, documentNumber, and
  documentDownloadUrl. Failures normalize to "document.failed" with
  redacted error messages.
- SUMIT_DOCUMENT_TYPE.TransactionInvoice = 1. Other SUMIT document type
  codes are accepted as plain numbers.
- currencyToSumitString helper — the documents endpoint takes literal
  "ILS"/"USD"/"EUR" strings, unlike the charge endpoints' numeric codes.
- NormalizedSumitEvent gains documentNumber and documentDownloadUrl.

Zero new runtime dependencies. 9 new tests; 23 total passing.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@BenKalsky BenKalsky merged commit 8f6c06e into main May 12, 2026
1 check passed
Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: af6456efa0

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/index.ts
Credentials: { CompanyID: params.companyId, APIKey: params.apiKey },
Details: details,
Items: items,
Payments: [] as never[],
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Allow payments for paid document types

When callers follow the new API docs and pass a receipt or tax-invoice-receipt documentType, this builder still always sends Payments: [] and the public params type has no way to provide payment rows. SUMIT paid-document types need populated payments to represent the collected amount, so those calls will either fail validation or create an unusable document despite the helper claiming arbitrary document type codes are supported.

Useful? React with 👍 / 👎.

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