Skip to content

MCP order tools never persist order totals: add_products ignores unitPriceWithoutVat and stores 0, force_price_recalculation does not save, validate_order_prices compares the stored zeros #696

Description

@Justinvolved

Describe the bug

An order built over MCP (create_orders as a cart, add_products, convert_cart_to_order) is stored with an order total of 0 and a line total of 0. The tools that should correct this do not:

  • add_products ignores unitPriceWithoutVat and stores the product's catalogue price as the unit price, with a line total of 0.
  • force_price_recalculation returns a correctly calculated order in its response and writes nothing.
  • validate_order_prices compares the stored values with each other and reports the order as valid (0 = 0).
  • update_order_line stores the new unit price, keeps the line total at 0, and changes the line type from Product to Fixed.

The stored totals only change when some other save runs on the order (in the test below, an unrelated update_orders call). Order history, reorder and reporting then show zero-value orders.

To Reproduce

  1. create_orders {"orders":[{"orderType":"Cart","shopId":"SHOP1","currencyCode":"EUR","languageId":"ENU","customerName":"TEST"}]}. Note cart id C.
  2. add_products {"orderId":"C","lines":[{"productId":"<product with price 60>","quantity":2,"unitPriceWithoutVat":10}]}.
  3. convert_cart_to_order {"id":"C"}. Note order id O.
  4. force_price_recalculation {"id":"O"}, then SELECT OrderPriceWithoutVAT FROM EcomOrders WHERE OrderId='O'.
  5. validate_order_prices {"id":"O"}.
  6. update_order_line {"request":{"orderLineId":"<line id>","unitPriceWithoutVat":10}}, then the same SELECT and SELECT OrderLineUnitPriceWithoutVAT, OrderLinePriceWithoutVAT, OrderLineType FROM EcomOrderLines WHERE OrderLineOrderId='O'.

Observed (DW 10.28.11, MCP add-in 0.6.0-BETA):

add_products          -> {"items":[{"id":"OL11313","quantity":2,"unitPrice":60,"totalPrice":0,"orderLineType":"Product"}],"succeeded":1}
SQL after add         -> OrderPriceWithoutVAT 0.0 | line unit 60.0 | line total 0.0
convert_cart_to_order -> {"id":"ORDER401","totalPriceWithoutVat":0,...,"lines":[{"unitPrice":60,"totalPrice":0}]}
force_price_recalculation -> {"id":"ORDER401","totalPriceWithoutVat":120,"totalPriceWithVat":120,"lines":[{"unitPrice":60,"totalPrice":120}]}
SQL after recalculation   -> OrderPriceWithoutVAT 0.0 | line total 0.0
validate_order_prices -> {"isValid":true,"storedOrderPrice":0,"storedOrderLinePrice":0,"priceDifference":0}
update_order_line     -> {"unitPrice":10,"totalPrice":0,"orderLineType":"Fixed"}
SQL after update line -> OrderPriceWithoutVAT 0.0 | line unit 10.0 | line total 0.0 | OrderLineType 2
update_orders {"updates":[{"id":"ORDER401","purchaseOrderNumber":"X"}]}
SQL after update_orders -> OrderPriceWithoutVAT 20.0 | line total 20.0

Expected behavior

  • add_products uses unitPriceWithoutVat when given (or documents that it is ignored) and stores a line total of unit price times quantity.
  • convert_cart_to_order and force_price_recalculation save the recalculated order and lines, so the stored total equals the sum of the priced lines.
  • validate_order_prices compares the stored total with a fresh calculation, so a zero-total order with priced lines is reported as invalid.
  • update_order_line keeps the line type unless asked to change it.

Environment

  • Dynamicweb 10.28.11 (.NET 10 hosting)
  • MCP add-in 0.6.0-BETA

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    BugSomething isn't workingCommerceFor items related to Commerce

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions