Cost summary / Flex
The push and documents/{id}/contents/push/preview methods have an optional includeCost parameter.
If this parameter is set, then the system will return the calculated cost of work with the result of aforesaid methods.
For this to work you will need to enable costing and add prices. Check out this page: Costing / Flex
How to request a cost summary
To get a cost preview, call the push/preview method like below. No data is updated as the API method name suggests.
(POST) /api/apps/wbflex/documents/{id}/contents/push/preview?includeCost=true
When pushing content you can also ask the system to include the cost.
(POST) /api/apps/wbflex/documents/{id}/contents/push?includeCost=true
To rather obtain pricing information (unit prices, discounts), check out this method: documents/{id}/pricing (GET)
Result
The cost information will be included in the result of the push or push/preview method under the result/cost node.
An example is shown below. The root shows the total cost including VAT (totalInc) and excluding VAT (totalEx) for the work. The lines array gives detailed information.
{
"cost": {
"success": true,
"message": null,
"messageCode": null,
"trgsCosted": [
{
"v": "de",
"t": "German (de)"
},
{
"v": "fr",
"t": "French (fr)"
}
],
"data": {
"totalEx": 16.0,
"totalExBase": 16.0,
"totalInc": 16.0,
"vatRate": 18.0,
"vatAmount": 2.88,
"currency": "EUR",
"currencys": "€",
"decimals": 4,
"contract": "",
"lines": [
{
"src": "en",
"srct": "English (en)",
"trg": "de",
"trgt": "German (de)",
"task": null,
"taskt": null,
"summary": "WM-11069.wbflex \nTranslation 8 Words, EUR 1.00 per Word = 8 EUR\n",
"total": 8.0,
"totalBase": 8.0
},
{
"src": "en",
"srct": "English (en)",
"trg": "fr",
"trgt": "French (fr)",
"task": null,
"taskt": null,
"summary": "WM-11069.wbflex \nTranslation 8 Words, EUR 1.00 per Word = 8 EUR\n",
"total": 8.0,
"totalBase": 8.0
}
]
}
}
}
The individual properties of the result/cost node are:
success | If false then cost cannot be shown or calculated. See Costing error messages / Flex for all details. | bool |
message | If success is false, the error message and code. See Costing error messages / Flex | string? |
trgsCosted | The list of all target locales that require work and are costed. In most but not all cases this will be all the Flex document locales. | string[] |
data | This object contains the actual cost information. NOTE: If success is false then this node will be null. | object? |
The data object contains these properties:
totalEx | The total amount excluding VAT. | decimal |
totalExBase | The total amount excl. VAT and before any discounts. | decimal |
totalInc | Total amount including VAT. | decimal |
vatRate | Applicable VAT rate in percent. This is 0 if none is required. Configured in the client company record. | decimal |
vatAmount | Total VAT amount. | decimal |
currency | The currency code. | string |
currencys | The one-letter currency symbol. | string |
decimals | Decimals used for amounts. This is configured in the client price list. | int |
contract | Optional contract information. Configured in the client company record. | string |
lines | The “invoice” details lines, see below. | object[] |
Each lines object has these properties:
src, srct | Source language code and name. | string, string |
trg, trgt | Target language code and name. | string, string |
task, taskt | Task code and name. Such as: “TR” and “Translation”. Task codes can be retrieved by API: settings/tasks/codes | string, string |
summary | The user readable summary. Generally these fields are sufficient to show in a user interface for each line:
| string |
total | Subtotal excl. VAT of this line. | decimal |
totalBase | Subtotal prior to applying any discounts. | decimal |
Invoice documents
The above information is the exact same that is used to create the client invoice in the project.
When you enable costing in a project, you get both the feature to retrieve cost and the automatic creation of client invoices in the project.