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",
"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": {
"context": "refunded event title",
"string": "Products were refunded by "
@ -3776,6 +3780,10 @@
"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"
@ -6881,6 +6889,10 @@
"context": "table column header",
"string": "Quantity"
},
"transaction reference subtitle": {
"context": "transaction reference subtitle",
"string": "Transaction reference"
},
"voucherDetailsUnassignCategory": {
"context": "unassign category from voucher, button",
"string": "Unassign"

View file

@ -78,6 +78,11 @@ export const titles = defineMessages({
defaultMessage: "Products were returned by",
description: "returned event title",
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",
description: "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,
lines,
amount,
transactionReference,
shippingCostsIncluded,
relatedOrder
} = 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>
);
};

View file

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

View file

@ -17,6 +17,7 @@ import TableCellAvatar from "@saleor/components/TableCellAvatar";
import { FormsetChange } from "@saleor/hooks/useFormset";
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";
@ -91,7 +92,12 @@ const OrderRefundFulfilledProducts: React.FC<OrderRefundFulfilledProductsProps>
<CardTitle
title={
<>
{intl.formatMessage({
{fulfillment.status === FulfillmentStatus.RETURNED
? intl.formatMessage({
defaultMessage: "Fulfillment returned",
description: "section header returned"
})
: intl.formatMessage({
defaultMessage: "Fulfillment",
description: "section header"
})}

View file

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

View file

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

View file

@ -14489,6 +14489,16 @@ exports[`Storyshots Orders / OrderHistory default 1`] = `
>
Shipment was refunded
</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>
@ -102510,6 +102520,16 @@ exports[`Storyshots Views / Orders / Order details cancelled 1`] = `
>
Shipment was refunded
</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>
@ -104288,6 +104308,16 @@ exports[`Storyshots Views / Orders / Order details default 1`] = `
>
Shipment was refunded
</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>
@ -106096,6 +106126,16 @@ exports[`Storyshots Views / Orders / Order details fulfilled 1`] = `
>
Shipment was refunded
</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>
@ -108472,6 +108512,16 @@ exports[`Storyshots Views / Orders / Order details no customer note 1`] = `
>
Shipment was refunded
</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>
@ -110280,6 +110330,16 @@ exports[`Storyshots Views / Orders / Order details no payment 1`] = `
>
Shipment was refunded
</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>
@ -112088,6 +112148,16 @@ exports[`Storyshots Views / Orders / Order details no shipping address 1`] = `
>
Shipment was refunded
</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>
@ -113896,6 +113966,16 @@ exports[`Storyshots Views / Orders / Order details partially fulfilled 1`] = `
>
Shipment was refunded
</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>
@ -115704,6 +115784,16 @@ exports[`Storyshots Views / Orders / Order details payment confirmed 1`] = `
>
Shipment was refunded
</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>
@ -117512,6 +117602,16 @@ exports[`Storyshots Views / Orders / Order details payment error 1`] = `
>
Shipment was refunded
</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>
@ -119320,6 +119420,16 @@ exports[`Storyshots Views / Orders / Order details pending payment 1`] = `
>
Shipment was refunded
</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>
@ -121128,6 +121238,16 @@ exports[`Storyshots Views / Orders / Order details refunded payment 1`] = `
>
Shipment was refunded
</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>
@ -122936,6 +123056,16 @@ exports[`Storyshots Views / Orders / Order details rejected payment 1`] = `
>
Shipment was refunded
</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>
@ -124744,6 +124874,16 @@ exports[`Storyshots Views / Orders / Order details unfulfilled 1`] = `
>
Shipment was refunded
</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>