Feat(order): order changes (#6614)

This is a PR to keep them relatively small. Very likely changes, validations and other features will be added.

What:
  Basic methods to cancel, confirm or decline order changes
  Apply order changes to modify and create a new version of an order

Things related to calculation, Order and Item totals are not covered in this PR. Properties won't match with definition, etc.

Co-authored-by: Adrien de Peretti <25098370+adrien2p@users.noreply.github.com>
This commit is contained in:
Carlos R. L. Rodrigues
2024-03-07 15:24:05 -03:00
committed by GitHub
parent e4acde1aa2
commit 43399c8d0d
34 changed files with 2138 additions and 338 deletions

View File

@@ -2,7 +2,7 @@ import { BaseFilterable } from "../dal"
import { OperatorMap } from "../dal/utils"
import { BigNumberRawValue } from "../totals"
type OrderSummary = {
export type OrderSummaryDTO = {
total: number
subtotal: number
total_tax: number
@@ -600,10 +600,17 @@ export interface OrderDTO {
* @expandable
*/
shipping_methods?: OrderShippingMethodDTO[]
/**
* The tramsactions associated with the order
*
* @expandable
*/
transactions?: OrderTransactionDTO[]
/**
* The summary of the order totals.
*/
summary?: OrderSummary
summary?: OrderSummaryDTO
/**
* Holds custom data in key-value pairs.
*/
@@ -633,6 +640,13 @@ export interface OrderChangeDTO {
* @expandable
*/
order: OrderDTO
/**
* The actions of the order change
*
* @expandable
*/
actions: OrderChangeActionDTO[]
/**
* The status of the order change
*/
@@ -695,13 +709,24 @@ export interface OrderChangeActionDTO {
/**
* The ID of the associated order change
*/
order_change_id: string
order_change_id: string | null
/**
* The associated order change
*
* @expandable
*/
order_change: OrderChangeDTO
order_change: OrderChangeDTO | null
/**
* The ID of the associated order
*/
order_id: string | null
/**
* The associated order
*
* @expandable
*/
order: OrderDTO | null
/**
* The reference of the order change action
*/

View File

@@ -40,11 +40,13 @@ export interface CreateOrderDTO {
no_notification?: boolean
items?: CreateOrderLineItemDTO[]
shipping_methods?: CreateOrderShippingMethodDTO[]
transactions?: CreateOrderTransactionDTO[]
metadata?: Record<string, unknown>
}
export interface UpdateOrderDTO {
id: string
id?: string
version?: number
region_id?: string
customer_id?: string
sales_channel_id?: string
@@ -234,17 +236,10 @@ export interface UpdateOrderShippingMethodAdjustmentDTO {
export interface CreateOrderChangeDTO {
order_id: string
status: string
description?: string
internal_note?: string
requested_by?: string
requested_at?: Date
confirmed_by?: string
confirmed_at?: Date
declined_by?: string
declined_reason?: string
declined_at?: Date
canceled_by?: string
metadata?: Record<string, unknown>
}
@@ -264,6 +259,24 @@ export interface UpdateOrderChangeDTO {
metadata?: Record<string, unknown>
}
export interface CancelOrderChangeDTO {
id: string
canceled_by?: string
metadata?: Record<string, unknown>
}
export interface DeclineOrderChangeDTO {
id: string
declined_by?: string
metadata?: Record<string, unknown>
}
export interface ConfirmOrderChangeDTO {
id: string
confirmed_by?: string
metadata?: Record<string, unknown>
}
/** ORDER CHANGE END */
/** ORDER CHANGE ACTION START */

View File

@@ -11,6 +11,7 @@ import {
FilterableOrderShippingMethodProps,
FilterableOrderShippingMethodTaxLineProps,
OrderAddressDTO,
OrderChangeDTO,
OrderDTO,
OrderItemDTO,
OrderLineItemAdjustmentDTO,
@@ -21,8 +22,11 @@ import {
OrderShippingMethodTaxLineDTO,
} from "./common"
import {
CancelOrderChangeDTO,
ConfirmOrderChangeDTO,
CreateOrderAddressDTO,
CreateOrderAdjustmentDTO,
CreateOrderChangeDTO,
CreateOrderDTO,
CreateOrderLineItemDTO,
CreateOrderLineItemForOrderDTO,
@@ -30,6 +34,7 @@ import {
CreateOrderShippingMethodAdjustmentDTO,
CreateOrderShippingMethodDTO,
CreateOrderShippingMethodTaxLineDTO,
DeclineOrderChangeDTO,
UpdateOrderAddressDTO,
UpdateOrderDTO,
UpdateOrderItemDTO,
@@ -356,4 +361,55 @@ export interface IOrderModuleService extends IModuleService {
selector: FilterableOrderShippingMethodTaxLineProps,
sharedContext?: Context
): Promise<void>
// Order Change
createOrderChange(
data: CreateOrderChangeDTO,
sharedContext?: Context
): Promise<OrderChangeDTO>
createOrderChange(
data: CreateOrderChangeDTO[],
sharedContext?: Context
): Promise<OrderChangeDTO[]>
createOrderChange(
data: CreateOrderChangeDTO | CreateOrderChangeDTO[],
sharedContext?: Context
): Promise<OrderChangeDTO | OrderChangeDTO[]>
cancelOrderChange(orderId: string, sharedContext?: Context): Promise<void>
cancelOrderChange(orderId: string[], sharedContext?: Context): Promise<void>
cancelOrderChange(
data: CancelOrderChangeDTO,
sharedContext?: Context
): Promise<void>
cancelOrderChange(
data: CancelOrderChangeDTO[],
sharedContext?: Context
): Promise<void>
confirmOrderChange(orderId: string, sharedContext?: Context): Promise<void>
confirmOrderChange(orderId: string[], sharedContext?: Context): Promise<void>
confirmOrderChange(
data: ConfirmOrderChangeDTO,
sharedContext?: Context
): Promise<void>
confirmOrderChange(
data: ConfirmOrderChangeDTO[],
sharedContext?: Context
): Promise<void>
declineOrderChange(orderId: string, sharedContext?: Context): Promise<void>
declineOrderChange(orderId: string[], sharedContext?: Context): Promise<void>
declineOrderChange(
data: DeclineOrderChangeDTO,
sharedContext?: Context
): Promise<void>
declineOrderChange(
data: DeclineOrderChangeDTO[],
sharedContext?: Context
): Promise<void>
applyPendingOrderActions(orderId: string | string[], sharedContext?: Context)
addOrderAction(data: any, sharedContext?: Context)
}