Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug]: Incorrect Outstanding amount and Total Pending amounts #10686

Open
docloulou opened this issue Dec 20, 2024 · 6 comments
Open

[Bug]: Incorrect Outstanding amount and Total Pending amounts #10686

docloulou opened this issue Dec 20, 2024 · 6 comments

Comments

@docloulou
Copy link
Contributor

Package.json file

v2.1.3

Node.js version

v21

Database and its version

16

Operating system name and version

linux docker

Browser name

firefox

What happended?

Incorrect Outstanding amount and Total Pending amounts after order edit (add quantity) with a pending payment

Expected behavior

correct outstanding amount and Total Pending amounts

Actual behavior

amount and Total Pending amounts are broken

image

{
  "id": "order_01JFHXQM4CBY2HR9JGZ9PZ5WXH",
  "status": "pending",
  "created_at": "2024-12-20T11:37:34.093Z",
  "canceled_at": null,
  "email": "[email protected]",
  "display_id": 60,
  "currency_code": "eur",
  "total": 24,
  "item_total": 24,
  "shipping_subtotal": 0,
  "subtotal": 20,
  "discount_total": 0,
  "discount_subtotal": 0,
  "shipping_total": 0,
  "shipping_tax_total": 0,
  "tax_total": 4,
  "summary": {
    "paid_total": 0,
    "difference_sum": 10,
    "raw_paid_total": {
      "value": "0",
      "precision": 20
    },
    "refunded_total": 0,
    "credit_line_total": 0,
    "transaction_total": 0,
    "pending_difference": 22,
    "raw_difference_sum": {
      "value": "10",
      "precision": 20
    },
    "raw_refunded_total": {
      "value": "0",
      "precision": 20
    },
    "current_order_total": 22,
    "original_order_total": 12,
    "raw_credit_line_total": {
      "value": "0",
      "precision": 20
    },
    "raw_transaction_total": {
      "value": "0",
      "precision": 20
    },
    "raw_pending_difference": {
      "value": "22",
      "precision": 20
    },
    "raw_current_order_total": {
      "value": "22",
      "precision": 20
    },
    "raw_original_order_total": {
      "value": "12",
      "precision": 20
    }
  },
  "version": 2,
  "region_id": "reg_01JBY047KVGYMTS64ZR1JGWZC8",
  "customer_id": "cus_01JBY0DMQZS4AC6KNHTAGKS66K",
  "sales_channel_id": "sc_01JBXZBM5TWK5YPBW5Q669FC73",
  "items": [
    {
      "id": "ordli_01JFHXQM4DQX9PNJA0T0CCTPF8",
      "title": "10ml / 0mg / 50/50",
      "subtitle": "Dulce",
      "thumbnail": "https://images.xxx.xxx/xxx.xxxprod/Dulce_1_50ml-01JD1V0B7GEZTXGANHPYQC9W2S.png",
      "variant_id": "variant_01JD1TV6CJH8N4DSD22TFDGZY5",
      "product_id": "prod_01JD1TV1DC8WCE6FAE779QX8KX",
      "product_title": "Dulce",
      "product_description": "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Aliquam fringilla molestie lectus sed facilisis. Cras eu odio non ex egestas cursus. Duis pharetra eros lectus, at suscipit nisi scelerisque in. Ut tempus lorem tortor, nec pellentesque dui iaculis et. Maecenas faucibus euismod neque sed finibus. Duis nec luctus turpis. Pellentesque dignissim mollis massa, eget efficitur metus auctor ut. Duis porta turpis eu nunc aliquam, vitae placerat eros lobortis. Ut ut lobortis ligula, eget mattis odio. Mauris blandit arcu sit amet leo venenatis mattis. Nunc vel magna mi. Sed condimentum neque id vestibulum varius. Vivamus in massa dui. Fusce tempor dolor ut urna sagittis aliquam.\n\nSuspendisse placerat, tortor eu egestas vestibulum, velit odio lobortis nulla, ac gravida est sapien ac odio. Phasellus ut vehicula neque. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nam bibendum lacus vel nunc mollis, dignissim venenatis lectus sodales. Donec libero velit, sagittis a consectetur sit amet, fringilla non sapien. Vestibulum tortor orci, tempus eu luctus nec, consectetur non tellus. Donec luctus interdum aliquet. \n",
      "product_subtitle": null,
      "product_type": null,
      "product_type_id": null,
      "product_collection": null,
      "product_handle": "dulce",
      "variant_sku": "DULCE-10-0-5050",
      "variant_barcode": null,
      "variant_title": "10ml / 0mg / 50/50",
      "variant_option_values": null,
      "requires_shipping": true,
      "is_discountable": true,
      "is_tax_inclusive": false,
      "raw_compare_at_unit_price": null,
      "raw_unit_price": {
        "value": "5",
        "precision": 20
      },
      "is_custom_price": false,
      "metadata": {},
      "created_at": "2024-12-20T11:37:34.094Z",
      "updated_at": "2024-12-20T11:37:34.094Z",
      "deleted_at": null,
      "tax_lines": [
        {
          "id": "ordlitxl_01JFHXQM4DHTWK7J3H3PN7Y9EF",
          "description": "default TVA",
          "tax_rate_id": "txr_01JE66425TGBRZPYJ5JF5SC7FK",
          "code": "TVA20",
          "raw_rate": {
            "value": "20",
            "precision": 20
          },
          "provider_id": "system",
          "created_at": "2024-12-20T11:37:34.094Z",
          "updated_at": "2024-12-20T11:37:34.094Z",
          "deleted_at": null,
          "item_id": "ordli_01JFHXQM4DQX9PNJA0T0CCTPF8",
          "rate": 20,
          "total": 4,
          "subtotal": 4,
          "raw_total": {
            "value": "4",
            "precision": 20
          },
          "raw_subtotal": {
            "value": "4",
            "precision": 20
          }
        }
      ],
      "adjustments": [],
      "compare_at_unit_price": null,
      "unit_price": 5,
      "quantity": 4,
      "raw_quantity": {
        "value": "4",
        "precision": 20
      },
      "detail": {
        "id": "orditem_01JFHXRQ694CQCKT4XNN5X543S",
        "order_id": "order_01JFHXQM4CBY2HR9JGZ9PZ5WXH",
        "version": 2,
        "item_id": "ordli_01JFHXQM4DQX9PNJA0T0CCTPF8",
        "raw_unit_price": {
          "value": "5",
          "precision": 20
        },
        "raw_compare_at_unit_price": null,
        "raw_quantity": {
          "value": "4",
          "precision": 20
        },
        "raw_fulfilled_quantity": {
          "value": "0",
          "precision": 20
        },
        "raw_delivered_quantity": {
          "value": "0",
          "precision": 20
        },
        "raw_shipped_quantity": {
          "value": "0",
          "precision": 20
        },
        "raw_return_requested_quantity": {
          "value": "0",
          "precision": 20
        },
        "raw_return_received_quantity": {
          "value": "0",
          "precision": 20
        },
        "raw_return_dismissed_quantity": {
          "value": "0",
          "precision": 20
        },
        "raw_written_off_quantity": {
          "value": "0",
          "precision": 20
        },
        "metadata": null,
        "created_at": "2024-12-20T11:38:09.993Z",
        "updated_at": "2024-12-20T11:38:09.993Z",
        "deleted_at": null,
        "unit_price": 5,
        "compare_at_unit_price": null,
        "quantity": 4,
        "fulfilled_quantity": 0,
        "delivered_quantity": 0,
        "shipped_quantity": 0,
        "return_requested_quantity": 0,
        "return_received_quantity": 0,
        "return_dismissed_quantity": 0,
        "written_off_quantity": 0
      },
      "subtotal": 20,
      "total": 24,
      "original_total": 24,
      "discount_total": 0,
      "discount_subtotal": 0,
      "discount_tax_total": 0,
      "tax_total": 4,
      "original_tax_total": 4,
      "refundable_total_per_unit": 6,
      "refundable_total": 24,
      "fulfilled_total": 0,
      "shipped_total": 0,
      "return_requested_total": 0,
      "return_received_total": 0,
      "return_dismissed_total": 0,
      "write_off_total": 0,
      "raw_subtotal": {
        "value": "20",
        "precision": 20
      },
      "raw_total": {
        "value": "24",
        "precision": 20
      },
      "raw_original_total": {
        "value": "24",
        "precision": 20
      },
      "raw_discount_total": {
        "value": "0",
        "precision": 20
      },
      "raw_discount_subtotal": {
        "value": "0",
        "precision": 20
      },
      "raw_discount_tax_total": {
        "value": "0",
        "precision": 20
      },
      "raw_tax_total": {
        "value": "4",
        "precision": 20
      },
      "raw_original_tax_total": {
        "value": "4",
        "precision": 20
      },
      "raw_refundable_total_per_unit": {
        "value": "6",
        "precision": 20
      },
      "raw_refundable_total": {
        "value": "24",
        "precision": 20
      },
      "raw_fulfilled_total": {
        "value": "0",
        "precision": 20
      },
      "raw_shipped_total": {
        "value": "0",
        "precision": 20
      },
      "raw_return_requested_total": {
        "value": "0",
        "precision": 20
      },
      "raw_return_received_total": {
        "value": "0",
        "precision": 20
      },
      "raw_return_dismissed_total": {
        "value": "0",
        "precision": 20
      },
      "raw_write_off_total": {
        "value": "0",
        "precision": 20
      },
      "variant": {
        "id": "variant_01JD1TV6CJH8N4DSD22TFDGZY5",
        "title": "10ml / 0mg / 50/50",
        "sku": "DULCE-10-0-5050",
        "barcode": null,
        "ean": null,
        "upc": null,
        "allow_backorder": false,
        "manage_inventory": true,
        "hs_code": null,
        "origin_country": null,
        "mid_code": null,
        "material": null,
        "weight": null,
        "length": null,
        "height": null,
        "width": null,
        "metadata": null,
        "variant_rank": 0,
        "product_id": "prod_01JD1TV1DC8WCE6FAE779QX8KX",
        "product": {
          "id": "prod_01JD1TV1DC8WCE6FAE779QX8KX",
          "title": "Dulce",
          "handle": "dulce",
          "subtitle": null,
          "description": "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Aliquam fringilla molestie lectus sed facilisis. Cras eu odio non ex egestas cursus. Duis pharetra eros lectus, at suscipit nisi scelerisque in. Ut tempus lorem tortor, nec pellentesque dui iaculis et. Maecenas faucibus euismod neque sed finibus. Duis nec luctus turpis. Pellentesque dignissim mollis massa, eget efficitur metus auctor ut. Duis porta turpis eu nunc aliquam, vitae placerat eros lobortis. Ut ut lobortis ligula, eget mattis odio. Mauris blandit arcu sit amet leo venenatis mattis. Nunc vel magna mi. Sed condimentum neque id vestibulum varius. Vivamus in massa dui. Fusce tempor dolor ut urna sagittis aliquam.\n\nSuspendisse placerat, tortor eu egestas vestibulum, velit odio lobortis nulla, ac gravida est sapien ac odio. Phasellus ut vehicula neque. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nam bibendum lacus vel nunc mollis, dignissim venenatis lectus sodales. Donec libero velit, sagittis a consectetur sit amet, fringilla non sapien. Vestibulum tortor orci, tempus eu luctus nec, consectetur non tellus. Donec luctus interdum aliquet. \n",
          "is_giftcard": false,
          "status": "published",
          "thumbnail": "https://images.xxx.xxx/xxx.xxxprod/Dulce_1_50ml-01JD1V0B7GEZTXGANHPYQC9W2S.png",
          "weight": "400",
          "length": null,
          "height": null,
          "width": null,
          "origin_country": null,
          "hs_code": null,
          "mid_code": null,
          "material": null,
          "discountable": true,
          "external_id": null,
          "metadata": null,
          "type_id": null,
          "type": null,
          "collection_id": null,
          "collection": null,
          "created_at": "2024-11-19T09:06:43.457Z",
          "updated_at": "2024-11-19T09:06:43.457Z",
          "deleted_at": null
        },
        "created_at": "2024-11-19T09:07:50.809Z",
        "updated_at": "2024-11-19T09:07:50.809Z",
        "deleted_at": null,
        "options": [
          {
            "id": "optval_01JD1TV1XB38D5D01VZSWFGG3A",
            "value": "50/50",
            "metadata": null,
            "option_id": "opt_01JD1TV1MBFBNXQAKQC20NV84Y",
            "option": {
              "id": "opt_01JD1TV1MBFBNXQAKQC20NV84Y"
            },
            "created_at": "2024-11-19T09:06:43.457Z",
            "updated_at": "2024-11-19T09:06:43.457Z",
            "deleted_at": null
          },
          {
            "id": "optval_01JD1TV1XBD2FE758ZZGZ92G48",
            "value": "0mg",
            "metadata": null,
            "option_id": "opt_01JD1TV1MBKF66A6WHBYYNFA42",
            "option": {
              "id": "opt_01JD1TV1MBKF66A6WHBYYNFA42"
            },
            "created_at": "2024-11-19T09:06:43.457Z",
            "updated_at": "2024-11-19T09:06:43.457Z",
            "deleted_at": null
          },
          {
            "id": "optval_01JD1TV1XB6PCJVP8A4CQXQGEW",
            "value": "10ml",
            "metadata": null,
            "option_id": "opt_01JD1TV1MBYNQPHQGGCVWJJY2P",
            "option": {
              "id": "opt_01JD1TV1MBYNQPHQGGCVWJJY2P"
            },
            "created_at": "2024-11-19T09:06:43.457Z",
            "updated_at": "2024-11-19T09:06:43.457Z",
            "deleted_at": null
          }
        ],
        "inventory_items": [
          {
            "required_quantity": 1,
            "variant_id": "variant_01JD1TV6CJH8N4DSD22TFDGZY5",
            "inventory_item_id": "iitem_01JD1TV7M7MG29NBXKP0X6XNRR",
            "inventory": {
              "id": "iitem_01JD1TV7M7MG29NBXKP0X6XNRR",
              "sku": "DULCE-10-0-5050",
              "origin_country": null,
              "hs_code": null,
              "mid_code": null,
              "material": null,
              "weight": null,
              "length": null,
              "height": null,
              "width": null,
              "requires_shipping": true,
              "description": "10ml / 0mg / 50/50",
              "title": "10ml / 0mg / 50/50",
              "thumbnail": null,
              "metadata": null,
              "created_at": "2024-11-19T09:07:52.074Z",
              "updated_at": "2024-11-19T09:07:52.074Z",
              "deleted_at": null
            }
          }
        ]
      }
    }
  ],
  "shipping_methods": [
    {
      "id": "ordsm_01JFHXQM4CRVQSS30BSBJFXJ1T",
      "name": "Standard",
      "description": null,
      "raw_amount": {
        "value": "0",
        "precision": 20
      },
      "is_tax_inclusive": false,
      "is_custom_amount": false,
      "shipping_option_id": "so_01JFCGWPWHPDT57XNE9FRF5WWF",
      "data": {},
      "metadata": null,
      "created_at": "2024-12-20T11:37:34.094Z",
      "updated_at": "2024-12-20T11:37:34.094Z",
      "deleted_at": null,
      "tax_lines": [
        {
          "id": "ordsmtxl_01JFHXQM4CF86NS97KDZ38EF3N",
          "description": "default TVA",
          "tax_rate_id": "txr_01JE66425TGBRZPYJ5JF5SC7FK",
          "code": "TVA20",
          "raw_rate": {
            "value": "20",
            "precision": 20
          },
          "provider_id": "system",
          "created_at": "2024-12-20T11:37:34.094Z",
          "updated_at": "2024-12-20T11:37:34.094Z",
          "deleted_at": null,
          "shipping_method_id": "ordsm_01JFHXQM4CRVQSS30BSBJFXJ1T",
          "rate": 20
        }
      ],
      "adjustments": [],
      "amount": 0,
      "order_id": "order_01JFHXQM4CBY2HR9JGZ9PZ5WXH",
      "detail": {
        "id": "ordspmv_01JFHXRQ6BJ8ST66794A14CYYN",
        "order_id": "order_01JFHXQM4CBY2HR9JGZ9PZ5WXH",
        "version": 2,
        "shipping_method_id": "ordsm_01JFHXQM4CRVQSS30BSBJFXJ1T",
        "created_at": "2024-12-20T11:37:34.094Z",
        "updated_at": "2024-12-20T11:37:34.094Z",
        "deleted_at": null
      },
      "subtotal": 0,
      "total": 0,
      "original_total": 0,
      "discount_total": 0,
      "discount_subtotal": 0,
      "discount_tax_total": 0,
      "tax_total": 0,
      "original_tax_total": 0,
      "raw_subtotal": {
        "value": "0",
        "precision": 20
      },
      "raw_total": {
        "value": "0",
        "precision": 20
      },
      "raw_original_total": {
        "value": "0",
        "precision": 20
      },
      "raw_discount_total": {
        "value": "0",
        "precision": 20
      },
      "raw_discount_subtotal": {
        "value": "0",
        "precision": 20
      },
      "raw_discount_tax_total": {
        "value": "0",
        "precision": 20
      },
      "raw_tax_total": {
        "value": "0",
        "precision": 20
      },
      "raw_original_tax_total": {
        "value": "0",
        "precision": 20
      }
    }
  ],
  "region": {
    "automatic_taxes": true,
    "id": "reg_01JBY047KVGYMTS64ZR1JGWZC8"
  },
  "customer": {
    "id": "cus_01JBY0DMQZS4AC6KNHTAGKS66K",
    "company_name": "Compagnie Test",
    "first_name": "Prénom Test",
    "last_name": "Nom test",
    "email": "[email protected]",
    "phone": "0606060606",
    "has_account": true,
    "metadata": {
      "siret": "12345678901234",
      "newsletter": true,
      "jourNaissance": 1,
      "moisNaissance": 1,
      "moisOuverture": 1,
      "anneeNaissance": 1990,
      "anneeOuverture": 2024
    },
    "created_by": null,
    "created_at": "2024-11-05T11:12:38.655Z",
    "updated_at": "2024-12-05T12:25:56.599Z",
    "deleted_at": null
  },
  "sales_channel": {
    "id": "sc_01JBXZBM5TWK5YPBW5Q669FC73",
    "name": "Default Sales Channel",
    "description": "Created by Medusa",
    "is_disabled": false,
    "metadata": null,
    "created_at": "2024-11-05T10:54:03.962Z",
    "updated_at": "2024-11-05T10:54:03.962Z",
    "deleted_at": null
  },
  "promotion": [],
  "fulfillments": [],
  "payment_collections": [
    {
      "id": "pay_col_01JFHXQHXG7HMWNZZY9RKCJ14J",
      "currency_code": "eur",
      "region_id": "reg_01JBY047KVGYMTS64ZR1JGWZC8",
      "completed_at": null,
      "status": "authorized",
      "metadata": null,
      "raw_amount": {
        "value": "12",
        "precision": 20
      },
      "raw_authorized_amount": {
        "value": "12",
        "precision": 20
      },
      "raw_captured_amount": {
        "value": "0",
        "precision": 20
      },
      "raw_refunded_amount": {
        "value": "0",
        "precision": 20
      },
      "created_at": "2024-12-20T11:37:31.824Z",
      "updated_at": "2024-12-20T11:37:33.896Z",
      "deleted_at": null,
      "payments": [
        {
          "id": "pay_01JFHXQKVKQKTV4E000NJT0VAJ",
          "currency_code": "eur",
          "provider_id": "pp_bank-transfer_bank-transfer",
          "cart_id": null,
          "order_id": null,
          "customer_id": null,
          "data": {
            "amount": 12,
            "context": {
              "customer": {
                "id": "cus_01JBY0DMQZS4AC6KNHTAGKS66K"
              },
              "session_id": "payses_01JFHXQJ2Z6HKZRDFN8Z01VD49"
            },
            "currency_code": "eur"
          },
          "metadata": null,
          "captured_at": null,
          "canceled_at": null,
          "payment_collection_id": "pay_col_01JFHXQHXG7HMWNZZY9RKCJ14J",
          "payment_session": {
            "id": "payses_01JFHXQJ2Z6HKZRDFN8Z01VD49"
          },
          "raw_amount": {
            "value": "12",
            "precision": 20
          },
          "created_at": "2024-12-20T11:37:33.811Z",
          "updated_at": "2024-12-20T11:37:33.811Z",
          "deleted_at": null,
          "payment_session_id": "payses_01JFHXQJ2Z6HKZRDFN8Z01VD49",
          "refunds": [],
          "amount": 12
        }
      ],
      "amount": 12,
      "authorized_amount": 12,
      "captured_amount": 0,
      "refunded_amount": 0
    },
    {
      "id": "pay_col_01JFHXRN70JG8TDT90SWWFKVF7",
      "currency_code": "eur",
      "region_id": "reg_01JBY047KVGYMTS64ZR1JGWZC8",
      "completed_at": null,
      "status": "not_paid",
      "metadata": null,
      "raw_amount": {
        "value": "22",
        "precision": 20
      },
      "raw_authorized_amount": null,
      "raw_captured_amount": null,
      "raw_refunded_amount": null,
      "created_at": "2024-12-20T11:38:07.968Z",
      "updated_at": "2024-12-20T11:38:10.348Z",
      "deleted_at": null,
      "payments": [],
      "amount": 22,
      "authorized_amount": null,
      "captured_amount": null,
      "refunded_amount": null
    }
  ],
  "payment_status": "partially_authorized",
  "fulfillment_status": "not_fulfilled"
}

