Add mmissing no return button and logic
This commit is contained in:
parent
5dd63128b4
commit
430f80ac58
5 changed files with 49 additions and 18 deletions
|
@ -14,7 +14,8 @@ export enum OrderRefundType {
|
|||
}
|
||||
export enum OrderRefundAmountCalculationMode {
|
||||
AUTOMATIC = "automatic",
|
||||
MANUAL = "manual"
|
||||
MANUAL = "manual",
|
||||
NONE = "none"
|
||||
}
|
||||
|
||||
export interface OrderRefundData {
|
||||
|
|
|
@ -82,6 +82,7 @@ interface OrderRefundAmountProps {
|
|||
isReturn?: boolean;
|
||||
errors: OrderErrorFragment[];
|
||||
amountData: OrderRefundAmountValuesProps;
|
||||
allowNoRefund?: boolean;
|
||||
onChange: (event: React.ChangeEvent<any>) => void;
|
||||
onRefund: () => void;
|
||||
}
|
||||
|
@ -96,7 +97,8 @@ const OrderRefundAmount: React.FC<OrderRefundAmountProps> = props => {
|
|||
onRefund,
|
||||
isReturn = false,
|
||||
amountData,
|
||||
disableSubmitButton
|
||||
disableSubmitButton,
|
||||
allowNoRefund = false
|
||||
} = props;
|
||||
const classes = useStyles(props);
|
||||
const intl = useIntl();
|
||||
|
@ -144,6 +146,17 @@ const OrderRefundAmount: React.FC<OrderRefundAmountProps> = props => {
|
|||
onChange={onChange}
|
||||
name="amountCalculationMode"
|
||||
>
|
||||
{allowNoRefund && (
|
||||
<FormControlLabel
|
||||
disabled={disabled}
|
||||
value={OrderRefundAmountCalculationMode.NONE}
|
||||
control={<Radio color="primary" />}
|
||||
label={intl.formatMessage({
|
||||
defaultMessage: "No refund",
|
||||
description: "label"
|
||||
})}
|
||||
/>
|
||||
)}
|
||||
<FormControlLabel
|
||||
disabled={disabled}
|
||||
value={OrderRefundAmountCalculationMode.AUTOMATIC}
|
||||
|
@ -153,6 +166,18 @@ const OrderRefundAmount: React.FC<OrderRefundAmountProps> = props => {
|
|||
description: "label"
|
||||
})}
|
||||
/>
|
||||
{data.amountCalculationMode ===
|
||||
OrderRefundAmountCalculationMode.NONE && (
|
||||
<>
|
||||
<CardSpacer />
|
||||
<OrderRefundAmountValues
|
||||
authorizedAmount={authorizedAmount}
|
||||
previouslyRefunded={previouslyRefunded}
|
||||
maxRefund={maxRefund}
|
||||
shipmentCost={data.refundShipmentCosts && shipmentCost}
|
||||
/>
|
||||
</>
|
||||
)}
|
||||
{data.amountCalculationMode ===
|
||||
OrderRefundAmountCalculationMode.AUTOMATIC && (
|
||||
<>
|
||||
|
|
|
@ -107,6 +107,7 @@ const OrderRefundPage: React.FC<OrderReturnPageProps> = props => {
|
|||
</div>
|
||||
<div>
|
||||
<OrderAmount
|
||||
allowNoRefund
|
||||
isReturn
|
||||
amountData={getReturnProductsAmountValues(order, data)}
|
||||
data={data}
|
||||
|
|
|
@ -137,24 +137,24 @@ const getPartialProductsValue = ({
|
|||
itemsQuantities: FormsetData<LineItemData, number>;
|
||||
orderLines: OrderDetails_order_lines[];
|
||||
}) =>
|
||||
itemsQuantities.reduce((resultAmount, { id, value: quantity }) => {
|
||||
const {
|
||||
value: isItemToBeReplaced,
|
||||
data: { isRefunded }
|
||||
} = itemsToBeReplaced.find(getById(id));
|
||||
itemsQuantities.reduce(
|
||||
(resultAmount, { id, value: quantity, data: { isRefunded } }) => {
|
||||
const { value: isItemToBeReplaced } = itemsToBeReplaced.find(getById(id));
|
||||
|
||||
if (quantity < 1 || isItemToBeReplaced || isRefunded) {
|
||||
return resultAmount;
|
||||
}
|
||||
if (quantity < 1 || isItemToBeReplaced || isRefunded) {
|
||||
return resultAmount;
|
||||
}
|
||||
|
||||
const { selectedQuantity, unitPrice } = getItemPriceAndQuantity({
|
||||
id,
|
||||
itemsQuantities,
|
||||
orderLines
|
||||
});
|
||||
const { selectedQuantity, unitPrice } = getItemPriceAndQuantity({
|
||||
id,
|
||||
itemsQuantities,
|
||||
orderLines
|
||||
});
|
||||
|
||||
return resultAmount + unitPrice.gross.amount * selectedQuantity;
|
||||
}, 0);
|
||||
return resultAmount + unitPrice.gross.amount * selectedQuantity;
|
||||
},
|
||||
0
|
||||
);
|
||||
|
||||
export function getRefundedLinesPriceSum(
|
||||
lines: OrderRefundData_order_lines[],
|
||||
|
|
|
@ -78,7 +78,11 @@ class ReturnFormDataParser {
|
|||
orderLines: OrderReturnLineInput[],
|
||||
fulfillmentLines: OrderReturnFulfillmentLineInput[]
|
||||
) => {
|
||||
if (!this.order.totalCaptured?.amount) {
|
||||
if (
|
||||
!this.order.totalCaptured?.amount ||
|
||||
this.formData.amountCalculationMode ===
|
||||
OrderRefundAmountCalculationMode.NONE
|
||||
) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue