Internal reconciliation with Claude¶
Let accounting and treasury reconcile open items of a business partner or a G/L account in B1 with Claude: invoices against payments on account, credit notes against invoices, supplier invoices against vendor payments, and lines of transit accounts that should net to zero. Claude finds the open items, proposes what goes together with a confidence, and reconciles a batch after one confirmation.
Last updated: 2026-11-12 (requirements from an interview with Ivan Armoa; data read from COMPU, tests in ZZ_COMPU_3) Epic: SAP #110 "Reconciliaciones internas con Claude" (hypothesis and outcomes there)
Requirements¶
Who and why¶
Accounting (contabilidad) and treasury/collections (tesorería, cobros) reconcile by hand in the B1 client today. An accounting user reported on 2026-11-06 that Claude could not do it. The MCP fails for three reasons (tested 2026-11-12, see Service Layer behaviour):
- the schema shows
InternalReconciliationRows, which the Service Layer refuses on POST; - open items come from the action
InternalReconciliationsService_GetOpenTransactions, which no tool can call; - reading the
InternalReconciliationscollection fails (502 or 400), only a read by number works.
Each manual reconciliation takes more than 3 minutes (interview estimate): finding the partner's open items, deciding what goes together, checking, reconciling. Success means time saved and no backlog: no partner left with both open debits and credits at month-end close.
What is reconciled today (COMPU, reconciliations dated 2026-10-17 to 11-12)¶
Read on 2026-11-12: the 3,238 reconciliations numbered 177,340 to 181,339.
- 359 are manual (
rtManual); the rest are made by B1 itself (payments 1,571, down payment allocations 395, automatic 373, reversals 273, cancellations 144, credit notes 81). - 18 of the 359 manual ones (5%) were cancelled later.
- 303 manual reconciliations are dated in the period, for 277 different partners: about 11 a day, up to 25. At more than 3 minutes each, that is over 15 hours in four weeks (estimate).
- What the 341 manual ones not cancelled close:
| Items | Count |
|---|---|
| A/R invoice + incoming payment | 247 |
| A/P invoice + vendor payment | 31 |
| A/R invoice + A/R credit note | 25 |
| A/R invoice + credit note + payment | 13 |
| A/P invoice + A/P credit note | 6 |
| Other mixes (journal entries, incoming with vendor payments) | 19 |
| G/L account (no partner) | 0 |
- Of those 341, 295 are for customers and 46 for suppliers; 286 have two items, 55 have three to five, none more.
- 240 of the 359 made B1 post a conversion or exchange difference entry (the items' USD values differ); B1 does that by itself.
- A sample of 25 of the payments in "A/R invoice + incoming payment": all were payments on account. 17 were card payments, 5 transfers to 111401, 3 cash. They come from several sources (store, web, transfers); the spec does not assume one.
- Payments of down payment requests are drawn in the invoice at COMPU (the 395 down payment allocations), not reconciled by hand.
Flows¶
A. One partner on request. "Reconcile customer C32852" or "apply this transfer to the customer's invoices". Claude lists the partner's open items, proposes groups, and reconciles after the user confirms.
B. All partners in bulk. "Reconcile every customer that has both open debits and credits", for example at month-end. Claude lists the partners with open items on both sides (the open-items report), then works through them in pages: high-confidence groups go in one batch with one confirmation; medium and low ones are shown to the user one by one.
C. A G/L account by period. "Reconcile 111205 for October". Claude lists the account's open lines in the period and proposes lines that net to zero.
D. Undo. "Cancel reconciliation 108193": B1 reopens its items.
E. What closed this document. "Which reconciliation closed invoice 835427?": the reconciliations of a document, with their other items.
Matching rules and confidence¶
All four rules are valid at COMPU. Items match only within one partner (or one G/L account) and in the reconciliation currency.
| Rule | Confidence |
|---|---|
| One debit and one credit of the same open amount, and no other item of that amount on either side | high |
| A payment's or entry's text (remarks, references, line memo) names the invoice's number, amount up to its open amount | high |
| A credit note against the invoice it was copied from (its lines' base document) | high |
| A credit equal to all of the partner's open debits together, or the reverse | high |
| The same amount, but several candidates: the oldest debit is proposed | medium |
| Oldest first: a payment on account pays the oldest open invoices (by due date), the last one possibly in part | medium |
| The only combination of items that adds up to a credit (bounded search) | medium |
| Amounts that differ, such as a mistyped amount: the smaller amount is proposed, the rest stays open | low |
When several combinations fit, none is proposed and the items are listed as ambiguous.
Must¶
- List a partner's (or several partners') open items with date, due date, document type and number, open amount in local currency and, for foreign-currency partners, in their currency, and the text the rules read.
- List a G/L account's open lines for a period.
- The open-items report: partners (customers, suppliers or both) and G/L accounts with open items on both sides, with counts and totals. It also gives the backlog's baseline.
- Propose groups with a confidence and reasons, each ready for the write tool.
- Reconcile one group or a batch of groups after one confirmation; partial amounts allowed.
- Use the latest item's date as reconciliation date; if that date is in a closed or locked period, use today and say so in the confirmation.
- Show the conversion or exchange difference entry B1 posts, like the other posting tools.
- Business partners in USD (foreign-currency partners) from the start: amounts in their currency.
- Payments of down payment requests: flag them ("draw it in the invoice"), never propose them, and refuse them in the write tool.
- Cancel a reconciliation.
- Read one reconciliation and the reconciliations of a document.
b1_readandb1_writeonInternalReconciliationspoint to the new tools instead of failing with the Service Layer's errors.- A team skill in the sap-b1 plugin.
Not in the first version¶
- Writing off small differences to an account: the smaller amount is reconciled and the rest stays open for a person.
- Unattended reconciliation (an endpoint for n8n).
- Reconciling payments of down payment requests.
- Reconciling items of different partners together (B1 allows it, e.g. a customer that is also a supplier; reconciliation 104993 in ZZ_COMPU_3 did it).
Acceptance criteria¶
- A user can reconcile one customer's invoice and payment on account through Claude in COMPU, with one confirmation, and the invoice closes.
- In a bulk run over all customers, high-confidence groups are reconciled in one batch and every medium or low group is shown before it is reconciled.
- A USD supplier's invoice and vendor payment reconcile in USD, and the exchange difference entry is shown.
- A G/L account's offsetting lines in a period reconcile.
- A reconciliation made by mistake can be cancelled through Claude.
- A payment of a down payment request is never proposed, and reconciling it is refused with the reason.
b1_readofInternalReconciliationsandb1_writecreate on it answer with the tool to use.
Design¶
Service Layer behaviour¶
Tested in ZZ_COMPU_3 on 2026-11-12; the test data is under Test data.
- Create:
POST InternalReconciliationswithReconDate,CardOrAccount(coaCardorcoaAccount) andInternalReconciliationOpenTransRows, each row withSelected: "tYES",ShortName(partner code or account),TransId,TransRowId,CreditOrDebit(codDebit,codCredit) andReconcileAmount. WithoutSelectedthe answer is 404-2028; withInternalReconciliationRows(the shape$metadatadeclares for the entity) it is-1005 Data InternalReconciliationRows not found.SrcObjTyp/SrcObjAbsare not needed. - Read: only
InternalReconciliations(n). The bare collection,$topand/$countgive a Cloudflare 502;$filter,$selector$orderbygive 400 "Property 'ReconNum' of 'InternalReconciliationOpenTrans' is invalid". In a stored reconciliationSrcObjAbsis the document's DocEntry; a row withSrcObjTyp321 is the difference entry B1 posted. - Open items:
POST InternalReconciliationsService_GetOpenTransactionswithInternalReconciliationOpenTransParams:ReconDate,CardOrAccount, thenInternalReconciliationBPs([{BPCode}], several at once) orAccountNowithDateType(rsdtPostDate),FromDate,ToDate. Rows carry no dates or USD values,SrcObjAbsis the DocNum here, and amounts can be negative (a vendor payment of -30 USD). For a USD partnerReconcileAmountis in USD. - Cancel:
POST InternalReconciliations(n)/Cancelwith no body; B1 creates anrtCancellationreconciliation and reopens the items. - Worked: G/L lines (108187, 108190), partner journal entry lines (108188, 108191), invoice + journal entry (108193), invoice + the on-account part of a payment in part (108195), USD supplier invoice + vendor payment (108199, exchange difference of 18,813 to 521103), all with the differences B1 posts to 421103/521103.
- Failed: an invoice with a payment of a down payment request:
-5011 [JDT1.Account][line: 1] Invalid Account Code; with a journal entry instead of the invoice: "Only an invoice or a reserve invoice can be reconciled with a down payment request". Setting the partner'sDownPaymentClearActdid not help, and the period'sCustomerDownPaymentsAccountmust be a control account (empty in COMPU too). Not needed at COMPU, where down payments are drawn in the invoice.
Building blocks that already exist¶
B1SavedSqlQuery(services/b1-saved-sql-query.ts): creates and patches saved SQL queries on first use, with paging (postAllPages). JDT1 and OJDT are allowed in COMPU.searchAmountSubsets(services/b1-amount-combinations.ts): bounded subset search for the combination rule.services/b1-account-currency.ts: local currency, account currency and the day's rate.services/b1-journal-entry-feedback.ts: appends a posted journal entry to a tool's result.- The registry's
confirmed()wrapper andb1_confirm_operation: one confirmation for a batch, asb1_external_reconciliationdoes withreconciliations(at most 100 groups per call). b1_external_reconciliationandb1_reconciliation_items: the shape to copy for tool names, operations, batch results and audit events.
New pieces¶
Saved query mcpOpenReconItems on JDT1 + OJDT: open lines of a partner list or of an account in
a period. Columns: TransId, Line_ID, ShortName, Account, RefDate, DueDate, BalDueDeb,
BalDueCred, BalFcDeb, BalFcCred, FCCurrency, Ref1, Ref2, LineMemo, and from OJDT
TransType, BaseRef (DocNum), CreatedBy (DocEntry). Open means BalDueDeb <> 0 OR BalDueCred <>
0. This replaces GetOpenTransactions for listing because it gives dates, document keys and text;
GetOpenTransactions stays as the check right before posting.
Saved query mcpOpenReconSummary: the open-items report, grouped by ShortName (and Account
for G/L lines without a partner) with counts and totals of open debits and credits, only where both
sides are open.
Saved query mcpDocumentReconciliations: reconciliations of a document's journal lines, from
ITR1 (reconciliation rows) joined to OITR. If the Service Layer does not allow ITR1/OITR in saved
queries, fall back to JDT1.IntrnMatch (the last reconciliation number of each line), which misses
earlier partial reconciliations.
Tool b1_internal_reconciliation_items (read-only):
open_items:cardCodes(up to 50) oraccountCodewithdateFrom/dateTo; returns the items and the proposals, each proposal with confidence, reasons and areconcilefield ready for the write tool. Payments of down payment requests are listed with a flag and no proposal.report:partnerType(customer,supplier,both) or G/L accounts; returns the partners or accounts with open items on both sides.get: one reconciliation by number, with its items' documents and the difference entry.document: the reconciliations of a document (type and DocEntry or DocNum).
Tool b1_internal_reconciliation (writes, needs confirmation):
reconcile: one group (items:transId,lineId,amount) orreconciliations(a batch of groups, at most 100). Each group is checked: every item open (GetOpenTransactionsfor the group's partner or account), one partner or one account, amount up to the open amount, debits equal credits in the reconciliation currency, no payment of a down payment request. Invalid groups are skipped and reported; the rest are reconciled one by one after one confirmation. The confirmation summary lists each group with its documents, amounts, date, and whether today replaced a closed period's date.cancel:reconciliationNo.
Pure planning in services/b1-internal-reconciliation-plan.ts: the matching rules and
confidence, testable without B1. I/O in services/b1-internal-reconciliation-service.ts.
Guards: b1_read on InternalReconciliations without a key, and b1_write create on it,
return a message naming the new tools.
Skill plugins/sap-b1/skills/internal-reconciliation: when to use it (accounting and
treasury), the bulk flow with confidence levels, down payments drawn in the invoice, the usual G/L
accounts once accounting lists them. Raise the plugin version.
Docs: README tool tables, tools/b1-server-instructions.ts, CLAUDE.md (architecture paragraph,
the "not supported by design" list gains GetOpenTransactions and Cancel, and the Service Layer
quirks above as gotchas).
Currency¶
- The reconciliation currency is the partner's currency when it is a foreign currency (USD), otherwise the local currency. For a G/L account, the account's currency.
- Foreign-currency partners: amounts from
BalFcDeb/BalFcCred. Others, including multi-currency (##) partners with USD documents: local amounts; B1 posts the exchange difference. - System-currency (USD) differences between items in guaraníes are normal (240 of 359 manual reconciliations); B1 posts them and the tool shows the entry.
Edge cases¶
- Installments: each installment of an invoice is its own journal line and its own item; oldest-first uses the due date.
- Payment partly applied: the rest of a payment that also paid an invoice is an open item like a payment on account (108195 used one).
- Negative amounts: an open amount with the opposite sign counts on the other side.
- Changed since the proposal: items reconciled by someone else in between fail the check before posting and the group is reported, not posted.
- Reconciliation date: never before the latest item's date; a closed or locked period (read from
CompanyService_GetFinancePeriods) means today. - Personal data: results contain partner names; no tax IDs are needed.
Test data¶
ZZ_COMPU_3, created 2026-11-12: journal entries 399804, 399806, 399807, 399811 and 399812 (399812 still open) on customer C32852 and G/L 111205 (Canje); reconciliations 108187 (cancelled by 108189), 108188, 108190, 108191, 108193, 108195 and 108199 (supplier PL0279, USD).
Decisions¶
| Date | Decision | By |
|---|---|---|
| 2026-11-12 | Users: accounting and treasury/collections. | Ivan Armoa |
| 2026-11-12 | Kinds: customer payments on account, credit notes, supplier side and G/L accounts, all in the first version. | Ivan Armoa |
| 2026-11-12 | Flows: one partner, all partners in bulk, a G/L account by period. | Ivan Armoa |
| 2026-11-12 | Matching rules: exact amount, reference in the text, oldest first, a credit note's base invoice. | Ivan Armoa |
| 2026-11-12 | High-confidence groups in a batch with one confirmation; medium and low shown one by one. | Ivan Armoa |
| 2026-11-12 | Partial reconciliations allowed; small differences are not written off, the rest stays open. | Ivan Armoa |
| 2026-11-12 | Reconciliation date: the latest item's date; today when that period is closed or locked, said in the confirmation. | Ivan Armoa |
| 2026-11-12 | USD partners from the start. | Ivan Armoa |
| 2026-11-12 | Down payment request payments are drawn in the invoice at COMPU: flagged, never reconciled. | Ivan Armoa |
| 2026-11-12 | Also cancel, read a document's reconciliations and an open-items report. | Ivan Armoa |
| 2026-11-12 | A new skill in the sap-b1 plugin. | Ivan Armoa |
| 2026-11-12 | List open items from JDT1 through a saved query and check them with GetOpenTransactions before posting (proposed). |
Claude |
| 2026-11-12 | Two tools, read-only and write, like the external reconciliation tools (proposed). | Claude |
| open | Which G/L accounts accounting reconciles (none by hand from 2026-10-17 to 11-12). | Accounting |
| open | Whether saved queries may read ITR1/OITR; otherwise JDT1.IntrnMatch. |
Verify in COMPU |
| open | Today's backlog (partners with open items on both sides), measured with the report. | First use of the report |
Links¶
- Taiga epic: https://proyectos.compulandia.com.py/project/sap/epic/110
- Stories: #111 open items and report, #112 proposals, #90 reconcile in batches, #113 cancel, #114 a document's reconciliations, #115 plugin skill.