{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/trimble/json-schema/trimble-ap-invoice-schema.json",
  "title": "apInvoice",
  "x-generated": "2026-11-11",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/trimble-truckmate-finance-openapi.yml#/components/schemas/apInvoice",
  "type": "object",
  "properties": {
    "apInvoiceId": {
      "type": "integer"
    },
    "auditNumber": {
      "type": [
        "integer",
        "null"
      ]
    },
    "vendorId": {
      "type": "string",
      "maxLength": 10
    },
    "vendorBillNumber": {
      "type": [
        "string",
        "null"
      ],
      "maxLength": 20
    },
    "vendorBillAmount": {
      "type": [
        "number",
        "null"
      ]
    },
    "vendorBillDate": {
      "type": [
        "string",
        "null"
      ],
      "oneOf": [
        {
          "enum": [
            ""
          ]
        },
        {
          "pattern": "^\\d{4}-(1[0-2]|0[1-9])-(3[01]|0[1-9]|[12]\\d)((T| )([01]\\d|2[0-3]):([0-5]\\d):([0-5]\\d))?$"
        }
      ]
    },
    "vendorBillReference": {
      "type": [
        "string",
        "null"
      ],
      "maxLength": 40
    },
    "currencyCode": {
      "type": [
        "string",
        "null"
      ],
      "maxLength": 3
    },
    "poNumber": {
      "type": [
        "string",
        "null"
      ],
      "maxLength": 25
    },
    "equipmentId": {
      "type": "string",
      "maxLength": 10
    },
    "powerUnitId": {
      "type": "string",
      "maxLength": 10
    },
    "trailerId": {
      "type": "string",
      "maxLength": 10
    },
    "tax1": {
      "type": [
        "number",
        "null"
      ]
    },
    "tax2": {
      "type": [
        "number",
        "null"
      ]
    },
    "payableFunctionalTotal": {
      "type": [
        "number",
        "null"
      ]
    },
    "transactionDate": {
      "type": [
        "string",
        "null"
      ],
      "oneOf": [
        {
          "enum": [
            ""
          ]
        },
        {
          "pattern": "^\\d{4}-(1[0-2]|0[1-9])-(3[01]|0[1-9]|[12]\\d)((T| )([01]\\d|2[0-3]):([0-5]\\d):([0-5]\\d))?$"
        }
      ]
    },
    "payableType": {
      "type": [
        "string",
        "null"
      ],
      "enum": [
        "bill",
        "credit",
        "debit",
        ""
      ]
    },
    "payableHold": {
      "type": [
        "string",
        "null"
      ],
      "enum": [
        "False",
        "True",
        ""
      ]
    },
    "payableTerms": {
      "type": [
        "string",
        "null"
      ],
      "maxLength": 10
    },
    "payableAgingDate": {
      "type": [
        "string",
        "null"
      ],
      "oneOf": [
        {
          "enum": [
            ""
          ]
        },
        {
          "pattern": "^\\d{4}-(1[0-2]|0[1-9])-(3[01]|0[1-9]|[12]\\d)((T| )([01]\\d|2[0-3]):([0-5]\\d):([0-5]\\d))?$"
        }
      ]
    },
    "payableDiscount": {
      "type": [
        "number",
        "null"
      ]
    },
    "payableDiscountDate": {
      "type": [
        "string",
        "null"
      ],
      "oneOf": [
        {
          "enum": [
            ""
          ]
        },
        {
          "pattern": "^\\d{4}-(1[0-2]|0[1-9])-(3[01]|0[1-9]|[12]\\d)((T| )([01]\\d|2[0-3]):([0-5]\\d):([0-5]\\d))?$"
        }
      ]
    },
    "payableDueDate": {
      "type": [
        "string",
        "null"
      ],
      "oneOf": [
        {
          "enum": [
            ""
          ]
        },
        {
          "pattern": "^\\d{4}-(1[0-2]|0[1-9])-(3[01]|0[1-9]|[12]\\d)((T| )([01]\\d|2[0-3]):([0-5]\\d):([0-5]\\d))?$"
        }
      ]
    },
    "glAccount": {
      "type": [
        "string",
        "null"
      ],
      "maxLength": 50,
      "oneOf": [
        {
          "enum": [
            ""
          ]
        },
        {
          "pattern": "^[A-Za-z0-9]+(-[A-Za-z0-9]+){0,4}$"
        }
      ]
    },
    "autoForeignExchange": {
      "type": [
        "string",
        "null"
      ],
      "enum": [
        "False",
        "True",
        ""
      ]
    },
    "isIntercompany": {
      "type": [
        "string",
        "null"
      ],
      "enum": [
        "False",
        "True",
        ""
      ]
    },
    "transactionPosted": {
      "type": [
        "string",
        "null"
      ],
      "enum": [
        "False",
        "True",
        ""
      ]
    },
    "expenses": {
      "type": "array",
      "items": {
        "$ref": "#/$defs/apInvoiceExpense"
      }
    },
    "apDriverDeductions": {
      "type": "array",
      "items": {
        "$ref": "#/$defs/apInvoiceDriverDeduction"
      }
    },
    "ista": {
      "type": "array",
      "items": {
        "$ref": "#/$defs/apInvoiceIsta"
      }
    }
  },
  "$defs": {
    "apInvoiceDriverDeduction": {
      "type": "object",
      "properties": {
        "apInvoiceId": {
          "type": "integer"
        },
        "apDriverDeductionId": {
          "type": "integer"
        },
        "parentApDriverDeductionId": {
          "type": "integer"
        },
        "driverId": {
          "type": "string",
          "maxLength": 10
        },
        "deductionCode": {
          "type": [
            "string",
            "null"
          ],
          "maxLength": 10
        },
        "deductionGlAccount": {
          "type": [
            "string",
            "null"
          ],
          "maxLength": 50
        },
        "deductionQuantity": {
          "type": [
            "number",
            "null"
          ]
        },
        "deductionRate": {
          "type": [
            "number",
            "null"
          ]
        },
        "deductionAmount": {
          "type": [
            "number",
            "null"
          ]
        },
        "deductionFunctionalTotal": {
          "type": [
            "number",
            "null"
          ]
        },
        "deductionReference": {
          "type": [
            "string",
            "null"
          ],
          "maxLength": 40
        },
        "user1": {
          "type": [
            "string",
            "null"
          ],
          "maxLength": 40
        },
        "user2": {
          "type": [
            "string",
            "null"
          ],
          "maxLength": 40
        },
        "user3": {
          "type": [
            "string",
            "null"
          ],
          "maxLength": 40
        }
      }
    },
    "apInvoiceExpense": {
      "type": "object",
      "properties": {
        "apInvoiceId": {
          "type": "integer"
        },
        "expenseId": {
          "type": "integer"
        },
        "expenseGlAccount": {
          "type": [
            "string",
            "null"
          ],
          "maxLength": 50
        },
        "expenseQuantity": {
          "type": [
            "number",
            "null"
          ]
        },
        "expenseRate": {
          "type": [
            "number",
            "null"
          ]
        },
        "expenseAmount": {
          "type": [
            "number",
            "null"
          ]
        },
        "expenseFunctionalTotal": {
          "type": [
            "number",
            "null"
          ]
        },
        "expenseAmountInInvoiceCurrency": {
          "type": [
            "number",
            "null"
          ]
        },
        "expenseBillRate": {
          "type": [
            "number",
            "null"
          ],
          "description": "The expense rate in invoice currency (AP_BILL.CURRENCY_CODE). When present, indicates the bill rate stored for this expense."
        },
        "expenseReference": {
          "type": [
            "string",
            "null"
          ],
          "maxLength": 40
        },
        "resourceType1": {
          "type": [
            "string",
            "null"
          ],
          "enum": [
            "container",
            "driver",
            "miscEquipment",
            "freightBill",
            "interliner",
            "powerUnit",
            "trailer",
            "tripNumber",
            "vendor",
            ""
          ]
        },
        "resourceId1": {
          "type": [
            "string",
            "null"
          ],
          "maxLength": 20
        },
        "resourceType2": {
          "type": [
            "string",
            "null"
          ],
          "enum": [
            "container",
            "driver",
            "miscEquipment",
            "freightBill",
            "interliner",
            "powerUnit",
            "trailer",
            "tripNumber",
            "vendor",
            ""
          ]
        },
        "resourceId2": {
          "type": [
            "string",
            "null"
          ],
          "maxLength": 20
        },
        "user1": {
          "type": [
            "string",
            "null"
          ],
          "maxLength": 40
        },
        "user2": {
          "type": [
            "string",
            "null"
          ],
          "maxLength": 40
        },
        "user3": {
          "type": [
            "string",
            "null"
          ],
          "maxLength": 40
        },
        "user4": {
          "type": [
            "string",
            "null"
          ],
          "maxLength": 40
        },
        "user5": {
          "type": [
            "string",
            "null"
          ],
          "maxLength": 40
        }
      }
    },
    "apInvoiceIsta": {
      "type": "object",
      "properties": {
        "apInvoiceId": {
          "type": "integer"
        },
        "istaId": {
          "type": "integer"
        },
        "istaCode": {
          "type": [
            "string",
            "null"
          ],
          "maxLength": 10
        },
        "istaReference": {
          "type": [
            "string",
            "null"
          ],
          "maxLength": 40
        },
        "istaProvince": {
          "type": [
            "string",
            "null"
          ],
          "maxLength": 10
        },
        "partsAmount": {
          "type": [
            "number",
            "null"
          ]
        },
        "laborAmount": {
          "type": [
            "number",
            "null"
          ]
        },
        "otherAmount": {
          "type": [
            "number",
            "null"
          ]
        },
        "equipmentId": {
          "type": "string",
          "maxLength": 10
        },
        "powerUnitId": {
          "type": "string",
          "maxLength": 10
        },
        "trailerId": {
          "type": "string",
          "maxLength": 10
        }
      }
    }
  }
}