@fullqueso/mcp-bc-gastos 1.1.0 → 1.10.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +149 -25
- package/README.md +153 -40
- package/config/bank-keywords.js +50 -0
- package/config/company-config.js +3 -0
- package/lib/bc-client.js +171 -12
- package/package.json +9 -2
- package/scripts/generate-bank-recon-xlsx.py +376 -0
- package/scripts/generate-draft-payables-xlsx.py +282 -0
- package/server.js +109 -0
- package/tools/auditoria/bank-reconciliation-report.js +598 -0
- package/tools/auditoria/find-potential-matches.js +187 -0
- package/tools/auditoria/list-bank-accounts.js +50 -0
- package/tools/auditoria/reconcile-pos-sales.js +1347 -0
- package/tools/auditoria/reconciliation-status.js +123 -0
- package/tools/auditoria/suggest-journal-entries.js +253 -0
- package/tools/auditoria/unmatched-ledger-entries.js +106 -0
- package/tools/auditoria/unmatched-statement-lines.js +180 -0
- package/tools/cobranzas/collection-status.js +103 -0
- package/tools/cobranzas/customer-balances.js +86 -0
- package/tools/cobranzas/customer-ledger.js +145 -0
- package/tools/cobranzas/open-payables.js +198 -0
- package/tools/cobranzas/open-receivables.js +196 -0
- package/tools/cobranzas/vendor-ledger.js +147 -0
- package/tools/expense-details.js +36 -8
- package/tools/list-vendors.js +130 -0
- package/tools/multi-payment/draft-payables.js +705 -0
- package/tools/multi-payment/draft-receivables.js +704 -0
- package/tools/multi-payment/draft-summary.js +241 -0
- package/tools/multi-payment/index.js +3 -0
- package/tools/vendor-transactions.js +162 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,49 +1,173 @@
|
|
|
1
1
|
# CHANGELOG
|
|
2
2
|
|
|
3
|
+
## [1.10.0] - 2026-02-26
|
|
4
|
+
|
|
5
|
+
### Highlights
|
|
6
|
+
- **26 tools** across 5 domains
|
|
7
|
+
- **New**: Consolidated bank reconciliation report tool — single call replaces 3-5 sequential tool calls
|
|
8
|
+
- **Performance**: Parallel API fetching in reconciliation-status, bulk MP line fetching
|
|
9
|
+
|
|
10
|
+
### Added
|
|
11
|
+
- `get_bank_reconciliation_report` — consolidated bank reconciliation: progress + unmatched debits/credits + journal entry suggestions in ONE MCP call. Statement selection by number, month (`month: "2025-12"`), or latest. Includes `matchBankDescription` keyword matching + historical GL pattern matching for debit suggestions.
|
|
12
|
+
- Skill spec: `docs/SKILL_bank_reconciliation.md` — trigger phrases, presentation guide, example queries
|
|
13
|
+
|
|
14
|
+
### Performance
|
|
15
|
+
- **Bank reconciliation**: `get_reconciliation_status` now fetches statement lines in parallel (`Promise.all`) instead of sequential `for...of` loop
|
|
16
|
+
- **Multi-Payment draft tools**: Replaced per-MP-header parallel line fetch (`Promise.all` on N headers) with single bulk fetch + in-memory grouping. Fixes BC 429 rate limiting for large stores (FQ28: ~1,173 invoices)
|
|
17
|
+
- **BC client**: `fetchWithRetry` now handles HTTP 429 with `Retry-After` header support and exponential backoff
|
|
18
|
+
|
|
19
|
+
---
|
|
20
|
+
|
|
21
|
+
## [1.9.0] - 2026-02-25
|
|
22
|
+
|
|
23
|
+
### Highlights
|
|
24
|
+
- **25 tools** across 5 domains: expenses, bank reconciliation, POS reconciliation, AR/AP, **Multi-Payment draft visibility**
|
|
25
|
+
- **4 API integrations**: Standard v2.0, OData V4, Finance Reports Beta, **Custom Extension API**
|
|
26
|
+
- Three-tier invoice classification: Fully Pending → Drafted → In Journal
|
|
27
|
+
|
|
28
|
+
### Added
|
|
29
|
+
|
|
30
|
+
**Multi-Payment Draft Visibility — 3 herramientas (Custom Extension API):**
|
|
31
|
+
- `get_draft_receivables` — facturas de venta abiertas con clasificación de tres niveles: sin documento, con borrador Open, con borrador Transferred. Incluye monto neto realmente pendiente y desglose por método de pago
|
|
32
|
+
- `get_draft_payables` — mismo análisis para facturas de compra (proveedores)
|
|
33
|
+
- `get_draft_summary` — resumen ejecutivo del pipeline de cobros y pagos en borrador por tienda
|
|
34
|
+
|
|
35
|
+
**Aging Reports — nuevo parámetro `report` en get_draft_receivables y get_draft_payables:**
|
|
36
|
+
- `report: "aging_pending"` — facturas SIN multipago agrupadas por mes con top vendors/customers, age_days_avg, y aging buckets (0-30, 31-60, 61-90, 90+)
|
|
37
|
+
- `report: "aging_full"` — ambas categorías por mes: sin multipago + con draft sin postear, incluyendo drafted_amount y net_pending
|
|
38
|
+
- `report: "default"` (o sin parámetro) — comportamiento existente sin cambios
|
|
39
|
+
|
|
40
|
+
### Fixed
|
|
41
|
+
- **Currency conversion bug**: `totalPaymentAmount` on MP headers is a VES FlowField sum — was being reported as USD. Now fetches MP lines + BCV exchange rates to compute accurate USD totals per line (VES lines ÷ BCV rate, USD lines as-is). Affects all 3 draft tools.
|
|
42
|
+
|
|
43
|
+
### Technical
|
|
44
|
+
- Custom Extension API integration (`buildCustomApiUrl`, `buildMultiPaymentApiUrl`) in BCClient
|
|
45
|
+
- Supports 4 new API pages from Sales Invoice Payment Automation extension v1.4.0.0:
|
|
46
|
+
`multiPaymentHeaders`, `multiPaymentLines`, `purchMultiPaymentHeaders`, `purchMultiPaymentLines`
|
|
47
|
+
- Three-tier classification logic cross-referencing customer/vendor ledger entries with MP headers
|
|
48
|
+
- Multi-store parallel fetching with consolidated summaries
|
|
49
|
+
- Payment method breakdown via MP lines (optional `include_lines` parameter)
|
|
50
|
+
- Aging logic is pure post-processing on existing data — no additional API calls
|
|
51
|
+
- Entity-parameterized aging builders (`VENDOR_ENTITY` / `CUSTOMER_ENTITY`) for correct field names per tool
|
|
52
|
+
|
|
53
|
+
---
|
|
54
|
+
|
|
55
|
+
## [1.8.0] - 2026-02-23
|
|
56
|
+
|
|
57
|
+
### Highlights
|
|
58
|
+
- **22 tools** across 4 domains: expenses, bank reconciliation, POS reconciliation, AR/AP
|
|
59
|
+
- **3 API integrations**: Standard v2.0, OData V4, Finance Reports Beta
|
|
60
|
+
- **4-bank POS reconciliation**: Banesco, Bancrecer, BDV, UBII (cross-account)
|
|
61
|
+
- **Performance**: in-memory caching, parallel fetching, request deduplication
|
|
62
|
+
|
|
63
|
+
This npm release consolidates all changes from v1.2.0 through v1.8.0.
|
|
64
|
+
|
|
65
|
+
### Added
|
|
66
|
+
- UBII cross-account POS reconciliation — matches sales in virtual account MN0012 against deposits in Bancrecer/BDV
|
|
67
|
+
- In-memory caching for store financial data (5-min TTL) and exchange rates (15-min TTL)
|
|
68
|
+
- Inflight request deduplication in BCClient (concurrent calls share one promise)
|
|
69
|
+
- Parallel store fetching via `Promise.all` in `getAllStoresFinancialData`
|
|
70
|
+
- Test suite: `test-pos-reconciliation.js` for multi-bank POS reconciliation
|
|
71
|
+
|
|
72
|
+
---
|
|
73
|
+
|
|
74
|
+
## [1.6.0] - 2026-02-22
|
|
75
|
+
|
|
76
|
+
### Added
|
|
77
|
+
- BDV aggregate POS matching — reconciliation by period totals (no lot numbers in bank statements)
|
|
78
|
+
- Bancrecer lot-based POS reconciliation with separate commission (`N/D COM.`) and ISLR (`N/D ISLR`) line handling
|
|
79
|
+
- Daily summary with status pipeline: `OK`, `MISSING_MPCR`, `HIGH_COMMISSION`, `BANK_EXCEEDS_BC`, `MPCR_NO_BANK`, `BANK_ONLY`, `COMMISSION_UNKNOWN`
|
|
80
|
+
- Data source indicators: `BALE_DIRECT` vs `CLE_WITH_BALE_CORRECTION`
|
|
81
|
+
- `COMMISSION_UNKNOWN` status for uncalculable commissions (BALE correction fallback)
|
|
82
|
+
|
|
83
|
+
---
|
|
84
|
+
|
|
85
|
+
## [1.5.0] - 2026-02-21
|
|
86
|
+
|
|
87
|
+
### Added
|
|
88
|
+
- Herramienta `reconcile_pos_sales` — conciliación POS por número de lote (Banesco)
|
|
89
|
+
- BALE (BankAccountLedgerEntries) OData V4 integration for precise per-bank POS amounts
|
|
90
|
+
- Settlement batch grouping by bank deposit date
|
|
91
|
+
- Commission calculations and journal entry suggestions (debit 67100, credit 182XX)
|
|
92
|
+
- Lot parsing: `parseBCLots()`, `parseBankStatementLot()` for compound lot numbers
|
|
93
|
+
- POS reconciliation skill spec documentation
|
|
94
|
+
|
|
95
|
+
---
|
|
96
|
+
|
|
97
|
+
## [1.4.0] - 2026-02-21
|
|
98
|
+
|
|
99
|
+
### Added
|
|
100
|
+
|
|
101
|
+
**Auditoría Bancaria — 6 herramientas (OData V4):**
|
|
102
|
+
- `list_bank_accounts` — cuentas bancarias activas por tienda
|
|
103
|
+
- `get_reconciliation_status` — resumen de reconciliaciones abiertas (matched vs pending)
|
|
104
|
+
- `get_unmatched_statement_lines` — líneas del estado de cuenta no conciliadas con BC
|
|
105
|
+
- `get_unmatched_ledger_entries` — entradas contables de BC sin correspondencia en banco
|
|
106
|
+
- `find_potential_matches` — scoring 0-100 para encontrar correspondencias (monto/fecha/descripción)
|
|
107
|
+
- `suggest_journal_entries` — sugerencias de asientos contables para líneas no conciliadas
|
|
108
|
+
|
|
109
|
+
**Cobranzas y Cuentas por Pagar — 6 herramientas (Finance Reports Beta API):**
|
|
110
|
+
- `get_customer_balances` — clientes con saldos pendientes
|
|
111
|
+
- `get_customer_ledger` — movimientos de clientes (facturas, pagos, notas de crédito)
|
|
112
|
+
- `get_open_receivables` — cuentas por cobrar abiertas con aging (0-30, 31-60, 61-90, 90+)
|
|
113
|
+
- `get_collection_status` — verificación de cobranza completa por período
|
|
114
|
+
- `get_vendor_ledger` — movimientos de proveedores (facturas recibidas, pagos realizados)
|
|
115
|
+
- `get_open_payables` — cuentas por pagar abiertas con aging
|
|
116
|
+
|
|
117
|
+
### Technical
|
|
118
|
+
- OData V4 Web Service integration (`buildODataUrl`, `odataCall`, `odataCallAllPages`)
|
|
119
|
+
- Finance Reports Beta API integration (`buildBetaApiUrl`)
|
|
120
|
+
- Bank keywords configuration (`config/bank-keywords.js`)
|
|
121
|
+
- Company name mapping in `config/company-config.js`
|
|
122
|
+
|
|
123
|
+
---
|
|
124
|
+
|
|
125
|
+
## [1.2.0] - 2026-02-20
|
|
126
|
+
|
|
127
|
+
### Added
|
|
128
|
+
- Herramienta `get_vendor_transactions` — todas las transacciones de un proveedor con desglose por cuenta contable
|
|
129
|
+
- Herramienta `list_vendors` — directorio de proveedores activos ordenados por monto pagado
|
|
130
|
+
- `vendor_search` — búsqueda parcial case-insensitive por nombre de proveedor en `get_expense_details`
|
|
131
|
+
- Paginación (`offset`/`limit`) para `get_expense_details`
|
|
132
|
+
- Archivo LICENSE (MIT)
|
|
133
|
+
- `.env.example` con documentación completa de variables
|
|
134
|
+
|
|
135
|
+
---
|
|
136
|
+
|
|
3
137
|
## [1.1.0] - 2026-02-19
|
|
4
138
|
|
|
5
139
|
### Added
|
|
6
|
-
- Herramienta `get_expense_details`
|
|
7
|
-
- Herramienta `get_account_transactions`
|
|
8
|
-
- Vendor lookup automático
|
|
9
|
-
- Métodos `getVendorLedgerEntries()`, `getVendors()
|
|
10
|
-
-
|
|
140
|
+
- Herramienta `get_expense_details` — drill-down transaccional con filtros por categoría, cuenta, monto mínimo
|
|
141
|
+
- Herramienta `get_account_transactions` — listado por cuenta contable con running balance
|
|
142
|
+
- Vendor lookup automático: `vendor_name` y `vendor_number` vía cruce con Vendor Ledger Entries
|
|
143
|
+
- Métodos `getVendorLedgerEntries()`, `getVendors()`, `buildVendorMap()` en bc-client.js
|
|
144
|
+
- `getDetailedGLEntries()` con filtros flexibles
|
|
11
145
|
|
|
12
146
|
### Technical
|
|
13
|
-
- `buildVendorMap()`
|
|
14
|
-
- GL entries y vendor map
|
|
15
|
-
- Tests 6 y 7 agregados a test-tools.js (total: 7 tools testeadas)
|
|
147
|
+
- `buildVendorMap()` resiliente: retorna `{}` si endpoints no disponibles
|
|
148
|
+
- GL entries y vendor map en paralelo con `Promise.all`
|
|
16
149
|
|
|
17
150
|
---
|
|
18
151
|
|
|
19
152
|
## [1.0.0] - 2026-02-18
|
|
20
153
|
|
|
21
154
|
### Added
|
|
22
|
-
- Herramienta `get_expense_analysis`
|
|
23
|
-
- Herramienta `get_efficiency_ratios`
|
|
24
|
-
- Herramienta `compare_stores`
|
|
25
|
-
- Herramienta `detect_anomalies`
|
|
26
|
-
- Herramienta `get_trends`
|
|
27
|
-
-
|
|
28
|
-
-
|
|
155
|
+
- Herramienta `get_expense_analysis` — análisis detallado por categoría con benchmarks
|
|
156
|
+
- Herramienta `get_efficiency_ratios` — ratios financieros
|
|
157
|
+
- Herramienta `compare_stores` — comparación entre tiendas con rankings
|
|
158
|
+
- Herramienta `detect_anomalies` — detección de anomalías por severidad
|
|
159
|
+
- Herramienta `get_trends` — tendencias históricas (6 meses)
|
|
160
|
+
- Cliente Business Central con OAuth 2.0
|
|
161
|
+
- Chart of Accounts mapping (60000-99999 gastos, 50000-59999 ingresos)
|
|
29
162
|
- Conversión automática VES/USD
|
|
30
163
|
- Benchmarking contra rangos esperados
|
|
31
164
|
- Insights accionables automáticos
|
|
32
165
|
|
|
33
|
-
### Technical
|
|
34
|
-
- Cliente Business Central con OAuth 2.0
|
|
35
|
-
- ExpenseAnalyzer para análisis de gastos
|
|
36
|
-
- RatioCalculator para métricas financieras
|
|
37
|
-
- AnomalyDetector para alertas
|
|
38
|
-
- TrendAnalyzer para análisis histórico
|
|
39
|
-
- Formatter para outputs bien formateados
|
|
40
|
-
|
|
41
166
|
---
|
|
42
167
|
|
|
43
168
|
## [0.1.0] - 2026-02-18
|
|
44
169
|
|
|
45
170
|
### Added
|
|
46
171
|
- Proyecto inicializado
|
|
47
|
-
- Documentación completa
|
|
172
|
+
- Documentación completa
|
|
48
173
|
- Estructura de proyecto definida
|
|
49
|
-
- Chart of Accounts mapeado
|
package/README.md
CHANGED
|
@@ -1,16 +1,15 @@
|
|
|
1
1
|
# @fullqueso/mcp-bc-gastos
|
|
2
2
|
|
|
3
|
-
MCP server for
|
|
3
|
+
MCP server for Microsoft Business Central — operational expenses, bank reconciliation, POS reconciliation, and accounts receivable/payable. Built for the Full Queso franchise (3 stores: FQ01 Chacao, FQ28 Marques, FQ88 Candelaria).
|
|
4
|
+
|
|
5
|
+
**22 tools** across 4 domains, powered by 3 BC API integrations.
|
|
4
6
|
|
|
5
7
|
## Features
|
|
6
8
|
|
|
7
|
-
- **Expense Analysis**
|
|
8
|
-
- **
|
|
9
|
-
- **
|
|
10
|
-
- **
|
|
11
|
-
- **Trend Analysis** - 6-month historical trends with growth rates and seasonality
|
|
12
|
-
- **Expense Details** - Transaction-level drill-down with vendor information
|
|
13
|
-
- **Account Transactions** - Per-account ledger with running balance and vendor lookup
|
|
9
|
+
- **Expense Analysis** — Breakdown by 10 categories, efficiency ratios, store comparison, anomaly detection, 6-month trends
|
|
10
|
+
- **Drill-Down & Vendors** — Transaction-level detail with vendor lookup, per-account ledger, vendor directory
|
|
11
|
+
- **Bank Reconciliation** — Unmatched statement lines/ledger entries, match scoring, journal entry suggestions, multi-bank POS reconciliation (Banesco, Bancrecer, BDV, UBII)
|
|
12
|
+
- **Accounts Receivable & Payable** — Customer/vendor ledger entries, open receivables/payables with aging, collection status
|
|
14
13
|
|
|
15
14
|
## Installation
|
|
16
15
|
|
|
@@ -52,35 +51,121 @@ cp .env.example .env
|
|
|
52
51
|
npm start
|
|
53
52
|
```
|
|
54
53
|
|
|
55
|
-
## Tools
|
|
54
|
+
## Tools (22)
|
|
55
|
+
|
|
56
|
+
### Expense Analysis (5 tools)
|
|
56
57
|
|
|
57
|
-
|
|
58
|
-
Detailed expense analysis by category with benchmark comparisons.
|
|
59
|
-
-
|
|
58
|
+
#### get_expense_analysis
|
|
59
|
+
Detailed expense analysis by category with account-level detail and benchmark comparisons.
|
|
60
|
+
- Params: `stores`, `period`, `month`, `start_date`, `end_date`
|
|
60
61
|
|
|
61
|
-
|
|
62
|
+
#### get_efficiency_ratios
|
|
62
63
|
Financial ratios: expense-to-income, payroll, rent, utilities, marketing, operating margin.
|
|
63
|
-
-
|
|
64
|
+
- Params: `stores`, `period`, `month`, `start_date`, `end_date`
|
|
65
|
+
|
|
66
|
+
#### compare_stores
|
|
67
|
+
Compare all stores with efficiency rankings, variances, and savings opportunities.
|
|
68
|
+
- Params: `period`, `month`, `start_date`, `end_date`
|
|
69
|
+
|
|
70
|
+
#### detect_anomalies
|
|
71
|
+
Detect expense anomalies with severity levels, root causes, and recommended actions.
|
|
72
|
+
- Params: `stores`, `period`, `month`, `start_date`, `end_date`
|
|
73
|
+
|
|
74
|
+
#### get_trends
|
|
75
|
+
Historical trend analysis (up to 6 months) with growth rates, seasonality, and ASCII charts.
|
|
76
|
+
- Params: `store`, `months`
|
|
77
|
+
|
|
78
|
+
### Drill-Down & Vendors (4 tools)
|
|
79
|
+
|
|
80
|
+
#### get_expense_details
|
|
81
|
+
Transaction-level drill-down with vendor lookup, category/account filters, and pagination.
|
|
82
|
+
- Params: `store` (req), `period`, `month`, `start_date`, `end_date`, `category`, `account_number`, `min_amount`, `vendor_search`, `limit`, `offset`
|
|
83
|
+
|
|
84
|
+
#### get_account_transactions
|
|
85
|
+
Per-account ledger with running balance and vendor information.
|
|
86
|
+
- Params: `account_number` (req), `store` (req), `start_date` (req), `end_date` (req)
|
|
87
|
+
|
|
88
|
+
#### get_vendor_transactions
|
|
89
|
+
All transactions for a vendor (partial name search) with account breakdown.
|
|
90
|
+
- Params: `store` (req), `vendor_search` (req), `start_date` (req), `end_date` (req)
|
|
91
|
+
|
|
92
|
+
#### list_vendors
|
|
93
|
+
Directory of active vendors ordered by total amount paid.
|
|
94
|
+
- Params: `store` (req), `start_date`, `end_date`
|
|
95
|
+
|
|
96
|
+
### Bank Reconciliation (7 tools)
|
|
97
|
+
|
|
98
|
+
> These tools use OData V4 Web Services. Amounts in VES. Read-only.
|
|
99
|
+
|
|
100
|
+
#### list_bank_accounts
|
|
101
|
+
List active bank accounts for a store.
|
|
102
|
+
- Params: `store` (req)
|
|
103
|
+
|
|
104
|
+
#### get_reconciliation_status
|
|
105
|
+
Open reconciliation summary: matched vs unmatched lines per bank account.
|
|
106
|
+
- Params: `store` (req), `bank_account`
|
|
107
|
+
|
|
108
|
+
#### get_unmatched_statement_lines
|
|
109
|
+
Bank statement lines not reconciled with BC, categorized by type (payments/deposits).
|
|
110
|
+
- Params: `store` (req), `bank_account` (req), `statement_no`, `min_amount`, `type_filter`
|
|
64
111
|
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
-
|
|
112
|
+
#### get_unmatched_ledger_entries
|
|
113
|
+
BC ledger entries not cleared at the bank, with stale entry detection (>30 days).
|
|
114
|
+
- Params: `store` (req), `bank_account` (req), `date_from`, `date_to`
|
|
68
115
|
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
-
|
|
116
|
+
#### find_potential_matches
|
|
117
|
+
Scoring-based match finder (0-100) for unmatched bank lines against BC entries.
|
|
118
|
+
- Params: `store` (req), `bank_account` (req), `statement_amount` (req), `transaction_date` (req), `description`, `date_tolerance_days`, `amount_tolerance_pct`
|
|
72
119
|
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
-
|
|
120
|
+
#### suggest_journal_entries
|
|
121
|
+
Suggest GL journal entries for unreconciled bank payments using keyword matching and historical patterns.
|
|
122
|
+
- Params: `store` (req), `bank_account` (req), `statement_no`, `auto_categorize`
|
|
76
123
|
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
-
|
|
124
|
+
#### reconcile_pos_sales
|
|
125
|
+
Multi-bank POS sales reconciliation. Matches bank deposits against BC lot records with commission tracking.
|
|
126
|
+
- **Banesco**: lot-based matching, commission netted in deposit
|
|
127
|
+
- **Bancrecer**: lot-based with separate commission/ISLR lines
|
|
128
|
+
- **BDV**: aggregate matching by period totals (no lot numbers)
|
|
129
|
+
- **UBII**: cross-account matching (BC virtual account → Bancrecer/BDV deposits)
|
|
130
|
+
- Params: `store` (req), `start_date` (req), `end_date` (req), `bank_account`
|
|
80
131
|
|
|
81
|
-
###
|
|
82
|
-
|
|
83
|
-
|
|
132
|
+
### Accounts Receivable & Payable (6 tools)
|
|
133
|
+
|
|
134
|
+
> These tools use the Finance Reports Beta API. Amounts in VES and USD. Read-only.
|
|
135
|
+
|
|
136
|
+
#### get_customer_balances
|
|
137
|
+
Customers with outstanding balances.
|
|
138
|
+
- Params: `store` (req), `only_with_balance`, `customer_number`
|
|
139
|
+
|
|
140
|
+
#### get_customer_ledger
|
|
141
|
+
Customer transaction history: invoices, payments, credit memos with collection rate.
|
|
142
|
+
- Params: `store` (req), `start_date` (req), `end_date` (req), `customer_number`, `document_type`, `open_only`
|
|
143
|
+
|
|
144
|
+
#### get_open_receivables
|
|
145
|
+
Open accounts receivable by customer with aging buckets (0-30, 31-60, 61-90, 90+).
|
|
146
|
+
- Params: `store` (req), `as_of_date`, `customer_number`, `min_amount`
|
|
147
|
+
|
|
148
|
+
#### get_collection_status
|
|
149
|
+
Period collection completeness: "Were all December invoices collected?"
|
|
150
|
+
- Params: `store` (req), `start_date` (req), `end_date` (req)
|
|
151
|
+
|
|
152
|
+
#### get_vendor_ledger
|
|
153
|
+
Vendor transaction history: bills received, payments made.
|
|
154
|
+
- Params: `store` (req), `start_date` (req), `end_date` (req), `vendor_number`, `document_type`, `open_only`
|
|
155
|
+
|
|
156
|
+
#### get_open_payables
|
|
157
|
+
Open accounts payable by vendor with aging buckets (0-30, 31-60, 61-90, 90+).
|
|
158
|
+
- Params: `store` (req), `as_of_date`, `vendor_number`, `min_amount`
|
|
159
|
+
|
|
160
|
+
## API Integrations
|
|
161
|
+
|
|
162
|
+
| API | Used By | URL Pattern |
|
|
163
|
+
|-----|---------|-------------|
|
|
164
|
+
| **Standard v2.0** | Expenses, vendors, customers | `v2.0/{tenant}/{environment}/api/v2.0/companies({guid})/...` |
|
|
165
|
+
| **OData V4** | Bank reconciliation, BALE | `ODataV4/Company('{name}')/{service}` |
|
|
166
|
+
| **Finance Reports Beta** | Customer/vendor ledger entries | `api/microsoft/reportsFinance/beta/companies({guid})/...` |
|
|
167
|
+
|
|
168
|
+
All APIs share the same OAuth 2.0 credentials (Azure AD client credentials flow).
|
|
84
169
|
|
|
85
170
|
## Environment Variables
|
|
86
171
|
|
|
@@ -96,22 +181,50 @@ Per-account ledger view with running balance and vendor information.
|
|
|
96
181
|
| `BC_COMPANY_FQ01` | Yes | Company GUID for store FQ01 |
|
|
97
182
|
| `BC_COMPANY_FQ28` | No | Company GUID for store FQ28 |
|
|
98
183
|
| `BC_COMPANY_FQ88` | No | Company GUID for store FQ88 |
|
|
99
|
-
| `LOG_LEVEL` | No |
|
|
184
|
+
| `LOG_LEVEL` | No | `debug`, `info`, `warn`, `error` (default: `info`) |
|
|
100
185
|
|
|
101
186
|
## Chart of Accounts
|
|
102
187
|
|
|
103
188
|
10 expense categories mapped to account ranges 60000-99999:
|
|
104
189
|
|
|
105
|
-
1. **Planta Fisica** (60000-60999)
|
|
106
|
-
2. **Alquiler Equipos** (61000-61999)
|
|
107
|
-
3. **Logistica** (62000-62999)
|
|
108
|
-
4. **Marketing** (63000-63999)
|
|
109
|
-
5. **Administrativos** (64000-64999)
|
|
110
|
-
6. **Seguros** (65000-65999)
|
|
111
|
-
7. **Bancarios** (67000-67999)
|
|
112
|
-
8. **Servicios Contratados** (68000-68999)
|
|
113
|
-
9. **Nomina** (70000-74999)
|
|
114
|
-
10. **Otros** (80000-99999)
|
|
190
|
+
1. **Planta Fisica** (60000-60999) — Rent, utilities
|
|
191
|
+
2. **Alquiler Equipos** (61000-61999) — Equipment rental
|
|
192
|
+
3. **Logistica** (62000-62999) — Vehicles, delivery
|
|
193
|
+
4. **Marketing** (63000-63999) — Advertising, commissions
|
|
194
|
+
5. **Administrativos** (64000-64999) — Office, software
|
|
195
|
+
6. **Seguros** (65000-65999) — Insurance
|
|
196
|
+
7. **Bancarios** (67000-67999) — Banking fees, interest
|
|
197
|
+
8. **Servicios Contratados** (68000-68999) — Contracted services
|
|
198
|
+
9. **Nomina** (70000-74999) — Payroll, benefits
|
|
199
|
+
10. **Otros** (80000-99999) — Depreciation, other
|
|
200
|
+
|
|
201
|
+
## Architecture
|
|
202
|
+
|
|
203
|
+
```
|
|
204
|
+
mcp-fullqueso-bc-gastos/
|
|
205
|
+
├── server.js # MCP server entry point (22 tools)
|
|
206
|
+
├── lib/
|
|
207
|
+
│ ├── bc-client.js # OAuth + BC API (v2.0, OData V4, Beta)
|
|
208
|
+
│ ├── expense-analyzer.js
|
|
209
|
+
│ ├── ratio-calculator.js
|
|
210
|
+
│ ├── anomaly-detector.js
|
|
211
|
+
│ ├── trend-analyzer.js
|
|
212
|
+
│ └── formatter.js
|
|
213
|
+
├── config/
|
|
214
|
+
│ ├── expense-accounts.js
|
|
215
|
+
│ ├── income-accounts.js
|
|
216
|
+
│ ├── benchmarks.js
|
|
217
|
+
│ ├── company-config.js
|
|
218
|
+
│ └── bank-keywords.js
|
|
219
|
+
├── tools/
|
|
220
|
+
│ ├── [9 expense/vendor tools]
|
|
221
|
+
│ ├── auditoria/ # 7 bank reconciliation tools
|
|
222
|
+
│ └── cobranzas/ # 6 AR/AP tools
|
|
223
|
+
└── utils/
|
|
224
|
+
├── date-helper.js
|
|
225
|
+
├── currency-converter.js
|
|
226
|
+
└── logger.js
|
|
227
|
+
```
|
|
115
228
|
|
|
116
229
|
## License
|
|
117
230
|
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
// Bank Statement Keywords → GL Account Mapping
|
|
2
|
+
// Used by suggest_journal_entries tool for automatic categorization
|
|
3
|
+
// Keywords are matched case-insensitively against bank statement descriptions
|
|
4
|
+
|
|
5
|
+
export const BANK_KEYWORDS = [
|
|
6
|
+
// Servicios públicos
|
|
7
|
+
{ keywords: ['CANTV', 'MOVISTAR', 'DIGITEL'], account: '60530', name: 'Telecomunicaciones' },
|
|
8
|
+
{ keywords: ['CORPOELEC', 'ELECTRICIDAD'], account: '60510', name: 'Electricidad' },
|
|
9
|
+
{ keywords: ['HIDRO', 'AGUA'], account: '60520', name: 'Agua' },
|
|
10
|
+
{ keywords: ['ASEO'], account: '60540', name: 'Aseo Urbano' },
|
|
11
|
+
|
|
12
|
+
// Gastos bancarios
|
|
13
|
+
{ keywords: ['COMISION', 'COMISIÓN'], account: '67100', name: 'Comisiones Bancarias' },
|
|
14
|
+
{ keywords: ['ITF', 'IGTF', 'IDB'], account: '67200', name: 'Impuestos Transacciones Financieras' },
|
|
15
|
+
{ keywords: ['INTERES', 'INTERÉS', 'INTERESES'], account: '67300', name: 'Intereses Bancarios' },
|
|
16
|
+
|
|
17
|
+
// Nómina
|
|
18
|
+
{ keywords: ['NOMINA', 'NÓMINA'], account: '71100', name: 'Sueldos y Salarios' },
|
|
19
|
+
{ keywords: ['BONO', 'BONIFICACION'], account: '71120', name: 'Bonos' },
|
|
20
|
+
|
|
21
|
+
// Alquiler
|
|
22
|
+
{ keywords: ['ALQUILER', 'ARRENDAMIENTO', 'CANON'], account: '60110', name: 'Alquiler Local' },
|
|
23
|
+
|
|
24
|
+
// Seguros
|
|
25
|
+
{ keywords: ['SEGURO', 'POLIZA', 'PÓLIZA'], account: '65100', name: 'Seguros' },
|
|
26
|
+
|
|
27
|
+
// POS / Ventas (credits)
|
|
28
|
+
{ keywords: ['PUNTO DE VENTA', 'POS', 'VISA', 'MASTERCARD'], account: '11300', name: 'Depósito POS' },
|
|
29
|
+
|
|
30
|
+
// Transfers
|
|
31
|
+
{ keywords: ['TRANSF RECIBIDA', 'TRANSFERENCIA RECIBIDA'], account: '11000', name: 'Transferencia Recibida' },
|
|
32
|
+
{ keywords: ['TRANSF ENVIADA', 'TRANSFERENCIA ENVIADA'], account: '11000', name: 'Transferencia Enviada' },
|
|
33
|
+
];
|
|
34
|
+
|
|
35
|
+
// Match a bank description against keywords
|
|
36
|
+
// Returns { account, name } or null if no match
|
|
37
|
+
export function matchBankDescription(description) {
|
|
38
|
+
if (!description) return null;
|
|
39
|
+
const upper = description.toUpperCase();
|
|
40
|
+
|
|
41
|
+
for (const rule of BANK_KEYWORDS) {
|
|
42
|
+
for (const keyword of rule.keywords) {
|
|
43
|
+
if (upper.includes(keyword.toUpperCase())) {
|
|
44
|
+
return { account: rule.account, name: rule.name };
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
return null;
|
|
50
|
+
}
|
package/config/company-config.js
CHANGED
|
@@ -5,18 +5,21 @@ function getStores() {
|
|
|
5
5
|
return {
|
|
6
6
|
FQ01: {
|
|
7
7
|
companyId: process.env.BC_COMPANY_FQ01,
|
|
8
|
+
companyName: 'Alimentos%20FQ-01',
|
|
8
9
|
name: 'FQ01 Chacao',
|
|
9
10
|
shortName: 'Chacao',
|
|
10
11
|
location: 'Chacao, Caracas',
|
|
11
12
|
},
|
|
12
13
|
FQ28: {
|
|
13
14
|
companyId: process.env.BC_COMPANY_FQ28,
|
|
15
|
+
companyName: 'Alimentos%20FQ-28',
|
|
14
16
|
name: 'FQ28 Marqués',
|
|
15
17
|
shortName: 'Marqués',
|
|
16
18
|
location: 'El Marqués, Caracas',
|
|
17
19
|
},
|
|
18
20
|
FQ88: {
|
|
19
21
|
companyId: process.env.BC_COMPANY_FQ88,
|
|
22
|
+
companyName: 'Alimentos%20FQ-88',
|
|
20
23
|
name: 'FQ88 Candelaria',
|
|
21
24
|
shortName: 'Candelaria',
|
|
22
25
|
location: 'La Candelaria, Caracas',
|