CrmDeal
The CrmDeal entity, mapped to the crm_deal table.
| Table | crm_deal |
| Tenant-scoped | Yes — extends TenantOwned |
| Columns | 11 |
| Relationships | 5 |
| Source | backend/src/main/java/com/motorph/payroll/model/CrmDeal.java |
Columns
| Field | Type | Column | Null | Notes |
|---|---|---|---|---|
dealId | Integer | deal_id | — | primary key, generated |
name | String | name | — | — |
stage | String | stage | — | — |
probability | Integer | probability | — | — |
expectedValue | BigDecimal | expected_value | Yes | — |
actualValue | BigDecimal | actual_value | Yes | — |
expectedCloseDate | LocalDate | expected_close_date | Yes | — |
actualCloseDate | LocalDate | actual_close_date | Yes | — |
lostReason | String | lost_reason | Yes | — |
createdAt | LocalDateTime | created_at | — | — |
updatedAt | LocalDateTime | updated_at | Yes | — |
Plus tenant_id, inherited from TenantOwned. Hibernate stamps it on insert and adds where tenant_id = ? to every query, so it is never written or read by application code.
Relationships
| Field | Kind | Target | Join column | Required |
|---|---|---|---|---|
organization | @ManyToOne | CrmOrganization | org_id | — |
contact | @ManyToOne | CrmContact | contact_id | — |
lead | @ManyToOne | CrmLead | lead_id | — |
owner | @ManyToOne | Employee | owner_id | — |
accountManager | @ManyToOne | Employee | account_manager_id | — |
Referenced by
| Entity | Field | Kind |
|---|---|---|
| CrmActivity | deal | @ManyToOne |
| CrmNote | deal | @ManyToOne |
Neighbourhood
Repository
CrmDealRepository
Declared over CrmDeal with id type Integer, with JpaSpecificationExecutor for dynamic filtering. Source: backend/src/main/java/com/motorph/payroll/repository/CrmDealRepository.java
| Method | Returns | Notes |
|---|---|---|
findWithDetailsByDealId(Integer dealId) | Optional<CrmDeal> | derived |
findAllByStageNotIn(List<String> excludedStages) | List<CrmDeal> | derived |
countByStage(String stage) | long | derived |
countGroupedByStage() | List<Object[]> | explicit @Query |
renameStage(@Param("oldName") String oldName, @Param("newName") String newName) | int | explicit @Query, modifying |
Reached by
These controllers hold — directly or through a service they depend on — a repository over CrmDeal.
| Controller | Base path | Endpoints | Module |
|---|---|---|---|
| CrmActivityController | /api/crm/activities | 5 | CRM |
| CrmDealController | /api/crm/deals | 11 | CRM |
| CrmLeadController | /api/crm/leads | 7 | CRM |
| CrmPicklistController | /api/crm/picklists | 4 | CRM |
Generated page
This page is rebuilt from the source on every docs build by docs-site/scripts/gen-code-wiki.mjs. Editing it has no effect — change the code, or, if what you want to say is prose, write it in docs/.