[
  {
    "apiName": "NetSuite_Revenue_Monthly__c",
    "label": "NetSuite Monthly Revenue",
    "pluralLabel": "NetSuite Monthly Revenue",
    "tableType": "custom_object",
    "category": "crm",
    "keyPrefix": "a2Z",
    "sharingModel": "Private",
    "enableHierarchySharing": false,
    "description": "Versioned Account-backed monthly NetSuite actuals candidates. Grain: posting month, CRM Account, normalized Product, Category, company and transaction currency. Self-serve without Account is excluded before CRM writes. Monthly_Revenue_Key__c is stable across versions; Snapshot_Row_Key__c uniquely identifies one run plus monthly key. Existence of a row is not publication or business approval: consumers must select an independently approved complete run. Never mix these summaries with voucher-line or order-based RevRec totals.",
    "fields": [
      {"apiName": "Name", "label": "Name", "type": "string", "isNameField": true, "required": true},
      {
        "apiName": "CRM_Account__c",
        "label": "CRM Account",
        "type": "reference",
        "referenceTo": ["Account"],
        "relationshipName": "CRM_Account__r",
        "childRelationshipName": "NetSuite_Monthly_Revenues",
        "deleteConstraint": "Restrict",
        "required": true
      },
      {"apiName": "Revenue_Month__c", "label": "Revenue Month", "type": "date", "required": true},
      {
        "apiName": "Product_Name__c", "label": "Product", "type": "picklist", "required": true,
        "options": [
          {"value": "Dedicated", "label": "Dedicated"},
          {"value": "Starter", "label": "Starter"},
          {"value": "Essential", "label": "Essential"},
          {"value": "Premium", "label": "Premium"},
          {"value": "Lake", "label": "Lake"},
          {"value": "BYOC", "label": "BYOC"},
          {"value": "Support Plan", "label": "Support Plan"},
          {"value": "Subscription", "label": "Subscription"},
          {"value": "Professional Service", "label": "Professional Service"}
        ]
      },
      {
        "apiName": "Product_Category__c", "label": "Product Category", "type": "picklist", "required": true,
        "options": [{"value": "Cloud", "label": "Cloud"}, {"value": "OP", "label": "OP"}]
      },
      {"apiName": "Company__c", "label": "Source Company", "type": "string", "required": true},
      {
        "apiName": "Transaction_Currency__c", "label": "Transaction Currency", "type": "string",
        "required": true, "minLength": 3, "maxLength": 3, "regex": "^[A-Z]{3}$"
      },
      {
        "apiName": "Transaction_Amount__c", "label": "Transaction Revenue", "type": "currency", "required": true,
        "description": "Signed source transaction-currency sum; preserve credits and zero amounts. No implicit FX."
      },
      {
        "apiName": "Base_Amount__c", "label": "Source Base Amount", "type": "currency",
        "description": "Optional signed audit sum in the source company's base currency; not consolidated USD."
      },
      {"apiName": "NetSuite_Posting_Period_Id__c", "label": "NetSuite Posting Period ID", "type": "string", "required": true},
      {
        "apiName": "Monthly_Revenue_Key__c", "label": "Monthly Revenue Key", "type": "string",
        "required": true, "minLength": 64, "maxLength": 64, "regex": "^[0-9a-f]{64}$",
        "description": "Stable business grain hash. Deliberately not globally unique: multiple versions may coexist."
      },
      {"apiName": "Sync_Run_Id__c", "label": "Sync Run ID", "type": "string", "required": true},
      {
        "apiName": "Snapshot_Row_Key__c", "label": "Snapshot Row Key", "type": "string",
        "required": true, "unique": true, "minLength": 64, "maxLength": 64, "regex": "^[0-9a-f]{64}$",
        "description": "Unique API upsert identity over Sync Run ID plus Monthly Revenue Key."
      },
      {
        "apiName": "Source_Line_Count__c", "label": "Source Line Count", "type": "double", "required": true,
        "minValue": 1, "description": "Positive integer count of constituent voucher lines; ETL must validate integrality."
      },
      {
        "apiName": "Source_Payload_Set_Hash__c", "label": "Source Payload Set Hash", "type": "string",
        "required": true, "minLength": 64, "maxLength": 64, "regex": "^[0-9a-f]{64}$"
      },
      {
        "apiName": "Payload_Hash__c", "label": "Target Payload Hash", "type": "string",
        "required": true, "minLength": 64, "maxLength": 64, "regex": "^[0-9a-f]{64}$",
        "description": "Hash of the canonical written business fields; verify by rehashing actual API readback."
      }
    ],
    "indices": [
      {"name": "idx_nrm_account_month", "columns": ["CRM_Account__c", "Revenue_Month__c"]},
      {"name": "idx_nrm_month_run", "columns": ["Revenue_Month__c", "Sync_Run_Id__c"]},
      {"name": "idx_nrm_monthly_key", "columns": ["Monthly_Revenue_Key__c"]}
    ]
  }
]
