POST
/v2/api/corporate/expenseCode
For corporates that wish to integrate internal trip approval flows with the Expense Code feature, the following process may be followed:
Name | Data Type | Description | Type | Remark |
---|---|---|---|---|
expense_code | string | Expense Code Name | Payload | Mandatory |
capping | map |
Capping
|
Payload | Optional |
scopes | list of objects |
Scopes
|
Payload | Mandatory |
POST
https://devapi.olacabs.com/v2/api/corporate/expenseCode
{
"expense_code": "ExpenseCodeName",
"scopes": [
{
"expense_code_creation_level": "EMPLOYEE",
"expense_code_created_for": "sav@mailinator.com"
},
{
"expense_code_creation_level": "GROUP",
"expense_code_created_for": "Freshers"
},
{
"expense_code_creation_level": "GROUP",
"expense_code_created_for": "SanityGroup"
},
{
"expense_code_creation_level": "CORPORATE",
"expense_code_created_for": null
}
],
"capping": {
"start_time": "12-01-2018 00:19:00",
"end_time": "15-01-2018 12:10:00",
"ride_cap": 10
}
}
Headers: {
X-CORPORATE-TOKEN: fd5d4d3726121212f12ff12f12f1f12f1f12fa
}
{
"expense_code": "ExpenseCodeName",
"expense_code_created": true,
"successful_scopes": 3,
"failed_scopes": 1,
"expense_code_message": "Expense code successfully created",
"expense_code_scope_error_dtos": [
{
"entity_type": "EMPLOYEE",
"entity_created_as": "sav@mailinator.com",
"entity_error": "Successfully Added",
"successful": true
},
{
"entity_type": "GROUP",
"entity_created_as": "Freshers",
"entity_error": "Corporate Group doesn't exist",
"successful": false
},
{
"entity_type": "GROUP",
"entity_created_as": "SanityGroup",
"entity_error": "Successfully Added",
"successful": true
},
{
"entity_type": "CORPORATE",
"entity_created_as": "NA",
"entity_error": "Successfully Added",
"successful": true
}
]
}
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"
}
]
}