[
  {
    "apiName": "OpportunityLineItem",
    "keyPrefix": "00k",
    "label": "Opportunity Line Item",
    "tableType": "standard_object",
    "category": "crm",
    "sharingModel": "ControlledByParent",
    "enableHierarchySharing": false,
    "displayNameField": "Product2Id",
    "description": "Standard Salesforce Opportunity Line Item object \u2014 represents products sold in an opportunity",
    "fields": [
      {
        "apiName": "OpportunityId",
        "label": "Opportunity",
        "type": "reference",
        "required": true,
        "referenceTo": [
          "Opportunity"
        ],
        "relationshipName": "Opportunity",
        "childRelationshipName": "OpportunityLineItems"
      },
      {
        "apiName": "PricebookEntryId",
        "label": "Price Book Entry",
        "type": "reference",
        "referenceTo": [
          "PricebookEntry"
        ],
        "relationshipName": "PricebookEntry",
        "childRelationshipName": "OpportunityLineItems",
        "validator": "runtime_scoped_lookup",
        "validatorConfig": "{\"filterMappings\":[{\"recordField\":\"OpportunityId\",\"sourceField\":\"Pricebook2Id\",\"targetField\":\"Pricebook2Id\"}]}"
      },
      {
        "apiName": "Quantity",
        "label": "Quantity",
        "type": "double",
        "required": true,
        "default": "1"
      },
      {
        "apiName": "UnitPrice",
        "label": "Unit Price",
        "type": "formula",
        "createable": false,
        "updateable": false,
        "returnType": "currency",
        "formulaMode": "active",
        "formula": "ListPrice"
      },
      {
        "apiName": "CurrencyIsoCode",
        "label": "Currency ISO Code",
        "type": "picklist",
        "default": "USD",
        "options": [
          {
            "label": "Chinese Yuan",
            "value": "CNY"
          },
          {
            "label": "Japanese Yen",
            "value": "JPY"
          },
          {
            "label": "Singapore Dollar",
            "value": "SGD"
          },
          {
            "label": "U.S. Dollar",
            "value": "USD"
          }
        ]
      },
      {
        "apiName": "TotalPrice",
        "label": "Total Price",
        "type": "formula",
        "createable": false,
        "updateable": false,
        "returnType": "currency",
        "formulaMode": "active",
        "formula": "Quantity * UnitPrice"
      },
      {
        "apiName": "Description",
        "label": "Description",
        "type": "textarea"
      },
      {
        "apiName": "ServiceDate",
        "label": "Service Date",
        "type": "date"
      },
      {
        "apiName": "ListPrice",
        "label": "List Price",
        "type": "currency",
        "createable": false,
        "updateable": false
      },
      {
        "apiName": "Discount",
        "label": "Discount",
        "type": "formula",
        "createable": false,
        "updateable": false,
        "returnType": "percent",
        "formulaMode": "active",
        "formula": "IF(TEXT(Product2.Family) = \"TiDB Cloud\", 0, (ListPrice - Unit_Net_Price__c) / ListPrice)",
        "description": "Discount off list price. TiDB Cloud is consumption-priced against a $1.00 placeholder PricebookEntry (one product, 01t5g000000liLxAAI, list 1 in every currency) and carries no list discount, so the formula returns 0 for that family to match Salesforce, which stores 0.00% on every TiDB Cloud line. All other families keep (ListPrice - Unit_Net_Price__c) / ListPrice."
      },
      {
        "apiName": "Net_fees__c",
        "type": "currency",
        "label": "Net Fees",
        "createable": false,
        "updateable": false,
        "description": "Derived line net fees. Stamped before save by the OpportunityLineItem Net Fees autocalc flows (OpportunityLineItem_Net_Fees_Autocalc at order 200, and an early stamp in OpportunityLineItem_PricebookEntryId_Autofill_From_Product2 for the Product2-first path): Unit_Net_Price__c * Quantity * Term_Mounths__c for the TiDB Enterprise Subscription family (term-priced), and Unit_Net_Price__c * Quantity for every other family including TiDB Cloud and the one-time service families. Do not write directly; enter Unit_Net_Price__c, Quantity and (for Enterprise Subscription) Term_Mounths__c."
      },
      {
        "apiName": "OpportunityProduct__c",
        "type": "string",
        "label": "OpportunityProduct",
        "unique": true
      },
      {
        "apiName": "Product2Id",
        "type": "reference",
        "label": "Product",
        "referenceTo": [
          "Product2"
        ],
        "relationshipName": "Product2",
        "childRelationshipName": "OpportunityLineItems"
      },
      {
        "apiName": "Product_Family__c",
        "label": "Product Family",
        "type": "formula",
        "formula": "TEXT(Product2.Family)",
        "returnType": "string",
        "formulaMode": "active",
        "createable": false,
        "updateable": false
      },
      {
        "apiName": "Recalculate__c",
        "type": "boolean",
        "label": "Recalculate",
        "default": "0"
      },
      {
        "apiName": "Service_End_Date__c",
        "type": "date",
        "label": "Service End Date"
      },
      {
        "apiName": "Service_Start_Date__c",
        "type": "date",
        "label": "Service Start Date"
      },
      {
        "apiName": "Term_Mounths__c",
        "type": "double",
        "label": "Term(Months)",
        "default": "12",
        "description": "Typo-named legacy twin of the term field (QuoteLineItem uses the correctly spelled Term_Months__c). Kept for existing consumers only \u2014 do not add new references; unification is tracked in the field-semantics review."
      },
      {
        "apiName": "Unit_Net_Price__c",
        "type": "currency",
        "label": "Unit Net Price"
      },
      {
        "apiName": "Net_Fees_Total__c",
        "type": "currency",
        "label": "Net Fees (Total) (Do Not Use)",
        "createable": false,
        "updateable": false,
        "description": "DEPRECATED and read-only. Never consumed on this object: the OLI Net_fees derivation reads Unit_Net_Price__c/Quantity/Term_Mounths__c directly, and Opportunity.Net_Fees__c rolls up Net_fees__c. Populated on 0 of 2620 rows. A write is silently dropped by the platform capability gate, so callers get a 2xx and no value change. Kept for schema parity with QuoteLineItem only; do not treat as a money input."
      }
    ],
    "managedRelationships": [
      {
        "fieldApiName": "OpportunityId",
        "parentObject": "Opportunity",
        "isSharingParent": true
      }
    ]
  }
]
