Skip to content

Fix/orders custom fields mapping - #1027

Merged
btravisebsco merged 3 commits into
mainfrom
fix/orders-custom-fields-mapping
Jul 21, 2026
Merged

Fix/orders custom fields mapping#1027
btravisebsco merged 3 commits into
mainfrom
fix/orders-custom-fields-mapping

Conversation

@btravisebsco

Copy link
Copy Markdown
Contributor

Purpose

Orders customFields mappings defined in the JSON mapping file were not being applied to transformed order output. This caused configured custom fields to be silently dropped for both top-level purchase orders and embedded purchase order lines.

Changes Made in this PR

  • Added schema injection logic in the orders mapper to dynamically register mapped customFields keys before transformation.
  • Supported both mapping paths:
    • top-level order custom fields
    • embedded PO line custom fields
  • Kept compatibility with both schema variants for line arrays by using the detected line key.
  • Added a regression test that verifies custom field mapping is preserved in output for:
    • order-level custom fields
    • PO line-level custom fields

Code Review Specifics

  • Please focus review on:
    • Dynamic schema mutation safety and maintainability
    • Behavior across schema variants for purchase order lines
    • Regression test realism and coverage of expected mapping behavior

Task Checklist

  • Ran nox -rs safety
  • Ran pre-commit run --all-files
  • Tests cover new or modified code
  • Ran test suite: nox -rs tests
  • Code runs and outputs default usage info: cd src; poetry run python3 -m folio_migration_tools -h
  • Documentation updated

Warning Checklist

  • New dependencies added
  • Includes breaking changes

How to Verify

  1. Check out branch fix/orders-custom-fields-mapping.

  2. Run targeted regression tests:

    pytest test_orders_mapper.py

  3. Confirm the custom fields test passes and validates that mapped custom fields are present in transformed order output for both:

    • customFields.
    • line-array customFields.

Open Questions

  • Should customFields support additional non-string types from mapping configuration, or remain string-only as currently implemented?

Learn Anything Cool?

Schema-defined open objects with empty properties can still block mapper traversal if mapping logic depends on explicit schema properties. Dynamically injecting mapped keys into schema is an effective way to preserve strict mapper behavior while enabling custom field extensibility.

@sonarqubecloud

Copy link
Copy Markdown

@codecov

codecov Bot commented Jul 21, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 80.70175% with 11 lines in your changes missing coverage. Please review.
✅ Project coverage is 81.80%. Comparing base (3374380) to head (a6bf445).

Files with missing lines Patch % Lines
..._tools/mapping_file_transformation/order_mapper.py 76.59% 6 Missing and 5 partials ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1027      +/-   ##
==========================================
- Coverage   81.80%   81.80%   -0.01%     
==========================================
  Files         117      117              
  Lines       18444    18501      +57     
  Branches     2137     2148      +11     
==========================================
+ Hits        15089    15135      +46     
- Misses       2919     2925       +6     
- Partials      436      441       +5     
Flag Coverage Δ
unittests 81.80% <80.70%> (-0.01%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@btravisebsco
btravisebsco merged commit 6aad957 into main Jul 21, 2026
4 of 5 checks passed
@btravisebsco
btravisebsco deleted the fix/orders-custom-fields-mapping branch July 21, 2026 06:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants