Skip to main content
Back to Prompt Library
implementation

Build the application

Inspect the original prompt language first, then copy or adapt it once you know how it fits your workflow.

Linked challenge: Build an SME Trade Invoice Reconciliation and Document Correction Pipeline

Format
Code-aware
Lines
97
Sections
11
Linked challenge
Build an SME Trade Invoice Reconciliation and Document Correction Pipeline

Prompt source

Original prompt text with formatting preserved for inspection.

97 lines
11 sections
No variables
1 code block
## Build
Reconcile commercial invoices against Singapore GST requirements, purchase orders, and proof-of-delivery receipts. Detect price drift and missing tax registration details to generate structured correction notices.

## User
SME Treasury Accountant

## Workflow
1. Extract structured line items, seller UEN, and GST breakdown from normalized SME commercial invoices.
2. Cross-check unit quantities and extended totals against matching delivery orders and purchase orders.
3. Calculate GST computation discrepancies and flag missing or malformed Singapore tax registration numbers.
4. Generate an itemized invoice reconciliation summary and formal vendor document correction notice.

## Interface
A split-screen web reconciliation ledger displaying invoice fields, matched purchase order lines, discrepancy badges, and an editable correction draft.

## Data
Generate synthetic JSON invoice datasets with deliberate calculation errors and mock Singapore UEN numbers in a local test suite.
Starter examples below are synthetic. They are not downloaded records.

## Source
[Singapore open data API](https://guide.data.gov.sg/developer-guide/api-overview)
Utilize data.gov.sg dataset search schema specifications to format tabular financial reconciliation records.

## Tools
pydantic-ai, fastapi, pytest.
Pydantic AI guarantees type-strict schema parsing and deterministic validation for invoice arithmetic and tax IDs.
Hosted general LLM with strong mathematical and table extraction reliability.

## Deliverables
Submit runnable source, pinned dependencies, setup commands, a working interface, example outputs, and a recorded end-to-end demo. Include tests and an action log.

## Acceptance
- Identifies unit price variances exceeding pre-set SME tolerance thresholds.
- Verifies that 9% Singapore GST is applied correctly across taxable sub-totals.
- Synthesizes structured correction notices citing specific mismatched line items.
- Maintains audit logs of human approvals for corrected invoice ledgers.

## Starter Examples
```json
[
  {
    "input": {
      "invoice_id": "INV-SG-2025-01",
      "seller_uen": "201812345M",
      "subtotal_amount": 1000,
      "gst_rate": 0.09,
      "stated_gst": 90,
      "stated_total": 1090,
      "po_reference": "PO-8812",
      "po_expected_total": 1090,
      "po_items": [
        {
          "item_id": "IT-1",
          "qty": 10,
          "unit_price": 100
        }
      ]
    },
    "expected_output": {
      "status": "reconciled",
      "math_discrepancy": 0,
      "gst_discrepancy": 0,
      "line_item_matches": true,
      "action_required": "ready_for_payment_batching",
      "correction_notice": null
    }
  },
  {
    "input": {
      "invoice_id": "INV-SG-2025-02",
      "seller_uen": "INVALID_UEN",
      "subtotal_amount": 5000,
      "gst_rate": 0.09,
      "stated_gst": 400,
      "stated_total": 5400,
      "po_reference": "PO-9910",
      "po_expected_total": 5450,
      "po_items": [
        {
          "item_id": "IT-2",
          "qty": 50,
          "unit_price": 100
        }
      ]
    },
    "expected_output": {
      "status": "discrepancy_flagged",
      "math_discrepancy": 50,
      "gst_discrepancy": 50,
      "line_item_matches": false,
      "action_required": "vendor_correction_requested",
      "correction_notice": {
        "invoice_id": "INV-SG-2025-02",
        "issues": [
          "Stated GST of 400.00 does not match calculated 9% GST of 450.00",
          "Seller UEN format is malformed",
          "Stated total 5400.00 differs from expected PO total 5450.00"
        ]
      }
    }
  }
]
```

## Safety
Executes accounting reconciliation and draft generation only; does not disburse bank payments.
Use mock external writes. Require human review before any real deployment.

Adaptation plan

Keep the source stable, then change the prompt in a predictable order so the next run is easier to evaluate.

Keep stable

Hold the task contract and output shape stable so generated implementations remain comparable.

Tune next

Update libraries, interfaces, and environment assumptions to match the stack you actually run.

Verify after

Test failure handling, edge cases, and any code paths that depend on hidden context or secrets.