From 08637b27fde726d35ba21f869dfc2dc2f67ed809 Mon Sep 17 00:00:00 2001 From: Dawid Tarasiuk Date: Fri, 20 Aug 2021 16:36:05 +0200 Subject: [PATCH] Introduce fulfillment creation API (#1241) * Display warehouse name for each fulfillment (#1259) * Hide no-stocks columns in fulfillment view (#1260) * Hide no-stocks columns in fulfillment view * Update tests * Refactor * Update tests * Add fulfillment settings card (#1242) * Add fulfillment setting card * Make fulfillment approvement naming consistent * Fix mutation bug * Update types * Trigger CI * Handle fulfillment acceptance on order details page (#1255) * Handle fulfillment acceptance on order details page * Make fulfillment approvement naming consistent * Update fulfillment schema and its usage * Render history events regarding waiting fulfillments (#1265) * Add awaiting for approval fulfillment order event * Fix warehouse name * Change fulfillment quantity calculation (#1267) * Change fulfillment quantity calculation * Fix warehouse name * Update messages * Trigger CI * Refactor * Fix refactor * Fix fulfillment for no variant * Allow creating fulfillments waiting for acceptance (#1248) * Fix fulfillment page style and typescript classname types perfomance issue * Allow creating fulfillments waiting for acceptance * Make fulfillment approvement naming consistent * Update schema * Add tooltip to fulfillment savebar * Update unpaid fulfillment creation restriction * Update fulfillment cration restriction * Update test snapshots * Add possibility to cancel "waiting" fulfillments (#1288) * Allow to cancel waiting fulfillments * Add delete button to fulfillment card * Update test snapshots * Handle waiting fulfillments on refund page (#1290) * Handle waiting fulfillments on refund page * Trigger CI * Trigger CI * Calculate quantity to refund on quantityToFulfill * Update changelog * Update snapshots Co-authored-by: Jakub Majorek --- CHANGELOG.md | 2 + locale/defaultMessages.json | 170 +- schema.graphql | 16 + .../SaveButtonBar/ButtonTooltipDecorator.tsx | 23 + src/components/StatusLabel/StatusLabel.tsx | 3 +- src/fragments/orders.ts | 9 + src/fragments/types/FulfillmentFragment.ts | 1 + src/fragments/types/OrderDetailsFragment.ts | 4 +- src/fragments/types/OrderLineFragment.ts | 1 + .../types/ShopOrderSettingsFragment.ts | 14 + src/intl.ts | 8 + .../OrderDetailsPage/OrderDetailsPage.tsx | 24 +- .../OrderFulfillPage/OrderFulfillPage.tsx | 234 +- .../components/OrderFulfillPage/fixtures.ts | 4 + .../components/OrderFulfillPage/messages.ts | 48 + .../ActionButtons.tsx | 50 +- .../ExtraInfoLines.tsx | 24 +- .../OrderFulfilledProductsCard.tsx | 71 +- .../OrderFulfilledProductsCard/messages.ts | 31 + .../OrderFulfillmentApproveDialog.tsx | 92 + .../OrderFulfillmentApproveDialog/index.ts | 2 + .../OrderFulfillmentApproveDialog/messages.ts | 16 + .../OrderFulfillmentDialog.tsx | 247 -- .../OrderFulfillmentDialog/index.ts | 2 - .../OrderFulfillmentSettings.tsx | 80 + .../OrderFulfillmentSettings/index.ts | 2 + .../components/OrderHistory/OrderHistory.tsx | 5 + .../OrderProductsTableRow.tsx | 6 +- .../OrderRefundFulfilledProducts.tsx | 12 +- .../OrderRefundFulfilledProducts/messages.ts | 31 + .../OrderRefundPage/OrderRefundPage.tsx | 5 +- .../components/OrderRefundPage/fixtures.ts | 4 +- .../components/OrderRefundPage/form.tsx | 4 +- .../OrderRefundUnfulfilledProducts.tsx | 2 +- .../OrderReturnRefundItemsCard/CardTitle.tsx | 36 +- .../OrderSettingsPage.stories.tsx | 15 +- .../OrderSettingsPage/OrderSettingsPage.tsx | 26 +- .../components/OrderSettingsPage/form.tsx | 17 +- .../OrderUnfulfilledProductsCard.tsx | 35 +- src/orders/containers/OrderOperations.tsx | 192 +- src/orders/fixtures.ts | 40 +- src/orders/mutations.ts | 44 +- src/orders/queries.ts | 31 +- src/orders/types/FulfillOrder.ts | 4 +- src/orders/types/OrderCancel.ts | 4 +- src/orders/types/OrderCapture.ts | 4 +- src/orders/types/OrderConfirm.ts | 4 +- src/orders/types/OrderDetails.ts | 6 +- src/orders/types/OrderDiscountAdd.ts | 4 +- src/orders/types/OrderDiscountDelete.ts | 4 +- src/orders/types/OrderDiscountUpdate.ts | 4 +- src/orders/types/OrderDraftCancel.ts | 4 +- src/orders/types/OrderDraftFinalize.ts | 4 +- src/orders/types/OrderDraftUpdate.ts | 4 +- src/orders/types/OrderFulfillData.ts | 3 + src/orders/types/OrderFulfillSettings.ts | 18 + src/orders/types/OrderFulfillmentApprove.ts | 528 +++++ src/orders/types/OrderFulfillmentCancel.ts | 4 +- .../types/OrderFulfillmentRefundProducts.ts | 5 +- .../types/OrderFulfillmentUpdateTracking.ts | 4 +- src/orders/types/OrderLineDelete.ts | 4 +- src/orders/types/OrderLineDiscountRemove.ts | 4 +- src/orders/types/OrderLineDiscountUpdate.ts | 4 +- src/orders/types/OrderLineUpdate.ts | 4 +- src/orders/types/OrderLinesAdd.ts | 4 +- src/orders/types/OrderMarkAsPaid.ts | 4 +- src/orders/types/OrderRefund.ts | 4 +- src/orders/types/OrderRefundData.ts | 2 +- src/orders/types/OrderSettings.ts | 7 + src/orders/types/OrderSettingsUpdate.ts | 24 +- src/orders/types/OrderShippingMethodUpdate.ts | 4 +- src/orders/types/OrderUpdate.ts | 4 +- src/orders/types/OrderVoid.ts | 4 +- src/orders/urls.ts | 1 + src/orders/utils/data.test.ts | 96 +- src/orders/utils/data.ts | 55 + .../OrderDetails/OrderDetailsMessages.tsx | 15 + .../OrderDetails/OrderNormalDetails/index.tsx | 36 + .../OrderUnconfirmedDetails/index.tsx | 36 + src/orders/views/OrderDetails/index.tsx | 6 + .../views/OrderFulfill/OrderFulfill.tsx | 29 +- src/orders/views/OrderSettings.tsx | 17 +- .../__snapshots__/Stories.test.ts.snap | 1992 ++++++++++------- src/storybook/config.js | 1 - .../stories/orders/OrderDetailsPage.tsx | 7 +- .../stories/orders/OrderFulfillmentDialog.tsx | 44 - src/types/globalTypes.ts | 5 + 87 files changed, 3193 insertions(+), 1511 deletions(-) create mode 100644 src/components/SaveButtonBar/ButtonTooltipDecorator.tsx create mode 100644 src/fragments/types/ShopOrderSettingsFragment.ts create mode 100644 src/orders/components/OrderFulfillPage/messages.ts create mode 100644 src/orders/components/OrderFulfilledProductsCard/messages.ts create mode 100644 src/orders/components/OrderFulfillmentApproveDialog/OrderFulfillmentApproveDialog.tsx create mode 100644 src/orders/components/OrderFulfillmentApproveDialog/index.ts create mode 100644 src/orders/components/OrderFulfillmentApproveDialog/messages.ts delete mode 100644 src/orders/components/OrderFulfillmentDialog/OrderFulfillmentDialog.tsx delete mode 100644 src/orders/components/OrderFulfillmentDialog/index.ts create mode 100644 src/orders/components/OrderFulfillmentSettings/OrderFulfillmentSettings.tsx create mode 100644 src/orders/components/OrderFulfillmentSettings/index.ts create mode 100644 src/orders/components/OrderRefundFulfilledProducts/messages.ts create mode 100644 src/orders/types/OrderFulfillSettings.ts create mode 100644 src/orders/types/OrderFulfillmentApprove.ts delete mode 100644 src/storybook/stories/orders/OrderFulfillmentDialog.tsx diff --git a/CHANGELOG.md b/CHANGELOG.md index b51f868c4..439ecd6cb 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -76,6 +76,8 @@ All notable, unreleased changes to this project will be documented in this file. - Fixed navigation menu items reordering issue - #1239 by @kamilpastuszka - Fixed issue with modals containing invalid, redundant scrolls #1240 by @kamilpastuszka - Add text attribute for product and page translations - #1276 by @kamilpastuszka +- Add app dashboard extensions - #1292 by @jwm0 +- Introduce fulfillment creation - #1241 by @orzechdev # 2.11.1 diff --git a/locale/defaultMessages.json b/locale/defaultMessages.json index c3afa5cd6..9ce957542 100644 --- a/locale/defaultMessages.json +++ b/locale/defaultMessages.json @@ -536,6 +536,10 @@ "context": "button", "string": "Accept" }, + "src_dot_approve": { + "context": "button", + "string": "Approve" + }, "src_dot_apps": { "context": "apps section name", "string": "Apps" @@ -1302,6 +1306,10 @@ "context": "order status", "string": "Cancelled" }, + "src_dot_cannotFullfillUnpaidOrder": { + "context": "disabled option description", + "string": "Can’t fulfill until payment is captured" + }, "src_dot_catalog": { "string": "Catalog" }, @@ -3956,68 +3964,66 @@ "context": "button", "string": "Finalize" }, - "src_dot_orders_dot_components_dot_OrderFulfillPage_dot_1608534452": { - "context": "page header", - "string": "Order no. {orderNumber} - Add Fulfillment" - }, - "src_dot_orders_dot_components_dot_OrderFulfillPage_dot_2094985970": { - "context": "quantity of fulfilled products", - "string": "Quantity to fulfill" - }, - "src_dot_orders_dot_components_dot_OrderFulfillPage_dot_2095687440": { - "context": "fulfill order, button", - "string": "Fulfill" - }, - "src_dot_orders_dot_components_dot_OrderFulfillPage_dot_2588284040": { - "context": "no variant stock in warehouse", - "string": "No Stock" - }, - "src_dot_orders_dot_components_dot_OrderFulfillPage_dot_3244948255": { - "context": "header", - "string": "Items ready to ship" - }, - "src_dot_orders_dot_components_dot_OrderFulfillPage_dot_3620521256": { + "src_dot_orders_dot_components_dot_OrderFulfillPage_dot_headerOrder": { "context": "page header", "string": "Order" }, - "src_dot_orders_dot_components_dot_OrderFulfillPage_dot_4046223826": { - "string": "Product name" - }, - "src_dot_orders_dot_components_dot_OrderFulfillPage_dot_4251997263": { - "context": "checkbox", - "string": "Send shipment details to customer" - }, - "src_dot_orders_dot_components_dot_OrderFulfillPage_dot_580490159": { - "context": "page header with order number", + "src_dot_orders_dot_components_dot_OrderFulfillPage_dot_headerOrderNumber": { + "context": "page header", "string": "Order #{orderNumber}" }, - "src_dot_orders_dot_components_dot_OrderFulfillPage_dot_693960049": { + "src_dot_orders_dot_components_dot_OrderFulfillPage_dot_headerOrderNumberAddFulfillment": { + "context": "page header", + "string": "Order no. {orderNumber} - Add Fulfillment" + }, + "src_dot_orders_dot_components_dot_OrderFulfillPage_dot_itemsReadyToShip": { + "context": "header", + "string": "Items ready to ship" + }, + "src_dot_orders_dot_components_dot_OrderFulfillPage_dot_noStock": { + "context": "no variant stock in warehouse", + "string": "No Stock" + }, + "src_dot_orders_dot_components_dot_OrderFulfillPage_dot_productName": { + "context": "name", + "string": "Product name" + }, + "src_dot_orders_dot_components_dot_OrderFulfillPage_dot_quantityToFulfill": { + "context": "quantity of fulfilled products", + "string": "Quantity to fulfill" + }, + "src_dot_orders_dot_components_dot_OrderFulfillPage_dot_sentShipmentDetails": { + "context": "checkbox label", + "string": "Send shipment details to customer" + }, + "src_dot_orders_dot_components_dot_OrderFulfillPage_dot_sku": { "context": "product's sku", "string": "SKU" }, - "src_dot_orders_dot_components_dot_OrderFulfilledProductsCard_dot_1119771899": { + "src_dot_orders_dot_components_dot_OrderFulfillPage_dot_submitFulfillment": { + "context": "fulfill order, button", + "string": "Fulfill" + }, + "src_dot_orders_dot_components_dot_OrderFulfillPage_dot_submitPrepareFulfillment": { + "context": "prepare order fulfillment, button", + "string": "Prepare fulfillment" + }, + "src_dot_orders_dot_components_dot_OrderFulfilledProductsCard_dot_addTracking": { "context": "add tracking button", "string": "Add tracking" }, - "src_dot_orders_dot_components_dot_OrderFulfilledProductsCard_dot_2211099657": { + "src_dot_orders_dot_components_dot_OrderFulfilledProductsCard_dot_editTracking": { "context": "edit tracking button", "string": "Edit tracking" }, - "src_dot_orders_dot_components_dot_OrderFulfilledProductsCard_dot_2845258362": { - "context": "refund button", - "string": "Refund" - }, - "src_dot_orders_dot_components_dot_OrderFulfilledProductsCard_dot_3254150098": { - "string": "Tracking Number: {trackingNumber}" - }, - "src_dot_orders_dot_components_dot_OrderFulfilledProductsCard_dot_732594284": { - "context": "button", - "string": "Cancel Fulfillment" - }, "src_dot_orders_dot_components_dot_OrderFulfilledProductsCard_dot_fulfilled": { "context": "fulfillment group", "string": "Fulfilled from: " }, + "src_dot_orders_dot_components_dot_OrderFulfilledProductsCard_dot_refund": { + "context": "refund button", + "string": "Refund" + }, "src_dot_orders_dot_components_dot_OrderFulfilledProductsCard_dot_restocked": { "context": "restocked group", "string": "Restocked from: " @@ -4026,6 +4032,18 @@ "context": "tracking number", "string": "Tracking Number: {trackingNumber}" }, + "src_dot_orders_dot_components_dot_OrderFulfillmentApproveDialog_dot_description": { + "context": "dialog description", + "string": "Are you sure you want to approve this fullfillment?" + }, + "src_dot_orders_dot_components_dot_OrderFulfillmentApproveDialog_dot_notifyCustomer": { + "context": "checkbox label, fulfillment approval", + "string": "Send shipment details to customer" + }, + "src_dot_orders_dot_components_dot_OrderFulfillmentApproveDialog_dot_title": { + "context": "dialog header", + "string": "Approve this fulfillment" + }, "src_dot_orders_dot_components_dot_OrderFulfillmentCancelDialog_dot_1097287358": { "string": "Are you sure you want to cancel fulfillment? Canceling a fulfillment will restock products at a selected warehouse." }, @@ -4037,24 +4055,25 @@ "context": "dialog header", "string": "Cancel Fulfillment" }, - "src_dot_orders_dot_components_dot_OrderFulfillmentDialog_dot_2796503714": { - "context": "quantity of fulfilled products", - "string": "Quantity" + "src_dot_orders_dot_components_dot_OrderFulfillmentSettings_dot_1154699654": { + "context": "checkbox label", + "string": "Allow fulfillment without payment" }, - "src_dot_orders_dot_components_dot_OrderFulfillmentDialog_dot_3123761129": { - "context": "dialog header", - "string": "Fulfill Products" + "src_dot_orders_dot_components_dot_OrderFulfillmentSettings_dot_2478368540": { + "context": "checkbox label description", + "string": "All fulfillments will be automatically approved" }, - "src_dot_orders_dot_components_dot_OrderFulfillmentDialog_dot_3252172269": { - "context": "fulfillment group", - "string": "Tracking number" + "src_dot_orders_dot_components_dot_OrderFulfillmentSettings_dot_3336812159": { + "context": "checkbox label", + "string": "Automatically approve all fulfillments" }, - "src_dot_orders_dot_components_dot_OrderFulfillmentDialog_dot_4046223826": { - "string": "Product name" + "src_dot_orders_dot_components_dot_OrderFulfillmentSettings_dot_3666602886": { + "context": "checkbox label description", + "string": "You will be able to fulfill products without capturing payment for the order." }, - "src_dot_orders_dot_components_dot_OrderFulfillmentDialog_dot_693960049": { - "context": "product's sku", - "string": "SKU" + "src_dot_orders_dot_components_dot_OrderFulfillmentSettings_dot_4200951094": { + "context": "section header", + "string": "Fulfillment settings" }, "src_dot_orders_dot_components_dot_OrderFulfillmentTrackingDialog_dot_3252172269": { "string": "Tracking number" @@ -4163,6 +4182,10 @@ "context": "order history message", "string": "Products were added to an order" }, + "src_dot_orders_dot_components_dot_OrderHistory_dot_3854352507": { + "context": "order history message", + "string": "Fulfillment awaits approval" + }, "src_dot_orders_dot_components_dot_OrderHistory_dot_393045022": { "context": "order history message", "string": "Invoice no. {invoiceNumber} was updated" @@ -4441,10 +4464,6 @@ "context": "order line total price", "string": "Total" }, - "src_dot_orders_dot_components_dot_OrderRefundFulfilledProducts_dot_1097582574": { - "context": "section header returned", - "string": "Fulfillment returned" - }, "src_dot_orders_dot_components_dot_OrderRefundFulfilledProducts_dot_1134347598": { "context": "tabel column header", "string": "Price" @@ -4464,10 +4483,6 @@ "context": "button", "string": "Set maximal quantities" }, - "src_dot_orders_dot_components_dot_OrderRefundFulfilledProducts_dot_615325604": { - "context": "section header", - "string": "Fulfillment" - }, "src_dot_orders_dot_components_dot_OrderRefundFulfilledProducts_dot_878013594": { "context": "tabel column header", "string": "Total" @@ -4476,6 +4491,18 @@ "context": "error message", "string": "Improper value" }, + "src_dot_orders_dot_components_dot_OrderRefundFulfilledProducts_dot_fulfillment": { + "context": "section header", + "string": "Fulfillment" + }, + "src_dot_orders_dot_components_dot_OrderRefundFulfilledProducts_dot_fulfillmentReturned": { + "context": "section header returned", + "string": "Fulfillment returned" + }, + "src_dot_orders_dot_components_dot_OrderRefundFulfilledProducts_dot_fulfillmentWaitingForApproval": { + "context": "section header returned", + "string": "Fulfillment waiting for approval" + }, "src_dot_orders_dot_components_dot_OrderRefundPage_dot_194531545": { "context": "page header", "string": "Order no. {orderNumber} - Refund" @@ -4651,6 +4678,10 @@ "context": "section header", "string": "Fulfilled ({quantity})" }, + "src_dot_orders_dot_components_dot_OrderReturnPage_dot_OrderReturnRefundItemsCard_dot_fulfilledFrom": { + "context": "fulfilled fulfillment, section header", + "string": "Fulfilled from {warehouseName}" + }, "src_dot_orders_dot_components_dot_OrderReturnPage_dot_OrderReturnRefundItemsCard_dot_improperValue": { "context": "error message", "string": "Improper value" @@ -4687,6 +4718,10 @@ "context": "section header", "string": "Unfulfilled" }, + "src_dot_orders_dot_components_dot_OrderReturnPage_dot_OrderReturnRefundItemsCard_dot_waitingForApproval": { + "context": "unapproved fulfillment, section header", + "string": "Waiting for approval ({quantity})" + }, "src_dot_orders_dot_components_dot_OrderReturnPage_dot_appTitle": { "context": "page header with order number", "string": "Order #{orderNumber}" @@ -4758,6 +4793,9 @@ "src_dot_orders_dot_views_dot_OrderDetails_dot_3367579693": { "string": "Order successfully updated" }, + "src_dot_orders_dot_views_dot_OrderDetails_dot_3897044696": { + "string": "Fulfillment successfully approved" + }, "src_dot_orders_dot_views_dot_OrderDetails_dot_4085755992": { "string": "Invoice email sent" }, diff --git a/schema.graphql b/schema.graphql index 7a5a41d0f..e59070057 100644 --- a/schema.graphql +++ b/schema.graphql @@ -2144,6 +2144,13 @@ type Fulfillment implements Node & ObjectWithMetadata { warehouse: Warehouse } +type FulfillmentApprove { + fulfillment: Fulfillment + order: Order + orderErrors: [OrderError!]! @deprecated(reason: "Use errors field instead. This field will be removed in Saleor 4.0.") + errors: [OrderError!]! +} + type FulfillmentCancel { fulfillment: Fulfillment order: Order @@ -2184,6 +2191,7 @@ enum FulfillmentStatus { REPLACED REFUNDED_AND_RETURNED CANCELED + WAITING_FOR_APPROVAL } type FulfillmentUpdateTracking { @@ -3695,6 +3703,7 @@ type Mutation { orderConfirm(id: ID!): OrderConfirm orderFulfill(input: OrderFulfillInput!, order: ID): OrderFulfill orderFulfillmentCancel(id: ID!, input: FulfillmentCancelInput!): FulfillmentCancel + orderFulfillmentApprove(id: ID!, notifyCustomer: Boolean!): FulfillmentApprove orderFulfillmentUpdateTracking(id: ID!, input: FulfillmentUpdateTrackingInput!): FulfillmentUpdateTracking orderFulfillmentRefundProducts(input: OrderRefundProductsInput!, order: ID!): FulfillmentRefundProducts orderFulfillmentReturnProducts(input: OrderReturnProductsInput!, order: ID!): FulfillmentReturnProducts @@ -4038,6 +4047,7 @@ enum OrderErrorCode { CANNOT_DELETE CANNOT_DISCOUNT CANNOT_REFUND + CANNOT_FULFILL_UNPAID_ORDER CAPTURE_INACTIVE_PAYMENT NOT_EDITABLE FULFILL_ORDER_LINE @@ -4168,6 +4178,7 @@ enum OrderEventsEnum { FULFILLMENT_REFUNDED FULFILLMENT_RETURNED FULFILLMENT_REPLACED + FULFILLMENT_AWAITS_APPROVAL TRACKING_UPDATED NOTE_ADDED OTHER @@ -4226,6 +4237,7 @@ type OrderLine implements Node { translatedProductName: String! translatedVariantName: String! allocations: [Allocation!] + quantityToFulfill: Int! unitDiscountType: DiscountValueTypeEnum } @@ -6146,6 +6158,8 @@ type Shop { phonePrefixes: [String]! headerText: String includeTaxesInPrices: Boolean! + fulfillmentAutoApprove: Boolean! + fulfillmentAllowUnpaid: Boolean! displayGrossPrices: Boolean! chargeTaxesOnShipping: Boolean! trackInventoryByDefault: Boolean @@ -6204,6 +6218,8 @@ input ShopSettingsInput { trackInventoryByDefault: Boolean defaultWeightUnit: WeightUnitsEnum automaticFulfillmentDigitalProducts: Boolean + fulfillmentAutoApprove: Boolean + fulfillmentAllowUnpaid: Boolean defaultDigitalMaxDownloads: Int defaultDigitalUrlValidDays: Int defaultMailSenderName: String diff --git a/src/components/SaveButtonBar/ButtonTooltipDecorator.tsx b/src/components/SaveButtonBar/ButtonTooltipDecorator.tsx new file mode 100644 index 000000000..648213c3c --- /dev/null +++ b/src/components/SaveButtonBar/ButtonTooltipDecorator.tsx @@ -0,0 +1,23 @@ +import { Tooltip } from "@material-ui/core"; +import React from "react"; + +interface ButtonTooltipDecoratorProps { + tooltip?: string; +} + +export const ButtonTooltipDecorator: React.FC = ({ + tooltip, + children +}) => { + if (tooltip) { + return ( + + {children} + + ); + } + + return <>{children}; +}; +ButtonTooltipDecorator.displayName = "ButtonTooltipDecorator"; +export default ButtonTooltipDecorator; diff --git a/src/components/StatusLabel/StatusLabel.tsx b/src/components/StatusLabel/StatusLabel.tsx index a87d4845c..1c210d5f4 100644 --- a/src/components/StatusLabel/StatusLabel.tsx +++ b/src/components/StatusLabel/StatusLabel.tsx @@ -29,7 +29,8 @@ export const useStyles = makeStyles( textContainer: { marginLeft: theme.spacing(1), display: "flex", - flexDirection: "column" + flexDirection: "column", + width: "100%" }, dotVertical: { marginTop: theme.spacing(1) diff --git a/src/fragments/orders.ts b/src/fragments/orders.ts index 2fe90a0bf..b8ad4eb80 100644 --- a/src/fragments/orders.ts +++ b/src/fragments/orders.ts @@ -81,6 +81,7 @@ export const fragmentOrderLine = gql` productSku quantity quantityFulfilled + quantityToFulfill unitDiscount { amount currency @@ -200,6 +201,7 @@ export const fragmentOrderDetails = gql` ...OrderLineFragment } number + isPaid paymentStatus shippingAddress { ...AddressFragment @@ -280,3 +282,10 @@ export const fragmentOrderSettings = gql` automaticallyConfirmAllNewOrders } `; + +export const fragmentShopOrderSettings = gql` + fragment ShopOrderSettingsFragment on Shop { + fulfillmentAutoApprove + fulfillmentAllowUnpaid + } +`; diff --git a/src/fragments/types/FulfillmentFragment.ts b/src/fragments/types/FulfillmentFragment.ts index eed4213ee..327dc9533 100644 --- a/src/fragments/types/FulfillmentFragment.ts +++ b/src/fragments/types/FulfillmentFragment.ts @@ -72,6 +72,7 @@ export interface FulfillmentFragment_lines_orderLine { productSku: string; quantity: number; quantityFulfilled: number; + quantityToFulfill: number; unitDiscount: FulfillmentFragment_lines_orderLine_unitDiscount; unitDiscountValue: any; unitDiscountReason: string | null; diff --git a/src/fragments/types/OrderDetailsFragment.ts b/src/fragments/types/OrderDetailsFragment.ts index bd494d14a..354503995 100644 --- a/src/fragments/types/OrderDetailsFragment.ts +++ b/src/fragments/types/OrderDetailsFragment.ts @@ -216,6 +216,7 @@ export interface OrderDetailsFragment_fulfillments_lines_orderLine { productSku: string; quantity: number; quantityFulfilled: number; + quantityToFulfill: number; unitDiscount: OrderDetailsFragment_fulfillments_lines_orderLine_unitDiscount; unitDiscountValue: any; unitDiscountReason: string | null; @@ -311,6 +312,7 @@ export interface OrderDetailsFragment_lines { productSku: string; quantity: number; quantityFulfilled: number; + quantityToFulfill: number; unitDiscount: OrderDetailsFragment_lines_unitDiscount; unitDiscountValue: any; unitDiscountReason: string | null; @@ -483,6 +485,7 @@ export interface OrderDetailsFragment { fulfillments: (OrderDetailsFragment_fulfillments | null)[]; lines: (OrderDetailsFragment_lines | null)[]; number: string | null; + isPaid: boolean; paymentStatus: PaymentChargeStatusEnum; shippingAddress: OrderDetailsFragment_shippingAddress | null; shippingMethod: OrderDetailsFragment_shippingMethod | null; @@ -500,5 +503,4 @@ export interface OrderDetailsFragment { availableShippingMethods: (OrderDetailsFragment_availableShippingMethods | null)[] | null; invoices: (OrderDetailsFragment_invoices | null)[] | null; channel: OrderDetailsFragment_channel; - isPaid: boolean; } diff --git a/src/fragments/types/OrderLineFragment.ts b/src/fragments/types/OrderLineFragment.ts index 3f8f7991c..0d0ecb06e 100644 --- a/src/fragments/types/OrderLineFragment.ts +++ b/src/fragments/types/OrderLineFragment.ts @@ -72,6 +72,7 @@ export interface OrderLineFragment { productSku: string; quantity: number; quantityFulfilled: number; + quantityToFulfill: number; unitDiscount: OrderLineFragment_unitDiscount; unitDiscountValue: any; unitDiscountReason: string | null; diff --git a/src/fragments/types/ShopOrderSettingsFragment.ts b/src/fragments/types/ShopOrderSettingsFragment.ts new file mode 100644 index 000000000..dcb75a453 --- /dev/null +++ b/src/fragments/types/ShopOrderSettingsFragment.ts @@ -0,0 +1,14 @@ +/* tslint:disable */ +/* eslint-disable */ +// @generated +// This file was automatically generated and should not be edited. + +// ==================================================== +// GraphQL fragment: ShopOrderSettingsFragment +// ==================================================== + +export interface ShopOrderSettingsFragment { + __typename: "Shop"; + fulfillmentAutoApprove: boolean; + fulfillmentAllowUnpaid: boolean; +} diff --git a/src/intl.ts b/src/intl.ts index 4693407aa..8f43d2e6b 100644 --- a/src/intl.ts +++ b/src/intl.ts @@ -121,6 +121,10 @@ export const commonMessages = defineMessages({ time: { defaultMessage: "Time", description: "independent of any particular day, eg. 11:35" + }, + cannotFullfillUnpaidOrder: { + defaultMessage: "Can’t fulfill until payment is captured", + description: "disabled option description" } }); @@ -139,6 +143,10 @@ export const buttonMessages = defineMessages({ defaultMessage: "Accept", description: "button" }, + approve: { + defaultMessage: "Approve", + description: "button" + }, back: { defaultMessage: "Back", description: "button" diff --git a/src/orders/components/OrderDetailsPage/OrderDetailsPage.tsx b/src/orders/components/OrderDetailsPage/OrderDetailsPage.tsx index 2dfc0afe0..a8eb8e53e 100644 --- a/src/orders/components/OrderDetailsPage/OrderDetailsPage.tsx +++ b/src/orders/components/OrderDetailsPage/OrderDetailsPage.tsx @@ -23,7 +23,10 @@ import { defineMessages, useIntl } from "react-intl"; import { maybe } from "../../../misc"; import { OrderStatus } from "../../../types/globalTypes"; -import { OrderDetails_order } from "../../types/OrderDetails"; +import { + OrderDetails_order, + OrderDetails_shop +} from "../../types/OrderDetails"; import OrderCustomer from "../OrderCustomer"; import OrderCustomerNote from "../OrderCustomerNote"; import OrderDraftDetails from "../OrderDraftDetails/OrderDraftDetails"; @@ -54,6 +57,7 @@ const useStyles = makeStyles( export interface OrderDetailsPageProps extends UserPermissionProps { order: OrderDetails_order; + shop: OrderDetails_shop; shippingMethods?: Array<{ id: string; name: string; @@ -69,6 +73,7 @@ export interface OrderDetailsPageProps extends UserPermissionProps { onShippingMethodEdit?: () => void; onBack(); onBillingAddressEdit(); + onFulfillmentApprove(id: string); onFulfillmentCancel(id: string); onFulfillmentTrackingNumberUpdate(id: string); onOrderFulfill(); @@ -107,10 +112,12 @@ const OrderDetailsPage: React.FC = props => { const { disabled, order, + shop, saveButtonBarState, userPermissions, onBack, onBillingAddressEdit, + onFulfillmentApprove, onFulfillmentCancel, onFulfillmentTrackingNumberUpdate, onNoteAdd, @@ -146,8 +153,12 @@ const OrderDetailsPage: React.FC = props => { const canCancel = order?.status !== OrderStatus.CANCELED; const canEditAddresses = order?.status !== OrderStatus.CANCELED; const canFulfill = order?.status !== OrderStatus.CANCELED; + const notAllowedToFulfillUnpaid = + shop?.fulfillmentAutoApprove && + !shop?.fulfillmentAllowUnpaid && + !order?.isPaid; const unfulfilled = (order?.lines || []).filter( - line => line.quantityFulfilled < line.quantity + line => line.quantityToFulfill > 0 ); const handleSubmit = async (data: MetadataFormData) => { @@ -229,7 +240,8 @@ const OrderDetailsPage: React.FC = props => {
{!isOrderUnconfirmed ? ( @@ -249,7 +261,8 @@ const OrderDetailsPage: React.FC = props => { onFulfillmentCancel(fulfillment.id) } @@ -257,6 +270,9 @@ const OrderDetailsPage: React.FC = props => { onFulfillmentTrackingNumberUpdate(fulfillment.id) } onRefund={onPaymentRefund} + onOrderFulfillmentApprove={() => + onFulfillmentApprove(fulfillment.id) + } /> ))} diff --git a/src/orders/components/OrderFulfillPage/OrderFulfillPage.tsx b/src/orders/components/OrderFulfillPage/OrderFulfillPage.tsx index 007bc85a7..ab9aebada 100644 --- a/src/orders/components/OrderFulfillPage/OrderFulfillPage.tsx +++ b/src/orders/components/OrderFulfillPage/OrderFulfillPage.tsx @@ -9,6 +9,7 @@ import { Typography } from "@material-ui/core"; import { CSSProperties } from "@material-ui/styles"; +import { drawerWidthExpanded } from "@saleor/components/AppLayout/consts"; import CardTitle from "@saleor/components/CardTitle"; import { ConfirmButtonTransitionState } from "@saleor/components/ConfirmButton"; import Container from "@saleor/components/Container"; @@ -19,8 +20,10 @@ import ResponsiveTable from "@saleor/components/ResponsiveTable"; import Savebar from "@saleor/components/Savebar"; import Skeleton from "@saleor/components/Skeleton"; import TableCellAvatar from "@saleor/components/TableCellAvatar"; +import { ShopOrderSettingsFragment } from "@saleor/fragments/types/ShopOrderSettingsFragment"; import { WarehouseFragment } from "@saleor/fragments/types/WarehouseFragment"; import useFormset, { FormsetData } from "@saleor/hooks/useFormset"; +import { commonMessages } from "@saleor/intl"; import { Backlink } from "@saleor/macaw-ui"; import { makeStyles } from "@saleor/macaw-ui"; import { renderCollection } from "@saleor/misc"; @@ -29,29 +32,17 @@ import { OrderFulfillData_order, OrderFulfillData_order_lines } from "@saleor/orders/types/OrderFulfillData"; -import { - OrderErrorCode, - OrderFulfillStockInput -} from "@saleor/types/globalTypes"; +import { getToFulfillOrderLines } from "@saleor/orders/utils/data"; +import { isStockError } from "@saleor/orders/utils/data"; +import { OrderFulfillStockInput } from "@saleor/types/globalTypes"; import { update } from "@saleor/utils/lists"; import classNames from "classnames"; import React from "react"; import { FormattedMessage, useIntl } from "react-intl"; -type ClassKey = - | "actionBar" - | "table" - | "colName" - | "colQuantity" - | "colQuantityHeader" - | "colQuantityTotal" - | "colSku" - | "error" - | "full" - | "quantityInnerInput" - | "quantityInnerInputNoRemaining" - | "remainingQuantity"; -const useStyles = makeStyles( +import { messages } from "./messages"; + +const useStyles = makeStyles( theme => { const inputPadding: CSSProperties = { paddingBottom: theme.spacing(2), @@ -59,14 +50,9 @@ const useStyles = makeStyles( }; return { - [theme.breakpoints.up("lg")]: { - colName: { - width: ({ warehouses }) => (warehouses?.length > 3 ? 250 : "auto") - } - }, - [theme.breakpoints.only("md")]: { - colName: { - width: ({ warehouses }) => (warehouses?.length > 2 ? 250 : "auto") + container: { + [theme.breakpoints.up("md")]: { + width: `calc(100vw - ${drawerWidthExpanded}px)` } }, actionBar: { @@ -74,7 +60,15 @@ const useStyles = makeStyles( paddingLeft: `calc(${theme.spacing(2)} + 2px)` }, colName: { - width: 250 + width: 250, + [theme.breakpoints.up("lg")]: { + width: ({ warehouses }: OrderFulfillPageProps) => + warehouses?.length > 3 ? 250 : "auto" + }, + [theme.breakpoints.only("md")]: { + width: ({ warehouses }: OrderFulfillPageProps) => + warehouses?.length > 2 ? 250 : "auto" + } }, colQuantity: { textAlign: "right", @@ -131,6 +125,7 @@ export interface OrderFulfillPageProps { order: OrderFulfillData_order; saveButtonBar: ConfirmButtonTransitionState; warehouses: WarehouseFragment[]; + shopSettings?: ShopOrderSettingsFragment; onBack: () => void; onSubmit: (data: OrderFulfillSubmitData) => void; } @@ -139,10 +134,6 @@ const initialFormData: OrderFulfillFormData = { sendInfo: true }; -function getRemainingQuantity(line: OrderFulfillData_order_lines): number { - return line.quantity - line.quantityFulfilled; -} - const OrderFulfillPage: React.FC = props => { const { loading, @@ -150,6 +141,7 @@ const OrderFulfillPage: React.FC = props => { order, saveButtonBar, warehouses, + shopSettings, onBack, onSubmit } = props; @@ -161,23 +153,21 @@ const OrderFulfillPage: React.FC = props => { null, OrderFulfillStockInput[] >( - order?.lines - .filter(line => getRemainingQuantity(line) > 0) - .map(line => ({ - data: null, - id: line.id, - label: line.variant.attributes - .map(attribute => - attribute.values - .map(attributeValue => attributeValue.name) - .join(" , ") - ) - .join(" / "), - value: line.variant.stocks.map(stock => ({ - quantity: 0, - warehouse: stock.warehouse.id - })) + getToFulfillOrderLines(order?.lines).map(line => ({ + data: null, + id: line.id, + label: line.variant?.attributes + .map(attribute => + attribute.values + .map(attributeValue => attributeValue.name) + .join(" , ") + ) + .join(" / "), + value: line.variant?.stocks?.map(stock => ({ + quantity: 0, + warehouse: stock.warehouse.id })) + })) ); const handleSubmit = (formData: OrderFulfillFormData) => @@ -186,110 +176,71 @@ const OrderFulfillPage: React.FC = props => { items: formsetData }); + const notAllowedToFulfillUnpaid = + shopSettings?.fulfillmentAutoApprove && + !shopSettings?.fulfillmentAllowUnpaid && + !order?.isPaid; + const shouldEnableSave = () => { if (!order || loading) { return false; } - const isAtLeastOneFulfilled = formsetData.some(({ value }) => - value.some(({ quantity }) => quantity > 0) + if (notAllowedToFulfillUnpaid) { + return false; + } + + const isAtLeastOneFulfilled = formsetData?.some(({ value }) => + value?.some(({ quantity }) => quantity > 0) ); - const areProperlyFulfilled = formsetData.every(({ id, value }) => { + const areProperlyFulfilled = formsetData?.every(({ id, value }) => { const { lines } = order; - const { quantity, quantityFulfilled } = lines.find( + const { quantityToFulfill } = lines.find( ({ id: lineId }) => lineId === id ); - const remainingQuantity = quantity - quantityFulfilled; - - const formQuantityFulfilled = value.reduce( + const formQuantityFulfilled = value?.reduce( (result, { quantity }) => result + quantity, 0 ); - return formQuantityFulfilled <= remainingQuantity; + return formQuantityFulfilled <= quantityToFulfill; }); return isAtLeastOneFulfilled && areProperlyFulfilled; }; - const isStockError = ( - overfulfill: boolean, - formsetStock: { quantity: number }, - availableQuantity: number, - warehouse: WarehouseFragment, - line: OrderFulfillData_order_lines, - errors: FulfillOrder_orderFulfill_errors[] - ) => { - if (overfulfill) { - return true; - } - - const isQuantityLargerThanAvailable = - line.variant.trackInventory && formsetStock.quantity > availableQuantity; - - const isError = !!errors?.find( - err => - err.warehouse === warehouse.id && - err.orderLines.find((id: string) => id === line.id) && - err.code === OrderErrorCode.INSUFFICIENT_STOCK - ); - - return isQuantityLargerThanAvailable || isError; - }; - return ( - + {order?.number - ? intl.formatMessage( - { - defaultMessage: "Order #{orderNumber}", - description: "page header with order number" - }, - { - orderNumber: order.number - } - ) - : intl.formatMessage({ - defaultMessage: "Order", - description: "page header" - })} + ? intl.formatMessage(messages.headerOrderNumber, { + orderNumber: order.number + }) + : intl.formatMessage(messages.headerOrder)}
{({ change, data, submit }) => ( <> - + - + {warehouses?.map(warehouse => ( = props => { ))} - + {renderCollection( - order?.lines.filter(line => getRemainingQuantity(line) > 0), + getToFulfillOrderLines(order?.lines), (line: OrderFulfillData_order_lines, lineIndex) => { if (!line) { return ( @@ -339,10 +287,10 @@ const OrderFulfillPage: React.FC = props => { ); } - const remainingQuantity = getRemainingQuantity(line); + const remainingQuantity = line.quantityToFulfill; const quantityToFulfill = formsetData[ lineIndex - ].value.reduce( + ].value?.reduce( (quantityToFulfill, lineInput) => quantityToFulfill + (lineInput.quantity || 0), 0 @@ -357,20 +305,20 @@ const OrderFulfillPage: React.FC = props => { > {line.productName} - {line.variant.attributes - .map(attribute => + {line.variant?.attributes + ?.map(attribute => attribute.values .map(attributeValue => attributeValue.name) .join(", ") ) - .join(" / ")} + ?.join(" / ")} - {line.variant.sku} + {line.variant?.sku} {warehouses?.map(warehouse => { - const warehouseStock = line.variant.stocks.find( + const warehouseStock = line.variant?.stocks?.find( stock => stock.warehouse.id === warehouse.id ); const formsetStock = formsetData[ @@ -388,10 +336,7 @@ const OrderFulfillPage: React.FC = props => { classes.error )} > - + ); } @@ -491,27 +436,30 @@ const OrderFulfillPage: React.FC = props => { )} - - - + {shopSettings?.fulfillmentAutoApprove && ( + + + + )} diff --git a/src/orders/components/OrderFulfillPage/fixtures.ts b/src/orders/components/OrderFulfillPage/fixtures.ts index d0de449ef..7cb252ac7 100644 --- a/src/orders/components/OrderFulfillPage/fixtures.ts +++ b/src/orders/components/OrderFulfillPage/fixtures.ts @@ -7,6 +7,7 @@ import { warehouseList } from "@saleor/warehouses/fixtures"; export const orderToFulfill: OrderFulfillData_order = { __typename: "Order", id: "T3JkZXI6Mg==", + isPaid: true, lines: [ { __typename: "OrderLine", @@ -16,6 +17,7 @@ export const orderToFulfill: OrderFulfillData_order = { productName: "T-Shirt", quantity: 3, quantityFulfilled: 1, + quantityToFulfill: 2, variant: { __typename: "ProductVariant", id: "UHJvZHVjdFZhcmlhbnQ6Mjk2", @@ -78,6 +80,7 @@ export const orderToFulfill: OrderFulfillData_order = { productName: "Lemon Juice", quantity: 4, quantityFulfilled: 0, + quantityToFulfill: 4, variant: { __typename: "ProductVariant", id: "UHJvZHVjdFZhcmlhbnQ6MTgx", @@ -133,6 +136,7 @@ export const orderToFulfill: OrderFulfillData_order = { productName: "Orange Juice", quantity: 3, quantityFulfilled: 2, + quantityToFulfill: 1, variant: { __typename: "ProductVariant", id: "UHJvZHVjdFZhcmlhbnQ6MTgy", diff --git a/src/orders/components/OrderFulfillPage/messages.ts b/src/orders/components/OrderFulfillPage/messages.ts new file mode 100644 index 000000000..2eacb5500 --- /dev/null +++ b/src/orders/components/OrderFulfillPage/messages.ts @@ -0,0 +1,48 @@ +import { defineMessages } from "react-intl"; + +export const messages = defineMessages({ + headerOrder: { + defaultMessage: "Order", + description: "page header" + }, + headerOrderNumber: { + defaultMessage: "Order #{orderNumber}", + description: "page header" + }, + headerOrderNumberAddFulfillment: { + defaultMessage: "Order no. {orderNumber} - Add Fulfillment", + description: "page header" + }, + submitFulfillment: { + defaultMessage: "Fulfill", + description: "fulfill order, button" + }, + submitPrepareFulfillment: { + defaultMessage: "Prepare fulfillment", + description: "prepare order fulfillment, button" + }, + itemsReadyToShip: { + defaultMessage: "Items ready to ship", + description: "header" + }, + productName: { + defaultMessage: "Product name", + description: "name" + }, + sku: { + defaultMessage: "SKU", + description: "product's sku" + }, + quantityToFulfill: { + defaultMessage: "Quantity to fulfill", + description: "quantity of fulfilled products" + }, + noStock: { + defaultMessage: "No Stock", + description: "no variant stock in warehouse" + }, + sentShipmentDetails: { + defaultMessage: "Send shipment details to customer", + description: "checkbox label" + } +}); diff --git a/src/orders/components/OrderFulfilledProductsCard/ActionButtons.tsx b/src/orders/components/OrderFulfilledProductsCard/ActionButtons.tsx index 65a90e143..7673182ae 100644 --- a/src/orders/components/OrderFulfilledProductsCard/ActionButtons.tsx +++ b/src/orders/components/OrderFulfilledProductsCard/ActionButtons.tsx @@ -1,25 +1,35 @@ -import { Button, CardActions } from "@material-ui/core"; +import { Button, CardActions, Typography } from "@material-ui/core"; +import { buttonMessages, commonMessages } from "@saleor/intl"; import { FulfillmentStatus } from "@saleor/types/globalTypes"; import React from "react"; import { FormattedMessage } from "react-intl"; +import { actionButtonsMessages } from "./messages"; + interface AcionButtonsProps { status: FulfillmentStatus; trackingNumber?: string; + orderIsPaid?: boolean; + fulfillmentAllowUnpaid: boolean; onTrackingCodeAdd(); onRefund(); + onApprove(); } const statusesToShow = [ FulfillmentStatus.FULFILLED, - FulfillmentStatus.RETURNED + FulfillmentStatus.RETURNED, + FulfillmentStatus.WAITING_FOR_APPROVAL ]; const ActionButtons: React.FC = ({ status, - onTrackingCodeAdd, trackingNumber, - onRefund + orderIsPaid, + fulfillmentAllowUnpaid, + onTrackingCodeAdd, + onRefund, + onApprove }) => { const hasTrackingNumber = !!trackingNumber; @@ -27,14 +37,28 @@ const ActionButtons: React.FC = ({ return null; } + if (status === FulfillmentStatus.WAITING_FOR_APPROVAL) { + const cannotFulfill = !orderIsPaid && !fulfillmentAllowUnpaid; + + return ( + + + {cannotFulfill && ( + + + + )} + + ); + } + if (status === FulfillmentStatus.RETURNED) { return ( ); @@ -43,19 +67,13 @@ const ActionButtons: React.FC = ({ return hasTrackingNumber ? ( ) : ( ); diff --git a/src/orders/components/OrderFulfilledProductsCard/ExtraInfoLines.tsx b/src/orders/components/OrderFulfilledProductsCard/ExtraInfoLines.tsx index c4cce62f5..f7c40fed8 100644 --- a/src/orders/components/OrderFulfilledProductsCard/ExtraInfoLines.tsx +++ b/src/orders/components/OrderFulfilledProductsCard/ExtraInfoLines.tsx @@ -4,10 +4,11 @@ import { getStringOrPlaceholder } from "@saleor/misc"; import { FulfillmentStatus } from "@saleor/types/globalTypes"; import classNames from "classnames"; import React from "react"; -import { defineMessages, useIntl } from "react-intl"; +import { useIntl } from "react-intl"; import { FormattedMessage } from "react-intl"; import { OrderDetails_order_fulfillments } from "../../types/OrderDetails"; +import { extraInfoMessages } from "./messages"; const useStyles = makeStyles( theme => ({ @@ -24,21 +25,6 @@ const useStyles = makeStyles( { name: "ExtraInfoLines" } ); -const messages = defineMessages({ - fulfilled: { - defaultMessage: "Fulfilled from: ", - description: "fulfillment group" - }, - restocked: { - defaultMessage: "Restocked from: ", - description: "restocked group" - }, - tracking: { - defaultMessage: "Tracking Number: {trackingNumber}", - description: "tracking number" - } -}); - const NUMBER_OF_COLUMNS = 5; interface ExtraInfoLinesProps { @@ -63,8 +49,8 @@ const ExtraInfoLines: React.FC = ({ fulfillment }) => { <> {intl.formatMessage( status === FulfillmentStatus.RETURNED - ? messages.restocked - : messages.fulfilled + ? extraInfoMessages.restocked + : extraInfoMessages.fulfilled )} = ({ fulfillment }) => { {trackingNumber && ( ({ + theme => ({ table: { tableLayout: "fixed" + }, + deleteIcon: { + height: 40, + paddingRight: 0, + paddingLeft: theme.spacing(1), + width: 40 } }), { name: "OrderFulfillment" } @@ -27,36 +33,42 @@ const useStyles = makeStyles( interface OrderFulfilledProductsCardProps { fulfillment: OrderDetails_order_fulfillments; - orderNumber?: string; + fulfillmentAllowUnpaid: boolean; + order?: OrderDetailsFragment; + onOrderFulfillmentApprove: () => void; onOrderFulfillmentCancel: () => void; onTrackingCodeAdd: () => void; onRefund: () => void; } +const statusesToMergeLines = [ + FulfillmentStatus.REFUNDED, + FulfillmentStatus.REFUNDED_AND_RETURNED, + FulfillmentStatus.RETURNED, + FulfillmentStatus.REPLACED +]; +const cancelableStatuses = [ + FulfillmentStatus.FULFILLED, + FulfillmentStatus.WAITING_FOR_APPROVAL +]; + const OrderFulfilledProductsCard: React.FC = props => { const { fulfillment, - orderNumber, + fulfillmentAllowUnpaid, + order, + onOrderFulfillmentApprove, onOrderFulfillmentCancel, onTrackingCodeAdd, onRefund } = props; const classes = useStyles(props); - const intl = useIntl(); - if (!fulfillment) { return null; } const getLines = () => { - const statusesToMergeLines = [ - FulfillmentStatus.REFUNDED, - FulfillmentStatus.REFUNDED_AND_RETURNED, - FulfillmentStatus.RETURNED, - FulfillmentStatus.REPLACED - ]; - if (statusesToMergeLines.includes(fulfillment?.status)) { return mergeRepeatedOrderLines(fulfillment.lines); } @@ -72,21 +84,17 @@ const OrderFulfilledProductsCard: React.FC = pr lines={fulfillment?.lines} fulfillmentOrder={fulfillment?.fulfillmentOrder} status={fulfillment?.status} - orderNumber={orderNumber} + warehouseName={fulfillment?.warehouse?.name} + orderNumber={order?.number} toolbar={ - maybe(() => fulfillment.status) === FulfillmentStatus.FULFILLED && ( - + cancelableStatuses.includes(fulfillment?.status) && ( + + + ) } /> @@ -102,8 +110,11 @@ const OrderFulfilledProductsCard: React.FC = pr diff --git a/src/orders/components/OrderFulfilledProductsCard/messages.ts b/src/orders/components/OrderFulfilledProductsCard/messages.ts new file mode 100644 index 000000000..20ef4b8e4 --- /dev/null +++ b/src/orders/components/OrderFulfilledProductsCard/messages.ts @@ -0,0 +1,31 @@ +import { defineMessages } from "react-intl"; + +export const actionButtonsMessages = defineMessages({ + refund: { + defaultMessage: "Refund", + description: "refund button" + }, + editTracking: { + defaultMessage: "Edit tracking", + description: "edit tracking button" + }, + addTracking: { + defaultMessage: "Add tracking", + description: "add tracking button" + } +}); + +export const extraInfoMessages = defineMessages({ + fulfilled: { + defaultMessage: "Fulfilled from: ", + description: "fulfillment group" + }, + restocked: { + defaultMessage: "Restocked from: ", + description: "restocked group" + }, + tracking: { + defaultMessage: "Tracking Number: {trackingNumber}", + description: "tracking number" + } +}); diff --git a/src/orders/components/OrderFulfillmentApproveDialog/OrderFulfillmentApproveDialog.tsx b/src/orders/components/OrderFulfillmentApproveDialog/OrderFulfillmentApproveDialog.tsx new file mode 100644 index 000000000..17af5ec33 --- /dev/null +++ b/src/orders/components/OrderFulfillmentApproveDialog/OrderFulfillmentApproveDialog.tsx @@ -0,0 +1,92 @@ +import { + Button, + Dialog, + DialogActions, + DialogContent, + DialogContentText, + DialogTitle +} from "@material-ui/core"; +import ConfirmButton, { + ConfirmButtonTransitionState +} from "@saleor/components/ConfirmButton"; +import ControlledCheckbox from "@saleor/components/ControlledCheckbox"; +import Form from "@saleor/components/Form"; +import FormSpacer from "@saleor/components/FormSpacer"; +import { OrderErrorFragment } from "@saleor/fragments/types/OrderErrorFragment"; +import { buttonMessages } from "@saleor/intl"; +import getOrderErrorMessage from "@saleor/utils/errors/order"; +import React from "react"; +import { FormattedMessage, useIntl } from "react-intl"; + +import { messages } from "./messages"; + +export interface OrderFulfillmentAcceptDialogFormData { + notifyCustomer: boolean; +} + +export interface OrderFulfillmentAcceptDialogProps { + confirmButtonState: ConfirmButtonTransitionState; + errors: OrderErrorFragment[]; + open: boolean; + onClose(); + onConfirm(data: OrderFulfillmentAcceptDialogFormData); +} + +const OrderFulfillmentAcceptDialog: React.FC = props => { + const { confirmButtonState, errors, open, onConfirm, onClose } = props; + + const intl = useIntl(); + + return ( + + + {({ change, data, submit }) => ( + <> + + + + + + + + + {errors.length > 0 && ( + <> + + {errors.map((err, index) => ( + + {getOrderErrorMessage(err, intl)} + + ))} + + )} + + + + + + + + + )} + + + ); +}; +OrderFulfillmentAcceptDialog.displayName = "OrderFulfillmentAcceptDialog"; +export default OrderFulfillmentAcceptDialog; diff --git a/src/orders/components/OrderFulfillmentApproveDialog/index.ts b/src/orders/components/OrderFulfillmentApproveDialog/index.ts new file mode 100644 index 000000000..3906338ec --- /dev/null +++ b/src/orders/components/OrderFulfillmentApproveDialog/index.ts @@ -0,0 +1,2 @@ +export { default } from "./OrderFulfillmentApproveDialog"; +export * from "./OrderFulfillmentApproveDialog"; diff --git a/src/orders/components/OrderFulfillmentApproveDialog/messages.ts b/src/orders/components/OrderFulfillmentApproveDialog/messages.ts new file mode 100644 index 000000000..9a4f6158c --- /dev/null +++ b/src/orders/components/OrderFulfillmentApproveDialog/messages.ts @@ -0,0 +1,16 @@ +import { defineMessages } from "react-intl"; + +export const messages = defineMessages({ + title: { + defaultMessage: "Approve this fulfillment", + description: "dialog header" + }, + description: { + defaultMessage: "Are you sure you want to approve this fullfillment?", + description: "dialog description" + }, + notifyCustomer: { + defaultMessage: "Send shipment details to customer", + description: "checkbox label, fulfillment approval" + } +}); diff --git a/src/orders/components/OrderFulfillmentDialog/OrderFulfillmentDialog.tsx b/src/orders/components/OrderFulfillmentDialog/OrderFulfillmentDialog.tsx deleted file mode 100644 index 7d5d53069..000000000 --- a/src/orders/components/OrderFulfillmentDialog/OrderFulfillmentDialog.tsx +++ /dev/null @@ -1,247 +0,0 @@ -import { - Button, - Dialog, - DialogActions, - DialogContent, - DialogContentText, - DialogTitle, - TableBody, - TableCell, - TableHead, - TableRow, - TextField -} from "@material-ui/core"; -import ConfirmButton, { - ConfirmButtonTransitionState -} from "@saleor/components/ConfirmButton"; -import Form from "@saleor/components/Form"; -import { FormSpacer } from "@saleor/components/FormSpacer"; -import ResponsiveTable from "@saleor/components/ResponsiveTable"; -import TableCellAvatar from "@saleor/components/TableCellAvatar"; -import { AVATAR_MARGIN } from "@saleor/components/TableCellAvatar/Avatar"; -import { OrderErrorFragment } from "@saleor/fragments/types/OrderErrorFragment"; -import { buttonMessages } from "@saleor/intl"; -import { makeStyles } from "@saleor/macaw-ui"; -import { getFormErrors } from "@saleor/utils/errors"; -import getOrderErrorMessage from "@saleor/utils/errors/order"; -import React from "react"; -import { FormattedMessage, useIntl } from "react-intl"; - -import { maybe } from "../../../misc"; -import { OrderDetails_order_lines } from "../../types/OrderDetails"; - -export interface FormData { - lines: number[]; - trackingNumber: string; -} - -const useStyles = makeStyles( - theme => ({ - colName: { - width: "auto" - }, - colNameLabel: { - marginLeft: AVATAR_MARGIN - }, - colQuantity: { - textAlign: "right", - width: 150 - }, - colQuantityContent: { - alignItems: "center", - display: "inline-flex" - }, - colSku: { - width: 120 - }, - quantityInput: { - width: 100 - }, - remainingQuantity: { - marginLeft: theme.spacing(), - paddingTop: 14 - }, - table: { - tableLayout: "fixed" - } - }), - { name: "OrderFulfillmentDialog" } -); - -export interface OrderFulfillmentDialogProps { - confirmButtonState: ConfirmButtonTransitionState; - errors: OrderErrorFragment[]; - open: boolean; - lines: OrderDetails_order_lines[]; - onClose(); - onSubmit(data: FormData); -} - -const OrderFulfillmentDialog: React.FC = props => { - const { confirmButtonState, errors, open, lines, onClose, onSubmit } = props; - - const classes = useStyles(props); - const intl = useIntl(); - - const formFields = ["trackingNumber"]; - const formErrors = getFormErrors(formFields, errors); - - return ( - -
- lines.map( - product => product.quantity - product.quantityFulfilled - ), - [] - ), - trackingNumber: "" - }} - onSubmit={onSubmit} - > - {({ data, change }) => { - const handleQuantityChange = ( - productIndex: number, - event: React.ChangeEvent - ) => { - const newData = data.lines; - newData[productIndex] = event.target.value; - change({ - target: { - name: "lines", - value: newData - } - } as any); - }; - return ( - <> - - - - - - - - - - - - - - - - - - - - - {lines.map((product, productIndex) => { - const remainingQuantity = - product.quantity - product.quantityFulfilled; - return ( - - product.thumbnail.url)} - > - {product.productName} - - - {product.productSku} - - -
- - handleQuantityChange(productIndex, event) - } - error={ - !!formErrors.trackingNumber || - remainingQuantity < data.lines[productIndex] - } - helperText={getOrderErrorMessage( - formErrors.trackingNumber, - intl - )} - /> -
- / {remainingQuantity} -
-
-
-
- ); - })} -
-
- - - - {errors.length > 0 && ( - <> - - {errors - .filter(err => !formFields.includes(err.field)) - .map((err, index) => ( - - {getOrderErrorMessage(err, intl)} - - ))} - - )} - - - - - - - - - ); - }} - -
- ); -}; - -OrderFulfillmentDialog.displayName = "OrderFulfillmentDialog"; -export default OrderFulfillmentDialog; diff --git a/src/orders/components/OrderFulfillmentDialog/index.ts b/src/orders/components/OrderFulfillmentDialog/index.ts deleted file mode 100644 index 5a977a6c0..000000000 --- a/src/orders/components/OrderFulfillmentDialog/index.ts +++ /dev/null @@ -1,2 +0,0 @@ -export { default } from "./OrderFulfillmentDialog"; -export * from "./OrderFulfillmentDialog"; diff --git a/src/orders/components/OrderFulfillmentSettings/OrderFulfillmentSettings.tsx b/src/orders/components/OrderFulfillmentSettings/OrderFulfillmentSettings.tsx new file mode 100644 index 000000000..5dcfd3d1f --- /dev/null +++ b/src/orders/components/OrderFulfillmentSettings/OrderFulfillmentSettings.tsx @@ -0,0 +1,80 @@ +import { Card, CardContent, Typography } from "@material-ui/core"; +import CardTitle from "@saleor/components/CardTitle"; +import ControlledCheckbox from "@saleor/components/ControlledCheckbox"; +import FormSpacer from "@saleor/components/FormSpacer"; +import React from "react"; +import { FormattedMessage, useIntl } from "react-intl"; + +import { OrderSettingsFormData } from "../OrderSettingsPage/form"; + +export interface OrderFulfillmentSettingsProps { + data: OrderSettingsFormData; + disabled: boolean; + onChange: (event: React.ChangeEvent) => void; +} + +const OrderFulfillmentSettings: React.FC = ({ + data, + disabled, + onChange +}) => { + const intl = useIntl(); + + return ( + + + + + + + + + + } + checked={data.fulfillmentAutoApprove} + onChange={onChange} + disabled={disabled} + data-test="fulfillmentAutoApproveCheckbox" + /> + + + + + + + + } + checked={data.fulfillmentAllowUnpaid} + onChange={onChange} + disabled={disabled} + data-test="fulfillmentAllowUnpaidCheckbox" + /> + + + ); +}; +OrderFulfillmentSettings.displayName = "OrderFulfillmentSettings"; +export default OrderFulfillmentSettings; diff --git a/src/orders/components/OrderFulfillmentSettings/index.ts b/src/orders/components/OrderFulfillmentSettings/index.ts new file mode 100644 index 000000000..bc8a5b598 --- /dev/null +++ b/src/orders/components/OrderFulfillmentSettings/index.ts @@ -0,0 +1,2 @@ +export { default } from "./OrderFulfillmentSettings"; +export * from "./OrderFulfillmentSettings"; diff --git a/src/orders/components/OrderHistory/OrderHistory.tsx b/src/orders/components/OrderHistory/OrderHistory.tsx index 6bfb355c5..d26a8b03a 100644 --- a/src/orders/components/OrderHistory/OrderHistory.tsx +++ b/src/orders/components/OrderHistory/OrderHistory.tsx @@ -142,6 +142,11 @@ export const getEventMessage = ( sentBy: event.user ? event.user.email : null } ); + case OrderEventsEnum.FULFILLMENT_AWAITS_APPROVAL: + return intl.formatMessage({ + defaultMessage: "Fulfillment awaits approval", + description: "order history message" + }); case OrderEventsEnum.FULFILLMENT_FULFILLED_ITEMS: return intl.formatMessage( { diff --git a/src/orders/components/OrderProductsCardElements/OrderProductsTableRow.tsx b/src/orders/components/OrderProductsCardElements/OrderProductsTableRow.tsx index 359e8edd3..ead0c1b81 100644 --- a/src/orders/components/OrderProductsCardElements/OrderProductsTableRow.tsx +++ b/src/orders/components/OrderProductsCardElements/OrderProductsTableRow.tsx @@ -72,7 +72,7 @@ const TableLine: React.FC = ({ isOrderLine = false }) => { const classes = useStyles({}); - const { quantity, quantityFulfilled } = lineData as OrderDetails_order_lines; + const { quantity, quantityToFulfill } = lineData as OrderDetails_order_lines; if (!lineData) { return ; @@ -85,9 +85,7 @@ const TableLine: React.FC = ({ } as OrderDetails_order_fulfillments_lines) : (lineData as OrderDetails_order_fulfillments_lines); - const quantityToDisplay = isOrderLine - ? quantity - quantityFulfilled - : quantity; + const quantityToDisplay = isOrderLine ? quantityToFulfill : quantity; return ( diff --git a/src/orders/components/OrderRefundFulfilledProducts/OrderRefundFulfilledProducts.tsx b/src/orders/components/OrderRefundFulfilledProducts/OrderRefundFulfilledProducts.tsx index 4acec26bd..482e27cc1 100644 --- a/src/orders/components/OrderRefundFulfilledProducts/OrderRefundFulfilledProducts.tsx +++ b/src/orders/components/OrderRefundFulfilledProducts/OrderRefundFulfilledProducts.tsx @@ -18,11 +18,11 @@ import { FormsetChange } from "@saleor/hooks/useFormset"; import { makeStyles } from "@saleor/macaw-ui"; import { renderCollection } from "@saleor/misc"; import { OrderRefundData_order_fulfillments } from "@saleor/orders/types/OrderRefundData"; -import { FulfillmentStatus } from "@saleor/types/globalTypes"; import React from "react"; import { FormattedMessage, useIntl } from "react-intl"; import { OrderRefundFormData } from "../OrderRefundPage/form"; +import { getTitle } from "./messages"; const useStyles = makeStyles( theme => { @@ -93,15 +93,7 @@ const OrderRefundFulfilledProducts: React.FC - {fulfillment.status === FulfillmentStatus.RETURNED - ? intl.formatMessage({ - defaultMessage: "Fulfillment returned", - description: "section header returned" - }) - : intl.formatMessage({ - defaultMessage: "Fulfillment", - description: "section header" - })} + {getTitle(fulfillment.status, intl)} {fulfillment && ( {`#${orderNumber}-${fulfillment?.fulfillmentOrder}`} diff --git a/src/orders/components/OrderRefundFulfilledProducts/messages.ts b/src/orders/components/OrderRefundFulfilledProducts/messages.ts new file mode 100644 index 000000000..db42f78a5 --- /dev/null +++ b/src/orders/components/OrderRefundFulfilledProducts/messages.ts @@ -0,0 +1,31 @@ +import { FulfillmentStatus } from "@saleor/types/globalTypes"; +import { defineMessages, IntlShape } from "react-intl"; + +export const messages = defineMessages({ + fulfillment: { + defaultMessage: "Fulfillment", + description: "section header" + }, + fulfillmentReturned: { + defaultMessage: "Fulfillment returned", + description: "section header returned" + }, + fulfillmentWaitingForApproval: { + defaultMessage: "Fulfillment waiting for approval", + description: "section header returned" + } +}); + +export const getTitle = ( + fulfillmentStatus: FulfillmentStatus, + intl: IntlShape +) => { + switch (fulfillmentStatus) { + case FulfillmentStatus.RETURNED: + return intl.formatMessage(messages.fulfillmentReturned); + case FulfillmentStatus.WAITING_FOR_APPROVAL: + return intl.formatMessage(messages.fulfillmentWaitingForApproval); + default: + return intl.formatMessage(messages.fulfillment); + } +}; diff --git a/src/orders/components/OrderRefundPage/OrderRefundPage.tsx b/src/orders/components/OrderRefundPage/OrderRefundPage.tsx index 00b912618..9ded90cf6 100644 --- a/src/orders/components/OrderRefundPage/OrderRefundPage.tsx +++ b/src/orders/components/OrderRefundPage/OrderRefundPage.tsx @@ -26,7 +26,8 @@ import OrderRefundForm, { export const refundFulfilledStatuses = [ FulfillmentStatus.FULFILLED, - FulfillmentStatus.RETURNED + FulfillmentStatus.RETURNED, + FulfillmentStatus.WAITING_FOR_APPROVAL ]; export interface OrderRefundPageProps { @@ -51,7 +52,7 @@ const OrderRefundPage: React.FC = props => { const intl = useIntl(); const unfulfilledLines = order?.lines.filter( - line => line.quantity !== line.quantityFulfilled + line => line.quantityToFulfill > 0 ); const fulfilledFulfillemnts = diff --git a/src/orders/components/OrderRefundPage/fixtures.ts b/src/orders/components/OrderRefundPage/fixtures.ts index fdbf9baf5..61b9aa391 100644 --- a/src/orders/components/OrderRefundPage/fixtures.ts +++ b/src/orders/components/OrderRefundPage/fixtures.ts @@ -34,7 +34,7 @@ export const orderToRefund = (placeholder: string): OrderRefundData_order => ({ id: "diufhdsif", productName: "Milk", quantity: 19, - quantityFulfilled: 3, + quantityToFulfill: 16, thumbnail: { __typename: "Image", url: placeholder @@ -53,7 +53,7 @@ export const orderToRefund = (placeholder: string): OrderRefundData_order => ({ id: "fdsfdfdsf", productName: "Coffee", quantity: 13, - quantityFulfilled: 5, + quantityToFulfill: 8, thumbnail: { __typename: "Image", url: placeholder diff --git a/src/orders/components/OrderRefundPage/form.tsx b/src/orders/components/OrderRefundPage/form.tsx index f51e237b1..40b21d158 100644 --- a/src/orders/components/OrderRefundPage/form.tsx +++ b/src/orders/components/OrderRefundPage/form.tsx @@ -78,7 +78,7 @@ function useOrderRefundForm( const form = useForm(getOrderRefundPageFormData(defaultType)); const refundedProductQuantities = useFormset( order?.lines - .filter(line => line.quantityFulfilled !== line.quantity) + .filter(line => line.quantityToFulfill > 0) .map(line => ({ data: null, id: line.id, @@ -132,7 +132,7 @@ function useOrderRefundForm( data: null, id: line.id, label: null, - value: (line.quantity - line.quantityFulfilled).toString() + value: line.quantityToFulfill.toString() }; }); refundedProductQuantities.set(newQuantities); diff --git a/src/orders/components/OrderRefundUnfulfilledProducts/OrderRefundUnfulfilledProducts.tsx b/src/orders/components/OrderRefundUnfulfilledProducts/OrderRefundUnfulfilledProducts.tsx index fd34a145c..2c2fca628 100644 --- a/src/orders/components/OrderRefundUnfulfilledProducts/OrderRefundUnfulfilledProducts.tsx +++ b/src/orders/components/OrderRefundUnfulfilledProducts/OrderRefundUnfulfilledProducts.tsx @@ -148,7 +148,7 @@ const OrderRefundUnfulfilledProducts: React.FC refundedLine.id === line.id ); - const lineQuantity = line?.quantity - line?.quantityFulfilled; + const lineQuantity = line?.quantityToFulfill; const isError = Number(selectedLineQuantity?.value) > lineQuantity || Number(selectedLineQuantity?.value) < 0; diff --git a/src/orders/components/OrderReturnPage/OrderReturnRefundItemsCard/CardTitle.tsx b/src/orders/components/OrderReturnPage/OrderReturnRefundItemsCard/CardTitle.tsx index c0aefebaf..4e461eed2 100644 --- a/src/orders/components/OrderReturnPage/OrderReturnRefundItemsCard/CardTitle.tsx +++ b/src/orders/components/OrderReturnPage/OrderReturnRefundItemsCard/CardTitle.tsx @@ -6,14 +6,24 @@ import { makeStyles } from "@saleor/macaw-ui"; import { FulfillmentStatus } from "@saleor/types/globalTypes"; import camelCase from "lodash/camelCase"; import React from "react"; +import { FormattedMessage } from "react-intl"; import { defineMessages } from "react-intl"; import { useIntl } from "react-intl"; const useStyles = makeStyles( theme => ({ + title: { + width: "100%", + display: "flex" + }, orderNumber: { display: "inline", marginLeft: theme.spacing(1) + }, + warehouseName: { + float: "right", + color: theme.palette.text.secondary, + margin: `auto ${theme.spacing(1)} auto auto` } }), { name: "CardTitle" } @@ -44,9 +54,17 @@ const messages = defineMessages({ defaultMessage: "Returned ({quantity})", description: "refunded fulfillment, section header" }, + waitingForApproval: { + defaultMessage: "Waiting for approval ({quantity})", + description: "unapproved fulfillment, section header" + }, unfulfilled: { defaultMessage: "Unfulfilled", description: "section header" + }, + fulfilledFrom: { + defaultMessage: "Fulfilled from {warehouseName}", + description: "fulfilled fulfillment, section header" } }); @@ -62,6 +80,7 @@ interface CardTitleProps { status: CardTitleStatus; toolbar?: React.ReactNode; orderNumber?: string; + warehouseName?: string; withStatus?: boolean; } @@ -77,6 +96,8 @@ const selectStatus = (status: CardTitleStatus) => { return StatusType.NEUTRAL; case FulfillmentStatus.REFUNDED_AND_RETURNED: return StatusType.NEUTRAL; + case FulfillmentStatus.WAITING_FOR_APPROVAL: + return StatusType.ALERT; case FulfillmentStatus.CANCELED: return StatusType.ERROR; default: @@ -89,6 +110,7 @@ const CardTitle: React.FC = ({ fulfillmentOrder, status, orderNumber = "", + warehouseName, withStatus = false, toolbar }) => { @@ -108,7 +130,7 @@ const CardTitle: React.FC = ({ ); const title = ( - <> +
{intl.formatMessage(messageForStatus, { fulfillmentName, quantity: totalQuantity @@ -116,7 +138,17 @@ const CardTitle: React.FC = ({ {fulfillmentName} - + {!!warehouseName && ( + + + + )} +
); return ( diff --git a/src/orders/components/OrderSettingsPage/OrderSettingsPage.stories.tsx b/src/orders/components/OrderSettingsPage/OrderSettingsPage.stories.tsx index 503d08325..42a26d7f1 100644 --- a/src/orders/components/OrderSettingsPage/OrderSettingsPage.stories.tsx +++ b/src/orders/components/OrderSettingsPage/OrderSettingsPage.stories.tsx @@ -1,4 +1,7 @@ -import { orderSettings as orderSettingsFixture } from "@saleor/orders/fixtures"; +import { + orderSettings as orderSettingsFixture, + shopOrderSettings as shopOrderSettingsFixture +} from "@saleor/orders/fixtures"; import { storiesOf } from "@storybook/react"; import React from "react"; @@ -6,7 +9,8 @@ import Decorator from "../../../storybook/Decorator"; import OrderSettings, { OrderSettingsPageProps } from "."; const props: OrderSettingsPageProps = { - data: orderSettingsFixture, + orderSettings: orderSettingsFixture, + shop: shopOrderSettingsFixture, disabled: false, onBack: () => undefined, onSubmit: () => undefined, @@ -17,5 +21,10 @@ storiesOf("Views / Orders / Order settings", module) .addDecorator(Decorator) .add("default", () => ) .add("loading", () => ( - + )); diff --git a/src/orders/components/OrderSettingsPage/OrderSettingsPage.tsx b/src/orders/components/OrderSettingsPage/OrderSettingsPage.tsx index e2e3adc06..70d1b4268 100644 --- a/src/orders/components/OrderSettingsPage/OrderSettingsPage.tsx +++ b/src/orders/components/OrderSettingsPage/OrderSettingsPage.tsx @@ -5,17 +5,20 @@ import Grid from "@saleor/components/Grid"; import PageHeader from "@saleor/components/PageHeader"; import Savebar from "@saleor/components/Savebar"; import { OrderSettingsFragment } from "@saleor/fragments/types/OrderSettingsFragment"; +import { ShopOrderSettingsFragment } from "@saleor/fragments/types/ShopOrderSettingsFragment"; import { SubmitPromise } from "@saleor/hooks/useForm"; import { sectionNames } from "@saleor/intl"; import { Backlink } from "@saleor/macaw-ui"; import React from "react"; import { FormattedMessage, useIntl } from "react-intl"; +import OrderFulfillmentSettings from "../OrderFulfillmentSettings"; import OrderSettings from "../OrderSettings/OrderSettings"; import OrderSettingsForm, { OrderSettingsFormData } from "./form"; export interface OrderSettingsPageProps { - data: OrderSettingsFragment; + orderSettings: OrderSettingsFragment; + shop: ShopOrderSettingsFragment; disabled: boolean; saveButtonBarState: ConfirmButtonTransitionState; onBack: () => void; @@ -23,11 +26,22 @@ export interface OrderSettingsPageProps { } const OrderSettingsPage: React.FC = props => { - const { data, disabled, saveButtonBarState, onBack, onSubmit } = props; + const { + orderSettings, + shop, + disabled, + saveButtonBarState, + onBack, + onSubmit + } = props; const intl = useIntl(); return ( - + {({ data, submit, hasChanged, change }) => ( @@ -46,6 +60,12 @@ const OrderSettingsPage: React.FC = props => {
+
+ React.ReactNode; orderSettings: OrderSettingsFragment; + shop: ShopOrderSettingsFragment; onSubmit: (data: OrderSettingsFormData) => SubmitPromise; } function getOrderSeettingsFormData( - orderSettings: OrderSettingsFragment + orderSettings: OrderSettingsFragment, + shop: ShopOrderSettingsFragment ): OrderSettingsFormData { return { automaticallyConfirmAllNewOrders: - orderSettings?.automaticallyConfirmAllNewOrders + orderSettings?.automaticallyConfirmAllNewOrders, + fulfillmentAutoApprove: shop?.fulfillmentAutoApprove, + fulfillmentAllowUnpaid: shop?.fulfillmentAllowUnpaid }; } function useOrderSettingsForm( orderSettings: OrderSettingsFragment, + shop: ShopOrderSettingsFragment, onSubmit: (data: OrderSettingsFormData) => SubmitPromise ): UseOrderSettingsFormResult { const [changed, setChanged] = React.useState(false); const triggerChange = () => setChanged(true); - const form = useForm(getOrderSeettingsFormData(orderSettings)); + const form = useForm(getOrderSeettingsFormData(orderSettings, shop)); const handleChange: FormChange = (event, cb) => { form.change(event, cb); @@ -60,9 +68,10 @@ function useOrderSettingsForm( const OrderSettingsForm: React.FC = ({ children, orderSettings, + shop, onSubmit }) => { - const props = useOrderSettingsForm(orderSettings, onSubmit); + const props = useOrderSettingsForm(orderSettings, shop, onSubmit); return
{children(props)}
; }; diff --git a/src/orders/components/OrderUnfulfilledProductsCard/OrderUnfulfilledProductsCard.tsx b/src/orders/components/OrderUnfulfilledProductsCard/OrderUnfulfilledProductsCard.tsx index 7b8487dd2..1f4400d42 100644 --- a/src/orders/components/OrderUnfulfilledProductsCard/OrderUnfulfilledProductsCard.tsx +++ b/src/orders/components/OrderUnfulfilledProductsCard/OrderUnfulfilledProductsCard.tsx @@ -1,6 +1,13 @@ -import { Button, Card, CardActions, TableBody } from "@material-ui/core"; +import { + Button, + Card, + CardActions, + TableBody, + Typography +} from "@material-ui/core"; import CardSpacer from "@saleor/components/CardSpacer"; import ResponsiveTable from "@saleor/components/ResponsiveTable"; +import { commonMessages } from "@saleor/intl"; import { makeStyles } from "@saleor/macaw-ui"; import { renderCollection } from "@saleor/misc"; import React from "react"; @@ -21,13 +28,19 @@ const useStyles = makeStyles( ); interface OrderUnfulfilledProductsCardProps { - canFulfill: boolean; + showFulfillmentAction: boolean; + notAllowedToFulfillUnpaid: boolean; lines: OrderDetails_order_lines[]; onFulfill: () => void; } const OrderUnfulfilledProductsCard: React.FC = props => { - const { canFulfill, lines, onFulfill } = props; + const { + showFulfillmentAction, + notAllowedToFulfillUnpaid, + lines, + onFulfill + } = props; const classes = useStyles({}); if (!lines.length) { @@ -46,11 +59,23 @@ const OrderUnfulfilledProductsCard: React.FC ))} - {canFulfill && ( + {showFulfillmentAction && ( - + {notAllowedToFulfillUnpaid && ( + + + + )} )} diff --git a/src/orders/containers/OrderOperations.tsx b/src/orders/containers/OrderOperations.tsx index 3dc85c25e..1dd1302a3 100644 --- a/src/orders/containers/OrderOperations.tsx +++ b/src/orders/containers/OrderOperations.tsx @@ -11,6 +11,7 @@ import { TypedOrderDraftCancelMutation, TypedOrderDraftFinalizeMutation, TypedOrderDraftUpdateMutation, + TypedOrderFulfillmentApproveMutation, TypedOrderFulfillmentCancelMutation, TypedOrderFulfillmentUpdateTrackingMutation, TypedOrderLineDeleteMutation, @@ -44,6 +45,10 @@ import { OrderDraftUpdate, OrderDraftUpdateVariables } from "../types/OrderDraftUpdate"; +import { + OrderFulfillmentApprove, + OrderFulfillmentApproveVariables +} from "../types/OrderFulfillmentApprove"; import { OrderFulfillmentCancel, OrderFulfillmentCancelVariables @@ -83,6 +88,10 @@ interface OrderOperationsProps { OrderCancel, OrderCancelVariables >; + orderFulfillmentApprove: PartialMutationProviderOutput< + OrderFulfillmentApprove, + OrderFulfillmentApproveVariables + >; orderFulfillmentCancel: PartialMutationProviderOutput< OrderFulfillmentCancel, OrderFulfillmentCancelVariables @@ -141,6 +150,7 @@ interface OrderOperationsProps { InvoiceEmailSendVariables >; }) => React.ReactNode; + onOrderFulfillmentApprove: (data: OrderFulfillmentApprove) => void; onOrderFulfillmentCancel: (data: OrderFulfillmentCancel) => void; onOrderFulfillmentUpdate: (data: OrderFulfillmentUpdateTracking) => void; onOrderCancel: (data: OrderCancel) => void; @@ -174,6 +184,7 @@ const OrderOperations: React.FC = ({ onUpdate, onDraftCancel, onDraftFinalize, + onOrderFulfillmentApprove, onOrderFulfillmentCancel, onOrderFulfillmentUpdate, onOrderMarkAsPaid, @@ -210,121 +221,138 @@ const OrderOperations: React.FC = ({ onCompleted={onOrderLineUpdate} > {(...updateOrderLine) => ( - - {(...cancelFulfillment) => ( - ( + - {(...updateTrackingNumber) => ( - ( + - {(...finalizeDraft) => ( - ( + - {(...cancelDraft) => ( - ( + {( - ...markAsPaid + ...cancelDraft ) => ( - {( - ...invoiceRequest + ...markAsPaid ) => ( - {( - ...invoiceEmailSend - ) => - children({ - orderAddNote: getMutationProviderData( - ...addNote - ), - orderCancel: getMutationProviderData( - ...orderCancel - ), - orderDraftCancel: getMutationProviderData( - ...cancelDraft - ), - orderDraftFinalize: getMutationProviderData( - ...finalizeDraft - ), - orderDraftUpdate: getMutationProviderData( - ...updateDraft - ), - orderFulfillmentCancel: getMutationProviderData( - ...cancelFulfillment - ), - orderFulfillmentUpdateTracking: getMutationProviderData( - ...updateTrackingNumber - ), - orderInvoiceRequest: getMutationProviderData( - ...invoiceRequest - ), - orderInvoiceSend: getMutationProviderData( + ...invoiceRequest + ) => ( + + {( ...invoiceEmailSend - ), - orderLineDelete: getMutationProviderData( - ...deleteOrderLine - ), - orderLineUpdate: getMutationProviderData( - ...updateOrderLine - ), - orderLinesAdd: getMutationProviderData( - ...addOrderLine - ), - orderPaymentCapture: getMutationProviderData( - ...paymentCapture - ), - orderPaymentMarkAsPaid: getMutationProviderData( - ...markAsPaid - ), - orderShippingMethodUpdate: getMutationProviderData( - ...updateShippingMethod - ), - orderUpdate: getMutationProviderData( - ...update - ), - orderVoid: getMutationProviderData( - ...orderVoid - ) - }) - } - + ) => + children( + { + orderAddNote: getMutationProviderData( + ...addNote + ), + orderCancel: getMutationProviderData( + ...orderCancel + ), + orderDraftCancel: getMutationProviderData( + ...cancelDraft + ), + orderDraftFinalize: getMutationProviderData( + ...finalizeDraft + ), + orderDraftUpdate: getMutationProviderData( + ...updateDraft + ), + orderFulfillmentApprove: getMutationProviderData( + ...approveFulfillment + ), + orderFulfillmentCancel: getMutationProviderData( + ...cancelFulfillment + ), + orderFulfillmentUpdateTracking: getMutationProviderData( + ...updateTrackingNumber + ), + orderInvoiceRequest: getMutationProviderData( + ...invoiceRequest + ), + orderInvoiceSend: getMutationProviderData( + ...invoiceEmailSend + ), + orderLineDelete: getMutationProviderData( + ...deleteOrderLine + ), + orderLineUpdate: getMutationProviderData( + ...updateOrderLine + ), + orderLinesAdd: getMutationProviderData( + ...addOrderLine + ), + orderPaymentCapture: getMutationProviderData( + ...paymentCapture + ), + orderPaymentMarkAsPaid: getMutationProviderData( + ...markAsPaid + ), + orderShippingMethodUpdate: getMutationProviderData( + ...updateShippingMethod + ), + orderUpdate: getMutationProviderData( + ...update + ), + orderVoid: getMutationProviderData( + ...orderVoid + ) + } + ) + } + + )} + )} - + )} - + )} - + )} - + )} - + )} - + )} )} diff --git a/src/orders/fixtures.ts b/src/orders/fixtures.ts index d7eb4b62a..5a3f76f6f 100644 --- a/src/orders/fixtures.ts +++ b/src/orders/fixtures.ts @@ -1,6 +1,7 @@ import { ShopInfo_shop_countries } from "@saleor/components/Shop/types/ShopInfo"; import { InvoiceFragment } from "@saleor/fragments/types/InvoiceFragment"; import { OrderSettingsFragment } from "@saleor/fragments/types/OrderSettingsFragment"; +import { ShopOrderSettingsFragment } from "@saleor/fragments/types/ShopOrderSettingsFragment"; import { SearchCustomers_search_edges_node } from "@saleor/searches/types/SearchCustomers"; import { warehouseList } from "@saleor/warehouses/fixtures"; import { MessageDescriptor } from "react-intl"; @@ -13,12 +14,28 @@ import { OrderEventsEmailsEnum, OrderEventsEnum, OrderStatus, - PaymentChargeStatusEnum + PaymentChargeStatusEnum, + WeightUnitsEnum } from "../types/globalTypes"; -import { OrderDetails_order } from "./types/OrderDetails"; +import { OrderDetails_order, OrderDetails_shop } from "./types/OrderDetails"; import { OrderList_orders_edges_node } from "./types/OrderList"; import { SearchOrderVariant_search_edges_node } from "./types/SearchOrderVariant"; +export const countries: ShopInfo_shop_countries[] = [ + { __typename: "CountryDisplay", code: "AF", country: "Afghanistan" }, + { __typename: "CountryDisplay", code: "AX", country: "Åland Islands" }, + { __typename: "CountryDisplay", code: "AL", country: "Albania" }, + { __typename: "CountryDisplay", code: "DZ", country: "Algeria" }, + { __typename: "CountryDisplay", code: "AS", country: "American Samoa" } +]; +export const shop: OrderDetails_shop = { + __typename: "Shop", + countries, + defaultWeightUnit: WeightUnitsEnum.KG, + fulfillmentAllowUnpaid: true, + fulfillmentAutoApprove: true +}; + export const clients: SearchCustomers_search_edges_node[] = [ { __typename: "User" as "User", @@ -1024,6 +1041,7 @@ export const order = (placeholder: string): OrderDetails_order => ({ productSku: "5-1337", quantity: 2, quantityFulfilled: 2, + quantityToFulfill: 0, thumbnail: { __typename: "Image" as "Image", url: placeholder @@ -1092,6 +1110,7 @@ export const order = (placeholder: string): OrderDetails_order => ({ productSku: "5-1337", quantity: 2, quantityFulfilled: 2, + quantityToFulfill: 0, thumbnail: { __typename: "Image" as "Image", url: placeholder @@ -1167,6 +1186,7 @@ export const order = (placeholder: string): OrderDetails_order => ({ productSku: "59-1337", quantity: 3, quantityFulfilled: 0, + quantityToFulfill: 3, thumbnail: { __typename: "Image" as "Image", url: placeholder @@ -1220,6 +1240,7 @@ export const order = (placeholder: string): OrderDetails_order => ({ productSku: "5-1337", quantity: 2, quantityFulfilled: 2, + quantityToFulfill: 0, thumbnail: { __typename: "Image" as "Image", url: placeholder @@ -1405,6 +1426,7 @@ export const draftOrder = (placeholder: string): OrderDetails_order => ({ productSku: "58-1338", quantity: 2, quantityFulfilled: 0, + quantityToFulfill: 2, thumbnail: { __typename: "Image" as "Image", url: placeholder @@ -1458,6 +1480,7 @@ export const draftOrder = (placeholder: string): OrderDetails_order => ({ productSku: "15-1337", quantity: 2, quantityFulfilled: 0, + quantityToFulfill: 2, thumbnail: { __typename: "Image" as "Image", url: placeholder @@ -1588,13 +1611,6 @@ export const variants = [ { id: "p7", name: "Product 5: variant 2", sku: "14345", stockQuantity: 11 } ]; export const prefixes = ["01", "02", "41", "49"]; -export const countries: ShopInfo_shop_countries[] = [ - { __typename: "CountryDisplay", code: "AF", country: "Afghanistan" }, - { __typename: "CountryDisplay", code: "AX", country: "Åland Islands" }, - { __typename: "CountryDisplay", code: "AL", country: "Albania" }, - { __typename: "CountryDisplay", code: "DZ", country: "Algeria" }, - { __typename: "CountryDisplay", code: "AS", country: "American Samoa" } -]; export const shippingMethods = [ { country: "whole world", id: "s1", name: "DHL", price: {} }, { country: "Afghanistan", id: "s2", name: "UPS" } @@ -1897,3 +1913,9 @@ export const orderSettings: OrderSettingsFragment = { __typename: "OrderSettings", automaticallyConfirmAllNewOrders: true }; + +export const shopOrderSettings: ShopOrderSettingsFragment = { + __typename: "Shop", + fulfillmentAutoApprove: true, + fulfillmentAllowUnpaid: true +}; diff --git a/src/orders/mutations.ts b/src/orders/mutations.ts index b7859f5b9..0b47685fd 100644 --- a/src/orders/mutations.ts +++ b/src/orders/mutations.ts @@ -1,12 +1,14 @@ import { invoiceErrorFragment, orderErrorFragment, - orderSettingsErrorFragment + orderSettingsErrorFragment, + shopErrorFragment } from "@saleor/fragments/errors"; import { fragmentOrderDetails, fragmentOrderEvent, fragmentOrderSettings, + fragmentShopOrderSettings, fulfillmentFragment, invoiceFragment } from "@saleor/fragments/orders"; @@ -63,6 +65,10 @@ import { OrderDraftUpdate, OrderDraftUpdateVariables } from "./types/OrderDraftUpdate"; +import { + OrderFulfillmentApprove, + OrderFulfillmentApproveVariables +} from "./types/OrderFulfillmentApprove"; import { OrderFulfillmentCancel, OrderFulfillmentCancelVariables @@ -461,6 +467,25 @@ export const TypedOrderFulfillmentUpdateTrackingMutation = TypedMutation< OrderFulfillmentUpdateTrackingVariables >(orderFulfillmentUpdateTrackingMutation); +const orderFulfillmentApproveMutation = gql` + ${fragmentOrderDetails} + ${orderErrorFragment} + mutation OrderFulfillmentApprove($id: ID!, $notifyCustomer: Boolean!) { + orderFulfillmentApprove(id: $id, notifyCustomer: $notifyCustomer) { + errors { + ...OrderErrorFragment + } + order { + ...OrderDetailsFragment + } + } + } +`; +export const TypedOrderFulfillmentApproveMutation = TypedMutation< + OrderFulfillmentApprove, + OrderFulfillmentApproveVariables +>(orderFulfillmentApproveMutation); + const orderFulfillmentCancelMutation = gql` ${fragmentOrderDetails} ${orderErrorFragment} @@ -734,9 +759,14 @@ export const TypedInvoiceEmailSendMutation = TypedMutation< const orderSettingsUpdateMutation = gql` ${fragmentOrderSettings} + ${fragmentShopOrderSettings} ${orderSettingsErrorFragment} - mutation OrderSettingsUpdate($input: OrderSettingsUpdateInput!) { - orderSettingsUpdate(input: $input) { + ${shopErrorFragment} + mutation OrderSettingsUpdate( + $orderSettingsInput: OrderSettingsUpdateInput! + $shopSettingsInput: ShopSettingsInput! + ) { + orderSettingsUpdate(input: $orderSettingsInput) { errors { ...OrderSettingsErrorFragment } @@ -744,6 +774,14 @@ const orderSettingsUpdateMutation = gql` ...OrderSettingsFragment } } + shopSettingsUpdate(input: $shopSettingsInput) { + errors { + ...ShopErrorFragment + } + shop { + ...ShopOrderSettingsFragment + } + } } `; export const useOrderSettingsUpdateMutation = makeMutation< diff --git a/src/orders/queries.ts b/src/orders/queries.ts index 875837259..5c508d3b6 100644 --- a/src/orders/queries.ts +++ b/src/orders/queries.ts @@ -2,9 +2,11 @@ import { fragmentAddress } from "@saleor/fragments/address"; import { fragmentOrderDetails, fragmentOrderSettings, - fragmentRefundOrderLine + fragmentRefundOrderLine, + fragmentShopOrderSettings } from "@saleor/fragments/orders"; import { fragmentMoney } from "@saleor/fragments/products"; +import { warehouseFragment } from "@saleor/fragments/warehouses"; import makeQuery from "@saleor/hooks/makeQuery"; import makeTopLevelSearch from "@saleor/hooks/makeTopLevelSearch"; import gql from "graphql-tag"; @@ -19,6 +21,7 @@ import { OrderFulfillData, OrderFulfillDataVariables } from "./types/OrderFulfillData"; +import { OrderFulfillSettings } from "./types/OrderFulfillSettings"; import { OrderList, OrderListVariables } from "./types/OrderList"; import { OrderRefundData, @@ -150,6 +153,8 @@ export const orderDetailsQuery = gql` country } defaultWeightUnit + fulfillmentAllowUnpaid + fulfillmentAutoApprove } } `; @@ -217,9 +222,11 @@ export const useOrderVariantSearch = makeTopLevelSearch< >(searchOrderVariant); const orderFulfillData = gql` + ${warehouseFragment} query OrderFulfillData($orderId: ID!) { order(id: $orderId) { id + isPaid lines { id isShippingRequired @@ -232,6 +239,7 @@ const orderFulfillData = gql` } } quantityFulfilled + quantityToFulfill variant { id name @@ -245,7 +253,7 @@ const orderFulfillData = gql` stocks { id warehouse { - id + ...WarehouseFragment } quantity quantityAllocated @@ -265,12 +273,29 @@ export const useOrderFulfillData = makeQuery< OrderFulfillDataVariables >(orderFulfillData); +export const orderFulfillSettingsQuery = gql` + ${fragmentShopOrderSettings} + query OrderFulfillSettings { + shop { + ...ShopOrderSettingsFragment + } + } +`; +export const useOrderFulfillSettingsQuery = makeQuery< + OrderFulfillSettings, + never +>(orderFulfillSettingsQuery); + export const orderSettingsQuery = gql` ${fragmentOrderSettings} + ${fragmentShopOrderSettings} query OrderSettings { orderSettings { ...OrderSettingsFragment } + shop { + ...ShopOrderSettingsFragment + } } `; export const useOrderSettingsQuery = makeQuery( @@ -299,7 +324,7 @@ const orderRefundData = gql` } lines { ...RefundOrderLineFragment - quantityFulfilled + quantityToFulfill } fulfillments { id diff --git a/src/orders/types/FulfillOrder.ts b/src/orders/types/FulfillOrder.ts index b794b9d52..0434f003a 100644 --- a/src/orders/types/FulfillOrder.ts +++ b/src/orders/types/FulfillOrder.ts @@ -225,6 +225,7 @@ export interface FulfillOrder_orderFulfill_order_fulfillments_lines_orderLine { productSku: string; quantity: number; quantityFulfilled: number; + quantityToFulfill: number; unitDiscount: FulfillOrder_orderFulfill_order_fulfillments_lines_orderLine_unitDiscount; unitDiscountValue: any; unitDiscountReason: string | null; @@ -320,6 +321,7 @@ export interface FulfillOrder_orderFulfill_order_lines { productSku: string; quantity: number; quantityFulfilled: number; + quantityToFulfill: number; unitDiscount: FulfillOrder_orderFulfill_order_lines_unitDiscount; unitDiscountValue: any; unitDiscountReason: string | null; @@ -492,6 +494,7 @@ export interface FulfillOrder_orderFulfill_order { fulfillments: (FulfillOrder_orderFulfill_order_fulfillments | null)[]; lines: (FulfillOrder_orderFulfill_order_lines | null)[]; number: string | null; + isPaid: boolean; paymentStatus: PaymentChargeStatusEnum; shippingAddress: FulfillOrder_orderFulfill_order_shippingAddress | null; shippingMethod: FulfillOrder_orderFulfill_order_shippingMethod | null; @@ -509,7 +512,6 @@ export interface FulfillOrder_orderFulfill_order { availableShippingMethods: (FulfillOrder_orderFulfill_order_availableShippingMethods | null)[] | null; invoices: (FulfillOrder_orderFulfill_order_invoices | null)[] | null; channel: FulfillOrder_orderFulfill_order_channel; - isPaid: boolean; } export interface FulfillOrder_orderFulfill { diff --git a/src/orders/types/OrderCancel.ts b/src/orders/types/OrderCancel.ts index ee93337aa..905752175 100644 --- a/src/orders/types/OrderCancel.ts +++ b/src/orders/types/OrderCancel.ts @@ -223,6 +223,7 @@ export interface OrderCancel_orderCancel_order_fulfillments_lines_orderLine { productSku: string; quantity: number; quantityFulfilled: number; + quantityToFulfill: number; unitDiscount: OrderCancel_orderCancel_order_fulfillments_lines_orderLine_unitDiscount; unitDiscountValue: any; unitDiscountReason: string | null; @@ -318,6 +319,7 @@ export interface OrderCancel_orderCancel_order_lines { productSku: string; quantity: number; quantityFulfilled: number; + quantityToFulfill: number; unitDiscount: OrderCancel_orderCancel_order_lines_unitDiscount; unitDiscountValue: any; unitDiscountReason: string | null; @@ -490,6 +492,7 @@ export interface OrderCancel_orderCancel_order { fulfillments: (OrderCancel_orderCancel_order_fulfillments | null)[]; lines: (OrderCancel_orderCancel_order_lines | null)[]; number: string | null; + isPaid: boolean; paymentStatus: PaymentChargeStatusEnum; shippingAddress: OrderCancel_orderCancel_order_shippingAddress | null; shippingMethod: OrderCancel_orderCancel_order_shippingMethod | null; @@ -507,7 +510,6 @@ export interface OrderCancel_orderCancel_order { availableShippingMethods: (OrderCancel_orderCancel_order_availableShippingMethods | null)[] | null; invoices: (OrderCancel_orderCancel_order_invoices | null)[] | null; channel: OrderCancel_orderCancel_order_channel; - isPaid: boolean; } export interface OrderCancel_orderCancel { diff --git a/src/orders/types/OrderCapture.ts b/src/orders/types/OrderCapture.ts index 24054ca01..65d01a50f 100644 --- a/src/orders/types/OrderCapture.ts +++ b/src/orders/types/OrderCapture.ts @@ -223,6 +223,7 @@ export interface OrderCapture_orderCapture_order_fulfillments_lines_orderLine { productSku: string; quantity: number; quantityFulfilled: number; + quantityToFulfill: number; unitDiscount: OrderCapture_orderCapture_order_fulfillments_lines_orderLine_unitDiscount; unitDiscountValue: any; unitDiscountReason: string | null; @@ -318,6 +319,7 @@ export interface OrderCapture_orderCapture_order_lines { productSku: string; quantity: number; quantityFulfilled: number; + quantityToFulfill: number; unitDiscount: OrderCapture_orderCapture_order_lines_unitDiscount; unitDiscountValue: any; unitDiscountReason: string | null; @@ -490,6 +492,7 @@ export interface OrderCapture_orderCapture_order { fulfillments: (OrderCapture_orderCapture_order_fulfillments | null)[]; lines: (OrderCapture_orderCapture_order_lines | null)[]; number: string | null; + isPaid: boolean; paymentStatus: PaymentChargeStatusEnum; shippingAddress: OrderCapture_orderCapture_order_shippingAddress | null; shippingMethod: OrderCapture_orderCapture_order_shippingMethod | null; @@ -507,7 +510,6 @@ export interface OrderCapture_orderCapture_order { availableShippingMethods: (OrderCapture_orderCapture_order_availableShippingMethods | null)[] | null; invoices: (OrderCapture_orderCapture_order_invoices | null)[] | null; channel: OrderCapture_orderCapture_order_channel; - isPaid: boolean; } export interface OrderCapture_orderCapture { diff --git a/src/orders/types/OrderConfirm.ts b/src/orders/types/OrderConfirm.ts index 829e37cda..56b86433a 100644 --- a/src/orders/types/OrderConfirm.ts +++ b/src/orders/types/OrderConfirm.ts @@ -223,6 +223,7 @@ export interface OrderConfirm_orderConfirm_order_fulfillments_lines_orderLine { productSku: string; quantity: number; quantityFulfilled: number; + quantityToFulfill: number; unitDiscount: OrderConfirm_orderConfirm_order_fulfillments_lines_orderLine_unitDiscount; unitDiscountValue: any; unitDiscountReason: string | null; @@ -318,6 +319,7 @@ export interface OrderConfirm_orderConfirm_order_lines { productSku: string; quantity: number; quantityFulfilled: number; + quantityToFulfill: number; unitDiscount: OrderConfirm_orderConfirm_order_lines_unitDiscount; unitDiscountValue: any; unitDiscountReason: string | null; @@ -490,6 +492,7 @@ export interface OrderConfirm_orderConfirm_order { fulfillments: (OrderConfirm_orderConfirm_order_fulfillments | null)[]; lines: (OrderConfirm_orderConfirm_order_lines | null)[]; number: string | null; + isPaid: boolean; paymentStatus: PaymentChargeStatusEnum; shippingAddress: OrderConfirm_orderConfirm_order_shippingAddress | null; shippingMethod: OrderConfirm_orderConfirm_order_shippingMethod | null; @@ -507,7 +510,6 @@ export interface OrderConfirm_orderConfirm_order { availableShippingMethods: (OrderConfirm_orderConfirm_order_availableShippingMethods | null)[] | null; invoices: (OrderConfirm_orderConfirm_order_invoices | null)[] | null; channel: OrderConfirm_orderConfirm_order_channel; - isPaid: boolean; } export interface OrderConfirm_orderConfirm { diff --git a/src/orders/types/OrderDetails.ts b/src/orders/types/OrderDetails.ts index 44f534eb4..0211de638 100644 --- a/src/orders/types/OrderDetails.ts +++ b/src/orders/types/OrderDetails.ts @@ -216,6 +216,7 @@ export interface OrderDetails_order_fulfillments_lines_orderLine { productSku: string; quantity: number; quantityFulfilled: number; + quantityToFulfill: number; unitDiscount: OrderDetails_order_fulfillments_lines_orderLine_unitDiscount; unitDiscountValue: any; unitDiscountReason: string | null; @@ -311,6 +312,7 @@ export interface OrderDetails_order_lines { productSku: string; quantity: number; quantityFulfilled: number; + quantityToFulfill: number; unitDiscount: OrderDetails_order_lines_unitDiscount; unitDiscountValue: any; unitDiscountReason: string | null; @@ -483,6 +485,7 @@ export interface OrderDetails_order { fulfillments: (OrderDetails_order_fulfillments | null)[]; lines: (OrderDetails_order_lines | null)[]; number: string | null; + isPaid: boolean; paymentStatus: PaymentChargeStatusEnum; shippingAddress: OrderDetails_order_shippingAddress | null; shippingMethod: OrderDetails_order_shippingMethod | null; @@ -500,7 +503,6 @@ export interface OrderDetails_order { availableShippingMethods: (OrderDetails_order_availableShippingMethods | null)[] | null; invoices: (OrderDetails_order_invoices | null)[] | null; channel: OrderDetails_order_channel; - isPaid: boolean; } export interface OrderDetails_shop_countries { @@ -513,6 +515,8 @@ export interface OrderDetails_shop { __typename: "Shop"; countries: OrderDetails_shop_countries[]; defaultWeightUnit: WeightUnitsEnum | null; + fulfillmentAllowUnpaid: boolean; + fulfillmentAutoApprove: boolean; } export interface OrderDetails { diff --git a/src/orders/types/OrderDiscountAdd.ts b/src/orders/types/OrderDiscountAdd.ts index b50626dc0..5a29e4fd7 100644 --- a/src/orders/types/OrderDiscountAdd.ts +++ b/src/orders/types/OrderDiscountAdd.ts @@ -223,6 +223,7 @@ export interface OrderDiscountAdd_orderDiscountAdd_order_fulfillments_lines_orde productSku: string; quantity: number; quantityFulfilled: number; + quantityToFulfill: number; unitDiscount: OrderDiscountAdd_orderDiscountAdd_order_fulfillments_lines_orderLine_unitDiscount; unitDiscountValue: any; unitDiscountReason: string | null; @@ -318,6 +319,7 @@ export interface OrderDiscountAdd_orderDiscountAdd_order_lines { productSku: string; quantity: number; quantityFulfilled: number; + quantityToFulfill: number; unitDiscount: OrderDiscountAdd_orderDiscountAdd_order_lines_unitDiscount; unitDiscountValue: any; unitDiscountReason: string | null; @@ -490,6 +492,7 @@ export interface OrderDiscountAdd_orderDiscountAdd_order { fulfillments: (OrderDiscountAdd_orderDiscountAdd_order_fulfillments | null)[]; lines: (OrderDiscountAdd_orderDiscountAdd_order_lines | null)[]; number: string | null; + isPaid: boolean; paymentStatus: PaymentChargeStatusEnum; shippingAddress: OrderDiscountAdd_orderDiscountAdd_order_shippingAddress | null; shippingMethod: OrderDiscountAdd_orderDiscountAdd_order_shippingMethod | null; @@ -507,7 +510,6 @@ export interface OrderDiscountAdd_orderDiscountAdd_order { availableShippingMethods: (OrderDiscountAdd_orderDiscountAdd_order_availableShippingMethods | null)[] | null; invoices: (OrderDiscountAdd_orderDiscountAdd_order_invoices | null)[] | null; channel: OrderDiscountAdd_orderDiscountAdd_order_channel; - isPaid: boolean; } export interface OrderDiscountAdd_orderDiscountAdd { diff --git a/src/orders/types/OrderDiscountDelete.ts b/src/orders/types/OrderDiscountDelete.ts index fa1f8096e..61a5e5005 100644 --- a/src/orders/types/OrderDiscountDelete.ts +++ b/src/orders/types/OrderDiscountDelete.ts @@ -223,6 +223,7 @@ export interface OrderDiscountDelete_orderDiscountDelete_order_fulfillments_line productSku: string; quantity: number; quantityFulfilled: number; + quantityToFulfill: number; unitDiscount: OrderDiscountDelete_orderDiscountDelete_order_fulfillments_lines_orderLine_unitDiscount; unitDiscountValue: any; unitDiscountReason: string | null; @@ -318,6 +319,7 @@ export interface OrderDiscountDelete_orderDiscountDelete_order_lines { productSku: string; quantity: number; quantityFulfilled: number; + quantityToFulfill: number; unitDiscount: OrderDiscountDelete_orderDiscountDelete_order_lines_unitDiscount; unitDiscountValue: any; unitDiscountReason: string | null; @@ -490,6 +492,7 @@ export interface OrderDiscountDelete_orderDiscountDelete_order { fulfillments: (OrderDiscountDelete_orderDiscountDelete_order_fulfillments | null)[]; lines: (OrderDiscountDelete_orderDiscountDelete_order_lines | null)[]; number: string | null; + isPaid: boolean; paymentStatus: PaymentChargeStatusEnum; shippingAddress: OrderDiscountDelete_orderDiscountDelete_order_shippingAddress | null; shippingMethod: OrderDiscountDelete_orderDiscountDelete_order_shippingMethod | null; @@ -507,7 +510,6 @@ export interface OrderDiscountDelete_orderDiscountDelete_order { availableShippingMethods: (OrderDiscountDelete_orderDiscountDelete_order_availableShippingMethods | null)[] | null; invoices: (OrderDiscountDelete_orderDiscountDelete_order_invoices | null)[] | null; channel: OrderDiscountDelete_orderDiscountDelete_order_channel; - isPaid: boolean; } export interface OrderDiscountDelete_orderDiscountDelete { diff --git a/src/orders/types/OrderDiscountUpdate.ts b/src/orders/types/OrderDiscountUpdate.ts index 3c7895bcf..6f3d299b6 100644 --- a/src/orders/types/OrderDiscountUpdate.ts +++ b/src/orders/types/OrderDiscountUpdate.ts @@ -223,6 +223,7 @@ export interface OrderDiscountUpdate_orderDiscountUpdate_order_fulfillments_line productSku: string; quantity: number; quantityFulfilled: number; + quantityToFulfill: number; unitDiscount: OrderDiscountUpdate_orderDiscountUpdate_order_fulfillments_lines_orderLine_unitDiscount; unitDiscountValue: any; unitDiscountReason: string | null; @@ -318,6 +319,7 @@ export interface OrderDiscountUpdate_orderDiscountUpdate_order_lines { productSku: string; quantity: number; quantityFulfilled: number; + quantityToFulfill: number; unitDiscount: OrderDiscountUpdate_orderDiscountUpdate_order_lines_unitDiscount; unitDiscountValue: any; unitDiscountReason: string | null; @@ -490,6 +492,7 @@ export interface OrderDiscountUpdate_orderDiscountUpdate_order { fulfillments: (OrderDiscountUpdate_orderDiscountUpdate_order_fulfillments | null)[]; lines: (OrderDiscountUpdate_orderDiscountUpdate_order_lines | null)[]; number: string | null; + isPaid: boolean; paymentStatus: PaymentChargeStatusEnum; shippingAddress: OrderDiscountUpdate_orderDiscountUpdate_order_shippingAddress | null; shippingMethod: OrderDiscountUpdate_orderDiscountUpdate_order_shippingMethod | null; @@ -507,7 +510,6 @@ export interface OrderDiscountUpdate_orderDiscountUpdate_order { availableShippingMethods: (OrderDiscountUpdate_orderDiscountUpdate_order_availableShippingMethods | null)[] | null; invoices: (OrderDiscountUpdate_orderDiscountUpdate_order_invoices | null)[] | null; channel: OrderDiscountUpdate_orderDiscountUpdate_order_channel; - isPaid: boolean; } export interface OrderDiscountUpdate_orderDiscountUpdate { diff --git a/src/orders/types/OrderDraftCancel.ts b/src/orders/types/OrderDraftCancel.ts index b38cab841..9911df654 100644 --- a/src/orders/types/OrderDraftCancel.ts +++ b/src/orders/types/OrderDraftCancel.ts @@ -223,6 +223,7 @@ export interface OrderDraftCancel_draftOrderDelete_order_fulfillments_lines_orde productSku: string; quantity: number; quantityFulfilled: number; + quantityToFulfill: number; unitDiscount: OrderDraftCancel_draftOrderDelete_order_fulfillments_lines_orderLine_unitDiscount; unitDiscountValue: any; unitDiscountReason: string | null; @@ -318,6 +319,7 @@ export interface OrderDraftCancel_draftOrderDelete_order_lines { productSku: string; quantity: number; quantityFulfilled: number; + quantityToFulfill: number; unitDiscount: OrderDraftCancel_draftOrderDelete_order_lines_unitDiscount; unitDiscountValue: any; unitDiscountReason: string | null; @@ -490,6 +492,7 @@ export interface OrderDraftCancel_draftOrderDelete_order { fulfillments: (OrderDraftCancel_draftOrderDelete_order_fulfillments | null)[]; lines: (OrderDraftCancel_draftOrderDelete_order_lines | null)[]; number: string | null; + isPaid: boolean; paymentStatus: PaymentChargeStatusEnum; shippingAddress: OrderDraftCancel_draftOrderDelete_order_shippingAddress | null; shippingMethod: OrderDraftCancel_draftOrderDelete_order_shippingMethod | null; @@ -507,7 +510,6 @@ export interface OrderDraftCancel_draftOrderDelete_order { availableShippingMethods: (OrderDraftCancel_draftOrderDelete_order_availableShippingMethods | null)[] | null; invoices: (OrderDraftCancel_draftOrderDelete_order_invoices | null)[] | null; channel: OrderDraftCancel_draftOrderDelete_order_channel; - isPaid: boolean; } export interface OrderDraftCancel_draftOrderDelete { diff --git a/src/orders/types/OrderDraftFinalize.ts b/src/orders/types/OrderDraftFinalize.ts index 97c7efebf..0320a23f2 100644 --- a/src/orders/types/OrderDraftFinalize.ts +++ b/src/orders/types/OrderDraftFinalize.ts @@ -223,6 +223,7 @@ export interface OrderDraftFinalize_draftOrderComplete_order_fulfillments_lines_ productSku: string; quantity: number; quantityFulfilled: number; + quantityToFulfill: number; unitDiscount: OrderDraftFinalize_draftOrderComplete_order_fulfillments_lines_orderLine_unitDiscount; unitDiscountValue: any; unitDiscountReason: string | null; @@ -318,6 +319,7 @@ export interface OrderDraftFinalize_draftOrderComplete_order_lines { productSku: string; quantity: number; quantityFulfilled: number; + quantityToFulfill: number; unitDiscount: OrderDraftFinalize_draftOrderComplete_order_lines_unitDiscount; unitDiscountValue: any; unitDiscountReason: string | null; @@ -490,6 +492,7 @@ export interface OrderDraftFinalize_draftOrderComplete_order { fulfillments: (OrderDraftFinalize_draftOrderComplete_order_fulfillments | null)[]; lines: (OrderDraftFinalize_draftOrderComplete_order_lines | null)[]; number: string | null; + isPaid: boolean; paymentStatus: PaymentChargeStatusEnum; shippingAddress: OrderDraftFinalize_draftOrderComplete_order_shippingAddress | null; shippingMethod: OrderDraftFinalize_draftOrderComplete_order_shippingMethod | null; @@ -507,7 +510,6 @@ export interface OrderDraftFinalize_draftOrderComplete_order { availableShippingMethods: (OrderDraftFinalize_draftOrderComplete_order_availableShippingMethods | null)[] | null; invoices: (OrderDraftFinalize_draftOrderComplete_order_invoices | null)[] | null; channel: OrderDraftFinalize_draftOrderComplete_order_channel; - isPaid: boolean; } export interface OrderDraftFinalize_draftOrderComplete { diff --git a/src/orders/types/OrderDraftUpdate.ts b/src/orders/types/OrderDraftUpdate.ts index 51a681446..d6dc80f2e 100644 --- a/src/orders/types/OrderDraftUpdate.ts +++ b/src/orders/types/OrderDraftUpdate.ts @@ -223,6 +223,7 @@ export interface OrderDraftUpdate_draftOrderUpdate_order_fulfillments_lines_orde productSku: string; quantity: number; quantityFulfilled: number; + quantityToFulfill: number; unitDiscount: OrderDraftUpdate_draftOrderUpdate_order_fulfillments_lines_orderLine_unitDiscount; unitDiscountValue: any; unitDiscountReason: string | null; @@ -318,6 +319,7 @@ export interface OrderDraftUpdate_draftOrderUpdate_order_lines { productSku: string; quantity: number; quantityFulfilled: number; + quantityToFulfill: number; unitDiscount: OrderDraftUpdate_draftOrderUpdate_order_lines_unitDiscount; unitDiscountValue: any; unitDiscountReason: string | null; @@ -490,6 +492,7 @@ export interface OrderDraftUpdate_draftOrderUpdate_order { fulfillments: (OrderDraftUpdate_draftOrderUpdate_order_fulfillments | null)[]; lines: (OrderDraftUpdate_draftOrderUpdate_order_lines | null)[]; number: string | null; + isPaid: boolean; paymentStatus: PaymentChargeStatusEnum; shippingAddress: OrderDraftUpdate_draftOrderUpdate_order_shippingAddress | null; shippingMethod: OrderDraftUpdate_draftOrderUpdate_order_shippingMethod | null; @@ -507,7 +510,6 @@ export interface OrderDraftUpdate_draftOrderUpdate_order { availableShippingMethods: (OrderDraftUpdate_draftOrderUpdate_order_availableShippingMethods | null)[] | null; invoices: (OrderDraftUpdate_draftOrderUpdate_order_invoices | null)[] | null; channel: OrderDraftUpdate_draftOrderUpdate_order_channel; - isPaid: boolean; } export interface OrderDraftUpdate_draftOrderUpdate { diff --git a/src/orders/types/OrderFulfillData.ts b/src/orders/types/OrderFulfillData.ts index 844ea15aa..905c1ec43 100644 --- a/src/orders/types/OrderFulfillData.ts +++ b/src/orders/types/OrderFulfillData.ts @@ -32,6 +32,7 @@ export interface OrderFulfillData_order_lines_variant_attributes { export interface OrderFulfillData_order_lines_variant_stocks_warehouse { __typename: "Warehouse"; id: string; + name: string; } export interface OrderFulfillData_order_lines_variant_stocks { @@ -65,6 +66,7 @@ export interface OrderFulfillData_order_lines { quantity: number; allocations: OrderFulfillData_order_lines_allocations[] | null; quantityFulfilled: number; + quantityToFulfill: number; variant: OrderFulfillData_order_lines_variant | null; thumbnail: OrderFulfillData_order_lines_thumbnail | null; } @@ -72,6 +74,7 @@ export interface OrderFulfillData_order_lines { export interface OrderFulfillData_order { __typename: "Order"; id: string; + isPaid: boolean; lines: (OrderFulfillData_order_lines | null)[]; number: string | null; } diff --git a/src/orders/types/OrderFulfillSettings.ts b/src/orders/types/OrderFulfillSettings.ts new file mode 100644 index 000000000..d8e633c4f --- /dev/null +++ b/src/orders/types/OrderFulfillSettings.ts @@ -0,0 +1,18 @@ +/* tslint:disable */ +/* eslint-disable */ +// @generated +// This file was automatically generated and should not be edited. + +// ==================================================== +// GraphQL query operation: OrderFulfillSettings +// ==================================================== + +export interface OrderFulfillSettings_shop { + __typename: "Shop"; + fulfillmentAutoApprove: boolean; + fulfillmentAllowUnpaid: boolean; +} + +export interface OrderFulfillSettings { + shop: OrderFulfillSettings_shop; +} diff --git a/src/orders/types/OrderFulfillmentApprove.ts b/src/orders/types/OrderFulfillmentApprove.ts new file mode 100644 index 000000000..6daf28b44 --- /dev/null +++ b/src/orders/types/OrderFulfillmentApprove.ts @@ -0,0 +1,528 @@ +/* tslint:disable */ +/* eslint-disable */ +// @generated +// This file was automatically generated and should not be edited. + +import { OrderErrorCode, AddressTypeEnum, OrderDiscountType, DiscountValueTypeEnum, OrderEventsEmailsEnum, OrderEventsEnum, FulfillmentStatus, PaymentChargeStatusEnum, OrderStatus, OrderAction, JobStatusEnum } from "./../../types/globalTypes"; + +// ==================================================== +// GraphQL mutation operation: OrderFulfillmentApprove +// ==================================================== + +export interface OrderFulfillmentApprove_orderFulfillmentApprove_errors { + __typename: "OrderError"; + code: OrderErrorCode; + field: string | null; + addressType: AddressTypeEnum | null; +} + +export interface OrderFulfillmentApprove_orderFulfillmentApprove_order_metadata { + __typename: "MetadataItem"; + key: string; + value: string; +} + +export interface OrderFulfillmentApprove_orderFulfillmentApprove_order_privateMetadata { + __typename: "MetadataItem"; + key: string; + value: string; +} + +export interface OrderFulfillmentApprove_orderFulfillmentApprove_order_billingAddress_country { + __typename: "CountryDisplay"; + code: string; + country: string; +} + +export interface OrderFulfillmentApprove_orderFulfillmentApprove_order_billingAddress { + __typename: "Address"; + city: string; + cityArea: string; + companyName: string; + country: OrderFulfillmentApprove_orderFulfillmentApprove_order_billingAddress_country; + countryArea: string; + firstName: string; + id: string; + lastName: string; + phone: string | null; + postalCode: string; + streetAddress1: string; + streetAddress2: string; +} + +export interface OrderFulfillmentApprove_orderFulfillmentApprove_order_discounts_amount { + __typename: "Money"; + amount: number; + currency: string; +} + +export interface OrderFulfillmentApprove_orderFulfillmentApprove_order_discounts { + __typename: "OrderDiscount"; + id: string; + type: OrderDiscountType; + calculationMode: DiscountValueTypeEnum; + value: any; + reason: string | null; + amount: OrderFulfillmentApprove_orderFulfillmentApprove_order_discounts_amount; +} + +export interface OrderFulfillmentApprove_orderFulfillmentApprove_order_events_discount_amount { + __typename: "Money"; + amount: number; + currency: string; +} + +export interface OrderFulfillmentApprove_orderFulfillmentApprove_order_events_discount_oldAmount { + __typename: "Money"; + amount: number; + currency: string; +} + +export interface OrderFulfillmentApprove_orderFulfillmentApprove_order_events_discount { + __typename: "OrderEventDiscountObject"; + valueType: DiscountValueTypeEnum; + value: any; + reason: string | null; + amount: OrderFulfillmentApprove_orderFulfillmentApprove_order_events_discount_amount | null; + oldValueType: DiscountValueTypeEnum | null; + oldValue: any | null; + oldAmount: OrderFulfillmentApprove_orderFulfillmentApprove_order_events_discount_oldAmount | null; +} + +export interface OrderFulfillmentApprove_orderFulfillmentApprove_order_events_relatedOrder { + __typename: "Order"; + id: string; + number: string | null; +} + +export interface OrderFulfillmentApprove_orderFulfillmentApprove_order_events_user { + __typename: "User"; + id: string; + email: string; + firstName: string; + lastName: string; +} + +export interface OrderFulfillmentApprove_orderFulfillmentApprove_order_events_lines_discount_amount { + __typename: "Money"; + amount: number; + currency: string; +} + +export interface OrderFulfillmentApprove_orderFulfillmentApprove_order_events_lines_discount_oldAmount { + __typename: "Money"; + amount: number; + currency: string; +} + +export interface OrderFulfillmentApprove_orderFulfillmentApprove_order_events_lines_discount { + __typename: "OrderEventDiscountObject"; + valueType: DiscountValueTypeEnum; + value: any; + reason: string | null; + amount: OrderFulfillmentApprove_orderFulfillmentApprove_order_events_lines_discount_amount | null; + oldValueType: DiscountValueTypeEnum | null; + oldValue: any | null; + oldAmount: OrderFulfillmentApprove_orderFulfillmentApprove_order_events_lines_discount_oldAmount | null; +} + +export interface OrderFulfillmentApprove_orderFulfillmentApprove_order_events_lines_orderLine { + __typename: "OrderLine"; + id: string; + productName: string; + variantName: string; +} + +export interface OrderFulfillmentApprove_orderFulfillmentApprove_order_events_lines { + __typename: "OrderEventOrderLineObject"; + quantity: number | null; + itemName: string | null; + discount: OrderFulfillmentApprove_orderFulfillmentApprove_order_events_lines_discount | null; + orderLine: OrderFulfillmentApprove_orderFulfillmentApprove_order_events_lines_orderLine | null; +} + +export interface OrderFulfillmentApprove_orderFulfillmentApprove_order_events { + __typename: "OrderEvent"; + id: string; + amount: number | null; + shippingCostsIncluded: boolean | null; + date: any | null; + email: string | null; + emailType: OrderEventsEmailsEnum | null; + invoiceNumber: string | null; + discount: OrderFulfillmentApprove_orderFulfillmentApprove_order_events_discount | null; + relatedOrder: OrderFulfillmentApprove_orderFulfillmentApprove_order_events_relatedOrder | null; + message: string | null; + quantity: number | null; + transactionReference: string | null; + type: OrderEventsEnum | null; + user: OrderFulfillmentApprove_orderFulfillmentApprove_order_events_user | null; + lines: (OrderFulfillmentApprove_orderFulfillmentApprove_order_events_lines | null)[] | null; +} + +export interface OrderFulfillmentApprove_orderFulfillmentApprove_order_fulfillments_lines_orderLine_variant { + __typename: "ProductVariant"; + id: string; + quantityAvailable: number; +} + +export interface OrderFulfillmentApprove_orderFulfillmentApprove_order_fulfillments_lines_orderLine_unitDiscount { + __typename: "Money"; + amount: number; + currency: string; +} + +export interface OrderFulfillmentApprove_orderFulfillmentApprove_order_fulfillments_lines_orderLine_undiscountedUnitPrice_gross { + __typename: "Money"; + amount: number; + currency: string; +} + +export interface OrderFulfillmentApprove_orderFulfillmentApprove_order_fulfillments_lines_orderLine_undiscountedUnitPrice_net { + __typename: "Money"; + amount: number; + currency: string; +} + +export interface OrderFulfillmentApprove_orderFulfillmentApprove_order_fulfillments_lines_orderLine_undiscountedUnitPrice { + __typename: "TaxedMoney"; + currency: string; + gross: OrderFulfillmentApprove_orderFulfillmentApprove_order_fulfillments_lines_orderLine_undiscountedUnitPrice_gross; + net: OrderFulfillmentApprove_orderFulfillmentApprove_order_fulfillments_lines_orderLine_undiscountedUnitPrice_net; +} + +export interface OrderFulfillmentApprove_orderFulfillmentApprove_order_fulfillments_lines_orderLine_unitPrice_gross { + __typename: "Money"; + amount: number; + currency: string; +} + +export interface OrderFulfillmentApprove_orderFulfillmentApprove_order_fulfillments_lines_orderLine_unitPrice_net { + __typename: "Money"; + amount: number; + currency: string; +} + +export interface OrderFulfillmentApprove_orderFulfillmentApprove_order_fulfillments_lines_orderLine_unitPrice { + __typename: "TaxedMoney"; + gross: OrderFulfillmentApprove_orderFulfillmentApprove_order_fulfillments_lines_orderLine_unitPrice_gross; + net: OrderFulfillmentApprove_orderFulfillmentApprove_order_fulfillments_lines_orderLine_unitPrice_net; +} + +export interface OrderFulfillmentApprove_orderFulfillmentApprove_order_fulfillments_lines_orderLine_thumbnail { + __typename: "Image"; + url: string; +} + +export interface OrderFulfillmentApprove_orderFulfillmentApprove_order_fulfillments_lines_orderLine { + __typename: "OrderLine"; + id: string; + isShippingRequired: boolean; + variant: OrderFulfillmentApprove_orderFulfillmentApprove_order_fulfillments_lines_orderLine_variant | null; + productName: string; + productSku: string; + quantity: number; + quantityFulfilled: number; + quantityToFulfill: number; + unitDiscount: OrderFulfillmentApprove_orderFulfillmentApprove_order_fulfillments_lines_orderLine_unitDiscount; + unitDiscountValue: any; + unitDiscountReason: string | null; + unitDiscountType: DiscountValueTypeEnum | null; + undiscountedUnitPrice: OrderFulfillmentApprove_orderFulfillmentApprove_order_fulfillments_lines_orderLine_undiscountedUnitPrice; + unitPrice: OrderFulfillmentApprove_orderFulfillmentApprove_order_fulfillments_lines_orderLine_unitPrice; + thumbnail: OrderFulfillmentApprove_orderFulfillmentApprove_order_fulfillments_lines_orderLine_thumbnail | null; +} + +export interface OrderFulfillmentApprove_orderFulfillmentApprove_order_fulfillments_lines { + __typename: "FulfillmentLine"; + id: string; + quantity: number; + orderLine: OrderFulfillmentApprove_orderFulfillmentApprove_order_fulfillments_lines_orderLine | null; +} + +export interface OrderFulfillmentApprove_orderFulfillmentApprove_order_fulfillments_warehouse { + __typename: "Warehouse"; + id: string; + name: string; +} + +export interface OrderFulfillmentApprove_orderFulfillmentApprove_order_fulfillments { + __typename: "Fulfillment"; + id: string; + lines: (OrderFulfillmentApprove_orderFulfillmentApprove_order_fulfillments_lines | null)[] | null; + fulfillmentOrder: number; + status: FulfillmentStatus; + trackingNumber: string; + warehouse: OrderFulfillmentApprove_orderFulfillmentApprove_order_fulfillments_warehouse | null; +} + +export interface OrderFulfillmentApprove_orderFulfillmentApprove_order_lines_variant { + __typename: "ProductVariant"; + id: string; + quantityAvailable: number; +} + +export interface OrderFulfillmentApprove_orderFulfillmentApprove_order_lines_unitDiscount { + __typename: "Money"; + amount: number; + currency: string; +} + +export interface OrderFulfillmentApprove_orderFulfillmentApprove_order_lines_undiscountedUnitPrice_gross { + __typename: "Money"; + amount: number; + currency: string; +} + +export interface OrderFulfillmentApprove_orderFulfillmentApprove_order_lines_undiscountedUnitPrice_net { + __typename: "Money"; + amount: number; + currency: string; +} + +export interface OrderFulfillmentApprove_orderFulfillmentApprove_order_lines_undiscountedUnitPrice { + __typename: "TaxedMoney"; + currency: string; + gross: OrderFulfillmentApprove_orderFulfillmentApprove_order_lines_undiscountedUnitPrice_gross; + net: OrderFulfillmentApprove_orderFulfillmentApprove_order_lines_undiscountedUnitPrice_net; +} + +export interface OrderFulfillmentApprove_orderFulfillmentApprove_order_lines_unitPrice_gross { + __typename: "Money"; + amount: number; + currency: string; +} + +export interface OrderFulfillmentApprove_orderFulfillmentApprove_order_lines_unitPrice_net { + __typename: "Money"; + amount: number; + currency: string; +} + +export interface OrderFulfillmentApprove_orderFulfillmentApprove_order_lines_unitPrice { + __typename: "TaxedMoney"; + gross: OrderFulfillmentApprove_orderFulfillmentApprove_order_lines_unitPrice_gross; + net: OrderFulfillmentApprove_orderFulfillmentApprove_order_lines_unitPrice_net; +} + +export interface OrderFulfillmentApprove_orderFulfillmentApprove_order_lines_thumbnail { + __typename: "Image"; + url: string; +} + +export interface OrderFulfillmentApprove_orderFulfillmentApprove_order_lines { + __typename: "OrderLine"; + id: string; + isShippingRequired: boolean; + variant: OrderFulfillmentApprove_orderFulfillmentApprove_order_lines_variant | null; + productName: string; + productSku: string; + quantity: number; + quantityFulfilled: number; + quantityToFulfill: number; + unitDiscount: OrderFulfillmentApprove_orderFulfillmentApprove_order_lines_unitDiscount; + unitDiscountValue: any; + unitDiscountReason: string | null; + unitDiscountType: DiscountValueTypeEnum | null; + undiscountedUnitPrice: OrderFulfillmentApprove_orderFulfillmentApprove_order_lines_undiscountedUnitPrice; + unitPrice: OrderFulfillmentApprove_orderFulfillmentApprove_order_lines_unitPrice; + thumbnail: OrderFulfillmentApprove_orderFulfillmentApprove_order_lines_thumbnail | null; +} + +export interface OrderFulfillmentApprove_orderFulfillmentApprove_order_shippingAddress_country { + __typename: "CountryDisplay"; + code: string; + country: string; +} + +export interface OrderFulfillmentApprove_orderFulfillmentApprove_order_shippingAddress { + __typename: "Address"; + city: string; + cityArea: string; + companyName: string; + country: OrderFulfillmentApprove_orderFulfillmentApprove_order_shippingAddress_country; + countryArea: string; + firstName: string; + id: string; + lastName: string; + phone: string | null; + postalCode: string; + streetAddress1: string; + streetAddress2: string; +} + +export interface OrderFulfillmentApprove_orderFulfillmentApprove_order_shippingMethod { + __typename: "ShippingMethod"; + id: string; +} + +export interface OrderFulfillmentApprove_orderFulfillmentApprove_order_shippingPrice_gross { + __typename: "Money"; + amount: number; + currency: string; +} + +export interface OrderFulfillmentApprove_orderFulfillmentApprove_order_shippingPrice { + __typename: "TaxedMoney"; + gross: OrderFulfillmentApprove_orderFulfillmentApprove_order_shippingPrice_gross; +} + +export interface OrderFulfillmentApprove_orderFulfillmentApprove_order_subtotal_gross { + __typename: "Money"; + amount: number; + currency: string; +} + +export interface OrderFulfillmentApprove_orderFulfillmentApprove_order_subtotal_net { + __typename: "Money"; + amount: number; + currency: string; +} + +export interface OrderFulfillmentApprove_orderFulfillmentApprove_order_subtotal { + __typename: "TaxedMoney"; + gross: OrderFulfillmentApprove_orderFulfillmentApprove_order_subtotal_gross; + net: OrderFulfillmentApprove_orderFulfillmentApprove_order_subtotal_net; +} + +export interface OrderFulfillmentApprove_orderFulfillmentApprove_order_total_gross { + __typename: "Money"; + amount: number; + currency: string; +} + +export interface OrderFulfillmentApprove_orderFulfillmentApprove_order_total_net { + __typename: "Money"; + amount: number; + currency: string; +} + +export interface OrderFulfillmentApprove_orderFulfillmentApprove_order_total_tax { + __typename: "Money"; + amount: number; + currency: string; +} + +export interface OrderFulfillmentApprove_orderFulfillmentApprove_order_total { + __typename: "TaxedMoney"; + gross: OrderFulfillmentApprove_orderFulfillmentApprove_order_total_gross; + net: OrderFulfillmentApprove_orderFulfillmentApprove_order_total_net; + tax: OrderFulfillmentApprove_orderFulfillmentApprove_order_total_tax; +} + +export interface OrderFulfillmentApprove_orderFulfillmentApprove_order_totalAuthorized { + __typename: "Money"; + amount: number; + currency: string; +} + +export interface OrderFulfillmentApprove_orderFulfillmentApprove_order_totalCaptured { + __typename: "Money"; + amount: number; + currency: string; +} + +export interface OrderFulfillmentApprove_orderFulfillmentApprove_order_undiscountedTotal_net { + __typename: "Money"; + amount: number; + currency: string; +} + +export interface OrderFulfillmentApprove_orderFulfillmentApprove_order_undiscountedTotal_gross { + __typename: "Money"; + amount: number; + currency: string; +} + +export interface OrderFulfillmentApprove_orderFulfillmentApprove_order_undiscountedTotal { + __typename: "TaxedMoney"; + net: OrderFulfillmentApprove_orderFulfillmentApprove_order_undiscountedTotal_net; + gross: OrderFulfillmentApprove_orderFulfillmentApprove_order_undiscountedTotal_gross; +} + +export interface OrderFulfillmentApprove_orderFulfillmentApprove_order_user { + __typename: "User"; + id: string; + email: string; +} + +export interface OrderFulfillmentApprove_orderFulfillmentApprove_order_availableShippingMethods_price { + __typename: "Money"; + amount: number; + currency: string; +} + +export interface OrderFulfillmentApprove_orderFulfillmentApprove_order_availableShippingMethods { + __typename: "ShippingMethod"; + id: string; + name: string; + price: OrderFulfillmentApprove_orderFulfillmentApprove_order_availableShippingMethods_price | null; +} + +export interface OrderFulfillmentApprove_orderFulfillmentApprove_order_invoices { + __typename: "Invoice"; + id: string; + number: string | null; + createdAt: any; + url: string | null; + status: JobStatusEnum; +} + +export interface OrderFulfillmentApprove_orderFulfillmentApprove_order_channel { + __typename: "Channel"; + isActive: boolean; + id: string; + name: string; + currencyCode: string; + slug: string; +} + +export interface OrderFulfillmentApprove_orderFulfillmentApprove_order { + __typename: "Order"; + id: string; + metadata: (OrderFulfillmentApprove_orderFulfillmentApprove_order_metadata | null)[]; + privateMetadata: (OrderFulfillmentApprove_orderFulfillmentApprove_order_privateMetadata | null)[]; + billingAddress: OrderFulfillmentApprove_orderFulfillmentApprove_order_billingAddress | null; + isShippingRequired: boolean; + canFinalize: boolean; + created: any; + customerNote: string; + discounts: OrderFulfillmentApprove_orderFulfillmentApprove_order_discounts[] | null; + events: (OrderFulfillmentApprove_orderFulfillmentApprove_order_events | null)[] | null; + fulfillments: (OrderFulfillmentApprove_orderFulfillmentApprove_order_fulfillments | null)[]; + lines: (OrderFulfillmentApprove_orderFulfillmentApprove_order_lines | null)[]; + number: string | null; + isPaid: boolean; + paymentStatus: PaymentChargeStatusEnum; + shippingAddress: OrderFulfillmentApprove_orderFulfillmentApprove_order_shippingAddress | null; + shippingMethod: OrderFulfillmentApprove_orderFulfillmentApprove_order_shippingMethod | null; + shippingMethodName: string | null; + shippingPrice: OrderFulfillmentApprove_orderFulfillmentApprove_order_shippingPrice; + status: OrderStatus; + subtotal: OrderFulfillmentApprove_orderFulfillmentApprove_order_subtotal; + total: OrderFulfillmentApprove_orderFulfillmentApprove_order_total; + actions: (OrderAction | null)[]; + totalAuthorized: OrderFulfillmentApprove_orderFulfillmentApprove_order_totalAuthorized; + totalCaptured: OrderFulfillmentApprove_orderFulfillmentApprove_order_totalCaptured; + undiscountedTotal: OrderFulfillmentApprove_orderFulfillmentApprove_order_undiscountedTotal; + user: OrderFulfillmentApprove_orderFulfillmentApprove_order_user | null; + userEmail: string | null; + availableShippingMethods: (OrderFulfillmentApprove_orderFulfillmentApprove_order_availableShippingMethods | null)[] | null; + invoices: (OrderFulfillmentApprove_orderFulfillmentApprove_order_invoices | null)[] | null; + channel: OrderFulfillmentApprove_orderFulfillmentApprove_order_channel; +} + +export interface OrderFulfillmentApprove_orderFulfillmentApprove { + __typename: "FulfillmentApprove"; + errors: OrderFulfillmentApprove_orderFulfillmentApprove_errors[]; + order: OrderFulfillmentApprove_orderFulfillmentApprove_order | null; +} + +export interface OrderFulfillmentApprove { + orderFulfillmentApprove: OrderFulfillmentApprove_orderFulfillmentApprove | null; +} + +export interface OrderFulfillmentApproveVariables { + id: string; + notifyCustomer: boolean; +} diff --git a/src/orders/types/OrderFulfillmentCancel.ts b/src/orders/types/OrderFulfillmentCancel.ts index 061c9f1be..382b0f016 100644 --- a/src/orders/types/OrderFulfillmentCancel.ts +++ b/src/orders/types/OrderFulfillmentCancel.ts @@ -223,6 +223,7 @@ export interface OrderFulfillmentCancel_orderFulfillmentCancel_order_fulfillment productSku: string; quantity: number; quantityFulfilled: number; + quantityToFulfill: number; unitDiscount: OrderFulfillmentCancel_orderFulfillmentCancel_order_fulfillments_lines_orderLine_unitDiscount; unitDiscountValue: any; unitDiscountReason: string | null; @@ -318,6 +319,7 @@ export interface OrderFulfillmentCancel_orderFulfillmentCancel_order_lines { productSku: string; quantity: number; quantityFulfilled: number; + quantityToFulfill: number; unitDiscount: OrderFulfillmentCancel_orderFulfillmentCancel_order_lines_unitDiscount; unitDiscountValue: any; unitDiscountReason: string | null; @@ -490,6 +492,7 @@ export interface OrderFulfillmentCancel_orderFulfillmentCancel_order { fulfillments: (OrderFulfillmentCancel_orderFulfillmentCancel_order_fulfillments | null)[]; lines: (OrderFulfillmentCancel_orderFulfillmentCancel_order_lines | null)[]; number: string | null; + isPaid: boolean; paymentStatus: PaymentChargeStatusEnum; shippingAddress: OrderFulfillmentCancel_orderFulfillmentCancel_order_shippingAddress | null; shippingMethod: OrderFulfillmentCancel_orderFulfillmentCancel_order_shippingMethod | null; @@ -507,7 +510,6 @@ export interface OrderFulfillmentCancel_orderFulfillmentCancel_order { availableShippingMethods: (OrderFulfillmentCancel_orderFulfillmentCancel_order_availableShippingMethods | null)[] | null; invoices: (OrderFulfillmentCancel_orderFulfillmentCancel_order_invoices | null)[] | null; channel: OrderFulfillmentCancel_orderFulfillmentCancel_order_channel; - isPaid: boolean; } export interface OrderFulfillmentCancel_orderFulfillmentCancel { diff --git a/src/orders/types/OrderFulfillmentRefundProducts.ts b/src/orders/types/OrderFulfillmentRefundProducts.ts index d9ea059fe..bbc6218d0 100644 --- a/src/orders/types/OrderFulfillmentRefundProducts.ts +++ b/src/orders/types/OrderFulfillmentRefundProducts.ts @@ -79,6 +79,7 @@ export interface OrderFulfillmentRefundProducts_orderFulfillmentRefundProducts_f productSku: string; quantity: number; quantityFulfilled: number; + quantityToFulfill: number; unitDiscount: OrderFulfillmentRefundProducts_orderFulfillmentRefundProducts_fulfillment_lines_orderLine_unitDiscount; unitDiscountValue: any; unitDiscountReason: string | null; @@ -318,6 +319,7 @@ export interface OrderFulfillmentRefundProducts_orderFulfillmentRefundProducts_o productSku: string; quantity: number; quantityFulfilled: number; + quantityToFulfill: number; unitDiscount: OrderFulfillmentRefundProducts_orderFulfillmentRefundProducts_order_fulfillments_lines_orderLine_unitDiscount; unitDiscountValue: any; unitDiscountReason: string | null; @@ -413,6 +415,7 @@ export interface OrderFulfillmentRefundProducts_orderFulfillmentRefundProducts_o productSku: string; quantity: number; quantityFulfilled: number; + quantityToFulfill: number; unitDiscount: OrderFulfillmentRefundProducts_orderFulfillmentRefundProducts_order_lines_unitDiscount; unitDiscountValue: any; unitDiscountReason: string | null; @@ -585,6 +588,7 @@ export interface OrderFulfillmentRefundProducts_orderFulfillmentRefundProducts_o fulfillments: (OrderFulfillmentRefundProducts_orderFulfillmentRefundProducts_order_fulfillments | null)[]; lines: (OrderFulfillmentRefundProducts_orderFulfillmentRefundProducts_order_lines | null)[]; number: string | null; + isPaid: boolean; paymentStatus: PaymentChargeStatusEnum; shippingAddress: OrderFulfillmentRefundProducts_orderFulfillmentRefundProducts_order_shippingAddress | null; shippingMethod: OrderFulfillmentRefundProducts_orderFulfillmentRefundProducts_order_shippingMethod | null; @@ -602,7 +606,6 @@ export interface OrderFulfillmentRefundProducts_orderFulfillmentRefundProducts_o availableShippingMethods: (OrderFulfillmentRefundProducts_orderFulfillmentRefundProducts_order_availableShippingMethods | null)[] | null; invoices: (OrderFulfillmentRefundProducts_orderFulfillmentRefundProducts_order_invoices | null)[] | null; channel: OrderFulfillmentRefundProducts_orderFulfillmentRefundProducts_order_channel; - isPaid: boolean; } export interface OrderFulfillmentRefundProducts_orderFulfillmentRefundProducts { diff --git a/src/orders/types/OrderFulfillmentUpdateTracking.ts b/src/orders/types/OrderFulfillmentUpdateTracking.ts index 17e0d4e1d..9c2b8edea 100644 --- a/src/orders/types/OrderFulfillmentUpdateTracking.ts +++ b/src/orders/types/OrderFulfillmentUpdateTracking.ts @@ -223,6 +223,7 @@ export interface OrderFulfillmentUpdateTracking_orderFulfillmentUpdateTracking_o productSku: string; quantity: number; quantityFulfilled: number; + quantityToFulfill: number; unitDiscount: OrderFulfillmentUpdateTracking_orderFulfillmentUpdateTracking_order_fulfillments_lines_orderLine_unitDiscount; unitDiscountValue: any; unitDiscountReason: string | null; @@ -318,6 +319,7 @@ export interface OrderFulfillmentUpdateTracking_orderFulfillmentUpdateTracking_o productSku: string; quantity: number; quantityFulfilled: number; + quantityToFulfill: number; unitDiscount: OrderFulfillmentUpdateTracking_orderFulfillmentUpdateTracking_order_lines_unitDiscount; unitDiscountValue: any; unitDiscountReason: string | null; @@ -490,6 +492,7 @@ export interface OrderFulfillmentUpdateTracking_orderFulfillmentUpdateTracking_o fulfillments: (OrderFulfillmentUpdateTracking_orderFulfillmentUpdateTracking_order_fulfillments | null)[]; lines: (OrderFulfillmentUpdateTracking_orderFulfillmentUpdateTracking_order_lines | null)[]; number: string | null; + isPaid: boolean; paymentStatus: PaymentChargeStatusEnum; shippingAddress: OrderFulfillmentUpdateTracking_orderFulfillmentUpdateTracking_order_shippingAddress | null; shippingMethod: OrderFulfillmentUpdateTracking_orderFulfillmentUpdateTracking_order_shippingMethod | null; @@ -507,7 +510,6 @@ export interface OrderFulfillmentUpdateTracking_orderFulfillmentUpdateTracking_o availableShippingMethods: (OrderFulfillmentUpdateTracking_orderFulfillmentUpdateTracking_order_availableShippingMethods | null)[] | null; invoices: (OrderFulfillmentUpdateTracking_orderFulfillmentUpdateTracking_order_invoices | null)[] | null; channel: OrderFulfillmentUpdateTracking_orderFulfillmentUpdateTracking_order_channel; - isPaid: boolean; } export interface OrderFulfillmentUpdateTracking_orderFulfillmentUpdateTracking { diff --git a/src/orders/types/OrderLineDelete.ts b/src/orders/types/OrderLineDelete.ts index b0f22c4b1..2d046c8f2 100644 --- a/src/orders/types/OrderLineDelete.ts +++ b/src/orders/types/OrderLineDelete.ts @@ -223,6 +223,7 @@ export interface OrderLineDelete_orderLineDelete_order_fulfillments_lines_orderL productSku: string; quantity: number; quantityFulfilled: number; + quantityToFulfill: number; unitDiscount: OrderLineDelete_orderLineDelete_order_fulfillments_lines_orderLine_unitDiscount; unitDiscountValue: any; unitDiscountReason: string | null; @@ -318,6 +319,7 @@ export interface OrderLineDelete_orderLineDelete_order_lines { productSku: string; quantity: number; quantityFulfilled: number; + quantityToFulfill: number; unitDiscount: OrderLineDelete_orderLineDelete_order_lines_unitDiscount; unitDiscountValue: any; unitDiscountReason: string | null; @@ -490,6 +492,7 @@ export interface OrderLineDelete_orderLineDelete_order { fulfillments: (OrderLineDelete_orderLineDelete_order_fulfillments | null)[]; lines: (OrderLineDelete_orderLineDelete_order_lines | null)[]; number: string | null; + isPaid: boolean; paymentStatus: PaymentChargeStatusEnum; shippingAddress: OrderLineDelete_orderLineDelete_order_shippingAddress | null; shippingMethod: OrderLineDelete_orderLineDelete_order_shippingMethod | null; @@ -507,7 +510,6 @@ export interface OrderLineDelete_orderLineDelete_order { availableShippingMethods: (OrderLineDelete_orderLineDelete_order_availableShippingMethods | null)[] | null; invoices: (OrderLineDelete_orderLineDelete_order_invoices | null)[] | null; channel: OrderLineDelete_orderLineDelete_order_channel; - isPaid: boolean; } export interface OrderLineDelete_orderLineDelete { diff --git a/src/orders/types/OrderLineDiscountRemove.ts b/src/orders/types/OrderLineDiscountRemove.ts index 8b15bfa72..8e3d0021c 100644 --- a/src/orders/types/OrderLineDiscountRemove.ts +++ b/src/orders/types/OrderLineDiscountRemove.ts @@ -223,6 +223,7 @@ export interface OrderLineDiscountRemove_orderLineDiscountRemove_order_fulfillme productSku: string; quantity: number; quantityFulfilled: number; + quantityToFulfill: number; unitDiscount: OrderLineDiscountRemove_orderLineDiscountRemove_order_fulfillments_lines_orderLine_unitDiscount; unitDiscountValue: any; unitDiscountReason: string | null; @@ -318,6 +319,7 @@ export interface OrderLineDiscountRemove_orderLineDiscountRemove_order_lines { productSku: string; quantity: number; quantityFulfilled: number; + quantityToFulfill: number; unitDiscount: OrderLineDiscountRemove_orderLineDiscountRemove_order_lines_unitDiscount; unitDiscountValue: any; unitDiscountReason: string | null; @@ -490,6 +492,7 @@ export interface OrderLineDiscountRemove_orderLineDiscountRemove_order { fulfillments: (OrderLineDiscountRemove_orderLineDiscountRemove_order_fulfillments | null)[]; lines: (OrderLineDiscountRemove_orderLineDiscountRemove_order_lines | null)[]; number: string | null; + isPaid: boolean; paymentStatus: PaymentChargeStatusEnum; shippingAddress: OrderLineDiscountRemove_orderLineDiscountRemove_order_shippingAddress | null; shippingMethod: OrderLineDiscountRemove_orderLineDiscountRemove_order_shippingMethod | null; @@ -507,7 +510,6 @@ export interface OrderLineDiscountRemove_orderLineDiscountRemove_order { availableShippingMethods: (OrderLineDiscountRemove_orderLineDiscountRemove_order_availableShippingMethods | null)[] | null; invoices: (OrderLineDiscountRemove_orderLineDiscountRemove_order_invoices | null)[] | null; channel: OrderLineDiscountRemove_orderLineDiscountRemove_order_channel; - isPaid: boolean; } export interface OrderLineDiscountRemove_orderLineDiscountRemove { diff --git a/src/orders/types/OrderLineDiscountUpdate.ts b/src/orders/types/OrderLineDiscountUpdate.ts index a7bc512dd..f37504e35 100644 --- a/src/orders/types/OrderLineDiscountUpdate.ts +++ b/src/orders/types/OrderLineDiscountUpdate.ts @@ -223,6 +223,7 @@ export interface OrderLineDiscountUpdate_orderLineDiscountUpdate_order_fulfillme productSku: string; quantity: number; quantityFulfilled: number; + quantityToFulfill: number; unitDiscount: OrderLineDiscountUpdate_orderLineDiscountUpdate_order_fulfillments_lines_orderLine_unitDiscount; unitDiscountValue: any; unitDiscountReason: string | null; @@ -318,6 +319,7 @@ export interface OrderLineDiscountUpdate_orderLineDiscountUpdate_order_lines { productSku: string; quantity: number; quantityFulfilled: number; + quantityToFulfill: number; unitDiscount: OrderLineDiscountUpdate_orderLineDiscountUpdate_order_lines_unitDiscount; unitDiscountValue: any; unitDiscountReason: string | null; @@ -490,6 +492,7 @@ export interface OrderLineDiscountUpdate_orderLineDiscountUpdate_order { fulfillments: (OrderLineDiscountUpdate_orderLineDiscountUpdate_order_fulfillments | null)[]; lines: (OrderLineDiscountUpdate_orderLineDiscountUpdate_order_lines | null)[]; number: string | null; + isPaid: boolean; paymentStatus: PaymentChargeStatusEnum; shippingAddress: OrderLineDiscountUpdate_orderLineDiscountUpdate_order_shippingAddress | null; shippingMethod: OrderLineDiscountUpdate_orderLineDiscountUpdate_order_shippingMethod | null; @@ -507,7 +510,6 @@ export interface OrderLineDiscountUpdate_orderLineDiscountUpdate_order { availableShippingMethods: (OrderLineDiscountUpdate_orderLineDiscountUpdate_order_availableShippingMethods | null)[] | null; invoices: (OrderLineDiscountUpdate_orderLineDiscountUpdate_order_invoices | null)[] | null; channel: OrderLineDiscountUpdate_orderLineDiscountUpdate_order_channel; - isPaid: boolean; } export interface OrderLineDiscountUpdate_orderLineDiscountUpdate { diff --git a/src/orders/types/OrderLineUpdate.ts b/src/orders/types/OrderLineUpdate.ts index fdddb41f7..5d09d89d3 100644 --- a/src/orders/types/OrderLineUpdate.ts +++ b/src/orders/types/OrderLineUpdate.ts @@ -223,6 +223,7 @@ export interface OrderLineUpdate_orderLineUpdate_order_fulfillments_lines_orderL productSku: string; quantity: number; quantityFulfilled: number; + quantityToFulfill: number; unitDiscount: OrderLineUpdate_orderLineUpdate_order_fulfillments_lines_orderLine_unitDiscount; unitDiscountValue: any; unitDiscountReason: string | null; @@ -318,6 +319,7 @@ export interface OrderLineUpdate_orderLineUpdate_order_lines { productSku: string; quantity: number; quantityFulfilled: number; + quantityToFulfill: number; unitDiscount: OrderLineUpdate_orderLineUpdate_order_lines_unitDiscount; unitDiscountValue: any; unitDiscountReason: string | null; @@ -490,6 +492,7 @@ export interface OrderLineUpdate_orderLineUpdate_order { fulfillments: (OrderLineUpdate_orderLineUpdate_order_fulfillments | null)[]; lines: (OrderLineUpdate_orderLineUpdate_order_lines | null)[]; number: string | null; + isPaid: boolean; paymentStatus: PaymentChargeStatusEnum; shippingAddress: OrderLineUpdate_orderLineUpdate_order_shippingAddress | null; shippingMethod: OrderLineUpdate_orderLineUpdate_order_shippingMethod | null; @@ -507,7 +510,6 @@ export interface OrderLineUpdate_orderLineUpdate_order { availableShippingMethods: (OrderLineUpdate_orderLineUpdate_order_availableShippingMethods | null)[] | null; invoices: (OrderLineUpdate_orderLineUpdate_order_invoices | null)[] | null; channel: OrderLineUpdate_orderLineUpdate_order_channel; - isPaid: boolean; } export interface OrderLineUpdate_orderLineUpdate { diff --git a/src/orders/types/OrderLinesAdd.ts b/src/orders/types/OrderLinesAdd.ts index c3ff37b18..459c8d912 100644 --- a/src/orders/types/OrderLinesAdd.ts +++ b/src/orders/types/OrderLinesAdd.ts @@ -223,6 +223,7 @@ export interface OrderLinesAdd_orderLinesCreate_order_fulfillments_lines_orderLi productSku: string; quantity: number; quantityFulfilled: number; + quantityToFulfill: number; unitDiscount: OrderLinesAdd_orderLinesCreate_order_fulfillments_lines_orderLine_unitDiscount; unitDiscountValue: any; unitDiscountReason: string | null; @@ -318,6 +319,7 @@ export interface OrderLinesAdd_orderLinesCreate_order_lines { productSku: string; quantity: number; quantityFulfilled: number; + quantityToFulfill: number; unitDiscount: OrderLinesAdd_orderLinesCreate_order_lines_unitDiscount; unitDiscountValue: any; unitDiscountReason: string | null; @@ -490,6 +492,7 @@ export interface OrderLinesAdd_orderLinesCreate_order { fulfillments: (OrderLinesAdd_orderLinesCreate_order_fulfillments | null)[]; lines: (OrderLinesAdd_orderLinesCreate_order_lines | null)[]; number: string | null; + isPaid: boolean; paymentStatus: PaymentChargeStatusEnum; shippingAddress: OrderLinesAdd_orderLinesCreate_order_shippingAddress | null; shippingMethod: OrderLinesAdd_orderLinesCreate_order_shippingMethod | null; @@ -507,7 +510,6 @@ export interface OrderLinesAdd_orderLinesCreate_order { availableShippingMethods: (OrderLinesAdd_orderLinesCreate_order_availableShippingMethods | null)[] | null; invoices: (OrderLinesAdd_orderLinesCreate_order_invoices | null)[] | null; channel: OrderLinesAdd_orderLinesCreate_order_channel; - isPaid: boolean; } export interface OrderLinesAdd_orderLinesCreate { diff --git a/src/orders/types/OrderMarkAsPaid.ts b/src/orders/types/OrderMarkAsPaid.ts index 63e481c6f..a93aa9c47 100644 --- a/src/orders/types/OrderMarkAsPaid.ts +++ b/src/orders/types/OrderMarkAsPaid.ts @@ -223,6 +223,7 @@ export interface OrderMarkAsPaid_orderMarkAsPaid_order_fulfillments_lines_orderL productSku: string; quantity: number; quantityFulfilled: number; + quantityToFulfill: number; unitDiscount: OrderMarkAsPaid_orderMarkAsPaid_order_fulfillments_lines_orderLine_unitDiscount; unitDiscountValue: any; unitDiscountReason: string | null; @@ -318,6 +319,7 @@ export interface OrderMarkAsPaid_orderMarkAsPaid_order_lines { productSku: string; quantity: number; quantityFulfilled: number; + quantityToFulfill: number; unitDiscount: OrderMarkAsPaid_orderMarkAsPaid_order_lines_unitDiscount; unitDiscountValue: any; unitDiscountReason: string | null; @@ -490,6 +492,7 @@ export interface OrderMarkAsPaid_orderMarkAsPaid_order { fulfillments: (OrderMarkAsPaid_orderMarkAsPaid_order_fulfillments | null)[]; lines: (OrderMarkAsPaid_orderMarkAsPaid_order_lines | null)[]; number: string | null; + isPaid: boolean; paymentStatus: PaymentChargeStatusEnum; shippingAddress: OrderMarkAsPaid_orderMarkAsPaid_order_shippingAddress | null; shippingMethod: OrderMarkAsPaid_orderMarkAsPaid_order_shippingMethod | null; @@ -507,7 +510,6 @@ export interface OrderMarkAsPaid_orderMarkAsPaid_order { availableShippingMethods: (OrderMarkAsPaid_orderMarkAsPaid_order_availableShippingMethods | null)[] | null; invoices: (OrderMarkAsPaid_orderMarkAsPaid_order_invoices | null)[] | null; channel: OrderMarkAsPaid_orderMarkAsPaid_order_channel; - isPaid: boolean; } export interface OrderMarkAsPaid_orderMarkAsPaid { diff --git a/src/orders/types/OrderRefund.ts b/src/orders/types/OrderRefund.ts index 22eb4aa50..c816ef08a 100644 --- a/src/orders/types/OrderRefund.ts +++ b/src/orders/types/OrderRefund.ts @@ -223,6 +223,7 @@ export interface OrderRefund_orderRefund_order_fulfillments_lines_orderLine { productSku: string; quantity: number; quantityFulfilled: number; + quantityToFulfill: number; unitDiscount: OrderRefund_orderRefund_order_fulfillments_lines_orderLine_unitDiscount; unitDiscountValue: any; unitDiscountReason: string | null; @@ -318,6 +319,7 @@ export interface OrderRefund_orderRefund_order_lines { productSku: string; quantity: number; quantityFulfilled: number; + quantityToFulfill: number; unitDiscount: OrderRefund_orderRefund_order_lines_unitDiscount; unitDiscountValue: any; unitDiscountReason: string | null; @@ -490,6 +492,7 @@ export interface OrderRefund_orderRefund_order { fulfillments: (OrderRefund_orderRefund_order_fulfillments | null)[]; lines: (OrderRefund_orderRefund_order_lines | null)[]; number: string | null; + isPaid: boolean; paymentStatus: PaymentChargeStatusEnum; shippingAddress: OrderRefund_orderRefund_order_shippingAddress | null; shippingMethod: OrderRefund_orderRefund_order_shippingMethod | null; @@ -507,7 +510,6 @@ export interface OrderRefund_orderRefund_order { availableShippingMethods: (OrderRefund_orderRefund_order_availableShippingMethods | null)[] | null; invoices: (OrderRefund_orderRefund_order_invoices | null)[] | null; channel: OrderRefund_orderRefund_order_channel; - isPaid: boolean; } export interface OrderRefund_orderRefund { diff --git a/src/orders/types/OrderRefundData.ts b/src/orders/types/OrderRefundData.ts index eb6fc188a..0974720b1 100644 --- a/src/orders/types/OrderRefundData.ts +++ b/src/orders/types/OrderRefundData.ts @@ -60,7 +60,7 @@ export interface OrderRefundData_order_lines { quantity: number; unitPrice: OrderRefundData_order_lines_unitPrice; thumbnail: OrderRefundData_order_lines_thumbnail | null; - quantityFulfilled: number; + quantityToFulfill: number; } export interface OrderRefundData_order_fulfillments_lines_orderLine_unitPrice_gross { diff --git a/src/orders/types/OrderSettings.ts b/src/orders/types/OrderSettings.ts index 94eec096d..8414483e0 100644 --- a/src/orders/types/OrderSettings.ts +++ b/src/orders/types/OrderSettings.ts @@ -12,6 +12,13 @@ export interface OrderSettings_orderSettings { automaticallyConfirmAllNewOrders: boolean; } +export interface OrderSettings_shop { + __typename: "Shop"; + fulfillmentAutoApprove: boolean; + fulfillmentAllowUnpaid: boolean; +} + export interface OrderSettings { orderSettings: OrderSettings_orderSettings | null; + shop: OrderSettings_shop; } diff --git a/src/orders/types/OrderSettingsUpdate.ts b/src/orders/types/OrderSettingsUpdate.ts index d799f6912..a84f184f6 100644 --- a/src/orders/types/OrderSettingsUpdate.ts +++ b/src/orders/types/OrderSettingsUpdate.ts @@ -3,7 +3,7 @@ // @generated // This file was automatically generated and should not be edited. -import { OrderSettingsUpdateInput, OrderSettingsErrorCode } from "./../../types/globalTypes"; +import { OrderSettingsUpdateInput, ShopSettingsInput, OrderSettingsErrorCode, ShopErrorCode } from "./../../types/globalTypes"; // ==================================================== // GraphQL mutation operation: OrderSettingsUpdate @@ -26,10 +26,30 @@ export interface OrderSettingsUpdate_orderSettingsUpdate { orderSettings: OrderSettingsUpdate_orderSettingsUpdate_orderSettings | null; } +export interface OrderSettingsUpdate_shopSettingsUpdate_errors { + __typename: "ShopError"; + code: ShopErrorCode; + field: string | null; +} + +export interface OrderSettingsUpdate_shopSettingsUpdate_shop { + __typename: "Shop"; + fulfillmentAutoApprove: boolean; + fulfillmentAllowUnpaid: boolean; +} + +export interface OrderSettingsUpdate_shopSettingsUpdate { + __typename: "ShopSettingsUpdate"; + errors: OrderSettingsUpdate_shopSettingsUpdate_errors[]; + shop: OrderSettingsUpdate_shopSettingsUpdate_shop | null; +} + export interface OrderSettingsUpdate { orderSettingsUpdate: OrderSettingsUpdate_orderSettingsUpdate | null; + shopSettingsUpdate: OrderSettingsUpdate_shopSettingsUpdate | null; } export interface OrderSettingsUpdateVariables { - input: OrderSettingsUpdateInput; + orderSettingsInput: OrderSettingsUpdateInput; + shopSettingsInput: ShopSettingsInput; } diff --git a/src/orders/types/OrderShippingMethodUpdate.ts b/src/orders/types/OrderShippingMethodUpdate.ts index 13aaa512c..4e68a6f7d 100644 --- a/src/orders/types/OrderShippingMethodUpdate.ts +++ b/src/orders/types/OrderShippingMethodUpdate.ts @@ -285,6 +285,7 @@ export interface OrderShippingMethodUpdate_orderUpdateShipping_order_fulfillment productSku: string; quantity: number; quantityFulfilled: number; + quantityToFulfill: number; unitDiscount: OrderShippingMethodUpdate_orderUpdateShipping_order_fulfillments_lines_orderLine_unitDiscount; unitDiscountValue: any; unitDiscountReason: string | null; @@ -380,6 +381,7 @@ export interface OrderShippingMethodUpdate_orderUpdateShipping_order_lines { productSku: string; quantity: number; quantityFulfilled: number; + quantityToFulfill: number; unitDiscount: OrderShippingMethodUpdate_orderUpdateShipping_order_lines_unitDiscount; unitDiscountValue: any; unitDiscountReason: string | null; @@ -503,6 +505,7 @@ export interface OrderShippingMethodUpdate_orderUpdateShipping_order { fulfillments: (OrderShippingMethodUpdate_orderUpdateShipping_order_fulfillments | null)[]; lines: (OrderShippingMethodUpdate_orderUpdateShipping_order_lines | null)[]; number: string | null; + isPaid: boolean; paymentStatus: PaymentChargeStatusEnum; shippingAddress: OrderShippingMethodUpdate_orderUpdateShipping_order_shippingAddress | null; status: OrderStatus; @@ -515,7 +518,6 @@ export interface OrderShippingMethodUpdate_orderUpdateShipping_order { userEmail: string | null; invoices: (OrderShippingMethodUpdate_orderUpdateShipping_order_invoices | null)[] | null; channel: OrderShippingMethodUpdate_orderUpdateShipping_order_channel; - isPaid: boolean; } export interface OrderShippingMethodUpdate_orderUpdateShipping { diff --git a/src/orders/types/OrderUpdate.ts b/src/orders/types/OrderUpdate.ts index b521df1cf..808043632 100644 --- a/src/orders/types/OrderUpdate.ts +++ b/src/orders/types/OrderUpdate.ts @@ -223,6 +223,7 @@ export interface OrderUpdate_orderUpdate_order_fulfillments_lines_orderLine { productSku: string; quantity: number; quantityFulfilled: number; + quantityToFulfill: number; unitDiscount: OrderUpdate_orderUpdate_order_fulfillments_lines_orderLine_unitDiscount; unitDiscountValue: any; unitDiscountReason: string | null; @@ -318,6 +319,7 @@ export interface OrderUpdate_orderUpdate_order_lines { productSku: string; quantity: number; quantityFulfilled: number; + quantityToFulfill: number; unitDiscount: OrderUpdate_orderUpdate_order_lines_unitDiscount; unitDiscountValue: any; unitDiscountReason: string | null; @@ -490,6 +492,7 @@ export interface OrderUpdate_orderUpdate_order { fulfillments: (OrderUpdate_orderUpdate_order_fulfillments | null)[]; lines: (OrderUpdate_orderUpdate_order_lines | null)[]; number: string | null; + isPaid: boolean; paymentStatus: PaymentChargeStatusEnum; shippingAddress: OrderUpdate_orderUpdate_order_shippingAddress | null; shippingMethod: OrderUpdate_orderUpdate_order_shippingMethod | null; @@ -507,7 +510,6 @@ export interface OrderUpdate_orderUpdate_order { availableShippingMethods: (OrderUpdate_orderUpdate_order_availableShippingMethods | null)[] | null; invoices: (OrderUpdate_orderUpdate_order_invoices | null)[] | null; channel: OrderUpdate_orderUpdate_order_channel; - isPaid: boolean; } export interface OrderUpdate_orderUpdate { diff --git a/src/orders/types/OrderVoid.ts b/src/orders/types/OrderVoid.ts index 8a520b1b0..bcd92612e 100644 --- a/src/orders/types/OrderVoid.ts +++ b/src/orders/types/OrderVoid.ts @@ -223,6 +223,7 @@ export interface OrderVoid_orderVoid_order_fulfillments_lines_orderLine { productSku: string; quantity: number; quantityFulfilled: number; + quantityToFulfill: number; unitDiscount: OrderVoid_orderVoid_order_fulfillments_lines_orderLine_unitDiscount; unitDiscountValue: any; unitDiscountReason: string | null; @@ -318,6 +319,7 @@ export interface OrderVoid_orderVoid_order_lines { productSku: string; quantity: number; quantityFulfilled: number; + quantityToFulfill: number; unitDiscount: OrderVoid_orderVoid_order_lines_unitDiscount; unitDiscountValue: any; unitDiscountReason: string | null; @@ -490,6 +492,7 @@ export interface OrderVoid_orderVoid_order { fulfillments: (OrderVoid_orderVoid_order_fulfillments | null)[]; lines: (OrderVoid_orderVoid_order_lines | null)[]; number: string | null; + isPaid: boolean; paymentStatus: PaymentChargeStatusEnum; shippingAddress: OrderVoid_orderVoid_order_shippingAddress | null; shippingMethod: OrderVoid_orderVoid_order_shippingMethod | null; @@ -507,7 +510,6 @@ export interface OrderVoid_orderVoid_order { availableShippingMethods: (OrderVoid_orderVoid_order_availableShippingMethods | null)[] | null; invoices: (OrderVoid_orderVoid_order_invoices | null)[] | null; channel: OrderVoid_orderVoid_order_channel; - isPaid: boolean; } export interface OrderVoid_orderVoid { diff --git a/src/orders/urls.ts b/src/orders/urls.ts index 7e137501a..891c96ac3 100644 --- a/src/orders/urls.ts +++ b/src/orders/urls.ts @@ -97,6 +97,7 @@ export const orderPath = (id: string) => urlJoin(orderSectionUrl, id); export type OrderUrlDialog = | "add-order-line" + | "approve-fulfillment" | "cancel" | "cancel-fulfillment" | "capture" diff --git a/src/orders/utils/data.test.ts b/src/orders/utils/data.test.ts index 70f9d8e12..52f60276e 100644 --- a/src/orders/utils/data.test.ts +++ b/src/orders/utils/data.test.ts @@ -22,7 +22,9 @@ import { getRefundedLinesPriceSum, getReplacedProductsAmount, getReturnSelectedProductsAmount, + getWarehousesFromOrderLines, mergeRepeatedOrderLines, + OrderLineWithStockWarehouses, OrderWithTotalAndTotalCaptured } from "./data"; @@ -67,6 +69,77 @@ const orderBase: OrderDetails_order = { } }; +describe("Get warehouses used in order", () => { + it("is able to calculate number of used warehouses from order", () => { + const lines: OrderLineWithStockWarehouses[] = [ + { + variant: { + stocks: [ + { + warehouse: { + __typename: "Warehouse", + id: "warehouse-1", + name: "Warehouse 1" + } + }, + { + warehouse: { + __typename: "Warehouse", + id: "warehouse-2", + name: "Warehouse 2" + } + } + ] + } + }, + { + variant: { + stocks: [ + { + warehouse: { + __typename: "Warehouse", + id: "warehouse-1", + name: "Warehouse 1" + } + }, + { + warehouse: { + __typename: "Warehouse", + id: "warehouse-2", + name: "Warehouse 2" + } + } + ] + } + }, + { + variant: { + stocks: [ + { + warehouse: { + __typename: "Warehouse", + id: "warehouse-2", + name: "Warehouse 2" + } + }, + { + warehouse: { + __typename: "Warehouse", + id: "warehouse-3", + name: "Warehouse 3" + } + } + ] + } + } + ]; + + const orderWarehouses = getWarehousesFromOrderLines(lines); + + expect(orderWarehouses.length).toBe(3); + }); +}); + describe("Get previously refunded price", () => { it("is able to calculate refunded price from order", () => { const order: OrderWithTotalAndTotalCaptured = { @@ -98,7 +171,7 @@ describe("Get refunded lines price sum", () => { id: "1", productName: "Milk 1", quantity: 1, - quantityFulfilled: 1, + quantityToFulfill: 0, thumbnail: undefined, unitPrice: { __typename: "TaxedMoney", @@ -114,7 +187,7 @@ describe("Get refunded lines price sum", () => { id: "2", productName: "Milk 2", quantity: 2, - quantityFulfilled: 2, + quantityToFulfill: 0, thumbnail: undefined, unitPrice: { __typename: "TaxedMoney", @@ -130,7 +203,7 @@ describe("Get refunded lines price sum", () => { id: "3", productName: "Milk 3", quantity: 4, - quantityFulfilled: 4, + quantityToFulfill: 0, thumbnail: undefined, unitPrice: { __typename: "TaxedMoney", @@ -464,6 +537,7 @@ describe("Get the total value of all replaced products", () => { productSku: "lake-tunes-mp3", quantity: 2, quantityFulfilled: 2, + quantityToFulfill: 0, undiscountedUnitPrice: { __typename: "TaxedMoney", currency: "USD", @@ -518,6 +592,7 @@ describe("Get the total value of all replaced products", () => { productSku: "lake-tunes-mp3", quantity: 10, quantityFulfilled: 2, + quantityToFulfill: 8, undiscountedUnitPrice: { __typename: "TaxedMoney", currency: "USD", @@ -572,6 +647,7 @@ describe("Get the total value of all replaced products", () => { productSku: "29810068", quantity: 6, quantityFulfilled: 1, + quantityToFulfill: 5, undiscountedUnitPrice: { __typename: "TaxedMoney", currency: "USD", @@ -632,6 +708,7 @@ describe("Get the total value of all replaced products", () => { productSku: "lake-tunes-mp3", quantity: 20, quantityFulfilled: 6, + quantityToFulfill: 14, undiscountedUnitPrice: { __typename: "TaxedMoney", currency: "USD", @@ -691,6 +768,7 @@ describe("Get the total value of all replaced products", () => { productSku: "lake-tunes-mp3", quantity: 25, quantityFulfilled: 8, + quantityToFulfill: 17, undiscountedUnitPrice: { __typename: "TaxedMoney", currency: "USD", @@ -750,6 +828,7 @@ describe("Get the total value of all replaced products", () => { productSku: "29810068", quantity: 10, quantityFulfilled: 3, + quantityToFulfill: 7, undiscountedUnitPrice: { __typename: "TaxedMoney", currency: "USD", @@ -809,6 +888,7 @@ describe("Get the total value of all replaced products", () => { productSku: "lake-tunes-mp3", quantity: 20, quantityFulfilled: 6, + quantityToFulfill: 14, undiscountedUnitPrice: { __typename: "TaxedMoney", currency: "USD", @@ -868,6 +948,7 @@ describe("Get the total value of all replaced products", () => { productSku: "lake-tunes-mp3", quantity: 25, quantityFulfilled: 8, + quantityToFulfill: 17, undiscountedUnitPrice: { __typename: "TaxedMoney", currency: "USD", @@ -1061,6 +1142,7 @@ describe("Get the total value of all selected products", () => { productSku: "lake-tunes-mp3", quantity: 2, quantityFulfilled: 2, + quantityToFulfill: 0, undiscountedUnitPrice: { __typename: "TaxedMoney", currency: "USD", @@ -1115,6 +1197,7 @@ describe("Get the total value of all selected products", () => { productSku: "lake-tunes-mp3", quantity: 10, quantityFulfilled: 2, + quantityToFulfill: 8, undiscountedUnitPrice: { __typename: "TaxedMoney", currency: "USD", @@ -1169,6 +1252,7 @@ describe("Get the total value of all selected products", () => { productSku: "29810068", quantity: 6, quantityFulfilled: 1, + quantityToFulfill: 5, undiscountedUnitPrice: { __typename: "TaxedMoney", currency: "USD", @@ -1229,6 +1313,7 @@ describe("Get the total value of all selected products", () => { productSku: "lake-tunes-mp3", quantity: 20, quantityFulfilled: 6, + quantityToFulfill: 14, undiscountedUnitPrice: { __typename: "TaxedMoney", currency: "USD", @@ -1288,6 +1373,7 @@ describe("Get the total value of all selected products", () => { productSku: "lake-tunes-mp3", quantity: 25, quantityFulfilled: 8, + quantityToFulfill: 17, undiscountedUnitPrice: { __typename: "TaxedMoney", currency: "USD", @@ -1347,6 +1433,7 @@ describe("Get the total value of all selected products", () => { productSku: "29810068", quantity: 10, quantityFulfilled: 3, + quantityToFulfill: 7, undiscountedUnitPrice: { __typename: "TaxedMoney", currency: "USD", @@ -1531,6 +1618,7 @@ describe("Merge repeated order lines of fulfillment lines", () => { productSku: "lake-tunes-mp3", quantity: 2, quantityFulfilled: 2, + quantityToFulfill: 0, undiscountedUnitPrice: { __typename: "TaxedMoney", currency: "USD", @@ -1590,6 +1678,7 @@ describe("Merge repeated order lines of fulfillment lines", () => { productSku: "lake-tunes-mp3", quantity: 2, quantityFulfilled: 2, + quantityToFulfill: 0, undiscountedUnitPrice: { __typename: "TaxedMoney", currency: "USD", @@ -1649,6 +1738,7 @@ describe("Merge repeated order lines of fulfillment lines", () => { productSku: "29810068", quantity: 3, quantityFulfilled: 1, + quantityToFulfill: 2, undiscountedUnitPrice: { __typename: "TaxedMoney", currency: "USD", diff --git a/src/orders/utils/data.ts b/src/orders/utils/data.ts index 8980507a6..3923a84a7 100644 --- a/src/orders/utils/data.ts +++ b/src/orders/utils/data.ts @@ -1,5 +1,7 @@ import { IMoney, subtractMoney } from "@saleor/components/Money"; +import { WarehouseFragment } from "@saleor/fragments/types/WarehouseFragment"; import { FormsetData } from "@saleor/hooks/useFormset"; +import { OrderErrorCode } from "@saleor/types/globalTypes"; import { LineItemData, @@ -9,11 +11,13 @@ import { getAllOrderFulfilledLines, getById } from "../components/OrderReturnPage/utils"; +import { FulfillOrder_orderFulfill_errors } from "../types/FulfillOrder"; import { OrderDetails_order, OrderDetails_order_fulfillments_lines, OrderDetails_order_lines } from "../types/OrderDetails"; +import { OrderFulfillData_order_lines } from "../types/OrderFulfillData"; import { OrderRefundData_order, OrderRefundData_order_fulfillments, @@ -25,6 +29,32 @@ export type OrderWithTotalAndTotalCaptured = Pick< "total" | "totalCaptured" >; +export interface OrderLineWithStockWarehouses { + variant?: { + stocks: Array<{ warehouse: WarehouseFragment }>; + }; +} + +export function getToFulfillOrderLines(lines?: OrderFulfillData_order_lines[]) { + return lines?.filter(line => line.quantityToFulfill > 0) || []; +} + +export function getWarehousesFromOrderLines< + T extends OrderLineWithStockWarehouses +>(lines?: T[]) { + return lines?.reduce( + (warehouses, line) => + line.variant?.stocks?.reduce( + (warehouses, stock) => + warehouses.some(getById(stock.warehouse.id)) + ? warehouses + : [...warehouses, stock.warehouse], + warehouses + ), + [] as WarehouseFragment[] + ); +} + export function getPreviouslyRefundedPrice( order: OrderWithTotalAndTotalCaptured ): IMoney { @@ -208,3 +238,28 @@ export function mergeRepeatedOrderLines( return prev; }, Array()); } + +export const isStockError = ( + overfulfill: boolean, + formsetStock: { quantity: number }, + availableQuantity: number, + warehouse: WarehouseFragment, + line: OrderFulfillData_order_lines, + errors: FulfillOrder_orderFulfill_errors[] +) => { + if (overfulfill) { + return true; + } + + const isQuantityLargerThanAvailable = + line.variant.trackInventory && formsetStock.quantity > availableQuantity; + + const isError = !!errors?.find( + err => + err.warehouse === warehouse.id && + err.orderLines.find((id: string) => id === line.id) && + err.code === OrderErrorCode.INSUFFICIENT_STOCK + ); + + return isQuantityLargerThanAvailable || isError; +}; diff --git a/src/orders/views/OrderDetails/OrderDetailsMessages.tsx b/src/orders/views/OrderDetails/OrderDetailsMessages.tsx index e05435575..929cef0dd 100644 --- a/src/orders/views/OrderDetails/OrderDetailsMessages.tsx +++ b/src/orders/views/OrderDetails/OrderDetailsMessages.tsx @@ -1,6 +1,7 @@ import messages from "@saleor/containers/BackgroundTasks/messages"; import useNavigator from "@saleor/hooks/useNavigator"; import useNotifier from "@saleor/hooks/useNotifier"; +import { OrderFulfillmentApprove } from "@saleor/orders/types/OrderFulfillmentApprove"; import getOrderErrorMessage from "@saleor/utils/errors/order"; import createDialogActionHandlers from "@saleor/utils/handlers/dialogActionHandlers"; import React from "react"; @@ -32,6 +33,7 @@ interface OrderDetailsMessages { handleDraftUpdate: (data: OrderDraftUpdate) => void; handleNoteAdd: (data: OrderAddNote) => void; handleOrderCancel: (data: OrderCancel) => void; + handleOrderFulfillmentApprove: (data: OrderFulfillmentApprove) => void; handleOrderFulfillmentCancel: (data: OrderFulfillmentCancel) => void; handleOrderFulfillmentUpdate: ( data: OrderFulfillmentUpdateTracking @@ -215,6 +217,18 @@ export const OrderDetailsMessages: React.FC = ({ ); } }; + const handleOrderFulfillmentApprove = (data: OrderFulfillmentApprove) => { + const errs = data.orderFulfillmentApprove?.errors; + if (errs.length === 0) { + pushMessage({ + status: "success", + text: intl.formatMessage({ + defaultMessage: "Fulfillment successfully approved" + }) + }); + closeModal(); + } + }; const handleOrderFulfillmentCancel = (data: OrderFulfillmentCancel) => { const errs = data.orderFulfillmentCancel?.errors; if (errs.length === 0) { @@ -299,6 +313,7 @@ export const OrderDetailsMessages: React.FC = ({ handleInvoiceSend, handleNoteAdd, handleOrderCancel, + handleOrderFulfillmentApprove, handleOrderFulfillmentCancel, handleOrderFulfillmentUpdate, handleOrderLineDelete, diff --git a/src/orders/views/OrderDetails/OrderNormalDetails/index.tsx b/src/orders/views/OrderDetails/OrderNormalDetails/index.tsx index 9dd082dae..3d1b9bf38 100644 --- a/src/orders/views/OrderDetails/OrderNormalDetails/index.tsx +++ b/src/orders/views/OrderDetails/OrderNormalDetails/index.tsx @@ -2,7 +2,13 @@ import { WindowTitle } from "@saleor/components/WindowTitle"; import useNavigator from "@saleor/hooks/useNavigator"; import useUser from "@saleor/hooks/useUser"; import OrderCannotCancelOrderDialog from "@saleor/orders/components/OrderCannotCancelOrderDialog"; +import OrderFulfillmentApproveDialog from "@saleor/orders/components/OrderFulfillmentApproveDialog"; import OrderInvoiceEmailSendDialog from "@saleor/orders/components/OrderInvoiceEmailSendDialog"; +import { + OrderFulfillmentApprove, + OrderFulfillmentApproveVariables +} from "@saleor/orders/types/OrderFulfillmentApprove"; +import { PartialMutationProviderOutput } from "@saleor/types"; import { mapEdgesToItems } from "@saleor/utils/maps"; import { useWarehouseList } from "@saleor/warehouses/queries"; import React from "react"; @@ -39,6 +45,10 @@ interface OrderNormalDetailsProps { orderPaymentMarkAsPaid: any; orderVoid: any; orderPaymentCapture: any; + orderFulfillmentApprove: PartialMutationProviderOutput< + OrderFulfillmentApprove, + OrderFulfillmentApproveVariables + >; orderFulfillmentCancel: any; orderFulfillmentUpdateTracking: any; orderInvoiceSend: any; @@ -59,6 +69,7 @@ export const OrderNormalDetails: React.FC = ({ orderPaymentMarkAsPaid, orderVoid, orderPaymentCapture, + orderFulfillmentApprove, orderFulfillmentCancel, orderFulfillmentUpdateTracking, orderInvoiceSend, @@ -68,6 +79,7 @@ export const OrderNormalDetails: React.FC = ({ closeModal }) => { const order = data?.order; + const shop = data?.shop; const navigate = useNavigator(); const { user } = useUser(); @@ -108,6 +120,7 @@ export const OrderNormalDetails: React.FC = ({ } onBack={handleBack} order={order} + shop={shop} saveButtonBarState={getMutationState( updateMetadataOpts.called || updatePrivateMetadataOpts.called, updateMetadataOpts.loading || updatePrivateMetadataOpts.loading, @@ -124,6 +137,14 @@ export const OrderNormalDetails: React.FC = ({ userPermissions={user?.userPermissions || []} onOrderCancel={() => openModal("cancel")} onOrderFulfill={() => navigate(orderFulfillUrl(id))} + onFulfillmentApprove={fulfillmentId => + navigate( + orderUrl(id, { + action: "approve-fulfillment", + id: fulfillmentId + }) + ) + } onFulfillmentCancel={fulfillmentId => navigate( orderUrl(id, { @@ -219,6 +240,21 @@ export const OrderNormalDetails: React.FC = ({ }) } /> + + orderFulfillmentApprove.mutate({ + id: params.id, + notifyCustomer + }) + } + onClose={closeModal} + /> ; orderFulfillmentCancel: any; orderFulfillmentUpdateTracking: any; orderInvoiceSend: any; @@ -73,6 +83,7 @@ export const OrderUnconfirmedDetails: React.FC = ( orderPaymentMarkAsPaid, orderVoid, orderPaymentCapture, + orderFulfillmentApprove, orderFulfillmentCancel, orderFulfillmentUpdateTracking, orderInvoiceSend, @@ -82,6 +93,7 @@ export const OrderUnconfirmedDetails: React.FC = ( closeModal }) => { const order = data.order; + const shop = data.shop; const navigate = useNavigator(); const { user } = useUser(); @@ -131,6 +143,7 @@ export const OrderUnconfirmedDetails: React.FC = ( } onBack={handleBack} order={order} + shop={shop} onOrderLineAdd={() => openModal("add-order-line")} onOrderLineChange={(id, data) => orderLineUpdate.mutate({ @@ -156,6 +169,14 @@ export const OrderUnconfirmedDetails: React.FC = ( userPermissions={user?.userPermissions || []} onOrderCancel={() => openModal("cancel")} onOrderFulfill={() => navigate(orderFulfillUrl(id))} + onFulfillmentApprove={fulfillmentId => + navigate( + orderUrl(id, { + action: "approve-fulfillment", + id: fulfillmentId + }) + ) + } onFulfillmentCancel={fulfillmentId => navigate( orderUrl(id, { @@ -292,6 +313,21 @@ export const OrderUnconfirmedDetails: React.FC = ( }) } /> + + orderFulfillmentApprove.mutate({ + id: params.id, + notifyCustomer + }) + } + onClose={closeModal} + /> = ({ id, params }) => { onOrderLineDelete={orderMessages.handleOrderLineDelete} onOrderLinesAdd={orderMessages.handleOrderLinesAdd} onOrderLineUpdate={orderMessages.handleOrderLineUpdate} + onOrderFulfillmentApprove={ + orderMessages.handleOrderFulfillmentApprove + } onOrderFulfillmentCancel={ orderMessages.handleOrderFulfillmentCancel } @@ -158,6 +161,7 @@ export const OrderDetails: React.FC = ({ id, params }) => { orderVoid, orderShippingMethodUpdate, orderUpdate, + orderFulfillmentApprove, orderFulfillmentCancel, orderFulfillmentUpdateTracking, orderDraftCancel, @@ -179,6 +183,7 @@ export const OrderDetails: React.FC = ({ id, params }) => { orderPaymentMarkAsPaid={orderPaymentMarkAsPaid} orderVoid={orderVoid} orderPaymentCapture={orderPaymentCapture} + orderFulfillmentApprove={orderFulfillmentApprove} orderFulfillmentCancel={orderFulfillmentCancel} orderFulfillmentUpdateTracking={ orderFulfillmentUpdateTracking @@ -224,6 +229,7 @@ export const OrderDetails: React.FC = ({ id, params }) => { orderPaymentMarkAsPaid={orderPaymentMarkAsPaid} orderVoid={orderVoid} orderPaymentCapture={orderPaymentCapture} + orderFulfillmentApprove={orderFulfillmentApprove} orderFulfillmentCancel={orderFulfillmentCancel} orderFulfillmentUpdateTracking={ orderFulfillmentUpdateTracking diff --git a/src/orders/views/OrderFulfill/OrderFulfill.tsx b/src/orders/views/OrderFulfill/OrderFulfill.tsx index 134ea3570..f77c4cda3 100644 --- a/src/orders/views/OrderFulfill/OrderFulfill.tsx +++ b/src/orders/views/OrderFulfill/OrderFulfill.tsx @@ -3,10 +3,12 @@ import useNavigator from "@saleor/hooks/useNavigator"; import useNotifier from "@saleor/hooks/useNotifier"; import OrderFulfillPage from "@saleor/orders/components/OrderFulfillPage"; import { useOrderFulfill } from "@saleor/orders/mutations"; -import { useOrderFulfillData } from "@saleor/orders/queries"; +import { + useOrderFulfillData, + useOrderFulfillSettingsQuery +} from "@saleor/orders/queries"; import { orderUrl } from "@saleor/orders/urls"; -import { mapEdgesToItems } from "@saleor/utils/maps"; -import { useWarehouseList } from "@saleor/warehouses/queries"; +import { getWarehousesFromOrderLines } from "@saleor/orders/utils/data"; import React from "react"; import { useIntl } from "react-intl"; @@ -18,6 +20,12 @@ const OrderFulfill: React.FC = ({ orderId }) => { const navigate = useNavigator(); const notify = useNotifier(); const intl = useIntl(); + + const { + data: settings, + loading: settingsLoading + } = useOrderFulfillSettingsQuery({}); + const { data, loading } = useOrderFulfillData({ displayLoader: true, variables: { @@ -25,12 +33,7 @@ const OrderFulfill: React.FC = ({ orderId }) => { } }); - const { data: warehouseData, loading: warehousesLoading } = useWarehouseList({ - displayLoader: true, - variables: { - first: 20 - } - }); + const orderLinesWarehouses = getWarehousesFromOrderLines(data?.order?.lines); const [fulfillOrder, fulfillOrderOpts] = useOrderFulfill({ onCompleted: data => { @@ -68,7 +71,7 @@ const OrderFulfill: React.FC = ({ orderId }) => { } /> navigate(orderUrl(orderId))} onSubmit={formData => @@ -79,7 +82,8 @@ const OrderFulfill: React.FC = ({ orderId }) => { orderLineId: line.id, stocks: line.value })), - notifyCustomer: formData.sendInfo + notifyCustomer: + settings?.shop?.fulfillmentAutoApprove && formData.sendInfo }, orderId } @@ -87,7 +91,8 @@ const OrderFulfill: React.FC = ({ orderId }) => { } order={data?.order} saveButtonBar="default" - warehouses={mapEdgesToItems(warehouseData?.warehouses)} + warehouses={orderLinesWarehouses} + shopSettings={settings?.shop} /> ); diff --git a/src/orders/views/OrderSettings.tsx b/src/orders/views/OrderSettings.tsx index 76c484805..b2fcd436b 100644 --- a/src/orders/views/OrderSettings.tsx +++ b/src/orders/views/OrderSettings.tsx @@ -22,10 +22,20 @@ export const OrderSettings: React.FC = () => { orderSettingsUpdateOpts ] = useOrderSettingsUpdateMutation({}); - const handleSubmit = async (data: OrderSettingsFormData) => { + const handleSubmit = async ({ + automaticallyConfirmAllNewOrders, + fulfillmentAutoApprove, + fulfillmentAllowUnpaid + }: OrderSettingsFormData) => { const result = await orderSettingsUpdate({ variables: { - input: data + orderSettingsInput: { + automaticallyConfirmAllNewOrders + }, + shopSettingsInput: { + fulfillmentAutoApprove, + fulfillmentAllowUnpaid + } } }); @@ -49,7 +59,8 @@ export const OrderSettings: React.FC = () => { return ( `; -exports[`Storyshots Orders / OrderFulfillmentDialog default 1`] = ` -
-`; - -exports[`Storyshots Orders / OrderFulfillmentDialog errors 1`] = ` -
-`; - exports[`Storyshots Orders / OrderFulfillmentTrackingDialog default 1`] = `
-
- -
@@ -116656,7 +116605,7 @@ exports[`Storyshots Views / Orders / Fulfill order error 1`] = ` style="padding:24px" >
-
- -
@@ -117302,7 +117212,7 @@ exports[`Storyshots Views / Orders / Fulfill order loading 1`] = ` style="padding:24px" >
- - -
-
- -
-
- - ‌ - -
-
- - - - ‌ - - - - - - ‌ - - - - + />
-
- -
@@ -117488,7 +117301,7 @@ exports[`Storyshots Views / Orders / Fulfill order one warehouse 1`] = ` style="padding:24px" >
-
- -
@@ -117945,10 +117719,14 @@ exports[`Storyshots Views / Orders / Order details cancelled 1`] = `
- Unfulfilled
+ class="CardTitle-title-id" + > + Unfulfilled +
+
@@ -118116,11 +117894,20 @@ exports[`Storyshots Views / Orders / Order details cancelled 1`] = `
- Unfulfilled
- #9-2 + Unfulfilled +
+ #9-2 +
+
+ Fulfilled from Be stocked +
@@ -118289,11 +118076,20 @@ exports[`Storyshots Views / Orders / Order details cancelled 1`] = `
- Unfulfilled
- #9-1 + Unfulfilled +
+ #9-1 +
+
+ Fulfilled from C our wares +
@@ -119861,10 +119657,14 @@ exports[`Storyshots Views / Orders / Order details default 1`] = `
- Unfulfilled
+ class="CardTitle-title-id" + > + Unfulfilled +
+
@@ -120047,11 +119847,20 @@ exports[`Storyshots Views / Orders / Order details default 1`] = `
- Fulfilled (1)
- #9-2 + Fulfilled (1) +
+ #9-2 +
+
+ Fulfilled from Be stocked +
@@ -120060,31 +119869,39 @@ exports[`Storyshots Views / Orders / Order details default 1`] = `
-
- -
+ + +
- Fulfilled (1)
- #9-1 + Fulfilled (1) +
+ #9-1 +
+
+ Fulfilled from C our wares +
@@ -120274,31 +120100,39 @@ exports[`Storyshots Views / Orders / Order details default 1`] = `
-
- -
+ + +
- Unfulfilled
+ class="CardTitle-title-id" + > + Unfulfilled +
+
@@ -122144,11 +121982,20 @@ exports[`Storyshots Views / Orders / Order details fulfilled 1`] = `
- Fulfilled (1)
- #9-2 + Fulfilled (1) +
+ #9-2 +
+
+ Fulfilled from Be stocked +
@@ -122157,31 +122004,39 @@ exports[`Storyshots Views / Orders / Order details fulfilled 1`] = `
-
- -
+ + +
- Fulfilled (1)
- #9-1 + Fulfilled (1) +
+ #9-1 +
+
+ Fulfilled from C our wares +
@@ -122371,31 +122235,39 @@ exports[`Storyshots Views / Orders / Order details fulfilled 1`] = `
-
- -
+ + +
- Unfulfilled
+ class="CardTitle-title-id" + > + Unfulfilled +
+
@@ -124837,11 +124713,20 @@ exports[`Storyshots Views / Orders / Order details no customer note 1`] = `
- Fulfilled (1)
- #9-2 + Fulfilled (1) +
+ #9-2 +
+
+ Fulfilled from Be stocked +
@@ -124850,31 +124735,39 @@ exports[`Storyshots Views / Orders / Order details no customer note 1`] = `
-
- -
+ + +
- Fulfilled (1)
- #9-1 + Fulfilled (1) +
+ #9-1 +
+
+ Fulfilled from C our wares +
@@ -125064,31 +124966,39 @@ exports[`Storyshots Views / Orders / Order details no customer note 1`] = `
-
- -
+ + +
- Unfulfilled
+ class="CardTitle-title-id" + > + Unfulfilled +
+
@@ -126934,11 +126848,20 @@ exports[`Storyshots Views / Orders / Order details no payment 1`] = `
- Fulfilled (1)
- #9-2 + Fulfilled (1) +
+ #9-2 +
+
+ Fulfilled from Be stocked +
@@ -126947,31 +126870,39 @@ exports[`Storyshots Views / Orders / Order details no payment 1`] = `
-
- -
+ + +
- Fulfilled (1)
- #9-1 + Fulfilled (1) +
+ #9-1 +
+
+ Fulfilled from C our wares +
@@ -127161,31 +127101,39 @@ exports[`Storyshots Views / Orders / Order details no payment 1`] = `
-
- -
+ + +
- Unfulfilled
+ class="CardTitle-title-id" + > + Unfulfilled +
+
@@ -129031,11 +128983,20 @@ exports[`Storyshots Views / Orders / Order details no shipping address 1`] = `
- Fulfilled (1)
- #9-2 + Fulfilled (1) +
+ #9-2 +
+
+ Fulfilled from Be stocked +
@@ -129044,31 +129005,39 @@ exports[`Storyshots Views / Orders / Order details no shipping address 1`] = `
-
- -
+ + +
- Fulfilled (1)
- #9-1 + Fulfilled (1) +
+ #9-1 +
+
+ Fulfilled from C our wares +
@@ -129258,31 +129236,39 @@ exports[`Storyshots Views / Orders / Order details no shipping address 1`] = `
-
- -
+ + +
- Unfulfilled
+ class="CardTitle-title-id" + > + Unfulfilled +
+
@@ -131128,11 +131118,20 @@ exports[`Storyshots Views / Orders / Order details partially fulfilled 1`] = `
- Fulfilled (1)
- #9-2 + Fulfilled (1) +
+ #9-2 +
+
+ Fulfilled from Be stocked +
@@ -131141,31 +131140,39 @@ exports[`Storyshots Views / Orders / Order details partially fulfilled 1`] = `
-
- -
+ + +
- Fulfilled (1)
- #9-1 + Fulfilled (1) +
+ #9-1 +
+
+ Fulfilled from C our wares +
@@ -131355,31 +131371,39 @@ exports[`Storyshots Views / Orders / Order details partially fulfilled 1`] = `
-
- -
+ + +
- Unfulfilled
+ class="CardTitle-title-id" + > + Unfulfilled +
+
@@ -133225,11 +133253,20 @@ exports[`Storyshots Views / Orders / Order details payment confirmed 1`] = `
- Fulfilled (1)
- #9-2 + Fulfilled (1) +
+ #9-2 +
+
+ Fulfilled from Be stocked +
@@ -133238,31 +133275,39 @@ exports[`Storyshots Views / Orders / Order details payment confirmed 1`] = `
-
- -
+ + +
- Fulfilled (1)
- #9-1 + Fulfilled (1) +
+ #9-1 +
+
+ Fulfilled from C our wares +
@@ -133452,31 +133506,39 @@ exports[`Storyshots Views / Orders / Order details payment confirmed 1`] = `
-
- -
+ + +
- Unfulfilled
+ class="CardTitle-title-id" + > + Unfulfilled +
+
@@ -135322,11 +135388,20 @@ exports[`Storyshots Views / Orders / Order details payment error 1`] = `
- Fulfilled (1)
- #9-2 + Fulfilled (1) +
+ #9-2 +
+
+ Fulfilled from Be stocked +
@@ -135335,31 +135410,39 @@ exports[`Storyshots Views / Orders / Order details payment error 1`] = `
-
- -
+ + +
- Fulfilled (1)
- #9-1 + Fulfilled (1) +
+ #9-1 +
+
+ Fulfilled from C our wares +
@@ -135549,31 +135641,39 @@ exports[`Storyshots Views / Orders / Order details payment error 1`] = `
-
- -
+ + +
- Unfulfilled
+ class="CardTitle-title-id" + > + Unfulfilled +
+
@@ -137419,11 +137523,20 @@ exports[`Storyshots Views / Orders / Order details pending payment 1`] = `
- Fulfilled (1)
- #9-2 + Fulfilled (1) +
+ #9-2 +
+
+ Fulfilled from Be stocked +
@@ -137432,31 +137545,39 @@ exports[`Storyshots Views / Orders / Order details pending payment 1`] = `
-
- -
+ + +
- Fulfilled (1)
- #9-1 + Fulfilled (1) +
+ #9-1 +
+
+ Fulfilled from C our wares +
@@ -137646,31 +137776,39 @@ exports[`Storyshots Views / Orders / Order details pending payment 1`] = `
-
- -
+ + +
- Unfulfilled
+ class="CardTitle-title-id" + > + Unfulfilled +
+
@@ -139516,11 +139658,20 @@ exports[`Storyshots Views / Orders / Order details refunded payment 1`] = `
- Fulfilled (1)
- #9-2 + Fulfilled (1) +
+ #9-2 +
+
+ Fulfilled from Be stocked +
@@ -139529,31 +139680,39 @@ exports[`Storyshots Views / Orders / Order details refunded payment 1`] = `
-
- -
+ + +
- Fulfilled (1)
- #9-1 + Fulfilled (1) +
+ #9-1 +
+
+ Fulfilled from C our wares +
@@ -139743,31 +139911,39 @@ exports[`Storyshots Views / Orders / Order details refunded payment 1`] = `
-
- -
+ + +
- Unfulfilled
+ class="CardTitle-title-id" + > + Unfulfilled +
+
@@ -141613,11 +141793,20 @@ exports[`Storyshots Views / Orders / Order details rejected payment 1`] = `
- Fulfilled (1)
- #9-2 + Fulfilled (1) +
+ #9-2 +
+
+ Fulfilled from Be stocked +
@@ -141626,31 +141815,39 @@ exports[`Storyshots Views / Orders / Order details rejected payment 1`] = `
-
- -
+ + +
- Fulfilled (1)
- #9-1 + Fulfilled (1) +
+ #9-1 +
+
+ Fulfilled from C our wares +
@@ -141840,31 +142046,39 @@ exports[`Storyshots Views / Orders / Order details rejected payment 1`] = `
-
- -
+ + +
- Unfulfilled
+ class="CardTitle-title-id" + > + Unfulfilled +
+
@@ -143710,11 +143928,20 @@ exports[`Storyshots Views / Orders / Order details unfulfilled 1`] = `
- Fulfilled (1)
- #9-2 + Fulfilled (1) +
+ #9-2 +
+
+ Fulfilled from Be stocked +
@@ -143723,31 +143950,39 @@ exports[`Storyshots Views / Orders / Order details unfulfilled 1`] = `
-
- -
+ + +
- Fulfilled (1)
- #9-1 + Fulfilled (1) +
+ #9-1 +
+
+ Fulfilled from C our wares +
@@ -143937,31 +144181,39 @@ exports[`Storyshots Views / Orders / Order details unfulfilled 1`] = `
-
- -
+ + +
+
+
+
+ + Fulfillment settings + +
+
+
+
+
+ +
+ +
+
@@ -155289,6 +155654,121 @@ exports[`Storyshots Views / Orders / Order settings loading 1`] = `
+
+
+
+ + Fulfillment settings + +
+
+
+
+
+ +
+ +
+
diff --git a/src/storybook/config.js b/src/storybook/config.js index f4541fdcc..98e6843d7 100644 --- a/src/storybook/config.js +++ b/src/storybook/config.js @@ -116,7 +116,6 @@ function loadStories() { require("./stories/orders/OrderDraftListPage"); require("./stories/orders/OrderDraftPage/OrderDraftPage"); require("./stories/orders/OrderFulfillmentCancelDialog"); - require("./stories/orders/OrderFulfillmentDialog"); require("./stories/orders/OrderFulfillmentTrackingDialog"); require("./stories/orders/OrderHistory"); require("./stories/orders/OrderListPage"); diff --git a/src/storybook/stories/orders/OrderDetailsPage.tsx b/src/storybook/stories/orders/OrderDetailsPage.tsx index bd100dfb2..4ab521f4b 100644 --- a/src/storybook/stories/orders/OrderDetailsPage.tsx +++ b/src/storybook/stories/orders/OrderDetailsPage.tsx @@ -6,7 +6,10 @@ import React from "react"; import OrderDetailsPage, { OrderDetailsPageProps } from "../../../orders/components/OrderDetailsPage"; -import { order as orderFixture } from "../../../orders/fixtures"; +import { + order as orderFixture, + shop as shopFixture +} from "../../../orders/fixtures"; import { FulfillmentStatus, OrderStatus, @@ -20,6 +23,7 @@ const props: Omit = { disabled: false, onBack: () => undefined, onBillingAddressEdit: undefined, + onFulfillmentApprove: () => undefined, onFulfillmentCancel: () => undefined, onFulfillmentTrackingNumberUpdate: () => undefined, onInvoiceClick: () => undefined, @@ -38,6 +42,7 @@ const props: Omit = { onShippingAddressEdit: undefined, onSubmit: () => undefined, order, + shop: shopFixture, saveButtonBarState: "default", userPermissions: adminUserPermissions }; diff --git a/src/storybook/stories/orders/OrderFulfillmentDialog.tsx b/src/storybook/stories/orders/OrderFulfillmentDialog.tsx deleted file mode 100644 index 8592005d6..000000000 --- a/src/storybook/stories/orders/OrderFulfillmentDialog.tsx +++ /dev/null @@ -1,44 +0,0 @@ -import placeholderImage from "@assets/images/placeholder60x60.png"; -import { OrderErrorCode } from "@saleor/types/globalTypes"; -import { storiesOf } from "@storybook/react"; -import React from "react"; - -import OrderFulfillmentDialog, { - OrderFulfillmentDialogProps -} from "../../../orders/components/OrderFulfillmentDialog"; -import { order as orderFixture } from "../../../orders/fixtures"; -import Decorator from "../../Decorator"; - -const order = orderFixture(placeholderImage); - -const props: Omit = { - confirmButtonState: "default", - errors: [], - lines: order.lines, - onClose: undefined, - onSubmit: undefined, - open: true -}; - -storiesOf("Orders / OrderFulfillmentDialog", module) - .addDecorator(Decorator) - .add("default", () => ) - .add("errors", () => ( - - )); diff --git a/src/types/globalTypes.ts b/src/types/globalTypes.ts index 72496fcc6..c3938662d 100644 --- a/src/types/globalTypes.ts +++ b/src/types/globalTypes.ts @@ -480,6 +480,7 @@ export enum FulfillmentStatus { REFUNDED_AND_RETURNED = "REFUNDED_AND_RETURNED", REPLACED = "REPLACED", RETURNED = "RETURNED", + WAITING_FOR_APPROVAL = "WAITING_FOR_APPROVAL", } export enum GiftCardErrorCode { @@ -1388,6 +1389,7 @@ export enum OrderErrorCode { CANNOT_CANCEL_ORDER = "CANNOT_CANCEL_ORDER", CANNOT_DELETE = "CANNOT_DELETE", CANNOT_DISCOUNT = "CANNOT_DISCOUNT", + CANNOT_FULFILL_UNPAID_ORDER = "CANNOT_FULFILL_UNPAID_ORDER", CANNOT_REFUND = "CANNOT_REFUND", CAPTURE_INACTIVE_PAYMENT = "CAPTURE_INACTIVE_PAYMENT", CHANNEL_INACTIVE = "CHANNEL_INACTIVE", @@ -1434,6 +1436,7 @@ export enum OrderEventsEnum { DRAFT_CREATED_FROM_REPLACE = "DRAFT_CREATED_FROM_REPLACE", EMAIL_SENT = "EMAIL_SENT", EXTERNAL_SERVICE_NOTIFICATION = "EXTERNAL_SERVICE_NOTIFICATION", + FULFILLMENT_AWAITS_APPROVAL = "FULFILLMENT_AWAITS_APPROVAL", FULFILLMENT_CANCELED = "FULFILLMENT_CANCELED", FULFILLMENT_FULFILLED_ITEMS = "FULFILLMENT_FULFILLED_ITEMS", FULFILLMENT_REFUNDED = "FULFILLMENT_REFUNDED", @@ -2709,6 +2712,8 @@ export interface ShopSettingsInput { trackInventoryByDefault?: boolean | null; defaultWeightUnit?: WeightUnitsEnum | null; automaticFulfillmentDigitalProducts?: boolean | null; + fulfillmentAutoApprove?: boolean | null; + fulfillmentAllowUnpaid?: boolean | null; defaultDigitalMaxDownloads?: number | null; defaultDigitalUrlValidDays?: number | null; defaultMailSenderName?: string | null;