Metadata-Version: 2.4
Name: sinapsis-bank-reconciliation
Version: 0.1.0
Summary: Sinapsis templates for bank/ERP reconciliation and LLM adjudication of fuzzy reference matches.
Project-URL: Homepage, https://sinapsis.tech
Project-URL: Documentation, https://docs.sinapsis.tech/docs
Project-URL: Tutorials, https://docs.sinapsis.tech/tutorials
Project-URL: Repository, https://github.com/Corteza-ai/sinapsis-bank-reconciliation.git
Requires-Python: >=3.10
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: pandas>=2.0.0
Requires-Dist: sinapsis>=0.2.26
Dynamic: license-file

<h1 align="center">
<br>
<a href="https://sinapsis.tech/">
  <img
    src="https://github.com/Sinapsis-AI/brand-resources/blob/main/sinapsis_logo/4x/logo.png?raw=true"
    alt="" width="300">
</a><br>
Sinapsis Bank Reconciliation
<br>
</h1>

<h4 align="center">Sinapsis templates for bank/ERP reconciliation and LLM adjudication of fuzzy reference matches</h4>

<p align="center">
<a href="#installation">🐍 Installation</a> •
<a href="#templates">🚀 Templates</a> •
<a href="#example">📚 Usage</a> •
<a href="#license">🔍 License</a>
</p>

This package provides the use-case-specific Sinapsis templates for reconciling a bank
statement against an ERP/accounting export. It consumes the reference-match output
produced upstream by a matching pipeline (e.g. `sinapsis-polyfuzz`'s `ExactMatch` and
pair matchers) and turns it into a settled, flagged reconciliation — escalating only the
genuinely ambiguous fuzzy cases to an LLM adjudicator.

<h2 id="installation">🐍 Installation</h2>

Install using your package manager of choice. We encourage the use of `uv`

Example with `uv`:

```bash
  uv pip install sinapsis-bank-reconciliation --extra-index-url https://pypi.sinapsis.tech
```

or with raw `pip`:

```bash
  pip install sinapsis-bank-reconciliation --extra-index-url https://pypi.sinapsis.tech
```

<h2 id="templates">🚀 Templates</h2>

| Template | Purpose |
| --- | --- |
| `BankReconciliation` | Groups rows by matched reference, compares amounts, and deterministically settles the clear-cut fuzzy cases via `classify_identity`, emitting reconciliation flags. |
| `AdjudicationCaseBuilder` | Turns the residual `needs_human` fuzzy cases into prompts for an LLM judge that decides document identity. |
| `AdjudicationResolver` | Resolves the final flags from the judge's verdicts (mirroring bank-side flags onto matched ERP rows). |
| `ReconciliationSummaryTable` | Emits a condensed, human-readable summary table of the reconciled result. |

<h2 id="example">📚 Usage</h2>

These templates are referenced by `class_name` in a Sinapsis agent config. See the
`bank-reconciliation` demo in [`sinapsis-demos`](https://github.com/Corteza-ai/sinapsis-demos)
for end-to-end `light`/`heavy` pipelines that wire matching → reconciliation → adjudication.

Below is a minimal example wiring the four templates this package provides. The upstream
CSV reading and reference matching come from other Sinapsis packages (`sinapsis-data-readers`
and `sinapsis-polyfuzz`); the values are placeholders — adapt the sources, column names and
the LLM template to your data.

```yaml
agent:
  name: bank_reconciliation
  description: Reconcile a bank statement against an ERP export, escalating ambiguous fuzzy matches to an LLM judge.

templates:
  - template_name: InputTemplate
    class_name: InputTemplate
    attributes: {}

  # --- Upstream: read both sources, then produce exact + fuzzy reference matches ---
  - template_name: BankCSVReader
    class_name: CSVDatasetReader
    template_input: InputTemplate
    attributes:
      root_dir: "artifacts"
      path_to_csv: "sample_bank.csv"

  - template_name: ERPCSVReader
    class_name: CSVDatasetReader
    template_input: BankCSVReader
    attributes:
      root_dir: "artifacts"
      path_to_csv: "sample_erp.csv"

  - template_name: ExactMatcher
    class_name: ExactMatch
    template_input: ERPCSVReader
    attributes:
      from_source: "BankCSVReader_x_dataset"
      from_column: "Reference1"
      to_source: "ERPCSVReader_x_dataset"
      to_column: "Reference1"
      exact_matches_source: "exact_matches"
      no_exact_matches_source: "no_exact_matches"

  - template_name: FuzzyMatcher
    class_name: RapidFuzzPairWrapper
    template_input: ExactMatcher
    attributes:
      from_source: "no_exact_matches"
      from_column: "Reference1"
      to_source: "ERPCSVReader_x_dataset"
      to_column: "Reference1"
      matches_source: "fuzzy_matches"
      min_similarity: 0.8

  - template_name: Reconcile
    class_name: BankReconciliation
    template_input: FuzzyMatcher
    attributes:
      bank_source: "BankCSVReader_x_dataset"
      erp_source: "ERPCSVReader_x_dataset"
      bank_ref_col: "Reference1"
      bank_amount_col: "Amount"
      erp_ref_col: "Reference1"
      erp_debit_col: "Debits"
      erp_credit_col: "Credits"
      match_min_similarity: 1.0
      resolve_identity: true
      overwrite: true

  - template_name: CaseBuilder
    class_name: AdjudicationCaseBuilder
    template_input: Reconcile
    attributes:
      bank_source: "BankCSVReader_x_dataset"
      bank_ref_col: "Reference1"
      prompt_path: "artifacts/adjudication_prompt.txt"

  - template_name: Judge
    class_name: LLaMACPPTextCompletion
    template_input: CaseBuilder
    attributes:
      init_args:
        llm_model_name: bartowski/Qwen2.5-3B-Instruct-GGUF
        llm_model_file: Qwen2.5-3B-Instruct-Q4_K_M.gguf
      completion_args:
        temperature: 0.1
        response_format:
          type: json_object

  - template_name: Resolver
    class_name: AdjudicationResolver
    template_input: Judge
    attributes:
      bank_source: "BankCSVReader_x_dataset"
      erp_source: "ERPCSVReader_x_dataset"
      erp_ref_col: "Reference1"

  - template_name: SummaryTable
    class_name: ReconciliationSummaryTable
    template_input: Resolver
    attributes:
      bank_source: "BankCSVReader_x_dataset"
      bank_ref_col: "Reference1"
      summary_source: "reconciliation_summary"
```

<h2 id="license">🔍 License</h2>

This project is licensed under the AGPLv3 license, which encourages open collaboration and sharing. For more details, please refer to the [LICENSE](LICENSE) file.

For commercial use, please refer to our [official Sinapsis website](https://sinapsis.tech) for information on obtaining a commercial license.
