Commit Graph

59 Commits

Author SHA1 Message Date
03c18f6782 plan(07-pre-expansion-fixes): create 5 plans for pre-expansion fixes
07-01: Performance — N+1 subqueries, information_schema static, DB indexes
07-02: Stability — SSL verification (4 clients), cron throttle→DB, migration 000014b
07-03: UX — orderpro_to_allegro disable, orders list items 14-17
07-04: Tests — AllegroTokenManager + AllegroOrderImportService unit tests
07-05: InPost ShipmentProviderInterface (replaces allegro_wza workaround)

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-13 17:44:42 +01:00
e01b68f559 chore(milestone): complete v0.1 Initial Release — archive, MILESTONES.md, ROADMAP reorganized
v0.1 Initial Release: 6 phases, 15 plans complete.
- Created .paul/MILESTONES.md with milestone entry
- Archived to .paul/milestones/v0.1-ROADMAP.md
- ROADMAP.md reorganized (milestone collapsed to Completed section)
- STATE.md cleared for next milestone

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-13 17:29:57 +01:00
aaa5d2fc25 feat(06-sonarqube-quality): phase 06 complete — SonarQube Quality 6/6 plans, milestone v0.1 done
Phase 06 summary:
- 06-01: typed exception hierarchy (S112: 95x eliminated)
- 06-02: return statement reduction (S1142: 57x reduced)
- 06-03: string literal constants (S1192: 40x eliminated)
- 06-04: cognitive complexity reduction (S3776: 31x reduced)
- 06-06: long method extraction (S138: 4x eliminated)
- 06-05: god class split — ShopproOrdersSyncService 39→9 methods, AllegroIntegrationController 35→25 methods (S1448: 6x→2x)

Milestone v0.1 Initial Release: 6/6 phases complete.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-13 17:27:41 +01:00
fbb3020180 docs(06-sonarqube-quality): close loop 06-05 — UNIFY complete
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-13 17:26:03 +01:00
eb5c9bf345 feat(06-sonarqube-quality): split god classes — ShopproOrdersSyncService + AllegroIntegrationController (06-05)
ShopproOrdersSyncService: 39→9 methods via ShopproOrderMapper + ShopproProductImageResolver.
AllegroIntegrationController: 35→25 methods via AllegroStatusMappingController + AllegroDeliveryMappingController.
S1448 violations: 6x→2x. CronHandlerFactory and routes/web.php updated.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-13 17:25:59 +01:00
ddf767926e docs(06-sonarqube-quality): close loop 06-04 — UNIFY complete
SUMMARY.md with AC results, deviations, skill audit.
STATE.md updated: 5/6 plans complete, next → 06-05.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-13 14:27:47 +01:00
8f56dab513 feat(06-sonarqube-quality): reduce cognitive complexity in loadDeliveryServices (S3776 fix, 06-04)
Extract private helpers to flatten 5-level nesting in AllegroIntegrationController
and ShopproIntegrationsController: loadAllegroDeliveryServices(),
fetchAllegroDeliveryResponse(), loadApaczkaServices().
sync() and saveStatusMappings() were already compliant from plan 06-06.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-13 14:22:52 +01:00
91bc9914c6 wip(06-sonarqube-quality): paused after 06-06 UNIFY — 4/6 plans complete
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-13 12:39:52 +01:00
42e647f007 feat(06-sonarqube-quality): extract long methods to fix S138 violations (06-06)
ShopproOrdersSyncService: sync() 195→44 lines via syncOneIntegration,
fetchOrdersPage, processPageCandidates, importOneOrder; mapAddresses()
166→34 lines via buildCustomerAddress, buildDeliveryAddress.

OrdersRepository: paginate() 183→69 lines via buildPaginateFilters,
buildListSql, transformOrderRow; findDetails() 101→40 lines via
loadOrderAddresses/Items/Payments/Shipments/Documents/Notes/StatusHistory.

