Amendment Apply Requested
A user finished reviewing a contract amendment and asked for its changes to be applied. cna-nexus's amendment consumer executes the changes on the contract and the franchise.
Overview
Fact: an amendment was saved in the state APPLYING and its application is requested.
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 +13SubscribesContractActivationRequested, AmendmentApplyRequested +4Ownercna-platformMapRepoView docs, in persistAmendmentUpdate, reached from the mutations that update an amendment or a rescission: after the amendment’s change rows and participants are replaced and its signedAt and status = APPLYING are written. No transaction wraps those writes and the producer is awaited afterwards, not registered with afterCommit. The parent contract is untouched at this point.
What the consumer does. cna-nexus (amendmentApplyConsumer, group contract-amendment-apply), using only amendmentId (contractId is there for routing):
- Loads the amendment; a missing one throws (logged and reported to Sentry).
- Idempotency guard:
APPLIEDorAPPLY_FAILEDare skipped. applyAmendmentChanges: in one transaction, dispatches each change to its handler (name, legal name, CNPJ, category, estimated opening date, address, territory, end date, corporate change;ADDITIONAL_CLAUSEandOTHERhave no handler and are skipped), runs the contract termination for aRESCISSION, writes field-level audit rows with the uploader as author, and marks the amendmentAPPLIED.- On failure: logs and sets the amendment to
APPLY_FAILED. Not rethrown.
Follow-up message. Exactly one FranchiseUpdated per amendment, registered with manager.afterCommit() (see the Franchise topic).
Kafka
Topic (aggregateRoot) | Contract |
Message key (routingKey) | payload.contractId |
| Contract owner | NEXUS |
metadata.event | AmendmentApplyRequested |
| Consumer group | contract-amendment-apply |
Payload schema
Source of truth
type AmendmentApplyRequestedPayload = { contractId: string; amendmentId: string;};
export class AmendmentApplyRequested extends Event<AmendmentApplyRequestedPayload> { static readonly owner = "NEXUS"; static readonly aggregateRoot = "Contract"; static readonly routingKey = "contractId";}The class exists only in cna-nexus.
Custom properties
| Property | Value |
|---|---|
| Contract Ownerx-contract-owner | NEXUS |
| Kafka Topicx-kafka-topic | Contract |
| Message Keyx-message-key | contractId |
| Sourcex-source | cna-nexus api/app/events/nexus/contract/AmendmentApplyRequested.ts |
Contract the amendment modifies (UUID). Kafka message key, so amendments and activations of one contract stay ordered.
Amendment id (UUID) in contract.contract_amendments. The only field the consumer reads.