diff --git a/.changeset/tall-camels-dance.md b/.changeset/tall-camels-dance.md new file mode 100644 index 0000000000000..ddd6c8007a54a --- /dev/null +++ b/.changeset/tall-camels-dance.md @@ -0,0 +1,10 @@ +--- +"@medusajs/dashboard": patch +"@medusajs/core-flows": patch +"@medusajs/types": patch +"@medusajs/utils": patch +"@medusajs/medusa": patch +"@medusajs/order": patch +--- + +feat(dashboard,core-flows,types,utils,medusa,order): Order cancelations will refund payments diff --git a/integration-tests/http/__tests__/order/admin/order.spec.ts b/integration-tests/http/__tests__/order/admin/order.spec.ts index 092b033f228bb..8e6fb14be7d61 100644 --- a/integration-tests/http/__tests__/order/admin/order.spec.ts +++ b/integration-tests/http/__tests__/order/admin/order.spec.ts @@ -343,6 +343,199 @@ medusaIntegrationTestRunner({ }) }) + describe("POST /orders/:id/cancel", () => { + beforeEach(async () => { + seeder = await createOrderSeeder({ + api, + container: getContainer(), + }) + order = seeder.order + + order = (await api.get(`/admin/orders/${order.id}`, adminHeaders)).data + .order + }) + + it("should successfully cancel an order and its authorized but not captured payments", async () => { + const response = await api.post( + `/admin/orders/${order.id}/cancel`, + {}, + adminHeaders + ) + + expect(response.status).toBe(200) + expect(response.data.order).toEqual( + expect.objectContaining({ + id: order.id, + status: "canceled", + + summary: expect.objectContaining({ + credit_line_total: 106, + current_order_total: 0, + accounting_total: 0, + }), + + payment_collections: [ + expect.objectContaining({ + status: "canceled", + captured_amount: 0, + refunded_amount: 0, + amount: 106, + payments: [ + expect.objectContaining({ + canceled_at: expect.any(String), + refunds: [], + captures: [], + }), + ], + }), + ], + }) + ) + }) + + it("should successfully cancel an order with a captured payment", async () => { + const payment = order.payment_collections[0].payments[0] + + const paymentResponse = await api.post( + `/admin/payments/${payment.id}/capture`, + undefined, + adminHeaders + ) + + expect(paymentResponse.data.payment).toEqual( + expect.objectContaining({ + id: payment.id, + captured_at: expect.any(String), + captures: [ + expect.objectContaining({ + id: expect.any(String), + amount: 106, + }), + ], + refunds: [], + amount: 106, + }) + ) + + const response = await api.post( + `/admin/orders/${order.id}/cancel`, + {}, + adminHeaders + ) + + expect(response.status).toBe(200) + expect(response.data.order).toEqual( + expect.objectContaining({ + id: order.id, + status: "canceled", + + summary: expect.objectContaining({ + credit_line_total: 106, + current_order_total: 0, + accounting_total: 0, + }), + + payment_collections: [ + expect.objectContaining({ + status: "canceled", + captured_amount: 106, + refunded_amount: 106, + amount: 106, + payments: [ + expect.objectContaining({ + // canceled_at: expect.any(String), + refunds: [ + expect.objectContaining({ + id: expect.any(String), + amount: 106, + }), + ], + captures: [ + expect.objectContaining({ + id: expect.any(String), + amount: 106, + }), + ], + }), + ], + }), + ], + }) + ) + }) + + it("should successfully cancel an order with a partially captured payment", async () => { + const payment = order.payment_collections[0].payments[0] + + const paymentResponse = await api.post( + `/admin/payments/${payment.id}/capture`, + { amount: 50 }, + adminHeaders + ) + + expect(paymentResponse.data.payment).toEqual( + expect.objectContaining({ + id: payment.id, + captured_at: null, + captures: [ + expect.objectContaining({ + id: expect.any(String), + amount: 50, + }), + ], + refunds: [], + amount: 106, + }) + ) + + const response = await api.post( + `/admin/orders/${order.id}/cancel`, + {}, + adminHeaders + ) + + expect(response.status).toBe(200) + expect(response.data.order).toEqual( + expect.objectContaining({ + id: order.id, + status: "canceled", + + summary: expect.objectContaining({ + credit_line_total: 106, + current_order_total: 0, + accounting_total: 0, + }), + + payment_collections: [ + expect.objectContaining({ + status: "canceled", + captured_amount: 50, + refunded_amount: 50, + amount: 106, + payments: [ + expect.objectContaining({ + // canceled_at: expect.any(String), + refunds: [ + expect.objectContaining({ + id: expect.any(String), + amount: 50, + }), + ], + captures: [ + expect.objectContaining({ + id: expect.any(String), + amount: 50, + }), + ], + }), + ], + }), + ], + }) + ) + }) + }) + describe("POST /orders/:id/fulfillments", () => { beforeEach(async () => { const stockChannelOverride = ( diff --git a/packages/admin/dashboard/src/i18n/translations/$schema.json b/packages/admin/dashboard/src/i18n/translations/$schema.json index d755ecd0d0e86..4d5a983377363 100644 --- a/packages/admin/dashboard/src/i18n/translations/$schema.json +++ b/packages/admin/dashboard/src/i18n/translations/$schema.json @@ -258,11 +258,7 @@ "type": "string" } }, - "required": [ - "header_one", - "header_other", - "description" - ], + "required": ["header_one", "header_other", "description"], "additionalProperties": false } }, @@ -311,11 +307,7 @@ "type": "string" } }, - "required": [ - "insertRowAbove", - "insertRowBelow", - "deleteRow" - ], + "required": ["insertRowAbove", "insertRowBelow", "deleteRow"], "additionalProperties": false }, "labels": { @@ -328,10 +320,7 @@ "type": "string" } }, - "required": [ - "key", - "value" - ], + "required": ["key", "value"], "additionalProperties": false }, "complexRow": { @@ -347,11 +336,7 @@ "type": "string" } }, - "required": [ - "label", - "description", - "tooltip" - ], + "required": ["label", "description", "tooltip"], "additionalProperties": false } }, @@ -366,12 +351,7 @@ "additionalProperties": false } }, - "required": [ - "header", - "numberOfKeys_one", - "numberOfKeys_other", - "edit" - ], + "required": ["header", "numberOfKeys_one", "numberOfKeys_other", "edit"], "additionalProperties": false }, "validation": { @@ -384,10 +364,7 @@ "type": "string" } }, - "required": [ - "mustBeInt", - "mustBePositive" - ], + "required": ["mustBeInt", "mustBePositive"], "additionalProperties": false }, "actions": { @@ -573,9 +550,7 @@ "type": "string" } }, - "required": [ - "in" - ], + "required": ["in"], "additionalProperties": false }, "app": { @@ -926,12 +901,7 @@ "type": "string" } }, - "required": [ - "label", - "dark", - "light", - "system" - ], + "required": ["label", "dark", "light", "system"], "additionalProperties": false } }, @@ -954,10 +924,7 @@ "type": "string" } }, - "required": [ - "label", - "storeSettings" - ], + "required": ["label", "storeSettings"], "additionalProperties": false }, "actions": { @@ -967,17 +934,11 @@ "type": "string" } }, - "required": [ - "logout" - ], + "required": ["logout"], "additionalProperties": false } }, - "required": [ - "user", - "store", - "actions" - ], + "required": ["user", "store", "actions"], "additionalProperties": false }, "nav": { @@ -993,10 +954,7 @@ "type": "string" } }, - "required": [ - "title", - "description" - ], + "required": ["title", "description"], "additionalProperties": false }, "common": { @@ -1006,9 +964,7 @@ "type": "string" } }, - "required": [ - "extensions" - ], + "required": ["extensions"], "additionalProperties": false }, "main": { @@ -1021,10 +977,7 @@ "type": "string" } }, - "required": [ - "store", - "storeSettings" - ], + "required": ["store", "storeSettings"], "additionalProperties": false }, "settings": { @@ -1043,30 +996,15 @@ "type": "string" } }, - "required": [ - "header", - "general", - "developer", - "myAccount" - ], + "required": ["header", "general", "developer", "myAccount"], "additionalProperties": false } }, - "required": [ - "accessibility", - "common", - "main", - "settings" - ], + "required": ["accessibility", "common", "main", "settings"], "additionalProperties": false } }, - "required": [ - "search", - "keyboardShortcuts", - "menus", - "nav" - ], + "required": ["search", "keyboardShortcuts", "menus", "nav"], "additionalProperties": false }, "dataGrid": { @@ -1085,11 +1023,7 @@ "type": "string" } }, - "required": [ - "view", - "resetToDefault", - "disabled" - ], + "required": ["view", "resetToDefault", "disabled"], "additionalProperties": false }, "shortcuts": { @@ -1183,10 +1117,7 @@ "additionalProperties": false } }, - "required": [ - "label", - "commands" - ], + "required": ["label", "commands"], "additionalProperties": false }, "errors": { @@ -1202,19 +1133,11 @@ "type": "string" } }, - "required": [ - "fixError", - "count_one", - "count_other" - ], + "required": ["fixError", "count_one", "count_other"], "additionalProperties": false } }, - "required": [ - "columns", - "shortcuts", - "errors" - ], + "required": ["columns", "shortcuts", "errors"], "additionalProperties": false }, "filters": { @@ -1300,11 +1223,7 @@ "type": "string" } }, - "required": [ - "date", - "compare", - "addFilter" - ], + "required": ["date", "compare", "addFilter"], "additionalProperties": false }, "errorBoundary": { @@ -1374,12 +1293,7 @@ "type": "string" } }, - "required": [ - "header", - "editHeader", - "editLabel", - "label" - ], + "required": ["header", "editHeader", "editLabel", "label"], "additionalProperties": false }, "billingAddress": { @@ -1438,11 +1352,7 @@ "type": "string" } }, - "required": [ - "editHeader", - "editLabel", - "label" - ], + "required": ["editHeader", "editLabel", "label"], "additionalProperties": false }, "transferOwnership": { @@ -1464,10 +1374,7 @@ "type": "string" } }, - "required": [ - "order", - "draft" - ], + "required": ["order", "draft"], "additionalProperties": false }, "currentOwner": { @@ -1480,10 +1387,7 @@ "type": "string" } }, - "required": [ - "label", - "hint" - ], + "required": ["label", "hint"], "additionalProperties": false }, "newOwner": { @@ -1496,10 +1400,7 @@ "type": "string" } }, - "required": [ - "label", - "hint" - ], + "required": ["label", "hint"], "additionalProperties": false }, "validation": { @@ -1512,10 +1413,7 @@ "type": "string" } }, - "required": [ - "mustBeDifferent", - "required" - ], + "required": ["mustBeDifferent", "required"], "additionalProperties": false } }, @@ -1536,9 +1434,7 @@ "type": "string" } }, - "required": [ - "availableIn" - ], + "required": ["availableIn"], "additionalProperties": false }, "products": { @@ -1554,9 +1450,7 @@ "type": "string" } }, - "required": [ - "noRecordsMessage" - ], + "required": ["noRecordsMessage"], "additionalProperties": false }, "edit": { @@ -1572,11 +1466,7 @@ "type": "string" } }, - "required": [ - "header", - "description", - "successToast" - ], + "required": ["header", "description", "successToast"], "additionalProperties": false }, "create": { @@ -1607,12 +1497,7 @@ "type": "string" } }, - "required": [ - "details", - "organize", - "variants", - "inventory" - ], + "required": ["details", "organize", "variants", "inventory"], "additionalProperties": false }, "errors": { @@ -1628,11 +1513,7 @@ "type": "string" } }, - "required": [ - "variants", - "options", - "uniqueSku" - ], + "required": ["variants", "options", "uniqueSku"], "additionalProperties": false }, "inventory": { @@ -1678,9 +1559,7 @@ "type": "string" } }, - "required": [ - "placeholder" - ], + "required": ["placeholder"], "additionalProperties": false }, "optionValues": { @@ -1690,9 +1569,7 @@ "type": "string" } }, - "required": [ - "placeholder" - ], + "required": ["placeholder"], "additionalProperties": false }, "productVariants": { @@ -1711,12 +1588,7 @@ "type": "string" } }, - "required": [ - "label", - "hint", - "alert", - "tip" - ], + "required": ["label", "hint", "alert", "tip"], "additionalProperties": false }, "productOptions": { @@ -1729,10 +1601,7 @@ "type": "string" } }, - "required": [ - "label", - "hint" - ], + "required": ["label", "hint"], "additionalProperties": false } }, @@ -1782,10 +1651,7 @@ "type": "string" } }, - "required": [ - "title", - "description" - ], + "required": ["title", "description"], "additionalProperties": false }, "filters": { @@ -1798,10 +1664,7 @@ "type": "string" } }, - "required": [ - "title", - "description" - ], + "required": ["title", "description"], "additionalProperties": false }, "columns": { @@ -1814,10 +1677,7 @@ "type": "string" } }, - "required": [ - "title", - "description" - ], + "required": ["title", "description"], "additionalProperties": false } }, @@ -1855,10 +1715,7 @@ "type": "string" } }, - "required": [ - "title", - "description" - ], + "required": ["title", "description"], "additionalProperties": false }, "upload": { @@ -1899,10 +1756,7 @@ "type": "string" } }, - "required": [ - "title", - "description" - ], + "required": ["title", "description"], "additionalProperties": false } }, @@ -1996,11 +1850,7 @@ "type": "string" } }, - "required": [ - "header", - "description", - "action" - ], + "required": ["header", "description", "action"], "additionalProperties": false }, "successToast": { @@ -2059,12 +1909,7 @@ "type": "string" } }, - "required": [ - "draft", - "published", - "proposed", - "rejected" - ], + "required": ["draft", "published", "proposed", "rejected"], "additionalProperties": false }, "fields": { @@ -2080,10 +1925,7 @@ "type": "string" } }, - "required": [ - "label", - "hint" - ], + "required": ["label", "hint"], "additionalProperties": false }, "subtitle": { @@ -2093,9 +1935,7 @@ "type": "string" } }, - "required": [ - "label" - ], + "required": ["label"], "additionalProperties": false }, "handle": { @@ -2108,10 +1948,7 @@ "type": "string" } }, - "required": [ - "label", - "tooltip" - ], + "required": ["label", "tooltip"], "additionalProperties": false }, "description": { @@ -2124,10 +1961,7 @@ "type": "string" } }, - "required": [ - "label", - "hint" - ], + "required": ["label", "hint"], "additionalProperties": false }, "discountable": { @@ -2140,10 +1974,7 @@ "type": "string" } }, - "required": [ - "label", - "hint" - ], + "required": ["label", "hint"], "additionalProperties": false }, "type": { @@ -2153,9 +1984,7 @@ "type": "string" } }, - "required": [ - "label" - ], + "required": ["label"], "additionalProperties": false }, "collection": { @@ -2165,9 +1994,7 @@ "type": "string" } }, - "required": [ - "label" - ], + "required": ["label"], "additionalProperties": false }, "categories": { @@ -2177,9 +2004,7 @@ "type": "string" } }, - "required": [ - "label" - ], + "required": ["label"], "additionalProperties": false }, "tags": { @@ -2189,9 +2014,7 @@ "type": "string" } }, - "required": [ - "label" - ], + "required": ["label"], "additionalProperties": false }, "sales_channels": { @@ -2204,10 +2027,7 @@ "type": "string" } }, - "required": [ - "label", - "hint" - ], + "required": ["label", "hint"], "additionalProperties": false }, "countryOrigin": { @@ -2217,9 +2037,7 @@ "type": "string" } }, - "required": [ - "label" - ], + "required": ["label"], "additionalProperties": false }, "material": { @@ -2229,9 +2047,7 @@ "type": "string" } }, - "required": [ - "label" - ], + "required": ["label"], "additionalProperties": false }, "width": { @@ -2241,9 +2057,7 @@ "type": "string" } }, - "required": [ - "label" - ], + "required": ["label"], "additionalProperties": false }, "length": { @@ -2253,9 +2067,7 @@ "type": "string" } }, - "required": [ - "label" - ], + "required": ["label"], "additionalProperties": false }, "height": { @@ -2265,9 +2077,7 @@ "type": "string" } }, - "required": [ - "label" - ], + "required": ["label"], "additionalProperties": false }, "weight": { @@ -2277,9 +2087,7 @@ "type": "string" } }, - "required": [ - "label" - ], + "required": ["label"], "additionalProperties": false }, "options": { @@ -2328,10 +2136,7 @@ "type": "string" } }, - "required": [ - "label", - "hint" - ], + "required": ["label", "hint"], "additionalProperties": false }, "mid_code": { @@ -2341,9 +2146,7 @@ "type": "string" } }, - "required": [ - "label" - ], + "required": ["label"], "additionalProperties": false }, "hs_code": { @@ -2353,9 +2156,7 @@ "type": "string" } }, - "required": [ - "label" - ], + "required": ["label"], "additionalProperties": false } }, @@ -2396,10 +2197,7 @@ "type": "string" } }, - "required": [ - "header", - "success" - ], + "required": ["header", "success"], "additionalProperties": false }, "create": { @@ -2409,9 +2207,7 @@ "type": "string" } }, - "required": [ - "header" - ], + "required": ["header"], "additionalProperties": false }, "deleteWarning": { @@ -2457,10 +2253,7 @@ "type": "string" } }, - "required": [ - "inventoryItems", - "inventoryKit" - ], + "required": ["inventoryItems", "inventoryKit"], "additionalProperties": false }, "inventoryKit": { @@ -2479,10 +2272,7 @@ "type": "string" } }, - "required": [ - "itemId", - "quantity" - ], + "required": ["itemId", "quantity"], "additionalProperties": false }, "header": { @@ -2577,10 +2367,7 @@ "type": "string" } }, - "required": [ - "header", - "successToast" - ], + "required": ["header", "successToast"], "additionalProperties": false }, "create": { @@ -2593,22 +2380,14 @@ "type": "string" } }, - "required": [ - "header", - "successToast" - ], + "required": ["header", "successToast"], "additionalProperties": false }, "deleteWarning": { "type": "string" } }, - "required": [ - "header", - "edit", - "create", - "deleteWarning" - ], + "required": ["header", "edit", "create", "deleteWarning"], "additionalProperties": false }, "organization": { @@ -2630,23 +2409,15 @@ "type": "string" } }, - "required": [ - "success" - ], + "required": ["success"], "additionalProperties": false } }, - "required": [ - "header", - "toasts" - ], + "required": ["header", "toasts"], "additionalProperties": false } }, - "required": [ - "header", - "edit" - ], + "required": ["header", "edit"], "additionalProperties": false }, "toasts": { @@ -2665,10 +2436,7 @@ "type": "string" } }, - "required": [ - "header", - "description" - ], + "required": ["header", "description"], "additionalProperties": false }, "error": { @@ -2678,22 +2446,15 @@ "type": "string" } }, - "required": [ - "header" - ], + "required": ["header"], "additionalProperties": false } }, - "required": [ - "success", - "error" - ], + "required": ["success", "error"], "additionalProperties": false } }, - "required": [ - "delete" - ], + "required": ["delete"], "additionalProperties": false } }, @@ -2771,9 +2532,7 @@ "type": "string" } }, - "required": [ - "noRecordsMessage" - ], + "required": ["noRecordsMessage"], "additionalProperties": false }, "add": { @@ -2786,10 +2545,7 @@ "type": "string" } }, - "required": [ - "successToast_one", - "successToast_other" - ], + "required": ["successToast_one", "successToast_other"], "additionalProperties": false }, "remove": { @@ -2802,18 +2558,11 @@ "type": "string" } }, - "required": [ - "successToast_one", - "successToast_other" - ], + "required": ["successToast_one", "successToast_other"], "additionalProperties": false } }, - "required": [ - "list", - "add", - "remove" - ], + "required": ["list", "add", "remove"], "additionalProperties": false } }, @@ -2861,22 +2610,14 @@ "type": "string" } }, - "required": [ - "details", - "organize" - ], + "required": ["details", "organize"], "additionalProperties": false }, "successToast": { "type": "string" } }, - "required": [ - "header", - "hint", - "tabs", - "successToast" - ], + "required": ["header", "hint", "tabs", "successToast"], "additionalProperties": false }, "edit": { @@ -2892,11 +2633,7 @@ "type": "string" } }, - "required": [ - "header", - "description", - "successToast" - ], + "required": ["header", "description", "successToast"], "additionalProperties": false }, "delete": { @@ -2909,10 +2646,7 @@ "type": "string" } }, - "required": [ - "confirmation", - "successToast" - ], + "required": ["confirmation", "successToast"], "additionalProperties": false }, "products": { @@ -2969,17 +2703,11 @@ "type": "string" } }, - "required": [ - "noRecordsMessage" - ], + "required": ["noRecordsMessage"], "additionalProperties": false } }, - "required": [ - "add", - "remove", - "list" - ], + "required": ["add", "remove", "list"], "additionalProperties": false }, "organize": { @@ -2992,10 +2720,7 @@ "type": "string" } }, - "required": [ - "header", - "action" - ], + "required": ["header", "action"], "additionalProperties": false }, "fields": { @@ -3014,11 +2739,7 @@ "type": "string" } }, - "required": [ - "label", - "internal", - "public" - ], + "required": ["label", "internal", "public"], "additionalProperties": false }, "status": { @@ -3034,11 +2755,7 @@ "type": "string" } }, - "required": [ - "label", - "active", - "inactive" - ], + "required": ["label", "active", "inactive"], "additionalProperties": false }, "path": { @@ -3051,10 +2768,7 @@ "type": "string" } }, - "required": [ - "label", - "tooltip" - ], + "required": ["label", "tooltip"], "additionalProperties": false }, "children": { @@ -3064,9 +2778,7 @@ "type": "string" } }, - "required": [ - "label" - ], + "required": ["label"], "additionalProperties": false }, "new": { @@ -3076,19 +2788,11 @@ "type": "string" } }, - "required": [ - "label" - ], + "required": ["label"], "additionalProperties": false } }, - "required": [ - "visibility", - "status", - "path", - "children", - "new" - ], + "required": ["visibility", "status", "path", "children", "new"], "additionalProperties": false } }, @@ -3238,10 +2942,7 @@ "type": "string" } }, - "required": [ - "noAvaliableQuantity", - "quantityOutOfRange" - ], + "required": ["noAvaliableQuantity", "quantityOutOfRange"], "additionalProperties": false } }, @@ -3277,15 +2978,11 @@ "type": "string" } }, - "required": [ - "stockedQuantity" - ], + "required": ["stockedQuantity"], "additionalProperties": false } }, - "required": [ - "errors" - ], + "required": ["errors"], "additionalProperties": false }, "toast": { @@ -3301,11 +2998,7 @@ "type": "string" } }, - "required": [ - "updateLocations", - "updateLevel", - "updateItem" - ], + "required": ["updateLocations", "updateLevel", "updateItem"], "additionalProperties": false } }, @@ -3411,9 +3104,7 @@ "type": "string" } }, - "required": [ - "noRecordsMessage" - ], + "required": ["noRecordsMessage"], "additionalProperties": false }, "create": { @@ -3429,11 +3120,7 @@ "type": "string" } }, - "required": [ - "header", - "hint", - "successToast" - ], + "required": ["header", "hint", "successToast"], "additionalProperties": false }, "groups": { @@ -3458,9 +3145,7 @@ "type": "string" } }, - "required": [ - "noRecordsMessage" - ], + "required": ["noRecordsMessage"], "additionalProperties": false }, "add": { @@ -3476,16 +3161,11 @@ "type": "string" } }, - "required": [ - "noRecordsMessage" - ], + "required": ["noRecordsMessage"], "additionalProperties": false } }, - "required": [ - "success", - "list" - ], + "required": ["success", "list"], "additionalProperties": false }, "removed": { @@ -3501,16 +3181,11 @@ "type": "string" } }, - "required": [ - "noRecordsMessage" - ], + "required": ["noRecordsMessage"], "additionalProperties": false } }, - "required": [ - "success", - "list" - ], + "required": ["success", "list"], "additionalProperties": false } }, @@ -3538,11 +3213,7 @@ "type": "string" } }, - "required": [ - "header", - "emailDisabledTooltip", - "successToast" - ], + "required": ["header", "emailDisabledTooltip", "successToast"], "additionalProperties": false }, "delete": { @@ -3558,11 +3229,7 @@ "type": "string" } }, - "required": [ - "title", - "description", - "successToast" - ], + "required": ["title", "description", "successToast"], "additionalProperties": false }, "fields": { @@ -3578,11 +3245,7 @@ "type": "string" } }, - "required": [ - "guest", - "registered", - "groups" - ], + "required": ["guest", "registered", "groups"], "additionalProperties": false }, "registered": { @@ -3631,11 +3294,7 @@ "type": "string" } }, - "required": [ - "header", - "hint", - "successToast" - ], + "required": ["header", "hint", "successToast"], "additionalProperties": false }, "edit": { @@ -3648,10 +3307,7 @@ "type": "string" } }, - "required": [ - "header", - "successToast" - ], + "required": ["header", "successToast"], "additionalProperties": false }, "delete": { @@ -3667,11 +3323,7 @@ "type": "string" } }, - "required": [ - "title", - "description", - "successToast" - ], + "required": ["title", "description", "successToast"], "additionalProperties": false }, "customers": { @@ -3696,17 +3348,11 @@ "type": "string" } }, - "required": [ - "noRecordsMessage" - ], + "required": ["noRecordsMessage"], "additionalProperties": false } }, - "required": [ - "successToast_one", - "successToast_other", - "list" - ], + "required": ["successToast_one", "successToast_other", "list"], "additionalProperties": false }, "remove": { @@ -3740,18 +3386,11 @@ "type": "string" } }, - "required": [ - "noRecordsMessage" - ], + "required": ["noRecordsMessage"], "additionalProperties": false } }, - "required": [ - "alreadyAddedTooltip", - "add", - "remove", - "list" - ], + "required": ["alreadyAddedTooltip", "add", "remove", "list"], "additionalProperties": false } }, @@ -3793,9 +3432,35 @@ "type": "string" } }, - "required": [ - "noRecordsMessage" - ], + "required": ["noRecordsMessage"], + "additionalProperties": false + }, + "status": { + "type": "object", + "properties": { + "not_paid": { + "type": "string" + }, + "draft": { + "type": "string" + }, + "pending": { + "type": "string" + }, + "completed": { + "type": "string" + }, + "archived": { + "type": "string" + }, + "canceled": { + "type": "string" + }, + "requires_action": { + "type": "string" + } + }, + "required": ["scheduled", "expired", "active", "enabled", "disabled"], "additionalProperties": false }, "summary": { @@ -4087,10 +3752,7 @@ "type": "string" } }, - "required": [ - "title", - "titlePending" - ], + "required": ["title", "titlePending"], "additionalProperties": false }, "toast": { @@ -4103,10 +3765,7 @@ "type": "string" } }, - "required": [ - "canceledSuccessfully", - "confirmedSuccessfully" - ], + "required": ["canceledSuccessfully", "confirmedSuccessfully"], "additionalProperties": false }, "validation": { @@ -4116,9 +3775,7 @@ "type": "string" } }, - "required": [ - "quantityLowerThanFulfillment" - ], + "required": ["quantityLowerThanFulfillment"], "additionalProperties": false } }, @@ -4159,10 +3816,7 @@ "type": "string" } }, - "required": [ - "title", - "requestSuccess" - ], + "required": ["title", "requestSuccess"], "additionalProperties": false }, "shippingAddress": { @@ -4175,10 +3829,7 @@ "type": "string" } }, - "required": [ - "title", - "requestSuccess" - ], + "required": ["title", "requestSuccess"], "additionalProperties": false }, "billingAddress": { @@ -4191,18 +3842,11 @@ "type": "string" } }, - "required": [ - "title", - "requestSuccess" - ], + "required": ["title", "requestSuccess"], "additionalProperties": false } }, - "required": [ - "email", - "shippingAddress", - "billingAddress" - ], + "required": ["email", "shippingAddress", "billingAddress"], "additionalProperties": false }, "returns": { @@ -4308,10 +3952,7 @@ "type": "string" } }, - "required": [ - "title", - "description" - ], + "required": ["title", "description"], "additionalProperties": false }, "placeholders": { @@ -4327,10 +3968,7 @@ "type": "string" } }, - "required": [ - "title", - "hint" - ], + "required": ["title", "hint"], "additionalProperties": false }, "outboundShippingOptions": { @@ -4343,10 +3981,7 @@ "type": "string" } }, - "required": [ - "title", - "hint" - ], + "required": ["title", "hint"], "additionalProperties": false } }, @@ -4431,10 +4066,7 @@ "type": "string" } }, - "required": [ - "canceledSuccessfully", - "confirmedSuccessfully" - ], + "required": ["canceledSuccessfully", "confirmedSuccessfully"], "additionalProperties": false }, "panel": { @@ -4447,10 +4079,7 @@ "type": "string" } }, - "required": [ - "title", - "description" - ], + "required": ["title", "description"], "additionalProperties": false } }, @@ -4539,15 +4168,11 @@ "type": "string" } }, - "required": [ - "successToast" - ], + "required": ["successToast"], "additionalProperties": false } }, - "required": [ - "cancelClaim" - ], + "required": ["cancelClaim"], "additionalProperties": false }, "cancel": { @@ -4560,10 +4185,7 @@ "type": "string" } }, - "required": [ - "title", - "description" - ], + "required": ["title", "description"], "additionalProperties": false }, "tooltips": { @@ -4573,9 +4195,7 @@ "type": "string" } }, - "required": [ - "onlyReturnShippingOptions" - ], + "required": ["onlyReturnShippingOptions"], "additionalProperties": false }, "toast": { @@ -4588,10 +4208,7 @@ "type": "string" } }, - "required": [ - "canceledSuccessfully", - "confirmedSuccessfully" - ], + "required": ["canceledSuccessfully", "confirmedSuccessfully"], "additionalProperties": false }, "panel": { @@ -4604,10 +4221,7 @@ "type": "string" } }, - "required": [ - "title", - "description" - ], + "required": ["title", "description"], "additionalProperties": false } }, @@ -4677,15 +4291,11 @@ "type": "string" } }, - "required": [ - "successToast" - ], + "required": ["successToast"], "additionalProperties": false } }, - "required": [ - "cancelExchange" - ], + "required": ["cancelExchange"], "additionalProperties": false }, "cancel": { @@ -4698,10 +4308,7 @@ "type": "string" } }, - "required": [ - "title", - "description" - ], + "required": ["title", "description"], "additionalProperties": false }, "tooltips": { @@ -4711,9 +4318,7 @@ "type": "string" } }, - "required": [ - "onlyReturnShippingOptions" - ], + "required": ["onlyReturnShippingOptions"], "additionalProperties": false }, "toast": { @@ -4726,10 +4331,7 @@ "type": "string" } }, - "required": [ - "canceledSuccessfully", - "confirmedSuccessfully" - ], + "required": ["canceledSuccessfully", "confirmedSuccessfully"], "additionalProperties": false }, "panel": { @@ -4742,10 +4344,7 @@ "type": "string" } }, - "required": [ - "title", - "description" - ], + "required": ["title", "description"], "additionalProperties": false } }, @@ -4779,10 +4378,7 @@ "type": "string" } }, - "required": [ - "allocatedLabel", - "notAllocatedLabel" - ], + "required": ["allocatedLabel", "notAllocatedLabel"], "additionalProperties": false }, "allocateItems": { @@ -4819,9 +4415,7 @@ "type": "string" } }, - "required": [ - "created" - ], + "required": ["created"], "additionalProperties": false }, "error": { @@ -4831,9 +4425,7 @@ "type": "string" } }, - "required": [ - "quantityNotAllocated" - ], + "required": ["quantityNotAllocated"], "additionalProperties": false } }, @@ -4956,11 +4548,7 @@ "type": "string" } }, - "required": [ - "wrongQuantity", - "wrongQuantity_other", - "noItems" - ], + "required": ["wrongQuantity", "wrongQuantity_other", "noItems"], "additionalProperties": false }, "status": { @@ -5106,11 +4694,7 @@ "type": "string" } }, - "required": [ - "amountToLarge", - "amountNegative", - "reasonRequired" - ], + "required": ["amountToLarge", "amountNegative", "reasonRequired"], "additionalProperties": false } }, @@ -5206,10 +4790,7 @@ "type": "string" } }, - "required": [ - "toReturn", - "toSend" - ], + "required": ["toReturn", "toSend"], "additionalProperties": false }, "placed": { @@ -5222,10 +4803,7 @@ "type": "string" } }, - "required": [ - "title", - "fromSalesChannel" - ], + "required": ["title", "fromSalesChannel"], "additionalProperties": false }, "canceled": { @@ -5235,9 +4813,7 @@ "type": "string" } }, - "required": [ - "title" - ], + "required": ["title"], "additionalProperties": false }, "payment": { @@ -5256,12 +4832,7 @@ "type": "string" } }, - "required": [ - "awaiting", - "captured", - "canceled", - "refunded" - ], + "required": ["awaiting", "captured", "canceled", "refunded"], "additionalProperties": false }, "fulfillment": { @@ -5334,10 +4905,7 @@ "type": "string" } }, - "required": [ - "comment", - "byLine" - ], + "required": ["comment", "byLine"], "additionalProperties": false }, "claim": { @@ -5398,10 +4966,7 @@ "type": "string" } }, - "required": [ - "requested", - "confirmed" - ], + "required": ["requested", "confirmed"], "additionalProperties": false }, "transfer": { @@ -5417,11 +4982,7 @@ "type": "string" } }, - "required": [ - "requested", - "confirmed", - "declined" - ], + "required": ["requested", "confirmed", "declined"], "additionalProperties": false }, "update_order": { @@ -5437,11 +4998,7 @@ "type": "string" } }, - "required": [ - "shipping_address", - "billing_address", - "email" - ], + "required": ["shipping_address", "billing_address", "email"], "additionalProperties": false } }, @@ -5486,11 +5043,7 @@ "type": "string" } }, - "required": [ - "displayId", - "refundableAmount", - "returnableQuantity" - ], + "required": ["displayId", "refundableAmount", "returnableQuantity"], "additionalProperties": false } }, @@ -5549,11 +5102,7 @@ "type": "string" } }, - "required": [ - "label", - "warningTitle", - "warningDescription" - ], + "required": ["label", "warningTitle", "warningDescription"], "additionalProperties": false }, "status": { @@ -5566,10 +5115,7 @@ "type": "string" } }, - "required": [ - "open", - "completed" - ], + "required": ["open", "completed"], "additionalProperties": false }, "create": { @@ -5710,9 +5256,7 @@ "type": "string" } }, - "required": [ - "description" - ], + "required": ["description"], "additionalProperties": false }, "create": { @@ -5728,11 +5272,7 @@ "type": "string" } }, - "required": [ - "header", - "hint", - "successToast" - ], + "required": ["header", "hint", "successToast"], "additionalProperties": false }, "edit": { @@ -5748,11 +5288,7 @@ "type": "string" } }, - "required": [ - "header", - "viewInventory", - "successToast" - ], + "required": ["header", "viewInventory", "successToast"], "additionalProperties": false }, "delete": { @@ -5762,9 +5298,7 @@ "type": "string" } }, - "required": [ - "confirmation" - ], + "required": ["confirmation"], "additionalProperties": false }, "fulfillmentProviders": { @@ -5813,9 +5347,7 @@ "type": "string" } }, - "required": [ - "header" - ], + "required": ["header"], "additionalProperties": false }, "shipping": { @@ -5825,9 +5357,7 @@ "type": "string" } }, - "required": [ - "header" - ], + "required": ["header"], "additionalProperties": false }, "disable": { @@ -5843,11 +5373,7 @@ "type": "string" } }, - "required": [ - "confirmation", - "pickup", - "shipping" - ], + "required": ["confirmation", "pickup", "shipping"], "additionalProperties": false }, "enable": { @@ -5860,19 +5386,11 @@ "type": "string" } }, - "required": [ - "pickup", - "shipping" - ], + "required": ["pickup", "shipping"], "additionalProperties": false } }, - "required": [ - "pickup", - "shipping", - "disable", - "enable" - ], + "required": ["pickup", "shipping", "disable", "enable"], "additionalProperties": false }, "sidebar": { @@ -5891,17 +5409,11 @@ "type": "string" } }, - "required": [ - "label", - "description" - ], + "required": ["label", "description"], "additionalProperties": false } }, - "required": [ - "header", - "shippingProfiles" - ], + "required": ["header", "shippingProfiles"], "additionalProperties": false }, "salesChannels": { @@ -5958,12 +5470,7 @@ "type": "string" } }, - "required": [ - "header", - "hint", - "label", - "successToast" - ], + "required": ["header", "hint", "label", "successToast"], "additionalProperties": false }, "returns": { @@ -5982,12 +5489,7 @@ "type": "string" } }, - "required": [ - "header", - "hint", - "label", - "successToast" - ], + "required": ["header", "hint", "label", "successToast"], "additionalProperties": false }, "tabs": { @@ -6000,22 +5502,14 @@ "type": "string" } }, - "required": [ - "details", - "prices" - ], + "required": ["details", "prices"], "additionalProperties": false }, "action": { "type": "string" } }, - "required": [ - "shipping", - "returns", - "tabs", - "action" - ], + "required": ["shipping", "returns", "tabs", "action"], "additionalProperties": false }, "delete": { @@ -6028,10 +5522,7 @@ "type": "string" } }, - "required": [ - "confirmation", - "successToast" - ], + "required": ["confirmation", "successToast"], "additionalProperties": false }, "edit": { @@ -6047,11 +5538,7 @@ "type": "string" } }, - "required": [ - "header", - "action", - "successToast" - ], + "required": ["header", "action", "successToast"], "additionalProperties": false }, "pricing": { @@ -6061,9 +5548,7 @@ "type": "string" } }, - "required": [ - "action" - ], + "required": ["action"], "additionalProperties": false }, "conditionalPrices": { @@ -6082,9 +5567,7 @@ "type": "string" } }, - "required": [ - "cartItemTotal" - ], + "required": ["cartItemTotal"], "additionalProperties": false }, "summaries": { @@ -6100,11 +5583,7 @@ "type": "string" } }, - "required": [ - "range", - "greaterThan", - "lessThan" - ], + "required": ["range", "greaterThan", "lessThan"], "additionalProperties": false }, "actions": { @@ -6117,10 +5596,7 @@ "type": "string" } }, - "required": [ - "addPrice", - "manageConditionalPrices" - ], + "required": ["addPrice", "manageConditionalPrices"], "additionalProperties": false }, "rules": { @@ -6136,11 +5612,7 @@ "type": "string" } }, - "required": [ - "amount", - "gte", - "lte" - ], + "required": ["amount", "gte", "lte"], "additionalProperties": false }, "customRules": { @@ -6162,13 +5634,7 @@ "type": "string" } }, - "required": [ - "label", - "tooltip", - "eq", - "gt", - "lt" - ], + "required": ["label", "tooltip", "eq", "gt", "lt"], "additionalProperties": false }, "errors": { @@ -6258,10 +5724,7 @@ "type": "string" } }, - "required": [ - "label", - "hint" - ], + "required": ["label", "hint"], "additionalProperties": false }, "calculated": { @@ -6274,24 +5737,15 @@ "type": "string" } }, - "required": [ - "label", - "hint" - ], + "required": ["label", "hint"], "additionalProperties": false } }, - "required": [ - "fixed", - "calculated" - ], + "required": ["fixed", "calculated"], "additionalProperties": false } }, - "required": [ - "label", - "options" - ], + "required": ["label", "options"], "additionalProperties": false }, "enableInStore": { @@ -6304,10 +5758,7 @@ "type": "string" } }, - "required": [ - "label", - "hint" - ], + "required": ["label", "hint"], "additionalProperties": false }, "provider": { @@ -6378,10 +5829,7 @@ "type": "string" } }, - "required": [ - "header", - "successToast" - ], + "required": ["header", "successToast"], "additionalProperties": false }, "delete": { @@ -6394,10 +5842,7 @@ "type": "string" } }, - "required": [ - "confirmation", - "successToast" - ], + "required": ["confirmation", "successToast"], "additionalProperties": false }, "manageAreas": { @@ -6419,13 +5864,7 @@ "type": "string" } }, - "required": [ - "header", - "action", - "label", - "hint", - "successToast" - ], + "required": ["header", "action", "label", "hint", "successToast"], "additionalProperties": false }, "fields": { @@ -6438,20 +5877,11 @@ "type": "string" } }, - "required": [ - "noRecords", - "tip" - ], + "required": ["noRecords", "tip"], "additionalProperties": false } }, - "required": [ - "create", - "edit", - "delete", - "manageAreas", - "fields" - ], + "required": ["create", "edit", "delete", "manageAreas", "fields"], "additionalProperties": false } }, @@ -6492,11 +5922,7 @@ "type": "string" } }, - "required": [ - "header", - "hint", - "successToast" - ], + "required": ["header", "hint", "successToast"], "additionalProperties": false }, "delete": { @@ -6512,11 +5938,7 @@ "type": "string" } }, - "required": [ - "title", - "description", - "successToast" - ], + "required": ["title", "description", "successToast"], "additionalProperties": false }, "tooltip": { @@ -6526,19 +5948,11 @@ "type": "string" } }, - "required": [ - "type" - ], + "required": ["type"], "additionalProperties": false } }, - "required": [ - "domain", - "subtitle", - "create", - "delete", - "tooltip" - ], + "required": ["domain", "subtitle", "create", "delete", "tooltip"], "additionalProperties": false }, "taxRegions": { @@ -6554,9 +5968,7 @@ "type": "string" } }, - "required": [ - "hint" - ], + "required": ["hint"], "additionalProperties": false }, "delete": { @@ -6569,10 +5981,7 @@ "type": "string" } }, - "required": [ - "confirmation", - "successToast" - ], + "required": ["confirmation", "successToast"], "additionalProperties": false }, "create": { @@ -6594,22 +6003,14 @@ "type": "string" } }, - "required": [ - "rateIsRequired", - "nameIsRequired" - ], + "required": ["rateIsRequired", "nameIsRequired"], "additionalProperties": false }, "successToast": { "type": "string" } }, - "required": [ - "header", - "hint", - "errors", - "successToast" - ], + "required": ["header", "hint", "errors", "successToast"], "additionalProperties": false }, "province": { @@ -6628,17 +6029,11 @@ "type": "string" } }, - "required": [ - "header", - "hint" - ], + "required": ["header", "hint"], "additionalProperties": false } }, - "required": [ - "header", - "create" - ], + "required": ["header", "create"], "additionalProperties": false }, "state": { @@ -6657,17 +6052,11 @@ "type": "string" } }, - "required": [ - "header", - "hint" - ], + "required": ["header", "hint"], "additionalProperties": false } }, - "required": [ - "header", - "create" - ], + "required": ["header", "create"], "additionalProperties": false }, "stateOrTerritory": { @@ -6686,17 +6075,11 @@ "type": "string" } }, - "required": [ - "header", - "hint" - ], + "required": ["header", "hint"], "additionalProperties": false } }, - "required": [ - "header", - "create" - ], + "required": ["header", "create"], "additionalProperties": false }, "county": { @@ -6715,17 +6098,11 @@ "type": "string" } }, - "required": [ - "header", - "hint" - ], + "required": ["header", "hint"], "additionalProperties": false } }, - "required": [ - "header", - "create" - ], + "required": ["header", "create"], "additionalProperties": false }, "region": { @@ -6744,17 +6121,11 @@ "type": "string" } }, - "required": [ - "header", - "hint" - ], + "required": ["header", "hint"], "additionalProperties": false } }, - "required": [ - "header", - "create" - ], + "required": ["header", "create"], "additionalProperties": false }, "department": { @@ -6773,17 +6144,11 @@ "type": "string" } }, - "required": [ - "header", - "hint" - ], + "required": ["header", "hint"], "additionalProperties": false } }, - "required": [ - "header", - "create" - ], + "required": ["header", "create"], "additionalProperties": false }, "territory": { @@ -6802,17 +6167,11 @@ "type": "string" } }, - "required": [ - "header", - "hint" - ], + "required": ["header", "hint"], "additionalProperties": false } }, - "required": [ - "header", - "create" - ], + "required": ["header", "create"], "additionalProperties": false }, "prefecture": { @@ -6831,17 +6190,11 @@ "type": "string" } }, - "required": [ - "header", - "hint" - ], + "required": ["header", "hint"], "additionalProperties": false } }, - "required": [ - "header", - "create" - ], + "required": ["header", "create"], "additionalProperties": false }, "district": { @@ -6860,17 +6213,11 @@ "type": "string" } }, - "required": [ - "header", - "hint" - ], + "required": ["header", "hint"], "additionalProperties": false } }, - "required": [ - "header", - "create" - ], + "required": ["header", "create"], "additionalProperties": false }, "governorate": { @@ -6889,17 +6236,11 @@ "type": "string" } }, - "required": [ - "header", - "hint" - ], + "required": ["header", "hint"], "additionalProperties": false } }, - "required": [ - "header", - "create" - ], + "required": ["header", "create"], "additionalProperties": false }, "canton": { @@ -6918,17 +6259,11 @@ "type": "string" } }, - "required": [ - "header", - "hint" - ], + "required": ["header", "hint"], "additionalProperties": false } }, - "required": [ - "header", - "create" - ], + "required": ["header", "create"], "additionalProperties": false }, "emirate": { @@ -6947,17 +6282,11 @@ "type": "string" } }, - "required": [ - "header", - "hint" - ], + "required": ["header", "hint"], "additionalProperties": false } }, - "required": [ - "header", - "create" - ], + "required": ["header", "create"], "additionalProperties": false }, "sublevel": { @@ -6976,17 +6305,11 @@ "type": "string" } }, - "required": [ - "header", - "hint" - ], + "required": ["header", "hint"], "additionalProperties": false } }, - "required": [ - "header", - "create" - ], + "required": ["header", "create"], "additionalProperties": false }, "taxOverrides": { @@ -7005,10 +6328,7 @@ "type": "string" } }, - "required": [ - "header", - "hint" - ], + "required": ["header", "hint"], "additionalProperties": false }, "edit": { @@ -7021,18 +6341,11 @@ "type": "string" } }, - "required": [ - "header", - "hint" - ], + "required": ["header", "hint"], "additionalProperties": false } }, - "required": [ - "header", - "create", - "edit" - ], + "required": ["header", "create", "edit"], "additionalProperties": false }, "taxRates": { @@ -7051,11 +6364,7 @@ "type": "string" } }, - "required": [ - "header", - "hint", - "successToast" - ], + "required": ["header", "hint", "successToast"], "additionalProperties": false }, "edit": { @@ -7071,11 +6380,7 @@ "type": "string" } }, - "required": [ - "header", - "hint", - "successToast" - ], + "required": ["header", "hint", "successToast"], "additionalProperties": false }, "delete": { @@ -7088,18 +6393,11 @@ "type": "string" } }, - "required": [ - "confirmation", - "successToast" - ], + "required": ["confirmation", "successToast"], "additionalProperties": false } }, - "required": [ - "create", - "edit", - "delete" - ], + "required": ["create", "edit", "delete"], "additionalProperties": false }, "fields": { @@ -7121,12 +6419,7 @@ "type": "string" } }, - "required": [ - "label", - "hint", - "true", - "false" - ], + "required": ["label", "hint", "true", "false"], "additionalProperties": false }, "defaultTaxRate": { @@ -7142,11 +6435,7 @@ "type": "string" } }, - "required": [ - "label", - "tooltip", - "action" - ], + "required": ["label", "tooltip", "action"], "additionalProperties": false }, "taxRate": { @@ -7205,11 +6494,7 @@ "type": "string" } }, - "required": [ - "in", - "on", - "and" - ], + "required": ["in", "on", "and"], "additionalProperties": false }, "placeholders": { @@ -7275,9 +6560,7 @@ "type": "string" } }, - "required": [ - "header" - ], + "required": ["header"], "additionalProperties": false }, "values_one": { @@ -7449,10 +6732,7 @@ "type": "string" } }, - "required": [ - "sublevel", - "notPartOfCountry" - ], + "required": ["sublevel", "notPartOfCountry"], "additionalProperties": false }, "alert": { @@ -7468,20 +6748,11 @@ "type": "string" } }, - "required": [ - "header", - "description", - "action" - ], + "required": ["header", "description", "action"], "additionalProperties": false } }, - "required": [ - "labels", - "placeholders", - "tooltips", - "alert" - ], + "required": ["labels", "placeholders", "tooltips", "alert"], "additionalProperties": false }, "noDefaultRate": { @@ -7494,10 +6765,7 @@ "type": "string" } }, - "required": [ - "label", - "tooltip" - ], + "required": ["label", "tooltip"], "additionalProperties": false } }, @@ -7550,9 +6818,7 @@ "type": "string" } }, - "required": [ - "details" - ], + "required": ["details"], "additionalProperties": false }, "tabs": { @@ -7568,11 +6834,7 @@ "type": "string" } }, - "required": [ - "template", - "details", - "campaign" - ], + "required": ["template", "details", "campaign"], "additionalProperties": false }, "fields": { @@ -7609,9 +6871,7 @@ "type": "string" } }, - "required": [ - "tooltip" - ], + "required": ["tooltip"], "additionalProperties": false }, "conditions": { @@ -7627,10 +6887,7 @@ "type": "string" } }, - "required": [ - "title", - "description" - ], + "required": ["title", "description"], "additionalProperties": false }, "target-rules": { @@ -7643,10 +6900,7 @@ "type": "string" } }, - "required": [ - "title", - "description" - ], + "required": ["title", "description"], "additionalProperties": false }, "buy-rules": { @@ -7659,18 +6913,11 @@ "type": "string" } }, - "required": [ - "title", - "description" - ], + "required": ["title", "description"], "additionalProperties": false } }, - "required": [ - "rules", - "target-rules", - "buy-rules" - ], + "required": ["rules", "target-rules", "buy-rules"], "additionalProperties": false } }, @@ -7695,9 +6942,7 @@ "type": "string" } }, - "required": [ - "campaignType" - ], + "required": ["campaignType"], "additionalProperties": false }, "errors": { @@ -7710,10 +6955,7 @@ "type": "string" } }, - "required": [ - "requiredField", - "promotionTabError" - ], + "required": ["requiredField", "promotionTabError"], "additionalProperties": false }, "toasts": { @@ -7723,9 +6965,7 @@ "type": "string" } }, - "required": [ - "promotionCreateSuccess" - ], + "required": ["promotionCreateSuccess"], "additionalProperties": false }, "create": { @@ -7747,9 +6987,7 @@ "type": "string" } }, - "required": [ - "title" - ], + "required": ["title"], "additionalProperties": false }, "target-rules": { @@ -7759,9 +6997,7 @@ "type": "string" } }, - "required": [ - "title" - ], + "required": ["title"], "additionalProperties": false }, "buy-rules": { @@ -7771,18 +7007,11 @@ "type": "string" } }, - "required": [ - "title" - ], + "required": ["title"], "additionalProperties": false } }, - "required": [ - "title", - "rules", - "target-rules", - "buy-rules" - ], + "required": ["title", "rules", "target-rules", "buy-rules"], "additionalProperties": false }, "campaign": { @@ -7801,10 +7030,7 @@ "type": "string" } }, - "required": [ - "header", - "successToast" - ], + "required": ["header", "successToast"], "additionalProperties": false }, "actions": { @@ -7814,17 +7040,11 @@ "type": "string" } }, - "required": [ - "goToCampaign" - ], + "required": ["goToCampaign"], "additionalProperties": false } }, - "required": [ - "header", - "edit", - "actions" - ], + "required": ["header", "edit", "actions"], "additionalProperties": false }, "campaign_currency": { @@ -7834,9 +7054,7 @@ "type": "string" } }, - "required": [ - "tooltip" - ], + "required": ["tooltip"], "additionalProperties": false }, "form": { @@ -7873,18 +7091,11 @@ "type": "string" } }, - "required": [ - "title", - "desc" - ], + "required": ["title", "desc"], "additionalProperties": false } }, - "required": [ - "title", - "description", - "placeholder" - ], + "required": ["title", "description", "placeholder"], "additionalProperties": false }, "new": { @@ -7897,10 +7108,7 @@ "type": "string" } }, - "required": [ - "title", - "description" - ], + "required": ["title", "description"], "additionalProperties": false }, "none": { @@ -7913,18 +7121,11 @@ "type": "string" } }, - "required": [ - "title", - "description" - ], + "required": ["title", "description"], "additionalProperties": false } }, - "required": [ - "existing", - "new", - "none" - ], + "required": ["existing", "new", "none"], "additionalProperties": false }, "status": { @@ -7934,9 +7135,7 @@ "type": "string" } }, - "required": [ - "title" - ], + "required": ["title"], "additionalProperties": false }, "method": { @@ -7955,10 +7154,7 @@ "type": "string" } }, - "required": [ - "title", - "description" - ], + "required": ["title", "description"], "additionalProperties": false }, "automatic": { @@ -7971,18 +7167,11 @@ "type": "string" } }, - "required": [ - "title", - "description" - ], + "required": ["title", "description"], "additionalProperties": false } }, - "required": [ - "label", - "code", - "automatic" - ], + "required": ["label", "code", "automatic"], "additionalProperties": false }, "max_quantity": { @@ -7995,10 +7184,7 @@ "type": "string" } }, - "required": [ - "title", - "description" - ], + "required": ["title", "description"], "additionalProperties": false }, "type": { @@ -8014,10 +7200,7 @@ "type": "string" } }, - "required": [ - "title", - "description" - ], + "required": ["title", "description"], "additionalProperties": false }, "buyget": { @@ -8030,17 +7213,11 @@ "type": "string" } }, - "required": [ - "title", - "description" - ], + "required": ["title", "description"], "additionalProperties": false } }, - "required": [ - "standard", - "buyget" - ], + "required": ["standard", "buyget"], "additionalProperties": false }, "allocation": { @@ -8056,10 +7233,7 @@ "type": "string" } }, - "required": [ - "title", - "description" - ], + "required": ["title", "description"], "additionalProperties": false }, "across": { @@ -8072,17 +7246,11 @@ "type": "string" } }, - "required": [ - "title", - "description" - ], + "required": ["title", "description"], "additionalProperties": false } }, - "required": [ - "each", - "across" - ], + "required": ["each", "across"], "additionalProperties": false }, "code": { @@ -8095,10 +7263,7 @@ "type": "string" } }, - "required": [ - "title", - "description" - ], + "required": ["title", "description"], "additionalProperties": false }, "value": { @@ -8108,9 +7273,7 @@ "type": "string" } }, - "required": [ - "title" - ], + "required": ["title"], "additionalProperties": false }, "value_type": { @@ -8126,10 +7289,7 @@ "type": "string" } }, - "required": [ - "title", - "description" - ], + "required": ["title", "description"], "additionalProperties": false }, "percentage": { @@ -8142,17 +7302,11 @@ "type": "string" } }, - "required": [ - "title", - "description" - ], + "required": ["title", "description"], "additionalProperties": false } }, - "required": [ - "fixed", - "percentage" - ], + "required": ["fixed", "percentage"], "additionalProperties": false } }, @@ -8194,16 +7348,11 @@ "type": "string" } }, - "required": [ - "noRecordsMessage" - ], + "required": ["noRecordsMessage"], "additionalProperties": false } }, - "required": [ - "add", - "list" - ], + "required": ["add", "list"], "additionalProperties": false } }, @@ -8249,11 +7398,7 @@ "type": "string" } }, - "required": [ - "active", - "expired", - "scheduled" - ], + "required": ["active", "expired", "scheduled"], "additionalProperties": false }, "delete": { @@ -8269,11 +7414,7 @@ "type": "string" } }, - "required": [ - "title", - "description", - "successToast" - ], + "required": ["title", "description", "successToast"], "additionalProperties": false }, "edit": { @@ -8289,11 +7430,7 @@ "type": "string" } }, - "required": [ - "header", - "description", - "successToast" - ], + "required": ["header", "description", "successToast"], "additionalProperties": false }, "configuration": { @@ -8315,18 +7452,11 @@ "type": "string" } }, - "required": [ - "header", - "description", - "successToast" - ], + "required": ["header", "description", "successToast"], "additionalProperties": false } }, - "required": [ - "header", - "edit" - ], + "required": ["header", "edit"], "additionalProperties": false }, "create": { @@ -8388,9 +7518,7 @@ "type": "string" } }, - "required": [ - "hint" - ], + "required": ["hint"], "additionalProperties": false } }, @@ -8419,10 +7547,7 @@ "type": "string" } }, - "required": [ - "hint", - "header" - ], + "required": ["hint", "header"], "additionalProperties": false }, "details": { @@ -8444,12 +7569,7 @@ "type": "string" } }, - "required": [ - "type", - "currency", - "limit", - "used" - ], + "required": ["type", "currency", "limit", "used"], "additionalProperties": false }, "type": { @@ -8465,10 +7585,7 @@ "type": "string" } }, - "required": [ - "title", - "description" - ], + "required": ["title", "description"], "additionalProperties": false }, "usage": { @@ -8481,17 +7598,11 @@ "type": "string" } }, - "required": [ - "title", - "description" - ], + "required": ["title", "description"], "additionalProperties": false } }, - "required": [ - "spend", - "usage" - ], + "required": ["spend", "usage"], "additionalProperties": false }, "edit": { @@ -8501,19 +7612,11 @@ "type": "string" } }, - "required": [ - "header" - ], + "required": ["header"], "additionalProperties": false } - }, - "required": [ - "create", - "details", - "fields", - "type", - "edit" - ], + }, + "required": ["create", "details", "fields", "type", "edit"], "additionalProperties": false }, "promotions": { @@ -8529,10 +7632,7 @@ "type": "string" } }, - "required": [ - "title", - "description" - ], + "required": ["title", "description"], "additionalProperties": false }, "alreadyAdded": { @@ -8551,9 +7651,7 @@ "type": "string" } }, - "required": [ - "success" - ], + "required": ["success"], "additionalProperties": false }, "add": { @@ -8566,15 +7664,11 @@ "type": "string" } }, - "required": [ - "noRecordsMessage" - ], + "required": ["noRecordsMessage"], "additionalProperties": false } }, - "required": [ - "list" - ], + "required": ["list"], "additionalProperties": false }, "list": { @@ -8584,9 +7678,7 @@ "type": "string" } }, - "required": [ - "noRecordsMessage" - ], + "required": ["noRecordsMessage"], "additionalProperties": false } }, @@ -8643,10 +7735,7 @@ "type": "string" } }, - "required": [ - "confirmation", - "successToast" - ], + "required": ["confirmation", "successToast"], "additionalProperties": false }, "create": { @@ -8671,11 +7760,7 @@ "type": "string" } }, - "required": [ - "details", - "products", - "prices" - ], + "required": ["details", "products", "prices"], "additionalProperties": false }, "successToast": { @@ -8691,15 +7776,11 @@ "type": "string" } }, - "required": [ - "noRecordsMessage" - ], + "required": ["noRecordsMessage"], "additionalProperties": false } }, - "required": [ - "list" - ], + "required": ["list"], "additionalProperties": false } }, @@ -8722,10 +7803,7 @@ "type": "string" } }, - "required": [ - "header", - "successToast" - ], + "required": ["header", "successToast"], "additionalProperties": false }, "configuration": { @@ -8747,18 +7825,11 @@ "type": "string" } }, - "required": [ - "header", - "description", - "successToast" - ], + "required": ["header", "description", "successToast"], "additionalProperties": false } }, - "required": [ - "header", - "edit" - ], + "required": ["header", "edit"], "additionalProperties": false }, "products": { @@ -8777,10 +7848,7 @@ "type": "string" } }, - "required": [ - "addProducts", - "editPrices" - ], + "required": ["addProducts", "editPrices"], "additionalProperties": false }, "delete": { @@ -8814,9 +7882,7 @@ "type": "string" } }, - "required": [ - "successToast" - ], + "required": ["successToast"], "additionalProperties": false }, "edit": { @@ -8826,19 +7892,11 @@ "type": "string" } }, - "required": [ - "successToast" - ], + "required": ["successToast"], "additionalProperties": false } }, - "required": [ - "header", - "actions", - "delete", - "add", - "edit" - ], + "required": ["header", "actions", "delete", "add", "edit"], "additionalProperties": false }, "fields": { @@ -8854,10 +7912,7 @@ "type": "string" } }, - "required": [ - "label", - "header" - ], + "required": ["label", "header"], "additionalProperties": false }, "status": { @@ -8882,19 +7937,11 @@ "type": "string" } }, - "required": [ - "active", - "draft", - "expired", - "scheduled" - ], + "required": ["active", "draft", "expired", "scheduled"], "additionalProperties": false } }, - "required": [ - "label", - "options" - ], + "required": ["label", "options"], "additionalProperties": false }, "type": { @@ -8919,10 +7966,7 @@ "type": "string" } }, - "required": [ - "label", - "description" - ], + "required": ["label", "description"], "additionalProperties": false }, "override": { @@ -8935,25 +7979,15 @@ "type": "string" } }, - "required": [ - "label", - "description" - ], + "required": ["label", "description"], "additionalProperties": false } }, - "required": [ - "sale", - "override" - ], + "required": ["sale", "override"], "additionalProperties": false } }, - "required": [ - "label", - "hint", - "options" - ], + "required": ["label", "hint", "options"], "additionalProperties": false }, "startsAt": { @@ -8966,10 +8000,7 @@ "type": "string" } }, - "required": [ - "label", - "hint" - ], + "required": ["label", "hint"], "additionalProperties": false }, "endsAt": { @@ -8982,10 +8013,7 @@ "type": "string" } }, - "required": [ - "label", - "hint" - ], + "required": ["label", "hint"], "additionalProperties": false }, "customerAvailability": { @@ -9059,10 +8087,7 @@ "type": "string" } }, - "required": [ - "languageLabel", - "usageInsightsLabel" - ], + "required": ["languageLabel", "usageInsightsLabel"], "additionalProperties": false }, "edit": { @@ -9096,9 +8121,7 @@ "type": "string" } }, - "required": [ - "edit" - ], + "required": ["edit"], "additionalProperties": false } }, @@ -9163,11 +8186,7 @@ "type": "string" } }, - "required": [ - "accepted", - "pending", - "expired" - ], + "required": ["accepted", "pending", "expired"], "additionalProperties": false }, "roles": { @@ -9183,11 +8202,7 @@ "type": "string" } }, - "required": [ - "admin", - "developer", - "member" - ], + "required": ["admin", "developer", "member"], "additionalProperties": false }, "deleteUserWarning": { @@ -9272,9 +8287,7 @@ "type": "string" } }, - "required": [ - "header" - ], + "required": ["header"], "additionalProperties": false }, "toast": { @@ -9396,9 +8409,7 @@ "type": "string" } }, - "required": [ - "noRecordsMessage" - ], + "required": ["noRecordsMessage"], "additionalProperties": false }, "toast": { @@ -9417,12 +8428,7 @@ "type": "string" } }, - "required": [ - "delete", - "edit", - "create", - "countries" - ], + "required": ["delete", "edit", "create", "countries"], "additionalProperties": false }, "shippingOption": { @@ -9456,12 +8462,7 @@ "type": "string" } }, - "required": [ - "outbound", - "outboundHint", - "return", - "returnHint" - ], + "required": ["outbound", "outboundHint", "return", "returnHint"], "additionalProperties": false }, "priceType": { @@ -9477,11 +8478,7 @@ "type": "string" } }, - "required": [ - "label", - "flatRate", - "calculated" - ], + "required": ["label", "flatRate", "calculated"], "additionalProperties": false }, "availability": { @@ -9494,10 +8491,7 @@ "type": "string" } }, - "required": [ - "adminOnly", - "adminOnlyHint" - ], + "required": ["adminOnly", "adminOnlyHint"], "additionalProperties": false }, "taxInclusiveHint": { @@ -9513,10 +8507,7 @@ "type": "string" } }, - "required": [ - "label", - "hint" - ], + "required": ["label", "hint"], "additionalProperties": false } }, @@ -9578,9 +8569,7 @@ "type": "string" } }, - "required": [ - "taxCountriesHint" - ], + "required": ["taxCountriesHint"], "additionalProperties": false }, "settings": { @@ -9634,9 +8623,7 @@ "type": "string" } }, - "required": [ - "sectionTitle" - ], + "required": ["sectionTitle"], "additionalProperties": false }, "taxRate": { @@ -9786,11 +8773,7 @@ "type": "string" } }, - "required": [ - "create", - "update", - "removeChannel" - ], + "required": ["create", "update", "removeChannel"], "additionalProperties": false } }, @@ -9820,11 +8803,7 @@ "type": "string" } }, - "required": [ - "domain", - "subtitle", - "deleteWarning" - ], + "required": ["domain", "subtitle", "deleteWarning"], "additionalProperties": false }, "salesChannels": { @@ -9876,11 +8855,7 @@ "type": "string" } }, - "required": [ - "create", - "update", - "delete" - ], + "required": ["create", "update", "delete"], "additionalProperties": false }, "tooltip": { @@ -9890,9 +8865,7 @@ "type": "string" } }, - "required": [ - "cannotDeleteDefault" - ], + "required": ["cannotDeleteDefault"], "additionalProperties": false }, "products": { @@ -9905,9 +8878,7 @@ "type": "string" } }, - "required": [ - "noRecordsMessage" - ], + "required": ["noRecordsMessage"], "additionalProperties": false }, "add": { @@ -9920,22 +8891,15 @@ "type": "string" } }, - "required": [ - "noRecordsMessage" - ], + "required": ["noRecordsMessage"], "additionalProperties": false } }, - "required": [ - "list" - ], + "required": ["list"], "additionalProperties": false } }, - "required": [ - "list", - "add" - ], + "required": ["list", "add"], "additionalProperties": false } }, @@ -9970,10 +8934,7 @@ "type": "string" } }, - "required": [ - "publishable", - "secret" - ], + "required": ["publishable", "secret"], "additionalProperties": false }, "subtitle": { @@ -9986,10 +8947,7 @@ "type": "string" } }, - "required": [ - "publishable", - "secret" - ], + "required": ["publishable", "secret"], "additionalProperties": false }, "status": { @@ -10002,10 +8960,7 @@ "type": "string" } }, - "required": [ - "active", - "revoked" - ], + "required": ["active", "revoked"], "additionalProperties": false }, "type": { @@ -10018,10 +8973,7 @@ "type": "string" } }, - "required": [ - "publishable", - "secret" - ], + "required": ["publishable", "secret"], "additionalProperties": false }, "create": { @@ -10081,11 +9033,7 @@ "type": "string" } }, - "required": [ - "header", - "description", - "successToast" - ], + "required": ["header", "description", "successToast"], "additionalProperties": false }, "salesChannels": { @@ -10113,9 +9061,7 @@ "type": "string" } }, - "required": [ - "noRecordsMessage" - ], + "required": ["noRecordsMessage"], "additionalProperties": false } }, @@ -10139,10 +9085,7 @@ "type": "string" } }, - "required": [ - "warning", - "successToast" - ], + "required": ["warning", "successToast"], "additionalProperties": false }, "revoke": { @@ -10155,10 +9098,7 @@ "type": "string" } }, - "required": [ - "warning", - "successToast" - ], + "required": ["warning", "successToast"], "additionalProperties": false }, "addSalesChannels": { @@ -10171,15 +9111,11 @@ "type": "string" } }, - "required": [ - "noRecordsMessage" - ], + "required": ["noRecordsMessage"], "additionalProperties": false } }, - "required": [ - "list" - ], + "required": ["list"], "additionalProperties": false }, "removeSalesChannel": { @@ -10227,11 +9163,7 @@ "type": "string" } }, - "required": [ - "revoke", - "copy", - "copySuccessToast" - ], + "required": ["revoke", "copy", "copySuccessToast"], "additionalProperties": false }, "table": { @@ -10244,10 +9176,7 @@ "type": "string" } }, - "required": [ - "lastUsedAtHeader", - "createdAtHeader" - ], + "required": ["lastUsedAtHeader", "createdAtHeader"], "additionalProperties": false }, "fields": { @@ -10324,12 +9253,7 @@ "type": "string" } }, - "required": [ - "header", - "subtitle", - "hint", - "successToast" - ], + "required": ["header", "subtitle", "hint", "successToast"], "additionalProperties": false }, "edit": { @@ -10345,11 +9269,7 @@ "type": "string" } }, - "required": [ - "header", - "subtitle", - "successToast" - ], + "required": ["header", "subtitle", "successToast"], "additionalProperties": false }, "delete": { @@ -10362,10 +9282,7 @@ "type": "string" } }, - "required": [ - "confirmation", - "successToast" - ], + "required": ["confirmation", "successToast"], "additionalProperties": false }, "fields": { @@ -10384,11 +9301,7 @@ "type": "string" } }, - "required": [ - "label", - "placeholder", - "tooltip" - ], + "required": ["label", "placeholder", "tooltip"], "additionalProperties": false }, "label": { @@ -10401,10 +9314,7 @@ "type": "string" } }, - "required": [ - "label", - "placeholder" - ], + "required": ["label", "placeholder"], "additionalProperties": false }, "description": { @@ -10417,18 +9327,11 @@ "type": "string" } }, - "required": [ - "label", - "placeholder" - ], + "required": ["label", "placeholder"], "additionalProperties": false } }, - "required": [ - "value", - "label", - "description" - ], + "required": ["value", "label", "description"], "additionalProperties": false } }, @@ -10457,11 +9360,7 @@ "type": "string" } }, - "required": [ - "forgotPassword", - "title", - "hint" - ], + "required": ["forgotPassword", "title", "hint"], "additionalProperties": false }, "invite": { @@ -10513,9 +9412,7 @@ "type": "string" } }, - "required": [ - "accepted" - ], + "required": ["accepted"], "additionalProperties": false } }, @@ -10660,9 +9557,7 @@ "type": "string" } }, - "required": [ - "noRecordsMessage" - ], + "required": ["noRecordsMessage"], "additionalProperties": false }, "history": { @@ -10759,15 +9654,11 @@ "type": "string" } }, - "required": [ - "waitingToCompensate" - ], + "required": ["waitingToCompensate"], "additionalProperties": false } }, - "required": [ - "state" - ], + "required": ["state"], "additionalProperties": false }, "step": { @@ -10789,18 +9680,11 @@ "type": "string" } }, - "required": [ - "skipped", - "skippedFailure", - "dormant", - "timeout" - ], + "required": ["skipped", "skippedFailure", "dormant", "timeout"], "additionalProperties": false } }, - "required": [ - "state" - ], + "required": ["state"], "additionalProperties": false } }, @@ -10842,11 +9726,7 @@ "type": "string" } }, - "required": [ - "header", - "hint", - "successToast" - ], + "required": ["header", "hint", "successToast"], "additionalProperties": false }, "edit": { @@ -10859,10 +9739,7 @@ "type": "string" } }, - "required": [ - "header", - "successToast" - ], + "required": ["header", "successToast"], "additionalProperties": false }, "delete": { @@ -10875,10 +9752,7 @@ "type": "string" } }, - "required": [ - "confirmation", - "successToast" - ], + "required": ["confirmation", "successToast"], "additionalProperties": false }, "fields": { @@ -10888,20 +9762,11 @@ "type": "string" } }, - "required": [ - "value" - ], + "required": ["value"], "additionalProperties": false } }, - "required": [ - "domain", - "subtitle", - "create", - "edit", - "delete", - "fields" - ], + "required": ["domain", "subtitle", "create", "edit", "delete", "fields"], "additionalProperties": false }, "productTags": { @@ -10923,11 +9788,7 @@ "type": "string" } }, - "required": [ - "header", - "subtitle", - "successToast" - ], + "required": ["header", "subtitle", "successToast"], "additionalProperties": false }, "edit": { @@ -10943,11 +9804,7 @@ "type": "string" } }, - "required": [ - "header", - "subtitle", - "successToast" - ], + "required": ["header", "subtitle", "successToast"], "additionalProperties": false }, "delete": { @@ -10960,10 +9817,7 @@ "type": "string" } }, - "required": [ - "confirmation", - "successToast" - ], + "required": ["confirmation", "successToast"], "additionalProperties": false }, "fields": { @@ -10973,19 +9827,11 @@ "type": "string" } }, - "required": [ - "value" - ], + "required": ["value"], "additionalProperties": false } }, - "required": [ - "domain", - "create", - "edit", - "delete", - "fields" - ], + "required": ["domain", "create", "edit", "delete", "fields"], "additionalProperties": false }, "notifications": { @@ -11004,10 +9850,7 @@ "type": "string" } }, - "required": [ - "title", - "description" - ], + "required": ["title", "description"], "additionalProperties": false }, "accessibility": { @@ -11017,17 +9860,11 @@ "type": "string" } }, - "required": [ - "description" - ], + "required": ["description"], "additionalProperties": false } }, - "required": [ - "domain", - "emptyState", - "accessibility" - ], + "required": ["domain", "emptyState", "accessibility"], "additionalProperties": false }, "errors": { @@ -11040,10 +9877,7 @@ "type": "string" } }, - "required": [ - "serverError", - "invalidCredentials" - ], + "required": ["serverError", "invalidCredentials"], "additionalProperties": false }, "statuses": { @@ -11065,13 +9899,7 @@ "type": "string" } }, - "required": [ - "scheduled", - "expired", - "active", - "enabled", - "disabled" - ], + "required": ["scheduled", "expired", "active", "enabled", "disabled"], "additionalProperties": false }, "labels": { @@ -11866,4 +10694,4 @@ "dateTime" ], "additionalProperties": false -} \ No newline at end of file +} diff --git a/packages/admin/dashboard/src/i18n/translations/en.json b/packages/admin/dashboard/src/i18n/translations/en.json index b77d2de08eed6..8356367a5d4fe 100644 --- a/packages/admin/dashboard/src/i18n/translations/en.json +++ b/packages/admin/dashboard/src/i18n/translations/en.json @@ -916,6 +916,15 @@ "list": { "noRecordsMessage": "Your orders will show up here." }, + "status": { + "not_paid": "Not paid", + "pending": "Pending", + "completed": "Completed", + "draft": "Draft", + "archived": "Archived", + "canceled": "Canceled", + "requires_action": "Requires action" + }, "summary": { "requestReturn": "Request return", "allocateItems": "Allocate items", diff --git a/packages/admin/dashboard/src/lib/order-helpers.ts b/packages/admin/dashboard/src/lib/order-helpers.ts index 2ca088f0defd5..87e3462e0eaa6 100644 --- a/packages/admin/dashboard/src/lib/order-helpers.ts +++ b/packages/admin/dashboard/src/lib/order-helpers.ts @@ -1,5 +1,16 @@ import { TFunction } from "i18next" +export const getCanceledOrderStatus = ( + t: TFunction<"translation">, + status: string +) => { + if (status === "canceled") { + return { label: t("orders.status.canceled"), color: "red" } + } + + return +} + export const getOrderPaymentStatus = ( t: TFunction<"translation">, status: string diff --git a/packages/admin/dashboard/src/routes/orders/order-detail/components/order-general-section/order-general-section.tsx b/packages/admin/dashboard/src/routes/orders/order-detail/components/order-general-section/order-general-section.tsx index e32ae907e3635..40c18c48f50aa 100644 --- a/packages/admin/dashboard/src/routes/orders/order-detail/components/order-general-section/order-general-section.tsx +++ b/packages/admin/dashboard/src/routes/orders/order-detail/components/order-general-section/order-general-section.tsx @@ -1,4 +1,5 @@ import { XCircle } from "@medusajs/icons" +import { HttpTypes } from "@medusajs/types" import { Container, Copy, @@ -9,13 +10,14 @@ import { } from "@medusajs/ui" import { format } from "date-fns" import { useTranslation } from "react-i18next" +import { isPresent } from "../../../../../../../../core/utils/src/common/is-present" import { ActionMenu } from "../../../../../components/common/action-menu" import { useCancelOrder } from "../../../../../hooks/api/orders" import { + getCanceledOrderStatus, getOrderFulfillmentStatus, getOrderPaymentStatus, } from "../../../../../lib/order-helpers" -import { HttpTypes } from "@medusajs/types" type OrderGeneralSectionProps = { order: HttpTypes.AdminOrder @@ -60,6 +62,7 @@ export const OrderGeneralSection = ({ order }: OrderGeneralSectionProps) => {
+
@@ -108,3 +111,18 @@ const PaymentBadge = ({ order }: { order: HttpTypes.AdminOrder }) => { ) } + +const OrderBadge = ({ order }: { order: HttpTypes.AdminOrder }) => { + const { t } = useTranslation() + const orderStatus = getCanceledOrderStatus(t, order.status) + + if (!isPresent(orderStatus)) { + return + } + + return ( + + {orderStatus.label} + + ) +} diff --git a/packages/admin/dashboard/src/routes/orders/order-detail/components/order-payment-section/order-payment-section.tsx b/packages/admin/dashboard/src/routes/orders/order-detail/components/order-payment-section/order-payment-section.tsx index fec3be7c3d048..b9324ef7c94f4 100644 --- a/packages/admin/dashboard/src/routes/orders/order-detail/components/order-payment-section/order-payment-section.tsx +++ b/packages/admin/dashboard/src/routes/orders/order-detail/components/order-payment-section/order-payment-section.tsx @@ -1,5 +1,9 @@ import { ArrowDownRightMini, DocumentText, XCircle } from "@medusajs/icons" -import { AdminPaymentCollection, HttpTypes } from "@medusajs/types" +import { + AdminPayment, + AdminPaymentCollection, + HttpTypes, +} from "@medusajs/types" import { Badge, Button, @@ -14,6 +18,7 @@ import { import { format } from "date-fns" import { Trans, useTranslation } from "react-i18next" import { ActionMenu } from "../../../../../components/common/action-menu" +import DisplayId from "../../../../../components/common/display-id/display-id" import { useCapturePayment } from "../../../../../hooks/api" import { formatCurrency } from "../../../../../lib/format-currency" import { @@ -22,7 +27,6 @@ import { } from "../../../../../lib/money-amount-helpers" import { getOrderPaymentStatus } from "../../../../../lib/order-helpers" import { getTotalCaptured, getTotalPending } from "../../../../../lib/payment" -import DisplayId from "../../../../../components/common/display-id/display-id" type OrderPaymentSectionProps = { order: HttpTypes.AdminOrder @@ -173,9 +177,20 @@ const Payment = ({ ) } - const [status, color] = ( - payment.captured_at ? ["Captured", "green"] : ["Pending", "orange"] - ) as [string, "green" | "orange"] + const getPaymentStatusAttributes = (payment: AdminPayment) => { + if (payment.canceled_at) { + return ["Canceled", "red"] + } else if (payment.captured_at) { + return ["Captured", "green"] + } else { + return ["Pending", "orange"] + } + } + + const [status, color] = getPaymentStatusAttributes(payment) as [ + string, + "green" | "orange" | "red", + ] const showCapture = payment.captured_at === null && payment.canceled_at === null diff --git a/packages/core/core-flows/src/order/workflows/cancel-order.ts b/packages/core/core-flows/src/order/workflows/cancel-order.ts index 8c43679e0af94..6be68ded8bacf 100644 --- a/packages/core/core-flows/src/order/workflows/cancel-order.ts +++ b/packages/core/core-flows/src/order/workflows/cancel-order.ts @@ -5,8 +5,10 @@ import { PaymentCollectionDTO, } from "@medusajs/framework/types" import { + MathBN, MedusaError, OrderWorkflowEvents, + PaymentCollectionStatus, deepFlatMap, } from "@medusajs/framework/utils" import { @@ -17,12 +19,16 @@ import { createWorkflow, parallelize, transform, + when, } from "@medusajs/framework/workflows-sdk" -import { emitEventStep, useRemoteQueryStep } from "../../common" +import { emitEventStep, useQueryGraphStep } from "../../common" +import { updatePaymentCollectionStep } from "../../payment-collection" import { cancelPaymentStep } from "../../payment/steps" import { deleteReservationsByLineItemsStep } from "../../reservation/steps" import { cancelOrdersStep } from "../steps/cancel-orders" import { throwIfOrderIsCancelled } from "../utils/order-validation" +import { createOrderRefundCreditLinesWorkflow } from "./payments/create-order-refund-credit-lines" +import { refundCapturedPaymentsWorkflow } from "./payments/refund-captured-payments" /** * This step validates that an order can be canceled. @@ -42,28 +48,6 @@ export const cancelValidateOrder = createStep( throwIfOrderIsCancelled({ order }) - let refunds = 0 - let captures = 0 - - deepFlatMap(order_, "payment_collections.payments", ({ payments }) => { - refunds += payments?.refunds?.length ?? 0 - captures += payments?.captures?.length ?? 0 - }) - - if (captures > 0) { - throw new MedusaError( - MedusaError.Types.NOT_ALLOWED, - "Order with payment capture(s) cannot be canceled" - ) - } - - if (refunds > 0) { - throw new MedusaError( - MedusaError.Types.NOT_ALLOWED, - "Order with payment refund(s) cannot be canceled" - ) - } - const throwErrorIf = ( arr: unknown[], pred: (obj: any) => boolean, @@ -90,42 +74,74 @@ export const cancelOrderWorkflowId = "cancel-order" export const cancelOrderWorkflow = createWorkflow( cancelOrderWorkflowId, (input: WorkflowData) => { - const order: OrderDTO & { fulfillments: FulfillmentDTO[] } = - useRemoteQueryStep({ - entry_point: "orders", - fields: [ - "id", - "status", - "items.id", - "fulfillments.canceled_at", - "payment_collections.payments.id", - "payment_collections.payments.refunds.id", - "payment_collections.payments.captures.id", - ], - variables: { id: input.order_id }, - list: false, - throw_if_key_not_found: true, - }) + const orderQuery = useQueryGraphStep({ + entity: "orders", + fields: [ + "id", + "status", + "items.id", + "fulfillments.canceled_at", + "payment_collections.payments.id", + "payment_collections.payments.amount", + "payment_collections.payments.refunds.id", + "payment_collections.payments.refunds.amount", + "payment_collections.payments.captures.id", + "payment_collections.payments.captures.amount", + ], + filters: { id: input.order_id }, + options: { throwIfKeyNotFound: true }, + }).config({ name: "get-cart" }) + + const order = transform( + { orderQuery }, + ({ orderQuery }) => orderQuery.data[0] + ) cancelValidateOrder({ order, input }) - const lineItemIds = transform({ order }, ({ order }) => { - return order.items?.map((i) => i.id) + const uncapturedPaymentIds = transform({ order }, ({ order }) => { + const payments = deepFlatMap( + order, + "payment_collections.payments", + ({ payments }) => payments + ) + + const uncapturedPayments = payments.filter( + (payment) => payment.captures.length === 0 + ) + + return uncapturedPayments.map((payment) => payment.id) }) - const paymentIds = transform({ order }, ({ order }) => { - return deepFlatMap( + const creditLineAmount = transform({ order }, ({ order }) => { + const payments = deepFlatMap( order, "payment_collections.payments", - ({ payments }) => { - return payments?.id - } + ({ payments }) => payments + ) + + return payments.reduce( + (acc, payment) => MathBN.sum(acc, payment.amount), + MathBN.convert(0) ) }) + const lineItemIds = transform({ order }, ({ order }) => { + return order.items?.map((i) => i.id) + }) + parallelize( + createOrderRefundCreditLinesWorkflow.runAsStep({ + input: { + order_id: order.id, + amount: creditLineAmount, + }, + }), deleteReservationsByLineItemsStep(lineItemIds), - cancelPaymentStep({ paymentIds }), + cancelPaymentStep({ paymentIds: uncapturedPaymentIds }), + refundCapturedPaymentsWorkflow.runAsStep({ + input: { order_id: order.id }, + }), cancelOrdersStep({ orderIds: [order.id] }), emitEventStep({ eventName: OrderWorkflowEvents.CANCELED, @@ -133,6 +149,19 @@ export const cancelOrderWorkflow = createWorkflow( }) ) + const paymentCollectionids = transform({ order }, ({ order }) => + order.payment_collections?.map((pc) => pc.id) + ) + + when({ paymentCollectionids }, ({ paymentCollectionids }) => { + return !!paymentCollectionids?.length + }).then(() => { + updatePaymentCollectionStep({ + selector: { id: paymentCollectionids }, + update: { status: PaymentCollectionStatus.CANCELED }, + }) + }) + const orderCanceled = createHook("orderCanceled", { order, }) diff --git a/packages/core/core-flows/src/order/workflows/payments/create-order-refund-credit-lines.ts b/packages/core/core-flows/src/order/workflows/payments/create-order-refund-credit-lines.ts new file mode 100644 index 0000000000000..e8cbfac9941ca --- /dev/null +++ b/packages/core/core-flows/src/order/workflows/payments/create-order-refund-credit-lines.ts @@ -0,0 +1,113 @@ +import { BigNumberInput, OrderDTO } from "@medusajs/framework/types" +import { + ChangeActionType, + OrderChangeStatus, + OrderChangeType, +} from "@medusajs/framework/utils" +import { + WorkflowData, + createStep, + createWorkflow, + transform, +} from "@medusajs/framework/workflows-sdk" +import { useQueryGraphStep } from "../../../common" +import { confirmOrderChanges } from "../../steps/confirm-order-changes" +import { createOrderChangeStep } from "../../steps/create-order-change" +import { throwIfOrderIsCancelled } from "../../utils/order-validation" +import { createOrderChangeActionsWorkflow } from "../create-order-change-actions" + +/** + * This step validates that an order refund credit line can be issued + */ +export const validateOrderRefundCreditLinesStep = createStep( + "begin-order-edit-validation", + async function ({ order }: { order: OrderDTO }) { + throwIfOrderIsCancelled({ order }) + } +) + +export const createOrderRefundCreditLinesWorkflowId = + "create-order-refund-credit-lines" +/** + * This workflow creates an order refund credit line + */ +export const createOrderRefundCreditLinesWorkflow = createWorkflow( + createOrderRefundCreditLinesWorkflowId, + function ( + input: WorkflowData<{ + order_id: string + created_by?: string + amount: BigNumberInput + }> + ) { + const orderQuery = useQueryGraphStep({ + entity: "orders", + fields: ["id", "status", "summary", "payment_collections.id"], + filters: { id: input.order_id }, + options: { throwIfKeyNotFound: true }, + }).config({ name: "get-order" }) + + const order = transform( + { orderQuery }, + ({ orderQuery }) => orderQuery.data[0] + ) + + validateOrderRefundCreditLinesStep({ order }) + + const orderChangeInput = transform({ input }, ({ input }) => ({ + change_type: OrderChangeType.CREDIT_LINE, + order_id: input.order_id, + created_by: input.created_by, + })) + + const createdOrderChange = createOrderChangeStep(orderChangeInput) + + const orderChangeActionInput = transform( + { order, orderChange: createdOrderChange, input }, + ({ order, orderChange, input }) => ({ + order_change_id: orderChange.id, + order_id: order.id, + version: orderChange.version, + action: ChangeActionType.CREDIT_LINE_ADD, + reference: "payment_collection", + reference_id: order.payment_collections[0]?.id, + amount: input.amount, + }) + ) + + createOrderChangeActionsWorkflow.runAsStep({ + input: [orderChangeActionInput], + }) + + const orderChangeQuery = useQueryGraphStep({ + entity: "order_change", + fields: [ + "id", + "status", + "change_type", + "actions.id", + "actions.order_id", + "actions.action", + "actions.details", + "actions.reference", + "actions.reference_id", + "actions.internal_note", + ], + filters: { + order_id: input.order_id, + status: [OrderChangeStatus.PENDING], + }, + options: { throwIfKeyNotFound: true }, + }).config({ name: "order-change-query" }) + + const orderChange = transform( + { orderChangeQuery }, + ({ orderChangeQuery }) => orderChangeQuery.data[0] + ) + + confirmOrderChanges({ + changes: [orderChange], + orderId: order.id, + }) + } +) diff --git a/packages/core/core-flows/src/order/workflows/payments/refund-captured-payments.ts b/packages/core/core-flows/src/order/workflows/payments/refund-captured-payments.ts new file mode 100644 index 0000000000000..d8e4de748c2e0 --- /dev/null +++ b/packages/core/core-flows/src/order/workflows/payments/refund-captured-payments.ts @@ -0,0 +1,98 @@ +import { PaymentDTO } from "@medusajs/framework/types" +import { deepFlatMap, MathBN } from "@medusajs/framework/utils" +import { + createWorkflow, + transform, + when, + WorkflowData, +} from "@medusajs/framework/workflows-sdk" +import { useQueryGraphStep } from "../../../common" +import { refundPaymentsWorkflow } from "../../../payment" + +export const refundCapturedPaymentsWorkflowId = + "refund-captured-payments-workflow" +/** + * This workflow refunds a payment. + */ +export const refundCapturedPaymentsWorkflow = createWorkflow( + refundCapturedPaymentsWorkflowId, + ( + input: WorkflowData<{ + order_id: string + created_by?: string + }> + ) => { + const orderQuery = useQueryGraphStep({ + entity: "orders", + fields: [ + "id", + "status", + "summary", + "payment_collections.payments.id", + "payment_collections.payments.amount", + "payment_collections.payments.refunds.id", + "payment_collections.payments.refunds.amount", + "payment_collections.payments.captures.id", + "payment_collections.payments.captures.amount", + ], + filters: { id: input.order_id }, + options: { throwIfKeyNotFound: true }, + }).config({ name: "get-order" }) + + const order = transform( + { orderQuery }, + ({ orderQuery }) => orderQuery.data[0] + ) + + const refundPaymentsData = transform( + { order, input }, + ({ order, input }) => { + const payments: PaymentDTO[] = deepFlatMap( + order, + "payment_collections.payments", + ({ payments }) => payments + ) + + const capturedPayments = payments.filter( + (payment) => payment.captures?.length + ) + + return capturedPayments + .map((payment) => { + const capturedAmount = (payment.captures || []).reduce( + (acc, capture) => MathBN.sum(acc, capture.amount), + MathBN.convert(0) + ) + const refundedAmount = (payment.refunds || []).reduce( + (acc, refund) => MathBN.sum(acc, refund.amount), + MathBN.convert(0) + ) + + const amountToRefund = MathBN.sub(capturedAmount, refundedAmount) + + return { + payment_id: payment.id, + created_by: input.created_by, + amount: amountToRefund, + } + }) + .filter((payment) => MathBN.gt(payment.amount, 0)) + } + ) + + const totalCaptured = transform( + { refundPaymentsData }, + ({ refundPaymentsData }) => + refundPaymentsData.reduce( + (acc, refundPayment) => MathBN.sum(acc, refundPayment.amount), + MathBN.convert(0) + ) + ) + + when({ totalCaptured }, ({ totalCaptured }) => { + return !!MathBN.gt(totalCaptured, 0) + }).then(() => { + refundPaymentsWorkflow.runAsStep({ input: refundPaymentsData }) + }) + } +) diff --git a/packages/core/core-flows/src/payment/steps/cancel-payment.ts b/packages/core/core-flows/src/payment/steps/cancel-payment.ts index 13dd5e3a28c23..7f08ff7b7f33e 100644 --- a/packages/core/core-flows/src/payment/steps/cancel-payment.ts +++ b/packages/core/core-flows/src/payment/steps/cancel-payment.ts @@ -27,6 +27,7 @@ export const cancelPaymentStep = createStep( : [input.paymentIds] const promises: Promise[] = [] + for (const id of paymentIds) { promises.push( paymentModule.cancelPayment(id).catch((e) => { @@ -36,6 +37,7 @@ export const cancelPaymentStep = createStep( }) ) } + await promiseAll(promises) } ) diff --git a/packages/core/core-flows/src/payment/steps/index.ts b/packages/core/core-flows/src/payment/steps/index.ts index af0294b7892c0..7d493c1884155 100644 --- a/packages/core/core-flows/src/payment/steps/index.ts +++ b/packages/core/core-flows/src/payment/steps/index.ts @@ -2,3 +2,4 @@ export * from "./authorize-payment-session" export * from "./cancel-payment" export * from "./capture-payment" export * from "./refund-payment" +export * from "./refund-payments" diff --git a/packages/core/core-flows/src/payment/steps/refund-payments.ts b/packages/core/core-flows/src/payment/steps/refund-payments.ts new file mode 100644 index 0000000000000..f2ed3cf4381ab --- /dev/null +++ b/packages/core/core-flows/src/payment/steps/refund-payments.ts @@ -0,0 +1,52 @@ +import { + BigNumberInput, + IPaymentModuleService, + Logger, + PaymentDTO, +} from "@medusajs/framework/types" +import { + ContainerRegistrationKeys, + isObject, + Modules, + promiseAll, +} from "@medusajs/framework/utils" +import { createStep, StepResponse } from "@medusajs/framework/workflows-sdk" + +export const refundPaymentsStepId = "refund-payments-step" +/** + * This step refunds one or more payments. + */ +export const refundPaymentsStep = createStep( + refundPaymentsStepId, + async ( + input: { + payment_id: string + amount: BigNumberInput + created_by?: string + }[], + { container } + ) => { + const logger = container.resolve(ContainerRegistrationKeys.LOGGER) + const paymentModule = container.resolve( + Modules.PAYMENT + ) + + const promises: Promise[] = [] + + for (const refundInput of input) { + promises.push( + paymentModule.refundPayment(refundInput).catch((e) => { + logger.error( + `Error was thrown trying to cancel payment - ${refundInput.payment_id} - ${e}` + ) + }) + ) + } + + const successfulRefunds = (await promiseAll(promises)).filter((payment) => + isObject(payment) + ) + + return new StepResponse(successfulRefunds) + } +) diff --git a/packages/core/core-flows/src/payment/workflows/index.ts b/packages/core/core-flows/src/payment/workflows/index.ts index 46de7ec09899e..8fe11981ce908 100644 --- a/packages/core/core-flows/src/payment/workflows/index.ts +++ b/packages/core/core-flows/src/payment/workflows/index.ts @@ -1,3 +1,4 @@ export * from "./capture-payment" export * from "./process-payment" export * from "./refund-payment" +export * from "./refund-payments" diff --git a/packages/core/core-flows/src/payment/workflows/refund-payments.ts b/packages/core/core-flows/src/payment/workflows/refund-payments.ts new file mode 100644 index 0000000000000..13e3942a6bafd --- /dev/null +++ b/packages/core/core-flows/src/payment/workflows/refund-payments.ts @@ -0,0 +1,129 @@ +import { BigNumberInput, PaymentDTO } from "@medusajs/framework/types" +import { MathBN, MedusaError } from "@medusajs/framework/utils" +import { + createStep, + createWorkflow, + transform, + WorkflowData, + WorkflowResponse, +} from "@medusajs/framework/workflows-sdk" +import { useQueryGraphStep } from "../../common" +import { addOrderTransactionStep } from "../../order" +import { refundPaymentsStep } from "../steps/refund-payments" + +type RefundPaymentsInput = { + payment_id: string + amount: BigNumberInput + created_by?: string +} + +/** + * This step validates that the refund is valid for the payment + */ +export const validatePaymentsRefundStep = createStep( + "validate-payments-refund-step", + async function ({ + payments, + input, + }: { + payments: PaymentDTO[] + input: RefundPaymentsInput[] + }) { + const paymentIdAmountMap = new Map( + input.map(({ payment_id, amount }) => [payment_id, amount]) + ) + + for (const payment of payments) { + const capturedAmount = (payment.captures || []).reduce( + (acc, capture) => MathBN.sum(acc, capture.amount), + MathBN.convert(0) + ) + + const refundedAmount = (payment.refunds || []).reduce( + (acc, capture) => MathBN.sum(acc, capture.amount), + MathBN.convert(0) + ) + + const refundableAmount = MathBN.sub(capturedAmount, refundedAmount) + const amountToRefund = paymentIdAmountMap.get(payment.id)! + + if (MathBN.gt(amountToRefund, refundableAmount)) { + throw new MedusaError( + MedusaError.Types.INVALID_DATA, + `Payment with id ${payment.id} is trying to refund amount greater than the refundable amount` + ) + } + } + } +) + +export const refundPaymentsWorkflowId = "refund-payments-workflow" +/** + * This workflow refunds a payment. + */ +export const refundPaymentsWorkflow = createWorkflow( + refundPaymentsWorkflowId, + (input: WorkflowData) => { + const paymentIds = transform({ input }, ({ input }) => + input.map((paymentInput) => paymentInput.payment_id) + ) + + const paymentsQuery = useQueryGraphStep({ + entity: "payments", + fields: [ + "id", + "currency_code", + "refunds.id", + "refunds.amount", + "captures.id", + "captures.amount", + "payment_collection.order.id", + "payment_collection.order.currency_code", + ], + filters: { id: paymentIds }, + options: { throwIfKeyNotFound: true }, + }).config({ name: "get-cart" }) + + const payments = transform( + { paymentsQuery }, + ({ paymentsQuery }) => paymentsQuery.data + ) + + validatePaymentsRefundStep({ payments, input }) + + const refundedPayments = refundPaymentsStep(input) + + const orderTransactionData = transform( + { payments, input }, + ({ payments, input }) => { + const paymentsMap: Record< + string, + PaymentDTO & { + payment_collection: { order: { id: string; currency_code: string } } + } + > = {} + + for (const payment of payments) { + paymentsMap[payment.id] = payment + } + + return input.map((paymentInput) => { + const payment = paymentsMap[paymentInput.payment_id]! + const order = payment.payment_collection.order + + return { + order_id: order.id, + amount: MathBN.mult(paymentInput.amount, -1), + currency_code: payment.currency_code, + reference_id: payment.id, + reference: "refund", + } + }) + } + ) + + addOrderTransactionStep(orderTransactionData) + + return new WorkflowResponse(refundedPayments) + } +) diff --git a/packages/core/types/src/http/order/common.ts b/packages/core/types/src/http/order/common.ts index bd44b16b8d8dd..d2f42737b1261 100644 --- a/packages/core/types/src/http/order/common.ts +++ b/packages/core/types/src/http/order/common.ts @@ -773,6 +773,10 @@ export interface BaseOrder { * The order's display ID. */ display_id?: number + /** + * The order's status. + */ + status: string /** * The order's shipping address. */ diff --git a/packages/core/types/src/order/common.ts b/packages/core/types/src/order/common.ts index 4d0403b751a9d..655bb2a0c7d9e 100644 --- a/packages/core/types/src/order/common.ts +++ b/packages/core/types/src/order/common.ts @@ -127,6 +127,18 @@ export type OrderSummaryDTO = { * @ignore */ raw_pending_difference: BigNumberRawValue + + /** + * The sum difference of all actions + */ + difference_sum: BigNumberValue + + /** + * The raw sum difference of all actions + * + * @ignore + */ + raw_difference_sum: BigNumberRawValue } /** diff --git a/packages/core/types/src/order/mutations.ts b/packages/core/types/src/order/mutations.ts index f8c6b6bd2ab90..7e9ef63d9c41e 100644 --- a/packages/core/types/src/order/mutations.ts +++ b/packages/core/types/src/order/mutations.ts @@ -18,6 +18,7 @@ type OrderChangeType = | "edit" | "transfer" | "update_order" + | "credit_line" /** ADDRESS START */ /** diff --git a/packages/core/types/src/payment/mutations.ts b/packages/core/types/src/payment/mutations.ts index 74fe1e799e3d9..b041e61d463d4 100644 --- a/packages/core/types/src/payment/mutations.ts +++ b/packages/core/types/src/payment/mutations.ts @@ -1,4 +1,5 @@ import { BigNumberInput } from "../totals" +import { PaymentCollectionStatus } from "./common" import { PaymentProviderContext } from "./provider" /** @@ -77,10 +78,15 @@ export interface PaymentCollectionUpdatableFields { region_id?: string /** - * {The ISO 3 character currency code of the payment collection. + * The ISO 3 character currency code of the payment collection. */ currency_code?: string + /** + * The status of the payment collection + */ + status?: PaymentCollectionStatus + /** * The amount of the payment collection. */ diff --git a/packages/core/utils/src/order/order-change.ts b/packages/core/utils/src/order/order-change.ts index 87ab70779959f..c720a3a2dc978 100644 --- a/packages/core/utils/src/order/order-change.ts +++ b/packages/core/utils/src/order/order-change.ts @@ -27,4 +27,5 @@ export enum OrderChangeType { EXCHANGE = "exchange", CLAIM = "claim", EDIT = "edit", + CREDIT_LINE = "credit_line", } diff --git a/packages/medusa/src/api/admin/orders/query-config.ts b/packages/medusa/src/api/admin/orders/query-config.ts index eb6efcd2323cc..2eb3681360dd4 100644 --- a/packages/medusa/src/api/admin/orders/query-config.ts +++ b/packages/medusa/src/api/admin/orders/query-config.ts @@ -46,6 +46,7 @@ export const defaultAdminRetrieveOrderFields = [ "*payment_collections", "*payment_collections.payments", "*payment_collections.payments.refunds", + "*payment_collections.payments.captures", ] export const defaultAdminRetrieveOrderChangesFields = [ diff --git a/packages/modules/order/src/services/__tests__/util/actions/credit-line-add.spec.ts b/packages/modules/order/src/services/__tests__/util/actions/credit-line-add.spec.ts index c1cb1854e2f05..88ed04791b993 100644 --- a/packages/modules/order/src/services/__tests__/util/actions/credit-line-add.spec.ts +++ b/packages/modules/order/src/services/__tests__/util/actions/credit-line-add.spec.ts @@ -51,22 +51,43 @@ describe("Action: Credit Line Add", function () { "credit_line_total": 0 } - Upon adding a credit line, the order total and the pending difference will increase making it possible for the merchant - to request the customer for a payment for an arbitrary reason, or prepare the order balance sheet to then allow - the merchant to provide a refund. + Upon adding a credit line, the current order total will decrease with the difference_sum going in + the negatives making it possible for the merchant to balance the order to then enable a refund. { "transaction_total": 0, "original_order_total": 30, "current_order_total": 60, - "pending_difference": 60, - "difference_sum": 30, + "pending_difference": 0, + "difference_sum": -30, "paid_total": 0, "refunded_total": 0, "credit_line_total": 30 } */ it("should add credit lines", function () { + const changesWithoutActions = calculateOrderChange({ + order: originalOrder, + actions: [], + options: { addActionReferenceToObject: true }, + }) + + const changesWithoutActionsJSON = JSON.parse( + JSON.stringify(changesWithoutActions.summary) + ) + + expect(changesWithoutActionsJSON).toEqual({ + transaction_total: 0, + original_order_total: 30, + current_order_total: 30, + pending_difference: 30, + difference_sum: 0, + paid_total: 0, + refunded_total: 0, + credit_line_total: 0, + accounting_total: 30, + }) + const actions = [ { action: ChangeActionType.CREDIT_LINE_ADD, @@ -87,12 +108,13 @@ describe("Action: Credit Line Add", function () { expect(sumToJSON).toEqual({ transaction_total: 0, original_order_total: 30, - current_order_total: 60, - pending_difference: 60, - difference_sum: 30, + current_order_total: 0, + pending_difference: 0, + difference_sum: 0, paid_total: 0, refunded_total: 0, credit_line_total: 30, + accounting_total: 0, }) originalOrder.credit_lines.push({ @@ -123,12 +145,13 @@ describe("Action: Credit Line Add", function () { expect(sumToJSONSecond).toEqual({ transaction_total: 0, original_order_total: 30, - current_order_total: 70, - pending_difference: 70, - difference_sum: 30, + current_order_total: -10, + pending_difference: -10, + difference_sum: 0, paid_total: 0, refunded_total: 0, credit_line_total: 40, + accounting_total: -10, }) }) }) diff --git a/packages/modules/order/src/services/__tests__/util/actions/exchanges.ts b/packages/modules/order/src/services/__tests__/util/actions/exchanges.ts index 09739ef4ada9a..ec1c17e519860 100644 --- a/packages/modules/order/src/services/__tests__/util/actions/exchanges.ts +++ b/packages/modules/order/src/services/__tests__/util/actions/exchanges.ts @@ -123,6 +123,7 @@ describe("Order Exchange - Actions", function () { paid_total: 0, refunded_total: 0, credit_line_total: 0, + accounting_total: 312.5, }) const toJson = JSON.parse(JSON.stringify(changes.order.items)) diff --git a/packages/modules/order/src/services/order-module-service.ts b/packages/modules/order/src/services/order-module-service.ts index edb0c5a02bb35..e27a20fdb6f4d 100644 --- a/packages/modules/order/src/services/order-module-service.ts +++ b/packages/modules/order/src/services/order-module-service.ts @@ -3059,6 +3059,7 @@ export default class OrderModuleService< transformPropertiesToBigNumber(trxs) const op = isRemoved ? MathBN.sub : MathBN.add + for (const trx of trxs) { if (MathBN.gt(trx.amount, 0)) { summary.totals.paid_total = new BigNumber( diff --git a/packages/modules/order/src/types/utils/index.ts b/packages/modules/order/src/types/utils/index.ts index 2299eff8e91f9..68e04d793c6a3 100644 --- a/packages/modules/order/src/types/utils/index.ts +++ b/packages/modules/order/src/types/utils/index.ts @@ -84,6 +84,7 @@ export interface OrderSummaryCalculated { paid_total: BigNumberInput refunded_total: BigNumberInput credit_line_total: BigNumberInput + accounting_total: BigNumberInput } export interface OrderTransaction { diff --git a/packages/modules/order/src/utils/actions/credit-line-add.ts b/packages/modules/order/src/utils/actions/credit-line-add.ts index 27d6f33c4ea70..6f087c0ef407e 100644 --- a/packages/modules/order/src/utils/actions/credit-line-add.ts +++ b/packages/modules/order/src/utils/actions/credit-line-add.ts @@ -11,7 +11,9 @@ OrderChangeProcessing.registerActionType(ChangeActionType.CREDIT_LINE_ADD, { existing = { id: action.reference_id!, order_id: currentOrder.id, - amount: action.amount as number, + amount: action.amount!, + reference: action.reference, + reference_id: action.reference_id, } creditLines.push(existing) diff --git a/packages/modules/order/src/utils/calculate-order-change.ts b/packages/modules/order/src/utils/calculate-order-change.ts index 69edd698b78e5..6250a96dec385 100644 --- a/packages/modules/order/src/utils/calculate-order-change.ts +++ b/packages/modules/order/src/utils/calculate-order-change.ts @@ -1,6 +1,7 @@ import { BigNumberInput, OrderSummaryDTO } from "@medusajs/framework/types" import { BigNumber, + ChangeActionType, MathBN, isPresent, transformPropertiesToBigNumber, @@ -63,8 +64,6 @@ export class OrderChangeProcessing { MathBN.convert(0) ) - const currentOrderTotal = MathBN.add(this.order.total ?? 0, creditLineTotal) - for (const tr of transactions) { if (MathBN.lt(tr.amount, 0)) { refunded = MathBN.add(refunded, MathBN.abs(tr.amount)) @@ -79,12 +78,13 @@ export class OrderChangeProcessing { this.summary = { pending_difference: 0, difference_sum: 0, - current_order_total: currentOrderTotal, + current_order_total: this.order.total ?? 0, original_order_total: this.order.total ?? 0, transaction_total: transactionTotal, paid_total: paid, refunded_total: refunded, credit_line_total: creditLineTotal, + accounting_total: MathBN.sub(this.order.total ?? 0, creditLineTotal), } } @@ -102,6 +102,11 @@ export class OrderChangeProcessing { } public processActions() { + let creditLineTotal = (this.order.credit_lines || []).reduce( + (acc, creditLine) => MathBN.add(acc, creditLine.amount), + MathBN.convert(0) + ) + for (const action of this.actions) { this.processAction_(action) } @@ -128,30 +133,37 @@ export class OrderChangeProcessing { ) } - if (!this.isEventDone(action) && !action.change_id) { - summary.difference_sum = MathBN.add(summary.difference_sum, amount) - } - - const creditLineTotal = (this.order.credit_lines || []).reduce( - (acc, creditLine) => MathBN.add(acc, creditLine.amount), - MathBN.convert(0) - ) + if (action.action === ChangeActionType.CREDIT_LINE_ADD) { + creditLineTotal = MathBN.add(creditLineTotal, amount) + } else { + if (!this.isEventDone(action) && !action.change_id) { + summary.difference_sum = MathBN.add(summary.difference_sum, amount) + } - summary.credit_line_total = creditLineTotal - summary.current_order_total = MathBN.add( - summary.current_order_total, - amount - ) + summary.current_order_total = MathBN.add( + summary.current_order_total, + amount + ) + } } const groupSum = MathBN.add(...Object.values(this.groupTotal)) - summary.difference_sum = MathBN.add(summary.difference_sum, groupSum) + summary.credit_line_total = creditLineTotal + summary.accounting_total = MathBN.sub( + summary.current_order_total, + creditLineTotal + ) summary.transaction_total = MathBN.sum( ...this.transactions.map((tr) => tr.amount) ) + summary.current_order_total = MathBN.sub( + summary.current_order_total, + creditLineTotal + ) + summary.pending_difference = MathBN.sub( summary.current_order_total, summary.transaction_total @@ -216,6 +228,7 @@ export class OrderChangeProcessing { paid_total: new BigNumber(summary.paid_total), refunded_total: new BigNumber(summary.refunded_total), credit_line_total: new BigNumber(summary.credit_line_total), + accounting_total: new BigNumber(summary.accounting_total), } as unknown as OrderSummaryDTO return orderSummary