Merge pull request #961 from mirumee/super-duper-urgent-return-fixes-again-2

Add returned items card to refund
This commit is contained in:
mmarkusik 2021-01-26 14:04:03 +01:00 committed by GitHub
commit 3af7117a1d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 199 additions and 9 deletions

View file

@ -70,6 +70,10 @@
"context": "draft created from replace event title", "context": "draft created from replace event title",
"string": "Draft was reissued from order " "string": "Draft was reissued from order "
}, },
"event title marked as paid": {
"context": "order marked as paid event title",
"string": "Order was marked as paid by"
},
"event title refunded": { "event title refunded": {
"context": "refunded event title", "context": "refunded event title",
"string": "Products were refunded by " "string": "Products were refunded by "
@ -3776,6 +3780,10 @@
"context": "order line total price", "context": "order line total price",
"string": "Total" "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": { "src_dot_orders_dot_components_dot_OrderRefundFulfilledProducts_dot_1134347598": {
"context": "tabel column header", "context": "tabel column header",
"string": "Price" "string": "Price"
@ -6881,6 +6889,10 @@
"context": "table column header", "context": "table column header",
"string": "Quantity" "string": "Quantity"
}, },
"transaction reference subtitle": {
"context": "transaction reference subtitle",
"string": "Transaction reference"
},
"voucherDetailsUnassignCategory": { "voucherDetailsUnassignCategory": {
"context": "unassign category from voucher, button", "context": "unassign category from voucher, button",
"string": "Unassign" "string": "Unassign"

View file

@ -78,6 +78,11 @@ export const titles = defineMessages({
defaultMessage: "Products were returned by", defaultMessage: "Products were returned by",
description: "returned event title", description: "returned event title",
id: "event title returned" id: "event title returned"
},
orderMarkedAsPaid: {
defaultMessage: "Order was marked as paid by",
description: "order marked as paid event title",
id: "event title marked as paid"
} }
}); });
@ -96,6 +101,11 @@ export const messages = defineMessages({
defaultMessage: "Shipment was refunded", defaultMessage: "Shipment was refunded",
description: "shipment refund title", description: "shipment refund title",
id: "shipment refund title" id: "shipment refund title"
},
transactionReference: {
defaultMessage: "Transaction reference",
description: "transaction reference subtitle",
id: "transaction reference subtitle"
} }
}); });
@ -115,6 +125,7 @@ const ExtendedTimelineEvent: React.FC<ExtendedTimelineEventProps> = ({
user, user,
lines, lines,
amount, amount,
transactionReference,
shippingCostsIncluded, shippingCostsIncluded,
relatedOrder relatedOrder
} = event; } = event;
@ -204,6 +215,19 @@ const ExtendedTimelineEvent: React.FC<ExtendedTimelineEventProps> = ({
)} )}
</> </>
)} )}
{!!transactionReference && (
<>
<Typography
variant="caption"
color="textSecondary"
className={classNames(classes.eventSubtitle)}
>
{intl.formatMessage(messages.transactionReference)}
</Typography>
<Typography>{transactionReference}</Typography>
</>
)}
</TimelineEvent> </TimelineEvent>
); );
}; };

View file

@ -24,7 +24,8 @@ const timelineEventTypes = {
OrderEventsEnum.FULFILLMENT_REFUNDED, OrderEventsEnum.FULFILLMENT_REFUNDED,
OrderEventsEnum.FULFILLMENT_REPLACED, OrderEventsEnum.FULFILLMENT_REPLACED,
OrderEventsEnum.FULFILLMENT_RETURNED, OrderEventsEnum.FULFILLMENT_RETURNED,
OrderEventsEnum.DRAFT_CREATED_FROM_REPLACE OrderEventsEnum.DRAFT_CREATED_FROM_REPLACE,
OrderEventsEnum.ORDER_MARKED_AS_PAID
], ],
linked: [OrderEventsEnum.ORDER_REPLACEMENT_CREATED], linked: [OrderEventsEnum.ORDER_REPLACEMENT_CREATED],
note: [OrderEventsEnum.NOTE_ADDED], note: [OrderEventsEnum.NOTE_ADDED],

