Are you receiving SNAP/EBT benefits? The Expensify.org/SNAP-VAX campaign is live and accepting new members. Learn more about receiving $50 for submitting a SNAP receipt and $50 for getting your COVID-19 vaccine here and join today!

Reimbursable expense not being created correctly using API template

InnovAsian
InnovAsian Expensify Customer Posts: 20 Expensify Newcomer
edited March 2020 in Integrations and API

I have used this template to download many approved expense reports. It is failing to capture the "Merchant" and "Amount" for certain expense reports.
The Merchant is showing as "(none)" in the export CSV and the Amount is "0".
The expense report has 2 expenses, both marked as reimbursable.

I can use the "Export To CSV" when viewing the report in the web interface and the CSV is correct. Using the CURL call does create a file via sFTP, but the contents are incorrect.

Template file:

<#assign reportNumber = 1>
<#assign reportHdr = 0>
<#assign expenseNumber = 1>
<#list reports as report>
    ${reportNumber},<#t>
    ${reportHdr},<#t>
    ${report.reportID},<#t>
    ${report.reportName},<#t>
    ${report.submitter.fullName},<#t>
    ${report.accountEmail},<#t>
    ${report.approved},<#t>
    ${report.submitterUserID},<#t>
    ${report.currency},<#t>
    ${report.status},<#t>
    ${report.total}<#lt>
    <#list report.transactionList as expense>
        ${reportNumber},<#t>
        ${expenseNumber},<#t>
        ${report.reportID},<#t>
        ${expense.created},<#t>
        ${expense.transactionID},<#t>
        ${expense.type},<#t>
        ${expense.category},<#t>
        ${expense.categoryGlCode},<#t>
        ${report.submitterUserID},<#t> 
        ${expense.comment},<#t>
        ${expense.merchant},<#t>
        ${expense.receiptObject.url},<#t>
        ${expense.reimbursable?string},<#t>
        ${expense.amount},<#t>
        ${expense.attendees},<#t>
        ${expense.bank}<#lt>
        <#assign expenseNumber = expenseNumber + 1>
    </#list>
    <#assign reportNumber = reportNumber + 1>
    <#assign expenseNumber = 1>
</#list>

Best Answer

  • InnovAsian
    InnovAsian Expensify Customer Posts: 20 Expensify Newcomer
    edited March 2020 Accepted Answer

    And the answer is:
    Use the ${expense.modifiedMerchant},<#t> and ${expense.modifiedAmount},<#t>.

    If a user creates a receipt using Smartscan and it fails, then the original Merchant, date and Amount are blank. The user has to fix them to create a real receipt. This makes them the "modified" values.

    You have to use get all the fields and use the "modified" if it is not null, else use the normal field.

    If you do an Export To using the web interface, it gives you the resulting value.

    Vote Up this post so other customers can find it!