update_transaction
Modify details of an existing transaction, including amount, description, category, date, VAT rate, sale type, supplier country, and cashflow type, using the Norman Finance MCP Server.
Instructions
Update an existing transaction.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| amount | No | ||
| cashflow_type | No | ||
| category | No | ||
| category_id | No | ||
| date | No | ||
| description | No | ||
| sale_type | No | ||
| supplier_country | No | ||
| transaction_id | Yes | ||
| vat_rate | No |
Implementation Reference
- norman_mcp/tools/transactions.py:147-194 (handler)The core handler function for the 'update_transaction' tool. Includes inline schema definitions via Pydantic Field descriptions and the execution logic that updates the transaction via the Norman API.@mcp.tool() async def update_transaction( ctx: Context, transaction_id: str = Field(description="Public ID of the transaction to update"), amount: Optional[float] = Field(description="Transaction amount (positive for income, negative for expense)"), description: Optional[str] = Field(description="Transaction description"), category: Optional[str] = Field(description="Transaction category"), date: Optional[str] = Field(description="Transaction date in YYYY-MM-DD format (defaults to today)"), vat_rate: Optional[int] = Field(description="VAT rate (0, 7, 19)"), sale_type: Optional[str] = Field(description="Sale type (GOODS, SERVICES)"), supplier_country: Optional[str] = Field(description="Country of the supplier (DE, INSIDE_EU, OUTSIDE_EU)"), cashflow_type: Optional[str] = Field(description="Cashflow type of the transaction (INCOME, EXPENSE)"), category_id: Optional[str] = Field(description="Category ID of the transaction (If not provided, the transaction will be categorized automatically using AI)"), ) -> Dict[str, Any]: """Update an existing transaction.""" api = ctx.request_context.lifespan_context["api"] company_id = api.company_id if not company_id: return {"error": "No company available. Please authenticate first."} transaction_url = urljoin( config.api_base_url, f"api/v1/companies/{company_id}/accounting/transactions/{transaction_id}/" ) # Prepare update data update_data = {} if amount is not None: update_data["amount"] = abs(amount) if cashflow_type == "INCOME" else -abs(amount) if description is not None: update_data["description"] = description if category is not None: update_data["category"] = category if date is not None: update_data["valueDate"] = date if vat_rate is not None: update_data["vatRate"] = vat_rate if sale_type is not None: update_data["saleType"] = sale_type if sale_type else "" if supplier_country is not None: update_data["supplierCountry"] = supplier_country if cashflow_type is not None: update_data["cashflowType"] = cashflow_type if category_id is not None: update_data["category"] = category_id return api._make_request("PATCH", transaction_url, json_data=update_data)
- Input schema for the update_transaction tool defined using Pydantic Fields with descriptions.async def update_transaction( ctx: Context, transaction_id: str = Field(description="Public ID of the transaction to update"), amount: Optional[float] = Field(description="Transaction amount (positive for income, negative for expense)"), description: Optional[str] = Field(description="Transaction description"), category: Optional[str] = Field(description="Transaction category"), date: Optional[str] = Field(description="Transaction date in YYYY-MM-DD format (defaults to today)"), vat_rate: Optional[int] = Field(description="VAT rate (0, 7, 19)"), sale_type: Optional[str] = Field(description="Sale type (GOODS, SERVICES)"), supplier_country: Optional[str] = Field(description="Country of the supplier (DE, INSIDE_EU, OUTSIDE_EU)"), cashflow_type: Optional[str] = Field(description="Cashflow type of the transaction (INCOME, EXPENSE)"), category_id: Optional[str] = Field(description="Category ID of the transaction (If not provided, the transaction will be categorized automatically using AI)"), ) -> Dict[str, Any]:
- norman_mcp/server.py:331-331 (registration)Registration call that invokes register_transaction_tools(server), which defines and registers the update_transaction tool along with other transaction tools.register_transaction_tools(server)