SonarQube S138 violations: 4 → 0.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-13 12:33:12 +01:00
ae976b7964 wip(06-sonarqube-quality): paused after 06-02 UNIFY — 3/6 plans complete
06-01 (S112 exceptions), 06-02 (S1142 returns), 06-03 (S1192 constants) done.
Next: 06-06 → 06-04 → 06-05

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-13 12:06:30 +01:00
028c46c685 feat(06-sonarqube-quality): reduce return statements to ≤3 (S1142 fix)
Extract validation helpers in AllegroIntegrationController:
- validateSaveInput(): ?string (save: 6→3 returns)
- validateImportSettingsInput(): ?string (saveImportSettings: 5→3 returns)
- validateOAuthCallbackParams(): ?string (oauthCallback: 4→3 returns)

Extract validation helpers in ShopproIntegrationsController:
- validateSaveAccess(): ?Response (save: 9→3 returns)
- validateSaveInput(): ?string (save field validation)
- validateCsrfAndIntegrationAccess(): ?Response (saveStatusMappings/syncStatuses: 4→3 returns)

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-13 11:57:18 +01:00
d7d3f996cc feat(06-sonarqube-quality): extract string literals to constants (S1192 fix)
- Add IntegrationSources {ALLEGRO, SHOPPRO, APACZKA, INPOST} and RedirectPaths constants in src/Core/Constants/
- Replace integration source literals in AllegroOrderImportService, AllegroStatusSyncService, ShopproOrdersSyncService, ShopproPaymentStatusSyncService
- Replace redirect path literals in AllegroIntegrationController (24+ occurrences) and ShopproIntegrationsController (3 occurrences)
- Auto-fix: broken use statements from plan 06-01 in AllegroOrderImportService and AllegroIntegrationController (missing backslashes)

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-13 11:28:23 +01:00
3c27c4e54a feat(06-sonarqube-quality): introduce typed exception hierarchy (S112 fix)
Replace 86+ generic RuntimeException throws with domain-specific exception
classes: AllegroApiException, AllegroOAuthException, ApaczkaApiException,
ShipmentException, IntegrationConfigException — all extending OrderProException
extends RuntimeException. Existing catch(RuntimeException) blocks unaffected.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-13 11:04:52 +01:00
3a9cfcd4a2 wip(06-sonarqube-quality): 6 planów SonarQube Quality utworzonych
Plany dla php:S112, S1142, S1192, S3776, S1448, S138 — gotowe do APPLY.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-13 10:54:57 +01:00
2d4b52adfc feat(04-schema-docs): annotate ensure_* compensating migrations and update DB_SCHEMA.md
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-13 10:15:58 +01:00
9a0dbe050b update 2026-03-13 01:00:28 +01:00
7b29fd9e02 feat(03-tech-debt): standardize CSRF field name to _token
Phase 3 complete:
- Zmieniono _csrf_token -> _token w OrdersController (1x), ShipmentController (2x)
- Zmieniono name="_csrf_token" -> name="_token" w orders/show.php (1x), shipments/prepare.php (2x)
- Usunięto concern z .paul/codebase/CONCERNS.md

Co-Authored-By: Claude <noreply@anthropic.com>
2026-03-13 00:58:59 +01:00
880ab5933f feat(02-bug-fixes): extract CronHandlerFactory, complete Phase 2
Phase 2 complete (4/4 plans):
- Plan 02-01: Fix dead ZPL page size condition in AllegroShipmentService
- Plan 02-02: Add time-based cursor to AllegroStatusSyncService
- Plan 02-03: Fix ShopproOrdersSyncService using wrong state repository
- Plan 02-04: Extract CronHandlerFactory as single cron composition point

