Franchise Updated
A franchise unit changed in CNA Nexus - edited in one of the franchise screens, re-activated from a contract, or amended. Full snapshot. cna-one consumes it (cna-br/cna-one#890) to keep its mirror of the unit, its address and its partners in sync.
Overview
Fact: a franchise unit changed. Same payload as Franchise CreatedFranchise CreatedEventv2.1.0A franchise unit was created in CNA Nexus by activating an opening contract. Full snapshot of the unit; cna-one mirrors ...Ownercna-platformSchemaMapView docs: a full snapshot re-read after commit. Since 1.1.0 it carries the unit’s primary contact (email, whatsapp, phone). Since 1.2.0 the address also carries countryId, foreignCity, foreignState, latitude and longitude, and each partner is identified by id (the person id) instead of personId. Since 2.0.0 the operational start and end travel as calendar days, operationalStartOn and operationalEndOn (YYYY-MM-DD). Since 2.1.0 taxRegime may also be MEI.
When it is published. CNA NexusCNA NexusServicev1.0.0Franchise network back-office (franchises, economic groups, partners, contracts and amendments, document storage, AI doc...PublishesInviteUser, ContractActivationRequested +15SubscribesContractActivationRequested, AmendmentApplyRequested +5Ownercna-platformMapRepoView docs, always through manager.afterCommit(), from six places: the four franchise edit commands (legal information, operational data, financial data, location and contact), applyContractToFranchiseAggregate (a renewal, resale or re-activation projecting a ContractContractEntityv1.0.0A franchise contract in CNA Nexus - opening, renewal or resale - uploaded as a document, analysed by AI, reviewed by a p...Ownercna-platformView docs onto the unit, see Contract Activation RequestedContract Activation RequestedEventv1.0.0A user saved a contract for activation. cna-nexus's activation consumer turns it ACTIVE and creates or updates the franc...Ownercna-platformSchemaMapView docs) and applyAmendmentChanges (one message per applied Contract AmendmentContract AmendmentEntityv1.0.0A supplementary document attached to a contract - attachment, addendum or rescission - carrying one change per contract ...Ownercna-platformView docs, see Amendment Apply RequestedAmendment Apply RequestedEventv1.0.0A user finished reviewing a contract amendment and asked for its changes to be applied. cna-nexus's amendment consumer e...Ownercna-platformSchemaMapView docs).
What the consumer does. CNA OneCNA OneServicev1.0.0Franchise operating system (franchises and employees, pricing, products and learning books, school operations, receivabl...PublishesGrantApplicationAccess, EmployeeCreated +19SubscribesInviteUser, FranchiseCreated +17Ownercna-platformMapRepoView docs, in production since v0.4.0 (cna-br/cna-one#890): franchiseConsumer handles it in the same group as Franchise CreatedFranchise CreatedEventv2.1.0A franchise unit was created in CNA Nexus by activating an opening contract. Full snapshot of the unit; cna-one mirrors ...Ownercna-platformSchemaMapView docs, franchise-franchise-events; both are keyed by the franchise id, so they reach it in order per franchise. It hands it to the same syncFranchise, whose blocks are described on the Franchise CreatedFranchise CreatedEventv2.1.0A franchise unit was created in CNA Nexus by activating an opening contract. Full snapshot of the unit; cna-one mirrors ...Ownercna-platformSchemaMapView docs page. What only an update of a known franchise reaches:
- A snapshot without
cnpjorlegalNamefor a franchise cna-one already stores is not mirrored (cna-br/cna-one#905): the franchise is deactivated and keeps everything else, and the next snapshot carrying both mirrors it again. A franchise already inactive is answered without a write. - The
partnersof the snapshot replace the stored set (cna-br/cna-one#890): a partner the snapshot stops naming loses the staff link of that franchise and has its employment contract terminated; one named again is taken back on a new contract.
A snapshot of a unit cna-one does not store yet, carrying cnpj and legalName, is mirrored as an insertion, as a Franchise CreatedFranchise CreatedEventv2.1.0A franchise unit was created in CNA Nexus by activating an opening contract. Full snapshot of the unit; cna-one mirrors ...Ownercna-platformSchemaMapView docs would be.
Where the group consumed the topic before cna-br/cna-one#890, the FranchiseUpdated messages it skipped stay skipped: fromBeginning reads the topic from its start only for a group with no committed offset, as in a new environment.
Kafka
Topic (aggregateRoot) | Franchise |
Message key (routingKey) | payload.id |
| Contract owner | NEXUS |
metadata.event | FranchiseUpdated |
| Consumer group | franchise-franchise-events (cna-one, cna-br/cna-one#890) |
Payload schema
Same payload type as FranchiseCreated (FranchisePayload).
Source of truth
import { FranchisePayload } from 'events/nexus/franchise/FranchiseCreated';
export class FranchiseUpdated extends Event<FranchisePayload> { static readonly owner = 'NEXUS'; static readonly aggregateRoot = 'Franchise'; static readonly routingKey = 'id'; static readonly version = '2.1.0';}cna-one has its own copy, declared 1.2.0, typed with the FranchisePayload of its FranchiseCreated copy; see Known drift.
Known drift
cna-one api/app/events/nexus/franchise/FranchiseUpdated.ts declares 1.2.0 and types its payload with the FranchisePayload of api/app/events/nexus/franchise/FranchiseCreated.ts, aligned to 1.2.0 by cna-br/cna-one#969 (in production since v0.4.0). It has none of the 2.0.0 and 2.1.0 changes, so cna-one’s receives is pinned to 1.2.0 until those alignments are in production. Only the tax regime changes what cna-one does: a MEI value fails the sync and nothing is written, while the operational dates are ignored. Observed 2026-11-17 on cna-one v0.4.0.
| Field | cna-nexus (2.1.0) | cna-one (v0.4.0, 1.2.0) |
|---|---|---|
| operational start and end | operationalStartOn, operationalEndOn (YYYY-MM-DD) | operationalStartAt, operationalEndAt (ignored) |
taxRegime values | SIMPLES_NACIONAL, LUCRO_PRESUMIDO, LUCRO_REAL, MEI | without MEI (rejected) |
Custom properties
| Property | Value |
|---|---|
| Contract Ownerx-contract-owner | NEXUS |
| Kafka Topicx-kafka-topic | Franchise |
| Message Keyx-message-key | id |
| Sourcex-source | cna-nexus api/app/events/nexus/franchise/FranchiseUpdated.ts |
| Driftx-drift | Produced by cna-nexus in six places. cna-one's copy of FranchisePayload matches 1.2.0 (cna-br/cna-one#969) and lags 2.0.0 and 2.1.0: the operational dates are still operationalStartAt and operationalEndAt, and its FranchiseTaxRegime lacks MEI, so a snapshot with that taxRegime fails the sync. cna-one's receives is pinned to 1.2.0 until the 2.0.0 and 2.1.0 alignments are in production. |
Franchise id (UUID). Kafka message key; cna-one mirrors the unit under this id.
Unit name.
Internal unit code, unique.
Company registration number as stored (no normalisation). cna-one requires and validates it.
Legal company name. cna-one requires it.
Primary contact e-mail of the unit (franchises.email in cna-nexus, not unique there). cna-one mirrors it and requires it to be unique across its franchises.
WhatsApp number in E.164 (+5511912345678). Mirrored by cna-one.
^\+[1-9]\d{6,14}$Primary contact phone in E.164. Mirrored by cna-one.
^\+[1-9]\d{6,14}$State registration number.
Tax regime (FranchiseTaxRegime), typed as string in the class.
SIMPLES_NACIONAL LUCRO_PRESUMIDO LUCRO_REAL MEI Id in the Protheus ERP.
Inter-school sharing enabled.
Lifecycle stage (FranchiseOpeningStatus), typed as string in the class.
CREATED BUILT TRAINED SUSPENDED UNDER_REVIEW DEFAULTINGOperational status (FranchiseOperationalStatus). cna-one maps OPERATIONAL to ACTIVE, anything else to INACTIVE.
OPERATIONAL NON_OPERATIONAL UNDER_DEVELOPMENTFinancial standing (FranchiseFinancialStatus).
ACTIVE INACTIVE SUSPENDED DEFAULTING UNDER_REVIEW YYYY-MM-DD day the unit started operating, or null. Ignored by cna-one.
YYYY-MM-DD day the unit stopped operating, or null. Ignored by cna-one.
YYYY-MM-DD start of the earliest opening contract, or null. Ignored by cna-one.
Size/type category of the unit.
Economic group of the unit, or null. cna-one requires the group to have been mirrored first (EconomicGroupCreated).
Operational region, or null.
Unit address, or null. cna-one requires street, number, neighborhood, postalCode and cityId to mirror it; it ignores countryId, foreignCity, foreignState, latitude and longitude.
People behind the unit. May be empty. Roles are not included; cna-one turns each into a FRANCHISEE employee.
Products the unit is enabled to sell. cna-one keeps only the distinct sub-categories.