@12-apps/fiscal 1.0.0 → 1.2.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 +164 -7
- package/dist/chunk-2LBQRYPV.js +21 -0
- package/dist/chunk-2LBQRYPV.js.map +1 -0
- package/dist/chunk-3SDXLSG4.js +24 -0
- package/dist/chunk-3SDXLSG4.js.map +1 -0
- package/dist/chunk-5S2PJHAE.js +85 -0
- package/dist/chunk-5S2PJHAE.js.map +1 -0
- package/dist/chunk-G3V7IYNF.js +192 -0
- package/dist/chunk-G3V7IYNF.js.map +1 -0
- package/dist/chunk-JVQKJNOC.js +14 -0
- package/dist/chunk-JVQKJNOC.js.map +1 -0
- package/dist/chunk-N5DCKYFR.js +610 -0
- package/dist/chunk-N5DCKYFR.js.map +1 -0
- package/dist/chunk-NVRYAAQ4.js +212 -0
- package/dist/chunk-NVRYAAQ4.js.map +1 -0
- package/dist/chunk-PNTKG3DZ.js +47 -0
- package/dist/chunk-PNTKG3DZ.js.map +1 -0
- package/dist/chunk-WTGASIZE.js +247 -0
- package/dist/chunk-WTGASIZE.js.map +1 -0
- package/dist/chunk-XQGW5HUG.js +30 -0
- package/dist/chunk-XQGW5HUG.js.map +1 -0
- package/dist/context-ChnWR4Kb.d.ts +455 -0
- package/dist/danfe/en-US.d.ts +12 -0
- package/dist/danfe/en-US.js +51 -0
- package/dist/danfe/en-US.js.map +1 -0
- package/dist/danfe/index.d.ts +50 -0
- package/dist/danfe/index.js +18 -0
- package/dist/danfe/index.js.map +1 -0
- package/dist/danfe/pt-BR.d.ts +11 -0
- package/dist/danfe/pt-BR.js +51 -0
- package/dist/danfe/pt-BR.js.map +1 -0
- package/dist/documents/index.d.ts +181 -0
- package/dist/documents/index.js +1234 -0
- package/dist/documents/index.js.map +1 -0
- package/dist/engine/index.d.ts +3 -246
- package/dist/http.d.ts +75 -0
- package/dist/http.js +16 -0
- package/dist/http.js.map +1 -0
- package/dist/issuer/index.d.ts +43 -0
- package/dist/issuer/index.js +131 -0
- package/dist/issuer/index.js.map +1 -0
- package/dist/jobs.d.ts +74 -0
- package/dist/jobs.js +22 -0
- package/dist/jobs.js.map +1 -0
- package/dist/labels-BNvflT0h.d.ts +44 -0
- package/dist/manifest/index.d.ts +30 -16
- package/dist/manifest/index.js +11 -17
- package/dist/manifest/index.js.map +1 -1
- package/dist/manifest/server.d.ts +57 -0
- package/dist/manifest/server.js +25 -0
- package/dist/manifest/server.js.map +1 -0
- package/dist/notifications.d.ts +93 -0
- package/dist/notifications.js +41 -0
- package/dist/notifications.js.map +1 -0
- package/dist/port-DpRFK56U.d.ts +238 -0
- package/dist/sale/index.d.ts +269 -0
- package/dist/sale/index.js +1 -0
- package/dist/sale/index.js.map +1 -0
- package/dist/service-KTjH7AxW.d.ts +139 -0
- package/dist/sidecar/index.d.ts +218 -0
- package/dist/sidecar/index.js +8 -0
- package/dist/sidecar/index.js.map +1 -0
- package/dist/types-B1b8LIWX.d.ts +247 -0
- package/package.json +63 -5
- package/prisma/fiscal.prisma +158 -0
- package/prisma/migrations/20261113220000_fiscal_documents/migration.sql +201 -0
- package/sidecar/.dockerignore +5 -0
- package/sidecar/Dockerfile +68 -0
- package/sidecar/README.md +162 -0
- package/sidecar/composer.json +30 -0
- package/sidecar/composer.lock +2224 -0
- package/sidecar/docker/apache.conf +14 -0
- package/sidecar/docker/icp-brasil.pem +8031 -0
- package/sidecar/docker/mpm.conf +17 -0
- package/sidecar/docker/openssl.cnf +16 -0
- package/sidecar/docker/php.ini +19 -0
- package/sidecar/public/index.php +15 -0
- package/sidecar/schema/sale-for-document.schema.json +422 -0
- package/sidecar/src/ErrorClass.php +31 -0
- package/sidecar/src/Http/Request.php +48 -0
- package/sidecar/src/Http/Response.php +32 -0
- package/sidecar/src/Http/Router.php +59 -0
- package/sidecar/src/Kernel.php +99 -0
- package/sidecar/src/Module.php +31 -0
- package/sidecar/src/Nfe/Classifier.php +89 -0
- package/sidecar/src/Nfe/Credentials.php +52 -0
- package/sidecar/src/Nfe/DocumentMapper.php +428 -0
- package/sidecar/src/Nfe/DocumentSchema.php +39 -0
- package/sidecar/src/Nfe/Input.php +125 -0
- package/sidecar/src/Nfe/Model.php +17 -0
- package/sidecar/src/Nfe/NfeModule.php +62 -0
- package/sidecar/src/Nfe/NfeService.php +504 -0
- package/sidecar/src/Nfe/Sefaz.php +49 -0
- package/sidecar/src/Nfe/SefazReply.php +81 -0
- package/sidecar/src/Nfe/Transport/CurlTransport.php +198 -0
- package/sidecar/src/Nfe/Transport/SoapAdapter.php +57 -0
- package/sidecar/src/Nfe/Transport/Transport.php +20 -0
- package/sidecar/src/Nfe/Transport/TransportFailure.php +42 -0
- package/sidecar/src/RequestLog.php +54 -0
- package/sidecar/src/ServiceError.php +69 -0
- package/src/danfe/en-US.ts +53 -0
- package/src/danfe/index.ts +11 -0
- package/src/danfe/labels.ts +49 -0
- package/src/danfe/pt-BR.ts +52 -0
- package/src/danfe/render.ts +265 -0
- package/src/danfe/xml.ts +45 -0
- package/src/documents/context.ts +260 -0
- package/src/documents/errors.ts +48 -0
- package/src/documents/helpers.ts +177 -0
- package/src/documents/index.ts +40 -0
- package/src/documents/lines.ts +63 -0
- package/src/documents/machine-steps.ts +260 -0
- package/src/documents/machine.ts +128 -0
- package/src/documents/memory.ts +138 -0
- package/src/documents/nfe-proc.ts +51 -0
- package/src/documents/ports.ts +130 -0
- package/src/documents/profile-input.ts +168 -0
- package/src/documents/profile.ts +98 -0
- package/src/documents/service-profile.ts +104 -0
- package/src/documents/service.ts +299 -0
- package/src/documents/settle.ts +121 -0
- package/src/documents/signing.ts +61 -0
- package/src/documents/sql-rows.ts +180 -0
- package/src/documents/sql-store.ts +242 -0
- package/src/documents/sql.ts +18 -0
- package/src/documents/steps.ts +173 -0
- package/src/documents/tests/integration/pglite.ts +73 -0
- package/src/documents/types.ts +193 -0
- package/src/http.ts +266 -0
- package/src/issuer/index.ts +9 -0
- package/src/issuer/port.ts +109 -0
- package/src/issuer/sidecar.ts +171 -0
- package/src/jobs.ts +115 -0
- package/src/manifest/index.ts +25 -16
- package/src/manifest/server.ts +20 -0
- package/src/notifications.ts +120 -0
- package/src/sale/index.ts +8 -0
- package/src/sale/types.ts +318 -0
- package/src/sidecar/index.ts +9 -0
- package/src/sidecar/types.ts +245 -0
|
@@ -0,0 +1,455 @@
|
|
|
1
|
+
import { F as FiscalDocumentModel, k as DocumentTotals, D as DocumentEventKind, g as FiscalDocumentStatus, h as FiscalDocument, i as FiscalDocumentEvent, j as SeriesKind, f as SigningMaterial, I as Issuer } from './port-DpRFK56U.js';
|
|
2
|
+
import { IssuerTaxRegime, Address, SaleForDocument } from './sale/index.js';
|
|
3
|
+
import { SefazEnvironment, IssuedDocument, SidecarErrorBody, ContingencySignedDocument, ContingencyEntry, CancelledDocument, LookedUpDocument, InutilizedRange } from './sidecar/index.js';
|
|
4
|
+
import { T as TaxRegime } from './types-B1b8LIWX.js';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* The emitter profile and its issuing points — what moved INTO this package
|
|
8
|
+
* from the host's tax profile (FUT-2231's decision block): the company data,
|
|
9
|
+
* the address, the regime, the environment, the document policy, who signs,
|
|
10
|
+
* the certificate (as ciphertext), the CSC (as ciphertext) and the series.
|
|
11
|
+
*
|
|
12
|
+
* Keyed by an opaque `ownerId` the host maps to its own tenant. What stays in
|
|
13
|
+
* the host: the link to its tenant, where the settings screen sits, the CNPJ
|
|
14
|
+
* lookup, the accountant, and the plan-driven DEFAULT of `documentPolicy`
|
|
15
|
+
* (this package knows no plans, so it takes the value and never invents it).
|
|
16
|
+
*/
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* - `ISSUED_HERE`: this package issues the store's documents.
|
|
20
|
+
* - `ISSUED_ELSEWHERE`: the store issues in its own system and the host
|
|
21
|
+
* records the access key it types.
|
|
22
|
+
* - `NONE`: no document.
|
|
23
|
+
*/
|
|
24
|
+
type DocumentPolicy = "ISSUED_HERE" | "ISSUED_ELSEWHERE" | "NONE";
|
|
25
|
+
declare const DOCUMENT_POLICIES: readonly DocumentPolicy[];
|
|
26
|
+
/**
|
|
27
|
+
* Who signs. `STORE_CERTIFICATE`: the store's own A1, held encrypted through
|
|
28
|
+
* the host's cipher. `PLATFORM`: the platform signing on the store's behalf
|
|
29
|
+
* (LC 214/2025 art. 22 §12) — declared, answering `NOT_SUPPORTED` until it is
|
|
30
|
+
* decided how that signature works (FUT-2229 q4). Its own field from the start,
|
|
31
|
+
* so enabling it is an adapter, not a migration.
|
|
32
|
+
*/
|
|
33
|
+
type SigningIdentityKind = "STORE_CERTIFICATE" | "PLATFORM";
|
|
34
|
+
declare const SIGNING_IDENTITY_KINDS: readonly SigningIdentityKind[];
|
|
35
|
+
interface EmitterProfile {
|
|
36
|
+
readonly ownerId: string;
|
|
37
|
+
/** 14 characters; the 2026 alphanumeric CNPJ is accepted. */
|
|
38
|
+
readonly cnpj: string;
|
|
39
|
+
/** IE digits, or `ISENTO`. */
|
|
40
|
+
readonly stateRegistration: string;
|
|
41
|
+
readonly municipalRegistration: string | null;
|
|
42
|
+
readonly cnae: string | null;
|
|
43
|
+
readonly legalName: string;
|
|
44
|
+
readonly tradeName: string | null;
|
|
45
|
+
/** `CRT` on the document. */
|
|
46
|
+
readonly taxRegime: IssuerTaxRegime;
|
|
47
|
+
/** The IBS/CBS engine's regime, and the day it took effect (the Simples option is by semester). */
|
|
48
|
+
readonly regime: TaxRegime;
|
|
49
|
+
readonly regimeEffectiveFrom: string;
|
|
50
|
+
/** LC 214/2025 arts. 273–276 apply to the store's prepared food. */
|
|
51
|
+
readonly restaurantRegime: boolean;
|
|
52
|
+
readonly address: Address & {
|
|
53
|
+
readonly postalCode: string;
|
|
54
|
+
};
|
|
55
|
+
readonly environment: SefazEnvironment;
|
|
56
|
+
readonly documentPolicy: DocumentPolicy;
|
|
57
|
+
readonly signingIdentity: SigningIdentityKind;
|
|
58
|
+
/** The `.pfx` bytes (base64) through the host's cipher. Never in clear, never on the wire. */
|
|
59
|
+
readonly certificateCiphertext: string | null;
|
|
60
|
+
readonly certificatePasswordCiphertext: string | null;
|
|
61
|
+
readonly certificateExpiresAt: string | null;
|
|
62
|
+
readonly cscId: string | null;
|
|
63
|
+
/** The CSC token through the host's cipher. */
|
|
64
|
+
readonly cscCiphertext: string | null;
|
|
65
|
+
/** The store's consent to `PLATFORM` signing (art. 22 §12). */
|
|
66
|
+
readonly consentRecordedAt: string | null;
|
|
67
|
+
readonly updatedAt: string;
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* Where documents are issued from: an opaque id the host maps (a register, the
|
|
71
|
+
* online store). A register has an ONLINE and a CONTINGENCY series; a point
|
|
72
|
+
* that never goes offline has no contingency series. The package owns every
|
|
73
|
+
* series' counter; no host keeps a second one.
|
|
74
|
+
*/
|
|
75
|
+
interface IssuingPoint {
|
|
76
|
+
readonly id: string;
|
|
77
|
+
readonly ownerId: string;
|
|
78
|
+
readonly model: FiscalDocumentModel;
|
|
79
|
+
readonly onlineSeries: number;
|
|
80
|
+
readonly contingencySeries: number | null;
|
|
81
|
+
readonly createdAt: string;
|
|
82
|
+
}
|
|
83
|
+
/** The profile as the HTTP surface answers it: no ciphertext leaves the server. */
|
|
84
|
+
type EmitterProfileView = Omit<EmitterProfile, "certificateCiphertext" | "certificatePasswordCiphertext" | "cscCiphertext"> & {
|
|
85
|
+
readonly hasCertificate: boolean;
|
|
86
|
+
readonly hasCsc: boolean;
|
|
87
|
+
};
|
|
88
|
+
declare function viewOf(profile: EmitterProfile): EmitterProfileView;
|
|
89
|
+
|
|
90
|
+
/**
|
|
91
|
+
* What each input does to a document's fields — the state machine's body
|
|
92
|
+
* (`./machine` holds its table and its one entry point). Pure functions; a
|
|
93
|
+
* refusal throws `TRANSITION_REFUSED`.
|
|
94
|
+
*/
|
|
95
|
+
|
|
96
|
+
type SidecarError = SidecarErrorBody["error"];
|
|
97
|
+
/** Failures in a row after which a document waits for a person. */
|
|
98
|
+
declare const MAX_FAILURES = 8;
|
|
99
|
+
/** What the machine is fed. Each carries the service's answer, which the event keeps. */
|
|
100
|
+
type DocumentInput = {
|
|
101
|
+
readonly kind: "SUBMIT";
|
|
102
|
+
} | {
|
|
103
|
+
readonly kind: "AUTHORIZE";
|
|
104
|
+
readonly answer: IssuedDocument;
|
|
105
|
+
readonly xmlKey: string;
|
|
106
|
+
} | {
|
|
107
|
+
readonly kind: "DENY";
|
|
108
|
+
readonly answer: IssuedDocument;
|
|
109
|
+
readonly xmlKey: string;
|
|
110
|
+
} | {
|
|
111
|
+
readonly kind: "REJECT";
|
|
112
|
+
readonly error: SidecarError;
|
|
113
|
+
}
|
|
114
|
+
/** `xmlKey`: where the signed XML the failed call returned was stored, when it returned one. */
|
|
115
|
+
| {
|
|
116
|
+
readonly kind: "RETRY";
|
|
117
|
+
readonly error: SidecarError;
|
|
118
|
+
readonly xmlKey?: string;
|
|
119
|
+
} | {
|
|
120
|
+
readonly kind: "SIGN_OFFLINE";
|
|
121
|
+
readonly answer: ContingencySignedDocument;
|
|
122
|
+
readonly contingency: ContingencyEntry;
|
|
123
|
+
readonly xmlKey: string;
|
|
124
|
+
} | {
|
|
125
|
+
readonly kind: "REPLACE";
|
|
126
|
+
readonly replacedById: string;
|
|
127
|
+
} | {
|
|
128
|
+
readonly kind: "CANCEL";
|
|
129
|
+
readonly answer: CancelledDocument;
|
|
130
|
+
readonly reason: string;
|
|
131
|
+
readonly eventXmlKey: string | null;
|
|
132
|
+
}
|
|
133
|
+
/**
|
|
134
|
+
* `xmlKey`: the `nfeProc` assembled from the stored signed XML and the
|
|
135
|
+
* lookup's protocol. Without it a lookup never makes a SUBMITTED document
|
|
136
|
+
* final: an authorised document always has its XML.
|
|
137
|
+
*/
|
|
138
|
+
| {
|
|
139
|
+
readonly kind: "LOOKUP";
|
|
140
|
+
readonly answer: LookedUpDocument;
|
|
141
|
+
readonly xmlKey?: string;
|
|
142
|
+
} | {
|
|
143
|
+
readonly kind: "INUTILIZE";
|
|
144
|
+
readonly answer: InutilizedRange;
|
|
145
|
+
readonly eventXmlKey: string | null;
|
|
146
|
+
}
|
|
147
|
+
/**
|
|
148
|
+
* A step that made no progress (a settlement refused or unanswered, a step
|
|
149
|
+
* that threw). It counts a failure; `attention` hands the document to a
|
|
150
|
+
* person at once (SEFAZ refused it: retrying would only repeat the refusal).
|
|
151
|
+
*/
|
|
152
|
+
| {
|
|
153
|
+
readonly kind: "DEFER";
|
|
154
|
+
readonly reason: string;
|
|
155
|
+
readonly error: SidecarError | null;
|
|
156
|
+
readonly attention: boolean;
|
|
157
|
+
}
|
|
158
|
+
/** A rejected contingency NFC-e, corrected by the store and signed again under the same number. */
|
|
159
|
+
| {
|
|
160
|
+
readonly kind: "RESIGN";
|
|
161
|
+
readonly answer: ContingencySignedDocument;
|
|
162
|
+
readonly sale: SaleForDocument;
|
|
163
|
+
readonly totals: DocumentTotals;
|
|
164
|
+
readonly buyerTaxId: string | null;
|
|
165
|
+
readonly xmlKey: string;
|
|
166
|
+
}
|
|
167
|
+
/** A person took a document back from `attention`: the sweep may try again. */
|
|
168
|
+
| {
|
|
169
|
+
readonly kind: "RELEASE";
|
|
170
|
+
}
|
|
171
|
+
/** The 24-hour contingency deadline warning went out. */
|
|
172
|
+
| {
|
|
173
|
+
readonly kind: "WARN";
|
|
174
|
+
};
|
|
175
|
+
|
|
176
|
+
/**
|
|
177
|
+
* The fiscal document state machine: pure functions from a document and one
|
|
178
|
+
* input to the next document and the event that records the step.
|
|
179
|
+
*
|
|
180
|
+
* ```
|
|
181
|
+
* PENDING ──SUBMIT──▶ SUBMITTED ──AUTHORIZE──▶ AUTHORIZED ──CANCEL──▶ CANCELLED
|
|
182
|
+
* │ │ ├──DENY─────▶ DENIED
|
|
183
|
+
* │ │ ├──REJECT───▶ REJECTED
|
|
184
|
+
* │ │ └──RETRY────▶ SUBMITTED
|
|
185
|
+
* │ └──REPLACE──▶ REPLACED
|
|
186
|
+
* ├──REPLACE──▶ REPLACED
|
|
187
|
+
* └──SIGN_OFFLINE──▶ CONTINGENCY ──AUTHORIZE | DENY | REJECT | RETRY──▶ …
|
|
188
|
+
* ▲ REJECTED (contingency) ──RESIGN──┘
|
|
189
|
+
* ```
|
|
190
|
+
*
|
|
191
|
+
* A document is one number, so going offline is a SECOND document on the
|
|
192
|
+
* issuing point's contingency series (`PENDING → CONTINGENCY`), and the first
|
|
193
|
+
* one is `REPLACED`. Every input yields an event; a refused one throws
|
|
194
|
+
* {@link FiscalDocumentError} `TRANSITION_REFUSED` and changes nothing:
|
|
195
|
+
* `CANCELLED` is entered only from `AUTHORIZED`, and `AUTHORIZED` never from a
|
|
196
|
+
* final state. A rejected contingency NFC-e is the one way back: the store
|
|
197
|
+
* corrects it and it is signed again under the same number (`RESIGN`).
|
|
198
|
+
*
|
|
199
|
+
* `DEFER`, `RELEASE` and `WARN` record what the sweep and a person did without
|
|
200
|
+
* changing the state: a failed step counts toward {@link MAX_FAILURES}, after
|
|
201
|
+
* which the document waits for a person (`attention`).
|
|
202
|
+
*/
|
|
203
|
+
|
|
204
|
+
/** From which states each input is accepted. */
|
|
205
|
+
declare const DOCUMENT_TRANSITIONS: Readonly<Record<DocumentEventKind, readonly FiscalDocumentStatus[]>>;
|
|
206
|
+
/** The states nothing but a lookup, a cancel or an inutilization of the number may follow. */
|
|
207
|
+
declare const FINAL_STATUSES: readonly FiscalDocumentStatus[];
|
|
208
|
+
interface Transition {
|
|
209
|
+
readonly document: FiscalDocument;
|
|
210
|
+
readonly event: FiscalDocumentEvent;
|
|
211
|
+
}
|
|
212
|
+
/**
|
|
213
|
+
* A copy of an answer with every secret-named key dropped. The service never
|
|
214
|
+
* echoes one; this is the second lock, so an event row can never hold one.
|
|
215
|
+
*/
|
|
216
|
+
declare function scrubSecrets(value: unknown): unknown;
|
|
217
|
+
/**
|
|
218
|
+
* Apply one input. Throws `TRANSITION_REFUSED` (and changes nothing) when the
|
|
219
|
+
* document's state does not accept it. `at` is the caller's clock, ISO 8601.
|
|
220
|
+
*/
|
|
221
|
+
declare function transition(document: FiscalDocument, input: DocumentInput, at: string): Transition;
|
|
222
|
+
/** Whether an input would be accepted, without applying it. */
|
|
223
|
+
declare function canTransition(status: FiscalDocumentStatus, kind: DocumentEventKind): boolean;
|
|
224
|
+
|
|
225
|
+
/**
|
|
226
|
+
* The ports a host implements for the document module. None has a default:
|
|
227
|
+
* where the bytes live, how a secret is encrypted, what a sale is and where
|
|
228
|
+
* the rows are stored are the host's answers, asked for by name.
|
|
229
|
+
*/
|
|
230
|
+
|
|
231
|
+
/**
|
|
232
|
+
* Encrypts the certificate, its password and the CSC at rest — the
|
|
233
|
+
* `{ encrypt, decrypt }` shape `@12-apps/payments-backend` takes. Synchronous
|
|
234
|
+
* or not, as the host's cipher is.
|
|
235
|
+
*/
|
|
236
|
+
interface Cipher {
|
|
237
|
+
encrypt(plaintext: string): string | Promise<string>;
|
|
238
|
+
decrypt(ciphertext: string): string | Promise<string>;
|
|
239
|
+
}
|
|
240
|
+
/** Where the XMLs live (object storage, retained as the law asks: five years). */
|
|
241
|
+
interface DocumentStorage {
|
|
242
|
+
put(key: string, body: string, contentType: string): Promise<void>;
|
|
243
|
+
get(key: string): Promise<string | null>;
|
|
244
|
+
}
|
|
245
|
+
/**
|
|
246
|
+
* The host's sale in the package's neutral shape — everything but what the
|
|
247
|
+
* package fills: the issuer (from the profile), the series and number (from
|
|
248
|
+
* its counter), the key code and the issue time.
|
|
249
|
+
*/
|
|
250
|
+
type SaleDraft = Omit<SaleForDocument, "series" | "number" | "keyCode" | "issuer" | "issuedAt">;
|
|
251
|
+
interface SaleSource {
|
|
252
|
+
saleFor(input: {
|
|
253
|
+
readonly ownerId: string;
|
|
254
|
+
readonly subjectId: string;
|
|
255
|
+
readonly model: FiscalDocumentModel;
|
|
256
|
+
}): Promise<SaleDraft>;
|
|
257
|
+
}
|
|
258
|
+
/**
|
|
259
|
+
* Which counter a new document draws from. SEFAZ numbers by the issuer's
|
|
260
|
+
* CNPJ, the model and the series, so the counter is keyed by them: one CNPJ
|
|
261
|
+
* can serve several owners, and they share its series.
|
|
262
|
+
*/
|
|
263
|
+
interface NumberRequest {
|
|
264
|
+
readonly ownerId: string;
|
|
265
|
+
readonly issuerCnpj: string;
|
|
266
|
+
readonly issuingPointId: string;
|
|
267
|
+
readonly environment: SefazEnvironment;
|
|
268
|
+
readonly model: FiscalDocumentModel;
|
|
269
|
+
readonly seriesKind: SeriesKind;
|
|
270
|
+
readonly series: number;
|
|
271
|
+
}
|
|
272
|
+
/**
|
|
273
|
+
* The rows. `createPrismaFiscalStore` (`./sql-store`) is the package's own
|
|
274
|
+
* implementation over the host's Prisma client; `createMemoryFiscalStore`
|
|
275
|
+
* the reference for tests. Every method that writes is one transaction:
|
|
276
|
+
*
|
|
277
|
+
* - `createDocument` draws the next number of the series AND inserts the
|
|
278
|
+
* document built from it, together — a refused insert gives the number
|
|
279
|
+
* back, so the sequence has no gap a failed write made. With `replace`, the
|
|
280
|
+
* document it replaces is advanced in the SAME transaction, before the
|
|
281
|
+
* insert, so a crash can never leave both live. A second LIVE document for
|
|
282
|
+
* the same (owner, subject, model) is refused with `SUBJECT_HAS_DOCUMENT`
|
|
283
|
+
* (`isLive`), and nothing is drawn;
|
|
284
|
+
* - `saveTransition` writes the document and appends its event, and refuses
|
|
285
|
+
* (`false`) when the stored row's `updatedAt` or `status` is no longer the
|
|
286
|
+
* one the transition started from, so two workers never both advance it.
|
|
287
|
+
*/
|
|
288
|
+
interface FiscalStore {
|
|
289
|
+
getProfile(ownerId: string): Promise<EmitterProfile | null>;
|
|
290
|
+
saveProfile(profile: EmitterProfile): Promise<void>;
|
|
291
|
+
getIssuingPoint(ownerId: string, issuingPointId: string): Promise<IssuingPoint | null>;
|
|
292
|
+
listIssuingPoints(ownerId: string): Promise<IssuingPoint[]>;
|
|
293
|
+
/**
|
|
294
|
+
* Creates the point and its counters under the issuer's CNPJ, in both
|
|
295
|
+
* environments, starting at `firstNumber` (a store moving from another
|
|
296
|
+
* system continues its sequence). A series another point holds is refused.
|
|
297
|
+
*/
|
|
298
|
+
createIssuingPoint(point: IssuingPoint, issuerCnpj: string, firstNumber: {
|
|
299
|
+
readonly online: number;
|
|
300
|
+
readonly contingency: number;
|
|
301
|
+
}): Promise<void>;
|
|
302
|
+
createDocument(request: NumberRequest, build: (number: number) => FiscalDocument, replace?: {
|
|
303
|
+
readonly previous: FiscalDocument;
|
|
304
|
+
readonly transition: Transition;
|
|
305
|
+
}): Promise<FiscalDocument>;
|
|
306
|
+
getDocument(ownerId: string, documentId: string): Promise<FiscalDocument | null>;
|
|
307
|
+
/** The subject's documents of a model, oldest first. */
|
|
308
|
+
listBySubject(ownerId: string, subjectId: string, model: FiscalDocumentModel): Promise<FiscalDocument[]>;
|
|
309
|
+
listEvents(documentId: string): Promise<FiscalDocumentEvent[]>;
|
|
310
|
+
saveTransition(previous: FiscalDocument, transition: Transition): Promise<boolean>;
|
|
311
|
+
/**
|
|
312
|
+
* Documents the sweep owes a step, across owners, whose `nextAttemptAt` has
|
|
313
|
+
* come: `PENDING` or `SUBMITTED`, and those whose `numberVoid` is still owed.
|
|
314
|
+
* Never one waiting for a person. Ordered by `nextAttemptAt`, so a row that
|
|
315
|
+
* keeps failing moves back and never pins the head. At most `limit`.
|
|
316
|
+
*/
|
|
317
|
+
listDue(input: {
|
|
318
|
+
readonly now: string;
|
|
319
|
+
readonly limit: number;
|
|
320
|
+
}): Promise<FiscalDocument[]>;
|
|
321
|
+
/** `CONTINGENCY` documents owed a transmission, the same way. */
|
|
322
|
+
listContingency(input: {
|
|
323
|
+
readonly now: string;
|
|
324
|
+
readonly limit: number;
|
|
325
|
+
}): Promise<FiscalDocument[]>;
|
|
326
|
+
/** `CONTINGENCY` documents signed before `signedBefore` whose deadline warning has not gone out. */
|
|
327
|
+
listContingencyDeadline(input: {
|
|
328
|
+
readonly signedBefore: string;
|
|
329
|
+
readonly limit: number;
|
|
330
|
+
}): Promise<FiscalDocument[]>;
|
|
331
|
+
/** Profiles whose certificate expires before `before`, across owners. */
|
|
332
|
+
listExpiringCertificates(before: string): Promise<EmitterProfile[]>;
|
|
333
|
+
}
|
|
334
|
+
/**
|
|
335
|
+
* DECLARED, NOT IMPLEMENTED (FUT-4717): what an offline register needs from
|
|
336
|
+
* the package that owns every number. A register that cannot reach the server
|
|
337
|
+
* signs on a block of its contingency series reserved in advance; back
|
|
338
|
+
* online, it hands in what it signed, and the known rest of a finished block
|
|
339
|
+
* is voided — an unknown range never is. The interface is named now so the
|
|
340
|
+
* register's ticket builds against it; nothing in this release calls it.
|
|
341
|
+
*/
|
|
342
|
+
interface ContingencyBlockSource {
|
|
343
|
+
/** Reserve the next `size` numbers of the point's contingency series for one register. */
|
|
344
|
+
reserveBlock(input: {
|
|
345
|
+
readonly ownerId: string;
|
|
346
|
+
readonly issuingPointId: string;
|
|
347
|
+
readonly size: number;
|
|
348
|
+
}): Promise<{
|
|
349
|
+
readonly series: number;
|
|
350
|
+
readonly from: number;
|
|
351
|
+
readonly to: number;
|
|
352
|
+
}>;
|
|
353
|
+
/** Record an XML the register signed offline as a CONTINGENCY document of the block. */
|
|
354
|
+
recordSigned(input: {
|
|
355
|
+
readonly ownerId: string;
|
|
356
|
+
readonly subjectId: string;
|
|
357
|
+
readonly signedXml: string;
|
|
358
|
+
}): Promise<FiscalDocument>;
|
|
359
|
+
/** The block is finished: void the numbers known unused (`sequenceUsed` tells which were). */
|
|
360
|
+
closeBlock(input: {
|
|
361
|
+
readonly ownerId: string;
|
|
362
|
+
readonly series: number;
|
|
363
|
+
readonly from: number;
|
|
364
|
+
readonly sequenceUsed: number;
|
|
365
|
+
}): Promise<void>;
|
|
366
|
+
}
|
|
367
|
+
|
|
368
|
+
/**
|
|
369
|
+
* The SigningIdentity port: who signs a call. It turns a profile into the
|
|
370
|
+
* {@link SigningMaterial} for ONE call to the issuer; the material is never
|
|
371
|
+
* stored, logged or put in an error.
|
|
372
|
+
*
|
|
373
|
+
* - `STORE_CERTIFICATE` ships now: the store's own A1, decrypted through the
|
|
374
|
+
* host's {@link Cipher} at the moment of the call.
|
|
375
|
+
* - `PLATFORM` is declared and answers `NOT_SUPPORTED` until FUT-2229
|
|
376
|
+
* question 4 says how the platform signs on a store's behalf.
|
|
377
|
+
*/
|
|
378
|
+
|
|
379
|
+
interface SigningIdentity {
|
|
380
|
+
readonly kind: SigningIdentityKind;
|
|
381
|
+
materialFor(profile: EmitterProfile): Promise<SigningMaterial>;
|
|
382
|
+
}
|
|
383
|
+
type SigningIdentities = Readonly<Record<SigningIdentityKind, SigningIdentity>>;
|
|
384
|
+
declare function createStoreCertificateIdentity(config: {
|
|
385
|
+
readonly cipher: Cipher;
|
|
386
|
+
}): SigningIdentity;
|
|
387
|
+
declare function createPlatformIdentity(): SigningIdentity;
|
|
388
|
+
/** The two identities over one cipher: what a host passes as `signing`. */
|
|
389
|
+
declare function createSigningIdentities(config: {
|
|
390
|
+
readonly cipher: Cipher;
|
|
391
|
+
}): SigningIdentities;
|
|
392
|
+
|
|
393
|
+
/**
|
|
394
|
+
* What every step of the document service shares: the ports, the clock, the
|
|
395
|
+
* host's words written into a document, and the two writes everything goes
|
|
396
|
+
* through — numbering a new document, and persisting one transition with the
|
|
397
|
+
* schedule and the person's flag it implies.
|
|
398
|
+
*/
|
|
399
|
+
|
|
400
|
+
/** Twin of `@12-apps/wiring/ports`' `NotifyPort`: never throws. */
|
|
401
|
+
interface FiscalNotifyPort {
|
|
402
|
+
emit(event: {
|
|
403
|
+
readonly type: string;
|
|
404
|
+
readonly recipient: {
|
|
405
|
+
readonly tenantId: string;
|
|
406
|
+
readonly permission: string;
|
|
407
|
+
};
|
|
408
|
+
readonly payload: unknown;
|
|
409
|
+
}): Promise<unknown>;
|
|
410
|
+
}
|
|
411
|
+
/**
|
|
412
|
+
* The words SEFAZ receives in a document, an event or a request — the host's,
|
|
413
|
+
* in the host's language, 15 to 255 characters each. No default: a library
|
|
414
|
+
* that wrote them would be writing a fiscal statement for its host.
|
|
415
|
+
*/
|
|
416
|
+
interface FiscalReasons {
|
|
417
|
+
/** `xJust` of a document signed offline. */
|
|
418
|
+
readonly contingency: string;
|
|
419
|
+
/** Why an unused number is inutilized. */
|
|
420
|
+
readonly inutilization: string;
|
|
421
|
+
/** Why a document found authorised after its sale moved to contingency is cancelled. */
|
|
422
|
+
readonly substitution: string;
|
|
423
|
+
}
|
|
424
|
+
interface FiscalDocumentsConfig {
|
|
425
|
+
readonly store: FiscalStore;
|
|
426
|
+
readonly issuer: Issuer;
|
|
427
|
+
readonly signing: SigningIdentities;
|
|
428
|
+
readonly storage: DocumentStorage;
|
|
429
|
+
readonly sales: SaleSource;
|
|
430
|
+
readonly notify: FiscalNotifyPort;
|
|
431
|
+
readonly now: () => Date;
|
|
432
|
+
/** The owner's UTC offset at an instant (`-03:00`): `dhEmi` and `dhCont` are local times. */
|
|
433
|
+
readonly utcOffset: (ownerId: string, at: Date) => string | Promise<string>;
|
|
434
|
+
readonly reasons: FiscalReasons;
|
|
435
|
+
/**
|
|
436
|
+
* How long a document owing a step waits before the sweep takes it again,
|
|
437
|
+
* the base of the backoff: each failure in a row doubles it, up to 64×.
|
|
438
|
+
*/
|
|
439
|
+
readonly staleAfterMs: number;
|
|
440
|
+
/**
|
|
441
|
+
* How late an online NFC-e may still be sent with its `dhEmi`. SEFAZ refuses
|
|
442
|
+
* a late one (704, "data-hora de emissão atrasada"; five minutes in most
|
|
443
|
+
* states — the host's, per state). Past it, a stale online NFC-e at a point
|
|
444
|
+
* with a contingency series goes offline instead of being sent again.
|
|
445
|
+
*/
|
|
446
|
+
readonly nfceOnlineToleranceMs: number;
|
|
447
|
+
/** Ids for new documents. */
|
|
448
|
+
readonly newId: () => string;
|
|
449
|
+
}
|
|
450
|
+
declare const FISCAL_DOCUMENT_REJECTED = "fiscal.document-rejected";
|
|
451
|
+
declare const FISCAL_CERTIFICATE_EXPIRING = "fiscal.certificate-expiring";
|
|
452
|
+
declare const FISCAL_DOCUMENT_NEEDS_ATTENTION = "fiscal.document-needs-attention";
|
|
453
|
+
declare const FISCAL_CONTINGENCY_DEADLINE = "fiscal.contingency-deadline";
|
|
454
|
+
|
|
455
|
+
export { type Cipher as C, type DocumentStorage as D, type EmitterProfile as E, type FiscalStore as F, type IssuingPoint as I, MAX_FAILURES as M, type NumberRequest as N, type SigningIdentityKind as S, type Transition as T, type FiscalNotifyPort as a, FISCAL_CERTIFICATE_EXPIRING as b, FISCAL_CONTINGENCY_DEADLINE as c, FISCAL_DOCUMENT_NEEDS_ATTENTION as d, FISCAL_DOCUMENT_REJECTED as e, type DocumentPolicy as f, type FiscalDocumentsConfig as g, type SaleDraft as h, type ContingencyBlockSource as i, DOCUMENT_POLICIES as j, DOCUMENT_TRANSITIONS as k, type DocumentInput as l, type EmitterProfileView as m, FINAL_STATUSES as n, type FiscalReasons as o, SIGNING_IDENTITY_KINDS as p, type SaleSource as q, type SigningIdentities as r, type SigningIdentity as s, canTransition as t, createPlatformIdentity as u, createSigningIdentities as v, createStoreCertificateIdentity as w, scrubSecrets as x, transition as y, viewOf as z };
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { D as DanfeNfceLabels } from '../labels-BNvflT0h.js';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* The DANFE NFC-e's words in English — a named pack, for a host that shows the
|
|
5
|
+
* paper to English readers (a preview, a support screen, a test). The paper a
|
|
6
|
+
* Brazilian consumer receives is printed with `./pt-BR`: the Manual do DANFE
|
|
7
|
+
* NFC-e fixes its legal phrases in Portuguese.
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
declare const DANFE_NFCE_EN_US: DanfeNfceLabels;
|
|
11
|
+
|
|
12
|
+
export { DANFE_NFCE_EN_US };
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import "../chunk-7QVYU63E.js";
|
|
2
|
+
|
|
3
|
+
// src/danfe/en-US.ts
|
|
4
|
+
var DANFE_NFCE_EN_US = {
|
|
5
|
+
cnpj: "CNPJ",
|
|
6
|
+
stateRegistration: "IE",
|
|
7
|
+
title: "Auxiliary Document of the Electronic Consumer Invoice",
|
|
8
|
+
itemsHeader: "CODE DESCRIPTION QTY UN UNIT PRICE TOTAL",
|
|
9
|
+
itemCount: "Total items",
|
|
10
|
+
totalValue: "Total BRL",
|
|
11
|
+
discounts: "Discounts BRL",
|
|
12
|
+
amountDue: "Amount due BRL",
|
|
13
|
+
paymentHeader: "PAYMENT METHOD / AMOUNT PAID BRL",
|
|
14
|
+
change: "Change BRL",
|
|
15
|
+
paymentMethods: {
|
|
16
|
+
"01": "Cash",
|
|
17
|
+
"02": "Check",
|
|
18
|
+
"03": "Credit card",
|
|
19
|
+
"04": "Debit card",
|
|
20
|
+
"05": "Store credit",
|
|
21
|
+
"10": "Food voucher",
|
|
22
|
+
"11": "Meal voucher",
|
|
23
|
+
"12": "Gift voucher",
|
|
24
|
+
"13": "Fuel voucher",
|
|
25
|
+
"15": "Bank slip",
|
|
26
|
+
"16": "Bank deposit",
|
|
27
|
+
"17": "Dynamic Pix",
|
|
28
|
+
"18": "Bank transfer",
|
|
29
|
+
"19": "Loyalty program",
|
|
30
|
+
"20": "Static Pix",
|
|
31
|
+
"90": "No payment",
|
|
32
|
+
"99": "Other"
|
|
33
|
+
},
|
|
34
|
+
lookupByKey: "Look the access key up at",
|
|
35
|
+
homologation: "ISSUED IN THE TEST ENVIRONMENT - NO FISCAL VALUE",
|
|
36
|
+
contingency: "ISSUED IN CONTINGENCY",
|
|
37
|
+
pendingAuthorization: "Pending authorisation",
|
|
38
|
+
consumerCopy: "Consumer copy",
|
|
39
|
+
consumer: "CONSUMER",
|
|
40
|
+
unidentifiedConsumer: "UNIDENTIFIED CONSUMER",
|
|
41
|
+
number: "NFC-e no.",
|
|
42
|
+
series: "Series",
|
|
43
|
+
protocol: "Authorisation protocol:",
|
|
44
|
+
authorizedAt: "Authorised at:",
|
|
45
|
+
qrCaption: "Look it up with a QR code reader",
|
|
46
|
+
approximateTaxes: "Total taxes (Federal Law 12.741/2012) BRL"
|
|
47
|
+
};
|
|
48
|
+
export {
|
|
49
|
+
DANFE_NFCE_EN_US
|
|
50
|
+
};
|
|
51
|
+
//# sourceMappingURL=en-US.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/danfe/en-US.ts"],"sourcesContent":["/**\n * The DANFE NFC-e's words in English — a named pack, for a host that shows the\n * paper to English readers (a preview, a support screen, a test). The paper a\n * Brazilian consumer receives is printed with `./pt-BR`: the Manual do DANFE\n * NFC-e fixes its legal phrases in Portuguese.\n */\n\nimport type { DanfeNfceLabels } from \"./labels\";\n\nexport const DANFE_NFCE_EN_US: DanfeNfceLabels = {\n cnpj: \"CNPJ\",\n stateRegistration: \"IE\",\n title: \"Auxiliary Document of the Electronic Consumer Invoice\",\n itemsHeader: \"CODE DESCRIPTION QTY UN UNIT PRICE TOTAL\",\n itemCount: \"Total items\",\n totalValue: \"Total BRL\",\n discounts: \"Discounts BRL\",\n amountDue: \"Amount due BRL\",\n paymentHeader: \"PAYMENT METHOD / AMOUNT PAID BRL\",\n change: \"Change BRL\",\n paymentMethods: {\n \"01\": \"Cash\",\n \"02\": \"Check\",\n \"03\": \"Credit card\",\n \"04\": \"Debit card\",\n \"05\": \"Store credit\",\n \"10\": \"Food voucher\",\n \"11\": \"Meal voucher\",\n \"12\": \"Gift voucher\",\n \"13\": \"Fuel voucher\",\n \"15\": \"Bank slip\",\n \"16\": \"Bank deposit\",\n \"17\": \"Dynamic Pix\",\n \"18\": \"Bank transfer\",\n \"19\": \"Loyalty program\",\n \"20\": \"Static Pix\",\n \"90\": \"No payment\",\n \"99\": \"Other\",\n },\n lookupByKey: \"Look the access key up at\",\n homologation: \"ISSUED IN THE TEST ENVIRONMENT - NO FISCAL VALUE\",\n contingency: \"ISSUED IN CONTINGENCY\",\n pendingAuthorization: \"Pending authorisation\",\n consumerCopy: \"Consumer copy\",\n consumer: \"CONSUMER\",\n unidentifiedConsumer: \"UNIDENTIFIED CONSUMER\",\n number: \"NFC-e no.\",\n series: \"Series\",\n protocol: \"Authorisation protocol:\",\n authorizedAt: \"Authorised at:\",\n qrCaption: \"Look it up with a QR code reader\",\n approximateTaxes: \"Total taxes (Federal Law 12.741/2012) BRL\",\n};\n"],"mappings":";;;AASO,IAAM,mBAAoC;AAAA,EAC/C,MAAM;AAAA,EACN,mBAAmB;AAAA,EACnB,OAAO;AAAA,EACP,aAAa;AAAA,EACb,WAAW;AAAA,EACX,YAAY;AAAA,EACZ,WAAW;AAAA,EACX,WAAW;AAAA,EACX,eAAe;AAAA,EACf,QAAQ;AAAA,EACR,gBAAgB;AAAA,IACd,MAAM;AAAA,IACN,MAAM;AAAA,IACN,MAAM;AAAA,IACN,MAAM;AAAA,IACN,MAAM;AAAA,IACN,MAAM;AAAA,IACN,MAAM;AAAA,IACN,MAAM;AAAA,IACN,MAAM;AAAA,IACN,MAAM;AAAA,IACN,MAAM;AAAA,IACN,MAAM;AAAA,IACN,MAAM;AAAA,IACN,MAAM;AAAA,IACN,MAAM;AAAA,IACN,MAAM;AAAA,IACN,MAAM;AAAA,EACR;AAAA,EACA,aAAa;AAAA,EACb,cAAc;AAAA,EACd,aAAa;AAAA,EACb,sBAAsB;AAAA,EACtB,cAAc;AAAA,EACd,UAAU;AAAA,EACV,sBAAsB;AAAA,EACtB,QAAQ;AAAA,EACR,QAAQ;AAAA,EACR,UAAU;AAAA,EACV,cAAc;AAAA,EACd,WAAW;AAAA,EACX,kBAAkB;AACpB;","names":[]}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { D as DanfeNfceLabels } from '../labels-BNvflT0h.js';
|
|
2
|
+
export { a as DANFE_LABEL_KEYS } from '../labels-BNvflT0h.js';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* The DANFE NFC-e as ESC/POS-ready lines, read from the document's XML —
|
|
6
|
+
* the authorised `nfeProc`, or the signed XML of a document issued offline,
|
|
7
|
+
* which prints the contingency variant. No provider returns ESC/POS and a
|
|
8
|
+
* register offline has nothing else to print, so the package renders it.
|
|
9
|
+
*
|
|
10
|
+
* The paper follows the Manual do DANFE NFC-e's divisions, in order (the
|
|
11
|
+
* FULL DANFE, items included):
|
|
12
|
+
*
|
|
13
|
+
* I the issuer: name, CNPJ, IE, address
|
|
14
|
+
* II the document's title
|
|
15
|
+
* III the items: code, description, quantity, unit, unit value, total
|
|
16
|
+
* IV the totals: item count, total, discounts, amount due, payments, change
|
|
17
|
+
* V the fiscal message: homologation, contingency, where to look the key up, the key
|
|
18
|
+
* VI the consumer
|
|
19
|
+
* VII the number, series, issue time, and the authorisation protocol
|
|
20
|
+
* VIII the QR code, then the taxpayer's message and the approximate taxes
|
|
21
|
+
*
|
|
22
|
+
* Each line is `{ text, align, emphasis }`, the shape `@12-apps/thermal-printing`
|
|
23
|
+
* encodes, laid out for the column count of the roll (Font A: 32 columns on
|
|
24
|
+
* 58 mm, 48 on 80 mm); the QR line carries `qrCode` for the host to rasterise.
|
|
25
|
+
*/
|
|
26
|
+
|
|
27
|
+
type DanfeDivision = "I" | "II" | "III" | "IV" | "V" | "VI" | "VII" | "VIII";
|
|
28
|
+
interface DanfeLine {
|
|
29
|
+
readonly division: DanfeDivision;
|
|
30
|
+
readonly text: string;
|
|
31
|
+
readonly align: "left" | "center";
|
|
32
|
+
readonly emphasis: "normal" | "bold";
|
|
33
|
+
/** Present on the QR line only: the URL the code encodes. */
|
|
34
|
+
readonly qrCode?: string;
|
|
35
|
+
}
|
|
36
|
+
type PaperWidth = 58 | 80;
|
|
37
|
+
declare const DANFE_COLUMNS: Readonly<Record<PaperWidth, number>>;
|
|
38
|
+
interface DanfeNfceInput {
|
|
39
|
+
/** The `nfeProc` of an authorised document, or the signed XML of one issued offline. */
|
|
40
|
+
readonly xml: string;
|
|
41
|
+
readonly paperWidth: PaperWidth;
|
|
42
|
+
readonly labels: DanfeNfceLabels;
|
|
43
|
+
}
|
|
44
|
+
/** `1234` cents → `12,34`; thousands with a dot, as the DANFE prints money. */
|
|
45
|
+
declare function money(value: string | null): string;
|
|
46
|
+
/** Wrap a text at the width, breaking on spaces where it can. */
|
|
47
|
+
declare function wrap(value: string, width: number): string[];
|
|
48
|
+
declare function renderDanfeNfce(input: DanfeNfceInput): DanfeLine[];
|
|
49
|
+
|
|
50
|
+
export { DANFE_COLUMNS, type DanfeDivision, type DanfeLine, type DanfeNfceInput, DanfeNfceLabels, type PaperWidth, money, renderDanfeNfce, wrap };
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import {
|
|
2
|
+
DANFE_COLUMNS,
|
|
3
|
+
DANFE_LABEL_KEYS,
|
|
4
|
+
money,
|
|
5
|
+
renderDanfeNfce,
|
|
6
|
+
wrap
|
|
7
|
+
} from "../chunk-WTGASIZE.js";
|
|
8
|
+
import "../chunk-PNTKG3DZ.js";
|
|
9
|
+
import "../chunk-2LBQRYPV.js";
|
|
10
|
+
import "../chunk-7QVYU63E.js";
|
|
11
|
+
export {
|
|
12
|
+
DANFE_COLUMNS,
|
|
13
|
+
DANFE_LABEL_KEYS,
|
|
14
|
+
money,
|
|
15
|
+
renderDanfeNfce,
|
|
16
|
+
wrap
|
|
17
|
+
};
|
|
18
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { D as DanfeNfceLabels } from '../labels-BNvflT0h.js';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* The Manual do DANFE NFC-e's own texts, in Portuguese — a named pack, the
|
|
5
|
+
* words a Brazilian host passes as `labels`. The legal phrases (the title,
|
|
6
|
+
* the homologation and contingency notices) are the Manual's, verbatim.
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
declare const DANFE_NFCE_PT_BR: DanfeNfceLabels;
|
|
10
|
+
|
|
11
|
+
export { DANFE_NFCE_PT_BR };
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import "../chunk-7QVYU63E.js";
|
|
2
|
+
|
|
3
|
+
// src/danfe/pt-BR.ts
|
|
4
|
+
var DANFE_NFCE_PT_BR = {
|
|
5
|
+
cnpj: "CNPJ",
|
|
6
|
+
stateRegistration: "IE",
|
|
7
|
+
title: "Documento Auxiliar da Nota Fiscal de Consumidor Eletr\xF4nica",
|
|
8
|
+
itemsHeader: "C\xD3DIGO DESCRI\xC7\xC3O QTDE UN VL UNIT VL TOTAL",
|
|
9
|
+
itemCount: "Qtde. total de itens",
|
|
10
|
+
totalValue: "Valor total R$",
|
|
11
|
+
discounts: "Descontos R$",
|
|
12
|
+
amountDue: "Valor a Pagar R$",
|
|
13
|
+
paymentHeader: "FORMA PAGAMENTO / VALOR PAGO R$",
|
|
14
|
+
change: "Troco R$",
|
|
15
|
+
paymentMethods: {
|
|
16
|
+
"01": "Dinheiro",
|
|
17
|
+
"02": "Cheque",
|
|
18
|
+
"03": "Cart\xE3o de Cr\xE9dito",
|
|
19
|
+
"04": "Cart\xE3o de D\xE9bito",
|
|
20
|
+
"05": "Cr\xE9dito Loja",
|
|
21
|
+
"10": "Vale Alimenta\xE7\xE3o",
|
|
22
|
+
"11": "Vale Refei\xE7\xE3o",
|
|
23
|
+
"12": "Vale Presente",
|
|
24
|
+
"13": "Vale Combust\xEDvel",
|
|
25
|
+
"15": "Boleto Banc\xE1rio",
|
|
26
|
+
"16": "Dep\xF3sito Banc\xE1rio",
|
|
27
|
+
"17": "PIX Din\xE2mico",
|
|
28
|
+
"18": "Transfer\xEAncia banc\xE1ria",
|
|
29
|
+
"19": "Programa de fidelidade",
|
|
30
|
+
"20": "PIX Est\xE1tico",
|
|
31
|
+
"90": "Sem pagamento",
|
|
32
|
+
"99": "Outros"
|
|
33
|
+
},
|
|
34
|
+
lookupByKey: "Consulte pela Chave de Acesso em",
|
|
35
|
+
homologation: "EMITIDA EM AMBIENTE DE HOMOLOGA\xC7\xC3O - SEM VALOR FISCAL",
|
|
36
|
+
contingency: "EMITIDA EM CONTING\xCANCIA",
|
|
37
|
+
pendingAuthorization: "Pendente de autoriza\xE7\xE3o",
|
|
38
|
+
consumerCopy: "Via consumidor",
|
|
39
|
+
consumer: "CONSUMIDOR",
|
|
40
|
+
unidentifiedConsumer: "CONSUMIDOR N\xC3O IDENTIFICADO",
|
|
41
|
+
number: "NFC-e n\xBA",
|
|
42
|
+
series: "S\xE9rie",
|
|
43
|
+
protocol: "Protocolo de autoriza\xE7\xE3o:",
|
|
44
|
+
authorizedAt: "Data de autoriza\xE7\xE3o:",
|
|
45
|
+
qrCaption: "Consulta via leitor de QR Code",
|
|
46
|
+
approximateTaxes: "Tributos totais incidentes (Lei Federal 12.741/2012) R$"
|
|
47
|
+
};
|
|
48
|
+
export {
|
|
49
|
+
DANFE_NFCE_PT_BR
|
|
50
|
+
};
|
|
51
|
+
//# sourceMappingURL=pt-BR.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/danfe/pt-BR.ts"],"sourcesContent":["/**\n * The Manual do DANFE NFC-e's own texts, in Portuguese — a named pack, the\n * words a Brazilian host passes as `labels`. The legal phrases (the title,\n * the homologation and contingency notices) are the Manual's, verbatim.\n */\n\nimport type { DanfeNfceLabels } from \"./labels\";\n\nexport const DANFE_NFCE_PT_BR: DanfeNfceLabels = {\n cnpj: \"CNPJ\",\n stateRegistration: \"IE\",\n title: \"Documento Auxiliar da Nota Fiscal de Consumidor Eletrônica\",\n itemsHeader: \"CÓDIGO DESCRIÇÃO QTDE UN VL UNIT VL TOTAL\",\n itemCount: \"Qtde. total de itens\",\n totalValue: \"Valor total R$\",\n discounts: \"Descontos R$\",\n amountDue: \"Valor a Pagar R$\",\n paymentHeader: \"FORMA PAGAMENTO / VALOR PAGO R$\",\n change: \"Troco R$\",\n paymentMethods: {\n \"01\": \"Dinheiro\",\n \"02\": \"Cheque\",\n \"03\": \"Cartão de Crédito\",\n \"04\": \"Cartão de Débito\",\n \"05\": \"Crédito Loja\",\n \"10\": \"Vale Alimentação\",\n \"11\": \"Vale Refeição\",\n \"12\": \"Vale Presente\",\n \"13\": \"Vale Combustível\",\n \"15\": \"Boleto Bancário\",\n \"16\": \"Depósito Bancário\",\n \"17\": \"PIX Dinâmico\",\n \"18\": \"Transferência bancária\",\n \"19\": \"Programa de fidelidade\",\n \"20\": \"PIX Estático\",\n \"90\": \"Sem pagamento\",\n \"99\": \"Outros\",\n },\n lookupByKey: \"Consulte pela Chave de Acesso em\",\n homologation: \"EMITIDA EM AMBIENTE DE HOMOLOGAÇÃO - SEM VALOR FISCAL\",\n contingency: \"EMITIDA EM CONTINGÊNCIA\",\n pendingAuthorization: \"Pendente de autorização\",\n consumerCopy: \"Via consumidor\",\n consumer: \"CONSUMIDOR\",\n unidentifiedConsumer: \"CONSUMIDOR NÃO IDENTIFICADO\",\n number: \"NFC-e nº\",\n series: \"Série\",\n protocol: \"Protocolo de autorização:\",\n authorizedAt: \"Data de autorização:\",\n qrCaption: \"Consulta via leitor de QR Code\",\n approximateTaxes: \"Tributos totais incidentes (Lei Federal 12.741/2012) R$\",\n};\n"],"mappings":";;;AAQO,IAAM,mBAAoC;AAAA,EAC/C,MAAM;AAAA,EACN,mBAAmB;AAAA,EACnB,OAAO;AAAA,EACP,aAAa;AAAA,EACb,WAAW;AAAA,EACX,YAAY;AAAA,EACZ,WAAW;AAAA,EACX,WAAW;AAAA,EACX,eAAe;AAAA,EACf,QAAQ;AAAA,EACR,gBAAgB;AAAA,IACd,MAAM;AAAA,IACN,MAAM;AAAA,IACN,MAAM;AAAA,IACN,MAAM;AAAA,IACN,MAAM;AAAA,IACN,MAAM;AAAA,IACN,MAAM;AAAA,IACN,MAAM;AAAA,IACN,MAAM;AAAA,IACN,MAAM;AAAA,IACN,MAAM;AAAA,IACN,MAAM;AAAA,IACN,MAAM;AAAA,IACN,MAAM;AAAA,IACN,MAAM;AAAA,IACN,MAAM;AAAA,IACN,MAAM;AAAA,EACR;AAAA,EACA,aAAa;AAAA,EACb,cAAc;AAAA,EACd,aAAa;AAAA,EACb,sBAAsB;AAAA,EACtB,cAAc;AAAA,EACd,UAAU;AAAA,EACV,sBAAsB;AAAA,EACtB,QAAQ;AAAA,EACR,QAAQ;AAAA,EACR,UAAU;AAAA,EACV,cAAc;AAAA,EACd,WAAW;AAAA,EACX,kBAAkB;AACpB;","names":[]}
|