Просмотр исходного кода

Archives: an archive printed more than once shows all its prints (#3609)

- Each plate of a multi-plate file and each reprint is a print of the
  same archive; its card showed the file's filament and cost next to
  the first print's energy, matching neither a plate nor Statistics
- With more than one print the card shows the totals of all of them:
  filament used, cost, energy and wear, as Statistics adds them up,
  with "Total of N prints" on hover
- The archive endpoints return total_cost, total_energy_kwh,
  total_energy_cost and total_wear_cost from the print log; null
  where no print has the figure, so no energy without a smart plug
- Archives printed once are unchanged
- Translations for all locales, tests
maziggy 2 дней назад
Родитель
Сommit
1c22460c26
73 измененных файлов с 370 добавлено и 7 удалено
  1. 1 0
      CHANGELOG.md
  2. 31 2
      backend/app/api/routes/archives.py
  3. 7 0
      backend/app/schemas/archive.py
  4. 80 0
      backend/tests/unit/test_archive_run_aggregation.py
  5. 136 0
      frontend/src/__tests__/pages/ArchivesRunTotals.test.tsx
  6. 7 0
      frontend/src/api/client.ts
  7. 2 0
      frontend/src/i18n/locales/de.ts
  8. 2 0
      frontend/src/i18n/locales/en.ts
  9. 2 0
      frontend/src/i18n/locales/es.ts
  10. 2 0
      frontend/src/i18n/locales/fr.ts
  11. 2 0
      frontend/src/i18n/locales/it.ts
  12. 2 0
      frontend/src/i18n/locales/ja.ts
  13. 3 1
      frontend/src/i18n/locales/ko.ts
  14. 2 0
      frontend/src/i18n/locales/nl.ts
  15. 2 0
      frontend/src/i18n/locales/pl.ts
  16. 2 0
      frontend/src/i18n/locales/pt-BR.ts
  17. 2 0
      frontend/src/i18n/locales/ru.ts
  18. 2 0
      frontend/src/i18n/locales/sv.ts
  19. 2 0
      frontend/src/i18n/locales/tr.ts
  20. 2 0
      frontend/src/i18n/locales/uk.ts
  21. 2 0
      frontend/src/i18n/locales/zh-CN.ts
  22. 2 0
      frontend/src/i18n/locales/zh-TW.ts
  23. 72 1
      frontend/src/pages/ArchivesPage.tsx
  24. 0 0
      static/assets/ArchivesPage-CmGmi94a.js
  25. 0 0
      static/assets/ArchivesPage-cQZd_lQi.js
  26. 0 0
      static/assets/CamWallPage-V2l-y9s5.js
  27. 0 0
      static/assets/CameraPage-BtdXmkHE.js
  28. 0 0
      static/assets/FileManagerPage-YZPFVVNd.js
  29. 0 0
      static/assets/InventoryPage-BN2QBs_5.js
  30. 0 0
      static/assets/Layout-DpexWd3Y.js
  31. 0 0
      static/assets/MaintenancePage-CCr2maLT.js
  32. 0 0
      static/assets/ModelSourcesPage-DVLMwxSl.js
  33. 0 0
      static/assets/PrintersPage-aic3Quc9.js
  34. 0 0
      static/assets/SettingsPage-H0x52GXp.js
  35. 0 0
      static/assets/SliceModal-DUFpS1OB.js
  36. 0 0
      static/assets/SpoolBuddyInventoryPage-hG1eqjVy.js
  37. 1 1
      static/assets/SpoolBuddySettingsPage-BrL1uzxn.js
  38. 0 0
      static/assets/SpoolBuddyWriteTagPage-BQ5Lap-B.js
  39. 0 0
      static/assets/de-CJJoH4SB.js
  40. 0 0
      static/assets/de-mw2-q9CG.js
  41. 0 0
      static/assets/es-DUmM10Pp.js
  42. 0 0
      static/assets/es-DVMtQnhG.js
  43. 0 0
      static/assets/fr-COO6m3qg.js
  44. 0 0
      static/assets/fr-Dr3HSO7m.js
  45. 0 0
      static/assets/index-BI9UraM9.js
  46. 0 0
      static/assets/it-CN-pbFOP.js
  47. 0 0
      static/assets/it-DrJIgEGP.js
  48. 0 0
      static/assets/ja-BeXQW_6_.js
  49. 0 0
      static/assets/ja-CHc9O7rw.js
  50. 0 0
      static/assets/ko-Cm4S6rOx.js
  51. 0 0
      static/assets/ko-Ctqe556j.js
  52. 0 0
      static/assets/locationSensorDefaults-BGtynA0D.js
  53. 0 0
      static/assets/nl-BpmRfh-Y.js
  54. 0 0
      static/assets/nl-VcmDjoaR.js
  55. 0 0
      static/assets/pl-B6Mzzpix.js
  56. 0 0
      static/assets/pl-B_K3xGev.js
  57. 0 0
      static/assets/pt-BR-D3qoKGct.js
  58. 0 0
      static/assets/pt-BR-DG7jFp8j.js
  59. 0 0
      static/assets/ru-BIdPLK6M.js
  60. 0 0
      static/assets/ru-DEwOuLNF.js
  61. 0 0
      static/assets/spoolCost-BMO6ot42.js
  62. 0 0
      static/assets/sv-BOiq16eh.js
  63. 0 0
      static/assets/sv-CPR-Upqh.js
  64. 0 0
      static/assets/tr-BOR-VT8X.js
  65. 0 0
      static/assets/tr-CLIjc4-H.js
  66. 0 0
      static/assets/uk-CtMheslB.js
  67. 0 0
      static/assets/uk-DrQE3ABK.js
  68. 0 0
      static/assets/usePageFileDrop-GEe1LDVR.js
  69. 0 0
      static/assets/zh-CN-C6nqaMxo.js
  70. 0 0
      static/assets/zh-CN-CtApxkcW.js
  71. 0 0
      static/assets/zh-TW-C-YD8WN9.js
  72. 0 0
      static/assets/zh-TW-CzHThMfO.js
  73. 2 2
      static/index.html

+ 1 - 0
CHANGELOG.md

@@ -15,6 +15,7 @@ All notable changes to Bambuddy will be documented in this file.
 - **Choose which printer an "Any model" job takes (#2915, requested by @bryanmahin, contributed by @Keybored02 in #3547)** — Several printers of a model can take an "Any model" job, and the one with the fewest print hours always got it. **Settings > Workflow > Printer Order for Any-Model Jobs** now chooses: the fewest print hours (the default, as before), the most (use up the machines near replacement first), the printer idle the longest (by its last finished print; one that never printed goes first), or the printers' own priority, a number in **Edit Printer** (lowest first, none last). The order only ranks printers that can take the job: a busy, offline or filament-short printer is still passed over, and preferred colours still come first. Powering a printer on with an Auto Power On plug follows the same order.
 
 ### Fixed
+- **An archive printed more than once shows what all its prints cost (#3609, reported by @RafalHo)** — Each plate of a multi-plate file printed one at a time is a print of the same archive, and so is a reprint. The archive card showed the file's filament and cost (all plates together) next to the first print's energy, so a seven-plate print showed the electricity of plate 1 only and matched neither one plate nor Statistics. An archive with more than one print now shows the totals of all of them: the filament they used, its cost, the energy and the wear, as Statistics adds them up, with "Total of N prints" on hover. An energy total is left out when no print was measured by a smart plug. Each print's own figures stay in the Print Log behind the prints badge; archives printed once are unchanged.
 - **A spool's slicer preset can be removed, and opening the field no longer loses its name (#3596, reported by @dertbv)** — the Slicer Preset field in the spool form had no way to remove a preset, so a configured spool could not go back to Stock, in an edit or a copy. Clicking into the field also emptied it, and saving then kept the preset but stored no name for it when the preset was not in the current list, for example a Bambu Cloud preset while the cloud list was unavailable. The spool then showed the raw preset code. The field now has a remove button, closing the list without picking shows the preset again, and text typed to search is never saved as the preset's name. The same applies to the SpoolBuddy write-tag page.
 - **The Slice dialog lists presets when a Bambu Cloud account has none of one type (#3593, reported by @KevinMidboe)** — Bambu Cloud answers "nothing here" for a preset type with an empty value instead of an empty list, for example on an account with no filament presets of its own. Bambuddy did not handle that, so with a Bambu Cloud sign-in on the Profiles page the Slice dialog showed "Failed to load presets" and offered no presets at all, local ones included, and the Profiles page's cloud list failed the same way. Such a type now reads as empty, and the presets the account does have are listed.
 - **Monitor-only MQTT plugs are no longer switched by automation (#3583, reported by @paulleonartcalvo)** — Bambuddy only listens to an MQTT plug, so it cannot turn one on or off, but its Auto On and Auto Off were on by default, hidden in the plug's settings, and every automation tried anyway. With an MQTT plug for metering and a switchable plug on the same printer, the queue could pick the MQTT plug to power the printer on, fail, and hold the job with "the smart plug could not power it on". A printer whose only plug was an MQTT plug counted as one the queue could switch on, so its job said "Offline" instead of that it has no Auto On plug. Auto-off at print end, "auto off after this job", auto-off after drying, plug schedules and the AI failure detection's power-off all logged a failed turn-off for it. All of them now leave MQTT plugs alone, and an auto-off still pending on one from an earlier version is cleared at startup. Home Assistant scripts linked to a printer still run at print start as before.

+ 31 - 2
backend/app/api/routes/archives.py

@@ -386,13 +386,18 @@ def compute_time_accuracy(archive: PrintArchive, run_aggregate: dict | None = No
     return result
 
 
+def _rounded(value, digits: int) -> float | None:
+    return None if value is None else round(float(value), digits)
+
+
 async def _load_run_aggregates(
     db: AsyncSession, archive_ids: list[int], printer_scope: PrinterScope | None = None, printer_id: int | None = None
 ) -> dict[int, dict]:
     """Batch-load per-archive run aggregates from PrintLogEntry.
 
     Returns ``{archive_id: {run_count, last_run_at, total_filament_actual_grams,
-    successful_run_count, failed_run_count, unmeasured_run_count, latest_run_id}}``. Archives with no logged runs are
+    successful_run_count, failed_run_count, unmeasured_run_count, total_cost,
+    total_energy_kwh, total_energy_cost, total_wear_cost, latest_run_id}}``. Archives with no logged runs are
     absent from the map; callers should treat that as zero/none.
 
     With ``printer_scope``, only the runs on its printers count: a caller
@@ -413,6 +418,11 @@ async def _load_run_aggregates(
             func.sum(case((PrintLogEntry.status == "completed", 1), else_=0)).label("successful"),
             func.sum(case((PrintLogEntry.status.in_(("failed", "aborted")), 1), else_=0)).label("failed"),
             func.sum(case((PrintLogEntry.duration_unmeasured.is_(True), 1), else_=0)).label("estimated"),
+            # NULL when no run has the figure (no plug, no price): unknown, not 0.
+            func.sum(PrintLogEntry.cost).label("total_cost"),
+            func.sum(PrintLogEntry.energy_kwh).label("total_energy_kwh"),
+            func.sum(PrintLogEntry.energy_cost).label("total_energy_cost"),
+            func.sum(PrintLogEntry.wear_cost).label("total_wear_cost"),
         )
         .where(
             PrintLogEntry.archive_id.in_(archive_ids),
@@ -426,7 +436,19 @@ async def _load_run_aggregates(
         .group_by(PrintLogEntry.archive_id)
     )
     aggregates: dict[int, dict] = {}
-    for archive_id, run_count, last_run_at, total_filament, successful, failed, estimated in rows.all():
+    for (
+        archive_id,
+        run_count,
+        last_run_at,
+        total_filament,
+        successful,
+        failed,
+        estimated,
+        total_cost,
+        total_energy_kwh,
+        total_energy_cost,
+        total_wear_cost,
+    ) in rows.all():
         aggregates[archive_id] = {
             "run_count": int(run_count or 0),
             "last_run_at": last_run_at,
@@ -434,6 +456,11 @@ async def _load_run_aggregates(
             "successful_run_count": int(successful or 0),
             "failed_run_count": int(failed or 0),
             "unmeasured_run_count": int(estimated or 0),
+            # What all its prints cost, as Statistics adds it up (#3609).
+            "total_cost": _rounded(total_cost, 2),
+            "total_energy_kwh": _rounded(total_energy_kwh, 3),
+            "total_energy_cost": _rounded(total_energy_cost, 3),
+            "total_wear_cost": _rounded(total_wear_cost, 2),
         }
     # The latest print of each (by start), which the archive shows: a print
     # running now included, as the archive shows it while it runs.
@@ -637,6 +664,8 @@ def archive_to_response(
         data["successful_run_count"] = run_aggregate.get("successful_run_count", 0)
         data["failed_run_count"] = run_aggregate.get("failed_run_count", 0)
         data["latest_run_id"] = run_aggregate.get("latest_run_id")
+        for key in ("total_cost", "total_energy_kwh", "total_energy_cost", "total_wear_cost"):
+            data[key] = run_aggregate.get(key)
 
     return data
 

+ 7 - 0
backend/app/schemas/archive.py

@@ -180,6 +180,13 @@ class ArchiveResponse(BaseModel):
     total_filament_actual_grams: float | None = None
     successful_run_count: int = 0
     failed_run_count: int = 0
+    # What all its runs cost, summed as Statistics does (#3609). The archive's
+    # own cost / energy_cost stay the file's and the first run's (#1378,
+    # #2614). None where no run has the figure.
+    total_cost: float | None = None
+    total_energy_kwh: float | None = None
+    total_energy_cost: float | None = None
+    total_wear_cost: float | None = None
 
     @model_validator(mode="after")
     def compute_object_count(self) -> "ArchiveResponse":

+ 80 - 0
backend/tests/unit/test_archive_run_aggregation.py

@@ -605,3 +605,83 @@ async def test_a_run_without_an_estimate_shows_no_reconnect_gap(
     assert (row["actual_time_seconds"], row["time_accuracy"]) == (None, None)
     body = (await async_client.get("/api/v1/archives/stats")).json()
     assert body["average_time_accuracy"] is None
+
+
+def _plate_run(archive, day: int, *, grams: float, cost: float, energy_kwh=None, energy_cost=None) -> PrintLogEntry:
+    started = datetime(2026, 11, day, 10, 0, tzinfo=timezone.utc)
+    return PrintLogEntry(
+        archive_id=archive.id,
+        printer_id=archive.printer_id,
+        status="completed",
+        started_at=started,
+        completed_at=started,
+        duration_seconds=3600,
+        filament_used_grams=grams,
+        cost=cost,
+        energy_kwh=energy_kwh,
+        energy_cost=energy_cost,
+        created_at=started,
+    )
+
+
+@pytest.mark.asyncio
+@pytest.mark.integration
+async def test_an_archive_printed_plate_by_plate_carries_what_all_its_prints_cost(
+    async_client: AsyncClient, archive_factory, printer_factory, db_session
+):
+    """Each plate of a multi-plate file is a run of one archive (#3609).
+
+    The archive keeps the file's filament and the first print's energy; the
+    totals are what the card shows, and what Statistics adds up.
+    """
+    printer = await printer_factory()
+    archive = await archive_factory(
+        printer.id,
+        status="completed",
+        filament_used_grams=837.0,  # the whole file, all plates
+        cost=45.17,
+        energy_kwh=0.2,
+        energy_cost=0.24,  # the first plate's
+        with_run=False,
+    )
+    db_session.add_all(
+        [
+            _plate_run(archive, 1, grams=120.0, cost=6.8, energy_kwh=0.2, energy_cost=0.24),
+            _plate_run(archive, 2, grams=150.0, cost=8.5, energy_kwh=0.5, energy_cost=0.61),
+            _plate_run(archive, 3, grams=90.0, cost=5.1, energy_kwh=0.3, energy_cost=0.38),
+        ]
+    )
+    await db_session.commit()
+
+    body = (await async_client.get(f"/api/v1/archives/{archive.id}")).json()
+
+    assert body["run_count"] == 3
+    assert body["total_filament_actual_grams"] == pytest.approx(360.0)
+    assert body["total_cost"] == pytest.approx(20.4)
+    assert body["total_energy_kwh"] == pytest.approx(1.0)
+    assert body["total_energy_cost"] == pytest.approx(1.23)
+    # The archive's own figures are unchanged (#1378).
+    assert body["cost"] == pytest.approx(45.17)
+    assert body["energy_cost"] == pytest.approx(0.24)
+
+    stats = (await async_client.get("/api/v1/archives/stats")).json()
+    assert stats["total_cost"] == pytest.approx(body["total_cost"])
+
+
+@pytest.mark.asyncio
+@pytest.mark.integration
+async def test_no_energy_total_when_no_print_measured_any(
+    async_client: AsyncClient, archive_factory, printer_factory, db_session
+):
+    printer = await printer_factory()
+    archive = await archive_factory(printer.id, status="completed", with_run=False)
+    db_session.add_all([_plate_run(archive, 1, grams=10.0, cost=1.0), _plate_run(archive, 2, grams=10.0, cost=1.0)])
+    await db_session.commit()
+
+    body = (await async_client.get("/api/v1/archives/")).json()
+    row = next(a for a in body if a["id"] == archive.id)
+
+    assert row["total_cost"] == pytest.approx(2.0)
+    # Unknown, not zero: no smart plug measured either print.
+    assert row["total_energy_kwh"] is None
+    assert row["total_energy_cost"] is None

+ 136 - 0
frontend/src/__tests__/pages/ArchivesRunTotals.test.tsx

@@ -0,0 +1,136 @@
+/**
+ * An archive printed more than once (a reprint, or each plate of a multi-plate
+ * file) shows what all its prints used and cost, as Statistics adds them up
+ * (#3609). The archive's own figures are the whole file's filament and the
+ * first print's energy, which side by side matched nothing.
+ */
+
+import { describe, it, expect, beforeEach } from 'vitest';
+import { screen, waitFor, within } from '@testing-library/react';
+import { render } from '../utils';
+import { ArchivesPage } from '../../pages/ArchivesPage';
+import { http, HttpResponse } from 'msw';
+import { server } from '../mocks/server';
+import { setAuthToken } from '../../api/client';
+
+const base = {
+  printer_id: 1,
+  printer_name: 'X2D',
+  print_time_seconds: 36000,
+  thumbnail_path: null,
+  notes: null,
+  rating: null,
+  project_id: null,
+  project_name: null,
+  project_color: null,
+  print_count: 1,
+  tags: '',
+  has_f3d: false,
+  status: 'completed',
+  started_at: '2026-11-10T10:00:00Z',
+  completed_at: '2026-11-10T20:00:00Z',
+  created_at: '2026-11-10T10:00:00Z',
+  updated_at: '2026-11-10T10:00:00Z',
+  successful_run_count: 0,
+  failed_run_count: 0,
+};
+
+const archives = [
+  {
+    ...base,
+    id: 1,
+    filename: 'snowman.gcode.3mf',
+    print_name: 'Snowman',
+    // The whole file and the first plate's energy.
+    filament_used_grams: 837,
+    cost: 45.17,
+    energy_kwh: 0.2,
+    energy_cost: 0.24,
+    run_count: 7,
+    successful_run_count: 7,
+    total_filament_actual_grams: 832,
+    total_cost: 47.51,
+    total_energy_kwh: 3.095,
+    total_energy_cost: 3.93,
+  },
+  {
+    ...base,
+    id: 2,
+    filename: 'single.gcode.3mf',
+    print_name: 'Single',
+    filament_used_grams: 12,
+    cost: 0.5,
+    energy_kwh: 0.05,
+    energy_cost: 0.06,
+    run_count: 1,
+    successful_run_count: 1,
+    total_filament_actual_grams: 12,
+    total_cost: 0.5,
+    total_energy_kwh: 0.05,
+    total_energy_cost: 0.06,
+  },
+  {
+    ...base,
+    id: 3,
+    filename: 'unplugged.gcode.3mf',
+    print_name: 'Unplugged',
+    filament_used_grams: 30,
+    cost: 1.2,
+    energy_kwh: 0.1,
+    energy_cost: 0.12,
+    run_count: 2,
+    successful_run_count: 2,
+    total_filament_actual_grams: 60,
+    total_cost: 2.4,
+    total_energy_kwh: null,
+    total_energy_cost: null,
+  },
+];
+
+function cardOf(name: string): HTMLElement {
+  return screen.getByText(name).closest('[data-archive-id]') as HTMLElement;
+}
+
+describe('ArchivesPage run totals (#3609)', () => {
+  beforeEach(() => {
+    setAuthToken(null);
+    server.use(
+      http.get('/api/v1/archives/', () => HttpResponse.json(archives)),
+      http.get('/api/v1/archives/stats', () =>
+        HttpResponse.json({ total_archives: 3, total_print_time_seconds: 0, total_filament_grams: 0 })
+      ),
+      http.get('/api/v1/printers/', () => HttpResponse.json([{ id: 1, name: 'X2D' }])),
+      http.get('/api/v1/projects/', () => HttpResponse.json([])),
+      http.get('/api/v1/archives/tags', () => HttpResponse.json([]))
+    );
+  });
+
+  it('shows the totals of all prints on an archive printed plate by plate', async () => {
+    render(<ArchivesPage />);
+    await waitFor(() => expect(screen.getAllByTestId('archive-cost')).toHaveLength(3));
+
+    const card = within(cardOf('Snowman'));
+    expect(card.getByTestId('archive-grams').textContent).toBe('832.0g');
+    expect(card.getByTestId('archive-cost').textContent).toMatch(/47\.51$/);
+    expect(card.getByTestId('archive-cost')).toHaveAttribute('title', 'Total of 7 prints');
+    expect(card.getByTestId('archive-energy-cost').textContent).toMatch(/3\.93$/);
+  });
+
+  it('keeps the archive figures for a single print', async () => {
+    render(<ArchivesPage />);
+    await waitFor(() => expect(screen.getAllByTestId('archive-cost')).toHaveLength(3));
+
+    const card = within(cardOf('Single'));
+    expect(card.getByTestId('archive-cost').textContent).toMatch(/0\.50$/);
+    expect(card.getByTestId('archive-cost')).not.toHaveAttribute('title');
+  });
+
+  it("shows no energy rather than one print's when no print was measured", async () => {
+    render(<ArchivesPage />);
+    await waitFor(() => expect(screen.getAllByTestId('archive-cost')).toHaveLength(3));
+
+    const card = within(cardOf('Unplugged'));
+    expect(card.getByTestId('archive-cost').textContent).toMatch(/2\.40$/);
+    expect(card.queryByTestId('archive-energy-cost')).toBeNull();
+  });
+});

+ 7 - 0
frontend/src/api/client.ts

@@ -984,6 +984,13 @@ export interface Archive {
   total_filament_actual_grams: number | null;
   successful_run_count: number;
   failed_run_count: number;
+  // What all its runs cost, summed as Statistics does (#3609); null where no
+  // run has the figure. The archive's own cost and energy stay the file's and
+  // the first run's.
+  total_cost?: number | null;
+  total_energy_kwh?: number | null;
+  total_energy_cost?: number | null;
+  total_wear_cost?: number | null;
 }
 
 export interface ArchiveSlim {

+ 2 - 0
frontend/src/i18n/locales/de.ts

@@ -1201,6 +1201,8 @@ export default {
       project: 'Projekt: {{name}}',
       runsBadge: '{{count}} Drucke',
       runsBadgeTitle: 'Insgesamt {{count}} Drucke — {{successful}} erfolgreich, {{failed}} fehlgeschlagen. Klicken, um das vollständige Druckprotokoll zu öffnen.',
+      // The card's figures for an archive printed more than once (#3609).
+      totalOfRuns: 'Summe aus {{count}} Drucken',
       estimated: 'Geschätzt: {{time}}',
       actual: 'Tatsächlich: {{time}}',
       accuracy: 'Genauigkeit: {{percent}}%',

+ 2 - 0
frontend/src/i18n/locales/en.ts

@@ -1208,6 +1208,8 @@ export default {
       project: 'Project: {{name}}',
       runsBadge: '{{count}} prints',
       runsBadgeTitle: '{{count}} prints total — {{successful}} successful, {{failed}} failed. Click to see the full print log.',
+      // The card's figures for an archive printed more than once (#3609).
+      totalOfRuns: 'Total of {{count}} prints',
       estimated: 'Estimated: {{time}}',
       actual: 'Actual: {{time}}',
       accuracy: 'Accuracy: {{percent}}%',

+ 2 - 0
frontend/src/i18n/locales/es.ts

@@ -1201,6 +1201,8 @@ export default {
       project: 'Proyecto: {{name}}',
       runsBadge: '{{count}} impresiones',
       runsBadgeTitle: '{{count}} impresiones en total — {{successful}} con éxito, {{failed}} fallidas. Haga clic para ver el registro completo de impresión.',
+      // The card's figures for an archive printed more than once (#3609).
+      totalOfRuns: 'Total de {{count}} impresiones',
       estimated: 'Estimado: {{time}}',
       actual: 'Real: {{time}}',
       accuracy: 'Precisión: {{percent}}%',

+ 2 - 0
frontend/src/i18n/locales/fr.ts

@@ -1201,6 +1201,8 @@ export default {
       project: 'Projet : {{name}}',
       runsBadge: '{{count}} impressions',
       runsBadgeTitle: '{{count}} impressions au total — {{successful}} réussies, {{failed}} échouées. Cliquez pour voir le journal complet.',
+      // The card's figures for an archive printed more than once (#3609).
+      totalOfRuns: 'Total de {{count}} impressions',
       estimated: 'Estimé : {{time}}',
       actual: 'Réel : {{time}}',
       accuracy: 'Précision : {{percent}}%',

+ 2 - 0
frontend/src/i18n/locales/it.ts

@@ -1201,6 +1201,8 @@ export default {
       project: 'Progetto: {{name}}',
       runsBadge: '{{count}} stampe',
       runsBadgeTitle: '{{count}} stampe in totale — {{successful}} riuscite, {{failed}} fallite. Fai clic per vedere il registro completo.',
+      // The card's figures for an archive printed more than once (#3609).
+      totalOfRuns: 'Totale di {{count}} stampe',
       estimated: 'Stimato: {{time}}',
       actual: 'Reale: {{time}}',
       accuracy: 'Accuratezza: {{percent}}%',

+ 2 - 0
frontend/src/i18n/locales/ja.ts

@@ -1200,6 +1200,8 @@ export default {
       project: 'プロジェクト: {{name}}',
       runsBadge: '{{count}} 回印刷',
       runsBadgeTitle: '合計 {{count}} 回 — 成功 {{successful}} 回、失敗 {{failed}} 回。クリックして印刷ログを開きます。',
+      // The card's figures for an archive printed more than once (#3609).
+      totalOfRuns: '{{count}} 回の印刷の合計',
       estimated: '推定: {{time}}',
       actual: '実際: {{time}}',
       accuracy: '精度: {{percent}}%',

+ 3 - 1
frontend/src/i18n/locales/ko.ts

@@ -1186,7 +1186,9 @@ export default {
       edit: '편집',
       delete: '삭제',
       runsBadge: '{{count}}회 인쇄',
-      runsBadgeTitle: '총 {{count}}회 인쇄 — {{successful}}회 성공, {{failed}}회 실패. 전체 인쇄 기록을 보려면 클릭하세요.'
+      runsBadgeTitle: '총 {{count}}회 인쇄 — {{successful}}회 성공, {{failed}}회 실패. 전체 인쇄 기록을 보려면 클릭하세요.',
+      // The card's figures for an archive printed more than once (#3609).
+      totalOfRuns: '{{count}}회 인쇄 합계',
     },
     modal: {
       deleteArchive: '아카이브 삭제',

+ 2 - 0
frontend/src/i18n/locales/nl.ts

@@ -1206,6 +1206,8 @@ export default {
       project: 'Project: {{name}}',
       runsBadge: '{{count}} afdrukken',
       runsBadgeTitle: '{{count}} afdrukken totaal — {{successful}} geslaagd, {{failed}} mislukt. Klik om het volledige afdruklogboek te bekijken.',
+      // The card's figures for an archive printed more than once (#3609).
+      totalOfRuns: 'Totaal van {{count}} prints',
       estimated: 'Geschat: {{time}}',
       actual: 'Werkelijk: {{time}}',
       accuracy: 'Nauwkeurigheid: {{percent}}%',

+ 2 - 0
frontend/src/i18n/locales/pl.ts

@@ -1208,6 +1208,8 @@ export default {
       project: 'Projekt: {{name}}',
       runsBadge: 'Wydruki: {{count}}',
       runsBadgeTitle: 'Wydruki łącznie: {{count}} — udane: {{successful}}, nieudane: {{failed}}. Kliknij, aby zobaczyć pełny dziennik wydruków.',
+      // The card's figures for an archive printed more than once (#3609).
+      totalOfRuns: 'Suma wydruków: {{count}}',
       estimated: 'Szacowany: {{time}}',
       actual: 'Rzeczywisty: {{time}}',
       accuracy: 'Dokładność: {{percent}}%',

+ 2 - 0
frontend/src/i18n/locales/pt-BR.ts

@@ -1201,6 +1201,8 @@ export default {
       project: 'Projeto: {{name}}',
       runsBadge: '{{count}} impressões',
       runsBadgeTitle: '{{count}} impressões no total — {{successful}} bem-sucedidas, {{failed}} com falha. Clique para ver o histórico completo.',
+      // The card's figures for an archive printed more than once (#3609).
+      totalOfRuns: 'Total de {{count}} impressões',
       estimated: 'Estimado: {{time}}',
       actual: 'Real: {{time}}',
       accuracy: 'Precisão: {{percent}}%',

+ 2 - 0
frontend/src/i18n/locales/ru.ts

@@ -1156,6 +1156,8 @@ export default {
       project: "Проект: {{name}}",
       runsBadge: "Печатей: {{count}}",
       runsBadgeTitle: "Всего печатей: {{count}}, успешных: {{successful}}, неудачных: {{failed}}. Нажмите, чтобы открыть полный журнал.",
+      // The card's figures for an archive printed more than once (#3609).
+      totalOfRuns: "Всего за печати: {{count}}",
       estimated: "Расчётное время: {{time}}",
       actual: "Фактическое время: {{time}}",
       accuracy: "Точность оценки: {{percent}}%",

+ 2 - 0
frontend/src/i18n/locales/sv.ts

@@ -1206,6 +1206,8 @@ export default {
       project: 'Projekt: {{name}}',
       runsBadge: '{{count}} utskrifter',
       runsBadgeTitle: '{{count}} utskrifter totalt — {{successful}} lyckade, {{failed}} misslyckade. Klicka för att se hela utskriftsloggen.',
+      // The card's figures for an archive printed more than once (#3609).
+      totalOfRuns: 'Totalt för {{count}} utskrifter',
       estimated: 'Uppskattad: {{time}}',
       actual: 'Faktisk: {{time}}',
       accuracy: 'Noggrannhet: {{percent}}%',

+ 2 - 0
frontend/src/i18n/locales/tr.ts

@@ -1201,6 +1201,8 @@ export default {
       project: 'Proje: {{name}}',
       runsBadge: '{{count}} baskı',
       runsBadgeTitle: 'Toplam {{count}} baskı — {{successful}} başarılı, {{failed}} başarısız. Tam baskı günlüğünü görmek için tıklayın.',
+      // The card's figures for an archive printed more than once (#3609).
+      totalOfRuns: '{{count}} baskının toplamı',
       estimated: 'Tahmini: {{time}}',
       actual: 'Gerçek: {{time}}',
       accuracy: 'Doğruluk: %{{percent}}',

+ 2 - 0
frontend/src/i18n/locales/uk.ts

@@ -1205,6 +1205,8 @@ export default {
       project: "Проєкт: {{name}}",
       runsBadge: "Друків: {{count}}",
       runsBadgeTitle: "Усього друків: {{count}} — успішних: {{successful}}, невдалих: {{failed}}. Натисніть, щоб переглянути повний журнал друку.",
+      // The card's figures for an archive printed more than once (#3609).
+      totalOfRuns: "Разом за друки: {{count}}",
       estimated: "Приблизно: {{time}}",
       actual: "Фактично: {{time}}",
       accuracy: "Точність: {{percent}}%",

+ 2 - 0
frontend/src/i18n/locales/zh-CN.ts

@@ -1201,6 +1201,8 @@ export default {
       project: '项目:{{name}}',
       runsBadge: '{{count}} 次打印',
       runsBadgeTitle: '共 {{count}} 次打印 — 成功 {{successful}} 次,失败 {{failed}} 次。点击查看完整打印记录。',
+      // The card's figures for an archive printed more than once (#3609).
+      totalOfRuns: '{{count}} 次打印的合计',
       estimated: '预计:{{time}}',
       actual: '实际:{{time}}',
       accuracy: '准确度:{{percent}}%',

+ 2 - 0
frontend/src/i18n/locales/zh-TW.ts

@@ -1201,6 +1201,8 @@ export default {
       project: '專案:{{name}}',
       runsBadge: '{{count}} 次列印',
       runsBadgeTitle: '共 {{count}} 次列印 — 成功 {{successful}} 次,失敗 {{failed}} 次。點擊查看完整列印記錄。',
+      // The card's figures for an archive printed more than once (#3609).
+      totalOfRuns: '{{count}} 次列印的合計',
       estimated: '預計:{{time}}',
       actual: '實際:{{time}}',
       accuracy: '準確度:{{percent}}%',

+ 72 - 1
frontend/src/pages/ArchivesPage.tsx

@@ -316,6 +316,18 @@ function ArchiveCard({
     if (!saved || !Array.isArray(saved.mapping) || saved.printer_id == null) return undefined;
     return printerMap.get(saved.printer_id);
   }, [archive.extra_data, printerMap]);
+  // With more than one print, the card shows what all of them used and cost
+  // (#3609); the Print Log behind the runs badge has each one.
+  const totals =
+    archive.run_count > 1
+      ? {
+          grams: archive.total_filament_actual_grams ?? null,
+          cost: archive.total_cost ?? null,
+          energyKwh: archive.total_energy_kwh ?? null,
+          energyCost: archive.total_energy_cost ?? null,
+          wearCost: archive.total_wear_cost ?? null,
+        }
+      : null;
   const [showReprint, setShowReprint] = useState(false);
   // Post-print outcome confirmation dialog (#1898)
   const [showConfirmOutcome, setShowConfirmOutcome] = useState(false);
@@ -1303,6 +1315,59 @@ function ArchiveCard({
               )}
             </div>
           )}
+          {/* More than one print (a reprint, or each plate of a multi-plate
+              file): the totals of all of them, as Statistics adds them up.
+              The archive's own figures are the file's filament and the first
+              print's energy, which side by side matched nothing (#3609). */}
+          {totals ? (
+            <>
+              {totals.grams != null && (
+                <div
+                  className="flex items-center gap-1.5 text-bambu-gray"
+                  title={t('archives.card.totalOfRuns', { count: archive.run_count })}
+                  data-testid="archive-grams"
+                >
+                  <Package className="w-3 h-3" />
+                  {totals.grams.toFixed(1)}g
+                </div>
+              )}
+              {(totals.cost != null || totals.energyCost != null || totals.wearCost != null) && (
+                <div className="flex items-center gap-3 text-bambu-gray">
+                  {totals.cost != null && (
+                    <div
+                      className="flex items-center gap-1.5"
+                      title={t('archives.card.totalOfRuns', { count: archive.run_count })}
+                      data-testid="archive-cost"
+                    >
+                      <Coins className="w-3 h-3" />
+                      {archive.status === 'printing' && '~'}
+                      {currency}{totals.cost.toFixed(2)}
+                    </div>
+                  )}
+                  {totals.energyCost != null && (
+                    <div
+                      className="flex items-center gap-1.5"
+                      title={`${t('archives.card.totalOfRuns', { count: archive.run_count })}\n${t('stats.energyUsed')}: ${totals.energyKwh?.toFixed(3) || 'N/A'} kWh`}
+                      data-testid="archive-energy-cost"
+                    >
+                      <Zap className="w-3 h-3" />
+                      {currency}{totals.energyCost.toFixed(2)}
+                    </div>
+                  )}
+                  {totals.wearCost != null && (
+                    <div
+                      className="flex items-center gap-1.5"
+                      title={`${t('archives.card.totalOfRuns', { count: archive.run_count })}\n${t('archives.card.wearCost')}`}
+                    >
+                      <Wrench className="w-3 h-3" />
+                      {currency}{totals.wearCost.toFixed(2)}
+                    </div>
+                  )}
+                </div>
+              )}
+            </>
+          ) : (
+            <>
           {archive.filament_used_grams && (
             <div
               className="flex items-center gap-1.5 text-bambu-gray"
@@ -1336,7 +1401,11 @@ function ArchiveCard({
                 </div>
               )}
                 {archive.energy_cost != null && (
-                  <div className="flex items-center gap-1.5" title={`${t('stats.energyUsed')}: ${archive.energy_kwh?.toFixed(3) || 'N/A'} kWh`}>
+                  <div
+                    className="flex items-center gap-1.5"
+                    title={`${t('stats.energyUsed')}: ${archive.energy_kwh?.toFixed(3) || 'N/A'} kWh`}
+                    data-testid="archive-energy-cost"
+                  >
                     <Zap className="w-3 h-3" />
                     {currency}{archive.energy_cost.toFixed(2)}
                   </div>
@@ -1348,6 +1417,8 @@ function ArchiveCard({
                   </div>
                 )}
             </div>
+          )}
+            </>
           )}
           {(archive.layer_height || archive.total_layers) && (
             <div className="flex items-center gap-1.5 text-bambu-gray">

Разница между файлами не показана из-за своего большого размера
+ 0 - 0
static/assets/ArchivesPage-CmGmi94a.js


Разница между файлами не показана из-за своего большого размера
+ 0 - 0
static/assets/ArchivesPage-cQZd_lQi.js


Разница между файлами не показана из-за своего большого размера
+ 0 - 0
static/assets/CamWallPage-V2l-y9s5.js


Разница между файлами не показана из-за своего большого размера
+ 0 - 0
static/assets/CameraPage-BtdXmkHE.js


Разница между файлами не показана из-за своего большого размера
+ 0 - 0
static/assets/FileManagerPage-YZPFVVNd.js


Разница между файлами не показана из-за своего большого размера
+ 0 - 0
static/assets/InventoryPage-BN2QBs_5.js


Разница между файлами не показана из-за своего большого размера
+ 0 - 0
static/assets/Layout-DpexWd3Y.js


Разница между файлами не показана из-за своего большого размера
+ 0 - 0
static/assets/MaintenancePage-CCr2maLT.js


Разница между файлами не показана из-за своего большого размера
+ 0 - 0
static/assets/ModelSourcesPage-DVLMwxSl.js


Разница между файлами не показана из-за своего большого размера
+ 0 - 0
static/assets/PrintersPage-aic3Quc9.js


Разница между файлами не показана из-за своего большого размера
+ 0 - 0
static/assets/SettingsPage-H0x52GXp.js


Разница между файлами не показана из-за своего большого размера
+ 0 - 0
static/assets/SliceModal-DUFpS1OB.js


Разница между файлами не показана из-за своего большого размера
+ 0 - 0
static/assets/SpoolBuddyInventoryPage-hG1eqjVy.js


Разница между файлами не показана из-за своего большого размера
+ 1 - 1
static/assets/SpoolBuddySettingsPage-BrL1uzxn.js


Разница между файлами не показана из-за своего большого размера
+ 0 - 0
static/assets/SpoolBuddyWriteTagPage-BQ5Lap-B.js


Разница между файлами не показана из-за своего большого размера
+ 0 - 0
static/assets/de-CJJoH4SB.js


Разница между файлами не показана из-за своего большого размера
+ 0 - 0
static/assets/de-mw2-q9CG.js


Разница между файлами не показана из-за своего большого размера
+ 0 - 0
static/assets/es-DUmM10Pp.js


Разница между файлами не показана из-за своего большого размера
+ 0 - 0
static/assets/es-DVMtQnhG.js


Разница между файлами не показана из-за своего большого размера
+ 0 - 0
static/assets/fr-COO6m3qg.js


Разница между файлами не показана из-за своего большого размера
+ 0 - 0
static/assets/fr-Dr3HSO7m.js


Разница между файлами не показана из-за своего большого размера
+ 0 - 0
static/assets/index-BI9UraM9.js


Разница между файлами не показана из-за своего большого размера
+ 0 - 0
static/assets/it-CN-pbFOP.js


Разница между файлами не показана из-за своего большого размера
+ 0 - 0
static/assets/it-DrJIgEGP.js


Разница между файлами не показана из-за своего большого размера
+ 0 - 0
static/assets/ja-BeXQW_6_.js


Разница между файлами не показана из-за своего большого размера
+ 0 - 0
static/assets/ja-CHc9O7rw.js


Разница между файлами не показана из-за своего большого размера
+ 0 - 0
static/assets/ko-Cm4S6rOx.js


Разница между файлами не показана из-за своего большого размера
+ 0 - 0
static/assets/ko-Ctqe556j.js


Разница между файлами не показана из-за своего большого размера
+ 0 - 0
static/assets/locationSensorDefaults-BGtynA0D.js


Разница между файлами не показана из-за своего большого размера
+ 0 - 0
static/assets/nl-BpmRfh-Y.js


Разница между файлами не показана из-за своего большого размера
+ 0 - 0
static/assets/nl-VcmDjoaR.js


Разница между файлами не показана из-за своего большого размера
+ 0 - 0
static/assets/pl-B6Mzzpix.js


Разница между файлами не показана из-за своего большого размера
+ 0 - 0
static/assets/pl-B_K3xGev.js


Разница между файлами не показана из-за своего большого размера
+ 0 - 0
static/assets/pt-BR-D3qoKGct.js


Разница между файлами не показана из-за своего большого размера
+ 0 - 0
static/assets/pt-BR-DG7jFp8j.js


Разница между файлами не показана из-за своего большого размера
+ 0 - 0
static/assets/ru-BIdPLK6M.js


Разница между файлами не показана из-за своего большого размера
+ 0 - 0
static/assets/ru-DEwOuLNF.js


Разница между файлами не показана из-за своего большого размера
+ 0 - 0
static/assets/spoolCost-BMO6ot42.js


Разница между файлами не показана из-за своего большого размера
+ 0 - 0
static/assets/sv-BOiq16eh.js


Разница между файлами не показана из-за своего большого размера
+ 0 - 0
static/assets/sv-CPR-Upqh.js


Разница между файлами не показана из-за своего большого размера
+ 0 - 0
static/assets/tr-BOR-VT8X.js


Разница между файлами не показана из-за своего большого размера
+ 0 - 0
static/assets/tr-CLIjc4-H.js


Разница между файлами не показана из-за своего большого размера
+ 0 - 0
static/assets/uk-CtMheslB.js


Разница между файлами не показана из-за своего большого размера
+ 0 - 0
static/assets/uk-DrQE3ABK.js


Разница между файлами не показана из-за своего большого размера
+ 0 - 0
static/assets/usePageFileDrop-GEe1LDVR.js


Разница между файлами не показана из-за своего большого размера
+ 0 - 0
static/assets/zh-CN-C6nqaMxo.js


Разница между файлами не показана из-за своего большого размера
+ 0 - 0
static/assets/zh-CN-CtApxkcW.js


Разница между файлами не показана из-за своего большого размера
+ 0 - 0
static/assets/zh-TW-C-YD8WN9.js


Разница между файлами не показана из-за своего большого размера
+ 0 - 0
static/assets/zh-TW-CzHThMfO.js


+ 2 - 2
static/index.html

@@ -26,7 +26,7 @@
 
     <!-- Splash screens for iOS -->
     <link rel="apple-touch-startup-image" href="/img/android-chrome-512x512.png" />
-    <script type="module" crossorigin src="/assets/index-ditXfNey.js"></script>
+    <script type="module" crossorigin src="/assets/index-BI9UraM9.js"></script>
     <link rel="modulepreload" crossorigin href="/assets/rolldown-runtime-aKtaBQYM.js">
     <link rel="modulepreload" crossorigin href="/assets/client-CI_mRuxq.js">
     <link rel="modulepreload" crossorigin href="/assets/react-dom--SxW8qhX.js">
@@ -122,7 +122,7 @@
     <link rel="modulepreload" crossorigin href="/assets/useColorCatalogVersion-p84g0m2K.js">
     <link rel="modulepreload" crossorigin href="/assets/circle-minus-CPviT500.js">
     <link rel="modulepreload" crossorigin href="/assets/ConnectionDiagnostic-BYvKBjRf.js">
-    <link rel="modulepreload" crossorigin href="/assets/Layout-Do5qTpzI.js">
+    <link rel="modulepreload" crossorigin href="/assets/Layout-DpexWd3Y.js">
     <link rel="stylesheet" crossorigin href="/assets/index-sEMHIQ3j.css">
   </head>
   <body>

Некоторые файлы не были показаны из-за большого количества измененных файлов