Skip to content

Commit

Permalink
feat(core): Expose additional price & tax data on OrderLine
Browse files Browse the repository at this point in the history
Relates to #467. The OrderLine type now exposes `taxRate`, `linePrice`, `lineTax` &
`linePriceWithTax`.

BREAKING CHANGE: The `OrderLine.totalPrice` field has been deprecated and will be removed in a
future release. Use the new `OrderLine.linePriceWithTax` field instead.
  • Loading branch information
michaelbromley committed Oct 30, 2020
1 parent 6e2d490 commit c870684
Show file tree
Hide file tree
Showing 15 changed files with 410 additions and 64 deletions.
13 changes: 13 additions & 0 deletions packages/admin-ui/src/lib/core/src/common/generated-types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2035,6 +2035,8 @@ export enum Permission {
ReadSettings = 'ReadSettings',
/** SuperAdmin has unrestricted access to all operations */
SuperAdmin = 'SuperAdmin',
/** Allows external tools to sync stock levels */
SyncInventory = 'SyncInventory',
/** Grants permission to update Administrator */
UpdateAdministrator = 'UpdateAdministrator',
/** Grants permission to update Catalog */
Expand Down Expand Up @@ -3334,8 +3336,11 @@ export type OrderItem = Node & {
createdAt: Scalars['DateTime'];
updatedAt: Scalars['DateTime'];
cancelled: Scalars['Boolean'];
/** The price of a single unit, excluding tax */
unitPrice: Scalars['Int'];
/** The price of a single unit, including tax */
unitPriceWithTax: Scalars['Int'];
/** @deprecated `unitPrice` is now always without tax */
unitPriceIncludesTax: Scalars['Boolean'];
taxRate: Scalars['Float'];
adjustments: Array<Adjustment>;
Expand All @@ -3354,7 +3359,15 @@ export type OrderLine = Node & {
unitPriceWithTax: Scalars['Int'];
quantity: Scalars['Int'];
items: Array<OrderItem>;
/** @deprecated Use `linePriceWithTax` instead */
totalPrice: Scalars['Int'];
taxRate: Scalars['Float'];
/** The total price of the line excluding tax */
linePrice: Scalars['Int'];
/** The total tax on this line */
lineTax: Scalars['Int'];
/** The total price of the line including tax */
linePriceWithTax: Scalars['Int'];
adjustments: Array<Adjustment>;
order: Order;
customFields?: Maybe<Scalars['JSON']>;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1860,6 +1860,8 @@ export enum Permission {
UpdateSettings = 'UpdateSettings',
/** Grants permission to delete Settings */
DeleteSettings = 'DeleteSettings',
/** Allows external tools to sync stock levels */
SyncInventory = 'SyncInventory',
}

export type DeletionResponse = {
Expand Down Expand Up @@ -3105,8 +3107,11 @@ export type OrderItem = Node & {
createdAt: Scalars['DateTime'];
updatedAt: Scalars['DateTime'];
cancelled: Scalars['Boolean'];
/** The price of a single unit, excluding tax */
unitPrice: Scalars['Int'];
/** The price of a single unit, including tax */
unitPriceWithTax: Scalars['Int'];
/** @deprecated `unitPrice` is now always without tax */
unitPriceIncludesTax: Scalars['Boolean'];
taxRate: Scalars['Float'];
adjustments: Array<Adjustment>;
Expand All @@ -3124,7 +3129,15 @@ export type OrderLine = Node & {
unitPriceWithTax: Scalars['Int'];
quantity: Scalars['Int'];
items: Array<OrderItem>;
/** @deprecated Use `linePriceWithTax` instead */
totalPrice: Scalars['Int'];
taxRate: Scalars['Float'];
/** The total price of the line excluding tax */
linePrice: Scalars['Int'];
/** The total tax on this line */
lineTax: Scalars['Int'];
/** The total price of the line including tax */
linePriceWithTax: Scalars['Int'];
adjustments: Array<Adjustment>;
order: Order;
customFields?: Maybe<Scalars['JSON']>;
Expand Down
13 changes: 13 additions & 0 deletions packages/common/src/generated-shop-types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -415,6 +415,8 @@ export enum Permission {
UpdateSettings = 'UpdateSettings',
/** Grants permission to delete Settings */
DeleteSettings = 'DeleteSettings',
/** Allows external tools to sync stock levels */
SyncInventory = 'SyncInventory',
}

export type DeletionResponse = {
Expand Down Expand Up @@ -2074,8 +2076,11 @@ export type OrderItem = Node & {
createdAt: Scalars['DateTime'];
updatedAt: Scalars['DateTime'];
cancelled: Scalars['Boolean'];
/** The price of a single unit, excluding tax */
unitPrice: Scalars['Int'];
/** The price of a single unit, including tax */
unitPriceWithTax: Scalars['Int'];
/** @deprecated `unitPrice` is now always without tax */
unitPriceIncludesTax: Scalars['Boolean'];
taxRate: Scalars['Float'];
adjustments: Array<Adjustment>;
Expand All @@ -2094,7 +2099,15 @@ export type OrderLine = Node & {
unitPriceWithTax: Scalars['Int'];
quantity: Scalars['Int'];
items: Array<OrderItem>;
/** @deprecated Use `linePriceWithTax` instead */
totalPrice: Scalars['Int'];
taxRate: Scalars['Float'];
/** The total price of the line excluding tax */
linePrice: Scalars['Int'];
/** The total tax on this line */
lineTax: Scalars['Int'];
/** The total price of the line including tax */
linePriceWithTax: Scalars['Int'];
adjustments: Array<Adjustment>;
order: Order;
customFields?: Maybe<Scalars['JSON']>;
Expand Down
15 changes: 14 additions & 1 deletion packages/common/src/generated-types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2014,7 +2014,9 @@ export enum Permission {
/** Grants permission to update Settings */
UpdateSettings = 'UpdateSettings',
/** Grants permission to delete Settings */
DeleteSettings = 'DeleteSettings'
DeleteSettings = 'DeleteSettings',
/** Allows external tools to sync stock levels */
SyncInventory = 'SyncInventory'
}

export type DeletionResponse = {
Expand Down Expand Up @@ -3302,8 +3304,11 @@ export type OrderItem = Node & {
createdAt: Scalars['DateTime'];
updatedAt: Scalars['DateTime'];
cancelled: Scalars['Boolean'];
/** The price of a single unit, excluding tax */
unitPrice: Scalars['Int'];
/** The price of a single unit, including tax */
unitPriceWithTax: Scalars['Int'];
/** @deprecated `unitPrice` is now always without tax */
unitPriceIncludesTax: Scalars['Boolean'];
taxRate: Scalars['Float'];
adjustments: Array<Adjustment>;
Expand All @@ -3322,7 +3327,15 @@ export type OrderLine = Node & {
unitPriceWithTax: Scalars['Int'];
quantity: Scalars['Int'];
items: Array<OrderItem>;
/** @deprecated Use `linePriceWithTax` instead */
totalPrice: Scalars['Int'];
taxRate: Scalars['Float'];
/** The total price of the line excluding tax */
linePrice: Scalars['Int'];
/** The total tax on this line */
lineTax: Scalars['Int'];
/** The total price of the line including tax */
linePriceWithTax: Scalars['Int'];
adjustments: Array<Adjustment>;
order: Order;
customFields?: Maybe<Scalars['JSON']>;
Expand Down
77 changes: 46 additions & 31 deletions packages/core/e2e/graphql/generated-e2e-admin-types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1860,6 +1860,8 @@ export enum Permission {
UpdateSettings = 'UpdateSettings',
/** Grants permission to delete Settings */
DeleteSettings = 'DeleteSettings',
/** Allows external tools to sync stock levels */
SyncInventory = 'SyncInventory',
}

export type DeletionResponse = {
Expand Down Expand Up @@ -3105,8 +3107,11 @@ export type OrderItem = Node & {
createdAt: Scalars['DateTime'];
updatedAt: Scalars['DateTime'];
cancelled: Scalars['Boolean'];
/** The price of a single unit, excluding tax */
unitPrice: Scalars['Int'];
/** The price of a single unit, including tax */
unitPriceWithTax: Scalars['Int'];
/** @deprecated `unitPrice` is now always without tax */
unitPriceIncludesTax: Scalars['Boolean'];
taxRate: Scalars['Float'];
adjustments: Array<Adjustment>;
Expand All @@ -3124,7 +3129,15 @@ export type OrderLine = Node & {
unitPriceWithTax: Scalars['Int'];
quantity: Scalars['Int'];
items: Array<OrderItem>;
/** @deprecated Use `linePriceWithTax` instead */
totalPrice: Scalars['Int'];
taxRate: Scalars['Float'];
/** The total price of the line excluding tax */
linePrice: Scalars['Int'];
/** The total tax on this line */
lineTax: Scalars['Int'];
/** The total price of the line including tax */
linePriceWithTax: Scalars['Int'];
adjustments: Array<Adjustment>;
order: Order;
customFields?: Maybe<Scalars['JSON']>;
Expand Down Expand Up @@ -5150,19 +5163,9 @@ export type UpdateRoleMutationVariables = Exact<{

export type UpdateRoleMutation = { updateRole: RoleFragment };

export type UpdateOptionGroupMutationVariables = Exact<{
input: UpdateProductOptionGroupInput;
}>;

export type UpdateOptionGroupMutation = { updateProductOptionGroup: Pick<ProductOptionGroup, 'id'> };

export type DeletePromotionAdHoc1MutationVariables = Exact<{ [key: string]: never }>;

export type DeletePromotionAdHoc1Mutation = { deletePromotion: Pick<DeletionResponse, 'result'> };

export type GetPromoProductsQueryVariables = Exact<{ [key: string]: never }>;
export type GetProductsWithVariantPricesQueryVariables = Exact<{ [key: string]: never }>;

export type GetPromoProductsQuery = {
export type GetProductsWithVariantPricesQuery = {
products: {
items: Array<
Pick<Product, 'id' | 'slug'> & {
Expand All @@ -5176,6 +5179,16 @@ export type GetPromoProductsQuery = {
};
};

export type UpdateOptionGroupMutationVariables = Exact<{
input: UpdateProductOptionGroupInput;
}>;

export type UpdateOptionGroupMutation = { updateProductOptionGroup: Pick<ProductOptionGroup, 'id'> };

export type DeletePromotionAdHoc1MutationVariables = Exact<{ [key: string]: never }>;

export type DeletePromotionAdHoc1Mutation = { deletePromotion: Pick<DeletionResponse, 'result'> };

export type SettlePaymentMutationVariables = Exact<{
id: Scalars['ID'];
}>;
Expand Down Expand Up @@ -6991,29 +7004,17 @@ export namespace UpdateRole {
export type UpdateRole = NonNullable<UpdateRoleMutation['updateRole']>;
}

export namespace UpdateOptionGroup {
export type Variables = UpdateOptionGroupMutationVariables;
export type Mutation = UpdateOptionGroupMutation;
export type UpdateProductOptionGroup = NonNullable<UpdateOptionGroupMutation['updateProductOptionGroup']>;
}

export namespace DeletePromotionAdHoc1 {
export type Variables = DeletePromotionAdHoc1MutationVariables;
export type Mutation = DeletePromotionAdHoc1Mutation;
export type DeletePromotion = NonNullable<DeletePromotionAdHoc1Mutation['deletePromotion']>;
}

export namespace GetPromoProducts {
export type Variables = GetPromoProductsQueryVariables;
export type Query = GetPromoProductsQuery;
export type Products = NonNullable<GetPromoProductsQuery['products']>;
export namespace GetProductsWithVariantPrices {
export type Variables = GetProductsWithVariantPricesQueryVariables;
export type Query = GetProductsWithVariantPricesQuery;
export type Products = NonNullable<GetProductsWithVariantPricesQuery['products']>;
export type Items = NonNullable<
NonNullable<NonNullable<GetPromoProductsQuery['products']>['items']>[number]
NonNullable<NonNullable<GetProductsWithVariantPricesQuery['products']>['items']>[number]
>;
export type Variants = NonNullable<
NonNullable<
NonNullable<
NonNullable<NonNullable<GetPromoProductsQuery['products']>['items']>[number]
NonNullable<NonNullable<GetProductsWithVariantPricesQuery['products']>['items']>[number]
>['variants']
>[number]
>;
Expand All @@ -7022,14 +7023,28 @@ export namespace GetPromoProducts {
NonNullable<
NonNullable<
NonNullable<
NonNullable<NonNullable<GetPromoProductsQuery['products']>['items']>[number]
NonNullable<
NonNullable<GetProductsWithVariantPricesQuery['products']>['items']
>[number]
>['variants']
>[number]
>['facetValues']
>[number]
>;
}

export namespace UpdateOptionGroup {
export type Variables = UpdateOptionGroupMutationVariables;
export type Mutation = UpdateOptionGroupMutation;
export type UpdateProductOptionGroup = NonNullable<UpdateOptionGroupMutation['updateProductOptionGroup']>;
}

export namespace DeletePromotionAdHoc1 {
export type Variables = DeletePromotionAdHoc1MutationVariables;
export type Mutation = DeletePromotionAdHoc1Mutation;
export type DeletePromotion = NonNullable<DeletePromotionAdHoc1Mutation['deletePromotion']>;
}

export namespace SettlePayment {
export type Variables = SettlePaymentMutationVariables;
export type Mutation = SettlePaymentMutation;
Expand Down
60 changes: 60 additions & 0 deletions packages/core/e2e/graphql/generated-e2e-shop-types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -408,6 +408,8 @@ export enum Permission {
UpdateSettings = 'UpdateSettings',
/** Grants permission to delete Settings */
DeleteSettings = 'DeleteSettings',
/** Allows external tools to sync stock levels */
SyncInventory = 'SyncInventory',
}

export type DeletionResponse = {
Expand Down Expand Up @@ -1996,8 +1998,11 @@ export type OrderItem = Node & {
createdAt: Scalars['DateTime'];
updatedAt: Scalars['DateTime'];
cancelled: Scalars['Boolean'];
/** The price of a single unit, excluding tax */
unitPrice: Scalars['Int'];
/** The price of a single unit, including tax */
unitPriceWithTax: Scalars['Int'];
/** @deprecated `unitPrice` is now always without tax */
unitPriceIncludesTax: Scalars['Boolean'];
taxRate: Scalars['Float'];
adjustments: Array<Adjustment>;
Expand All @@ -2015,7 +2020,15 @@ export type OrderLine = Node & {
unitPriceWithTax: Scalars['Int'];
quantity: Scalars['Int'];
items: Array<OrderItem>;
/** @deprecated Use `linePriceWithTax` instead */
totalPrice: Scalars['Int'];
taxRate: Scalars['Float'];
/** The total price of the line excluding tax */
linePrice: Scalars['Int'];
/** The total tax on this line */
lineTax: Scalars['Int'];
/** The total price of the line including tax */
linePriceWithTax: Scalars['Int'];
adjustments: Array<Adjustment>;
order: Order;
customFields?: Maybe<Scalars['JSON']>;
Expand Down Expand Up @@ -2831,6 +2844,30 @@ export type GetActiveOrderQueryVariables = Exact<{ [key: string]: never }>;

export type GetActiveOrderQuery = { activeOrder?: Maybe<TestOrderFragmentFragment> };

export type GetActiveOrderWithPriceDataQueryVariables = Exact<{ [key: string]: never }>;

export type GetActiveOrderWithPriceDataQuery = {
activeOrder?: Maybe<
Pick<Order, 'id' | 'subTotalBeforeTax' | 'subTotal' | 'totalBeforeTax' | 'total'> & {
lines: Array<
Pick<
OrderLine,
| 'id'
| 'unitPrice'
| 'unitPriceWithTax'
| 'taxRate'
| 'linePrice'
| 'lineTax'
| 'linePriceWithTax'
> & {
items: Array<Pick<OrderItem, 'id' | 'unitPrice' | 'unitPriceWithTax' | 'taxRate'>>;
adjustments: Array<Pick<Adjustment, 'amount' | 'type'>>;
}
>;
}
>;
};

export type AdjustItemQuantityMutationVariables = Exact<{
orderLineId: Scalars['ID'];
quantity: Scalars['Int'];
Expand Down Expand Up @@ -3287,6 +3324,29 @@ export namespace GetActiveOrder {
export type ActiveOrder = NonNullable<GetActiveOrderQuery['activeOrder']>;
}

export namespace GetActiveOrderWithPriceData {
export type Variables = GetActiveOrderWithPriceDataQueryVariables;
export type Query = GetActiveOrderWithPriceDataQuery;
export type ActiveOrder = NonNullable<GetActiveOrderWithPriceDataQuery['activeOrder']>;
export type Lines = NonNullable<
NonNullable<NonNullable<GetActiveOrderWithPriceDataQuery['activeOrder']>['lines']>[number]
>;
export type Items = NonNullable<
NonNullable<
NonNullable<
NonNullable<NonNullable<GetActiveOrderWithPriceDataQuery['activeOrder']>['lines']>[number]
>['items']
>[number]
>;
export type Adjustments = NonNullable<
NonNullable<
NonNullable<
NonNullable<NonNullable<GetActiveOrderWithPriceDataQuery['activeOrder']>['lines']>[number]
>['adjustments']
>[number]
>;
}

export namespace AdjustItemQuantity {
export type Variables = AdjustItemQuantityMutationVariables;
export type Mutation = AdjustItemQuantityMutation;
Expand Down
Loading

0 comments on commit c870684

Please sign in to comment.