+1

How to get details (unit, quantity, price) from customer invoice api?

erika hohn 6 years ago in API updated by mark 5 years ago 9

I can't get details about the jobs using customer invoice api. I need information as unit, quantity and price and not only the total gross.

+1

We'd love to get that too. We assumed it wasn't possible with the current api and spent time developing macros to export this data. Having said that, we'd LOVE to see this available via api.

Mark,

Sorry for asking, but what is the complexity to develop macros to obtain invoice details, both customer and vendors? And how was to get information neeed from XTRF? Because the XTRF team ask us if our technical person has an experience with running macros via API and if knows parameters need to be given and how to convert macro`s info.

Thank you in advance!

Best regards,

Erika

I don't know the details of why... but I know that the API is limited in what fields are available and accessible. And we've never tried to run macros via API, so I don't have any knowledge of that. I would like to learn more though.

Hi Erika, Mark,

Sorry to say, this is not yet available in XTRF API. I can see that such improvement is requested by has no version assigned yet. 

Hello Bartosz,

I had a response from the XTRF team that is working on a customization for us. 

Mateusz replied that although Get in Invoice did not bring the details, we can get into Project.

Do you know how we can get this from Project? The example he sent is below, but I did not find a GET that returns this in the documentation.

{
"currencyId": 2,
"totalAgreed": 36.8,
"totalCost": 3,
"profit": 33.8,
"margin": 0.92,
"receivables": [
{
"id": 1404,
"jobTypeId": 14,
"languageCombination": {
"sourceLanguageId": 7,
"targetLanguageId": 3
},
"languageCombinationIdNumber": "task_stab-82 - 2019/354/AR-DZ » AF/1",
"rateOrigin": "FILLED_MANUALLY",
"currencyId": 2,
"total": 0,
"invoiceId": null,
"type": "SIMPLE",
"calculationUnitId": 1,
"ignoreMinimumCharge": false,
"minimumCharge": null,
"description": "",
"rate": 0,
"quantity": 4
},
{
"id": 3971,
"jobTypeId": 37,
"languageCombination": {
"sourceLanguageId": 7,
"targetLanguageId": 3
},
"languageCombinationIdNumber": "task_stab-82 - 2019/354/AR-DZ » AF/1",
"rateOrigin": "FILLED_MANUALLY",
"currencyId": 2,
"total": 36.8,
"invoiceId": null,
"type": "CAT",
"calculationUnitId": 1,
"ignoreMinimumCharge": false,
"minimumCharge": null,
"description": "",
"totalQuantity": 61,
"weightedQuantity": 18.4,
"baseRate": 2,
"rateType": "PERCENTAGE",
"catGrid": "OTHER",
"rates": {
"PERCENT_85_94": 60,
"X_TRANSLATED": 0,
"PERCENT_50_74": 100,
"NO_MATCH": 100,
"PERCENT_95_99": 30,
"PERCENT_100": 30,
"PERCENT_75_84": 60,
"REPETITIONS": 30
},
"quantities": {
"PERCENT_85_94": 0,
"X_TRANSLATED": 31,
"PERCENT_50_74": 1,
"NO_MATCH": 0,
"PERCENT_95_99": 0,
"PERCENT_100": 0,
"PERCENT_75_84": 29,
"REPETITIONS": 0
}
}
],
"payables": [
{
"id": 3379,
"jobTypeId": 1,
"languageCombination": {
"sourceLanguageId": 7,
"targetLanguageId": 3
},
"languageCombinationIdNumber": "task_stab-82 - 2019/354/AR-DZ » AF/1",
"rateOrigin": "FILLED_MANUALLY",
"currencyId": 2,
"total": 3,
"invoiceId": null,
"type": "SIMPLE",
"calculationUnitId": 1,
"ignoreMinimumCharge": false,
"minimumCharge": null,
"description": "aaa",
"rate": 1,
"quantity": 3,
"jobId": "BR42BM3IEBAODFX5ABVZWCFRCU"
},

I think the easiest way is to create a View with all the values that you need (unit, quantity, price) and then retrieve this View through the Browser API. That thing is pretty powerful.

I didn't think you can get invoicing details on a project view. Am I wrong?

But I know that you can't get task or project details on the invoice view. So that wouldn't work. 

If you can get invoicing details at the task level in a view, I'd love to learn how!

You could play around with the Custom Columns and add whatever you like.

I have created this little snippet to show you how to get all the invoice items from the invoice of a project to your project view. 

##loop through the tasks of a single quote
#foreach($task in $this.tasks)
    #if($task.invoice) ##if there is an invoice
        <b>Task invoice $task.invoice.id</b>
        ##loop through the invoice items
        #foreach($invoiceItem in $task.invoice.invoiceItems)          
<br />$invoiceItem.name
<br />$invoiceItem.quantity ($invoiceItem.unit) * $invoiceItem.rate = $invoiceItem.lineNetto
        #end
    #end
#end

In contrary to what you think, you can add project details to the invoice view.

Here is a little snippet that I use to show all the project ID's that are added to an invoice:

#set($projectIds = $utils.createNewArrayList())
#foreach($task in $utils.unwrap($this).getTasks())
#set($projectId = $task.getProject().projectId)
#if(!$projectIds.contains($projectId))
#set($temp = $projectIds.add($projectId))
#end
#end
#foreach($p in $projectIds)$p
#end
+1

I will be playing around with this later this week. I'm excited to give this a try. This is very helpful! Thanks Dennis. I appreciate it!! I'm so glad to be shown that I'm wrong. :)