Feat(orders,utils, cart): orders get endpoints and cart totals (#7010)

This commit is contained in:
Carlos R. L. Rodrigues authored and GitHub committed 2024-04-22 09:01:18 +00:00
1 parent 89143e1032
commit cc557c8752
23 files changed
+2411 -30

No files matched your search

+231 -6
View File
@@ -1,6 +1,6 @@
import { BaseFilterable } from "../dal"
import { OperatorMap } from "../dal/utils"
import { BigNumberValue } from "../totals"
import { BigNumberRawValue, BigNumberValue } from "../totals"
/**
* The adjustment line details.
@@ -22,6 +22,11 @@ export interface AdjustmentLineDTO {
*/
amount: BigNumberValue
/**
* The raw amount to adjust the original amount with.
*/
raw_amount: BigNumberRawValue
/**
* The ID of the associated cart.
*/
@@ -153,6 +158,16 @@ export interface ShippingMethodTaxLineDTO extends TaxLineDTO {
* The subtotal tax relative to the shipping method.
*/
subtotal: BigNumberValue
/**
* The raw total tax relative to the shipping method.
*/
raw_total: BigNumberRawValue
/**
* The raw subtotal tax relative to the shipping method.
*/
raw_subtotal: BigNumberRawValue
}
/**
@@ -178,6 +193,16 @@ export interface LineItemTaxLineDTO extends TaxLineDTO {
* The subtotal tax relative to the item.
*/
subtotal: BigNumberValue
/**
* The raw total tax relative to the item.
*/
raw_total: BigNumberRawValue
/**
* The raw subtotal tax relative to the item.
*/
raw_subtotal: BigNumberRawValue
}
/**
@@ -372,6 +397,46 @@ export interface CartShippingMethodDTO {
* The discount tax total of the cart shipping method.
*/
discount_tax_total: BigNumberValue
/**
* The raw original total of the cart shipping method.
*/
raw_original_total: BigNumberRawValue
/**
* The raw original subtotal of the cart shipping method.
*/
raw_original_subtotal: BigNumberRawValue
/**
* The raw original tax total of the cart shipping method.
*/
raw_original_tax_total: BigNumberRawValue
/**
* The raw total of the cart shipping method.
*/
raw_total: BigNumberRawValue
/**
* The raw subtotal of the cart shipping method.
*/
raw_subtotal: BigNumberRawValue
/**
* The raw tax total of the cart shipping method.
*/
raw_tax_total: BigNumberRawValue
/**
* The raw discount total of the cart shipping method.
*/
raw_discount_total: BigNumberRawValue
/**
* The raw discount tax total of the cart shipping method.
*/
raw_discount_tax_total: BigNumberRawValue
}
/**
@@ -432,6 +497,61 @@ export interface CartLineItemTotalsDTO {
* The discount tax total of the cart line item.
*/
discount_tax_total: BigNumberValue
/**
* The raw original total of the cart line item.
*/
raw_original_total: BigNumberRawValue
/**
* The raw original subtotal of the cart line item.
*/
raw_original_subtotal: BigNumberRawValue
/**
* The raw original tax total of the cart line item.
*/
raw_original_tax_total: BigNumberRawValue
/**
* The raw item total of the cart line item.
*/
raw_item_total: BigNumberRawValue
/**
* The raw item subtotal of the cart line item.
*/
raw_item_subtotal: BigNumberRawValue
/**
* The raw item tax total of the cart line item.
*/
raw_item_tax_total: BigNumberRawValue
/**
* The raw total of the cart line item.
*/
raw_total: BigNumberRawValue
/**
* The raw subtotal of the cart line item.
*/
raw_subtotal: BigNumberRawValue
/**
* The raw tax total of the cart line item.
*/
raw_tax_total: BigNumberRawValue
/**
* The raw discount total of the cart line item.
*/
raw_discount_total: BigNumberRawValue
/**
* The raw discount tax total of the cart line item.
*/
raw_discount_tax_total: BigNumberRawValue
}
/**
@@ -737,11 +857,6 @@ export interface CartDTO {
*/
discount_total: BigNumberValue
/**
* The raw discount total of the cart.
*/
raw_discount_total: any
/**
* The discount tax total of the cart.
*/
@@ -786,6 +901,116 @@ export interface CartDTO {
* The original shipping tax total of the cart.
*/
original_shipping_tax_total: BigNumberValue
/**
* The raw original item total of the cart.
*/
raw_original_item_total: BigNumberRawValue
/**
* The raw original item subtotal of the cart.
*/
raw_original_item_subtotal: BigNumberRawValue
/**
* The raw original item tax total of the cart.
*/
raw_original_item_tax_total: BigNumberRawValue
/**
* The raw item total of the cart.
*/
raw_item_total: BigNumberRawValue
/**
* The raw item subtotal of the cart.
*/
raw_item_subtotal: BigNumberRawValue
/**
* The raw item tax total of the cart.
*/
raw_item_tax_total: BigNumberRawValue
/**
* The raw original total of the cart.
*/
raw_original_total: BigNumberRawValue
/**
* The raw original subtotal of the cart.
*/
raw_original_subtotal: BigNumberRawValue
/**
* The raw original tax total of the cart.
*/
raw_original_tax_total: BigNumberRawValue
/**
* The raw total of the cart.
*/
raw_total: BigNumberRawValue
/**
* The raw subtotal of the cart. (Excluding taxes)
*/
raw_subtotal: BigNumberRawValue
/**
* The raw tax total of the cart.
*/
raw_tax_total: BigNumberRawValue
/**
* The raw discount total of the cart.
*/
raw_discount_total: BigNumberRawValue
/**
* The raw discount tax total of the cart.
*/
raw_discount_tax_total: BigNumberRawValue
/**
* The raw gift card total of the cart.
*/
raw_gift_card_total: BigNumberRawValue
/**
* The raw gift card tax total of the cart.
*/
raw_gift_card_tax_total: BigNumberRawValue
/**
* The raw shipping total of the cart.
*/
raw_shipping_total: BigNumberRawValue
/**
* The raw shipping subtotal of the cart.
*/
raw_shipping_subtotal: BigNumberRawValue
/**
* The raw shipping tax total of the cart.
*/
raw_shipping_tax_total: BigNumberRawValue
/**
* The raw original shipping total of the cart.
*/
raw_original_shipping_total: BigNumberRawValue
/**
* The raw original shipping subtotal of the cart.
*/
raw_original_shipping_subtotal: BigNumberRawValue
/**
* The raw original shipping tax total of the cart.
*/
raw_original_shipping_tax_total: BigNumberRawValue
}
/**
+2 -1
View File
@@ -2,8 +2,9 @@ export * from "./api-key"
export * from "./customer"
export * from "./fulfillment"
export * from "./inventory"
export * from "./order"
export * from "./pricing"
export * from "./product-category"
export * from "./sales-channel"
export * from "./stock-locations"
export * from "./tax"
export * from "./product-category"
@@ -0,0 +1,314 @@
import { BigNumberRawValue } from "../../../totals"
import { PaginatedResponse } from "../../common"
interface OrderSummary {
total: number
subtotal: number
total_tax: number
ordered_total: number
fulfilled_total: number
returned_total: number
return_request_total: number
write_off_total: number
projected_total: number
net_total: number
net_subtotal: number
net_total_tax: number
future_total: number
future_subtotal: number
future_total_tax: number
future_projected_total: number
balance: number
future_balance: number
}
interface OrderAdjustmentLine {
id: string
code?: string
amount: number
order_id: string
description?: string
promotion_id?: string
provider_id?: string
created_at: Date | string
updated_at: Date | string
}
interface OrderShippingMethodAdjustment extends OrderAdjustmentLine {
shipping_method: OrderShippingMethod
shipping_method_id: string
}
interface OrderLineItemAdjustment extends OrderAdjustmentLine {
item: OrderLineItem
item_id: string
}
interface OrderTaxLine {
id: string
description?: string
tax_rate_id?: string
code: string
rate: number
provider_id?: string
created_at: Date | string
updated_at: Date | string
}
interface OrderShippingMethodTaxLine extends OrderTaxLine {
shipping_method: OrderShippingMethod
shipping_method_id: string
total: number
subtotal: number
raw_total?: BigNumberRawValue
raw_subtotal?: BigNumberRawValue
}
interface OrderLineItemTaxLine extends OrderTaxLine {
item: OrderLineItem
item_id: string
total: number
subtotal: number
raw_total?: BigNumberRawValue
raw_subtotal?: BigNumberRawValue
}
interface OrderAddress {
id: string
customer_id?: string
first_name?: string
last_name?: string
phone?: string
company?: string
address_1?: string
address_2?: string
city?: string
country_code?: string
province?: string
postal_code?: string
metadata: Record<string, unknown> | null
created_at: Date | string
updated_at: Date | string
}
interface OrderShippingMethod {
id: string
order_id: string
name: string
description?: string
amount: number
raw_amount?: BigNumberRawValue
is_tax_inclusive: boolean
shipping_option_id: string | null
data: Record<string, unknown> | null
metadata: Record<string, unknown> | null
tax_lines?: OrderShippingMethodTaxLine[]
adjustments?: OrderShippingMethodAdjustment[]
created_at: Date | string
updated_at: Date | string
}
interface OrderLineItem {
id: string
title: string
subtitle: string | null
thumbnail: string | null
variant_id: string | null
product_id: string | null
product_title: string | null
product_description: string | null
product_subtitle: string | null
product_type: string | null
product_collection: string | null
product_handle: string | null
variant_sku: string | null
variant_barcode: string | null
variant_title: string | null
variant_option_values: Record<string, unknown> | null
requires_shipping: boolean
is_discountable: boolean
is_tax_inclusive: boolean
compare_at_unit_price?: number
raw_compare_at_unit_price?: BigNumberRawValue
unit_price: number
raw_unit_price?: BigNumberRawValue
quantity: number
raw_quantity?: BigNumberRawValue
tax_lines?: OrderLineItemTaxLine[]
adjustments?: OrderLineItemAdjustment[]
detail: OrderItemDetail
created_at: Date
updated_at: Date
metadata: Record<string, unknown> | null
original_total: number
original_subtotal: number
original_tax_total: number
item_total: number
item_subtotal: number
item_tax_total: number
total: number
subtotal: number
tax_total: number
discount_total: number
discount_tax_total: number
raw_original_total?: BigNumberRawValue
raw_original_subtotal?: BigNumberRawValue
raw_original_tax_total?: BigNumberRawValue
raw_item_total?: BigNumberRawValue
raw_item_subtotal?: BigNumberRawValue
raw_item_tax_total?: BigNumberRawValue
raw_total?: BigNumberRawValue
raw_subtotal?: BigNumberRawValue
raw_tax_total?: BigNumberRawValue
raw_discount_total?: BigNumberRawValue
raw_discount_tax_total?: BigNumberRawValue
}
interface OrderItemDetail {
id: string
item_id: string
item: OrderLineItem
quantity: number
fulfilled_quantity: number
shipped_quantity: number
return_requested_quantity: number
return_received_quantity: number
return_dismissed_quantity: number
written_off_quantity: number
raw_quantity?: BigNumberRawValue
raw_fulfilled_quantity?: BigNumberRawValue
raw_shipped_quantity?: BigNumberRawValue
raw_return_requested_quantity?: BigNumberRawValue
raw_return_received_quantity?: BigNumberRawValue
raw_return_dismissed_quantity?: BigNumberRawValue
raw_written_off_quantity?: BigNumberRawValue
metadata: Record<string, unknown> | null
created_at: Date
updated_at: Date
}
interface OrderChange {
id: string
order_id: string
actions: OrderChangeAction[]
status: string
requested_by: string | null
requested_at: Date | string | null
confirmed_by: string | null
confirmed_at: Date | string | null
declined_by: string | null
declined_reason: string | null
metadata: Record<string, unknown> | null
declined_at: Date | string | null
canceled_by: string | null
canceled_at: Date | string | null
created_at: Date | string
updated_at: Date | string
}
interface OrderChangeAction {
id: string
order_change_id: string | null
order_change: OrderChange | null
order_id: string | null
reference: string
reference_id: string
action: string
details: Record<string, unknown> | null
internal_note: string | null
created_at: Date | string
updated_at: Date | string
}
interface OrderTransaction {
id: string
order_id: string
amount: number
raw_amount?: BigNumberRawValue
currency_code: string
reference: string
reference_id: string
metadata: Record<string, unknown> | null
created_at: Date | string
updated_at: Date | string
}
/**
* @experimental
*/
export interface OrderResponse {
id: string
version: number
region_id: string | null
customer_id: string | null
sales_channel_id: string | null
email: string | null
currency_code: string
shipping_address?: OrderAddress
billing_address?: OrderAddress
items: OrderLineItem[] | null
shipping_methods: OrderShippingMethod[] | null
transactions?: OrderTransaction[]
summary: OrderSummary
metadata: Record<string, unknown> | null
created_at: string | Date
updated_at: string | Date
original_item_total: number
original_item_subtotal: number
original_item_tax_total: number
item_total: number
item_subtotal: number
item_tax_total: number
original_total: number
original_subtotal: number
original_tax_total: number
total: number
subtotal: number
tax_total: number
discount_total: number
discount_tax_total: number
gift_card_total: number
gift_card_tax_total: number
shipping_total: number
shipping_subtotal: number
shipping_tax_total: number
original_shipping_total: number
original_shipping_subtotal: number
original_shipping_tax_total: number
raw_original_item_total?: BigNumberRawValue
raw_original_item_subtotal?: BigNumberRawValue
raw_original_item_tax_total?: BigNumberRawValue
raw_item_total?: BigNumberRawValue
raw_item_subtotal?: BigNumberRawValue
raw_item_tax_total?: BigNumberRawValue
raw_original_total?: BigNumberRawValue
raw_original_subtotal?: BigNumberRawValue
raw_original_tax_total?: BigNumberRawValue
raw_total?: BigNumberRawValue
raw_subtotal?: BigNumberRawValue
raw_tax_total?: BigNumberRawValue
raw_discount_total?: BigNumberRawValue
raw_discount_tax_total?: BigNumberRawValue
raw_gift_card_total?: BigNumberRawValue
raw_gift_card_tax_total?: BigNumberRawValue
raw_shipping_total?: BigNumberRawValue
raw_shipping_subtotal?: BigNumberRawValue
raw_shipping_tax_total?: BigNumberRawValue
raw_original_shipping_total?: BigNumberRawValue
raw_original_shipping_subtotal?: BigNumberRawValue
raw_original_shipping_tax_total?: BigNumberRawValue
}
/**
* @experimental
*/
export interface AdminOrderListResponse extends PaginatedResponse {
orders: OrderResponse[]
}
/**
* @experimental
*/
export interface AdminOrderResponse {
order: OrderResponse
}
+1
View File
@@ -0,0 +1 @@
export * from "./admin"
+398 -13
View File
@@ -144,6 +144,16 @@ export interface OrderShippingMethodTaxLineDTO extends OrderTaxLineDTO {
* The subtotal tax relative to the shipping method.
*/
subtotal: BigNumberValue
/**
* The raw total tax relative to the shipping method.
*/
raw_total: BigNumberRawValue
/**
* The raw subtotal tax relative to the shipping method.
*/
raw_subtotal: BigNumberRawValue
}
export interface OrderLineItemTaxLineDTO extends OrderTaxLineDTO {
@@ -165,6 +175,16 @@ export interface OrderLineItemTaxLineDTO extends OrderTaxLineDTO {
* The subtotal tax relative to the item.
*/
subtotal: BigNumberValue
/**
* The raw total tax relative to the item.
*/
raw_total: BigNumberRawValue
/**
* The raw subtotal tax relative to the item.
*/
raw_subtotal: BigNumberRawValue
}
export interface OrderAddressDTO {
@@ -253,7 +273,12 @@ export interface OrderShippingMethodDTO {
/**
* The price of the shipping method
*/
amount: BigNumberRawValue
amount: BigNumberValue
/**
* The raw price of the shipping method
*/
raw_amount: BigNumberRawValue
/**
* Whether the shipping method price is tax inclusive or not
*/
@@ -335,22 +360,158 @@ export interface OrderShippingMethodDTO {
* The discount tax total of the order shipping method.
*/
discount_tax_total: BigNumberValue
/**
* The raw original total of the order shipping method.
*/
raw_original_total: BigNumberRawValue
/**
* The raw original subtotal of the order shipping method.
*/
raw_original_subtotal: BigNumberRawValue
/**
* The raw original tax total of the order shipping method.
*/
raw_original_tax_total: BigNumberRawValue
/**
* The raw total of the order shipping method.
*/
raw_total: BigNumberRawValue
/**
* The raw subtotal of the order shipping method.
*/
raw_subtotal: BigNumberRawValue
/**
* The raw tax total of the order shipping method.
*/
raw_tax_total: BigNumberRawValue
/**
* The raw discount total of the order shipping method.
*/
raw_discount_total: BigNumberRawValue
/**
* The raw discount tax total of the order shipping method.
*/
raw_discount_tax_total: BigNumberRawValue
}
export interface OrderLineItemTotalsDTO {
original_total: number
original_subtotal: number
original_tax_total: number
/**
* The original total of the order line item.
*/
original_total: BigNumberValue
item_total: number
item_subtotal: number
item_tax_total: number
/**
* The original subtotal of the order line item.
*/
original_subtotal: BigNumberValue
total: number
subtotal: number
tax_total: number
discount_total: number
discount_tax_total: number
/**
* The original tax total of the order line item.
*/
original_tax_total: BigNumberValue
/**
* The item total of the order line item.
*/
item_total: BigNumberValue
/**
* The item subtotal of the order line item.
*/
item_subtotal: BigNumberValue
/**
* The item tax total of the order line item.
*/
item_tax_total: BigNumberValue
/**
* The total of the order line item.
*/
total: BigNumberValue
/**
* The subtotal of the order line item.
*/
subtotal: BigNumberValue
/**
* The tax total of the order line item.
*/
tax_total: BigNumberValue
/**
* The discount total of the order line item.
*/
discount_total: BigNumberValue
/**
* The discount tax total of the order line item.
*/
discount_tax_total: BigNumberValue
/**
* The raw original total of the order line item.
*/
raw_original_total: BigNumberRawValue
/**
* The raw original subtotal of the order line item.
*/
raw_original_subtotal: BigNumberRawValue
/**
* The raw original tax total of the order line item.
*/
raw_original_tax_total: BigNumberRawValue
/**
* The raw item total of the order line item.
*/
raw_item_total: BigNumberRawValue
/**
* The raw item subtotal of the order line item.
*/
raw_item_subtotal: BigNumberRawValue
/**
* The raw item tax total of the order line item.
*/
raw_item_tax_total: BigNumberRawValue
/**
* The raw total of the order line item.
*/
raw_total: BigNumberRawValue
/**
* The raw subtotal of the order line item.
*/
raw_subtotal: BigNumberRawValue
/**
* The raw tax total of the order line item.
*/
raw_tax_total: BigNumberRawValue
/**
* The raw discount total of the order line item.
*/
raw_discount_total: BigNumberRawValue
/**
* The raw discount tax total of the order line item.
*/
raw_discount_tax_total: BigNumberRawValue
}
export interface OrderLineItemDTO extends OrderLineItemTotalsDTO {
@@ -691,6 +852,226 @@ export interface OrderDTO {
* When the order was updated.
*/
updated_at?: string | Date
/**
* The original item total of the order.
*/
original_item_total: BigNumberValue
/**
* The original item subtotal of the order.
*/
original_item_subtotal: BigNumberValue
/**
* The original item tax total of the order.
*/
original_item_tax_total: BigNumberValue
/**
* The item total of the order.
*/
item_total: BigNumberValue
/**
* The item subtotal of the order.
*/
item_subtotal: BigNumberValue
/**
* The item tax total of the order.
*/
item_tax_total: BigNumberValue
/**
* The original total of the order.
*/
original_total: BigNumberValue
/**
* The original subtotal of the order.
*/
original_subtotal: BigNumberValue
/**
* The original tax total of the order.
*/
original_tax_total: BigNumberValue
/**
* The total of the order.
*/
total: BigNumberValue
/**
* The subtotal of the order. (Excluding taxes)
*/
subtotal: BigNumberValue
/**
* The tax total of the order.
*/
tax_total: BigNumberValue
/**
* The discount total of the order.
*/
discount_total: BigNumberValue
/**
* The discount tax total of the order.
*/
discount_tax_total: BigNumberValue
/**
* The gift card total of the order.
*/
gift_card_total: BigNumberValue
/**
* The gift card tax total of the order.
*/
gift_card_tax_total: BigNumberValue
/**
* The shipping total of the order.
*/
shipping_total: BigNumberValue
/**
* The shipping subtotal of the order.
*/
shipping_subtotal: BigNumberValue
/**
* The shipping tax total of the order.
*/
shipping_tax_total: BigNumberValue
/**
* The original shipping total of the order.
*/
original_shipping_total: BigNumberValue
/**
* The original shipping subtotal of the order.
*/
original_shipping_subtotal: BigNumberValue
/**
* The original shipping tax total of the order.
*/
original_shipping_tax_total: BigNumberValue
/**
* The raw original item total of the order.
*/
raw_original_item_total: BigNumberRawValue
/**
* The raw original item subtotal of the order.
*/
raw_original_item_subtotal: BigNumberRawValue
/**
* The raw original item tax total of the order.
*/
raw_original_item_tax_total: BigNumberRawValue
/**
* The raw item total of the order.
*/
raw_item_total: BigNumberRawValue
/**
* The raw item subtotal of the order.
*/
raw_item_subtotal: BigNumberRawValue
/**
* The raw item tax total of the order.
*/
raw_item_tax_total: BigNumberRawValue
/**
* The raw original total of the order.
*/
raw_original_total: BigNumberRawValue
/**
* The raw original subtotal of the order.
*/
raw_original_subtotal: BigNumberRawValue
/**
* The raw original tax total of the order.
*/
raw_original_tax_total: BigNumberRawValue
/**
* The raw total of the order.
*/
raw_total: BigNumberRawValue
/**
* The raw subtotal of the order. (Excluding taxes)
*/
raw_subtotal: BigNumberRawValue
/**
* The raw tax total of the order.
*/
raw_tax_total: BigNumberRawValue
/**
* The raw discount total of the order.
*/
raw_discount_total: BigNumberRawValue
/**
* The raw discount tax total of the order.
*/
raw_discount_tax_total: BigNumberRawValue
/**
* The raw gift card total of the order.
*/
raw_gift_card_total: BigNumberRawValue
/**
* The raw gift card tax total of the order.
*/
raw_gift_card_tax_total: BigNumberRawValue
/**
* The raw shipping total of the order.
*/
raw_shipping_total: BigNumberRawValue
/**
* The raw shipping subtotal of the order.
*/
raw_shipping_subtotal: BigNumberRawValue
/**
* The raw shipping tax total of the order.
*/
raw_shipping_tax_total: BigNumberRawValue
/**
* The raw original shipping total of the order.
*/
raw_original_shipping_total: BigNumberRawValue
/**
* The raw original shipping subtotal of the order.
*/
raw_original_shipping_subtotal: BigNumberRawValue
/**
* The raw original shipping tax total of the order.
*/
raw_original_shipping_tax_total: BigNumberRawValue
}
export interface OrderChangeDTO {
@@ -843,7 +1224,11 @@ export interface OrderTransactionDTO {
/**
* The amount of the transaction
*/
amount: number
amount: BigNumberValue
/**
* The raw amount of the transaction
*/
raw_amount: BigNumberRawValue
/**
* The currency code of the transaction
*/