Plan 02-04 specifics:
- New CronHandlerFactory builds complete cron object graph
- Application::maybeRunCronOnWeb() reduced from 80+ to ~20 lines
- bin/cron.php reduced from 123 to 26 lines
- Fixed 2 bugs: AllegroOAuthClient→AllegroTokenManager,
  AllegroOrderSyncStateRepository→ShopproOrderSyncStateRepository

Co-Authored-By: Claude <noreply@anthropic.com>
2026-03-13 00:43:04 +01:00
87203c4321 fix(02-bug-fixes): fix 3 known bugs from CONCERNS.md
Phase 02 plans 02-01, 02-02, 02-03:

- fix(02-01): dead condition in AllegroShipmentService ZPL page size
  Both ternary branches returned 'A6'; ZPL now correctly returns 'ZPL'

- fix(02-02): add last_status_checked_at cursor to AllegroStatusSyncService
  New migration adds orders.last_status_checked_at DATETIME NULL with
  composite index (source, source_updated_at). findOrdersNeedingStatusSync()
  filters by cursor; markOrderStatusChecked() records timestamp on success.

- fix(02-03): replace AllegroOrderSyncStateRepository in ShopproOrdersSyncService
  New ShopproOrderSyncStateRepository (same table, correct class name).
  Application.php wires correct repository to correct service.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-13 00:26:07 +01:00
f8db8c0162 refactor(01-tech-debt): extract AllegroTokenManager and StringHelper
Phase 1 complete (2/2 plans):

- Plan 01-01: Extract AllegroTokenManager — OAuth token logic
  centralized from 4 classes into dedicated manager class

- Plan 01-02: Extract StringHelper — nullableString/normalizeDateTime/
  normalizeColorHex extracted from 15+ classes into App\Core\Support\StringHelper;
  removed 19 duplicate private methods

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-12 23:36:06 +01:00
4c3daf69b7 docs: add codebase map to .paul/codebase/
Auto-generated by paul:map-codebase — 4 parallel analysis agents.
Covers stack, architecture, conventions, and concerns.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-12 21:42:24 +01:00
2b12fde248 feat(shipments): add ShipmentProviderInterface and ShipmentProviderRegistry
- Introduced ShipmentProviderInterface to define the contract for shipment providers.
- Implemented ShipmentProviderRegistry to manage and retrieve shipment providers.
- Added a new tool for probing Apaczka order_send payload variants, enhancing debugging capabilities.
2026-03-08 23:45:10 +01:00
af052e1ff5 feat: add Shoppro payment status synchronization service
- Implemented ShopproPaymentStatusSyncService to handle payment status synchronization between Shoppro and Orderpro.
- Added methods for resolving watched status codes, finding candidate orders, and syncing individual order payments.
- Introduced ShopproStatusMappingRepository for managing status mappings between Shoppro and Orderpro.
- Created ShopproStatusSyncService to facilitate synchronization of order statuses from Shoppro to Orderpro.
2026-03-08 20:41:10 +01:00
3ba6202770 feat: Enhance InPost service selection and handling in Allegro settings
- Added a check for available InPost services and display a message if none are found.
- Updated the InPost service selection dropdown to include additional data attributes for better handling in JavaScript.
- Improved JavaScript event handling for InPost service selection to correctly populate hidden fields with selected service data.

feat: Introduce Cash on Delivery (COD) functionality in shipment preparation

- Added a new input field for specifying the COD amount and currency in the shipment preparation view.
- Updated the shipment creation logic to handle COD amounts correctly when creating shipments.

refactor: Update OrdersController to include shipment package repository

- Modified the OrdersController to accept a ShipmentPackageRepository for better management of shipment-related data.
- Enhanced order details to include shipment package information.

fix: Ensure internal order numbers are generated upon order creation

- Updated the OrderImportRepository to generate and store internal order numbers when a new order is created.

feat: Implement status synchronization for Allegro orders

- Introduced a new service for syncing order statuses from Allegro to the internal system.
- Added logic to fetch and process orders needing status updates, handling errors gracefully.

chore: Clean up InPost service definitions in AllegroIntegrationController

- Removed hardcoded InPost service definitions and replaced them with dynamic fetching based on available services.

feat: Add activity logging for shipment actions

- Implemented activity logging for various shipment actions, including creation, label downloads, and errors, to improve traceability and auditing.
2026-03-06 20:09:59 +01:00
1b5e403c31 Add Allegro shipment service and related components
- Implement AllegroShipmentService for managing shipment creation and status checks.
- Create ShipmentController to handle shipment preparation and label downloading.
- Introduce ShipmentPackageRepository for database interactions related to shipment packages.
- Add methods for retrieving delivery services, creating shipments, checking creation status, and downloading labels.
- Implement address validation and token management for Allegro API integration.
2026-03-06 01:06:59 +01:00
9df7a63244 feat: Enhance order date handling with effective date fallback and update documentation 2026-03-04 23:56:45 +01:00
7ac4293df4 feat: Implement Allegro Order Sync and Status Management
- Added AllegroOrderSyncStateRepository for managing sync state with Allegro orders.
- Introduced AllegroOrdersSyncService to handle the synchronization of orders from Allegro.
- Created AllegroStatusDiscoveryService to discover and store order statuses from Allegro.
- Developed AllegroStatusMappingRepository for managing status mappings between Allegro and OrderPro.
- Implemented AllegroStatusSyncService to facilitate status synchronization.
- Added CronSettingsController for managing cron job settings related to Allegro integration.
2026-03-04 23:21:35 +01:00
9ca79ca8d8 feat: Add guidelines for deploying code changes and testing procedures 2026-03-03 08:25:09 +01:00
c489891d15 Add Orders and Order Status repositories with pagination and management features
- Implemented OrdersRepository for handling order data with pagination, filtering, and sorting capabilities.
- Added methods for retrieving order status options, quick stats, and detailed order information.
- Created OrderStatusRepository for managing order status groups and statuses, including CRUD operations and sorting.
- Introduced a bootstrap file for test environment setup and autoloading.
2026-03-03 01:32:28 +01:00
d1576bc4ab feat: Implement pagination and filtering for linked offers by integration
- Refactored `listLinkedOffersByIntegration` to `paginateLinkedOffersByIntegration` in `MarketplaceRepository`.
- Added pagination support with `page` and `per_page` filters.
- Introduced sorting options for offers.
- Created `listOfferChannelsByIntegration` method to retrieve distinct sales channels.
- Enhanced SQL queries to support dynamic filtering based on provided parameters.

feat: Add new fields for products and SKU generation

- Introduced new fields: `new_to_date`, `additional_message`, `additional_message_required`, and `additional_message_text` in the `products` table.
- Added `findAllSkus` method in `ProductRepository` to retrieve all SKUs.
- Created `ProductSkuGenerator` class to handle SKU generation based on a configurable format.
- Implemented `nextSku` method to generate the next available SKU.

feat: Enhance product settings management in the UI

- Added new settings page for product SKU format in `SettingsController`.
- Implemented form handling for saving SKU format settings.
- Updated the view to include SKU format configuration options.

feat: Implement cron job for refreshing ShopPro offer titles

- Created `ShopProOfferTitlesRefreshHandler` to handle the cron job for refreshing offer titles.
- Integrated with the `OfferImportService` to import offers from ShopPro.

docs: Update database schema documentation

- Added documentation for new fields in the `products` table and new cron job for offer title refresh.
- Documented the purpose and structure of the `app_settings` table.

migrations: Add necessary migrations for new features

