Depreciation report: merge the on-screen table and form 1342 print data into one backend model

Abierto
#5,317 0 comentarios 0 reacciones 0 asignados Ver en GitHub

Los mantenedores suelen responder en 2 días

Nadie ha tomado este issue todavía.

Evaluación

Dificultad
5/5
Tiempo estimado
Más de una semana
Aptitud para principiantes
38/100
Tipo de issue
Refactorización
Claridad
Bastante claro
Estado de actividad
Activo
Stack tecnológico
typescript

Línea de trabajo

Read the depreciation report resolver and depreciation-form-1342.helper.ts, then trace the screen query and rendering in index.tsx and form-1342.tsx. Compare the existing server and client tests listed in the acceptance criteria. Done means printing fetches form1342 on demand, the screen and print view share row iteration, the two report PDFs match the specified outputs, and the listed checks pass.

Escrito por el modelo de indexación a partir del texto del issue.

Descripción

Context

PR https://github.com/Urigo/accounter-fullstack/pull/5235 adds a print-only Hebrew replica of Tax Authority form 1342 for the depreciation report. It builds on https://github.com/Urigo/accounter-fullstack/pull/5233. The print view runs in parallel with the on-screen table, so the same report is rendered and fetched twice.

Current duplication

  • Server (already one source). DepreciationReportResult.form1342 is a field resolver (packages/server/src/modules/reports/resolvers/depreciation-report.resolver.ts). It calls buildForm1342(roundDepreciationReport(report), ...) on the same report that categories comes from, so nothing is recomputed. The model is built in packages/server/src/modules/reports/helpers/depreciation-form-1342.helper.ts. That helper owns the Hebrew texts (FORM_1342_TEXTS), columns, instructions, notes key, and the category, asset and total row building (buildRows, assetRow, totalRow).
  • Client fetches twice. packages/client/src/components/screens/reports/depreciation-report/index.tsx requests categories and form1342 in the same DepreciationReportScreen query on every load. form1342 is never shown on screen, so its payload and render are wasted on every page load.
  • Client renders twice. The screen rebuilds category headers, record rows, summary rows and the grand total (index.tsx, depreciation-record-row.tsx, depreciation-summary-row.tsx). packages/client/src/components/screens/reports/depreciation-report/form-1342.tsx (441 lines) re-lays-out the same rows for print. The screen hides its table only with print:hidden, so both trees stay mounted.
  • Labels in two places. Hebrew labels live in the client i18n.ts (from #5232) and in the server's FORM_1342_TEXTS.

Proposed work

  1. Backend owns the print model. Keep buildForm1342 as the single place that turns a report into printable rows. Keep the print labels only on the server, and remove client copies that exist only for print.
  2. Fetch the print model only when printing. Move form1342 out of DepreciationReportScreen. Fetch it with a separate urql query that stays paused until the print button is pressed.
  3. Shared UI rows. Extract the category, asset and summary row iteration into one module used by both the screen table and the print view. The print view then only maps model rows to cells. The screen keeps its own columns, and the print view keeps the form's 11 columns.
  4. Label ownership. Decide which side owns each label set so the same wording is not kept twice.

Open questions

  • Fetch the print model on click (recommended), or keep one combined query?
  • Should the screen table also be built from the server's rows, or only share the client row helpers?

Acceptance criteria

  • The report page loads without a form1342 request. Clicking print fetches it and prints the same form as #5235.
  • The PDF output matches the output from #5235 for the short and 40-asset reports.
  • Server tests (depreciation-form-1342.helper.test.ts, depreciation-report.resolver.test.ts) and client form-1342.test.tsx pass.
  • yarn generate and yarn lint pass.

Notes

Builds on #5233 and #5235. Merge after #5235.


Generated by Claude Code

Lenguaje dominante
TypeScript
Estrellas
30
Forks
10
Merge medio
2 d 12 h
PR fusionados (30 d)
276

Preparar el entorno

Este proyecto no incluye contenedor de desarrollo, Dockerfile ni guía de contribución, así que la configuración corre por tu cuenta: empieza por su README y consulta nuestra guía para la primera contribución para los pasos generales.

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de Urigo/accounter-fullstack

Todos los issues de Urigo/accounter-fullstack

Issues similares

Más issues de TypeScript

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.