toga-ai 1.0.160 → 1.0.161
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.
|
@@ -2,5 +2,5 @@
|
|
|
2
2
|
|
|
3
3
|
| Doc | Framework | Summary | Files |
|
|
4
4
|
|-----|-----------|---------|-------|
|
|
5
|
-
| [Credit Card Receipt Processing](features/receipt-processing.md) | 2.0 | Automated processing of credit card receipts uploaded to SharePoint. | worker2/Worker/Client/TowFoundation.php, worker2/Worker/Client/TowFoundation/ProcessReceipts.php, worker2/Worker/Client/TowFoundation/TowFoundationVendors.php |
|
|
5
|
+
| [Credit Card Receipt Processing](features/receipt-processing.md) | 2.0 | Automated processing of credit card receipts uploaded to SharePoint. | worker2/Worker/Client/TowFoundation.php, worker2/Worker/Client/TowFoundation/ProcessReceipts.php, worker2/Worker/Client/TowFoundation/TowFoundationVendors.php, worker2/Worker/Client/TowFoundation/TowFoundationCategories.php |
|
|
6
6
|
| [Tow Foundation](profile.md) | 2.0 | Tow Foundation is a nonprofit client. | |
|
|
@@ -5,12 +5,13 @@ project: Worker
|
|
|
5
5
|
client: tow-foundation
|
|
6
6
|
type: client-feature
|
|
7
7
|
status: active
|
|
8
|
-
updated: 2026-06-
|
|
8
|
+
updated: 2026-06-23
|
|
9
9
|
owners: ["rgirish"]
|
|
10
10
|
files:
|
|
11
11
|
- worker2/Worker/Client/TowFoundation.php
|
|
12
12
|
- worker2/Worker/Client/TowFoundation/ProcessReceipts.php
|
|
13
13
|
- worker2/Worker/Client/TowFoundation/TowFoundationVendors.php
|
|
14
|
+
- worker2/Worker/Client/TowFoundation/TowFoundationCategories.php
|
|
14
15
|
related:
|
|
15
16
|
- clients/tow-foundation/profile.md
|
|
16
17
|
---
|
|
@@ -86,7 +87,7 @@ Amex billing cycle runs 3rd-to-3rd. `computeRefNo()` returns the cycle-end date
|
|
|
86
87
|
`TowFoundationVendors.php` holds 2,994 vendor names exported verbatim from Tow Foundation's
|
|
87
88
|
QuickBooks vendor list (June 2026). `matchQbVendor()` runs three passes against this list:
|
|
88
89
|
1. Exact match (case-insensitive)
|
|
89
|
-
2. Substring match — QB name contains extracted name or vice versa
|
|
90
|
+
2. Substring match — QB name contains extracted name or vice versa; minimum 3 chars. For needles shorter than 4 chars, a **whole-word boundary check** is used (regex `(?<![a-z])<needle>(?![a-z])`) to prevent short acronyms like `"UPS"` from matching inside `"USPS"`. Picks shortest QB name on multiple hits.
|
|
90
91
|
3. `similar_text()` similarity ≥ 80% — picks highest scorer
|
|
91
92
|
|
|
92
93
|
Returns the exact QB vendor string or `''` if no confident match. The AI only extracts
|
|
@@ -95,11 +96,35 @@ Returns the exact QB vendor string or `''` if no confident match. The AI only ex
|
|
|
95
96
|
To update the vendor list: re-export from QuickBooks → run the extraction script →
|
|
96
97
|
replace `TowFoundationVendors.php`. The matching logic is in `matchQbVendor()` and needs no changes.
|
|
97
98
|
|
|
98
|
-
### AI category values
|
|
99
|
-
The AI is prompted to return **specific expense types
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
99
|
+
### AI category values and QB mapping
|
|
100
|
+
The AI is prompted to return **specific expense types**. These are then mapped to the exact
|
|
101
|
+
QB account string via `mapCategory()`, which loads `TowFoundationCategories.php` and does
|
|
102
|
+
a case-insensitive lookup. Unmapped values are passed through as-is and logged as warnings.
|
|
103
|
+
|
|
104
|
+
| AI category value | QB account string |
|
|
105
|
+
|---|---|
|
|
106
|
+
| `Dining` | `6640 Dining & Entertainment` |
|
|
107
|
+
| `Entertainment` | `6640 Dining & Entertainment` |
|
|
108
|
+
| `Travel` | `6609 Travel, conferences, meetings` |
|
|
109
|
+
| `Transportation` | `6610 Travel expense` |
|
|
110
|
+
| `Accommodation` / `Lodging` | `6620 Lodging` |
|
|
111
|
+
| `Office Supplies` | `6751 Office supplies` |
|
|
112
|
+
| `Professional Services` | `6400 Professional Fees & Consultants` |
|
|
113
|
+
| `Subscriptions` | `67271 Subscriptions` |
|
|
114
|
+
| `Technology` | `6710 Technology Systems Expense` |
|
|
115
|
+
| `Software` | `6714 Software License Expense` |
|
|
116
|
+
| `Printing` | `6722 Printing expense` |
|
|
117
|
+
| `Postage` | `6721 Postage` |
|
|
118
|
+
| `Membership` | `6730 Membership Dues` |
|
|
119
|
+
| `Insurance` | `6740 Insurance` |
|
|
120
|
+
| `Telephone` | `6755 Telephone & internet expense` |
|
|
121
|
+
| `Photography` | `67241 Photography` |
|
|
122
|
+
| `Board` | `6650 Board Expenses and Board Development` |
|
|
123
|
+
| `Professional Development` | `6735 Staff Professional Development` |
|
|
124
|
+
|
|
125
|
+
To update the mapping: edit `TowFoundationCategories.php` — keys are case-insensitive,
|
|
126
|
+
values must be the exact QB account string. The AI prompt in `extractReceiptData()` lists
|
|
127
|
+
the valid category names; keep them in sync with the map keys.
|
|
103
128
|
|
|
104
129
|
### Per-person constants
|
|
105
130
|
`CLASS_MAP` and `PAYMENT_ACCOUNT_MAP` in `ProcessReceipts.php` map each cardholder's name
|
|
@@ -158,9 +183,13 @@ Fatal errors send only to `NOTIFY_EMAIL_DEV` (no CC/BCC).
|
|
|
158
183
|
- **`billingCycle` filter is suffix-match, not exact** — always pass just the date portion (`"06-03-2026"`), not the full folder name. Passing the full name (`"Amex ending in 06-03-2026"`) also works but would miss Mastercard folders.
|
|
159
184
|
- **Ole Mole not in QB vendor list** — as of June 2026 this vendor is not in Tow Foundation's QuickBooks, so `qb_vendor` will be blank for Ole Mole charges until they add it to QB and the vendor list is refreshed.
|
|
160
185
|
- **Duplicate detection is within-run only** — if the same receipt was processed in a prior run and archived, it won't be caught. The dedup only covers receipts present in the current run's `$pendingRenames`.
|
|
186
|
+
- **Unmapped AI categories pass through** — if the AI returns a category string not in `TowFoundationCategories.php`, `mapCategory()` logs a warning and writes the raw AI string to the Excel. Check error logs after a run if the Category column looks odd; add the new value to the map file to fix it.
|
|
187
|
+
- **Short vendor acronyms (< 4 chars) require whole-word match** — the substring pass uses a word-boundary regex for needles under 4 chars to avoid false positives (e.g. `"UPS"` inside `"USPS"`). If a short vendor name is not matching, check that the QB vendor list entry starts or ends with the acronym as a whole word.
|
|
188
|
+
- **Archive restore script** — a one-shot CLI script `/tmp/tow_restore_archives.php` was written 2026-06-23 to move archived files back to their billing-cycle folders for reprocessing. It is not committed; re-create from the session transcript if needed. It uses the production credentials from `Config/production.ini`.
|
|
161
189
|
|
|
162
190
|
## Change history
|
|
163
191
|
|
|
192
|
+
- 2026-06-23 — `TowFoundationCategories.php` added: AI category values now mapped to exact QB account strings via `mapCategory()`; `"Transportation"` → `"6610 Travel expense"` etc. (19 mappings). QB vendor substring match minimum lowered from 4 to 3 chars with whole-word boundary guard for short needles — fixes `"CVS"` → `"CVS Pharmacy"`, `"MTA"` → `"MTA Metro card"`, prevents `"UPS"` → `"USPS"` false positive. (rgirish)
|
|
164
193
|
- 2026-06-18 — QB vendor matching via local fuzzy match against `TowFoundationVendors.php` (2,994 vendors); AI category prompt updated to return specific types (Dining, Travel, etc.); duplicate receipt detection added (person+date+vendor+amount dedup); `billingCycle` filter parameter added (suffix-match — card-type agnostic); person folder ` CC receipts` suffix stripped so CLASS_MAP/PAYMENT_ACCOUNT_MAP resolve correctly (rgirish)
|
|
165
194
|
- 2026-06-12 — QB Excel upload moved to root-level `3. QB Excel/`; Archive/exception folders flattened (no person subfolder); unsupported mime types (`application/octet-stream`) now throw ReceiptProcessingException instead of being silently skipped (rgirish)
|
|
166
195
|
- 2026-06-11 — Added CC (Magdalena), BCC (devteam@togatech.com), per-cardholder Archive subfolders, Excel upload to "3. QB Excel" SharePoint folder, two-pass rename with alphabetical duplicate suffix, rename format changed to `YYYY.MM.DD Full Name_Vendor_Amount` (rgirish)
|
package/package.json
CHANGED