@12-apps/fiscal 1.2.0 → 1.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +17 -0
- package/dist/{chunk-N5DCKYFR.js → chunk-2ISYBTCE.js} +3 -3
- package/dist/{chunk-G3V7IYNF.js → chunk-EDEGIADD.js} +3 -3
- package/dist/{chunk-NVRYAAQ4.js → chunk-F2PGQVWL.js} +7 -6
- package/dist/chunk-F2PGQVWL.js.map +1 -0
- package/dist/{chunk-XQGW5HUG.js → chunk-GF3DXCD2.js} +1 -1
- package/dist/chunk-GF3DXCD2.js.map +1 -0
- package/dist/{chunk-2LBQRYPV.js → chunk-H33BK623.js} +1 -1
- package/dist/{chunk-2LBQRYPV.js.map → chunk-H33BK623.js.map} +1 -1
- package/dist/{chunk-WTGASIZE.js → chunk-MGTROA7K.js} +2 -2
- package/dist/{chunk-5S2PJHAE.js → chunk-OSYB7CVT.js} +2 -2
- package/dist/{context-ChnWR4Kb.d.ts → context-CLSMOSuf.d.ts} +1 -1
- package/dist/danfe/index.js +2 -2
- package/dist/documents/index.d.ts +12 -6
- package/dist/documents/index.js +118 -9
- package/dist/documents/index.js.map +1 -1
- package/dist/http.d.ts +4 -3
- package/dist/http.js +5 -5
- package/dist/issuer/index.d.ts +2 -2
- package/dist/jobs.d.ts +3 -3
- package/dist/jobs.js +4 -4
- package/dist/manifest/server.d.ts +3 -3
- package/dist/manifest/server.js +7 -7
- package/dist/notifications.d.ts +2 -2
- package/dist/notifications.js +3 -3
- package/dist/{service-KTjH7AxW.d.ts → service-hR3tgLpO.d.ts} +18 -3
- package/dist/{port-DpRFK56U.d.ts → types-BIJqm5GM.d.ts} +105 -85
- package/package.json +1 -1
- package/src/documents/errors.ts +7 -1
- package/src/documents/index.ts +2 -2
- package/src/documents/service.ts +88 -4
- package/src/documents/steps.ts +100 -4
- package/src/documents/types.ts +23 -0
- package/src/http.ts +1 -0
- package/dist/chunk-NVRYAAQ4.js.map +0 -1
- package/dist/chunk-XQGW5HUG.js.map +0 -1
- /package/dist/{chunk-N5DCKYFR.js.map → chunk-2ISYBTCE.js.map} +0 -0
- /package/dist/{chunk-G3V7IYNF.js.map → chunk-EDEGIADD.js.map} +0 -0
- /package/dist/{chunk-WTGASIZE.js.map → chunk-MGTROA7K.js.map} +0 -0
- /package/dist/{chunk-5S2PJHAE.js.map → chunk-OSYB7CVT.js.map} +0 -0
package/README.md
CHANGED
|
@@ -148,6 +148,9 @@ const documents = createFiscalDocuments({
|
|
|
148
148
|
newId: () => crypto.randomUUID(),
|
|
149
149
|
});
|
|
150
150
|
await documents.issue({ ownerId, subjectId, issuingPointId, model: "NFCE" });
|
|
151
|
+
// A counter whose paper cannot wait gives the send an online deadline: unanswered by then
|
|
152
|
+
// (or answered with no answer), the NFC-e goes offline on the point's contingency series.
|
|
153
|
+
await documents.issue({ ownerId, subjectId, issuingPointId, model: "NFCE", onlineDeadlineMs: 10_000 });
|
|
151
154
|
```
|
|
152
155
|
|
|
153
156
|
**One document is one number.** The state machine (`transition`) is pure:
|
|
@@ -210,6 +213,20 @@ nothing leaves `REJECTED`, `DENIED`, `REPLACED` or `CANCELLED` for `AUTHORIZED`
|
|
|
210
213
|
payment; the package checks neither. `isValidAccessKey` checks a typed key: 44
|
|
211
214
|
characters, the CNPJ inside it alphanumeric or not, the modulo-11 check
|
|
212
215
|
digit. A sale without the two fields is issued exactly as before.
|
|
216
|
+
- **Cancel, or the return when it is too late.** `cancelOrReturn({ ownerId,
|
|
217
|
+
documentId, reason, returnPointId })` cancels an authorised document; when
|
|
218
|
+
SEFAZ refuses the cancel as late (`LATE_CANCEL_CODES`, cStat 501) it issues
|
|
219
|
+
the buyer's return instead, an NF-e of entry on the NF-e point
|
|
220
|
+
`returnPointId`, from the sale the host's `SaleSource` answers for the
|
|
221
|
+
document's subject with `model: "NFE"` — which must quote the document's
|
|
222
|
+
key, or it is refused before a number is drawn. The document stays
|
|
223
|
+
AUTHORIZED beside its return. It answers `CANCELLED`, `RETURNED` (the
|
|
224
|
+
return may still be SUBMITTED; the sweep settles it like any document) or
|
|
225
|
+
`REFUSED` (the issuer refused the cancel for another reason; nothing
|
|
226
|
+
changed); a document that is not AUTHORIZED throws `TRANSITION_REFUSED`, and
|
|
227
|
+
a late NF-e (not an NFC-e) throws `RETURN_OF_NFCE_ONLY`. It is idempotent: a
|
|
228
|
+
document already cancelled, or already answered by a live return, is
|
|
229
|
+
answered with no call to the issuer.
|
|
213
230
|
- **An authorised document always has its XML.** A lookup that finds a
|
|
214
231
|
SUBMITTED document authorised joins the signed XML the service returned to
|
|
215
232
|
the lookup's `protNFe`; without both, the document stays SUBMITTED (its
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import {
|
|
2
2
|
OWED_VOIDS,
|
|
3
3
|
isLive
|
|
4
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-GF3DXCD2.js";
|
|
5
5
|
import {
|
|
6
6
|
FISCAL_ISSUE
|
|
7
7
|
} from "./chunk-3SDXLSG4.js";
|
|
8
8
|
import {
|
|
9
9
|
FiscalDocumentError
|
|
10
|
-
} from "./chunk-
|
|
10
|
+
} from "./chunk-H33BK623.js";
|
|
11
11
|
import {
|
|
12
12
|
__name
|
|
13
13
|
} from "./chunk-7QVYU63E.js";
|
|
@@ -607,4 +607,4 @@ export {
|
|
|
607
607
|
assertReason,
|
|
608
608
|
FiscalContext
|
|
609
609
|
};
|
|
610
|
-
//# sourceMappingURL=chunk-
|
|
610
|
+
//# sourceMappingURL=chunk-2ISYBTCE.js.map
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import {
|
|
2
2
|
FISCAL_DOCUMENT_MODELS
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-GF3DXCD2.js";
|
|
4
4
|
import {
|
|
5
5
|
FiscalDocumentError
|
|
6
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-H33BK623.js";
|
|
7
7
|
import {
|
|
8
8
|
__name
|
|
9
9
|
} from "./chunk-7QVYU63E.js";
|
|
@@ -189,4 +189,4 @@ export {
|
|
|
189
189
|
parseCertificateUpload,
|
|
190
190
|
parseIssuingPointInput
|
|
191
191
|
};
|
|
192
|
-
//# sourceMappingURL=chunk-
|
|
192
|
+
//# sourceMappingURL=chunk-EDEGIADD.js.map
|
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
import {
|
|
2
2
|
renderDanfeNfce
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-MGTROA7K.js";
|
|
4
4
|
import {
|
|
5
5
|
parseCertificateUpload,
|
|
6
6
|
parseIssuingPointInput,
|
|
7
7
|
parseProfileInput,
|
|
8
8
|
viewOf
|
|
9
|
-
} from "./chunk-
|
|
9
|
+
} from "./chunk-EDEGIADD.js";
|
|
10
10
|
import {
|
|
11
11
|
FISCAL_DOCUMENT_MODELS
|
|
12
|
-
} from "./chunk-
|
|
12
|
+
} from "./chunk-GF3DXCD2.js";
|
|
13
13
|
import {
|
|
14
14
|
FISCAL_CANCEL,
|
|
15
15
|
FISCAL_ISSUE,
|
|
@@ -18,7 +18,7 @@ import {
|
|
|
18
18
|
} from "./chunk-3SDXLSG4.js";
|
|
19
19
|
import {
|
|
20
20
|
FiscalDocumentError
|
|
21
|
-
} from "./chunk-
|
|
21
|
+
} from "./chunk-H33BK623.js";
|
|
22
22
|
import {
|
|
23
23
|
__name
|
|
24
24
|
} from "./chunk-7QVYU63E.js";
|
|
@@ -36,7 +36,8 @@ var FISCAL_ERROR_STATUS = {
|
|
|
36
36
|
NOT_PRINTABLE: 409,
|
|
37
37
|
RESEND_CHANGES_PRINTED_FIELDS: 422,
|
|
38
38
|
RETURN_NEEDS_REFERENCE: 422,
|
|
39
|
-
RETURN_ON_NFCE: 422
|
|
39
|
+
RETURN_ON_NFCE: 422,
|
|
40
|
+
RETURN_OF_NFCE_ONLY: 422
|
|
40
41
|
};
|
|
41
42
|
var PRINTABLE = /* @__PURE__ */ new Set(["AUTHORIZED", "CONTINGENCY"]);
|
|
42
43
|
var ok = /* @__PURE__ */ __name((data, status = 200) => ({ status, body: { data } }), "ok");
|
|
@@ -209,4 +210,4 @@ export {
|
|
|
209
210
|
FISCAL_ERROR_STATUS,
|
|
210
211
|
createApiFiscal
|
|
211
212
|
};
|
|
212
|
-
//# sourceMappingURL=chunk-
|
|
213
|
+
//# sourceMappingURL=chunk-F2PGQVWL.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/http.ts"],"sourcesContent":["/**\n * `createApiFiscal` — the fiscal HTTP surface as framework-neutral route\n * descriptors (the wiring contract's `http` capability, restated here\n * structurally: this package imports nothing from the contract at runtime,\n * and its manifest suite pins the twins).\n *\n * The package owns the paths, the bodies it reads (`./documents/profile-input`,\n * unknown keys refused), the `{ data }` envelope, the permission each route\n * needs and the status a refusal earns ({@link FISCAL_ERROR_STATUS}). The host\n * owns resolving WHO is calling into the opaque `ownerId` of its tenant, the\n * guards that check the declared permission, and every word a person reads:\n * an error answers a `code` for the host to word, never a sentence for a user.\n *\n * Nothing secret leaves: the profile answers `hasCertificate` / `hasCsc`, never\n * a ciphertext, and the certificate upload answers the profile view.\n */\n\nimport { type DanfeNfceLabels } from \"./danfe/labels\";\nimport { type PaperWidth, renderDanfeNfce } from \"./danfe/render\";\nimport { FiscalDocumentError, type FiscalDocumentErrorCode } from \"./documents/errors\";\nimport type { DocumentStorage } from \"./documents/ports\";\nimport { parseCertificateUpload, parseIssuingPointInput, parseProfileInput } from \"./documents/profile-input\";\nimport { viewOf } from \"./documents/profile\";\nimport type { FiscalDocuments } from \"./documents/service\";\nimport { FISCAL_DOCUMENT_MODELS, type FiscalDocumentModel } from \"./documents/types\";\nimport { FISCAL_CANCEL, FISCAL_ISSUE, FISCAL_MANAGE, FISCAL_READ } from \"./manifest/permissions\";\n\n/** The caller, as the host's adapter resolved it. */\nexport interface FiscalHttpActor {\n /** The emitter profile's owner: the host's tenant, mapped to an opaque id. */\n readonly ownerId: string;\n}\n\n/** Structural twin of the wiring contract's `WireRequest<FiscalHttpActor>`. */\nexport interface FiscalHttpRequest {\n actor: FiscalHttpActor;\n params: Record<string, string | undefined>;\n query: Record<string, string | undefined>;\n body?: unknown;\n}\n\n/** Structural twin of the wiring contract's `WireResponse`. */\nexport interface FiscalHttpResponse {\n status: number;\n body: unknown;\n}\n\n/** Structural twin of the wiring contract's `WireRoute<FiscalHttpActor>`. */\nexport interface FiscalRoute {\n method: \"GET\" | \"POST\" | \"PUT\";\n path: string;\n permission: string;\n handle(request: FiscalHttpRequest): Promise<FiscalHttpResponse>;\n}\n\nexport interface FiscalApiConfig {\n readonly documents: FiscalDocuments;\n /** Where the XMLs are, to render a DANFE from. */\n readonly storage: DocumentStorage;\n /** The DANFE's words: the host's, or `@12-apps/fiscal/danfe/pt-BR`. */\n readonly danfeLabels: DanfeNfceLabels;\n}\n\nexport const FISCAL_ERROR_STATUS = {\n INVALID_INPUT: 400,\n NOT_FOUND: 404,\n NOT_ISSUABLE: 409,\n NOT_SUPPORTED: 501,\n TRANSITION_REFUSED: 409,\n SERIES_EXHAUSTED: 409,\n CONFLICT: 409,\n SUBJECT_HAS_DOCUMENT: 409,\n NOT_PRINTABLE: 409,\n RESEND_CHANGES_PRINTED_FIELDS: 422,\n RETURN_NEEDS_REFERENCE: 422,\n RETURN_ON_NFCE: 422,\n RETURN_OF_NFCE_ONLY: 422,\n} as const satisfies Record<FiscalDocumentErrorCode, number>;\n\n/**\n * The states with paper: an authorised document, and one signed offline and\n * not yet transmitted (its DANFE is what the buyer takes). A denied,\n * cancelled, rejected or replaced document is not a valid DANFE.\n */\nconst PRINTABLE = new Set([\"AUTHORIZED\", \"CONTINGENCY\"]);\n\nconst ok = (data: unknown, status = 200): FiscalHttpResponse => ({ status, body: { data } });\n\nasync function answering(run: () => Promise<FiscalHttpResponse>): Promise<FiscalHttpResponse> {\n try {\n return await run();\n } catch (error) {\n if (error instanceof FiscalDocumentError) {\n return { status: FISCAL_ERROR_STATUS[error.code], body: { error: error.code, message: error.message } };\n }\n throw error;\n }\n}\n\nfunction record(body: unknown): Record<string, unknown> {\n if (body === null || typeof body !== \"object\" || Array.isArray(body)) {\n throw new FiscalDocumentError(\"INVALID_INPUT\", \"the body must be an object.\");\n }\n return body as Record<string, unknown>;\n}\n\nfunction stringField(body: Record<string, unknown>, key: string): string {\n const value = body[key];\n if (typeof value !== \"string\" || value === \"\") throw new FiscalDocumentError(\"INVALID_INPUT\", `${key} is required.`);\n return value;\n}\n\nfunction param(request: FiscalHttpRequest, key: string): string {\n const value = request.params[key];\n if (value === undefined || value === \"\") throw new FiscalDocumentError(\"INVALID_INPUT\", `${key} is required.`);\n return value;\n}\n\nconst ISSUE_KEYS = new Set([\"subjectId\", \"issuingPointId\", \"model\", \"offline\"]);\n\nfunction issueBody(body: unknown): { subjectId: string; issuingPointId: string; model: FiscalDocumentModel; offline: boolean } {\n const fields = record(body);\n const unknown = Object.keys(fields).filter((key) => !ISSUE_KEYS.has(key));\n if (unknown.length > 0) throw new FiscalDocumentError(\"INVALID_INPUT\", `unknown keys: ${unknown.join(\", \")}.`);\n const model = fields[\"model\"];\n if (!FISCAL_DOCUMENT_MODELS.includes(model as FiscalDocumentModel)) throw new FiscalDocumentError(\"INVALID_INPUT\", \"model must be NFE or NFCE.\");\n const offline = fields[\"offline\"] ?? false;\n if (typeof offline !== \"boolean\") throw new FiscalDocumentError(\"INVALID_INPUT\", \"offline must be a boolean.\");\n if (offline && model !== \"NFCE\") throw new FiscalDocumentError(\"INVALID_INPUT\", \"only an NFC-e is issued offline.\");\n return { subjectId: stringField(fields, \"subjectId\"), issuingPointId: stringField(fields, \"issuingPointId\"), model: model as FiscalDocumentModel, offline };\n}\n\nfunction profileRoutes({ documents }: FiscalApiConfig): FiscalRoute[] {\n return [\n {\n method: \"GET\",\n path: \"/fiscal/profile\",\n permission: FISCAL_READ,\n handle: ({ actor }) =>\n answering(async () => {\n const profile = await documents.getProfile(actor.ownerId);\n return ok(profile === null ? null : viewOf(profile));\n }),\n },\n {\n method: \"PUT\",\n path: \"/fiscal/profile\",\n permission: FISCAL_MANAGE,\n handle: ({ actor, body }) => answering(async () => ok(viewOf(await documents.saveProfile(actor.ownerId, parseProfileInput(body))))),\n },\n {\n method: \"PUT\",\n path: \"/fiscal/profile/certificate\",\n permission: FISCAL_MANAGE,\n handle: ({ actor, body }) =>\n answering(async () => ok(viewOf(await documents.uploadCertificate(actor.ownerId, parseCertificateUpload(body))))),\n },\n {\n method: \"GET\",\n path: \"/fiscal/issuing-points\",\n permission: FISCAL_READ,\n handle: ({ actor }) => answering(async () => ok(await documents.listIssuingPoints(actor.ownerId))),\n },\n {\n method: \"POST\",\n path: \"/fiscal/issuing-points\",\n permission: FISCAL_MANAGE,\n handle: ({ actor, body }) =>\n answering(async () => ok(await documents.createIssuingPoint(actor.ownerId, parseIssuingPointInput(body)), 201)),\n },\n ];\n}\n\n/** The DANFE of a printable document, as ESC/POS-ready lines. */\nfunction danfeRoute({ documents, storage, danfeLabels }: FiscalApiConfig): FiscalRoute {\n return {\n method: \"GET\",\n path: \"/fiscal/documents/:documentId/danfe\",\n permission: FISCAL_READ,\n handle: (request) =>\n answering(async () => {\n const paper = Number(request.query[\"paper\"] ?? \"80\");\n if (paper !== 58 && paper !== 80) throw new FiscalDocumentError(\"INVALID_INPUT\", \"paper must be 58 or 80.\");\n const document = await documents.getDocument(request.actor.ownerId, param(request, \"documentId\"));\n if (!PRINTABLE.has(document.status)) {\n throw new FiscalDocumentError(\"NOT_PRINTABLE\", `document ${document.id} is ${document.status}: only an AUTHORIZED or CONTINGENCY document prints.`);\n }\n const xml = document.model === \"NFCE\" && document.xmlKey !== null ? await storage.get(document.xmlKey) : null;\n if (xml === null) throw new FiscalDocumentError(\"NOT_FOUND\", `document ${document.id} has no NFC-e XML to print.`);\n return ok(renderDanfeNfce({ xml, paperWidth: paper as PaperWidth, labels: danfeLabels }));\n }),\n };\n}\n\nfunction documentRoutes(config: FiscalApiConfig): FiscalRoute[] {\n const { documents } = config;\n return [\n {\n method: \"POST\",\n path: \"/fiscal/documents\",\n permission: FISCAL_ISSUE,\n handle: ({ actor, body }) =>\n answering(async () => {\n const { offline, ...input } = issueBody(body);\n const document = offline\n ? await documents.issueOffline({ ownerId: actor.ownerId, subjectId: input.subjectId, issuingPointId: input.issuingPointId })\n : await documents.issue({ ownerId: actor.ownerId, ...input });\n return ok(document);\n }),\n },\n {\n method: \"GET\",\n path: \"/fiscal/documents/:documentId\",\n permission: FISCAL_READ,\n handle: (request) =>\n answering(async () => {\n const documentId = param(request, \"documentId\");\n const document = await documents.getDocument(request.actor.ownerId, documentId);\n return ok({ document, events: await documents.listEvents(request.actor.ownerId, documentId) });\n }),\n },\n {\n method: \"POST\",\n path: \"/fiscal/documents/:documentId/cancel\",\n permission: FISCAL_CANCEL,\n handle: (request) =>\n answering(async () => {\n const reason = stringField(record(request.body), \"reason\");\n const result = await documents.cancel({ ownerId: request.actor.ownerId, documentId: param(request, \"documentId\"), reason });\n return result.failure === null\n ? ok(result.document)\n : { status: 422, body: { error: \"ISSUER_FAILURE\", failure: result.failure, data: result.document } };\n }),\n },\n {\n method: \"POST\",\n path: \"/fiscal/documents/:documentId/resend\",\n permission: FISCAL_ISSUE,\n handle: (request) =>\n answering(async () =>\n ok(await documents.resendContingency({ ownerId: request.actor.ownerId, documentId: param(request, \"documentId\") })),\n ),\n },\n {\n method: \"POST\",\n path: \"/fiscal/documents/:documentId/release\",\n permission: FISCAL_ISSUE,\n handle: (request) =>\n answering(async () => ok(await documents.release({ ownerId: request.actor.ownerId, documentId: param(request, \"documentId\") }))),\n },\n {\n method: \"POST\",\n path: \"/fiscal/documents/:documentId/lookup\",\n permission: FISCAL_READ,\n handle: (request) =>\n answering(async () => ok(await documents.lookup({ ownerId: request.actor.ownerId, documentId: param(request, \"documentId\") }))),\n },\n danfeRoute(config),\n ];\n}\n\nexport function createApiFiscal(config: FiscalApiConfig): { routes: readonly FiscalRoute[] } {\n if (config?.documents === undefined) throw new TypeError(\"createApiFiscal needs documents.\");\n if (config.storage === undefined) throw new TypeError(\"createApiFiscal needs storage.\");\n if (config.danfeLabels === undefined) throw new TypeError(\"createApiFiscal needs danfeLabels.\");\n return { routes: [...profileRoutes(config), ...documentRoutes(config)] };\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AA+DO,IAAM,sBAAsB;AAAA,EACjC,eAAe;AAAA,EACf,WAAW;AAAA,EACX,cAAc;AAAA,EACd,eAAe;AAAA,EACf,oBAAoB;AAAA,EACpB,kBAAkB;AAAA,EAClB,UAAU;AAAA,EACV,sBAAsB;AAAA,EACtB,eAAe;AAAA,EACf,+BAA+B;AAAA,EAC/B,wBAAwB;AAAA,EACxB,gBAAgB;AAAA,EAChB,qBAAqB;AACvB;AAOA,IAAM,YAAY,oBAAI,IAAI,CAAC,cAAc,aAAa,CAAC;AAEvD,IAAM,KAAK,wBAAC,MAAe,SAAS,SAA6B,EAAE,QAAQ,MAAM,EAAE,KAAK,EAAE,IAA/E;AAEX,eAAe,UAAU,KAAqE;AAC5F,MAAI;AACF,WAAO,MAAM,IAAI;AAAA,EACnB,SAAS,OAAO;AACd,QAAI,iBAAiB,qBAAqB;AACxC,aAAO,EAAE,QAAQ,oBAAoB,MAAM,IAAI,GAAG,MAAM,EAAE,OAAO,MAAM,MAAM,SAAS,MAAM,QAAQ,EAAE;AAAA,IACxG;AACA,UAAM;AAAA,EACR;AACF;AATe;AAWf,SAAS,OAAO,MAAwC;AACtD,MAAI,SAAS,QAAQ,OAAO,SAAS,YAAY,MAAM,QAAQ,IAAI,GAAG;AACpE,UAAM,IAAI,oBAAoB,iBAAiB,6BAA6B;AAAA,EAC9E;AACA,SAAO;AACT;AALS;AAOT,SAAS,YAAY,MAA+B,KAAqB;AACvE,QAAM,QAAQ,KAAK,GAAG;AACtB,MAAI,OAAO,UAAU,YAAY,UAAU,GAAI,OAAM,IAAI,oBAAoB,iBAAiB,GAAG,GAAG,eAAe;AACnH,SAAO;AACT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SAAS,gBAAgB,QAA6D;AAC3F,MAAI,QAAQ,cAAc,OAAW,OAAM,IAAI,UAAU,kCAAkC;AAC3F,MAAI,OAAO,YAAY,OAAW,OAAM,IAAI,UAAU,gCAAgC;AACtF,MAAI,OAAO,gBAAgB,OAAW,OAAM,IAAI,UAAU,oCAAoC;AAC9F,SAAO,EAAE,QAAQ,CAAC,GAAG,cAAc,MAAM,GAAG,GAAG,eAAe,MAAM,CAAC,EAAE;AACzE;AALgB;","names":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/documents/types.ts"],"sourcesContent":["/**\n * The fiscal document record and its event log — the shape the package's\n * Prisma partial stores (`prisma/fiscal.prisma`, `FiscalDocument` and\n * `FiscalDocumentEvent`) and the state machine (`./machine`) transitions.\n *\n * A document is ONE number: one issuing point, one series, one `nNF`. A sale\n * that goes offline is a second document on the issuing point's contingency\n * series, and the first one is `REPLACED` (see `./machine`). The record is\n * keyed by an opaque `subjectId`: what the subject is (an order, a payment,\n * several orders) is the host's to know, never this package's.\n */\n\nimport type { IssuerFailure } from \"../issuer/port\";\nimport type { SaleForDocument } from \"../sale/types\";\nimport type { SefazEnvironment, SidecarErrorClass } from \"../sidecar/types\";\n\n/** The document model: NF-e (55) or NFC-e (65). NFS-e is not a model of this package yet (FUT-2242). */\nexport type FiscalDocumentModel = \"NFE\" | \"NFCE\";\n\nexport const FISCAL_DOCUMENT_MODELS: readonly FiscalDocumentModel[] = [\"NFE\", \"NFCE\"];\n\n/**\n * - `PENDING`: numbered and stored, not yet handed to the issuer.\n * - `SUBMITTED`: handed to the issuer; no final answer yet (a retry is owed).\n * - `AUTHORIZED`: SEFAZ authorised it. The only state a cancel leaves.\n * - `REJECTED`: refused (SEFAZ's `cStat`, or a request the service refuses as\n * malformed). Final; its number was not spent at SEFAZ and is inutilized.\n * - `DENIED`: a denial of use. Final; the number IS spent.\n * - `CONTINGENCY`: signed offline (`tpEmis = 9`), owed a transmission.\n * - `CANCELLED`: an authorised document cancelled at SEFAZ.\n * - `REPLACED`: its sale moved to another document (the contingency one);\n * its number is settled apart (`numberVoid`).\n */\nexport type FiscalDocumentStatus =\n | \"PENDING\"\n | \"SUBMITTED\"\n | \"AUTHORIZED\"\n | \"REJECTED\"\n | \"DENIED\"\n | \"CONTINGENCY\"\n | \"CANCELLED\"\n | \"REPLACED\";\n\nexport const FISCAL_DOCUMENT_STATUSES: readonly FiscalDocumentStatus[] = [\n \"PENDING\",\n \"SUBMITTED\",\n \"AUTHORIZED\",\n \"REJECTED\",\n \"DENIED\",\n \"CONTINGENCY\",\n \"CANCELLED\",\n \"REPLACED\",\n];\n\n/** Which of the issuing point's series the number came from. */\nexport type SeriesKind = \"ONLINE\" | \"CONTINGENCY\";\n\n/**\n * What is still owed on a number SEFAZ never used, so the sequence has no\n * unexplained gap:\n *\n * - `null`: nothing — the number is a document (authorised, denied, owed a\n * transmission) or still in flight.\n * - `LOOKUP_FIRST`: a request went out with no answer before the sale moved\n * to contingency; look the key up before deciding.\n * - `INUTILIZE`: never used at SEFAZ; inutilize it.\n * - `CANCEL`: the lookup found it authorised after all; cancel it.\n * - `INUTILIZED` / `CANCELLED`: settled.\n * - `DENIED`: settled — the lookup found the number denied, which spends it.\n */\nexport type NumberVoid = \"LOOKUP_FIRST\" | \"INUTILIZE\" | \"CANCEL\" | \"INUTILIZED\" | \"CANCELLED\" | \"DENIED\";\n\n/** The `numberVoid` values that still owe the sweep a call. */\nexport const OWED_VOIDS: readonly NumberVoid[] = [\"LOOKUP_FIRST\", \"INUTILIZE\", \"CANCEL\"];\n\n/** The order figures a document carries, in integer cents. */\nexport interface DocumentTotals {\n /** What the buyer pays: Σ line values − Σ discounts. */\n readonly totalCents: number;\n readonly discountCents: number;\n readonly cbsCents: number;\n readonly ibsUfCents: number;\n readonly ibsMunCents: number;\n}\n\n/**\n * Whether the document is the one its subject stands on. At most one live\n * document per (owner, subject, model): a REPLACED one is not, nor an online\n * one SEFAZ rejected (its number is voided and the sale is issued again) —\n * unless a lookup had found it authorised (its protocol is kept). A\n * REJECTED contingency NFC-e stays live: the buyer holds its DANFE, and the\n * store corrects and resends it under the same number.\n */\nexport function isLive(document: Pick<FiscalDocument, \"status\" | \"seriesKind\" | \"protocol\">): boolean {\n if (document.status === \"REPLACED\") return false;\n // An online rejection with a protocol known (a lookup found it SEFAZ's) is still the sale's.\n return !(document.status === \"REJECTED\" && document.seriesKind === \"ONLINE\" && document.protocol === null);\n}\n\n/** One fiscal document. */\nexport interface FiscalDocument {\n readonly id: string;\n /** The emitter profile's owner: an opaque id the host maps (a store, a company). */\n readonly ownerId: string;\n /** The issuer's CNPJ: SEFAZ numbers by CNPJ, model and series, so the counters do too. */\n readonly issuerCnpj: string;\n /** What the document is FOR, opaque: the host links it to its orders. */\n readonly subjectId: string;\n readonly issuingPointId: string;\n readonly model: FiscalDocumentModel;\n readonly environment: SefazEnvironment;\n readonly seriesKind: SeriesKind;\n readonly series: number;\n readonly number: number;\n /** `cNF`, drawn once: a retried call yields the same key. */\n readonly keyCode: string;\n readonly status: FiscalDocumentStatus;\n /** The sale as sent, issuer and number filled in. Never a secret. */\n readonly sale: SaleForDocument;\n readonly totals: DocumentTotals;\n /** The buyer's CPF/CNPJ at issue time, or `null`. */\n readonly buyerTaxId: string | null;\n readonly accessKey: string | null;\n /** The authorisation (or denial) protocol. */\n readonly protocol: string | null;\n /** The last SEFAZ `cStat`, or the service's named code. */\n readonly statusCode: string | null;\n readonly statusReason: string | null;\n /** The class of the last failed call, or `null`. */\n readonly lastErrorClass: SidecarErrorClass | null;\n /** A request went out and neither it nor its lookup was answered. */\n readonly outcomeUnknown: boolean;\n /** `dhEmi`. */\n readonly issuedAt: string;\n readonly authorizedAt: string | null;\n readonly contingency: { readonly since: string; readonly reason: string } | null;\n readonly cancelledAt: string | null;\n readonly cancelReason: string | null;\n readonly cancelProtocol: string | null;\n /** The document this one's sale moved to. */\n readonly replacedById: string | null;\n readonly numberVoid: NumberVoid | null;\n /** Storage keys: the signed or authorised XML, and the cancel or inutilization event's XML. */\n readonly xmlKey: string | null;\n readonly eventXmlKey: string | null;\n /** Calls made to the issuer for this document. */\n readonly attempts: number;\n /** Failed steps in a row (a retry, a deferred settlement); any progress resets it. */\n readonly failures: number;\n /** When the sweep (or the contingency transmission) may take it again; `null` when nothing is owed. */\n readonly nextAttemptAt: string | null;\n /**\n * A person must look: a settlement SEFAZ refused, or too many failures in a\n * row. The sweep leaves it alone until someone releases it.\n */\n readonly attention: boolean;\n /** When the 24-hour contingency deadline warning went out. */\n readonly deadlineWarnedAt: string | null;\n readonly createdAt: string;\n readonly updatedAt: string;\n}\n\n/** What the state machine was fed: the kind of the input that made the event. */\nexport type DocumentEventKind =\n | \"SUBMIT\"\n | \"AUTHORIZE\"\n | \"DENY\"\n | \"REJECT\"\n | \"RETRY\"\n | \"SIGN_OFFLINE\"\n | \"REPLACE\"\n | \"CANCEL\"\n | \"LOOKUP\"\n | \"INUTILIZE\"\n | \"DEFER\"\n | \"RESIGN\"\n | \"RELEASE\"\n | \"WARN\";\n\n/**\n * One transition, as stored. `answer` is what the fiscal service answered,\n * verbatim but for any secret-named key (`scrubSecrets`), so the record is the\n * evidence of what SEFAZ said, the `MarketplaceInboxEvent.payload` habit.\n */\nexport interface FiscalDocumentEvent {\n readonly documentId: string;\n readonly kind: DocumentEventKind;\n readonly fromStatus: FiscalDocumentStatus;\n readonly toStatus: FiscalDocumentStatus;\n readonly at: string;\n readonly errorClass: SidecarErrorClass | null;\n readonly code: string | null;\n readonly answer: unknown;\n}\n\nexport interface CancelOrReturnInput {\n readonly ownerId: string;\n readonly documentId: string;\n /** SEFAZ's 15–255 characters, sent with the cancel. */\n readonly reason: string;\n /** The NF-e (model 55) issuing point a return is numbered on. */\n readonly returnPointId: string;\n}\n\nexport interface CancelOrReturnResult {\n /**\n * `CANCELLED` inside the window; `RETURNED` past it (the return may itself\n * still be SUBMITTED: the sweep settles it like any document); `REFUSED`\n * when the issuer refused the cancel for any other reason (nothing changed).\n */\n readonly outcome: \"CANCELLED\" | \"RETURNED\" | \"REFUSED\";\n /** The document asked about, as it stands: CANCELLED, or still AUTHORIZED beside its return. */\n readonly document: FiscalDocument;\n readonly returnDocument: FiscalDocument | null;\n readonly failure: IssuerFailure | null;\n}\n"],"mappings":";;;;;AAmBO,IAAM,yBAAyD,CAAC,OAAO,MAAM;AAwB7E,IAAM,2BAA4D;AAAA,EACvE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF;AAqBO,IAAM,aAAoC,CAAC,gBAAgB,aAAa,QAAQ;AAoBhF,SAAS,OAAO,UAA+E;AACpG,MAAI,SAAS,WAAW,WAAY,QAAO;AAE3C,SAAO,EAAE,SAAS,WAAW,cAAc,SAAS,eAAe,YAAY,SAAS,aAAa;AACvG;AAJgB;","names":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/documents/errors.ts"],"sourcesContent":["/**\n * Every refusal the document module makes, as a typed error with a `code`.\n * A message never carries a certificate, a password or a CSC: the module\n * never holds one long enough to quote it.\n */\n\nexport type FiscalDocumentErrorCode =\n /** The state machine has no such transition from the document's state. */\n | \"TRANSITION_REFUSED\"\n /** An input is missing, malformed or out of range. */\n | \"INVALID_INPUT\"\n /** No emitter profile, issuing point or document under that id. */\n | \"NOT_FOUND\"\n /** The profile does not let the package issue (`documentPolicy`), or lacks what issuing needs. */\n | \"NOT_ISSUABLE\"\n /** The signing identity is declared but not built yet (`PLATFORM`). */\n | \"NOT_SUPPORTED\"\n /** A series' counter passed 999 999 999. */\n | \"SERIES_EXHAUSTED\"\n /** Another worker advanced the document first; re-read it. */\n | \"CONFLICT\"\n /** The subject already has a live document of that model (the per-subject guard). */\n | \"SUBJECT_HAS_DOCUMENT\"\n /** The document's state has no paper to print (only AUTHORIZED, or CONTINGENCY awaiting transmission). */\n | \"NOT_PRINTABLE\"\n /**\n * A resend of a rejected contingency NFC-e would change what the buyer's\n * DANFE prints and its QR encodes (the total, the buyer's document): such a\n * sale needs a new note, issued by a person.\n */\n | \"RESEND_CHANGES_PRINTED_FIELDS\"\n /** A `RETURN` quotes no document (`referencedDocuments` is absent or empty). */\n | \"RETURN_NEEDS_REFERENCE\"\n /**\n * A `RETURN` asked of an NFC-e. An NFC-e has no return purpose: the return is\n * an NF-e (model 55) of entry that references the NFC-e's key.\n */\n | \"RETURN_ON_NFCE\";\n\nexport class FiscalDocumentError extends Error {\n readonly code: FiscalDocumentErrorCode;\n\n constructor(code: FiscalDocumentErrorCode, message: string) {\n super(`[fiscal/documents] ${code}: ${message}`);\n this.name = \"FiscalDocumentError\";\n this.code = code;\n }\n}\n"],"mappings":";;;;;
|
|
1
|
+
{"version":3,"sources":["../src/documents/errors.ts"],"sourcesContent":["/**\n * Every refusal the document module makes, as a typed error with a `code`.\n * A message never carries a certificate, a password or a CSC: the module\n * never holds one long enough to quote it.\n */\n\nexport type FiscalDocumentErrorCode =\n /** The state machine has no such transition from the document's state. */\n | \"TRANSITION_REFUSED\"\n /** An input is missing, malformed or out of range. */\n | \"INVALID_INPUT\"\n /** No emitter profile, issuing point or document under that id. */\n | \"NOT_FOUND\"\n /** The profile does not let the package issue (`documentPolicy`), or lacks what issuing needs. */\n | \"NOT_ISSUABLE\"\n /** The signing identity is declared but not built yet (`PLATFORM`). */\n | \"NOT_SUPPORTED\"\n /** A series' counter passed 999 999 999. */\n | \"SERIES_EXHAUSTED\"\n /** Another worker advanced the document first; re-read it. */\n | \"CONFLICT\"\n /** The subject already has a live document of that model (the per-subject guard). */\n | \"SUBJECT_HAS_DOCUMENT\"\n /** The document's state has no paper to print (only AUTHORIZED, or CONTINGENCY awaiting transmission). */\n | \"NOT_PRINTABLE\"\n /**\n * A resend of a rejected contingency NFC-e would change what the buyer's\n * DANFE prints and its QR encodes (the total, the buyer's document): such a\n * sale needs a new note, issued by a person.\n */\n | \"RESEND_CHANGES_PRINTED_FIELDS\"\n /** A `RETURN` quotes no document (`referencedDocuments` is absent or empty). */\n | \"RETURN_NEEDS_REFERENCE\"\n /**\n * A `RETURN` asked of an NFC-e. An NFC-e has no return purpose: the return is\n * an NF-e (model 55) of entry that references the NFC-e's key.\n */\n | \"RETURN_ON_NFCE\"\n /**\n * `cancelOrReturn` past SEFAZ's window on a document that is not an NFC-e:\n * the buyer's return NF-e of entry answers a consumer's NFC-e only; an NF-e\n * past its window is the issuer's own correction, not this path's.\n */\n | \"RETURN_OF_NFCE_ONLY\";\n\nexport class FiscalDocumentError extends Error {\n readonly code: FiscalDocumentErrorCode;\n\n constructor(code: FiscalDocumentErrorCode, message: string) {\n super(`[fiscal/documents] ${code}: ${message}`);\n this.name = \"FiscalDocumentError\";\n this.code = code;\n }\n}\n"],"mappings":";;;;;AA6CO,IAAM,sBAAN,cAAkC,MAAM;AAAA,EA7C/C,OA6C+C;AAAA;AAAA;AAAA,EACpC;AAAA,EAET,YAAY,MAA+B,SAAiB;AAC1D,UAAM,sBAAsB,IAAI,KAAK,OAAO,EAAE;AAC9C,SAAK,OAAO;AACZ,SAAK,OAAO;AAAA,EACd;AACF;","names":[]}
|
|
@@ -6,7 +6,7 @@ import {
|
|
|
6
6
|
} from "./chunk-PNTKG3DZ.js";
|
|
7
7
|
import {
|
|
8
8
|
FiscalDocumentError
|
|
9
|
-
} from "./chunk-
|
|
9
|
+
} from "./chunk-H33BK623.js";
|
|
10
10
|
import {
|
|
11
11
|
__name
|
|
12
12
|
} from "./chunk-7QVYU63E.js";
|
|
@@ -244,4 +244,4 @@ export {
|
|
|
244
244
|
wrap,
|
|
245
245
|
renderDanfeNfce
|
|
246
246
|
};
|
|
247
|
-
//# sourceMappingURL=chunk-
|
|
247
|
+
//# sourceMappingURL=chunk-MGTROA7K.js.map
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
FISCAL_CERTIFICATE_EXPIRING
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-2ISYBTCE.js";
|
|
4
4
|
import {
|
|
5
5
|
FISCAL_MANAGE
|
|
6
6
|
} from "./chunk-3SDXLSG4.js";
|
|
@@ -82,4 +82,4 @@ export {
|
|
|
82
82
|
daysLeft,
|
|
83
83
|
FISCAL_JOBS
|
|
84
84
|
};
|
|
85
|
-
//# sourceMappingURL=chunk-
|
|
85
|
+
//# sourceMappingURL=chunk-OSYB7CVT.js.map
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { F as FiscalDocumentModel,
|
|
1
|
+
import { F as FiscalDocumentModel, n as DocumentTotals, D as DocumentEventKind, g as FiscalDocumentStatus, h as FiscalDocument, k as FiscalDocumentEvent, l as SeriesKind, f as SigningMaterial, I as Issuer } from './types-BIJqm5GM.js';
|
|
2
2
|
import { IssuerTaxRegime, Address, SaleForDocument } from './sale/index.js';
|
|
3
3
|
import { SefazEnvironment, IssuedDocument, SidecarErrorBody, ContingencySignedDocument, ContingencyEntry, CancelledDocument, LookedUpDocument, InutilizedRange } from './sidecar/index.js';
|
|
4
4
|
import { T as TaxRegime } from './types-B1b8LIWX.js';
|
package/dist/danfe/index.js
CHANGED
|
@@ -4,9 +4,9 @@ import {
|
|
|
4
4
|
money,
|
|
5
5
|
renderDanfeNfce,
|
|
6
6
|
wrap
|
|
7
|
-
} from "../chunk-
|
|
7
|
+
} from "../chunk-MGTROA7K.js";
|
|
8
8
|
import "../chunk-PNTKG3DZ.js";
|
|
9
|
-
import "../chunk-
|
|
9
|
+
import "../chunk-H33BK623.js";
|
|
10
10
|
import "../chunk-7QVYU63E.js";
|
|
11
11
|
export {
|
|
12
12
|
DANFE_COLUMNS,
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { F as FiscalDocumentModel,
|
|
2
|
-
export { D as DocumentEventKind,
|
|
3
|
-
import { h as SaleDraft, F as FiscalStore } from '../context-
|
|
4
|
-
export { C as Cipher, i as ContingencyBlockSource, j as DOCUMENT_POLICIES, k as DOCUMENT_TRANSITIONS, l as DocumentInput, f as DocumentPolicy, D as DocumentStorage, E as EmitterProfile, m as EmitterProfileView, n as FINAL_STATUSES, b as FISCAL_CERTIFICATE_EXPIRING, c as FISCAL_CONTINGENCY_DEADLINE, d as FISCAL_DOCUMENT_NEEDS_ATTENTION, e as FISCAL_DOCUMENT_REJECTED, g as FiscalDocumentsConfig, a as FiscalNotifyPort, o as FiscalReasons, I as IssuingPoint, M as MAX_FAILURES, N as NumberRequest, p as SIGNING_IDENTITY_KINDS, q as SaleSource, r as SigningIdentities, s as SigningIdentity, S as SigningIdentityKind, T as Transition, t as canTransition, u as createPlatformIdentity, v as createSigningIdentities, w as createStoreCertificateIdentity, x as scrubSecrets, y as transition, z as viewOf } from '../context-
|
|
5
|
-
export { C as CONTINGENCY_WARNING_AFTER_MS, a as CertificateFacts, b as CertificateUpload, E as EmitterProfileInput, F as FiscalDocuments, c as FiscalDocumentsServiceConfig, I as IssueInput, d as IssuingPointInput, S as SweepReport, e as createFiscalDocuments, p as parseCertificateUpload, f as parseIssuingPointInput, g as parseProfileInput } from '../service-
|
|
1
|
+
import { F as FiscalDocumentModel, l as SeriesKind, h as FiscalDocument, k as FiscalDocumentEvent } from '../types-BIJqm5GM.js';
|
|
2
|
+
export { i as CancelOrReturnInput, j as CancelOrReturnResult, D as DocumentEventKind, n as DocumentTotals, o as FISCAL_DOCUMENT_MODELS, p as FISCAL_DOCUMENT_STATUSES, g as FiscalDocumentStatus, N as NumberVoid, O as OWED_VOIDS, q as isLive } from '../types-BIJqm5GM.js';
|
|
3
|
+
import { h as SaleDraft, F as FiscalStore } from '../context-CLSMOSuf.js';
|
|
4
|
+
export { C as Cipher, i as ContingencyBlockSource, j as DOCUMENT_POLICIES, k as DOCUMENT_TRANSITIONS, l as DocumentInput, f as DocumentPolicy, D as DocumentStorage, E as EmitterProfile, m as EmitterProfileView, n as FINAL_STATUSES, b as FISCAL_CERTIFICATE_EXPIRING, c as FISCAL_CONTINGENCY_DEADLINE, d as FISCAL_DOCUMENT_NEEDS_ATTENTION, e as FISCAL_DOCUMENT_REJECTED, g as FiscalDocumentsConfig, a as FiscalNotifyPort, o as FiscalReasons, I as IssuingPoint, M as MAX_FAILURES, N as NumberRequest, p as SIGNING_IDENTITY_KINDS, q as SaleSource, r as SigningIdentities, s as SigningIdentity, S as SigningIdentityKind, T as Transition, t as canTransition, u as createPlatformIdentity, v as createSigningIdentities, w as createStoreCertificateIdentity, x as scrubSecrets, y as transition, z as viewOf } from '../context-CLSMOSuf.js';
|
|
5
|
+
export { C as CONTINGENCY_WARNING_AFTER_MS, a as CertificateFacts, b as CertificateUpload, E as EmitterProfileInput, F as FiscalDocuments, c as FiscalDocumentsServiceConfig, I as IssueInput, d as IssuingPointInput, L as LATE_CANCEL_CODES, S as SweepReport, e as createFiscalDocuments, p as parseCertificateUpload, f as parseIssuingPointInput, g as parseProfileInput } from '../service-hR3tgLpO.js';
|
|
6
6
|
import { a as TaxBreakdown } from '../types-B1b8LIWX.js';
|
|
7
7
|
import { SaleForDocument, SaleLine } from '../sale/index.js';
|
|
8
8
|
import '../sidecar/index.js';
|
|
@@ -43,7 +43,13 @@ type FiscalDocumentErrorCode =
|
|
|
43
43
|
* A `RETURN` asked of an NFC-e. An NFC-e has no return purpose: the return is
|
|
44
44
|
* an NF-e (model 55) of entry that references the NFC-e's key.
|
|
45
45
|
*/
|
|
46
|
-
| "RETURN_ON_NFCE"
|
|
46
|
+
| "RETURN_ON_NFCE"
|
|
47
|
+
/**
|
|
48
|
+
* `cancelOrReturn` past SEFAZ's window on a document that is not an NFC-e:
|
|
49
|
+
* the buyer's return NF-e of entry answers a consumer's NFC-e only; an NF-e
|
|
50
|
+
* past its window is the issuer's own correction, not this path's.
|
|
51
|
+
*/
|
|
52
|
+
| "RETURN_OF_NFCE_ONLY";
|
|
47
53
|
declare class FiscalDocumentError extends Error {
|
|
48
54
|
readonly code: FiscalDocumentErrorCode;
|
|
49
55
|
constructor(code: FiscalDocumentErrorCode, message: string);
|
package/dist/documents/index.js
CHANGED
|
@@ -5,7 +5,7 @@ import {
|
|
|
5
5
|
parseIssuingPointInput,
|
|
6
6
|
parseProfileInput,
|
|
7
7
|
viewOf
|
|
8
|
-
} from "../chunk-
|
|
8
|
+
} from "../chunk-EDEGIADD.js";
|
|
9
9
|
import {
|
|
10
10
|
element
|
|
11
11
|
} from "../chunk-PNTKG3DZ.js";
|
|
@@ -32,19 +32,19 @@ import {
|
|
|
32
32
|
totalsOf,
|
|
33
33
|
transition,
|
|
34
34
|
xmlKeys
|
|
35
|
-
} from "../chunk-
|
|
35
|
+
} from "../chunk-2ISYBTCE.js";
|
|
36
36
|
import {
|
|
37
37
|
FISCAL_DOCUMENT_MODELS,
|
|
38
38
|
FISCAL_DOCUMENT_STATUSES,
|
|
39
39
|
OWED_VOIDS,
|
|
40
40
|
isLive
|
|
41
|
-
} from "../chunk-
|
|
41
|
+
} from "../chunk-GF3DXCD2.js";
|
|
42
42
|
import {
|
|
43
43
|
FISCAL_ISSUE
|
|
44
44
|
} from "../chunk-3SDXLSG4.js";
|
|
45
45
|
import {
|
|
46
46
|
FiscalDocumentError
|
|
47
|
-
} from "../chunk-
|
|
47
|
+
} from "../chunk-H33BK623.js";
|
|
48
48
|
import {
|
|
49
49
|
__name
|
|
50
50
|
} from "../chunk-7QVYU63E.js";
|
|
@@ -341,16 +341,59 @@ function staleOnline(ctx, document, point) {
|
|
|
341
341
|
return !knownToSefaz && canGoOffline(document, point) && pastOnlineTolerance(ctx, document);
|
|
342
342
|
}
|
|
343
343
|
__name(staleOnline, "staleOnline");
|
|
344
|
-
|
|
344
|
+
function pastDeadline(document) {
|
|
345
|
+
return {
|
|
346
|
+
class: "CONTINGENCY",
|
|
347
|
+
code: null,
|
|
348
|
+
message: "SEFAZ did not answer before the online deadline.",
|
|
349
|
+
details: [],
|
|
350
|
+
accessKey: document.accessKey ?? computeAccessKey({ sale: document.sale, model: document.model, seriesKind: "ONLINE" }),
|
|
351
|
+
signedXml: null,
|
|
352
|
+
sefazReply: null,
|
|
353
|
+
outcomeUnknown: true
|
|
354
|
+
};
|
|
355
|
+
}
|
|
356
|
+
__name(pastDeadline, "pastDeadline");
|
|
357
|
+
async function sendBefore(send2, document, deadlineAt) {
|
|
358
|
+
send2.catch(() => void 0);
|
|
359
|
+
let timer;
|
|
360
|
+
const late = new Promise((resolve) => {
|
|
361
|
+
timer = setTimeout(() => resolve({ ok: false, error: pastDeadline(document) }), Math.max(0, deadlineAt - Date.now()));
|
|
362
|
+
});
|
|
363
|
+
try {
|
|
364
|
+
return await Promise.race([send2, late]);
|
|
365
|
+
} finally {
|
|
366
|
+
clearTimeout(timer);
|
|
367
|
+
}
|
|
368
|
+
}
|
|
369
|
+
__name(sendBefore, "sendBefore");
|
|
370
|
+
function send(ctx, document, signing, deadlineAt) {
|
|
371
|
+
const call = ctx.config.issuer.issue({ model: document.model, environment: document.environment, signing, document: document.sale });
|
|
372
|
+
return deadlineAt === null ? call : sendBefore(call, document, deadlineAt);
|
|
373
|
+
}
|
|
374
|
+
__name(send, "send");
|
|
375
|
+
function goesOffline(error, deadlineAt) {
|
|
376
|
+
return error.class === "CONTINGENCY" || deadlineAt !== null && error.class === "RETRYABLE";
|
|
377
|
+
}
|
|
378
|
+
__name(goesOffline, "goesOffline");
|
|
379
|
+
async function submit(ctx, document, profile, point, signing, deadlineAt = null) {
|
|
345
380
|
if (staleOnline(ctx, document, point)) return goOffline(ctx, document, profile, point, signing);
|
|
346
381
|
const sent = document.status === "PENDING" ? await ctx.advance(document, { kind: "SUBMIT" }) : document;
|
|
347
|
-
const
|
|
382
|
+
const bounded = deadlineAt !== null && canGoOffline(sent, point) ? deadlineAt : null;
|
|
383
|
+
const outcome = await send(ctx, sent, signing, bounded);
|
|
348
384
|
if (outcome.ok) return accept(ctx, sent, outcome.answer);
|
|
349
385
|
if (FINAL_FAILURES.has(outcome.error.class)) return reject(ctx, sent, outcome.error);
|
|
350
386
|
const retried = await ctx.advance(sent, { kind: "RETRY", error: outcome.error, ...await keepSigned(ctx, sent, outcome.error) });
|
|
351
|
-
return outcome.error
|
|
387
|
+
return goesOffline(outcome.error, bounded) && canGoOffline(retried, point) ? goOffline(ctx, retried, profile, point, signing) : retried;
|
|
352
388
|
}
|
|
353
389
|
__name(submit, "submit");
|
|
390
|
+
async function offlineIfOverdue(ctx, document, profile, point, signing, onlineDeadlineMs) {
|
|
391
|
+
const waiting = document.status === "PENDING" || document.status === "SUBMITTED";
|
|
392
|
+
const overdue = ctx.config.now().getTime() - Date.parse(document.createdAt) >= onlineDeadlineMs;
|
|
393
|
+
if (!waiting || !overdue || document.protocol !== null || !canGoOffline(document, point)) return document;
|
|
394
|
+
return goOffline(ctx, document, profile, point, signing);
|
|
395
|
+
}
|
|
396
|
+
__name(offlineIfOverdue, "offlineIfOverdue");
|
|
354
397
|
async function transmit(ctx, document, signing) {
|
|
355
398
|
const signedXml = document.xmlKey === null ? null : await ctx.config.storage.get(document.xmlKey);
|
|
356
399
|
if (signedXml === null) throw new FiscalDocumentError("NOT_FOUND", `document ${document.id} has no signed XML in storage.`);
|
|
@@ -360,6 +403,18 @@ async function transmit(ctx, document, signing) {
|
|
|
360
403
|
return ctx.advance(document, { kind: "RETRY", error: outcome.error });
|
|
361
404
|
}
|
|
362
405
|
__name(transmit, "transmit");
|
|
406
|
+
async function answerLive(ctx, existing, profile, onlineDeadlineMs) {
|
|
407
|
+
if (onlineDeadlineMs === void 0 || existing.model !== "NFCE" || existing.seriesKind !== "ONLINE") return existing;
|
|
408
|
+
const point = await ctx.requirePoint(existing.ownerId, existing.issuingPointId);
|
|
409
|
+
return offlineIfOverdue(ctx, existing, profile, point, await ctx.material(profile), onlineDeadlineMs);
|
|
410
|
+
}
|
|
411
|
+
__name(answerLive, "answerLive");
|
|
412
|
+
function assertOnlineDeadline(onlineDeadlineMs) {
|
|
413
|
+
if (onlineDeadlineMs !== void 0 && (!Number.isInteger(onlineDeadlineMs) || onlineDeadlineMs < 0)) {
|
|
414
|
+
throw new FiscalDocumentError("INVALID_INPUT", "onlineDeadlineMs must be a whole number of milliseconds, 0 or more.");
|
|
415
|
+
}
|
|
416
|
+
}
|
|
417
|
+
__name(assertOnlineDeadline, "assertOnlineDeadline");
|
|
363
418
|
|
|
364
419
|
// src/documents/service.ts
|
|
365
420
|
var CONTINGENCY_WARNING_AFTER_MS = 20 * 36e5;
|
|
@@ -397,9 +452,11 @@ async function numberOrExisting(deps, input, create) {
|
|
|
397
452
|
}
|
|
398
453
|
__name(numberOrExisting, "numberOrExisting");
|
|
399
454
|
async function issue(deps, input) {
|
|
455
|
+
assertOnlineDeadline(input.onlineDeadlineMs);
|
|
456
|
+
const deadlineAt = input.onlineDeadlineMs === void 0 ? null : Date.now() + input.onlineDeadlineMs;
|
|
400
457
|
const { profile, point } = await issuable(deps, input.ownerId, input.issuingPointId, input.model);
|
|
401
458
|
const existing = await liveDocument(deps, input);
|
|
402
|
-
if (existing !== null) return existing;
|
|
459
|
+
if (existing !== null) return answerLive(deps.ctx, existing, profile, input.onlineDeadlineMs);
|
|
403
460
|
const signing = await deps.ctx.material(profile);
|
|
404
461
|
const draft = await deps.config.sales.saleFor({ ownerId: input.ownerId, subjectId: input.subjectId, model: input.model });
|
|
405
462
|
assertDraftFits(draft, input.model);
|
|
@@ -408,7 +465,8 @@ async function issue(deps, input) {
|
|
|
408
465
|
input,
|
|
409
466
|
() => deps.ctx.createNumbered({ profile, point, subjectId: input.subjectId, model: input.model, seriesKind: "ONLINE", draft })
|
|
410
467
|
);
|
|
411
|
-
|
|
468
|
+
if (!numbered.created) return answerLive(deps.ctx, numbered.document, profile, input.onlineDeadlineMs);
|
|
469
|
+
return submit(deps.ctx, numbered.document, profile, point, signing, deadlineAt);
|
|
412
470
|
}
|
|
413
471
|
__name(issue, "issue");
|
|
414
472
|
async function issueOffline(deps, input) {
|
|
@@ -482,6 +540,51 @@ async function cancel(deps, input) {
|
|
|
482
540
|
return { document: cancelled, failure: null };
|
|
483
541
|
}
|
|
484
542
|
__name(cancel, "cancel");
|
|
543
|
+
var LATE_CANCEL_CODES = ["501"];
|
|
544
|
+
var isLateCancel = /* @__PURE__ */ __name((code) => code !== null && LATE_CANCEL_CODES.includes(code), "isLateCancel");
|
|
545
|
+
async function liveReturnOf(deps, document) {
|
|
546
|
+
const returns = (await deps.config.store.listBySubject(document.ownerId, document.subjectId, "NFE")).filter(isLive);
|
|
547
|
+
const quoting = returns.filter((candidate) => returnsDocument(candidate, document));
|
|
548
|
+
return quoting[quoting.length - 1] ?? null;
|
|
549
|
+
}
|
|
550
|
+
__name(liveReturnOf, "liveReturnOf");
|
|
551
|
+
async function cancelOrReturn(deps, input) {
|
|
552
|
+
assertReason(input.reason, "reason");
|
|
553
|
+
const document = await requireDocument(deps, input.ownerId, input.documentId);
|
|
554
|
+
if (document.status === "CANCELLED") return { outcome: "CANCELLED", document, returnDocument: null, failure: null };
|
|
555
|
+
const existing = document.accessKey === null ? null : await liveReturnOf(deps, document);
|
|
556
|
+
if (existing !== null) return { outcome: "RETURNED", document, returnDocument: existing, failure: null };
|
|
557
|
+
const cancelled = await cancel(deps, input);
|
|
558
|
+
if (cancelled.failure === null) return { outcome: "CANCELLED", document: cancelled.document, returnDocument: null, failure: null };
|
|
559
|
+
const late = cancelled.failure.class === "REJECTED" && isLateCancel(cancelled.failure.code);
|
|
560
|
+
if (!late) return { outcome: "REFUSED", document: cancelled.document, returnDocument: null, failure: cancelled.failure };
|
|
561
|
+
return { outcome: "RETURNED", document: cancelled.document, returnDocument: await issueReturn(deps, document, input.returnPointId), failure: cancelled.failure };
|
|
562
|
+
}
|
|
563
|
+
__name(cancelOrReturn, "cancelOrReturn");
|
|
564
|
+
function returnsDocument(candidate, document) {
|
|
565
|
+
const quotes = (candidate.sale.referencedDocuments ?? []).some((reference) => reference.accessKey === document.accessKey);
|
|
566
|
+
return candidate.model === "NFE" && candidate.sale.purpose === "RETURN" && quotes;
|
|
567
|
+
}
|
|
568
|
+
__name(returnsDocument, "returnsDocument");
|
|
569
|
+
async function issueReturn(deps, document, returnPointId) {
|
|
570
|
+
if (document.model !== "NFCE") {
|
|
571
|
+
throw new FiscalDocumentError("RETURN_OF_NFCE_ONLY", `document ${document.id} is an ${document.model}: only an NFC-e is answered with a buyer's return.`);
|
|
572
|
+
}
|
|
573
|
+
const live = (await deps.config.store.listBySubject(document.ownerId, document.subjectId, "NFE")).filter(isLive);
|
|
574
|
+
if (live.length > 0) {
|
|
575
|
+
throw new FiscalDocumentError("SUBJECT_HAS_DOCUMENT", `subject ${document.subjectId} already holds a live NF-e that is not document ${document.id}'s return.`);
|
|
576
|
+
}
|
|
577
|
+
const draft = await deps.config.sales.saleFor({ ownerId: document.ownerId, subjectId: document.subjectId, model: "NFE" });
|
|
578
|
+
if (!returnsDocument({ model: "NFE", sale: draft }, document)) {
|
|
579
|
+
throw new FiscalDocumentError("INVALID_INPUT", `the return the sale source answered for subject ${document.subjectId} does not quote document ${document.id}.`);
|
|
580
|
+
}
|
|
581
|
+
const returned = await issue(deps, { ownerId: document.ownerId, subjectId: document.subjectId, issuingPointId: returnPointId, model: "NFE" });
|
|
582
|
+
if (returned.id === document.id || !returnsDocument(returned, document)) {
|
|
583
|
+
throw new FiscalDocumentError("CONFLICT", `subject ${document.subjectId}'s live NF-e is not document ${document.id}'s return.`);
|
|
584
|
+
}
|
|
585
|
+
return returned;
|
|
586
|
+
}
|
|
587
|
+
__name(issueReturn, "issueReturn");
|
|
485
588
|
function lookupMoves(document) {
|
|
486
589
|
if (!canTransition(document.status, "LOOKUP")) return false;
|
|
487
590
|
if (document.status === "REPLACED" || document.status === "REJECTED") return document.numberVoid === "LOOKUP_FIRST";
|
|
@@ -570,6 +673,11 @@ function createFiscalDocuments(config) {
|
|
|
570
673
|
resendContingency: resendContingency.bind(null, deps),
|
|
571
674
|
/** Cancel an authorised document. A refusal (late, say) answers the issuer's failure and changes nothing. */
|
|
572
675
|
cancel: cancel.bind(null, deps),
|
|
676
|
+
/**
|
|
677
|
+
* Cancel an authorised document, or — when SEFAZ says the cancel is too late
|
|
678
|
+
* (501) — issue the buyer's return NF-e of entry quoting it. Idempotent.
|
|
679
|
+
*/
|
|
680
|
+
cancelOrReturn: cancelOrReturn.bind(null, deps),
|
|
573
681
|
/** Ask SEFAZ what it knows of the key; a state the answer moves is recorded. */
|
|
574
682
|
lookup: lookup.bind(null, deps),
|
|
575
683
|
/** A person takes a document back from `attention`; the sweep tries it again. */
|
|
@@ -1206,6 +1314,7 @@ export {
|
|
|
1206
1314
|
FISCAL_DOCUMENT_STATUSES,
|
|
1207
1315
|
FISCAL_NEXT_NUMBER_SQL,
|
|
1208
1316
|
FiscalDocumentError,
|
|
1317
|
+
LATE_CANCEL_CODES,
|
|
1209
1318
|
MAX_FAILURES,
|
|
1210
1319
|
OWED_VOIDS,
|
|
1211
1320
|
SIGNING_IDENTITY_KINDS,
|