Link to reproduction repo

none

@olivermrbl
Copy link
Contributor

@docloulou, please include the steps of the order edit, so we can reproduce :)

@olivermrbl olivermrbl self-assigned this Dec 20, 2024
@420coupe
Copy link
Contributor

@docloulou, please include the steps of the order edit, so we can reproduce :)

would this not be updated by the webhook return from payment provider?

@docloulou
Copy link
Contributor Author

@olivermrbl

here the steps:
https://github.com/user-attachments/assets/fbf332d3-d423-4c80-a071-f366a0fdb7f6

other scenario with captured payment :
https://github.com/user-attachments/assets/27fb4cc4-2d50-423b-a6e0-15f52ba013a2

{
	"order_changes": [
		{
			"id": "ordch_01JFN32WBCYDG3AKXADEQSBBNA",
			"order_id": "order_01JFN30RHVQCDAADX0VZQSZD3Q",
			"version": 2,
			"change_type": "edit",
			"description": null,
			"status": "confirmed",
			"internal_note": null,
			"created_by": null,
			"requested_by": "user_01JBY0MPKVDB0VBN297B4PK5C6",
			"requested_at": "2024-12-21T17:09:00.099Z",
			"confirmed_by": "user_01JBY0MPKVDB0VBN297B4PK5C6",
			"confirmed_at": "2024-12-21T17:09:02.515Z",
			"declined_by": null,
			"declined_reason": null,
			"metadata": null,
			"declined_at": null,
			"canceled_by": null,
			"canceled_at": null,
			"created_at": "2024-12-21T17:08:49.132Z",
			"updated_at": "2024-12-21T17:09:02.515Z",
			"actions": [
				{
					"id": "ordchact_01JFN331XWWM1BMVJJ2PSQNAK1",
					"ordering": "70",
					"order_id": "order_01JFN30RHVQCDAADX0VZQSZD3Q",
					"return_id": null,
					"claim_id": null,
					"exchange_id": null,
					"version": 2,
					"order_change_id": "ordch_01JFN32WBCYDG3AKXADEQSBBNA",
					"reference": null,
					"reference_id": null,
					"action": "ITEM_UPDATE",
					"details": {
						"quantity": 10,
						"reference_id": "ordli_01JFN30RHWD291WCMNDYN47H62",
						"quantity_diff": 9
					},
					"raw_amount": null,
					"internal_note": null,
					"applied": true,
					"created_at": "2024-12-21T17:08:54.844Z",
					"updated_at": "2024-12-21T17:09:02.526Z",
					"deleted_at": null,
					"order": {
						"id": "order_01JFN30RHVQCDAADX0VZQSZD3Q"
					},
					"return": null,
					"claim": null,
					"exchange": null,
					"amount": null
				}
			]
		}
	]
}