- Created migration to add `products_sku_format` setting in `app_settings`.
- Added migration to introduce new fields in the `products` table.
- Created migration for the new cron job schedule for refreshing ShopPro offer titles.
2026-03-01 22:05:21 +01:00
bcf078baac update 2026-02-27 21:43:15 +01:00
1cbbc76a17 feat: cache-bust assets, fix XSS and filemtime error handling, clean up users filters
- Add ?ver=<filemtime> cache-busting to CSS/JS assets in app and auth layouts
- Use ?: 0 fallback on filemtime() to prevent E_WARNING when files are missing
- Escape security_information output with $e() to fix XSS vulnerability (show.php:91)
- Wrap product image metadata in __meta container, move storage path into <details>
- Add table--details CSS class and th { white-space: nowrap } rule
- Remove redundant sort, sort_dir, per_page filter dropdowns from users list
- Add 10 as a per-page option in users list
- Clean up completed items from TODO.md

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-02-27 21:40:17 +01:00
bfff05a61b fix: include languages.pl content when saving categories to shopPRO
shopPRO's products/update clears ALL language fields (name, description,
short_description, etc.) for any language not included in the payload.
Sending only {"categories":[...]} wiped them out.

saveProductCategoriesJson() now:
1. Looks up the local orderPRO product via findMappedProductId()
2. Loads per-integration translation (with global fallback)
3. Includes languages.pl in the payload alongside categories

Also adds ProductRepository to MarketplaceController constructor.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-02-27 19:27:39 +01:00
a2a7934de6 fix: export per-integration name/description to shopPRO with global fallback
mapProductPayload() now receives the per-integration translation row for
the target integration. For name, short_description, and description it
uses the integration-specific value when set (non-null), and falls back
to the global product_translations value otherwise.

loadIntegrationTranslation() helper fetches the row from
product_integration_translations for the given product+integration pair.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-02-27 19:20:24 +01:00
ff5a9cef97 feat: add category assignment translation keys
Add marketplace.fields.categories, marketplace.actions.assign_categories,
and marketplace.category_modal section with all modal UI strings.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-02-27 19:15:28 +01:00
f1b5ba90bd fix: address code quality issues in category assignment modal
- Add btn--sm class to assign-categories button
- Force DOM reflow in openModal() so CSS transition fires correctly
- Clear treeEl.innerHTML at start of renderTree() to prevent stale tree
  on rapid double-click (race between two parallel fetch pairs)

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-02-27 19:14:07 +01:00
f5b9f81077 feat: add category assignment column, modal, and JS to marketplace offers view
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-02-27 19:07:07 +01:00
72b9de7ad2 fix: use short class names in MarketplaceController (add use imports)
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-02-27 19:05:12 +01:00
da5864d5a2 feat: register category AJAX routes and update MarketplaceController constructor
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-02-27 19:02:27 +01:00
7fd29e9758 feat: add categoriesJson, productCategoriesJson, saveProductCategoriesJson to MarketplaceController
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-02-27 18:59:28 +01:00
d7306be80f feat: add ShopProClient::fetchCategories() method 2026-02-27 18:56:16 +01:00
cad7ff5f94 feat: move content tabs between form fields and images section 2026-02-27 18:27:57 +01:00
33be5affa3 fix: whitelist integration_id against known integrations in product update 2026-02-27 18:26:34 +01:00
5d192427ec feat: add content_tabs translation key 2026-02-27 18:24:02 +01:00
a70b327960 feat: add per-integration content tabs to product edit form with CSS and JS
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-02-27 18:21:56 +01:00
571f0a990f feat: load and save per-integration content in product edit/update
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-02-27 18:18:12 +01:00
d51353e5cc feat: save per-integration name/short_description/description on product import 2026-02-27 18:15:54 +01:00
7b25e2e507 feat: add findIntegrationTranslations and upsertIntegrationTranslation to ProductRepository 2026-02-27 18:14:56 +01:00
5b64bb872b feat: add findIntegrationTranslations and upsertIntegrationTranslation to ProductRepository
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-02-27 18:13:44 +01:00
86a74bec93 docs: add inline comments to product_integration_translations migration 2026-02-27 18:12:58 +01:00