iobroker.e-invoices 0.9.2 → 0.9.4

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
@@ -186,6 +186,22 @@ The wording of every screen comes from one table per document type
186
186
  offer screen says "Rechnung". The booking list and the three accounting exports
187
187
  stay pinned to `docType=invoice`, so the two document types never mix.
188
188
 
189
+ ### Date range for lists and exports
190
+
191
+ The invoice list has a **period** filter: quick choices (this month, last month, this quarter, last
192
+ quarter, this year, last year) or two free days *Von* / *Bis*. It filters by the **invoice date**, and
193
+ **both days belong to the range** — 1 August to 31 August contains the invoices of both days. One side
194
+ may stay empty (open end).
195
+
196
+ - Excel, CSV and DATEV take exactly the filter of the list, so what you see is what is exported. The
197
+ file name names the range: `rechnungen_2026-08-01_2026-08-31.csv` (`…_ab-…` or `…_bis-…` for an open
198
+ end), and the Excel title shows it as well.
199
+ - Exports contain **all** matching invoices (no page limit) in date order and **never a draft** — a draft
200
+ has no number to book. A draft only comes into an export when the status "draft" is asked for.
201
+ - API: `from` and `to` (ISO date, `2026-08-01`) on `GET /api/invoices` and on the three export routes;
202
+ a malformed date or a range that ends before it starts answers `400`. They combine with `status`,
203
+ `companyId`, `q` and `docType`.
204
+
189
205
  ### Several companies
190
206
 
191
207
  Every document is bound to the company profile it was written for (the "Aus Firma
@@ -450,6 +466,14 @@ validation and hybrid embedding, `pdfkit`, `exceljs`, `jszip`,
450
466
  Placeholder for the next version (at the beginning of the line):
451
467
  ### **WORK IN PROGRESS**
452
468
  -->
469
+ ### 0.9.4 (2026-10-04)
470
+
471
+ * (alex) Invoice list: the period (quick choice, *Von*, *Bis*) sits in the same filter row as the other filters, with the labels above the two days.
472
+
473
+ ### 0.9.3 (2026-10-04)
474
+
475
+ * (alex) Date range for the invoice list and the exports: quick choices (this/last month, quarter, year) or free *Von* / *Bis* days on the invoice date, both days included. Excel, CSV and DATEV use the same filter as the list and name the range in the file name (`rechnungen_2026-08-01_2026-08-31.csv`). `from` / `to` on the list and export routes. Fixed on the way: an export was cut at 500 invoices — it now contains everything that matches, in date order, and never a draft (a draft has no number to book).
476
+
453
477
  ### 0.9.2 (2026-10-04)
454
478
 
455
479
  * (alex) Backup: the automatic backup is now **on by default** (daily) and keeps the newest 7 automatic backups (new setting *Automatic backups to keep*); only automatic backups are ever deleted, never those made by hand or the safety copies before a restore. The schedule counts from the last automatic backup, so a restart neither skips nor repeats one. The backup page and the new state `info.backupWarning` warn when there is no backup or it is old. Reason: an ioBroker backup (BackItUp) does not contain the invoice database `invoices.db` — it reaches the backup only through the adapter ZIP in `e-invoices.0.storage/backups/`. README compares BackItUp and the adapter backup. Instances installed earlier keep their saved interval (0 = off), set it in the instance settings.
@@ -65,7 +65,7 @@ function docTypeFilter(query, fallback) {
65
65
  }
66
66
  return raw ? (0, import_invoice_model.normalizeDocumentType)(raw) : fallback;
67
67
  }
68
- function filteredInvoices(db, query, fallbackDocType) {
68
+ function filteredInvoices(db, query, fallbackDocType, range = {}, forExport = false) {
69
69
  const status = typeof query.status === "string" ? query.status : void 0;
70
70
  const year = typeof query.year === "string" ? Number(query.year) : void 0;
71
71
  const text = typeof query.q === "string" ? query.q : void 0;
@@ -77,7 +77,14 @@ function filteredInvoices(db, query, fallbackDocType) {
77
77
  docType,
78
78
  companyId,
79
79
  query: text,
80
- limit: 500
80
+ from: range.from,
81
+ to: range.to,
82
+ ...forExport ? {
83
+ all: true,
84
+ sort: "date",
85
+ order: "asc",
86
+ excludeStatus: status === "draft" ? void 0 : "draft"
87
+ } : { limit: 500 }
81
88
  });
82
89
  }
83
90
  function openItemsOptions(query) {
@@ -410,7 +417,25 @@ function createApiServer(deps) {
410
417
  const docType = docTypeFilter(req.query);
411
418
  const sourceDocumentId = typeof req.query.sourceDocumentId === "string" ? req.query.sourceDocumentId : void 0;
412
419
  const companyId = typeof req.query.companyId === "string" && req.query.companyId ? req.query.companyId : void 0;
413
- res.json(db.listInvoices({ status, year, docType, sourceDocumentId, companyId, query, limit, offset }));
420
+ const range = (0, import_invoice_model.parseDateRange)(req.query.from, req.query.to);
421
+ if (typeof range === "string") {
422
+ res.status(400).json({ error: range });
423
+ return;
424
+ }
425
+ res.json(
426
+ db.listInvoices({
427
+ status,
428
+ year,
429
+ docType,
430
+ sourceDocumentId,
431
+ companyId,
432
+ query,
433
+ limit,
434
+ offset,
435
+ from: range.from,
436
+ to: range.to
437
+ })
438
+ );
414
439
  })
415
440
  );
416
441
  app.post(
@@ -437,26 +462,45 @@ function createApiServer(deps) {
437
462
  })
438
463
  );
439
464
  app.get("/api/invoices/export.csv", (req, res) => {
465
+ const range = (0, import_invoice_model.parseDateRange)(req.query.from, req.query.to);
466
+ if (typeof range === "string") {
467
+ res.status(400).json({ error: range });
468
+ return;
469
+ }
440
470
  res.type("text/csv; charset=utf-8");
441
- res.set("Content-Disposition", (0, import_attachments.attachmentDisposition)("rechnungen.csv"));
442
- res.send((0, import_csv.renderInvoiceListCsv)(filteredInvoices(db, req.query, "invoice")));
471
+ res.set("Content-Disposition", (0, import_attachments.attachmentDisposition)(`rechnungen${(0, import_invoice_model.dateRangeFileSuffix)(range)}.csv`));
472
+ res.send((0, import_csv.renderInvoiceListCsv)(filteredInvoices(db, req.query, "invoice", range, true)));
443
473
  });
444
474
  app.get("/api/invoices/export.datev", (req, res) => {
445
475
  var _a2, _b2, _c2;
476
+ const range = (0, import_invoice_model.parseDateRange)(req.query.from, req.query.to);
477
+ if (typeof range === "string") {
478
+ res.status(400).json({ error: range });
479
+ return;
480
+ }
446
481
  const company = (_a2 = db.getDefaultCompanyProfile()) == null ? void 0 : _a2.profile;
447
482
  const head = (0, import_csv.renderDatevHead)((_b2 = company == null ? void 0 : company.name) != null ? _b2 : "Firma", (_c2 = company == null ? void 0 : company.taxNumber) != null ? _c2 : "");
448
483
  res.type("text/plain; charset=iso-8859-1");
449
- res.set("Content-Disposition", (0, import_attachments.attachmentDisposition)("rechnungen.datev"));
484
+ res.set("Content-Disposition", (0, import_attachments.attachmentDisposition)(`rechnungen${(0, import_invoice_model.dateRangeFileSuffix)(range)}.datev`));
450
485
  res.send(`${head}
451
- ${(0, import_csv.renderDatevRows)(filteredInvoices(db, req.query, "invoice"))}`);
486
+ ${(0, import_csv.renderDatevRows)(filteredInvoices(db, req.query, "invoice", range, true))}`);
452
487
  });
453
488
  app.get("/api/invoices/export.xlsx", (req, res) => {
454
- const invoices = filteredInvoices(db, req.query, "invoice");
489
+ const range = (0, import_invoice_model.parseDateRange)(req.query.from, req.query.to);
490
+ if (typeof range === "string") {
491
+ res.status(400).json({ error: range });
492
+ return;
493
+ }
494
+ const invoices = filteredInvoices(db, req.query, "invoice", range, true);
455
495
  const stamp = (/* @__PURE__ */ new Date()).toISOString().slice(0, 10);
456
- void (0, import_excel.renderInvoiceListWorkbook)(invoices, `Rechnungs\xFCbersicht ${stamp}`).then(
496
+ const period = (0, import_invoice_model.formatDateRange)(range);
497
+ void (0, import_excel.renderInvoiceListWorkbook)(invoices, `Rechnungs\xFCbersicht ${stamp}${period ? ` (${period})` : ""}`).then(
457
498
  (buffer) => {
458
499
  res.type("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet");
459
- res.set("Content-Disposition", (0, import_attachments.attachmentDisposition)(`export-${stamp}.xlsx`));
500
+ res.set(
501
+ "Content-Disposition",
502
+ (0, import_attachments.attachmentDisposition)(`export-${stamp}${(0, import_invoice_model.dateRangeFileSuffix)(range)}.xlsx`)
503
+ );
460
504
  res.send(buffer);
461
505
  },
462
506
  (error) => {