@docloulou
Copy link
Contributor Author

Hi,
Do you have any updates on this?
It’s a blocker for production deployment.
Thanks.

@docloulou
Copy link
Contributor Author

docloulou commented Jan 7, 2025

Note: Same on fresh starter

image

image

image

ORDER JSON on picture 2

{
  "id": "order_01JH04FZW22A776G2FK7CC9HHS",
  "status": "pending",
  "created_at": "2025-01-07T10:20:47.876Z",
  "canceled_at": null,
  "email": "[email protected]",
  "display_id": 1,
  "currency_code": "eur",
  "total": 20,
  "item_total": 10,
  "shipping_subtotal": 10,
  "subtotal": 20,
  "discount_total": 0,
  "discount_subtotal": 0,
  "shipping_total": 10,
  "shipping_tax_total": 0,
  "tax_total": 0,
  "summary": {
    "paid_total": 20,
    "difference_sum": -10,
    "raw_paid_total": {
      "value": "20",
      "precision": 20
    },
    "refunded_total": 0,
    "credit_line_total": 0,
    "transaction_total": 20,
    "pending_difference": 0,
    "raw_difference_sum": {
      "value": "-10",
      "precision": 20
    },
    "raw_refunded_total": {
      "value": "0",
      "precision": 20
    },
    "current_order_total": 20,
    "original_order_total": 30,
    "raw_credit_line_total": {
      "value": "0",
      "precision": 20
    },
    "raw_transaction_total": {
      "value": "20",
      "precision": 20
    },
    "raw_pending_difference": {
      "value": "0",
      "precision": 20
    },
    "raw_current_order_total": {
      "value": "20",
      "precision": 20
    },
    "raw_original_order_total": {
      "value": "30",
      "precision": 20
    }
  },
  "version": 3,
  "region_id": "reg_01JH041FK8JJ7CPX6M6SPMM3Z0",
  "customer_id": "cus_01JH04FNTSNV2FGS2B2KS80Z08",
  "sales_channel_id": "sc_01JH041AJPJ8ZQ4S8SAQYVD9FH",
  "items": [
    {
      "id": "ordli_01JH04FZW3XQJJMZ6GFTHPBPDV",
      "title": "M",
      "subtitle": "Medusa Sweatshirt",
      "thumbnail": "https://medusa-public-images.s3.eu-west-1.amazonaws.com/sweatshirt-vintage-front.png",
      "variant_id": "variant_01JH041GR2PYWW2R23EKE32VHY",
      "product_id": "prod_01JH041G9MCSJF58AMFZ32YZC4",
      "product_title": "Medusa Sweatshirt",
      "product_description": "Reimagine the feeling of a classic sweatshirt. With our cotton sweatshirt, everyday essentials no longer have to be ordinary.",
      "product_subtitle": null,
      "product_type": null,
      "product_type_id": null,
      "product_collection": null,
      "product_handle": "sweatshirt",
      "variant_sku": "SWEATSHIRT-M",
      "variant_barcode": null,
      "variant_title": "M",
      "variant_option_values": null,
      "requires_shipping": true,
      "is_discountable": true,
      "is_tax_inclusive": false,
      "raw_compare_at_unit_price": null,
      "raw_unit_price": {
        "value": "10",
        "precision": 20
      },
      "is_custom_price": false,
      "metadata": {},
      "created_at": "2025-01-07T10:20:47.876Z",
      "updated_at": "2025-01-07T10:20:47.876Z",
      "deleted_at": null,
      "tax_lines": [],
      "adjustments": [],
      "compare_at_unit_price": null,
      "unit_price": 10,
      "quantity": 1,
      "raw_quantity": {
        "value": "1",
        "precision": 20
      },
      "detail": {
        "id": "orditem_01JH04H786WHJZ72HSQGXTG165",
        "order_id": "order_01JH04FZW22A776G2FK7CC9HHS",
        "version": 3,
        "item_id": "ordli_01JH04FZW3XQJJMZ6GFTHPBPDV",
        "raw_unit_price": {
          "value": "10",
          "precision": 20
        },
        "raw_compare_at_unit_price": null,
        "raw_quantity": {
          "value": "1",
          "precision": 20
        },
        "raw_fulfilled_quantity": {
          "value": "0",
          "precision": 20
        },
        "raw_delivered_quantity": {
          "value": "0",
          "precision": 20
        },
        "raw_shipped_quantity": {
          "value": "0",
          "precision": 20
        },
        "raw_return_requested_quantity": {
          "value": "0",
          "precision": 20
        },
        "raw_return_received_quantity": {
          "value": "0",
          "precision": 20
        },
        "raw_return_dismissed_quantity": {
          "value": "0",
          "precision": 20
        },
        "raw_written_off_quantity": {
          "value": "0",
          "precision": 20
        },
        "metadata": null,
        "created_at": "2025-01-07T10:21:28.198Z",
        "updated_at": "2025-01-07T10:21:28.198Z",
        "deleted_at": null,
        "unit_price": 10,
        "compare_at_unit_price": null,
        "quantity": 1,
        "fulfilled_quantity": 0,
        "delivered_quantity": 0,
        "shipped_quantity": 0,
        "return_requested_quantity": 0,
        "return_received_quantity": 0,
        "return_dismissed_quantity": 0,
        "written_off_quantity": 0
      },
      "subtotal": 10,
      "total": 10,
      "original_total": 10,
      "discount_total": 0,
      "discount_subtotal": 0,
      "discount_tax_total": 0,
      "tax_total": 0,
      "original_tax_total": 0,
      "refundable_total_per_unit": 10,
      "refundable_total": 10,
      "fulfilled_total": 0,
      "shipped_total": 0,
      "return_requested_total": 0,
      "return_received_total": 0,
      "return_dismissed_total": 0,
      "write_off_total": 0,
      "raw_subtotal": {
        "value": "10",
        "precision": 20
      },
      "raw_total": {
        "value": "10",
        "precision": 20
      },
      "raw_original_total": {
        "value": "10",
        "precision": 20
      },
      "raw_discount_total": {
        "value": "0",
        "precision": 20
      },
      "raw_discount_subtotal": {
        "value": "0",
        "precision": 20
      },
      "raw_discount_tax_total": {
        "value": "0",
        "precision": 20
      },
      "raw_tax_total": {
        "value": "0",
        "precision": 20
      },
      "raw_original_tax_total": {
        "value": "0",
        "precision": 20
      },
      "raw_refundable_total_per_unit": {
        "value": "10",
        "precision": 20
      },
      "raw_refundable_total": {
        "value": "10",
        "precision": 20
      },
      "raw_fulfilled_total": {
        "value": "0",
        "precision": 20
      },
      "raw_shipped_total": {
        "value": "0",
        "precision": 20
      },
      "raw_return_requested_total": {
        "value": "0",
        "precision": 20
      },
      "raw_return_received_total": {
        "value": "0",
        "precision": 20
      },
      "raw_return_dismissed_total": {
        "value": "0",
        "precision": 20
      },
      "raw_write_off_total": {
        "value": "0",
        "precision": 20
      },
      "variant": {
        "id": "variant_01JH041GR2PYWW2R23EKE32VHY",
        "title": "M",
        "sku": "SWEATSHIRT-M",
        "barcode": null,
        "ean": null,
        "upc": null,
        "allow_backorder": false,
        "manage_inventory": true,
        "hs_code": null,
        "origin_country": null,
        "mid_code": null,
        "material": null,
        "weight": null,
        "length": null,
        "height": null,
        "width": null,
        "metadata": null,
        "variant_rank": 0,
        "product_id": "prod_01JH041G9MCSJF58AMFZ32YZC4",
        "product": {
          "id": "prod_01JH041G9MCSJF58AMFZ32YZC4",
          "title": "Medusa Sweatshirt",
          "handle": "sweatshirt",
          "subtitle": null,
          "description": "Reimagine the feeling of a classic sweatshirt. With our cotton sweatshirt, everyday essentials no longer have to be ordinary.",
          "is_giftcard": false,
          "status": "published",
          "thumbnail": "https://medusa-public-images.s3.eu-west-1.amazonaws.com/sweatshirt-vintage-front.png",
          "weight": "400",
          "length": null,
          "height": null,
          "width": null,
          "origin_country": null,
          "hs_code": null,
          "mid_code": null,
          "material": null,
          "discountable": true,
          "external_id": null,
          "metadata": null,
          "type_id": null,
          "type": null,
          "collection_id": null,
          "collection": null,
          "created_at": "2025-01-07T10:11:20.691Z",
          "updated_at": "2025-01-07T10:11:20.691Z",
          "deleted_at": null
        },
        "created_at": "2025-01-07T10:12:53.635Z",
        "updated_at": "2025-01-07T10:12:53.635Z",
        "deleted_at": null,
        "options": [
          {
            "id": "optval_01JH041GDWAJBGZSWKM3067XSH",
            "value": "M",
            "metadata": null,
            "option_id": "opt_01JH041GCHXQK7ABWQGP63RS27",
            "option": {
              "id": "opt_01JH041GCHXQK7ABWQGP63RS27"
            },
            "created_at": "2025-01-07T10:11:20.691Z",
            "updated_at": "2025-01-07T10:11:20.691Z",
            "deleted_at": null
          }
        ],
        "inventory_items": [
          {
            "required_quantity": 1,
            "variant_id": "variant_01JH041GR2PYWW2R23EKE32VHY",
            "inventory_item_id": "iitem_01JH041GXXV55SY8TAF6ZGEFDH",
            "inventory": {
              "id": "iitem_01JH041GXXV55SY8TAF6ZGEFDH",
              "sku": "SWEATSHIRT-M",
              "origin_country": null,
              "hs_code": null,
              "mid_code": null,
              "material": null,
              "weight": null,
              "length": null,
              "height": null,
              "width": null,
              "requires_shipping": true,
              "description": "M",
              "title": "M",
              "thumbnail": null,
              "metadata": null,
              "created_at": "2025-01-07T10:12:53.823Z",
              "updated_at": "2025-01-07T10:12:53.823Z",
              "deleted_at": null
            }
          }
        ]
      }
    }
  ],
  "shipping_address": {
    "id": "caaddr_01JH04FNWDQJ9C488EPVJZZ42M",
    "customer_id": null,
    "company": "xxx.xxx",
    "first_name": "xxx.xxx",
    "last_name": "xxx.xxx",
    "address_1": "49 rue xxx.xxx",
    "address_2": "",
    "city": "Boulogne billancourt",
    "country_code": "fr",
    "province": "",
    "postal_code": "94000",
    "phone": "+33xxx.xxx",
    "metadata": null,
    "created_at": "2025-01-07T10:20:37.645Z",
    "updated_at": "2025-01-07T10:20:37.645Z"
  },
  "billing_address": {
    "id": "caaddr_01JH04FNWD5H46PR8A2R6BJ2NN",
    "customer_id": null,
    "company": "xxx.xxx",
    "first_name": "xxx.xxx",
    "last_name": "xxx.xxx",
    "address_1": "49 rue xxx.xxx",
    "address_2": "",
    "city": "Boulogne billancourt",
    "country_code": "fr",
    "province": "",
    "postal_code": "94000",
    "phone": "+33xxx.xxx",
    "metadata": null,
    "created_at": "2025-01-07T10:20:37.645Z",
    "updated_at": "2025-01-07T10:20:37.645Z"
  },
  "shipping_methods": [
    {
      "id": "ordsm_01JH04FZW2RBT6EE9BB5BJQFM9",
      "name": "Express Shipping",
      "description": null,
      "raw_amount": {
        "value": "10",
        "precision": 20
      },
      "is_tax_inclusive": false,
      "is_custom_amount": false,
      "shipping_option_id": "so_01JH041FYP7T4872P1Q6K2WMWF",
      "data": {},
      "metadata": null,
      "created_at": "2025-01-07T10:20:47.877Z",
      "updated_at": "2025-01-07T10:20:47.877Z",
      "deleted_at": null,
      "tax_lines": [],
      "adjustments": [],
      "amount": 10,
      "order_id": "order_01JH04FZW22A776G2FK7CC9HHS",
      "detail": {
        "id": "ordspmv_01JH04H7847GH62NZ313BA8YND",
        "order_id": "order_01JH04FZW22A776G2FK7CC9HHS",
        "version": 3,
        "shipping_method_id": "ordsm_01JH04FZW2RBT6EE9BB5BJQFM9",
        "created_at": "2025-01-07T10:20:47.877Z",
        "updated_at": "2025-01-07T10:20:47.877Z",
        "deleted_at": null
      },
      "subtotal": 10,
      "total": 10,
      "original_total": 10,
      "discount_total": 0,
      "discount_subtotal": 0,
      "discount_tax_total": 0,
      "tax_total": 0,
      "original_tax_total": 0,
      "raw_subtotal": {
        "value": "10",
        "precision": 20
      },
      "raw_total": {
        "value": "10",
        "precision": 20
      },
      "raw_original_total": {
        "value": "10",
        "precision": 20
      },
      "raw_discount_total": {
        "value": "0",
        "precision": 20
      },
      "raw_discount_subtotal": {
        "value": "0",
        "precision": 20
      },
      "raw_discount_tax_total": {
        "value": "0",
        "precision": 20
      },
      "raw_tax_total": {
        "value": "0",
        "precision": 20
      },
      "raw_original_tax_total": {
        "value": "0",
        "precision": 20
      }
    }
  ],
  "region": {
    "automatic_taxes": true,
    "id": "reg_01JH041FK8JJ7CPX6M6SPMM3Z0"
  },
  "customer": {
    "id": "cus_01JH04FNTSNV2FGS2B2KS80Z08",
    "company_name": null,
    "first_name": null,
    "last_name": null,
    "email": "[email protected]",
    "phone": null,
    "has_account": false,
    "metadata": null,
    "created_by": null,
    "created_at": "2025-01-07T10:20:37.593Z",
    "updated_at": "2025-01-07T10:20:37.593Z",
    "deleted_at": null
  },
  "sales_channel": {
    "id": "sc_01JH041AJPJ8ZQ4S8SAQYVD9FH",
    "name": "Default Sales Channel",
    "description": "Created by Medusa",
    "is_disabled": false,
    "metadata": null,
    "created_at": "2025-01-07T10:12:47.318Z",
    "updated_at": "2025-01-07T10:12:47.319Z",
    "deleted_at": null
  },
  "promotion": [],
  "fulfillments": [],
  "payment_collections": [
    {
      "id": "pay_col_01JH04FXG08W6DCB03H0RZB9H5",
      "currency_code": "eur",
      "region_id": "reg_01JH041FK8JJ7CPX6M6SPMM3Z0",
      "completed_at": null,
      "status": "authorized",
      "metadata": null,
      "raw_amount": {
        "value": "20",
        "precision": 20
      },
      "raw_authorized_amount": {
        "value": "20",
        "precision": 20
      },
      "raw_captured_amount": {
        "value": "20",
        "precision": 20
      },
      "raw_refunded_amount": {
        "value": "0",
        "precision": 20
      },
      "created_at": "2025-01-07T10:20:45.440Z",
      "updated_at": "2025-01-07T10:26:16.467Z",
      "deleted_at": null,
      "payments": [
        {
          "id": "pay_01JH04FZPB2H6MH6DNSBG6EE8Y",
          "currency_code": "eur",
          "provider_id": "pp_system_default",
          "cart_id": null,
          "order_id": null,
          "customer_id": null,
          "data": {},
          "metadata": null,
          "captured_at": "2025-01-07T10:26:16.401Z",
          "canceled_at": null,
          "payment_collection_id": "pay_col_01JH04FXG08W6DCB03H0RZB9H5",
          "payment_session": {
            "id": "payses_01JH04FXKYWWHWEXNN3BN7JH3K"
          },
          "raw_amount": {
            "value": "20",
            "precision": 20
          },
          "created_at": "2025-01-07T10:20:47.692Z",
          "updated_at": "2025-01-07T10:26:16.421Z",
          "deleted_at": null,
          "payment_session_id": "payses_01JH04FXKYWWHWEXNN3BN7JH3K",
          "refunds": [],
          "amount": 20
        }
      ],
      "amount": 20,
      "authorized_amount": 20,
      "captured_amount": 20,
      "refunded_amount": 0
    },
    {
      "id": "pay_col_01JH04GQVVQQGG651MKGHGRB2X",
      "currency_code": "eur",
      "region_id": "reg_01JH041FK8JJ7CPX6M6SPMM3Z0",
      "completed_at": null,
      "status": "not_paid",
      "metadata": null,
      "raw_amount": {
        "value": "20",
        "precision": 20
      },
      "raw_authorized_amount": null,
      "raw_captured_amount": null,
      "raw_refunded_amount": null,
      "created_at": "2025-01-07T10:21:12.443Z",
      "updated_at": "2025-01-07T10:21:28.491Z",
      "deleted_at": null,
      "payments": [],
      "amount": 20,
      "authorized_amount": null,
      "captured_amount": null,
      "refunded_amount": null
    }
  ],
  "payment_status": "partially_captured",
  "fulfillment_status": "not_fulfilled"
}

