Following up on my previous post about the new question I failed on. I summarized it and it goes roughly like this. For part 1, you can look up the parameters and so on elsewhere.
Part 1: Fixed-interval payouts
- You get a list of transactions, each with an id, amount and day, plus a payout_interval.
- A payout happens every payout_interval days.
- Each transaction is put into the next payout day. Transactions that happen on a payout day itself are held until the next period.
- Transactions paid out on the same day are merged into one amount, and their transaction IDs are recorded.
- Output is sorted by payout date, with the amount converted from cents to dollars and kept to two decimal places.
- Payout days with no transactions are not output.
Part 2: Different merchants have different intervals
- Add merchants, each with a name, first_payout and payout_interval. Each transaction now also has a merchant.
- Each merchant pays out on its own schedule, starting from its own first_payout.
- For each transaction, find the next payout day of the merchant it belongs to.
- Aggregate by merchant plus payout day. Different merchants cannot be merged together.
- Output the date, merchant name, total amount and transaction IDs, sorted by date.
Part 3: Add a hold period
- Each merchant gets a hold_days field.
- After a transaction happens, you have to wait hold_days days before it is eligible for payout.
- Find the earliest merchant payout day that satisfies the hold period.
- Aggregation and output are the same as in Part 2.
Discussion
Loading comments…