Skip to content

Instantly share code, notes, and snippets.

@framegrabber
Last active November 9, 2020 08:15

Revisions

  1. framegrabber revised this gist Nov 9, 2020. 1 changed file with 3 additions and 1 deletion.
    4 changes: 3 additions & 1 deletion expense.sh
    Original file line number Diff line number Diff line change
    @@ -1,5 +1,7 @@
    #!/usr/bin/env bash

    set -eu -o pipefail

    #Expects the following environment variables to be set
    #EXPENSIFY_PARTNER_USER_ID=
    #EXPENSIFY_PARTNER_USER_SECRET=
    @@ -24,7 +26,7 @@ for offset in "${offsets[@]}"; do
    done

    for date in "${dates[@]}"; do
    curl -X POST "$EXPENSIFY_SERVER/Integration-Server/ExpensifyIntegrations" \
    curl -X POST --fail "$EXPENSIFY_SERVER/Integration-Server/ExpensifyIntegrations" \
    --data-urlencode 'requestJobDescription={
    "type":"create",
    "credentials":{
  2. framegrabber created this gist Nov 12, 2018.
    63 changes: 63 additions & 0 deletions expense.sh
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,63 @@
    #!/usr/bin/env bash

    #Expects the following environment variables to be set
    #EXPENSIFY_PARTNER_USER_ID=
    #EXPENSIFY_PARTNER_USER_SECRET=
    #EXPENSIFY_EMPLOYEE_EMAIL=
    #EXPENSIFY_SERVER="https://integrations.expensify.com"


    offsets=("$@")
    dates=()

    if [ -z "$offsets" ]; then
    echo -n "Enter the offsets in days or weeks (-2w, +1w,…) then press [ENTER]: "
    read -a offsets
    if [ -z "$offsets" ]; then
    offsets=("+0w")
    fi
    fi
    for offset in "${offsets[@]}"; do
    for day in Mon Tue Wed; do
    dates+=( $(date -v "$offset" -v "$day" +%Y-%m-%d) )
    done
    done

    for date in "${dates[@]}"; do
    curl -X POST "$EXPENSIFY_SERVER/Integration-Server/ExpensifyIntegrations" \
    --data-urlencode 'requestJobDescription={
    "type":"create",
    "credentials":{
    "partnerUserID": "'"$EXPENSIFY_PARTNER_USER_ID"'",
    "partnerUserSecret": "'"$EXPENSIFY_PARTNER_USER_SECRET"'"
    },
    "inputSettings":{
    "type":"expenses",
    "employeeEmail": "'"$EXPENSIFY_EMPLOYEE_EMAIL"'",
    "transactionList": [
    {
    "created": "'"$date"'",
    "currency": "EUR",
    "merchant": "20 km @ €0.3 / km",
    "amount": 600,
    "category": "Mileage/Parking/Tolls",
    "tag": "Client Name goes gere:Travel",
    "billable": false,
    "reimbursable": true,
    "comment": "last mile between home and train station in the morning and evening"
    },
    {
    "created": "'"$date"'",
    "currency": "EUR",
    "merchant": "1 * Germany Day Trip > 8 Hours @ €12.00",
    "amount": 1200,
    "category": "Per Diem/Stipend (pre-approved)",
    "tag": "Client Name goes gere:Travel",
    "billable": false,
    "reimbursable": true,
    "comment": "Day at the client office"
    }
    ]
    }
    }'
    done