Admin business: optional fields such as withholdingTaxCompanyId can't be cleared

Aperta
#5,254 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 2 giorni

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
4/5
Tempo stimato
3-5 giorni
Idoneità per principianti
52/100
Tipo di issue
Bug
Chiarezza
Abbastanza chiara
Stato di attività
Attiva
Stack tecnologico
postgresql, typescript
Ambito
backend, database

Direzione di ricerca

Start with packages/server/src/modules/financial-entities/providers/admin-businesses.provider.ts and compare its update query with the tax-representation handling added in #5230. Read packages/server/src/modules/financial-entities/helpers/admin-businesses.helper.ts and the existing update integration test; first decide whether cleared array fields should be NULL or empty arrays. Done means each nullable field supports keep, clear and set, required fields retain their constraint with an explanatory comment, and the integration test covers those cases.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

Several optional admin-business fields can be set but never cleared. The update query in packages/server/src/modules/financial-entities/providers/admin-businesses.provider.ts writes them as COALESCE($param, column). A null therefore means "keep", and there is no value that empties the column. Affected:

  • company_tax_id (withholdingTaxCompanyId)
  • business_registration_start_date
  • advance_tax_rates
  • tax_advances_ids
  • social_security_employer_ids
  • withholding_tax_annual_ids

Once one of these holds a value, a user who empties it in the admin business settings gets the old value back.

The three tax-representation fields added in #5230 already work differently:

  • tax_assessing_office, tax_representative_name, tax_representative_license
  • An omitted field keeps its value; '' or null clears it.
  • Implementation: a CASE WHEN $x::TEXT IS NULL THEN column ELSE NULLIF($x, '') END in the SQL, plus toClearableText in packages/server/src/modules/financial-entities/helpers/admin-businesses.helper.ts.
  • Covered by providers/__tests__/admin-businesses-update.integration.test.ts.

Done when

  • Each nullable field above can be cleared from the UI, and an omitted field still keeps its value.
  • The array fields need a decision: is "cleared" NULL or an empty array?
  • Fields that must never be empty (for example company_tax_id, if required) stay as they are, with a comment saying why.
  • The integration test covers keep, clear and set for the changed fields.
Lingua principale
TypeScript
Stelle
30
Fork
10
Merge medio
2g 12h
PR unite (30g)
276

Preparare l'ambiente

Questo progetto non fornisce container di sviluppo, Dockerfile né guida per i contributori, quindi l'ambiente è a tuo carico: parti dal suo README e consulta la nostra guida al primo contributo per i passaggi generali.

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di Urigo/accounter-fullstack

Tutte le issue di Urigo/accounter-fullstack

Issue simili

Altre issue su TypeScript

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.