• Automation script for reconciling marketplace payments with orders and returns (Ozon/WB) with anomaly detection

    20 hours ago
    • Desired budget up to 420.78 USD
    • Waiting for a performer...
  • Initial situation
    There is a small e-commerce project: sales are made through marketplaces (Ozon and Wildberries), orders are kept in PostgreSQL (its own database), payments come once a week and often do not match due to returns, partial compensation, logistics adjustments and fines. Now reconciliation is done manually in Excel and takes 4-6 hours per payment; errors appear months later.

    Technical environment and data
    - Ubuntu 22.04 server, access via SSH
    - PostgreSQL 14 (read-only user access)
    - Python 3.11 (venv can be used), Git
    - Data sources:
    - Payments: CSV/XLSX uploads from your personal account (files are placed in the folder /data/payouts/ozon and /data/payouts/wb)
    - Orders/returns: tables in PostgreSQL (orders, returns, payments_expected) with fields order_id, sku, sale_price, commission, logistics_fee, created_at, status, etc.
    - Exchange rates are not needed (everything is in RUB), but there are different types of transactions (sale, return, retention, adjustment)

    Task
    Make a reliable script that pays out for each upload:
    - Parses the file, normalizes operations into a single model (sale/return/fee/penalty/adjustment)
    - Matches payment lines with orders and returns from the database according to a set of keys (order_id, posting_number, sku, date and amount, with acceptable deviations)
    - Calculates the expected amounts according to the rules (commission, logistics, deductions) and compares them with the actual
    - Generates a reconciliation report and a list of discrepancies with reasons
    - Notes anomalies (e.g. repeated deductions on the same order, unusual fines, negative logistics, returns without the original sale)

    Restrictions
    - You cannot store tokens/passwords in code - only through environment variables or .env (file in .gitignore)
    - The script must work offline for uploads (without marketplace APIs)
    - Marketplace releases periodically change column names - column mapping configuration via YAML/JSON is required
    - Processing time: no more than 10 minutes for payouts of up to 200,000 lines on a machine with 4 CPU and 8 GB RAM

    Result stages
    1) CLI utility (example: python -m payout_reconcile --market wb --file /data/payouts/wb/2024-10-01.xlsx --out /reports/)
    2) Module for normalization and mapping of columns via config
    3) Matching module with custom rules and matching quality report
    4) Report generation:
    - Final CSV: for each order_id - expected/actual/delta, discrepancy type, matching status
    - Separate CSV with payout lines that could not be matched
    - A short summary in JSON for further sending to Slack (without Slack integration)
    5) A set of autotests (pytest) for at least 10 cases: sale, full refund, partial refund, adjustment, fine, duplicate operation, skipping a column, changing the name of a column, discrepancy in amount within tolerance, discrepancy above tolerance

    Acceptance criteria (measurable)
    - On the provided set of 3 real payments (one large and two medium), the script completes without errors
    - The share of matched payment lines is not lower than 98% (the rest are included in the report as unassigned with a reason)
    - For 20 pre-marked orders, the script should show the correct delta (expected-fact) and correctly classify the reason for the discrepancy in at least 18 cases
    - Repeated run on the same data gives identical results (determinism)
    - The repository has a README with launch instructions, an example of a mapping config and a description of the output report format

    What will I provide?
    - Examples of 3 payout uploads (impersonal)
    - Access to PostgreSQL (read-only) and table schema description
    - A table with rules for calculating expected amounts in the current accounting logic (as is currently calculated in Excel)

    Stack wishes
    Python: pandas/polars for reading files, SQLAlchemy/psycopg, pydantic for models, typer/click for CLI, pytest. It is acceptable to offer alternatives if justified by performance.
  • How would you rate this task?

    Sign in to leave your rating.

    Total ratings: 1

Your offer

You have not submitted an offer for this order yet.
Click “Submit an offer” to send your offer.

Need a similar task?

If this project is close to your need, you can view ready services in the category or post your own task with the required budget, deadline and requirements.

The project «Automation script for reconciling marketplace payments with orders and returns (Ozon/WB) with anomaly detection» can be used as a reference for your own brief: what should be done, what result is needed and what budget to set.