@timbro/invoices 0.10.0 → 0.10.1

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 CHANGED
@@ -80,7 +80,7 @@ Persist the request and its `invoiceReference` before submitting it. An equivale
80
80
 
81
81
  For ERP attribution, the optional `source: {id, version}` identifies the immutable accounting snapshot. When omitted, the reference supplies the source identity and the version is `initial`. Odoo keeps ownership of its posted accounting facts, prepared requests, and durable retry work.
82
82
 
83
- Amounts are exact decimal strings. `unitPrice` is interpreted using the item's `tax.included` flag. `incomeType` is explicit when supplied; otherwise the issuer's configured default must exist. A create request may supply `expectedTotals` to assert accounting agreement. A mismatch refuses admission without consuming a fiscal number.
83
+ Amounts are exact decimal strings. `unitPrice` is interpreted using the item's `tax.included` flag. Timbro groups items by tax kind and `tax.included`, and rounds each group's taxable base and ITBIS once from the exact quantity × unit price amounts; a legal tip is 10% of each tipped item's value without ITBIS. `incomeType` is explicit when supplied; otherwise the issuer's configured default must exist. A create request may supply `expectedTotals` to assert accounting agreement. A mismatch refuses admission without consuming a fiscal number.
84
84
 
85
85
  The request is discriminated by `type`. E31 and E32 have sales fields, E41 has supplier and withholding fields, and E45 has buyer and government eligibility fields. They use the same methods and Invoice identity.
86
86
 
@@ -155,7 +155,7 @@ Administration and installation tooling use `@timbro/invoices/admin`. Source sna
155
155
 
156
156
  ## Compatibility
157
157
 
158
- `@timbro/invoices` and `@timbro/protocol` are released at one version, and packages that share a minor version, including `@timbro/payments`, form a compatible set. Install without a version or tag: `npm install @timbro/invoices`.
158
+ Packages that share a minor version, including `@timbro/invoices`, `@timbro/protocol`, and `@timbro/payments`, form a compatible set; a patch release of one package does not require the others to move. Install without a version or tag: `npm install @timbro/invoices`.
159
159
 
160
160
  The SDK validates requests strictly, so a misspelled or unsupported property is rejected before anything is sent. It accepts unknown properties in responses, at every depth and in every union variant, and drops them from the value it returns. A server that adds a field therefore does not break an installed SDK, and the returned value contains only fields the typings describe. Unknown webhook event types follow the same rule: after the signature verifies, `webhooks.verify` returns an event whose `type` is a plain string and whose `data` is `unknown`. Narrow it with `isRecognizedWebhookEvent` before reading `data`, and acknowledge the delivery. Known event types still require their documented fields.
161
161
 
@@ -2,7 +2,7 @@ import { zEvaluatedSourceDocumentResponse, zRejectedSourceDocumentResponse, } fr
2
2
  export const DOCUMENT_WORKER_PROTOCOL = "timbro.fiscal-document-worker.v1";
3
3
  export const DOCUMENT_EVALUATION_PROTOCOL = "timbro.fiscal-document-evaluation.v1";
4
4
  const FISCAL_DOCUMENT_ENGINE_NAME = "timbro-fiscal-engine";
5
- const FISCAL_DOCUMENT_RULES_VERSION = "timbro.fiscal-document-rules.v2";
5
+ const FISCAL_DOCUMENT_RULES_VERSION = "timbro.fiscal-document-rules.v3";
6
6
  const SHA256_PATTERN = /^[0-9a-f]{64}$/u;
7
7
  const MONEY_PATTERN = /^(?:0|[1-9][0-9]*)\.[0-9]{2}$/u;
