Dataset Viewer
Auto-converted to Parquet Duplicate
prompt
listlengths
1
1
completion
listlengths
1
1
meta
dict
[ { "role": "user", "content": "Implement a strict double-entry bookkeeping journal using frozen dataclasses and precise Decimal arithmetic (standard library only). A `Posting` holds an account code (matching the pattern `^\\d{2}(-\\d{2}){0,2}$`, e.g. `10-10`) and a `Decimal` amount that is positive for debit...
[ { "role": "assistant", "content": "from __future__ import annotations\n\nimport re\nfrom collections import OrderedDict\nfrom dataclasses import dataclass, field\nfrom datetime import date\nfrom decimal import Decimal, ROUND_HALF_EVEN\nfrom typing import Optional, Tuple\n\nCENT = Decimal(\"0.01\")\nACCOUNT_...
{ "idx": 3404, "topic": "accounting record dataclasses and schemas", "difficulty": "hard", "provider": "together", "in_tokens": 0, "out_tokens": 2690, "latency_s": 125.6 }
[ { "role": "user", "content": "You are given a CSV file `transactions.csv` where each row contains: date (YYYY-MM-DD), account (string), description (string), and amount (a decimal string in dollars, e.g. '123.45', possibly negative). Write a program that (1) reads the CSV, (2) validates each row: the date m...
[ { "role": "assistant", "content": "import csv\nfrom datetime import datetime\nfrom decimal import Decimal, ROUND_HALF_UP, InvalidOperation\n\nINPUT_FILE = 'transactions.csv'\nVALID_FILE = 'valid_transactions.csv'\nREPORT_FILE = 'validation_report.txt'\n\n\ndef validate_date(date_str):\n try:\n dat...
{ "idx": 3177, "topic": "transaction CSV import, validation, and export", "difficulty": "medium", "provider": "together", "in_tokens": 0, "out_tokens": 820, "latency_s": 2.2 }
[ { "role": "user", "content": "A bookkeeper must reconcile an amortizing loan ledger. Given a principal P (a Decimal amount), a nominal annual interest rate r (Decimal, e.g. 0.05 for 5%), and a number of monthly payments n (integer), produce the full amortization schedule using exact Decimal arithmetic with ...
[ { "role": "assistant", "content": "from decimal import Decimal, ROUND_HALF_UP\n\nCENT = Decimal('0.01')\n\ndef cents(x):\n return Decimal(x).quantize(CENT, rounding=ROUND_HALF_UP)\n\ndef amortize(principal, annual_rate, n):\n principal = Decimal(principal)\n annual_rate = Decimal(annual_rate)\n ...
{ "idx": 3299, "topic": "interest calculation and payment schedules", "difficulty": "medium", "provider": "together", "in_tokens": 0, "out_tokens": 690, "latency_s": 8.5 }
[ { "role": "user", "content": "A small agency processes sales invoices and must split each invoice's total into three parts: a 12% commission for the salesperson, an 8% tip for the support staff pool, and the remainder for the company. Because money must be tracked to the cent, all arithmetic uses Decimal wi...
[ { "role": "assistant", "content": "from decimal import Decimal, ROUND_HALF_UP\n\n\ndef split_invoices(invoices):\n \"\"\"Split invoice totals into commission, tip, and company portions.\n\n Args:\n invoices: list of (invoice_id, total_string) pairs.\n\n Returns:\n (entries, totals) wh...
{ "idx": 1498, "topic": "commission, tip, and percentage splits", "difficulty": "medium", "provider": "together", "in_tokens": 0, "out_tokens": 936, "latency_s": 7.8 }
[ { "role": "user", "content": "A restaurant's bookkeeping software must post each paid invoice to a ledger, splitting the gross amount into a house commission, a tip pool divided among the servers, and the net revenue. Write a function `split_invoice(amount, commission_rate, tip_rate, servers)` where `amount...
[ { "role": "assistant", "content": "from decimal import Decimal, ROUND_HALF_UP\n\n\ndef split_invoice(amount, commission_rate, tip_rate, servers):\n \"\"\"Split a gross invoice into commission, tip shares, and net revenue.\n\n All amounts are Decimals quantized to two decimal places (ROUND_HALF_UP).\n ...
{ "idx": 3109, "topic": "commission, tip, and percentage splits", "difficulty": "medium", "provider": "novita", "in_tokens": 199, "out_tokens": 1639, "latency_s": 16.2 }
[ { "role": "user", "content": "You maintain a simple double-entry ledger where each transaction is a list of (account, amount) lines, and the sum of amounts in a transaction must equal zero (debits positive, credits negative). Occasionally a transaction is entered incorrectly: it must be corrected by a 'reve...
[ { "role": "assistant", "content": "from decimal import Decimal, ROUND_HALF_UP\n\n\ndef apply_corrections(entries, corrections):\n balances = {}\n\n def check_and_post(lines):\n if sum((amt for _, amt in lines), Decimal('0')) != 0:\n raise ValueError('transaction does not balance to z...
{ "idx": 1858, "topic": "correcting entries, reversals, and voided transactions", "difficulty": "medium", "provider": "together", "in_tokens": 0, "out_tokens": 733, "latency_s": 2.1 }
[ { "role": "user", "content": "Write a function `monthly_amortization_schedule(principal, annual_rate, years)` that builds a fixed-payment mortgage amortization schedule using Python's `decimal.Decimal` for exact monetary arithmetic. The monthly interest rate is `annual_rate / 12` (no compounding adjustment)...
[ { "role": "assistant", "content": "from decimal import Decimal, ROUND_HALF_UP\n\nCENT = Decimal('0.01')\n\ndef _round(x):\n return x.quantize(CENT, rounding=ROUND_HALF_UP)\n\ndef monthly_amortization_schedule(principal, annual_rate, years):\n principal = Decimal(str(principal))\n annual_rate = Deci...
{ "idx": 1568, "topic": "loan and mortgage amortization schedules", "difficulty": "easy", "provider": "together", "in_tokens": 0, "out_tokens": 705, "latency_s": 4.9 }
[ { "role": "user", "content": "A bookkeeper needs to validate a chart of accounts and categorize expense entries. You are given a chart of accounts as a list of tuples (account_number, account_name, normal_balance) where normal_balance is 'debit' or 'credit', and a list of journal entries as tuples (account_...
[ { "role": "assistant", "content": "from decimal import Decimal, ROUND_HALF_UP\nfrom collections import defaultdict\n\n\ndef categorize_expenses(chart, entries):\n names = {}\n for account_number, account_name, _ in chart:\n names[account_number] = account_name\n\n totals = defaultdict(lambda...
{ "idx": 1411, "topic": "chart of accounts and expense categorization", "difficulty": "medium", "provider": "together", "in_tokens": 0, "out_tokens": 720, "latency_s": 6.2 }
[ { "role": "user", "content": "A small business keeps its ledger on a cash basis but needs a month-end accrual adjustment report. You are given a list of invoices (each with an invoice date, an amount, and a boolean indicating whether it has been paid) and a list of payments (each with a payment date and amo...
[ { "role": "assistant", "content": "from decimal import Decimal, ROUND_HALF_UP\nfrom datetime import date\n\n\ndef accrual_adjustment(invoices, payments, cutoff):\n cutoff_date = date.fromisoformat(cutoff)\n\n total_invoiced = sum(\n (Decimal(amount) for _, amount in invoices),\n Decimal(...
{ "idx": 189, "topic": "accrual versus cash basis adjustments", "difficulty": "easy", "provider": "together", "in_tokens": 0, "out_tokens": 550, "latency_s": 43.6 }
[ { "role": "user", "content": "Build a small command-line FIFO cost-basis bookkeeping tool. The program reads commands from standard input, one per line: `LOT <date> <qty> <price> <fee>` records a purchase lot where the lot's cost basis is `qty*price + fee`; `SELL <date> <qty> <price> <fee>` sells shares, co...
[ { "role": "assistant", "content": "import sys\nfrom decimal import Decimal, ROUND_HALF_EVEN\n\nCENT = Decimal(\"0.01\")\nZERO = Decimal(\"0\")\n\n\ndef q(amount):\n \"\"\"Quantize to cents with banker's rounding for display only.\"\"\"\n return amount.quantize(CENT, rounding=ROUND_HALF_EVEN)\n\n\nclas...
{ "idx": 2087, "topic": "small bookkeeping command-line tool logic", "difficulty": "hard", "provider": "together", "in_tokens": 0, "out_tokens": 1176, "latency_s": 7.8 }
[ { "role": "user", "content": "You are building a settlement report for a multi-currency accounting journal. Each transaction in the journal consists of a currency code, a total amount given as a decimal string, and a list of (account_id, weight) pairs with positive integer weights; the total must be split a...
[ { "role": "assistant", "content": "from decimal import Decimal, ROUND_HALF_UP, ROUND_HALF_EVEN, getcontext\nfrom collections import defaultdict\n\ngetcontext().prec = 50\n\nCURRENCY_RULES = {\n \"USD\": (ROUND_HALF_UP, Decimal(\"0.01\")),\n \"CHF\": (ROUND_HALF_EVEN, Decimal(\"0.01\")),\n \"JPY\": ...
{ "idx": 392, "topic": "currency rounding rules with the Decimal type", "difficulty": "hard", "provider": "together", "in_tokens": 0, "out_tokens": 1526, "latency_s": 58.4 }
[ { "role": "user", "content": "You are maintaining a simple multi-currency ledger. Each transaction is given as a tuple (currency, amount) where amount is a Decimal that may be positive (a debit/receivable) or negative (a credit/payable). Your company reports in USD, and you are given a dictionary of exchang...
[ { "role": "assistant", "content": "from decimal import Decimal, ROUND_HALF_UP\n\ndef total_usd(transactions, rates, base_rates):\n current_total = Decimal('0')\n base_total = Decimal('0')\n for currency, amount in transactions:\n rate = rates.get(currency, Decimal('1'))\n base_rate = ...
{ "idx": 3286, "topic": "multi-currency conversion and FX gain/loss", "difficulty": "easy", "provider": "together", "in_tokens": 0, "out_tokens": 628, "latency_s": 5.5 }
[ { "role": "user", "content": "Write a function `apply_sales_tax(amounts, rate)` that applies sales tax (or VAT) to a list of pre-tax invoice line amounts and returns the tax amounts, correctly rounded to the nearest cent. Each line amount is given as a string like '19.99' to avoid float issues, and the tax ...
[ { "role": "assistant", "content": "from decimal import Decimal, ROUND_HALF_UP\n\nTWO_PLACES = Decimal('0.01')\n\ndef apply_sales_tax(amounts, rate):\n tax_rate = Decimal(rate) / Decimal('100')\n results = []\n total = Decimal('0')\n for amount_str in amounts:\n amount = Decimal(amount_str...
{ "idx": 2038, "topic": "sales tax and VAT computation and rounding", "difficulty": "easy", "provider": "together", "in_tokens": 0, "out_tokens": 379, "latency_s": 1.6 }
[ { "role": "user", "content": "Implement an append-only ledger that maintains an immutable audit trail for a small business. Each entry is a dictionary with a sequential id (starting at 1), a date string 'YYYY-MM-DD', a description, a Decimal amount (positive for debit, negative for credit), and a SHA-256 ha...
[ { "role": "assistant", "content": "import hashlib\nfrom decimal import Decimal, ROUND_HALF_UP\n\n\nclass ImmutableLedger:\n GENESIS = 'GENESIS'\n\n def __init__(self):\n self.entries = []\n self._prev_hash = self.GENESIS\n\n @staticmethod\n def _canonical(date, description, amount)...
{ "idx": 1790, "topic": "audit trails and immutable entry logs", "difficulty": "medium", "provider": "baseten", "in_tokens": 199, "out_tokens": 842, "latency_s": 7.8 }
[ { "role": "user", "content": "At period end, a bookkeeper must generate closing entries from a trial balance of temporary (nominal) accounts. Given a dictionary mapping account names to balances (as strings, debit-positive for expenses, credit-positive for revenues, i.e. revenues > 0 and expenses < 0), prod...
[ { "role": "assistant", "content": "from decimal import Decimal, ROUND_HALF_UP\n\n\ndef two_places(value):\n return value.quantize(Decimal('0.01'), rounding=ROUND_HALF_UP)\n\n\ndef generate_closing_entries(trial_balance):\n \"\"\"Generate period-end closing entries from a trial balance of nominal accou...
{ "idx": 1294, "topic": "period-end closing entries and routines", "difficulty": "medium", "provider": "together", "in_tokens": 0, "out_tokens": 920, "latency_s": 14.5 }
[ { "role": "user", "content": "Write a function `compute_net_pay(gross, federal_rate, state_rate, pre_tax_deductions)` that computes a payroll check for one employee. The gross pay, the federal withholding rate, the state withholding rate, and a list of pre-tax deduction amounts (e.g., health insurance premi...
[ { "role": "assistant", "content": "from decimal import Decimal, ROUND_HALF_UP\n\nCENT = Decimal('0.01')\n\n\ndef _round_to_cent(value):\n return value.quantize(CENT, rounding=ROUND_HALF_UP)\n\n\ndef compute_net_pay(gross, federal_rate, state_rate, pre_tax_deductions):\n gross = Decimal(gross)\n fed...
{ "idx": 3207, "topic": "payroll calculations, withholdings, and deductions", "difficulty": "easy", "provider": "novita", "in_tokens": 200, "out_tokens": 894, "latency_s": 9.4 }
[ { "role": "user", "content": "A small firm records its transactions in a ledger and wants a fiscal-quarter report. Each ledger entry is a tuple (iso_date, description, amount) where amount is a Decimal in cents, e.g. Decimal('150.00'). The firm's fiscal year equals the calendar year, so fiscal quarters are ...
[ { "role": "assistant", "content": "import calendar\nfrom datetime import date\nfrom decimal import Decimal, ROUND_HALF_UP\n\n\ndef month_end(year, month):\n \"\"\"Return the last calendar day of the given month as a datetime.date.\"\"\"\n last_day = calendar.monthrange(year, month)[1]\n return date...
{ "idx": 52, "topic": "fiscal periods, quarters, and month-end date utilities", "difficulty": "medium", "provider": "together", "in_tokens": 0, "out_tokens": 1014, "latency_s": 11.5 }
[ { "role": "user", "content": "A small business keeps a simple ledger of transactions. Each transaction is recorded as a tuple (id, type, amount) where type is one of 'sale', 'purchase', 'reversal', or 'void'. A 'sale' adds to the net balance, a 'purchase' subtracts from it. A 'reversal' cancels out a previo...
[ { "role": "assistant", "content": "from decimal import Decimal, ROUND_HALF_UP\n\ndef compute_net(transactions):\n \"\"\"Compute the net balance from a chronological ledger of transactions.\n\n Each transaction is a tuple (id, type, amount):\n - 'sale': adds amount to the net balance\n -...
{ "idx": 3451, "topic": "correcting entries, reversals, and voided transactions", "difficulty": "easy", "provider": "together", "in_tokens": 0, "out_tokens": 1212, "latency_s": 16.6 }
[ { "role": "user", "content": "Implement a small general-ledger engine with exact monetary arithmetic. First, write allocate(total, weights): split the money string total proportionally according to a list of Decimal weight strings by computing each exact share at 50-digit precision, rounding each share to c...
[ { "role": "assistant", "content": "from decimal import Decimal, ROUND_HALF_UP, getcontext\nfrom collections import OrderedDict\n\ngetcontext().prec = 50\nCENT = Decimal(\"0.01\")\n\n\ndef allocate(total, weights):\n \"\"\"Split `total` proportionally by `weights`, cent-accurate, zero drift.\"\"\"\n to...
{ "idx": 3683, "topic": "general ledger and T-account operations", "difficulty": "hard", "provider": "together", "in_tokens": 0, "out_tokens": 1686, "latency_s": 67.4 }
[ { "role": "user", "content": "Write a function `process_payroll(employee_records, tax_brackets, standard_deduction)` that computes net pay for a list of employees and produces a payroll register. Each employee record is a dict with keys `name`, `gross_wages` (a string like '5250.75'), `pretax_401k` (a strin...
[ { "role": "assistant", "content": "from decimal import Decimal, ROUND_HALF_UP\n\nTWO = Decimal('0.01')\n\n\ndef _money(value):\n return Decimal(value).quantize(TWO, rounding=ROUND_HALF_UP)\n\n\ndef _federal_tax(taxable_income, standard_deduction, brackets):\n income = taxable_income - Decimal(str(stan...
{ "idx": 1567, "topic": "payroll calculations, withholdings, and deductions", "difficulty": "medium", "provider": "together", "in_tokens": 0, "out_tokens": 896, "latency_s": 16.9 }
[ { "role": "user", "content": "You are maintaining a small loan ledger. A loan of principal P is repaid with N equal monthly payments (annuity), computed with monthly interest rate r (as a Decimal, e.g. '0.01' for 1%). The payment amount is PMT = P * r / (1 - (1+r)**(-N)), rounded to the nearest cent with RO...
[ { "role": "assistant", "content": "from decimal import Decimal, ROUND_HALF_UP\n\nCENT = Decimal('0.01')\n\ndef _round(x):\n return x.quantize(CENT, rounding=ROUND_HALF_UP)\n\ndef amortize(principal, rate, months):\n P = Decimal(principal)\n r = Decimal(rate)\n n = int(months)\n one = Decimal(...
{ "idx": 2981, "topic": "interest calculation and payment schedules", "difficulty": "medium", "provider": "together", "in_tokens": 0, "out_tokens": 579, "latency_s": 5.6 }
[ { "role": "user", "content": "Implement a function `process_transactions(input_csv, output_csv)` that imports a CSV of double-entry bookkeeping journal lines, validates them, applies them to running account balances, and exports a formatted ledger.\n\nThe input CSV must have exactly the header `entry_id,dat...
[ { "role": "assistant", "content": "import csv\nimport re\nfrom collections import OrderedDict, defaultdict\nfrom datetime import date\nfrom decimal import Decimal\n\nEXPECTED_HEADER = [\"entry_id\", \"date\", \"account\", \"debit\", \"credit\", \"memo\"]\nAMOUNT_RE = re.compile(r\"^\\d+(?:\\.\\d{1,2})?$\")\...
{ "idx": 33, "topic": "transaction CSV import, validation, and export", "difficulty": "hard", "provider": "together", "in_tokens": 0, "out_tokens": 2230, "latency_s": 39.6 }
[ { "role": "user", "content": "You are given a list of ledger transactions, each represented as a tuple (tx_id, date, description, amount) where amount is a string like '123.45' (positive = debit, negative = credit). Write a function `flag_suspicious(transactions)` that returns a list of tx_ids flagged as su...
[ { "role": "assistant", "content": "from decimal import Decimal\n\n\ndef flag_suspicious(transactions):\n flagged = []\n seen = set() # (date, description, amount) exact keys\n seen_reversible = set() # (date, description, amount) for reversed-sign check\n\n for tx_id, date, description...
{ "idx": 3758, "topic": "detecting duplicate or anomalous transactions", "difficulty": "medium", "provider": "novita", "in_tokens": 198, "out_tokens": 834, "latency_s": 9 }
[ { "role": "user", "content": "You are building an expense categorizer for a small business. You are given a chart of accounts as a dict mapping 4-digit account codes (strings) to account names, a list of expense entries, and a set of keyword mappings. Each entry is a dict with keys 'description' (string) an...
[ { "role": "assistant", "content": "from decimal import Decimal, ROUND_HALF_UP\n\n\ndef build_expense_report(chart, entries, mappings):\n \"\"\"Categorize expense entries against a chart of accounts and produce a summary report.\"\"\"\n CENT = Decimal(\"0.01\")\n\n def to_cents(value):\n retu...
{ "idx": 3964, "topic": "chart of accounts and expense categorization", "difficulty": "medium", "provider": "novita", "in_tokens": 199, "out_tokens": 2711, "latency_s": 28.9 }
[ { "role": "user", "content": "You are building a perpetual inventory valuation engine for a bookkeeping system. Given a chronological list of transactions, where each transaction is a tuple (\"BUY\", quantity, unit_cost) or (\"SELL\", quantity, unit_price), write a function inventory_report(transactions) th...
[ { "role": "assistant", "content": "from decimal import Decimal, ROUND_HALF_UP\n\nCENT = Decimal(\"0.01\")\nZERO = Decimal(\"0\")\n\n\ndef _round_to_cent(amount):\n return amount.quantize(CENT, rounding=ROUND_HALF_UP)\n\n\ndef _cost_from_front(layers, qty):\n \"\"\"Remove qty units from the oldest laye...
{ "idx": 2588, "topic": "inventory valuation (FIFO, LIFO, weighted average)", "difficulty": "hard", "provider": "together", "in_tokens": 0, "out_tokens": 1434, "latency_s": 103.7 }
[ { "role": "user", "content": "Implement a small ledger module with a function `post_and_balance(entries)` that validates and posts journal entries to a ledger and returns the final balance per account. Each entry is a tuple `(account, amount)` where `amount` is a Decimal or a string convertible to Decimal; ...
[ { "role": "assistant", "content": "import unittest\nfrom decimal import Decimal, InvalidOperation, ROUND_HALF_UP\n\nCENT = Decimal('0.01')\n\n\ndef _to_money(value):\n try:\n d = Decimal(str(value))\n except (InvalidOperation, ValueError, TypeError) as exc:\n raise ValueError(f\"invalid ...
{ "idx": 1860, "topic": "unit tests for accounting functions", "difficulty": "medium", "provider": "together", "in_tokens": 0, "out_tokens": 1034, "latency_s": 3 }
[ { "role": "user", "content": "Build a FIFO capital-gains calculator for a small bookkeeping tool. The input consists of one trade per line in the format 'BUY <qty> <price> <fee>' or 'SELL <qty> <price> <fee>', where qty is an integer number of shares and price/fee are decimal money amounts; all arithmetic m...
[ { "role": "assistant", "content": "import sys\nfrom decimal import Decimal, ROUND_HALF_UP\n\nCENT = Decimal(\"0.01\")\n\n\ndef q(value):\n return value.quantize(CENT, rounding=ROUND_HALF_UP)\n\n\ndef process(lines):\n lots = [] # each lot: [remaining_qty, price, remaining_fee]\n outputs = []\n ...
{ "idx": 2163, "topic": "small bookkeeping command-line tool logic", "difficulty": "hard", "provider": "together", "in_tokens": 0, "out_tokens": 1165, "latency_s": 11.7 }
[ { "role": "user", "content": "Implement payroll_report(salary, k401_rate, health_pp) that builds a full-year semimonthly (24 pay periods) payroll ledger for one employee as a JSON-serializable dict. Per-period gross is salary/24 rounded half-up to cents; the employee contributes k401_rate of salary to a 401...
[ { "role": "assistant", "content": "from decimal import Decimal, ROUND_HALF_UP\n\nCENT = Decimal(\"0.01\")\nPERIODS = 24\n\nBRACKETS = [\n (Decimal(\"11000\"), Decimal(\"0.10\")),\n (Decimal(\"44725\"), Decimal(\"0.12\")),\n (Decimal(\"95375\"), Decimal(\"0.22\")),\n (Decimal(\"182100\"), Decimal...
{ "idx": 1343, "topic": "payroll calculations, withholdings, and deductions", "difficulty": "hard", "provider": "together", "in_tokens": 0, "out_tokens": 1867, "latency_s": 117.4 }
[ { "role": "user", "content": "Implement an append-only audit ledger for a small bookkeeping office. Each entry is a tuple (date, description, amount) where amount is a Decimal in dollars, positive for debits (charges) and negative for credits (payments). The ledger must be immutable: implement a class Audit...
[ { "role": "assistant", "content": "from decimal import Decimal, ROUND_HALF_UP\nimport hashlib\n\nclass AuditLedger:\n def __init__(self):\n self._entries = [] # list of dicts: date, description, amount, hash\n\n def add_entry(self, date, description, amount):\n amount = Decimal(amount)\...
{ "idx": 667, "topic": "audit trails and immutable entry logs", "difficulty": "medium", "provider": "together", "in_tokens": 0, "out_tokens": 782, "latency_s": 24.2 }
[ { "role": "user", "content": "A small business keeps its ledger on a cash basis but wants a month-end accrual adjustment for unpaid bills. Given a list of expenses, each with a date (YYYY-MM-DD string), an amount (string, may include cents), and a 'paid' status (True/False), write a function accrual_adjustm...
[ { "role": "assistant", "content": "from decimal import Decimal, ROUND_HALF_UP\n\ndef accrual_adjustment(expenses):\n cash = Decimal('0')\n accrual = Decimal('0')\n for _date, amount, paid in expenses:\n amt = Decimal(amount)\n accrual += amt\n if paid:\n cash += amt\...
{ "idx": 1907, "topic": "accrual versus cash basis adjustments", "difficulty": "easy", "provider": "together", "in_tokens": 0, "out_tokens": 371, "latency_s": 1.5 }
[ { "role": "user", "content": "A boutique agency processes weekly invoices and must split each invoice's total into three parts: an agent commission (a given percentage of the invoice total), a processing fee (a given percentage of the invoice total), and the remainder to the client's ledger balance. All mon...
[ { "role": "assistant", "content": "from decimal import Decimal, ROUND_HALF_UP\n\nCENT = Decimal('0.01')\n\n\ndef split_invoices(invoices, commission_pct, fee_pct):\n cp = Decimal(commission_pct) / Decimal('100')\n fp = Decimal(fee_pct) / Decimal('100')\n per_invoice = {}\n total_commission = Dec...
{ "idx": 989, "topic": "commission, tip, and percentage splits", "difficulty": "medium", "provider": "together", "in_tokens": 0, "out_tokens": 843, "latency_s": 3.8 }
[ { "role": "user", "content": "Implement a double-entry bookkeeping engine. A journal entry is a dict with an 'id' and a list of lines; each line has 'account' (str), 'debit' (str) and 'credit' (str) representing money amounts as decimal strings. A journal entry is valid only if (1) every line has exactly on...
[ { "role": "assistant", "content": "from decimal import Decimal\n\n\ndef post(entries):\n ledger = {}\n posted = []\n rejected = []\n\n def line_amount(line):\n d = Decimal(line['debit'])\n c = Decimal(line['credit'])\n return d, c\n\n def two_places_ok(x):\n # exac...
{ "idx": 486, "topic": "double-entry journal entries and posting rules", "difficulty": "medium", "provider": "together", "in_tokens": 0, "out_tokens": 813, "latency_s": 7.9 }
[ { "role": "user", "content": "Write a function `reconcile(bank_lines, ledger_lines)` that reconciles a bank statement against a cash ledger. Both inputs are lists of tuples: `(date_str, description, amount_str)` where `amount_str` is a decimal string, positive for deposits/debits in your favor and negative ...
[ { "role": "assistant", "content": "from decimal import Decimal\nfrom collections import Counter\n\n\ndef reconcile(bank_lines, ledger_lines):\n \"\"\"Reconcile a bank statement against a cash ledger.\n\n Each line is (date, description, amount_str). Lines match one-for-one\n when date, description,...
{ "idx": 2945, "topic": "bank statement reconciliation", "difficulty": "easy", "provider": "together", "in_tokens": 0, "out_tokens": 911, "latency_s": 10.8 }
[ { "role": "user", "content": "Write a command-line bookkeeping tool that processes ledger entries from stdin and prints a balance report. Each input line is one of: 'DEPOSIT <account> <amount>', 'WITHDRAW <account> <amount>', or 'TRANSFER <from> <to> <amount>', where amounts are decimal strings with up to 2...
[ { "role": "assistant", "content": "import sys\nfrom decimal import Decimal, ROUND_HALF_UP, InvalidOperation\n\nTWO = Decimal('0.01')\n\n\ndef q(value):\n return value.quantize(TWO, rounding=ROUND_HALF_UP)\n\n\ndef main():\n balances = {}\n for raw in sys.stdin:\n line = raw.strip()\n ...
{ "idx": 341, "topic": "small bookkeeping command-line tool logic", "difficulty": "medium", "provider": "together", "in_tokens": 0, "out_tokens": 700, "latency_s": 6.2 }
[ { "role": "user", "content": "A small business posts a monthly rent expense that recurs on the same day of every month. Given a start date, a number of occurrences, a monthly amount, and the ledger account name, generate the recurring journal entries and compute the total posted. Rules: each entry has a dat...
[ { "role": "assistant", "content": "import calendar\nfrom datetime import date\nfrom decimal import Decimal, ROUND_HALF_UP\n\ndef generate_recurring_entries(start_str, occurrences, amount_str, account_name):\n start = date.fromisoformat(start_str)\n day = start.day\n amount = Decimal(amount_str).qua...
{ "idx": 1743, "topic": "recurring and calendar-based postings", "difficulty": "easy", "provider": "together", "in_tokens": 0, "out_tokens": 506, "latency_s": 1.6 }
[ { "role": "user", "content": "A petty cash fund starts with a fixed imprest amount (e.g., $100.00). Each disbursement reduces the cash on hand; at month end the fund is replenished back to the imprest amount. Write a function `petty_cash_report(imprest, entries)` where `imprest` is a string like '100.00' an...
[ { "role": "assistant", "content": "from decimal import Decimal, ROUND_HALF_UP\n\ndef petty_cash_report(imprest, entries):\n TWO = Decimal('0.01')\n def q(x):\n return x.quantize(TWO, rounding=ROUND_HALF_UP)\n imp = Decimal(imprest)\n total_disb = Decimal('0')\n for date, desc, amt in e...
{ "idx": 2195, "topic": "petty cash logs and replenishment", "difficulty": "easy", "provider": "together", "in_tokens": 0, "out_tokens": 435, "latency_s": 2.3 }
[ { "role": "user", "content": "You are given a bookkeeping ledger as CSV text with the header `txn_id,date,account,description,amount`, where each row is a single posting and all rows sharing a `txn_id` form one journal transaction. Write a function `analyze_ledger(csv_text)` that returns a report with three...
[ { "role": "assistant", "content": "import csv\nimport io\nimport json\nimport re\nfrom datetime import datetime\nfrom decimal import Decimal, ROUND_HALF_EVEN\n\nTWO_PLACES = Decimal(\"0.01\")\nTHRESHOLD = Decimal(\"10000.00\")\nMULTIPLE = Decimal(\"1000.00\")\n\n\ndef normalize_description(text):\n \"\"\...
{ "idx": 1080, "topic": "detecting duplicate or anomalous transactions", "difficulty": "hard", "provider": "together", "in_tokens": 0, "out_tokens": 1555, "latency_s": 147 }
[ { "role": "user", "content": "Implement a `JournalEntry` dataclass and a `Ledger` class for a simple double-entry bookkeeping system. Each `JournalEntry` has a `date` (string 'YYYY-MM-DD'), `description` (string), and a list of `Line` objects, where each `Line` has an `account` (string), a `debit` (Decimal,...
[ { "role": "assistant", "content": "from dataclasses import dataclass, field\nfrom decimal import Decimal, ROUND_HALF_UP\nfrom typing import List\n\n\n@dataclass\nclass Line:\n account: str\n debit: Decimal = Decimal('0')\n credit: Decimal = Decimal('0')\n\n\n@dataclass\nclass JournalEntry:\n dat...
{ "idx": 3206, "topic": "accounting record dataclasses and schemas", "difficulty": "easy", "provider": "novita", "in_tokens": 198, "out_tokens": 840, "latency_s": 8.7 }
[ { "role": "user", "content": "Write a function `validate_journal_entry(lines)` that checks whether a double-entry journal entry balances. Each line is a tuple `(account, debit, credit)` where debit and credit are strings representing money amounts (e.g. '150.00'). The function must use `decimal.Decimal` for...
[ { "role": "assistant", "content": "from decimal import Decimal, ROUND_HALF_UP\n\ndef validate_journal_entry(lines):\n total_debits = Decimal('0')\n total_credits = Decimal('0')\n for account, debit_s, credit_s in lines:\n debit = Decimal(debit_s)\n credit = Decimal(credit_s)\n ...
{ "idx": 770, "topic": "double-entry journal entries and posting rules", "difficulty": "easy", "provider": "together", "in_tokens": 0, "out_tokens": 474, "latency_s": 2.1 }
[ { "role": "user", "content": "You are maintaining a small accounting ledger in which every monetary amount must be stored as a Decimal rounded to exactly 2 decimal places. Entries arrive as raw strings that may have any number of decimal digits (e.g. '10.005', '3.7', '-0.125'), and each entry is either a cr...
[ { "role": "assistant", "content": "from decimal import Decimal, ROUND_HALF_UP\n\nTWO_PLACES = Decimal('0.01')\n\ndef apply_entries(entries):\n total = Decimal('0.00')\n largest_debit = Decimal('0.00')\n count = 0\n for sign, amount_str in entries:\n amount = Decimal(amount_str).quantize(T...
{ "idx": 3819, "topic": "currency rounding rules with the Decimal type", "difficulty": "medium", "provider": "together", "in_tokens": 0, "out_tokens": 538, "latency_s": 9.6 }
[ { "role": "user", "content": "A bookkeeper must produce a loan amortization schedule using precise decimal arithmetic. Given a loan principal P, an annual nominal interest rate r (compounded monthly), and a term of n months, compute the level monthly payment using the standard annuity formula payment = P * ...
[ { "role": "assistant", "content": "from decimal import Decimal, ROUND_HALF_UP, getcontext\n\ngetcontext().prec = 28\n\nCENT = Decimal('0.01')\n\n\ndef to_cent(value):\n return value.quantize(CENT, rounding=ROUND_HALF_UP)\n\n\ndef amortize(principal, annual_rate, months):\n principal = Decimal(principa...
{ "idx": 3380, "topic": "interest calculation and payment schedules", "difficulty": "medium", "provider": "together", "in_tokens": 0, "out_tokens": 677, "latency_s": 36.8 }
[ { "role": "user", "content": "You are given a bank statement (list of transactions) and an internal ledger for the same period. Each transaction is a tuple (date, description, amount) where amount is a string like '123.45' or '-50.00' (negative = withdrawal, positive = deposit). Each ledger entry is a tuple...
[ { "role": "assistant", "content": "from decimal import Decimal, ROUND_HALF_UP\nfrom collections import defaultdict\n\n\ndef _parse(entry):\n date, desc, amount = entry\n return (date, desc, Decimal(amount))\n\n\ndef reconcile(statement, ledger, starting_balance):\n stmt = [_parse(e) for e in statem...
{ "idx": 3024, "topic": "bank statement reconciliation", "difficulty": "medium", "provider": "together", "in_tokens": 0, "out_tokens": 753, "latency_s": 2.6 }
[ { "role": "user", "content": "A restaurant records its nightly tip pool and must distribute it among staff according to fixed percentage shares: servers get 70%, kitchen staff 20%, and the host 10%. Write a function distribute_tips(total_cents, shares) where total_cents is an integer amount in cents and sha...
[ { "role": "assistant", "content": "from decimal import Decimal, ROUND_HALF_UP\n\n\ndef distribute_tips(total_cents, shares):\n total_pct = sum(Decimal(str(p)) for p in shares.values())\n if total_pct != Decimal('100'):\n raise ValueError('shares must sum to exactly 100')\n\n total = Decimal(...
{ "idx": 3468, "topic": "commission, tip, and percentage splits", "difficulty": "medium", "provider": "together", "in_tokens": 0, "out_tokens": 668, "latency_s": 6.5 }
[ { "role": "user", "content": "Write a Python function `reconcile_ledger(entries)` for a small bookkeeping CLI tool. Each entry is a tuple `(date, description, amount)` where `date` is a string 'YYYY-MM-DD', `description` is a string, and `amount` is a string representing a decimal number (e.g. '123.45', '-5...
[ { "role": "assistant", "content": "from decimal import Decimal, ROUND_HALF_UP, InvalidOperation\nfrom datetime import datetime\n\n\ndef reconcile_ledger(entries):\n valid = []\n for date, description, amount in entries:\n try:\n datetime.strptime(date, '%Y-%m-%d')\n except (Va...
{ "idx": 540, "topic": "small bookkeeping command-line tool logic", "difficulty": "medium", "provider": "together", "in_tokens": 0, "out_tokens": 612, "latency_s": 27.6 }
[ { "role": "user", "content": "Write a function `depreciation_schedule(cost, salvage, useful_life, rate=None)` that builds a depreciation schedule for an asset using the straight-line method (when `rate` is None) or the declining-balance method (when `rate` is given as a decimal fraction, e.g. 0.4 for 40%). ...
[ { "role": "assistant", "content": "from decimal import Decimal, ROUND_HALF_UP\n\n\ndef _q(value):\n return Decimal(value).quantize(Decimal('0.01'), rounding=ROUND_HALF_UP)\n\n\ndef depreciation_schedule(cost, salvage, useful_life, rate=None):\n cost = _q(cost)\n salvage = _q(salvage)\n schedule ...
{ "idx": 3081, "topic": "depreciation schedules (straight-line, declining balance)", "difficulty": "easy", "provider": "novita", "in_tokens": 201, "out_tokens": 710, "latency_s": 8.4 }
[ { "role": "user", "content": "Implement an append-only ledger for a small bookkeeping system. Each entry records an account name, a description, and a signed Decimal amount (credits positive, debits negative). To guarantee immutability, entries are hash-chained: entry 0 has a `prev_hash` of 'GENESIS', and e...
[ { "role": "assistant", "content": "import hashlib\nfrom decimal import Decimal, ROUND_HALF_UP\n\nTWO = Decimal('0.01')\n\n\nclass Ledger:\n def __init__(self):\n self._entries = [] # each: dict(index, prev_hash, account, description, amount, hash)\n\n @staticmethod\n def _canonical(index, p...
{ "idx": 3378, "topic": "audit trails and immutable entry logs", "difficulty": "medium", "provider": "together", "in_tokens": 0, "out_tokens": 839, "latency_s": 2.7 }
[ { "role": "user", "content": "Define a dataclass JournalEntry with fields date (str), description (str), debit_account (str), credit_account (str), and amount (Decimal, exactly 2 decimal places). Write a function validate_entries(entries) that returns a list of entry indices (0-based) which are invalid: an ...
[ { "role": "assistant", "content": "import re\nfrom dataclasses import dataclass\nfrom decimal import Decimal, ROUND_HALF_UP\n\n\n@dataclass\nclass JournalEntry:\n date: str\n description: str\n debit_account: str\n credit_account: str\n amount: Decimal\n\n def is_valid(self):\n if n...
{ "idx": 898, "topic": "accounting record dataclasses and schemas", "difficulty": "easy", "provider": "together", "in_tokens": 0, "out_tokens": 673, "latency_s": 3.9 }
[ { "role": "user", "content": "Write a function `aging_report(invoices, as_of)` that produces an accounts receivable/payable aging report. Each invoice is a dict with keys `id` (str), `due_date` (a `datetime.date`), and `amount` (a `Decimal` representing the outstanding balance, always non-negative). `as_of`...
[ { "role": "assistant", "content": "from datetime import date\nfrom decimal import Decimal, ROUND_HALF_UP\n\nBUCKETS = ['current', '1-30', '31-60', '61-90', '90+']\n\n\ndef aging_report(invoices, as_of):\n totals = {b: Decimal('0') for b in BUCKETS}\n for inv in invoices:\n amount = inv['amount'...
{ "idx": 3935, "topic": "accounts receivable and payable aging reports", "difficulty": "medium", "provider": "together", "in_tokens": 0, "out_tokens": 613, "latency_s": 6.4 }
[ { "role": "user", "content": "Write a function `aging_report(invoices, as_of)` that produces an accounts receivable/payable aging report. Each invoice is a dict with keys 'id' (str), 'customer' (str), 'due_date' (datetime.date), and 'amount' (Decimal, always positive). `as_of` is a datetime.date. An invoice...
[ { "role": "assistant", "content": "from decimal import Decimal, ROUND_HALF_UP\nfrom datetime import date\n\nBUCKETS = ['Current', '1-30', '31-60', '61-90', 'Over 90']\n\n\ndef aging_report(invoices, as_of):\n bucket_totals = {b: Decimal('0.00') for b in BUCKETS}\n customer_totals = {}\n\n for inv i...
{ "idx": 3550, "topic": "accounts receivable and payable aging reports", "difficulty": "medium", "provider": "together", "in_tokens": 0, "out_tokens": 778, "latency_s": 11.6 }
[ { "role": "user", "content": "At period end, a bookkeeper must post a single closing entry that zeroes out each revenue and expense account (temporary accounts) and transfers the net difference to the 'Retained Earnings' account (an equity account). Given a dictionary of account balances where keys are acco...
[ { "role": "assistant", "content": "from decimal import Decimal, ROUND_HALF_UP\n\nTWO = Decimal('0.01')\n\n\ndef _round2(amount):\n return amount.quantize(TWO, rounding=ROUND_HALF_UP)\n\n\ndef closing_entry(balances):\n \"\"\"Compute the period-end closing entry for temporary accounts.\n\n Args:\n ...
{ "idx": 31, "topic": "period-end closing entries and routines", "difficulty": "easy", "provider": "together", "in_tokens": 0, "out_tokens": 986, "latency_s": 14.8 }
End of preview. Expand in Data Studio

No dataset card yet

Downloads last month
70

Models trained or fine-tuned on gsultani/glm53-bookkeeping-python-distill