Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions .changeset/2804-contract-form-change.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
---
"hotcrm": minor
---

Clause-②: no
Metadata-protocol: none

**Sales: contract forms, an order contract that follows its order, and Change on an activated contract (#2804).** Every contract now has a **Contract Form**: **Order Contract**, **Framework Contract** or **Other**. It sits beside **Contract Type**, which is unchanged. **Draft Contract** on an order makes an order contract that names the order as its **Source Order**; its value is the order's total, tax included, it is read-only on the form, and while the contract is a draft a change to the order's amount changes the contract's value too. A contract you create by hand is a framework contract (value typed, may carry many orders) or Other (no amount needed, such as an NDA; the value starts at 0); you choose while it is a draft. Once a contract is activated, its **Contract Value**, **End Date** and **Payment Terms** are read-only on the form and change only through the new **Change** button: it asks for a reason and the signed amendment, and saves nothing without both. On a framework contract Change may set a new value; on an order contract it offers no value, only **Update from Order**, which takes the order's current amount. A new end date and new payment terms are optional on both. The contract stays Activated, so renewal reminders and expiry go on as before; Change creates no change order, does not touch the order and does not re-plan payments. History is now kept on the value, the start and end dates, the payment terms and the change reason, so the record's History shows each change before and after, who made it and when. If an order's amount changes after its contract is activated, the contract shows **Differs from the Order Amount**. A direct edit of those three fields on an activated contract, through the form or the API, is now refused and names the field (it used to refuse only an earlier end date). Contracts that already exist take a form on their next save: one drafted by Draft Contract and named by its order is an order contract, one with no value is Other, the rest are framework contracts; values are not changed. After upgrading, an administrator runs `pnpm exec objectstack migrate summary-nulls --apply --yes` (the platform's step that computes **Order Amount** on existing contracts), then `pnpm exec tsx scripts/backfill-contract-form.ts --apply`, which gives every existing contract its form at once and prints the order contracts whose value differs from their order, for the business to check; neither step changes a value. Labels, buttons and messages are in English, Chinese, Spanish and Japanese, and the Contracts manual and in-app help describe the rules.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ Open <http://localhost:4001/_console/> and sign in as `admin@objectos.ai` / `adm

The definition is the app. Objects and fields, rules, screens, flows, permissions and translations are typed metadata under `src/`: change a field there and the table, the API and the screens follow, with no second application to keep in step. An AI coding agent such as Claude Code writes that change in your copy of the repository, and `pnpm validate` checks it against the platform's schema before it ships.

Today the definition holds **38 business objects**, **54 actions**, **53 flows**, **7 dashboards**, **11 datasets** and **18 positions**, in **4 languages** (en, zh-CN, es-ES, ja-JP).
Today the definition holds **38 business objects**, **56 actions**, **53 flows**, **7 dashboards**, **11 datasets** and **18 positions**, in **4 languages** (en, zh-CN, es-ES, ja-JP).

HotCRM is built on [ObjectStack](https://github.com/objectstack-ai/objectstack), the open-source platform that runs one business definition as the database, the API, the screens and the agent tools at once. [Customize and extend](https://hotcrm.com/docs/developers/customize-and-extend) walks through a change.

Expand Down
2 changes: 1 addition & 1 deletion README.zh-CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ pnpm dev

定义就是应用。对象和字段、规则、界面、流程、权限和翻译都是 `src/` 下的类型化元数据:在那里改一个字段,数据表、API 和界面随之一起变,没有第二套应用需要同步。像 Claude Code 这样的 AI 编程智能体在你的仓库副本里写下这次改动,`pnpm validate` 在发布前按平台的 schema 检查它。

目前这份定义包含 **38 个业务对象**、**54 个动作**、**53 个流程**、**7 个仪表盘**、**11 个数据集**和 **18 个岗位**,支持 **4 种语言**(en、zh-CN、es-ES、ja-JP)。
目前这份定义包含 **38 个业务对象**、**56 个动作**、**53 个流程**、**7 个仪表盘**、**11 个数据集**和 **18 个岗位**,支持 **4 种语言**(en、zh-CN、es-ES、ja-JP)。

HotCRM 构建在 [ObjectStack](https://github.com/objectstack-ai/objectstack) 之上:这个开源平台把一份业务定义同时运行为数据库、API、界面和智能体工具。[定制与扩展](https://hotcrm.com/zh-Hans/docs/developers/customize-and-extend) 演示了一次改动的全过程。

Expand Down
44 changes: 37 additions & 7 deletions content/docs/(product)/sales/contracts.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,34 @@ A **contract** is the legal agreement between your company and a customer — wh

Activation is the key transition — it triggers the account to be promoted to *Customer*.

## The contract form: order, framework or other

Every contract has a **Contract Form**, which decides where its value comes from. It sits beside the contract type and does not replace it: the type says *what* is agreed (a subscription, a service, an NDA), the form says what the contract is *for*.

| Form | How it is made | Its value |
| --- | --- | --- |
| **Order Contract** | **Draft Contract** on an order — never by hand | The order's total, tax included. Read-only on the form |
| **Framework Contract** | By hand — the default for a new contract | Typed by hand. It may carry many orders |
| **Other** | By hand | No amount needed, such as an NDA. The value is 0 unless you type one |

You choose **Framework Contract** or **Other** while the contract is a draft; once it leaves Draft, the form is fixed. An order contract stays an order contract, and its **Source Order** names the order it was drafted from.

**An order contract follows its order while it is a draft.** Its **Order Amount** and its **Contract Value** are the order's total: change the order (or the quote it came from), and the draft contract's value changes with it. Nobody types the value of an order contract.

**Once the contract is activated, its value stays as signed.** If the order's amount changes afterwards, the contract shows **Differs from the Order Amount**, and its value does not move until someone runs **Change** with **Update from Order** (below).

Contracts that existed before contract forms took one by this rule, the first time each was saved after the upgrade: a contract drafted by **Draft Contract** and named by its order is an order contract; a contract with no value is **Other**; every other contract is a framework contract. An order contract whose value already differed from its order was left as it was, showing **Differs from the Order Amount**, for the business to check.

## Changing an activated contract

On an **Activated** contract, the **Contract Value**, the **End Date** and the **Payment Terms** are read-only on the form. They change only through **Change**, on the contract's header:

- Give a **Change Reason** and upload the **Signed Amendment** the customer signed. Change without both does not save.
- A framework (or other) contract may be given a **New Contract Value**. An order contract is offered no value at all: tick **Update from Order** to take the order's current amount.
- A **New End Date** and **New Payment Terms** are optional. A field left empty keeps its value. When the new end date takes the term out of step with **Contract Term (Months)**, the term is counted again from the dates.

The contract stays **Activated**, so renewal reminders and the expiration sweep go on as before. Change creates no change order, does not change the order, and does not re-plan the payments. The contract's **History** shows each value before and after, who changed it and when, and the **Last Change** section shows the latest reason and amendment.

## The 6 contract types

| Type | Use for |
Expand All @@ -32,18 +60,19 @@ Activation is the key transition — it triggers the account to be promoted to *

## What a contract record stores

A contract record declares its fields in **six groups**. The contract form shows a curated subset of them across its tabs, so read this as the full inventory of what a contract carries rather than a screen-by-screen map:
A contract record declares its fields in **seven groups**. The contract form shows a curated subset of them across its tabs, so read this as the full inventory of what a contract carries rather than a screen-by-screen map:

| Group | What's in it |
| --- | --- |
| **Contract Information** | Contract Name, Contract Number *(auto-numbered `CTR-0001`)*, Contract Type, Contract Document, Description |
| **Contract Information** | Contract Name, Contract Form, Source Order, Contract Number *(auto-numbered `CTR-0001`)*, Contract Type, Contract Document, Description |
| **Parties** | Contract Owner, Account, Primary Contact, Related Opportunity — the contact and opportunity pickers are scoped to the account you pick first |
| **Terms & Dates** | Contract Term (Months), Start Date, End Date, Special Terms |
| **Contract Value** | Contract Value, Billing Frequency, Payment Terms, Billing Address |
| **Contract Value** | Contract Value, Order Amount and Differs from the Order Amount *(order contracts)*, Billing Frequency, Payment Terms, Billing Address |
| **Status & Approval** | Status, Signed Date, Signed By, Signed Copy |
| **Renewal** | Auto Renewal, Renewal Notice (Days) |
| **Last Change** | Change Reason, Signed Amendment — written by **Change** |

Contract Name, Account, Primary Contact, Contract Term, Start Date, End Date, Contract Value and Status are all **required** — a contract cannot be saved without them.
Contract Name, Contract Form, Account, Primary Contact, Contract Term, Start Date, End Date, Contract Value and Status are all **required** — a contract cannot be saved without them. Contract Value starts at 0, so an Other contract needs no amount typed.

## The contract's name and number

Expand Down Expand Up @@ -149,15 +178,16 @@ Terminating a contract is a status change to *Terminated*, and two things about

**And it is final.** An edit that moves a terminated contract to any other status is refused, and the contract stays *Terminated* — see *The status progression is a gate* below; a replacement is a new contract. The rest of the contract stays editable: a change to its notes, its terms or its primary contact saves as long as the status is left as it is.

**Status** is one of the two fields Contract keeps history on, so the audit log does record who moved it and when.
**Status** is one of the fields Contract keeps history on, so the audit log does record who moved it and when. The others are the owner, the start and end dates, the value, the payment terms and the change reason.

## Built-in rules

Five rules reject a save outright:
Six rules reject a save outright:

- **End date must be after start date** — a validation rule on the object.
- **The term must match the dates** — the contract hook counts the months between **Start Date** and **End Date** and rejects anything more than **one month** away from **Contract Term (Months)**: *"Contract term (12 months) does not match date range (6 months from … to …)."* Term and dates move together, or the save bounces.
- **An activated contract's end date cannot be pulled in** — once the contract is *Activated*, an edit that moves **End Date** earlier is refused (*"Cannot shrink end_date … after activation"*). Pushing it out is fine; shortening a live agreement is a termination or an amendment, not an edit.
- **An activated contract changes only through Change** — once the contract is *Activated*, an edit to **Contract Value**, **End Date** or **Payment Terms** is refused, naming the field (*"An activated contract's End Date changes only through Change, with a reason and the signed amendment."*). See *Changing an activated contract* above.
- **An order contract's value is its order's** — typing **Contract Value** on an order contract is refused, whatever its status.
- **Activated requires a signed copy** — a save that moves a contract to *Activated*, or creates one already *Activated*, without a **Signed Copy** is refused on that field; see *Printing a contract and the signed copy* above.
- **The status progression is a gate.** The route is *Draft* → *In Approval* → *Activated* → *Expired* or *Terminated*, with *In Approval* able to go back to *Draft*, *Terminated* reachable from all three live statuses, and *Expired* and *Terminated* both final: a renewal is a new contract, never a revived one. A status change off that route — *Draft* straight to *Activated*, *Activated* back to *Draft*, or reviving an *Expired* or *Terminated* contract — is refused on **Status** with *"This status change is not allowed. A contract moves Draft → In Approval → Activated → Expired; In Approval can go back to Draft, and Draft, In Approval or Activated can be Terminated. Expired and Terminated are final: a renewal is a new contract."*, and the contract keeps its status, whether the change comes from the Edit form or the REST API (`400 VALIDATION_FAILED`). Only a change of the status is judged: any other edit saves on any contract, an expired or terminated one included. A contract *created* directly as *Activated* or *Expired* is not checked by this rule, which is the same import path that skips the activation writes described above; one created *Activated* still needs its **Signed Copy**.

Expand Down
Loading
Loading