8
8
  const DOCUMENT_PATH_PATTERN = /^\/document(?:\/[A-Za-z0-9_-]+)*$/u;
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "protocol": "timbro.fiscal-document-evaluation.v1",
3
- "source_digest": "2e80733d58f5fc82720a62e6c8c62a1abc3afe4658f2240180a862129b96ef6b",
4
- "provenance_sha256": "b5d67422362f254dc7b5df4afcf015287812aad1a5e57bdc1055cea9eb347d1c",
3
+ "source_digest": "155ec8a03d8334dda223f0d3b73b5e3297a459cd460c5b1a8bfc8e85ed78509d",
4
+ "provenance_sha256": "29a78b1d163486628bbbceb1299e1f741334f0030d976a7d761da4e5424de238",
5
5
  "source_inputs": [
6
6
  {
7
7
  "path": "Cargo.lock",
@@ -176,7 +176,7 @@
176
176
  {
177
177
  "path": "conformance/fiscal-document/v1/source-draft-mixed.expected.json",
178
178
  "bytes": 832,
179
- "sha256": "f2f4dac91a1ab86d1a65319d008259d73fd4afb719a3ee2f9cf58a7720da00c1"
179
+ "sha256": "18b3636c4c287690131dd62fccd281cd07caccb09e0bdffaaef97ec1bd2b0d55"
180
180
  },
181
181
  {
182
182
  "path": "conformance/fiscal-document/v1/source-draft-mixed.request.json",
@@ -200,8 +200,8 @@
200
200
  },
201
201
  {
202
202
  "path": "conformance/fiscal-document/v1/valid-type31-contingency-replacement.expected.json",
203
- "bytes": 5130,
204
- "sha256": "339046d0bfd35a00ec60630398e4d00de8c99a0c518edfd497a937805973d3fe"
203
+ "bytes": 5191,
204
+ "sha256": "d54f62f53482d22f506f061f1757b3ce40808792ca6e35a055e7f7855122466b"
205
205
  },
206
206
  {
207
207
  "path": "conformance/fiscal-document/v1/valid-type31-contingency-replacement.request.json",
@@ -210,8 +210,8 @@
210
210
  },
211
211
  {
212
212
  "path": "conformance/fiscal-document/v1/valid-type31-inclusive-legal-tip.expected.json",
213
- "bytes": 4738,
214
- "sha256": "09a8ca91f5fdbce32931204e4a0a9e1511476c931bf157ffc976f8bac5787d32"
213
+ "bytes": 4798,
214
+ "sha256": "41b0fc556d086b05894f484c2856da39d12ef09bb61becb243a6737acde40daf"
215
215
  },
216
216
  {
217
217
  "path": "conformance/fiscal-document/v1/valid-type31-inclusive-legal-tip.request.json",
@@ -220,8 +220,8 @@
220
220
  },
221
221
  {
222
222
  "path": "conformance/fiscal-document/v1/valid-type31-minimal-buyer.expected.json",
223
- "bytes": 4200,
224
- "sha256": "0e7ead256234be8058464806bc9253ffcbeedd7d18416baa3b676b98618379e9"
223
+ "bytes": 4261,
224
+ "sha256": "f62b49c980302737d9e9a85788c07ca96cd45f05ebb8611da8330ff01cca22c3"
225
225
  },
226
226
  {
227
227
  "path": "conformance/fiscal-document/v1/valid-type31-minimal-buyer.request.json",
@@ -230,8 +230,8 @@
230
230
  },
231
231
  {
232
232
  "path": "conformance/fiscal-document/v1/valid-type31-minimal-issuer.expected.json",
233
- "bytes": 4509,
234
- "sha256": "c41c1d38cf57656fbfb3176d2a97f4d57a795c77797a14fa6e007f9ca0e8a1ce"
233
+ "bytes": 4570,
234
+ "sha256": "da283430dd69e7362a28740bebf47b1aa4b045a742be92b1152b5f75a28968f3"
235
235
  },
236
236
  {
237
237
  "path": "conformance/fiscal-document/v1/valid-type31-minimal-issuer.request.json",
@@ -240,8 +240,8 @@
240
240
  },
241
241
  {
242
242
  "path": "conformance/fiscal-document/v1/valid-type31.expected.json",
243
- "bytes": 4868,
244
- "sha256": "0aadef6fea382cab9083402a5b962e4e37e956912d63e6949e9953839d910c02"
243
+ "bytes": 4929,
244
+ "sha256": "3e6f3b44f79f0d27b12cbfa4ff0b5174cf0b8876f0726de8f1fb11504cf8b557"
245
245
  },
246
246
  {
247
247
  "path": "conformance/fiscal-document/v1/valid-type31.request.json",
@@ -250,8 +250,8 @@
250
250
  },
251
251
  {
252
252
  "path": "conformance/fiscal-document/v1/valid-type32-card-summary.expected.json",
253
- "bytes": 4168,
254
- "sha256": "180fd43f5c2d241ea371903ea581bd092593feeff8bc8e6747368fec4bd0ec43"
253
+ "bytes": 4230,
254
+ "sha256": "7d269467ce573d45c6d0dfaf2e36c13b14f36afb51ea1e70e72591e893d32a43"
255
255
  },
256
256
  {
257
257
  "path": "conformance/fiscal-document/v1/valid-type32-card-summary.request.json",
@@ -265,8 +265,8 @@
265
265
  },
266
266
  {
267
267
  "path": "conformance/fiscal-document/v1/valid-type32-full.expected.json",
268
- "bytes": 4380,
269
- "sha256": "feb79841ceb8598afe0e54dead08f5f0cb04be10d263446fe1d7e7d7fbe0a1b2"
268
+ "bytes": 4442,
269
+ "sha256": "d277c6d11a9479cbfc0835593a061af95b11e4ed720cd84331c0fd7549401636"
270
270
  },
271
271
  {
272
272
  "path": "conformance/fiscal-document/v1/valid-type32-full.request.json",
@@ -275,18 +275,28 @@
275
275
  },
276
276
  {
277
277
  "path": "conformance/fiscal-document/v1/valid-type32-inclusive-legal-tip.expected.json",
278
- "bytes": 4666,
279
- "sha256": "4335b00c55746797fb3d9bf492f0b093322bf6a7313d022bf9377c6fb6e71713"
278
+ "bytes": 4726,
279
+ "sha256": "c6a4783e313676819d10a746de6d96cda65305087d120ad1dec26986913af881"
280
280
  },
281
281
  {
282
282
  "path": "conformance/fiscal-document/v1/valid-type32-inclusive-legal-tip.request.json",
283
283
  "bytes": 1792,
284
284
  "sha256": "de9d82cc239827d0c69471bc63173a212147fe042e704e4cfec60482e6140159"
285
285
  },
286
+ {
287
+ "path": "conformance/fiscal-document/v1/valid-type32-itbis-groups.expected.json",
288
+ "bytes": 8515,
289
+ "sha256": "27769edf223eb78665077f0850db074fb887bb4cc3a935ebd5760816f14d5d71"
290
+ },
291
+ {
292
+ "path": "conformance/fiscal-document/v1/valid-type32-itbis-groups.request.json",
293
+ "bytes": 3375,
294
+ "sha256": "bb06311337b9cce102b741634b5b5d386b152b9217bebae508e1651af7289f78"
295
+ },
286
296
  {
287
297
  "path": "conformance/fiscal-document/v1/valid-type32-summary.expected.json",
288
- "bytes": 4163,
289
- "sha256": "1824c8f8c0bbbfdcbe87404925b02ff0c9c468550703e0d6fb64b64e5e2db28d"
298
+ "bytes": 4225,
299
+ "sha256": "eeb4ef1ebbca0afedefccf346b90b4950c6063957b72b1ea85257bb4033241d0"
290
300
  },
291
301
  {
292
302
  "path": "conformance/fiscal-document/v1/valid-type32-summary.request.json",
@@ -300,8 +310,8 @@
300
310
  },
301
311
  {
302
312
  "path": "conformance/fiscal-document/v1/valid-type33-external.expected.json",
303
- "bytes": 5181,
304
- "sha256": "b0c2f59bb7bc8567dd163bd0dc810ff4dd4d7ba2e53db3742f4e3ee7ffa1da9e"
313
+ "bytes": 5240,
314
+ "sha256": "fc6233faaf6a5b0ea76ba3e4d0673ae3d4d381253f43fa2dc8f6f3a712d57f40"
305
315
  },
306
316
  {
307
317
  "path": "conformance/fiscal-document/v1/valid-type33-external.request.json",
@@ -310,8 +320,8 @@
310
320
  },
311
321
  {
312
322
  "path": "conformance/fiscal-document/v1/valid-type33-inclusive-legal-tip.expected.json",
313
- "bytes": 5746,
314
- "sha256": "51672ad9b1af4d517eeaf165b935d722369aa0daa6a445d086d366ea5eb7ae95"
323
+ "bytes": 5806,
324
+ "sha256": "90c0c0c9a98cb9593a34977e4a92610451615ff7133f36b0d03f06ae58ff49e0"
315
325
  },
316
326
  {
317
327
  "path": "conformance/fiscal-document/v1/valid-type33-inclusive-legal-tip.request.json",
@@ -320,8 +330,8 @@
320
330
  },
321
331
  {
322
332
  "path": "conformance/fiscal-document/v1/valid-type34-external.expected.json",
323
- "bytes": 5005,
324
- "sha256": "bf44cf70eff7798840d1fbf22ee9ddacc6843a928126e3bfcdbd93f3a0166bf6"
333
+ "bytes": 5064,
334
+ "sha256": "c0ad0a9496a040c89874e0047dd3c888e430605af725e4f1d86e2e2e1bcee36c"
325
335
  },
326
336
  {
327
337
  "path": "conformance/fiscal-document/v1/valid-type34-external.request.json",
@@ -330,8 +340,8 @@
330
340
  },
331
341
  {
332
342
  "path": "conformance/fiscal-document/v1/valid-type34-inclusive-legal-tip.expected.json",
333
- "bytes": 5566,
334
- "sha256": "00ce07b80889ae5e972a3bed4b06646b5731e4144a69d3baaf21882385f944a6"
343
+ "bytes": 5626,
344
+ "sha256": "4e94f79d5be0e9855793228f76a96d1da1d37bea9ac7a681a6d27bcc63bb729a"
335
345
  },
336
346
  {
337
347
  "path": "conformance/fiscal-document/v1/valid-type34-inclusive-legal-tip.request.json",
@@ -340,8 +350,8 @@
340
350
  },
341
351
  {
342
352
  "path": "conformance/fiscal-document/v1/valid-type41-external.expected.json",
343
- "bytes": 4902,
344
- "sha256": "73d6ac42ffcd06f596769d501128c477499fd39fc123c536f476a9398ca6b01c"
353
+ "bytes": 4962,
354
+ "sha256": "386ca954214ac50c9c3373aad463546b955ab46a65041385fcfce4a2778606f3"
345
355
  },
346
356
  {
347
357
  "path": "conformance/fiscal-document/v1/valid-type41-external.request.json",
@@ -350,8 +360,8 @@
350
360
  },
351
361
  {
352
362
  "path": "conformance/fiscal-document/v1/valid-type41-minimal-issuer.expected.json",
353
- "bytes": 4606,
354
- "sha256": "8ec365f1021183590da545d85c335164a0d353ec64cb61e5968b22be1cd1cfa0"
363
+ "bytes": 4666,
364
+ "sha256": "7ae485178052f3932ec34e51ced98d8d12743dd85ed870fb60ca9c1f057f48f1"
355
365
  },
356
366
  {
357
367
  "path": "conformance/fiscal-document/v1/valid-type41-minimal-issuer.request.json",
@@ -360,8 +370,8 @@
360
370
  },
361
371
  {
362
372
  "path": "conformance/fiscal-document/v1/valid-type43-external.expected.json",
363
- "bytes": 4036,
364
- "sha256": "da8ca3e671dd69c13e3990eaa6702859ca2447439d9f71659deb0f9d8614cba9"
373
+ "bytes": 4114,
374
+ "sha256": "79928c88828010b0d997f7f09410da73f3186557bf988cc73eda42497769ff2d"
365
375
  },
366
376
  {
367
377
  "path": "conformance/fiscal-document/v1/valid-type43-external.request.json",
@@ -370,8 +380,8 @@
370
380
  },
371
381
  {
372
382
  "path": "conformance/fiscal-document/v1/valid-type44-external.expected.json",
373
- "bytes": 5756,
374
- "sha256": "4622020ae26fecf9b2f5f6b730a4ae181b0d87d07bb633afa508cb2f59ea664c"
383
+ "bytes": 5834,
384
+ "sha256": "d278de1c0bd7ce908b4a8a4d0aa157367a964191c911839b890e5a952416a3ca"
375
385
  },
376
386
  {
377
387
  "path": "conformance/fiscal-document/v1/valid-type44-external.request.json",
@@ -380,8 +390,8 @@
380
390
  },
381
391
  {
382
392
  "path": "conformance/fiscal-document/v1/valid-type45-external.expected.json",
383
- "bytes": 4806,
384
- "sha256": "018f5fd7194ed3ea0079d9d82267e42cd783bd2921791c0ac2c1d98b6932d40d"
393
+ "bytes": 4866,
394
+ "sha256": "545504e1df20eca7846b3ad26fb147dd01b812e8b590a99195038e08b87fcf6e"
385
395
  },
386
396
  {
387
397
  "path": "conformance/fiscal-document/v1/valid-type45-external.request.json",
@@ -390,8 +400,8 @@
390
400
  },
391
401
  {
392
402
  "path": "conformance/fiscal-document/v1/valid-type45-inclusive-legal-tip.expected.json",
393
- "bytes": 5350,
394
- "sha256": "c5bb497481550dcb0ea992d5e96e213786a28d49bdd2e03b19b6ecea04d77e8e"
403
+ "bytes": 5410,
404
+ "sha256": "65d75e6d70fbe88f1ee5981b1bfc0883d89cee3ef6570e7f819d59fe03cd1f90"
395
405
  },
396
406
  {
397
407
  "path": "conformance/fiscal-document/v1/valid-type45-inclusive-legal-tip.request.json",
@@ -400,8 +410,8 @@
400
410
  },
401
411
  {
402
412
  "path": "conformance/fiscal-document/v1/valid-type46-external.expected.json",
403
- "bytes": 4108,
404
- "sha256": "cb81d702f2a13a4e6fceb34bb9f0cf183c395127847a28e193ef0464796902b9"
413
+ "bytes": 4166,
414
+ "sha256": "a6f6648066f0f2cb3f34565a3f241ed70d36bca99aa7fd92c4a11f5ac50dbe8e"
405
415
  },
406
416
  {
407
417
  "path": "conformance/fiscal-document/v1/valid-type46-external.request.json",
@@ -410,8 +420,8 @@
410
420
  },
411
421
  {
412
422
  "path": "conformance/fiscal-document/v1/valid-type47-external.expected.json",
413
- "bytes": 4144,
414
- "sha256": "ce91691c54ee3c3bf4a651015d69a5564600c8dc973ed068594f8123971fa1d3"
423
+ "bytes": 4202,
424
+ "sha256": "21a41c8b6ec330b6ef2182463bd1800f18fa770ce00b4ef1b78803d2381347f7"
415
425
  },
416
426
  {
417
427
  "path": "conformance/fiscal-document/v1/valid-type47-external.request.json",
@@ -445,8 +455,8 @@
445
455
  },
446
456
  {
447
457
  "path": "crates/fiscal-document/src/commercial_document.rs",
448
- "bytes": 163672,
449
- "sha256": "5a40691a42a77ee023286e298be06bd6c4e39e4ace73fe8d2702c5dd70d4af76"
458
+ "bytes": 163739,
459
+ "sha256": "10a0ab851e2033731b2482519280422bbdb8ea08c21412744cbc53d952b624be"
450
460
  },
451
461
  {
452
462
  "path": "crates/fiscal-document/src/consumer_summary.rs",
@@ -460,18 +470,18 @@
460
470
  },
461
471
  {
462
472
  "path": "crates/fiscal-document/src/evaluation.rs",
463
- "bytes": 13600,
464
- "sha256": "be5ca5879d35e0921268464042837e5c99e6fc89db30e227a7d1bd185edfb965"
473
+ "bytes": 14017,
474
+ "sha256": "fc01e229b0181a18ea1b11f905ca293614382c33fc23e636bafbc1a42155c54d"
465
475
  },
466
476
  {
467
477
  "path": "crates/fiscal-document/src/lib.rs",
468
- "bytes": 5371,
469
- "sha256": "2a8cb1e435ff7454bba8eac1ff4185ef5f6f3dff571875f8bf63b1f178897bc1"
478
+ "bytes": 5387,
479
+ "sha256": "05546e81bb087255afba0e200b2a52eec477df0ae25d75dfee532eb5ca069bb5"
470
480
  },
471
481
  {
472
482
  "path": "crates/fiscal-document/src/printed_representation.rs",
473
- "bytes": 30844,
474
- "sha256": "9c5ca9a06c817b3644a1dc62d69cd023251279b43b79b6fc30d9e8c6f90b28a0"
483
+ "bytes": 31256,
484
+ "sha256": "59d4b7771f7c9407c13237cd41da5891a2dd3a216f055509e12da5ec57f932eb"
475
485
  },
476
486
  {
477
487
  "path": "crates/fiscal-document/src/protocol.rs",
@@ -485,8 +495,18 @@
485
495
  },
486
496
  {
487
497
  "path": "crates/fiscal-document/src/source_operation.rs",
488
- "bytes": 13794,
489
- "sha256": "9f7b3f4194f1e61304a0bea5cb28333f23069ea99782e62cffc0188cc56839ce"
498
+ "bytes": 13839,
499
+ "sha256": "71f61979bf39a23f0e4c74781edc28448ac0615fd1e94e3afd499b02dd107cd5"
500
+ },
501
+ {
502
+ "path": "crates/fiscal-document/src/tax_groups.rs",
503
+ "bytes": 16012,
504
+ "sha256": "6f03269aa098deedc224ff5e7b046443b0a4081ce1572c764c707d20a34f0d21"
505
+ },
506
+ {
507
+ "path": "crates/fiscal-document/src/tax_groups/tests.rs",
508
+ "bytes": 25297,
509
+ "sha256": "f4a4e0f79388e122e37049da5f7801051c280c93ace8fdcc4263e0d6a5f6ab9c"
490
510
  },
491
511
  {
492
512
  "path": "crates/fiscal-model/Cargo.toml",
@@ -520,8 +540,8 @@
520
540
  },
521
541
  {
522
542
  "path": "crates/fiscal-model/src/intent_contract.rs",
523
- "bytes": 47409,
524
- "sha256": "3564b3165f9f1bd7b732786843372aeef3aa0d8ff39dd5cb8af3d607a2d0f0a1"
543
+ "bytes": 47896,
544
+ "sha256": "9f81de28d510029d4a97e60a22c9ec634ccefe0f98a990586dc0f66a99bf9542"
525
545
  },
526
546
  {
527
547
  "path": "crates/fiscal-model/src/issuance.rs",
@@ -530,8 +550,8 @@
530
550
  },
531
551
  {
532
552
  "path": "crates/fiscal-model/src/lib.rs",
533
- "bytes": 48205,
534
- "sha256": "4b5ed908690233a994acbb1e44d5782635acea5feb41ee8c4f912765a170610d"
553
+ "bytes": 48680,
554
+ "sha256": "ebdd999400e36ea7bb37fae97cc973799c64893c24edade45684a11504e72a31"
535
555
  },
536
556
  {
537
557
  "path": "crates/fiscal-model/src/lifecycle.rs",
@@ -620,8 +640,8 @@
620
640
  },
621
641
  {
622
642
  "path": "scripts/verify-fiscal-engine-wasm.mjs",
623
- "bytes": 5634,
624
- "sha256": "97a0fba9bee81048c072a8b950bff81f173b6ece4abbd04aa41adaa632d21e7d"
643
+ "bytes": 5665,
644
+ "sha256": "6ee679e7e5b168ee59d896b8ebfd64e4342f5955cc70bda871aea1107b65973a"
625
645
  }
626
646
  ],
627
647
  "artifacts": {
@@ -630,8 +650,8 @@
630
650
  "sha256": "150a5d5edb25b66ffebc776303b1a0e9c906b003c08131b0e8249d24e01b6000"
631
651
  },
632
652
  "timbro_fiscal_engine_bg.wasm": {
633
- "bytes": 1255598,
634
- "sha256": "03b39fc666e799a273ebd3461bbe09d6fdc752eaca563703ae426ad6cfad9263"
653
+ "bytes": 1280398,
654
+ "sha256": "da952e444289d99b610f68624e8821ce01f07352b4bcd7ab657f30bbdddc6601"
635
655
  }
636
656
  }
637
657
  }