Improve Magento 2 order import to reflect true net values #135
+378
−2
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Overview
This PR addresses FED-1276 and improves the Magento 2 order import functionality to reflect true net order values that match what customers actually paid, resolving discrepancies between Magento and Clerk order totals.
Key Problems Solved
✅ 1. Discounts are now properly deducted
✅ 2. Shipping costs are now included
shipping_amountfield to include shipping in calculations✅ 3. VAT treatment is now consistent
✅ 4. Refunds are now reflected
Customer Impact Examples
250518000276642505190002774225051900027752Technical Changes
Files Modified
Controller/Order/Index.php: Enhanced product price calculation and added new order fieldsObserver/SalesOrderCreditmemoSaveAfterObserver.php: Real-time order updates on refundsModel/Api.php: Added order update functionalityNew Order Fields Available
total- True net order value (grand_total - refunded_amount)discount_amount- Total discounts appliedshipping_amount- Shipping coststax_amount- Tax amountrefunded_amount- Total refunded amountProduct Price Calculation
Products now use net price per unit that customers actually paid:
Backward Compatibility
Testing Recommendations
This improvement ensures Clerk order values match Magento exactly, providing accurate data for recommendations, analytics, and revenue tracking.
Customer: LEAM S.r.l
Issue: FED-1276
💻 View my work • 👤 Initiated by @CasperKN • About Codegen