Identifying Split Expenses via API

Options
Mahlon
Mahlon Expensify Customer Posts: 5 Expensify Newcomer

We currently use the report exporter to generate a report containing expenses from Expensify. Those reports generally work quite well, offering us access to the invoices' costs, the submitter, receipts, etc.

We're now having trouble with expenses which have been split within Expensify. We're seeing that when an expense is split in Expensify, each of the split instances appears in the report as separate expenses. However, each of those instances' price appears in the report as the total, original cost. For example:

  • Take an expense for $100
  • Split the expense evenly, resulting in two expenses for $50 each
  • Pull the expense report via API; you'll see two separate expenses for $100 each

I'm wondering whether anyone's found a way to identify these split expenses and accurately identify their individual costs via the report exporter?

Best Answer

  • Ted Harris
    Ted Harris Expensify Success Coach - Admin, Expensify Team, Expensify Student Ambassador Posts: 359 Expensify Team
    edited November 2018 Answer ✓
    Options

    Hi @Mahlon, thanks for posting in the Expensify Community! It's great to have you here.

    I suspect you might possibly be exporting the expense.amount for each of these expenses, rather than the expense.modifiedAmount which will export the most recent amount attributed to these expenses.

    If this is the case, we'd definitely recommend assigning a value to the amount and using the below logic to calculate the amount of each expense:

    <#if expense.convertedAmount?has_content>
                <#assign amount = expense.convertedAmount/100>
    <#elseif expense.modifiedAmount?has_content>
                <#assign amount = expense.modifiedAmount/100>
    <#else>
                <#assign amount = expense.amount/100>
    </#if>
    

    Note: The below is incorrect and clarified below in this post.

    Other than that, if you're just looking to identify expenses which have been split from one another, a useful nugget of information might be that for split expenses, the expense.receiptID will always be the same for both.

Answers

  • Mahlon
    Mahlon Expensify Customer Posts: 5 Expensify Newcomer
    Options

    Thanks for the info, Ted!

    You're absolutely correct; we were referring to the expense.amount for these split expenses, rather than the expense.modifiedAmount, expecting that the split expenses' expense.amount would reflect the split amount, since that's the original amount assigned to that expense. We're getting the correct numbers now that we're using the expense.modifiedAmount.

    The expense.receiptID being the same is otherwise exactly what we needed in order to identify these split expenses! When we pull expenses, we're storing their details outside of Expensify for reporting purposes, so we need to ensure that for split expenses we're removing the original, un-split version of the expense so that we don't double up. This ID will allow us to identify the original and split versions of the expense, and can easily identify and remove the original expense by its amount being the largest.

  • PhilD
    PhilD Expensify Customer Posts: 1 Expensify Newcomer
    Options

    Hey @Ted Peeters I have a quick question about your API documents and just wanted to confirm something. On the section for the transaction level (expense) there is a field called Split which states whether or not the transaction originated from a split expense action.

    When checking the templates for the report exporter, the split field is not there? Is there any way of enabling it or does it not exist. It would be super helpful to have this field when dealing with split expenses!

    Cheers, Phil

  • Ted Harris
    Ted Harris Expensify Success Coach - Admin, Expensify Team, Expensify Student Ambassador Posts: 359 Expensify Team
    edited November 2018
    Options

    Hi @Mahlon and @PhilD - A quick update here after I spoke with one of our engineers and I have to backtrack on some of my advice - I'm so sorry!

    I previously stated that:

    the expense.receiptID will always be the same for both [transactions split from one expense]

    ...but I have to now inform you I was wrong. When they're split expenses, the receipt ID's will actually be sequential, incrementing by 1 for each split.

    The expense.receiptFilename is the value which will stay the same.

    Note: If you split one of the already split expenses, this will create a new set of incrementing receiptIDs which won't follow on from the original split expenses.

    The expense.amount for all of these will be the same though. Only the expense.modifiedAmount will have updated for each of them.

    All of this doesn't however mean I'm any closer to getting you an answer about the Split field. I'll get back to you as soon as I have an answer on that.

  • Mahlon
    Mahlon Expensify Customer Posts: 5 Expensify Newcomer
    Options

    Thanks for clarifying, @Ted Peeters .

    We'd originally looked at expense.receiptFilename as a way to identify split expenses which referred to the same receipt. However, we had a few concerns which led to us looking at the receiptID instead. I'm hoping that you can clarify a couple of details around those concerns:

    • You mentioned that receiptFilename will remain the same when an expense is split. Does that mean that the split expenses continue to refer to the same file, or is a copy of that file created in a separate folder (since files in the same folder can't share the same name)?
    • For expenses which do not include an image of the receipt, would receiptFilename be populated? If it's populated as (null), how could we differentiate between two separate expenses which were split, but did not include an image?
  • Mahlon
    Mahlon Expensify Customer Posts: 5 Expensify Newcomer
    Options
  • Sheena Trepanier
    Sheena Trepanier Expensify Team, Approved! Accountant, Expensify Student Ambassador Posts: 1,362 Expensify Team
    Options

    Hi @Mahlon, thanks for bumping this. I'll get to work finding some answers for you and will update this thread as soon as I can.

  • Ted Harris
    Ted Harris Expensify Success Coach - Admin, Expensify Team, Expensify Student Ambassador Posts: 359 Expensify Team
    Options

    Hi @Mahlon - sorry for missing this. I recently tagged you in the post where we managed to get to the bottom of Split expenses here.

    Did you still any pending questions on this?

    To quickly answer the latest few:

    • For expenses which do not include an image of the receipt, you're correct that there would be no receiptFilename
    • Split expenses both refer to the same receiptFilename
  • Branda
    Branda Expensify Customer Posts: 1
    Options

    The link to the post "where we managed to get to the bottom of the Split expenses here" is no longer a live link for me. Can you please tell me how to see that support article?

  • Conor Pendergrast
    Conor Pendergrast Expensify Success Coach - Admin, Expensify Team, Expensify Student Ambassador Posts: 175 Expensify Team
    Options

    @Branda it looks like that post may live a retired section of the Community!

    @Ted Harris I know it's been four years; do you have any member of that discussion, and if it's been moved or deleted? Thanks!