RFC-016: §6 Employment Income (DPČ/DPP/HPP) with OCR - #1
Conversation
Plan adding full DPFO support for employment income (Potvrzení o zdanitelných příjmech, both vzor 33 advance and vzor 12 withholding), with AI OCR extraction. Maps verified XSD attributes (kc_prij6, kc_zd6, kc_zalzavc, kc_sraz_6_4, potv_zam etc.) to DPFO rows 31-36, 42, 76, 84, 87, fixing the income_tax_gen.go assumption that §6 base is 0.
- ř.89 (kc_vyplbonus) for monthly bonuses, not ř.76 - Drop ChildBenefit -= MonthlyBonusPaid (would double-count) - Rename foreign_income -> income_without_advance (ř.35 covers §38c/§38h, not just foreign) - Fix §16/§16a terminology: 23% progressive is §16 odst.1, §16a is Příloha 4 separate base - Lhůta § 38j odst. 3: 10 days from request, not 1. March - OCR extracts ř.5 + ř.13 for monthly bonus, not just ř.13 - ř.32 stays "Neobsazeno" per PDF pokyny 2025 (XSD docstring stale)
Review feedback addressed (v2 commit f8968a7)Accepted (fixed in RFC):
Push-back na K1 (ř.32) — ponecháno bez změny: Pokyny FS 2025 vzor 33 explicitně říkají "ř. 32 Neobsazeno" (PDF str. 2, citace z bodu K2 oddílu). Pokyny pro ř.31 zároveň instruují, že srážkové příjmy zahrnuté do DAP "jste povinen uvést veškeré tyto příjmy do ř. 31" — tedy jdou do ř.31, ne ř.32. Stale text v XSD docstringu na Pokud máte odlišné čtení pokynů 2025 vzor 33 (např. jiná verze než ta z financnisprava.gov.cz), pošlete prosím odkaz a citaci — rád to znovu ověřím. |
- N5: drop Section6CertsBonus++ in Recalculate; potv_dazvyh tracks separate "Potvrzení o vyplaceném daňovém bonusu" forms (kind=bonus), not advance certs with bonus. MVP keeps it 0. - N4: frontend detail panel ř.76 -> ř.89 (leftover from v1) - N2/N7: drop "ř.19" reference (does not exist in vzor 33; doplatek z RZ is in ř.13 per XSD doc on kc_vyplbonus) - N1: test description rewritten — ChildBenefit must stay unchanged when MonthlyBonusPaid > 0 (regression test for K3) - N6: "§16a limit warning" -> "§16 progressive rate warning" - Integration test expectation potv_dazvyh=0 in MVP
v3 review feedback addressed (commit 8e17f0e)
|
Q7/Q8: XSD attribute table called kc_zd6p "§16a", but Legislative notes and XML generator correctly said "§38f / Příloha 3". Unified: table now says "§38f / Příloha 3" (allocation of §6 portion for foreign tax credit), with explicit note it is unrelated to §16a (Příloha 4 — separate base) and §16 odst. 1 progressive rate.
|
v4 (commit efaa2a2): Q7/Q8 fix — |
Adds full support for §6 závislá činnost (DPČ/DPP/HPP) into the DPFO income tax return. Users upload a Potvrzení o zdanitelných příjmech, AI extracts the fields, and aggregates flow into rows 31, 33, 34/36, 84, 87, 89 plus EPO XML attributes (kc_prij6, kc_zd6, kc_zalzavc, kc_sraz_6_4, kc_vyplbonus, potv_zam, potv_36). Backend: - Migration 027 (employment_documents, employment_income_certificates, §6 aggregate columns on income_tax_returns) - Migration 028 (warnings TEXT column on income_tax_returns) - Domain: EmploymentDocument, EmploymentCertificate, ContractType, CertificateType plus §6 fields on IncomeTaxReturn and Warnings []string - Repos with soft delete + UNIQUE (year, ico, type, period) ON CONFLICT REPLACE - Service: upload + OCR extract + CRUD + confirm with audit emits, IČO mod-11 validation via domain.ValidateICO - §6 aggregation in IncomeTaxReturnService.Recalculate - TaxDue now reconciles ř.84 + ř.87 + ř.89 (paid bonus) per pokyny DPFO 2025 - WarningProgressiveRateReview emit when totalBase > 36× průměrná mzda - ProgressiveThreshold 2025 = 1 676 052 Kč (nař. vlády 282/2024 Sb.) - XML generator emits VetaO/D/B §6 attrs with omitempty (zero §6 → no diff) - HTTP handler at /api/v1/tax/employment with 10 endpoints, 10 MB cap, MIME allowlist (PDF/JPEG/PNG/WEBP) + magic-byte sniffing - OCR prompt for vzor 33 (advance) and vzor 12 (withholding) variants Frontend: - /tax/employment page with year selector, dual upload tiles, certificate table, recompute on confirm/delete - EmploymentCertificateEditor modal with type toggle, validation, OCR confidence badge - §6 card on /tax overview, §6 panel on income return detail - Warnings banner with HelpTip on income return detail - 15 help topics covering §6, both Potvrzení variants, all relevant rows, superhrubá mzda zrušení, §16 progresivní sazba, §16a vs §38f distinction - Typed employmentApi in client.ts Legislative correctness verified against pokyny DPFO 2025 vzor 33, EPO XSD dpfdp7_epo2.xsd, and ZDP §§ 6, 16, 16a, 35ba, 35d, 36, 38c, 38f, 38g, 38h, 38ch, 38j odst. 3. Tests: 11 doc repo + 11 cert repo + 11 OCR prompt + 22 service + 30+ handler + 4 XML gen + 4 progressive/warning + 4 TaxDue reconciliation + frontend 849/849 vitest.
Summary
kc_prij6,kc_zd6,kc_dan_zah,kc_zalzavc,kc_sraz_6_4,potv_zam/potv_36/potv_dazvyh) -- no schema inventioninternal/annualtaxxml/income_tax_gen.go:210(// ř.42 -- assumes §6 employment base = 0)docs/xml-schemas/epo/dpfdp7_epo2.xsdVerified corrections vs. initial draft
kc_zalzavc)Scope highlights
EmploymentCertificateServicewith upload + OCR + validation pipeline/tax/employmentwith dual upload tiles, modal editor with confidence display/tax, read-only §6 panel on income return detailTest plan
ON CONFLICT REPLACEchoice on the UNIQUE clausekc_zakldan23 = kc_zd6per XSD critical controlReferences
docs/xml-schemas/epo/dpfdp7_epo2.xsd