Skip to content

Commit

Permalink
feat(core): Add amount field to RefundOrderInput
Browse files Browse the repository at this point in the history
Relates to #2393
  • Loading branch information
michaelbromley committed Jan 16, 2024
1 parent 8fd6edc commit fe43b4a
Show file tree
Hide file tree
Showing 17 changed files with 269 additions and 70 deletions.
1 change: 1 addition & 0 deletions packages/admin-ui/src/lib/catalog/src/public_api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ export * from './components/collection-tree/collection-tree.component';
export * from './components/collection-tree/collection-tree.service';
export * from './components/collection-tree/collection-tree.types';
export * from './components/confirm-variant-deletion-dialog/confirm-variant-deletion-dialog.component';
export * from './components/create-facet-value-dialog/create-facet-value-dialog.component';
export * from './components/create-product-option-group-dialog/create-product-option-group-dialog.component';
export * from './components/create-product-variant-dialog/create-product-variant-dialog.component';
export * from './components/facet-detail/facet-detail.component';
Expand Down
24 changes: 21 additions & 3 deletions packages/admin-ui/src/lib/core/src/common/generated-types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1601,6 +1601,7 @@ export enum ErrorCode {
PAYMENT_STATE_TRANSITION_ERROR = 'PAYMENT_STATE_TRANSITION_ERROR',
PRODUCT_OPTION_IN_USE_ERROR = 'PRODUCT_OPTION_IN_USE_ERROR',
QUANTITY_TOO_GREAT_ERROR = 'QUANTITY_TOO_GREAT_ERROR',
REFUND_AMOUNT_ERROR = 'REFUND_AMOUNT_ERROR',
REFUND_ORDER_STATE_ERROR = 'REFUND_ORDER_STATE_ERROR',
REFUND_PAYMENT_ID_MISSING_ERROR = 'REFUND_PAYMENT_ID_MISSING_ERROR',
REFUND_STATE_TRANSITION_ERROR = 'REFUND_STATE_TRANSITION_ERROR',
Expand Down Expand Up @@ -5360,6 +5361,14 @@ export type Refund = Node & {
updatedAt: Scalars['DateTime']['output'];
};

/** Returned if `amount` is greater than the maximum un-refunded amount of the Payment */
export type RefundAmountError = ErrorResult & {
__typename?: 'RefundAmountError';
errorCode: ErrorCode;
maximumRefundable: Scalars['Int']['output'];
message: Scalars['String']['output'];
};

export type RefundLine = {
__typename?: 'RefundLine';
orderLine: OrderLine;
Expand All @@ -5371,13 +5380,20 @@ export type RefundLine = {

export type RefundOrderInput = {
adjustment: Scalars['Money']['input'];
/**
* If an amount is specified, this value will be used to create a Refund rather than calculating the
* amount automatically. This was added in v2.2 and will be the preferred way to specify the refund
* amount in the future. The `lines`, `shipping` and `adjustment` fields will likely be removed in a future
* version.
*/
amount?: InputMaybe<Scalars['Money']['input']>;
lines: Array<OrderLineInput>;
paymentId: Scalars['ID']['input'];
reason?: InputMaybe<Scalars['String']['input']>;
shipping: Scalars['Money']['input'];
};

export type RefundOrderResult = AlreadyRefundedError | MultipleOrderError | NothingToRefundError | OrderStateTransitionError | PaymentOrderMismatchError | QuantityTooGreatError | Refund | RefundOrderStateError | RefundStateTransitionError;
export type RefundOrderResult = AlreadyRefundedError | MultipleOrderError | NothingToRefundError | OrderStateTransitionError | PaymentOrderMismatchError | QuantityTooGreatError | Refund | RefundAmountError | RefundOrderStateError | RefundStateTransitionError;

/** Returned if an attempting to refund an Order which is not in the expected state */
export type RefundOrderStateError = ErrorResult & {
Expand Down Expand Up @@ -7282,7 +7298,7 @@ export type RefundOrderMutationVariables = Exact<{
}>;


export type RefundOrderMutation = { refundOrder: { __typename?: 'AlreadyRefundedError', errorCode: ErrorCode, message: string } | { __typename?: 'MultipleOrderError', errorCode: ErrorCode, message: string } | { __typename?: 'NothingToRefundError', errorCode: ErrorCode, message: string } | { __typename?: 'OrderStateTransitionError', errorCode: ErrorCode, message: string } | { __typename?: 'PaymentOrderMismatchError', errorCode: ErrorCode, message: string } | { __typename?: 'QuantityTooGreatError', errorCode: ErrorCode, message: string } | { __typename?: 'Refund', id: string, state: string, items: number, shipping: number, adjustment: number, transactionId?: string | null, paymentId: string } | { __typename?: 'RefundOrderStateError', errorCode: ErrorCode, message: string } | { __typename?: 'RefundStateTransitionError', errorCode: ErrorCode, message: string } };
export type RefundOrderMutation = { refundOrder: { __typename?: 'AlreadyRefundedError', errorCode: ErrorCode, message: string } | { __typename?: 'MultipleOrderError', errorCode: ErrorCode, message: string } | { __typename?: 'NothingToRefundError', errorCode: ErrorCode, message: string } | { __typename?: 'OrderStateTransitionError', errorCode: ErrorCode, message: string } | { __typename?: 'PaymentOrderMismatchError', errorCode: ErrorCode, message: string } | { __typename?: 'QuantityTooGreatError', errorCode: ErrorCode, message: string } | { __typename?: 'Refund', id: string, state: string, items: number, shipping: number, adjustment: number, transactionId?: string | null, paymentId: string } | { __typename?: 'RefundAmountError', errorCode: ErrorCode, message: string } | { __typename?: 'RefundOrderStateError', errorCode: ErrorCode, message: string } | { __typename?: 'RefundStateTransitionError', errorCode: ErrorCode, message: string } };

export type SettleRefundMutationVariables = Exact<{
input: SettleRefundInput;
Expand Down Expand Up @@ -8281,6 +8297,8 @@ type ErrorResult_ProductOptionInUseError_Fragment = { __typename?: 'ProductOptio

type ErrorResult_QuantityTooGreatError_Fragment = { __typename?: 'QuantityTooGreatError', errorCode: ErrorCode, message: string };

type ErrorResult_RefundAmountError_Fragment = { __typename?: 'RefundAmountError', errorCode: ErrorCode, message: string };

type ErrorResult_RefundOrderStateError_Fragment = { __typename?: 'RefundOrderStateError', errorCode: ErrorCode, message: string };

type ErrorResult_RefundPaymentIdMissingError_Fragment = { __typename?: 'RefundPaymentIdMissingError', errorCode: ErrorCode, message: string };
Expand All @@ -8289,7 +8307,7 @@ type ErrorResult_RefundStateTransitionError_Fragment = { __typename?: 'RefundSta

type ErrorResult_SettlePaymentError_Fragment = { __typename?: 'SettlePaymentError', errorCode: ErrorCode, message: string };

export type ErrorResultFragment = ErrorResult_AlreadyRefundedError_Fragment | ErrorResult_CancelActiveOrderError_Fragment | ErrorResult_CancelPaymentError_Fragment | ErrorResult_ChannelDefaultLanguageError_Fragment | ErrorResult_CouponCodeExpiredError_Fragment | ErrorResult_CouponCodeInvalidError_Fragment | ErrorResult_CouponCodeLimitError_Fragment | ErrorResult_CreateFulfillmentError_Fragment | ErrorResult_EmailAddressConflictError_Fragment | ErrorResult_EmptyOrderLineSelectionError_Fragment | ErrorResult_FacetInUseError_Fragment | ErrorResult_FulfillmentStateTransitionError_Fragment | ErrorResult_GuestCheckoutError_Fragment | ErrorResult_IneligibleShippingMethodError_Fragment | ErrorResult_InsufficientStockError_Fragment | ErrorResult_InsufficientStockOnHandError_Fragment | ErrorResult_InvalidCredentialsError_Fragment | ErrorResult_InvalidFulfillmentHandlerError_Fragment | ErrorResult_ItemsAlreadyFulfilledError_Fragment | ErrorResult_LanguageNotAvailableError_Fragment | ErrorResult_ManualPaymentStateError_Fragment | ErrorResult_MimeTypeError_Fragment | ErrorResult_MissingConditionsError_Fragment | ErrorResult_MultipleOrderError_Fragment | ErrorResult_NativeAuthStrategyError_Fragment | ErrorResult_NegativeQuantityError_Fragment | ErrorResult_NoActiveOrderError_Fragment | ErrorResult_NoChangesSpecifiedError_Fragment | ErrorResult_NothingToRefundError_Fragment | ErrorResult_OrderLimitError_Fragment | ErrorResult_OrderModificationError_Fragment | ErrorResult_OrderModificationStateError_Fragment | ErrorResult_OrderStateTransitionError_Fragment | ErrorResult_PaymentMethodMissingError_Fragment | ErrorResult_PaymentOrderMismatchError_Fragment | ErrorResult_PaymentStateTransitionError_Fragment | ErrorResult_ProductOptionInUseError_Fragment | ErrorResult_QuantityTooGreatError_Fragment | ErrorResult_RefundOrderStateError_Fragment | ErrorResult_RefundPaymentIdMissingError_Fragment | ErrorResult_RefundStateTransitionError_Fragment | ErrorResult_SettlePaymentError_Fragment;
export type ErrorResultFragment = ErrorResult_AlreadyRefundedError_Fragment | ErrorResult_CancelActiveOrderError_Fragment | ErrorResult_CancelPaymentError_Fragment | ErrorResult_ChannelDefaultLanguageError_Fragment | ErrorResult_CouponCodeExpiredError_Fragment | ErrorResult_CouponCodeInvalidError_Fragment | ErrorResult_CouponCodeLimitError_Fragment | ErrorResult_CreateFulfillmentError_Fragment | ErrorResult_EmailAddressConflictError_Fragment | ErrorResult_EmptyOrderLineSelectionError_Fragment | ErrorResult_FacetInUseError_Fragment | ErrorResult_FulfillmentStateTransitionError_Fragment | ErrorResult_GuestCheckoutError_Fragment | ErrorResult_IneligibleShippingMethodError_Fragment | ErrorResult_InsufficientStockError_Fragment | ErrorResult_InsufficientStockOnHandError_Fragment | ErrorResult_InvalidCredentialsError_Fragment | ErrorResult_InvalidFulfillmentHandlerError_Fragment | ErrorResult_ItemsAlreadyFulfilledError_Fragment | ErrorResult_LanguageNotAvailableError_Fragment | ErrorResult_ManualPaymentStateError_Fragment | ErrorResult_MimeTypeError_Fragment | ErrorResult_MissingConditionsError_Fragment | ErrorResult_MultipleOrderError_Fragment | ErrorResult_NativeAuthStrategyError_Fragment | ErrorResult_NegativeQuantityError_Fragment | ErrorResult_NoActiveOrderError_Fragment | ErrorResult_NoChangesSpecifiedError_Fragment | ErrorResult_NothingToRefundError_Fragment | ErrorResult_OrderLimitError_Fragment | ErrorResult_OrderModificationError_Fragment | ErrorResult_OrderModificationStateError_Fragment | ErrorResult_OrderStateTransitionError_Fragment | ErrorResult_PaymentMethodMissingError_Fragment | ErrorResult_PaymentOrderMismatchError_Fragment | ErrorResult_PaymentStateTransitionError_Fragment | ErrorResult_ProductOptionInUseError_Fragment | ErrorResult_QuantityTooGreatError_Fragment | ErrorResult_RefundAmountError_Fragment | ErrorResult_RefundOrderStateError_Fragment | ErrorResult_RefundPaymentIdMissingError_Fragment | ErrorResult_RefundStateTransitionError_Fragment | ErrorResult_SettlePaymentError_Fragment;

export type ShippingMethodFragment = { __typename?: 'ShippingMethod', id: string, createdAt: any, updatedAt: any, code: string, name: string, description: string, fulfillmentHandlerCode: string, checker: { __typename?: 'ConfigurableOperation', code: string, args: Array<{ __typename?: 'ConfigArg', name: string, value: string }> }, calculator: { __typename?: 'ConfigurableOperation', code: string, args: Array<{ __typename?: 'ConfigArg', name: string, value: string }> }, translations: Array<{ __typename?: 'ShippingMethodTranslation', id: string, languageCode: LanguageCode, name: string, description: string }> };

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,7 @@
"PaymentStateTransitionError",
"ProductOptionInUseError",
"QuantityTooGreatError",
"RefundAmountError",
"RefundOrderStateError",
"RefundPaymentIdMissingError",
"RefundStateTransitionError",
Expand Down Expand Up @@ -223,6 +224,7 @@
"PaymentOrderMismatchError",
"QuantityTooGreatError",
"Refund",
"RefundAmountError",
"RefundOrderStateError",
"RefundStateTransitionError"
],
Expand Down
1 change: 1 addition & 0 deletions packages/admin-ui/src/lib/core/src/public_api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ export * from './providers/bulk-action-registry/bulk-action-registry.service';
export * from './providers/bulk-action-registry/bulk-action-types';
export * from './providers/channel/channel.service';
export * from './providers/component-registry/component-registry.service';
export * from './providers/currency/currency.service';
export * from './providers/custom-detail-component/custom-detail-component-types';
export * from './providers/custom-detail-component/custom-detail-component.service';
export * from './providers/custom-field-component/custom-field-component.service';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1546,6 +1546,7 @@ export enum ErrorCode {
PAYMENT_STATE_TRANSITION_ERROR = 'PAYMENT_STATE_TRANSITION_ERROR',
PRODUCT_OPTION_IN_USE_ERROR = 'PRODUCT_OPTION_IN_USE_ERROR',
QUANTITY_TOO_GREAT_ERROR = 'QUANTITY_TOO_GREAT_ERROR',
REFUND_AMOUNT_ERROR = 'REFUND_AMOUNT_ERROR',
REFUND_ORDER_STATE_ERROR = 'REFUND_ORDER_STATE_ERROR',
REFUND_PAYMENT_ID_MISSING_ERROR = 'REFUND_PAYMENT_ID_MISSING_ERROR',
REFUND_STATE_TRANSITION_ERROR = 'REFUND_STATE_TRANSITION_ERROR',
Expand Down Expand Up @@ -5153,6 +5154,13 @@ export type Refund = Node & {
updatedAt: Scalars['DateTime']['output'];
};

/** Returned if `amount` is greater than the maximum un-refunded amount of the Payment */
export type RefundAmountError = ErrorResult & {
errorCode: ErrorCode;
maximumRefundable: Scalars['Int']['output'];
message: Scalars['String']['output'];
};

export type RefundLine = {
orderLine: OrderLine;
orderLineId: Scalars['ID']['output'];
Expand All @@ -5163,13 +5171,20 @@ export type RefundLine = {

export type RefundOrderInput = {
adjustment: Scalars['Money']['input'];
/**
* If an amount is specified, this value will be used to create a Refund rather than calculating the
* amount automatically. This was added in v2.2 and will be the preferred way to specify the refund
* amount in the future. The `lines`, `shipping` and `adjustment` fields will likely be removed in a future
* version.
*/
amount?: InputMaybe<Scalars['Money']['input']>;
lines: Array<OrderLineInput>;
paymentId: Scalars['ID']['input'];
reason?: InputMaybe<Scalars['String']['input']>;
shipping: Scalars['Money']['input'];
};

export type RefundOrderResult = AlreadyRefundedError | MultipleOrderError | NothingToRefundError | OrderStateTransitionError | PaymentOrderMismatchError | QuantityTooGreatError | Refund | RefundOrderStateError | RefundStateTransitionError;
export type RefundOrderResult = AlreadyRefundedError | MultipleOrderError | NothingToRefundError | OrderStateTransitionError | PaymentOrderMismatchError | QuantityTooGreatError | Refund | RefundAmountError | RefundOrderStateError | RefundStateTransitionError;

/** Returned if an attempting to refund an Order which is not in the expected state */
export type RefundOrderStateError = ErrorResult & {
Expand Down
18 changes: 17 additions & 1 deletion packages/common/src/generated-types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1589,6 +1589,7 @@ export enum ErrorCode {
PAYMENT_STATE_TRANSITION_ERROR = 'PAYMENT_STATE_TRANSITION_ERROR',
PRODUCT_OPTION_IN_USE_ERROR = 'PRODUCT_OPTION_IN_USE_ERROR',
QUANTITY_TOO_GREAT_ERROR = 'QUANTITY_TOO_GREAT_ERROR',
REFUND_AMOUNT_ERROR = 'REFUND_AMOUNT_ERROR',
REFUND_ORDER_STATE_ERROR = 'REFUND_ORDER_STATE_ERROR',
REFUND_PAYMENT_ID_MISSING_ERROR = 'REFUND_PAYMENT_ID_MISSING_ERROR',
REFUND_STATE_TRANSITION_ERROR = 'REFUND_STATE_TRANSITION_ERROR',
Expand Down Expand Up @@ -5282,6 +5283,14 @@ export type Refund = Node & {
updatedAt: Scalars['DateTime']['output'];
};

/** Returned if `amount` is greater than the maximum un-refunded amount of the Payment */
export type RefundAmountError = ErrorResult & {
__typename?: 'RefundAmountError';
errorCode: ErrorCode;
maximumRefundable: Scalars['Int']['output'];
message: Scalars['String']['output'];
};

export type RefundLine = {
__typename?: 'RefundLine';
orderLine: OrderLine;
Expand All @@ -5293,13 +5302,20 @@ export type RefundLine = {

export type RefundOrderInput = {
adjustment: Scalars['Money']['input'];
/**
* If an amount is specified, this value will be used to create a Refund rather than calculating the
* amount automatically. This was added in v2.2 and will be the preferred way to specify the refund
* amount in the future. The `lines`, `shipping` and `adjustment` fields will likely be removed in a future
* version.
*/
amount?: InputMaybe<Scalars['Money']['input']>;
lines: Array<OrderLineInput>;
paymentId: Scalars['ID']['input'];
reason?: InputMaybe<Scalars['String']['input']>;
shipping: Scalars['Money']['input'];
};

export type RefundOrderResult = AlreadyRefundedError | MultipleOrderError | NothingToRefundError | OrderStateTransitionError | PaymentOrderMismatchError | QuantityTooGreatError | Refund | RefundOrderStateError | RefundStateTransitionError;
export type RefundOrderResult = AlreadyRefundedError | MultipleOrderError | NothingToRefundError | OrderStateTransitionError | PaymentOrderMismatchError | QuantityTooGreatError | Refund | RefundAmountError | RefundOrderStateError | RefundStateTransitionError;

/** Returned if an attempting to refund an Order which is not in the expected state */
export type RefundOrderStateError = ErrorResult & {
Expand Down
19 changes: 17 additions & 2 deletions packages/core/e2e/graphql/generated-e2e-admin-types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1546,6 +1546,7 @@ export enum ErrorCode {
PAYMENT_STATE_TRANSITION_ERROR = 'PAYMENT_STATE_TRANSITION_ERROR',
PRODUCT_OPTION_IN_USE_ERROR = 'PRODUCT_OPTION_IN_USE_ERROR',
QUANTITY_TOO_GREAT_ERROR = 'QUANTITY_TOO_GREAT_ERROR',
REFUND_AMOUNT_ERROR = 'REFUND_AMOUNT_ERROR',
REFUND_ORDER_STATE_ERROR = 'REFUND_ORDER_STATE_ERROR',
REFUND_PAYMENT_ID_MISSING_ERROR = 'REFUND_PAYMENT_ID_MISSING_ERROR',
REFUND_STATE_TRANSITION_ERROR = 'REFUND_STATE_TRANSITION_ERROR',
Expand Down Expand Up @@ -5153,6 +5154,13 @@ export type Refund = Node & {
updatedAt: Scalars['DateTime']['output'];
};

/** Returned if `amount` is greater than the maximum un-refunded amount of the Payment */
export type RefundAmountError = ErrorResult & {
errorCode: ErrorCode;
maximumRefundable: Scalars['Int']['output'];
message: Scalars['String']['output'];
};

export type RefundLine = {
orderLine: OrderLine;
orderLineId: Scalars['ID']['output'];
Expand All @@ -5163,13 +5171,20 @@ export type RefundLine = {

export type RefundOrderInput = {
adjustment: Scalars['Money']['input'];
/**
* If an amount is specified, this value will be used to create a Refund rather than calculating the
* amount automatically. This was added in v2.2 and will be the preferred way to specify the refund
* amount in the future. The `lines`, `shipping` and `adjustment` fields will likely be removed in a future
* version.
*/
amount?: InputMaybe<Scalars['Money']['input']>;
lines: Array<OrderLineInput>;
paymentId: Scalars['ID']['input'];
reason?: InputMaybe<Scalars['String']['input']>;
shipping: Scalars['Money']['input'];
};

export type RefundOrderResult = AlreadyRefundedError | MultipleOrderError | NothingToRefundError | OrderStateTransitionError | PaymentOrderMismatchError | QuantityTooGreatError | Refund | RefundOrderStateError | RefundStateTransitionError;
export type RefundOrderResult = AlreadyRefundedError | MultipleOrderError | NothingToRefundError | OrderStateTransitionError | PaymentOrderMismatchError | QuantityTooGreatError | Refund | RefundAmountError | RefundOrderStateError | RefundStateTransitionError;

/** Returned if an attempting to refund an Order which is not in the expected state */
export type RefundOrderStateError = ErrorResult & {
Expand Down Expand Up @@ -7597,7 +7612,7 @@ export type RefundOrderMutationVariables = Exact<{
}>;


export type RefundOrderMutation = { refundOrder: { errorCode: ErrorCode, message: string } | { errorCode: ErrorCode, message: string } | { errorCode: ErrorCode, message: string } | { errorCode: ErrorCode, message: string } | { errorCode: ErrorCode, message: string } | { errorCode: ErrorCode, message: string } | { id: string, state: string, items: number, transactionId?: string | null, shipping: number, total: number, metadata?: any | null } | { errorCode: ErrorCode, message: string } | { errorCode: ErrorCode, message: string } };
export type RefundOrderMutation = { refundOrder: { errorCode: ErrorCode, message: string } | { errorCode: ErrorCode, message: string } | { errorCode: ErrorCode, message: string } | { errorCode: ErrorCode, message: string } | { errorCode: ErrorCode, message: string } | { errorCode: ErrorCode, message: string } | { id: string, state: string, items: number, transactionId?: string | null, shipping: number, total: number, metadata?: any | null } | { errorCode: ErrorCode, message: string } | { errorCode: ErrorCode, message: string } | { errorCode: ErrorCode, message: string } };

export type SettleRefundMutationVariables = Exact<{
input: SettleRefundInput;
Expand Down
Loading

0 comments on commit fe43b4a

Please sign in to comment.