Commit Graph

8 Commits

Author SHA1 Message Date
8f45ccbee4 fix: correct category-page size and brand/category source of truth
Two fixes bundled together:

1. Shrink CATEGORY_PAGE_SIZE from 100 to 25. Each item in a category page
   can trigger several sequential BC calls (location stock, price lists,
   brand/category lookup) beyond the page fetch itself - at 100 items/page
   this measured 150-250+ seconds on live data, exceeding PHP's execution
   limit and leaving the Action Scheduler action stuck "in-progress"
   forever instead of completing or failing visibly.

2. BC's Item Category table has no parent-category field - confirmed via
   the actual published CategProd endpoint (Code, Description only) and
   the standard itemCategories entity (id, code, displayName only). The
   original ItemCategoryHierarchy AL snippet assumed a Parent Category
   field that doesn't exist. Switched to the standard /itemCategories API
   for the brand display name (no custom endpoint needed for that part),
   and replaced the BC-side parent-category walk with a WordPress-side
   manual map (wbc_category_parent_map: "CODE=Parent Name" per line) for
   the WooCommerce product category grouping, since BC has nothing to
   offer there.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
2026-07-09 14:41:59 +02:00
0aff5cf6d8 feat: category filter, item reference SKU lookup, brand sync, and on-demand BC write-back
- Filter product sync to an allow-list of BC item category codes
- Look up items by ReferenciasArticulo item reference before falling back to GTIN/item number
- Sync BC item category to product_brand and parent category to product_cat via a new ItemCategoryHierarchy endpoint
- Add on-demand push of product name/photo back to BC (product edit meta box + bulk action), including binary PATCH support for item pictures

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
2026-07-09 11:39:11 +02:00
5716ff7742 feat: add auto-release sales order option
PATCH salesOrders status to 'Released' after creation and line items.
Controlled by Auto-Release Order checkbox in Order Settings.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-17 16:12:11 +01:00
782681b30f feat: customer lookup by NIF with default customer fallback
- Search BC customers by taxRegistrationNumber (NIF/CIF from _nif meta)
- If NIF found in BC, use that customer; if not, create with NIF
- If no NIF on order, use configurable default customer number
- Add Default Customer Number setting in Order Settings tab

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-17 16:06:42 +01:00
2495b82e66 feat: integrate custom OData endpoints for stock and price sync
Replace broken itemLedgerEntries approach with custom ItemByLocation
OData V4 endpoint for location-specific stock. Add ListaPrecios
endpoint for price list sync (B2C regular, B2C_OF sale price) with
filters for active status and all-customers assignment.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-17 13:14:15 +01:00
2c36344932 feat: WooCommerce-first sync + location code filter
Reversed the product sync direction: instead of pulling all 60k+ items
from BC and matching against WooCommerce (600+ paginated API calls that
timeout), now iterates the ~100 WooCommerce products and queries BC for
each one by GTIN/item number (1-2 API calls per product).

Added Location Code setting (e.g. "ICP") to filter stock by BC location.
Uses Item Ledger Entries endpoint to sum per-location stock. Falls back
to total inventory if the endpoint is unavailable.

Also registered wbc_location_code in sync settings group and uninstall.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-17 10:26:02 +01:00
c06d6e4352 fix: client secret getting corrupted on save
Two bugs fixed:

1. sanitize_text_field() was stripping special characters from Azure AD
   client secrets (e.g. %XX sequences, angle brackets). Replaced with
   trim() to preserve the raw secret before encryption.

2. All settings tabs shared one option group (wbc_settings), so saving
   from any tab would trigger sanitize callbacks for ALL settings. This
   caused checkboxes on other tabs to reset to 'no' and could interfere
   with the client secret. Split into per-tab groups: wbc_connection,
   wbc_sync, wbc_orders.

Also clears OAuth token cache when client secret is changed.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-17 10:15:07 +01:00
b64397dcd3 feat: WooCommerce Business Central integration plugin
Native PHP plugin (no Composer) that syncs:
- Product stock and pricing from BC to WooCommerce (scheduled cron)
- Orders from WooCommerce to BC (on payment received)
- Auto-creates customers in BC from WooCommerce billing data

Product matching: WooCommerce SKU → BC Item Number, fallback to GTIN (EAN).
OAuth2 client credentials auth with encrypted secret storage.
Admin settings page with connection test, manual sync, and log viewer.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-17 09:59:53 +01:00