05RevenueType: Reference architecture
Renewals with one active contract and an unbroken history
A Zoho CRM design where a renewal is one controlled action: it opens the next contract record, retires the old one and links the two both ways.
Shows
- Data Architecture
- Business Automation
- Software Architecture
Where this comes from: Drawn from systems I've designed on Zoho. The business, names and data here are generalized. The patterns and failure modes come from real work, and the design includes what that work taught me.
On This Page
In 30 Seconds
A business sells contracts for installed equipment or services, and each term of a contract lives in Zoho CRM as its own record: what is covered, for whom, for how long. Here a renewal is one action on the active record, run once the renewal order is approved, not a status change or a hand-made copy. It creates the next record, links old and new both ways, and switches which one is active. Each contract keeps one current record and a history anyone can walk back.
What It Guarantees
- One renewal run never leaves a contract with two active records, and a check catches two runs started at the same moment.
- A renewal starts only from the active record, and only when it is ready.
- A record already renewed, or linked to a newer one, is refused.
- Every renewed record points to its successor, and every successor points back.
- A renewal that stops halfway leaves a named half-state with a known fix.
The Problem
Picture a business that sells maintenance, support or coverage for installed equipment, one term at a time. Each contract is a record, and support reads it to check coverage.
A common setup renews by hand. The renewal order is approved, but nothing creates the next record. So someone copies the old record, or edits its end date, or forgets. An unlinked copy that leaves the old record active gives one contract two current records. An edited end date erases what the previous term covered. A forgotten renewal leaves an approved order pointing at a record that looks about to lapse.
None of this fails loudly. It surfaces later, as a coverage question nobody can answer, or a history that stops.
The Approach, in One Sentence
One action on the active record refuses unless it is ready, builds the next record as a draft linked both ways, and retires the old record before activating the new one; a check then confirms the chain.
Architecture
Connections in this diagram
- Active contract record → Ready to renew? (check)
- Ready to renew? → Renewal order approved (yes)
- Renewal order approved → Renew action (run on record)
- Renew action → Next record, as draft (creates)
- Next record, as draft → Retire, then activate (then)
- Retire, then activate → Chain intact? (verify)
- Chain intact? → Chain extended (yes)
- Chain intact? → Named half-state (no)
A record that isn't ready is refused, with the reason.
Key Decisions
A new record for each term, not new dates on the old one
Alternatives: extend the end date on the existing record, or keep every term inside one record. Both blur the history: terms can cover different items under different conditions, and an edited end date erases what came before. One record per term keeps what was covered when, and gives each renewal order one clear record to point to.
Start from the active record, not from the order
Alternative: create the next record automatically when the renewal order is approved. But the order says what was sold, while the active record is where readiness is known. Starting there makes the backward link a given, not a search. The approved order, linked through a renewal field, authorizes the renewal but doesn't start it. A person runs the action in context, so no trigger renews a record that wasn't ready.
Links both ways, and statuses that must agree with them
Alternatives: one link from the new record back to the old, or a shared contract number on every record. A back-link alone can't tell, from the old record, whether it was renewed. A shared number groups the records but doesn't order them, so I keep one only as a grouping key for the checks. With links both ways, the chain walks in either direction, and a status that contradicts its links stands out.
The steps run in an order that keeps failures visible
Alternative: a checklist people follow by hand, where any step can be skipped. Even an action makes several separate writes, and any of them can fail. So it builds the next record as a draft first, with its term, covered items and both links, then marks the old record renewed, and only then activates the new one. If it stops after retiring the old record, the contract is left with no active record, which a check finds, never with two, which is harder to notice.
When Things Go Wrong
The renewal order is approved, but nobody runs the action
→ The record is still active, with an approved order and no successor. The check names that half-state; the fix is to run the action.
Someone runs the action again, or on an old record
→ The readiness rules refuse it, saying whether the record is already renewed or linked to a newer contract.
A record is marked renewed by hand, with no successor
→ The check compares status with links and flags it. The fix runs the missing steps of the renewal rather than starting another.
The action stops after creating the draft
→ The old record is either still active beside an orphan draft, or already renewed with no active record at all. The check finds any draft with a predecessor; once its term and items are confirmed, the remaining steps run.
Two people press Renew on the same record at once
→ Both runs can pass the readiness rules before either writes. The check finds two successors of one record, and a person sets the later one to Canceled.
What the Business Gets
- Anyone can open a contract and see whether it is current, what replaced it and what came before.
- Every team reads the same current record, because there is only one.
- Renewals follow the same steps whoever runs them.
For Engineers
Records. ContractRecord: account, covered items, start, end, status, excluded-from-renewal flag, chain (a contract key shared by every term), and previous and next lookups. RenewalOrder: approval status and a renews lookup to the record it renews.
Statuses. Draft → Active → Renewed, or Active → Expired or Terminated. A duplicate made by two runs at once goes to Canceled. Only the action should set Renewed; the checks catch anything else.
Checks (saved views or a scheduled query) flag:
- two
Activerecords in one chain; - two records whose
previousis the same record; Renewedwith nonext, or anextstill inDraft;- links that don't point back;
- an approved renewal order whose record has no successor;
- a
Draftthat has aprevious.
renew(rec):
refuse unless rec.status == ACTIVE
refuse if rec.excluded or rec.next or newer_record_links_to(rec)
order = approved_renewal_order(renews = rec) or refuse("no approved order")
nxt = create(status = DRAFT, term = next_term(rec), previous = rec, chain = rec.chain)
copy_items(carried_over(rec, order), into = nxt)
rec.next = nxt
rec.status = RENEWED # retire first: never two active
nxt.status = ACTIVE
return check_chain(rec)
A limit to know. The readiness rules and the writes are separate steps, with no lock between them, so two runs started on one record at the same moment could both pass. Where that can happen, put renewals through one queue that handles one record at a time. A unique field alone isn't enough: in my tests, the platform's unique check stopped back-to-back repeats but let parallel writes through. That may have changed.
How I Build Systems Like This
I design a renewal as a change to a chain, not to one record. I write down the statuses, the links, the conditions before and after the action, and each half-state with its fix, which also becomes the team's guide. Today, AI agents (Claude Code) do much of my hands-on build work from a design like this, under a rules file that keeps each rule beside its reason; decisions stay with a person.