Update Expense Code


PUT /v2/api/corporate/expenseCode

Use this Api to update an existing expense code.


Request Parameters

Name Data Type Description Type Remark
expense_code string Expense Code Name Payload Mandatory
capping map

Capping

  • start_time (Date), format:"dd-MM-yyyy hh:mm:ss"
  • end_time (Date), should be greater than start_date and same format
  • ride_cap (Integer), Should be > 0
Payload Optional
scopes list of objects

Scopes

  • expense_code_creation_level (string), values are case sensitive and allowed - { CORPORATE/GROUP/EMPLOYEE }, Mandatory
  • expense_code_created_for (string), Mandatory for GROUP and EMPLOYEE
Payload Mandatory
  • Example Request

    PUT

    https://devapi.olacabs.com/v2/api/corporate/expenseCode

    
        {
          "expense_code": "ExpenseCodeName",
          "capping": {
            "start_time": "12-01-2017 00:18:02",
            "end_time": "13-02-2018 00:20:01",
            "ride_cap": 1000
          }
        }
    
        Headers: {
          X-CORPORATE-TOKEN: fd5d4d3726121212f12ff12f12f1f12f1f12fa
        }
    
    

    Example Response (Success)

    
        {
          "expense_code": "ExpenseCodeName",
          "expense_code_created": true,
          "successful_scopes": 0,
          "failed_scopes": 0,
          "expense_code_message": "expense code updated successfully, use PATCH method if u wish to update the affiliated scopes",
          "expense_code_scope_error_dtos": []
        }
    
    

    Example Responses (Failures)

    • Invalid expense_code_creation_level

        expense_code_creation_level should be one of the following: CORPORATE GROUP EMPLOYEE
          {
            "code": 400,
            "message": "Unable to process JSON"
          }
      
    • Invalid expense code

        Expense code cannot be null
          {
            "errors": [
            "expense_code can not be null"
            ]
          }
      
    • Invalid expense_code_created_for

        expense_code_created_for should be null when expense_code_creation_level is CORPORATE expense_code_created_for should not be null when expense_code_creation_level is GROUP or EMPLOYEE
          {
            "errors": [
              "Invalid expense_code_created_for : expense_code_created_for should be null for corporate,expense_code_created_for should not be null for group/employee"
            ]
          }
      
    • expense code already exists for entity

        Request:
          [
            {
              "expense_code": "EXPENSECODE",
              "expense_code_creation_level": "CORPORATE",
              "expense_code_created_for": null
            },
            {
              "expense_code": "EXPENSECODE",
              "expense_code_creation_level": "GROUP",
              "expense_code_created_for": "Manager Group"
            },
            {
              "expense_code": "EXPENSECODE",
              "expense_code_creation_level": "EMPLOYEE",
              "expense_code_created_for": "employee@corporate.com"
            }
          ]
      
        Response:
          {
            "created_count": 0,
            "error_count": 3,
            "error_messages": [
              {
                "expense_code_creation_level": "CORPORATE",
                "expense_code_created_for": null,
                "expense_code": "EXPENSECODE",
                "message": "Expense code EXPENSECODE already exists for CORPORATE"
              },
              {
                "expense_code_creation_level": "GROUP",
                "expense_code_created_for": "Manager Group",
                "expense_code": "EXPENSECODE",
                "message": "Expense code EXPENSECODE already exists for Manager Group"
              },
              {
                "expense_code_creation_level": "EMPLOYEE",
                "expense_code_created_for": "employee@corporate.com",
                "expense_code": "EXPENSECODE",
                "message": "Expense code EXPENSECODE already exists for employee@corporate.com"
              }
            ]
          }
      
      
    • expense code is too long

        Request:
          [
            {
              "expense_code": "THIS EXPENSE CODE IS TOO LONG LET'S HAVE A SMALLER EXPENSE CODE",
              "expense_code_creation_level": "CORPORATE",
              "expense_code_created_for": null
            }
          ]
      
        Response:
          {
            "created_count": 0,
            "error_count": 1,
            "error_messages": [
              {
                "expense_code_creation_level": "CORPORATE",
                "expense_code_created_for": null,
                "expense_code": "THIS EXPENSE CODE IS TOO LONG LET'S HAVE A SMALLER EXPENSE CODE",
                "message": "Expense code THIS EXPENSE CODE IS TOO LONG LET'S HAVE A SMALLER EXPENSE CODE should be less than 50 characters"
              }
            ]
          }
      
      
    • expense_code_created_for does not exists

        Request:
          [
            {
              "expense_code": "EXPENSECODE",
              "expense_code_creation_level": "GROUP",
              "expense_code_created_for": "Wrong Group"
            },
            {
              "expense_code": "EXPENSECODE",
              "expense_code_creation_level": "EMPLOYEE",
              "expense_code_created_for": "wrong.employee"
            }
          ]
      
        Response:
          {
            "created_count": 0,
            "error_count": 2,
            "error_messages": [
              {
                "expense_code_creation_level": "GROUP",
                "expense_code_created_for": "Wrong Group",
                "expense_code": "EXPENSECODE",
                "message": "Corporate Group not found with given name"
              },
              {
                "expense_code_creation_level": "EMPLOYEE",
                "expense_code_created_for": "wrong.employee",
                "expense_code": "EXPENSECODE",
                "message": "Corporate User not found with given email address"
              }
            ]
          }