{
  "jira_key": "AN-62",
  "summary": "Opportunity Categorisation Automation",
  "approach": "Implement automatic Opportunity Type assignment and Deal Size Tier calculation using Flows and Custom Metadata. Enforce edit restrictions and override logic with Validation Rules and Permission Sets. Trigger notifications and tasks via Flow. Configure fields for visibility on layouts and list views. Provide Apex for one-off data update. Dashboard and reporting requirements escalated as out of allowlist.",
  "metadata_plan": [
    {
      "metadata_type": "CustomField",
      "api_name": "Deal_Size_Tier__c",
      "action": "create",
      "object": "Opportunity",
      "notes": "Picklist, label: Deal Size Tier, values: Small, Medium, Large, Strategic (example), no default, not required at definition."
    },
    {
      "metadata_type": "ValidationRule",
      "api_name": "Prevent_Type_Edit",
      "action": "create",
      "object": "Opportunity",
      "notes": "Purpose: Prevent reps from editing Type unless Sales Manager or SysAdmin and Override Reason is provided. Formula: AND(ISCHANGED(Type), NOT($Permission.Opportunity_Type_Override), ISBLANK(Override_Reason__c)). Error message: Only Sales Managers or System Administrators can override Type and must provide Override Reason. Error location: Type field."
    },
    {
      "metadata_type": "CustomField",
      "api_name": "Override_Reason__c",
      "action": "create",
      "object": "Opportunity",
      "notes": "Text, label: Override Reason, no default, not required at definition."
    },
    {
      "metadata_type": "ValidationRule",
      "api_name": "Strategic_Proposal_Stage_Validation",
      "action": "create",
      "object": "Opportunity",
      "notes": "Purpose: Prevent Strategic Opportunities from moving past Proposal stage unless Executive Sponsor is populated. Formula: AND(ISPICKVAL(Deal_Size_Tier__c, 'Strategic'), ISPICKVAL(StageName, 'Proposal'), ISBLANK(Executive_Sponsor__c)). Error message: Executive Sponsor is required for Strategic Opportunities at Proposal stage. Error location: Executive Sponsor field."
    },
    {
      "metadata_type": "Flow",
      "api_name": "Opportunity_Type_Assignment",
      "action": "create",
      "object": "Opportunity",
      "notes": "Record-triggered Flow on Opportunity create. Sets Type based on Account history and renewal status. Also sets Deal Size Tier from Amount using thresholds from Custom Metadata. Triggers notification and Task to manager when Opportunity becomes Strategic."
    },
    {
      "metadata_type": "PermissionSet",
      "api_name": "Opportunity_Type_Override",
      "action": "create",
      "object": null,
      "notes": "Grants edit access to Type and Override Reason fields for Sales Managers and System Administrators."
    },
    {
      "metadata_type": "CustomField",
      "api_name": "Executive_Sponsor__c",
      "action": "create",
      "object": "Opportunity",
      "notes": "Lookup(User), label: Executive Sponsor, no default, not required at definition."
    },
    {
      "metadata_type": "ApexClass",
      "api_name": "OpportunityDataMigration",
      "action": "create",
      "object": null,
      "notes": "Apex class to perform one-off data update to categorise all open Opportunities before go-live."
    }
  ],
  "dependencies": [
    "Custom Metadata for thresholds must be created before Flow.",
    "Permission Set must be assigned to Sales Managers and System Administrators."
  ],
  "risks_or_escalations": [
    "Dashboard component and reporting configuration are out of v1 allowlist and must be escalated.",
    "List view and Path configuration are UI settings and not metadata; escalate if automation is required.",
    "Metadata type outside v1 allowlist: CustomMetadata"
  ],
  "out_of_allowlist": true,
  "confidence": 1.0,
  "notes": null
}