Write a web service with routes to add point transactions for a payer and timestamp, spend points (oldest points first by transaction timestamp, no payer balance may go negative) returning a list of { "payer", "points" } deductions, and return all payer point balances.
Asked in the take-home stage. Backend Software Engineering coding exercise, any language, reviewer must be able to run it from your docs.
For grading, implement the equivalent pure function below. transactions contains dictionaries with payer, positive points, and integer timestamp. spends contains sequential nonnegative point amounts. Apply all transactions, process each spend, and assume every spend is at most the total available balance. Return { "deductions": [...], "balances": {...} }. Deductions use negative points and combine amounts by payer for each spend.
def process_point_transactions(transactions, spends):