Skip to content

Instantly share code, notes, and snippets.

@dperconti
Created September 11, 2023 02:37
Show Gist options
  • Save dperconti/0c3ce81c1bea6593e0989ab58ee411f4 to your computer and use it in GitHub Desktop.
Save dperconti/0c3ce81c1bea6593e0989ab58ee411f4 to your computer and use it in GitHub Desktop.
Transaction Data Questions

Financial Transaction Data Manipulation

You are given a list of financial transactions represented as dictionaries, each containing the following information:

  • transaction_id: A unique identifier for the transaction (string).
  • transaction_date: The date when the transaction occurred (string in the format "YYYY-MM-DD").
  • transaction_type: The type of the transaction. Purchases | Reversals | Refunds | Payments
  • reversal_transaction_id: the transaction_id of a reversal
  • amount: The transaction amount in cents (Int).
  • description: A brief description of the transaction (string).

Example Transaction

Full data example HERE.

{
  "transaction_id": "tx_78e3fa01b572",
  "transaction_date": "2023-01-01",
  "transaction_type": "Purchases",
  "amount": 5000,
  "description": "Electronics purchase"
},
{
  "transaction_id": "tx_225a164814a3",
  "transaction_date": "2023-01-02",
  "transaction_type": "Reversals",
  "reversal_transaction_id": "tx_78e3fa01b572",
  "amount": -5000,
  "description": "Merchant reversal"
},

You should write the code snippets or functions that solve each challenge.

Challenges:

  • What is this user's current balance?
  • What is the average cost per purchase?
  • What is the largest transaction?
  • We need to create a list of statements occuring every seven days starting on 2023-01-01.
  • Great - now we need to calculate interest for each of our statements. Let's post that new transaction to each statement.
  • Ok, now we want to give our customers 7 days to pay off their balance before we post the interest to their account statement. How can we adjust for this?
  • Bonus: There appears to be a reversal without a correlating transaction_id. Write a function to find the highest probable match.

Considerations:

  • Aim for efficient algorithms and code readability.
  • Validate and handle edge cases, such as an empty transaction list or handling transactions of the same amount.
  • Clearly define the input and output requirements for each challenge.
  • Explain your approach to solving these challenges and any relevant considerations. Take your time to think through the problem before writing the code snippets or functions for each challenge. Feel free to ask any clarifying questions if needed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment