Files
paliad/internal/db/migrations/041_upc_counterclaim_cross_flows.down.sql
m cc68ab2873 feat(t-paliad-131): Phase B1 — UPC counterclaim cross-flows
Closes m's primary complaint: today's `with_ccr` flag on UPC_INF only
swaps the Replik / Duplik durations. Per UPC RoP R.29 the with-CCR flow
ALSO adds 5–7 new submissions across the claimant / defendant exchange.
Same gap on UPC_REV: Application to amend (R.49.2.a → R.55 = R.32 m.m.)
and Counterclaim for infringement (R.49.2.b → R.50, R.56 cycle) were
entirely missing.

UPC_INF gets a nested `with_amend` flag under `with_ccr` (R.30 amend
is only available with a CCR). UPC_REV gets two parallel independent
flags `with_amend` + `with_cci`; both can be on. Citations verified
against data.laws_contents (youpcdb, UPCRoP).

Migration 041 (waved INSERTs because each subsequent rule references
the prior wave's parent_id):
- Wave 0: 11 new concept rows (counterclaim-for-revocation,
  defence-to-counterclaim-for-revocation, defence-to-application-to-amend,
  reply-to-defence-to-counterclaim-for-revocation,
  reply-to-defence-to-application-to-amend,
  rejoinder-on-reply-to-defence-to-ccr, rejoinder-on-reply-to-amend,
  counterclaim-for-infringement, defence-to-counterclaim-for-infringement,
  reply-to-defence-to-counterclaim-for-infringement,
  rejoinder-on-counterclaim-for-infringement). counterclaim-for-revocation
  also seeded for the search bar even though its rule lives implicitly
  in inf.sod (the with_ccr flag captures it).
- UPC_INF + UPC_REV sequence_orders renumbered to leave gaps (10/20/30…)
  so new cross-flow rows interleave chronologically with the backbone.
- 7 new UPC_INF rules: inf.def_to_ccr (R.29.a), inf.app_to_amend (R.30.1),
  inf.def_to_amend (R.32.1), inf.reply_def_ccr (R.29.d),
  inf.reply_def_amd (R.32.3), inf.rejoin_reply_ccr (R.29.e),
  inf.rejoin_amd (R.32.3).
- 8 new UPC_REV rules: rev.app_to_amend (R.49.2.a), rev.def_to_amend
  (R.43.3), rev.reply_def_amd (R.32.3 m.m.), rev.rejoin_amd (R.32.3 m.m.),
  rev.cc_inf (R.49.2.b), rev.def_cci (R.56.1), rev.reply_def_cci (R.56.3),
  rev.rejoin_cci (R.56.4).

Calculator (services/fristenrechner.go):
- Zero-duration rules now split into 4 buckets, not 2:
    1. parent=nil + non-court → IsRootEvent (existing)
    2. parent=nil + court     → IsCourtSet (existing, e.g. inf.oral when stand-alone)
    3. parent set + court     → IsCourtSet (existing, waypoints)
    4. parent set + non-court → "filed-with-parent" — inherit parent's
       date. NEW. Used by rev.app_to_amend / rev.cc_inf which per
       R.49(2) are filed AS PART OF the Defence to revocation.
- AnchorOverrides on a zero-duration rule short-circuits to the user's
  date, propagating downstream as before.

Frontend:
- New checkboxes inf-amend-flag (UPC_INF, nested under ccr-flag),
  rev-amend-flag, rev-cci-flag (UPC_REV). Visibility per proceeding
  type; inf-amend disabled until ccr is on (R.30 dependency).
- Three new i18n keys (DE+EN). Small CSS for nested-checkbox indent
  and disabled-state colour.

Live-verified via curl on paliad.de against tester@hlc.de:
  UPC_INF + with_ccr+with_amend, trigger 2026-05-04 → all 7 new rules
  render at correct dates (R.29.a 2mo, R.30.1 2mo, R.32.1 2mo from
  app_to_amend, R.29.d 2mo from def_to_ccr, R.32.3 1mo, R.29.e 1mo,
  R.32.3 1mo).
  UPC_REV + with_amend+with_cci → rev.app_to_amend / rev.cc_inf show
  rev.defence's date (filed-with-parent), R.43.3 2mo / R.56.1 2mo /
  R.32.3 + R.56.3 1mo / R.32.3 + R.56.4 1mo all line up.
2026-05-05 01:25:03 +02:00

61 lines
2.4 KiB
SQL

-- Reverses 041_upc_counterclaim_cross_flows. Removes the new rules first,
-- then the new concepts, then restores the original sequence_order on the
-- existing UPC_INF / UPC_REV rows. Concept rows that are still referenced
-- elsewhere are kept (defensive — concepts may be reused by future
-- migrations).
DELETE FROM paliad.deadline_rules
WHERE proceeding_type_id IN (
SELECT id FROM paliad.proceeding_types WHERE code IN ('UPC_INF','UPC_REV')
)
AND code IN (
'inf.def_to_ccr','inf.app_to_amend','inf.def_to_amend','inf.reply_def_ccr',
'inf.reply_def_amd','inf.rejoin_reply_ccr','inf.rejoin_amd',
'rev.app_to_amend','rev.def_to_amend','rev.reply_def_amd','rev.rejoin_amd',
'rev.cc_inf','rev.def_cci','rev.reply_def_cci','rev.rejoin_cci'
);
DELETE FROM paliad.deadline_concepts
WHERE slug IN (
'counterclaim-for-revocation','defence-to-counterclaim-for-revocation',
'application-to-amend','defence-to-application-to-amend',
'reply-to-defence-to-counterclaim-for-revocation',
'reply-to-defence-to-application-to-amend',
'rejoinder-on-reply-to-defence-to-ccr','rejoinder-on-reply-to-amend',
'counterclaim-for-infringement','defence-to-counterclaim-for-infringement',
'reply-to-defence-to-counterclaim-for-infringement',
'rejoinder-on-counterclaim-for-infringement'
)
AND id NOT IN (SELECT concept_id FROM paliad.deadline_rules WHERE concept_id IS NOT NULL);
WITH proc AS (SELECT id FROM paliad.proceeding_types WHERE code = 'UPC_INF')
UPDATE paliad.deadline_rules dr
SET sequence_order = CASE dr.code
WHEN 'inf.soc' THEN 0
WHEN 'inf.sod' THEN 1
WHEN 'inf.reply' THEN 2
WHEN 'inf.rejoin' THEN 3
WHEN 'inf.interim' THEN 4
WHEN 'inf.oral' THEN 5
WHEN 'inf.decision' THEN 6
WHEN 'inf.cost_app' THEN 7
ELSE dr.sequence_order
END
FROM proc p
WHERE dr.proceeding_type_id = p.id;
WITH proc AS (SELECT id FROM paliad.proceeding_types WHERE code = 'UPC_REV')
UPDATE paliad.deadline_rules dr
SET sequence_order = CASE dr.code
WHEN 'rev.app' THEN 0
WHEN 'rev.defence' THEN 1
WHEN 'rev.reply' THEN 2
WHEN 'rev.rejoin' THEN 3
WHEN 'rev.interim' THEN 4
WHEN 'rev.oral' THEN 5
WHEN 'rev.decision' THEN 6
ELSE dr.sequence_order
END
FROM proc p
WHERE dr.proceeding_type_id = p.id;