View file

@ -17,6 +17,7 @@ import TableCellAvatar from "@saleor/components/TableCellAvatar";
import { FormsetChange } from "@saleor/hooks/useFormset"; import { FormsetChange } from "@saleor/hooks/useFormset";
import { renderCollection } from "@saleor/misc"; import { renderCollection } from "@saleor/misc";
import { OrderRefundData_order_fulfillments } from "@saleor/orders/types/OrderRefundData"; import { OrderRefundData_order_fulfillments } from "@saleor/orders/types/OrderRefundData";
import { FulfillmentStatus } from "@saleor/types/globalTypes";
import React from "react"; import React from "react";
import { FormattedMessage, useIntl } from "react-intl"; import { FormattedMessage, useIntl } from "react-intl";
@ -91,10 +92,15 @@ const OrderRefundFulfilledProducts: React.FC<OrderRefundFulfilledProductsProps>
<CardTitle <CardTitle
title={ title={
<> <>
{intl.formatMessage({ {fulfillment.status === FulfillmentStatus.RETURNED
defaultMessage: "Fulfillment", ? intl.formatMessage({
description: "section header" defaultMessage: "Fulfillment returned",
})} description: "section header returned"
})
: intl.formatMessage({
defaultMessage: "Fulfillment",
description: "section header"
})}
{fulfillment && ( {fulfillment && (
<Typography className={classes.orderNumber} variant="body1"> <Typography className={classes.orderNumber} variant="body1">
{`#${orderNumber}-${fulfillment?.fulfillmentOrder}`} {`#${orderNumber}-${fulfillment?.fulfillmentOrder}`}

View file

@ -24,6 +24,11 @@ import OrderRefundForm, {
OrderRefundType OrderRefundType
} from "./form"; } from "./form";
export const refundFulfilledStatuses = [
FulfillmentStatus.FULFILLED,
FulfillmentStatus.RETURNED
];
export interface OrderRefundPageProps { export interface OrderRefundPageProps {
order: OrderRefundData_order; order: OrderRefundData_order;
defaultType?: OrderRefundType; defaultType?: OrderRefundType;
@ -48,9 +53,10 @@ const OrderRefundPage: React.FC<OrderRefundPageProps> = props => {
const unfulfilledLines = order?.lines.filter( const unfulfilledLines = order?.lines.filter(
line => line.quantity !== line.quantityFulfilled line => line.quantity !== line.quantityFulfilled
); );
const fulfilledFulfillemnts = const fulfilledFulfillemnts =
order?.fulfillments.filter( order?.fulfillments.filter(({ status }) =>
fulfillment => fulfillment.status === FulfillmentStatus.FULFILLED refundFulfilledStatuses.includes(status)
) || []; ) || [];
return ( return (

View file

@ -4,10 +4,11 @@ import useFormset, {
FormsetData FormsetData
} from "@saleor/hooks/useFormset"; } from "@saleor/hooks/useFormset";
import { OrderRefundData_order } from "@saleor/orders/types/OrderRefundData"; import { OrderRefundData_order } from "@saleor/orders/types/OrderRefundData";
import { FulfillmentStatus } from "@saleor/types/globalTypes";
import handleFormSubmit from "@saleor/utils/handlers/handleFormSubmit"; import handleFormSubmit from "@saleor/utils/handlers/handleFormSubmit";
import React from "react"; import React from "react";
import { refundFulfilledStatuses } from "./OrderRefundPage";
export enum OrderRefundType { export enum OrderRefundType {
MISCELLANEOUS = "miscellaneous", MISCELLANEOUS = "miscellaneous",
PRODUCTS = "products" PRODUCTS = "products"
@ -87,7 +88,7 @@ function useOrderRefundForm(
); );
const refundedFulfilledProductQuantities = useFormset<null, string>( const refundedFulfilledProductQuantities = useFormset<null, string>(
order?.fulfillments order?.fulfillments
.filter(fulfillment => fulfillment.status === FulfillmentStatus.FULFILLED) .filter(({ status }) => refundFulfilledStatuses.includes(status))
.reduce( .reduce(
(linesQty, fulfillemnt) => (linesQty, fulfillemnt) =>
linesQty.concat( linesQty.concat(

View file

@ -14489,6 +14489,16 @@ exports[`Storyshots Orders / OrderHistory default 1`] = `
> >
Shipment was refunded Shipment was refunded
</div> </div>
<div
class="MuiTypography-root-id OrderHistory-eventSubtitle-id MuiTypography-caption-id MuiTypography-colorTextSecondary-id"
>
Transaction reference
</div>
<div
class="MuiTypography-root-id MuiTypography-body1-id"
>
123
</div>
</div> </div>
</div> </div>
</div> </div>
@ -102510,6 +102520,16 @@ exports[`Storyshots Views / Orders / Order details cancelled 1`] = `
> >
Shipment was refunded Shipment was refunded
</div> </div>
<div
class="MuiTypography-root-id OrderHistory-eventSubtitle-id MuiTypography-caption-id MuiTypography-colorTextSecondary-id"
>
Transaction reference
</div>
<div
class="MuiTypography-root-id MuiTypography-body1-id"
>
123
</div>
</div> </div>
</div> </div>
</div> </div>
@ -104288,6 +104308,16 @@ exports[`Storyshots Views / Orders / Order details default 1`] = `
> >
Shipment was refunded Shipment was refunded
</div> </div>
<div
class="MuiTypography-root-id OrderHistory-eventSubtitle-id MuiTypography-caption-id MuiTypography-colorTextSecondary-id"
>
Transaction reference
</div>
<div
class="MuiTypography-root-id MuiTypography-body1-id"
>
123
</div>
</div> </div>
</div> </div>
</div> </div>
@ -106096,6 +106126,16 @@ exports[`Storyshots Views / Orders / Order details fulfilled 1`] = `
> >
Shipment was refunded Shipment was refunded
</div> </div>
<div
class="MuiTypography-root-id OrderHistory-eventSubtitle-id MuiTypography-caption-id MuiTypography-colorTextSecondary-id"
>
Transaction reference
</div>
<div
class="MuiTypography-root-id MuiTypography-body1-id"
>
123
</div>
</div> </div>
</div> </div>
</div> </div>
@ -108472,6 +108512,16 @@ exports[`Storyshots Views / Orders / Order details no customer note 1`] = `
> >
Shipment was refunded Shipment was refunded
</div> </div>
<div
class="MuiTypography-root-id OrderHistory-eventSubtitle-id MuiTypography-caption-id MuiTypography-colorTextSecondary-id"
>
Transaction reference
</div>
<div
class="MuiTypography-root-id MuiTypography-body1-id"
>
123
</div>
</div> </div>
</div> </div>
</div> </div>
@ -110280,6 +110330,16 @@ exports[`Storyshots Views / Orders / Order details no payment 1`] = `
> >
Shipment was refunded Shipment was refunded
</div> </div>
<div
class="MuiTypography-root-id OrderHistory-eventSubtitle-id MuiTypography-caption-id MuiTypography-colorTextSecondary-id"
>
Transaction reference
</div>
<div
class="MuiTypography-root-id MuiTypography-body1-id"
>
123
</div>
</div> </div>
</div> </div>
</div> </div>
@ -112088,6 +112148,16 @@ exports[`Storyshots Views / Orders / Order details no shipping address 1`] = `
> >
Shipment was refunded Shipment was refunded
</div> </div>
<div
class="MuiTypography-root-id OrderHistory-eventSubtitle-id MuiTypography-caption-id MuiTypography-colorTextSecondary-id"
>
Transaction reference
</div>
<div
class="MuiTypography-root-id MuiTypography-body1-id"
>
123
</div>
</div> </div>
</div> </div>
</div> </div>
@ -113896,6 +113966,16 @@ exports[`Storyshots Views / Orders / Order details partially fulfilled 1`] = `
> >
Shipment was refunded Shipment was refunded
</div> </div>
<div
class="MuiTypography-root-id OrderHistory-eventSubtitle-id MuiTypography-caption-id MuiTypography-colorTextSecondary-id"
>
Transaction reference
</div>
<div
class="MuiTypography-root-id MuiTypography-body1-id"
>
123
</div>
</div> </div>
</div> </div>
</div> </div>
@ -115704,6 +115784,16 @@ exports[`Storyshots Views / Orders / Order details payment confirmed 1`] = `
> >
Shipment was refunded Shipment was refunded
</div> </div>
<div
class="MuiTypography-root-id OrderHistory-eventSubtitle-id MuiTypography-caption-id MuiTypography-colorTextSecondary-id"
>
Transaction reference
</div>
<div
class="MuiTypography-root-id MuiTypography-body1-id"
>
123
</div>
</div> </div>
</div> </div>
</div> </div>
@ -117512,6 +117602,16 @@ exports[`Storyshots Views / Orders / Order details payment error 1`] = `
> >
Shipment was refunded Shipment was refunded
</div> </div>
<div
class="MuiTypography-root-id OrderHistory-eventSubtitle-id MuiTypography-caption-id MuiTypography-colorTextSecondary-id"
>
Transaction reference
</div>
<div
class="MuiTypography-root-id MuiTypography-body1-id"
>
123
</div>
</div> </div>
</div> </div>
</div> </div>
@ -119320,6 +119420,16 @@ exports[`Storyshots Views / Orders / Order details pending payment 1`] = `
> >
Shipment was refunded Shipment was refunded
</div> </div>
<div
class="MuiTypography-root-id OrderHistory-eventSubtitle-id MuiTypography-caption-id MuiTypography-colorTextSecondary-id"
>
Transaction reference
</div>
<div
class="MuiTypography-root-id MuiTypography-body1-id"
>
123
</div>
</div> </div>
</div> </div>
</div> </div>
@ -121128,6 +121238,16 @@ exports[`Storyshots Views / Orders / Order details refunded payment 1`] = `
> >
Shipment was refunded Shipment was refunded
</div> </div>
<div
class="MuiTypography-root-id OrderHistory-eventSubtitle-id MuiTypography-caption-id MuiTypography-colorTextSecondary-id"
>
Transaction reference
</div>
<div
class="MuiTypography-root-id MuiTypography-body1-id"
>
123
</div>
</div> </div>
</div> </div>
</div> </div>
@ -122936,6 +123056,16 @@ exports[`Storyshots Views / Orders / Order details rejected payment 1`] = `
> >
Shipment was refunded Shipment was refunded
</div> </div>
<div
class="MuiTypography-root-id OrderHistory-eventSubtitle-id MuiTypography-caption-id MuiTypography-colorTextSecondary-id"
>
Transaction reference
</div>
<div
class="MuiTypography-root-id MuiTypography-body1-id"
>
123
</div>
</div> </div>
</div> </div>
</div> </div>
@ -124744,6 +124874,16 @@ exports[`Storyshots Views / Orders / Order details unfulfilled 1`] = `
> >
Shipment was refunded Shipment was refunded
</div> </div>
<div
class="MuiTypography-root-id OrderHistory-eventSubtitle-id MuiTypography-caption-id MuiTypography-colorTextSecondary-id"
>
Transaction reference
</div>
<div
class="MuiTypography-root-id MuiTypography-body1-id"
>
123
</div>
</div> </div>
</div> </div>
</div> </div>