ORDER JSON on picture 3

{
  "id": "order_01JH04FZW22A776G2FK7CC9HHS",
  "status": "pending",
  "created_at": "2025-01-07T10:20:47.876Z",
  "canceled_at": null,
  "email": "[email protected]",
  "display_id": 1,
  "currency_code": "eur",
  "total": 20,
  "item_total": 10,
  "shipping_subtotal": 10,
  "subtotal": 20,
  "discount_total": 0,
  "discount_subtotal": 0,
  "shipping_total": 10,
  "shipping_tax_total": 0,
  "tax_total": 0,
  "summary": {
    "paid_total": 20,
    "difference_sum": -10,
    "raw_paid_total": {
      "value": "20",
      "precision": 20
    },
    "refunded_total": 0,
    "credit_line_total": 0,
    "transaction_total": 20,
    "pending_difference": 0,
    "raw_difference_sum": {
      "value": "-10",
      "precision": 20
    },
    "raw_refunded_total": {
      "value": "0",
      "precision": 20
    },
    "current_order_total": 20,
    "original_order_total": 30,
    "raw_credit_line_total": {
      "value": "0",
      "precision": 20
    },
    "raw_transaction_total": {
      "value": "20",
      "precision": 20
    },
    "raw_pending_difference": {
      "value": "0",
      "precision": 20
    },
    "raw_current_order_total": {
      "value": "20",
      "precision": 20
    },
    "raw_original_order_total": {
      "value": "30",
      "precision": 20
    }
  },
  "version": 5,
  "region_id": "reg_01JH041FK8JJ7CPX6M6SPMM3Z0",
  "customer_id": "cus_01JH04FNTSNV2FGS2B2KS80Z08",
  "sales_channel_id": "sc_01JH041AJPJ8ZQ4S8SAQYVD9FH",
  "items": [
    {
      "id": "ordli_01JH04FZW3XQJJMZ6GFTHPBPDV",
      "title": "M",
      "subtitle": "Medusa Sweatshirt",
      "thumbnail": "https://medusa-public-images.s3.eu-west-1.amazonaws.com/sweatshirt-vintage-front.png",
      "variant_id": "variant_01JH041GR2PYWW2R23EKE32VHY",
      "product_id": "prod_01JH041G9MCSJF58AMFZ32YZC4",
      "product_title": "Medusa Sweatshirt",
      "product_description": "Reimagine the feeling of a classic sweatshirt. With our cotton sweatshirt, everyday essentials no longer have to be ordinary.",
      "product_subtitle": null,
      "product_type": null,
      "product_type_id": null,
      "product_collection": null,
      "product_handle": "sweatshirt",
      "variant_sku": "SWEATSHIRT-M",
      "variant_barcode": null,
      "variant_title": "M",
      "variant_option_values": null,
      "requires_shipping": true,
      "is_discountable": true,
      "is_tax_inclusive": false,
      "raw_compare_at_unit_price": null,
      "raw_unit_price": {
        "value": "10",
        "precision": 20
      },
      "is_custom_price": false,
      "metadata": {},
      "created_at": "2025-01-07T10:20:47.876Z",
      "updated_at": "2025-01-07T10:20:47.876Z",
      "deleted_at": null,
      "tax_lines": [],
      "adjustments": [],
      "compare_at_unit_price": null,
      "unit_price": 10,
      "quantity": 1,
      "raw_quantity": {
        "value": "1",
        "precision": 20
      },
      "detail": {
        "id": "orditem_01JH050VMG32NVJJGVPSFE1VHN",
        "order_id": "order_01JH04FZW22A776G2FK7CC9HHS",
        "version": 5,
        "item_id": "ordli_01JH04FZW3XQJJMZ6GFTHPBPDV",
        "raw_unit_price": {
          "value": "10",
          "precision": 20
        },
        "raw_compare_at_unit_price": null,
        "raw_quantity": {
          "value": "1",
          "precision": 20
        },
        "raw_fulfilled_quantity": {
          "value": "0",
          "precision": 20
        },
        "raw_delivered_quantity": {
          "value": "0",
          "precision": 20
        },
        "raw_shipped_quantity": {
          "value": "0",
          "precision": 20
        },
        "raw_return_requested_quantity": {
          "value": "0",
          "precision": 20
        },
        "raw_return_received_quantity": {
          "value": "0",
          "precision": 20
        },
        "raw_return_dismissed_quantity": {
          "value": "0",
          "precision": 20
        },
        "raw_written_off_quantity": {
          "value": "0",
          "precision": 20
        },
        "metadata": null,
        "created_at": "2025-01-07T10:30:00.592Z",
        "updated_at": "2025-01-07T10:30:00.592Z",
        "deleted_at": null,
        "unit_price": 10,
        "compare_at_unit_price": null,
        "quantity": 1,
        "fulfilled_quantity": 0,
        "delivered_quantity": 0,
        "shipped_quantity": 0,
        "return_requested_quantity": 0,
        "return_received_quantity": 0,
        "return_dismissed_quantity": 0,
        "written_off_quantity": 0
      },
      "subtotal": 10,
      "total": 10,
      "original_total": 10,
      "discount_total": 0,
      "discount_subtotal": 0,
      "discount_tax_total": 0,
      "tax_total": 0,
      "original_tax_total": 0,
      "refundable_total_per_unit": 10,
      "refundable_total": 10,
      "fulfilled_total": 0,
      "shipped_total": 0,
      "return_requested_total": 0,
      "return_received_total": 0,
      "return_dismissed_total": 0,
      "write_off_total": 0,
      "raw_subtotal": {
        "value": "10",
        "precision": 20
      },
      "raw_total": {
        "value": "10",
        "precision": 20
      },
      "raw_original_total": {
        "value": "10",
        "precision": 20
      },
      "raw_discount_total": {
        "value": "0",
        "precision": 20
      },
      "raw_discount_subtotal": {
        "value": "0",
        "precision": 20
      },
      "raw_discount_tax_total": {
        "value": "0",
        "precision": 20
      },
      "raw_tax_total": {
        "value": "0",
        "precision": 20
      },
      "raw_original_tax_total": {
        "value": "0",
        "precision": 20
      },
      "raw_refundable_total_per_unit": {
        "value": "10",
        "precision": 20
      },
      "raw_refundable_total": {
        "value": "10",
        "precision": 20
      },
      "raw_fulfilled_total": {
        "value": "0",
        "precision": 20
      },
      "raw_shipped_total": {
        "value": "0",
        "precision": 20
      },
      "raw_return_requested_total": {
        "value": "0",
        "precision": 20
      },
      "raw_return_received_total": {
        "value": "0",
        "precision": 20
      },
      "raw_return_dismissed_total": {
        "value": "0",
        "precision": 20
      },
      "raw_write_off_total": {
        "value": "0",
        "precision": 20
      },
      "variant": {
        "id": "variant_01JH041GR2PYWW2R23EKE32VHY",
        "title": "M",
        "sku": "SWEATSHIRT-M",
        "barcode": null,
        "ean": null,
        "upc": null,
        "allow_backorder": false,
        "manage_inventory": true,
        "hs_code": null,
        "origin_country": null,
        "mid_code": null,
        "material": null,
        "weight": null,
        "length": null,
        "height": null,
        "width": null,
        "metadata": null,
        "variant_rank": 0,
        "product_id": "prod_01JH041G9MCSJF58AMFZ32YZC4",
        "product": {
          "id": "prod_01JH041G9MCSJF58AMFZ32YZC4",
          "title": "Medusa Sweatshirt",
          "handle": "sweatshirt",
          "subtitle": null,
          "description": "Reimagine the feeling of a classic sweatshirt. With our cotton sweatshirt, everyday essentials no longer have to be ordinary.",
          "is_giftcard": false,
          "status": "published",
          "thumbnail": "https://medusa-public-images.s3.eu-west-1.amazonaws.com/sweatshirt-vintage-front.png",
          "weight": "400",
          "length": null,
          "height": null,
          "width": null,
          "origin_country": null,
          "hs_code": null,
          "mid_code": null,
          "material": null,
          "discountable": true,
          "external_id": null,
          "metadata": null,
          "type_id": null,
          "type": null,
          "collection_id": null,
          "collection": null,
          "created_at": "2025-01-07T10:11:20.691Z",
          "updated_at": "2025-01-07T10:11:20.691Z",
          "deleted_at": null
        },
        "created_at": "2025-01-07T10:12:53.635Z",
        "updated_at": "2025-01-07T10:12:53.635Z",
        "deleted_at": null,
        "options": [
          {
            "id": "optval_01JH041GDWAJBGZSWKM3067XSH",
            "value": "M",
            "metadata": null,
            "option_id": "opt_01JH041GCHXQK7ABWQGP63RS27",
            "option": {
              "id": "opt_01JH041GCHXQK7ABWQGP63RS27"
            },
            "created_at": "2025-01-07T10:11:20.691Z",
            "updated_at": "2025-01-07T10:11:20.691Z",
            "deleted_at": null
          }
        ],
        "inventory_items": [
          {
            "required_quantity": 1,
            "variant_id": "variant_01JH041GR2PYWW2R23EKE32VHY",
            "inventory_item_id": "iitem_01JH041GXXV55SY8TAF6ZGEFDH",
            "inventory": {
              "id": "iitem_01JH041GXXV55SY8TAF6ZGEFDH",
              "sku": "SWEATSHIRT-M",
              "origin_country": null,
              "hs_code": null,
              "mid_code": null,
              "material": null,
              "weight": null,
              "length": null,
              "height": null,
              "width": null,
              "requires_shipping": true,
              "description": "M",
              "title": "M",
              "thumbnail": null,
              "metadata": null,
              "created_at": "2025-01-07T10:12:53.823Z",
              "updated_at": "2025-01-07T10:12:53.823Z",
              "deleted_at": null
            }
          }
        ]
      }
    }
  ],
  "shipping_address": {
    "id": "caaddr_01JH04FNWDQJ9C488EPVJZZ42M",
    "customer_id": null,
    "company": "xxx.xxx",
    "first_name": "xxx.xxx",
    "last_name": "xxx.xxx",
    "address_1": "49 rue xxx.xxx",
    "address_2": "",
    "city": "Boulogne billancourt",
    "country_code": "fr",
    "province": "",
    "postal_code": "94000",
    "phone": "+33xxx.xxx",
    "metadata": null,
    "created_at": "2025-01-07T10:20:37.645Z",
    "updated_at": "2025-01-07T10:20:37.645Z"
  },
  "billing_address": {
    "id": "caaddr_01JH04FNWD5H46PR8A2R6BJ2NN",
    "customer_id": null,
    "company": "xxx.xxx",
    "first_name": "xxx.xxx",
    "last_name": "xxx.xxx",
    "address_1": "49 rue xxx.xxx",
    "address_2": "",
    "city": "Boulogne billancourt",
    "country_code": "fr",
    "province": "",
    "postal_code": "94000",
    "phone": "+33xxx.xxx",
    "metadata": null,
    "created_at": "2025-01-07T10:20:37.645Z",
    "updated_at": "2025-01-07T10:20:37.645Z"
  },
  "shipping_methods": [
    {
      "id": "ordsm_01JH04FZW2RBT6EE9BB5BJQFM9",
      "name": "Express Shipping",
      "description": null,
      "raw_amount": {
        "value": "10",
        "precision": 20
      },
      "is_tax_inclusive": false,
      "is_custom_amount": false,
      "shipping_option_id": "so_01JH041FYP7T4872P1Q6K2WMWF",
      "data": {},
      "metadata": null,
      "created_at": "2025-01-07T10:20:47.877Z",
      "updated_at": "2025-01-07T10:20:47.877Z",
      "deleted_at": null,
      "tax_lines": [],
      "adjustments": [],
      "amount": 10,
      "order_id": "order_01JH04FZW22A776G2FK7CC9HHS",
      "detail": {
        "id": "ordspmv_01JH050VMH415B8D9813PTTZFY",
        "order_id": "order_01JH04FZW22A776G2FK7CC9HHS",
        "version": 5,
        "shipping_method_id": "ordsm_01JH04FZW2RBT6EE9BB5BJQFM9",
        "created_at": "2025-01-07T10:20:47.877Z",
        "updated_at": "2025-01-07T10:20:47.877Z",
        "deleted_at": null
      },
      "subtotal": 10,
      "total": 10,
      "original_total": 10,
      "discount_total": 0,
      "discount_subtotal": 0,
      "discount_tax_total": 0,
      "tax_total": 0,
      "original_tax_total": 0,
      "raw_subtotal": {
        "value": "10",
        "precision": 20
      },
      "raw_total": {
        "value": "10",
        "precision": 20
      },
      "raw_original_total": {
        "value": "10",
        "precision": 20
      },
      "raw_discount_total": {
        "value": "0",
        "precision": 20
      },
      "raw_discount_subtotal": {
        "value": "0",
        "precision": 20
      },
      "raw_discount_tax_total": {
        "value": "0",
        "precision": 20
      },
      "raw_tax_total": {
        "value": "0",
        "precision": 20
      },
      "raw_original_tax_total": {
        "value": "0",
        "precision": 20
      }
    }
  ],
  "region": {
    "automatic_taxes": true,
    "id": "reg_01JH041FK8JJ7CPX6M6SPMM3Z0"
  },
  "customer": {
    "id": "cus_01JH04FNTSNV2FGS2B2KS80Z08",
    "company_name": null,
    "first_name": null,
    "last_name": null,
    "email": "[email protected]",
    "phone": null,
    "has_account": false,
    "metadata": null,
    "created_by": null,
    "created_at": "2025-01-07T10:20:37.593Z",
    "updated_at": "2025-01-07T10:20:37.593Z",
    "deleted_at": null
  },
  "sales_channel": {
    "id": "sc_01JH041AJPJ8ZQ4S8SAQYVD9FH",
    "name": "Default Sales Channel",
    "description": "Created by Medusa",
    "is_disabled": false,
    "metadata": null,
    "created_at": "2025-01-07T10:12:47.318Z",
    "updated_at": "2025-01-07T10:12:47.319Z",
    "deleted_at": null
  },
  "promotion": [],
  "fulfillments": [],
  "payment_collections": [
    {
      "id": "pay_col_01JH04FXG08W6DCB03H0RZB9H5",
      "currency_code": "eur",
      "region_id": "reg_01JH041FK8JJ7CPX6M6SPMM3Z0",
      "completed_at": null,
      "status": "authorized",
      "metadata": null,
      "raw_amount": {
        "value": "20",
        "precision": 20
      },
      "raw_authorized_amount": {
        "value": "20",
        "precision": 20
      },
      "raw_captured_amount": {
        "value": "20",
        "precision": 20
      },
      "raw_refunded_amount": {
        "value": "0",
        "precision": 20
      },
      "created_at": "2025-01-07T10:20:45.440Z",
      "updated_at": "2025-01-07T10:26:16.467Z",
      "deleted_at": null,
      "payments": [
        {
          "id": "pay_01JH04FZPB2H6MH6DNSBG6EE8Y",
          "currency_code": "eur",
          "provider_id": "pp_system_default",
          "cart_id": null,
          "order_id": null,
          "customer_id": null,
          "data": {},
          "metadata": null,
          "captured_at": "2025-01-07T10:26:16.401Z",
          "canceled_at": null,
          "payment_collection_id": "pay_col_01JH04FXG08W6DCB03H0RZB9H5",
          "payment_session": {
            "id": "payses_01JH04FXKYWWHWEXNN3BN7JH3K"
          },
          "raw_amount": {
            "value": "20",
            "precision": 20
          },
          "created_at": "2025-01-07T10:20:47.692Z",
          "updated_at": "2025-01-07T10:26:16.421Z",
          "deleted_at": null,
          "payment_session_id": "payses_01JH04FXKYWWHWEXNN3BN7JH3K",
          "refunds": [],
          "amount": 20
        }
      ],
      "amount": 20,
      "authorized_amount": 20,
      "captured_amount": 20,
      "refunded_amount": 0
    },
    {
      "id": "pay_col_01JH04GQVVQQGG651MKGHGRB2X",
      "currency_code": "eur",
      "region_id": "reg_01JH041FK8JJ7CPX6M6SPMM3Z0",
      "completed_at": null,
      "status": "not_paid",
      "metadata": null,
      "raw_amount": {
        "value": "10",
        "precision": 20
      },
      "raw_authorized_amount": null,
      "raw_captured_amount": null,
      "raw_refunded_amount": null,
      "created_at": "2025-01-07T10:21:12.443Z",
      "updated_at": "2025-01-07T10:29:59.306Z",
      "deleted_at": null,
      "payments": [],
      "amount": 10,
      "authorized_amount": null,
      "captured_amount": null,
      "refunded_amount": null
    }
  ],
  "payment_status": "partially_captured",
  "fulfillment_status": "not_fulfilled"
}

@docloulou
Copy link
Contributor Author

docloulou commented Jan 8, 2025

@olivermrbl sorry to insist,
i may found the issue: everything is here : packages/core/core-flows/src/order/workflows/create-or-update-order-payment-collection.ts

I'm encountering an issue where modifying the quantity of an item in an order leads to inconsistent handling of payment collections. Specifically:

Scenario:
  1.     When I edit an order and increase the quantity of an item, the amountPending triggers the creation or modification of a PaymentCollection.
    
  2.     If I revert the quantity back to its original value, the PaymentCollection is neither deleted nor updated to zero.
    
  3.     As a result, a pending amount remains, which can only increase with further quantity changes.
    

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

No branches or pull requests

3 participants