feat: Totals calculation (#6980)
This commit is contained in:
@@ -1,11 +1,11 @@
|
||||
import { ModuleRegistrationName } from "@medusajs/modules-sdk"
|
||||
import { IPaymentModuleService } from "@medusajs/types"
|
||||
import { BigNumberInput, IPaymentModuleService } from "@medusajs/types"
|
||||
import { StepResponse, createStep } from "@medusajs/workflows-sdk"
|
||||
|
||||
type StepInput = {
|
||||
region_id: string
|
||||
currency_code: string
|
||||
amount: number
|
||||
amount: BigNumberInput
|
||||
metadata?: Record<string, unknown>
|
||||
}
|
||||
|
||||
|
||||
+6
-2
@@ -1,11 +1,15 @@
|
||||
import { ModuleRegistrationName } from "@medusajs/modules-sdk"
|
||||
import { IPaymentModuleService, PaymentProviderContext } from "@medusajs/types"
|
||||
import {
|
||||
BigNumberInput,
|
||||
IPaymentModuleService,
|
||||
PaymentProviderContext,
|
||||
} from "@medusajs/types"
|
||||
import { StepResponse, createStep } from "@medusajs/workflows-sdk"
|
||||
|
||||
interface StepInput {
|
||||
payment_collection_id: string
|
||||
provider_id: string
|
||||
amount: number
|
||||
amount: BigNumberInput
|
||||
currency_code: string
|
||||
context?: PaymentProviderContext
|
||||
data?: Record<string, unknown>
|
||||
|
||||
@@ -1,13 +1,12 @@
|
||||
import { ProductWorkflow, WorkflowTypes } from "@medusajs/types"
|
||||
|
||||
import { BigNumberInput, ProductWorkflow, WorkflowTypes } from "@medusajs/types"
|
||||
import { WorkflowArguments } from "@medusajs/workflows-sdk"
|
||||
|
||||
type VariantPrice = {
|
||||
region_id?: string
|
||||
currency_code?: string
|
||||
amount: number
|
||||
min_quantity?: number
|
||||
max_quantity?: number
|
||||
amount: BigNumberInput
|
||||
min_quantity?: BigNumberInput
|
||||
max_quantity?: BigNumberInput
|
||||
}
|
||||
|
||||
export type CreateProductVariantsPreparedData = {
|
||||
@@ -22,7 +21,8 @@ export type CreateProductVariantsPreparedData = {
|
||||
export async function createProductVariantsPrepareData({
|
||||
container,
|
||||
data,
|
||||
}: WorkflowArguments<WorkflowTypes.ProductWorkflow.CreateProductVariantsWorkflowInputDTO>): Promise<CreateProductVariantsPreparedData> {
|
||||
}: // eslint-disable-next-line max-len
|
||||
WorkflowArguments<WorkflowTypes.ProductWorkflow.CreateProductVariantsWorkflowInputDTO>): Promise<CreateProductVariantsPreparedData> {
|
||||
const productVariants: ProductWorkflow.CreateProductVariantsInputDTO[] =
|
||||
data.productVariants || []
|
||||
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
import { Modules, ModulesDefinition } from "@medusajs/modules-sdk"
|
||||
import { ProductTypes } from "@medusajs/types"
|
||||
import { BigNumberInput, ProductTypes } from "@medusajs/types"
|
||||
import { WorkflowArguments } from "@medusajs/workflows-sdk"
|
||||
|
||||
type VariantPrice = {
|
||||
region_id?: string
|
||||
currency_code?: string
|
||||
amount: number
|
||||
min_quantity?: number
|
||||
max_quantity?: number
|
||||
amount: BigNumberInput
|
||||
min_quantity?: BigNumberInput
|
||||
max_quantity?: BigNumberInput
|
||||
}
|
||||
|
||||
type HandlerInput = {
|
||||
|
||||
@@ -1,8 +1,13 @@
|
||||
import { ProductTypes, SalesChannelTypes, WorkflowTypes } from "@medusajs/types"
|
||||
import {
|
||||
BigNumberInput,
|
||||
ProductTypes,
|
||||
SalesChannelTypes,
|
||||
WorkflowTypes,
|
||||
} from "@medusajs/types"
|
||||
import {
|
||||
FeatureFlagUtils,
|
||||
kebabCase,
|
||||
ShippingProfileUtils,
|
||||
kebabCase,
|
||||
} from "@medusajs/utils"
|
||||
import { WorkflowArguments } from "@medusajs/workflows-sdk"
|
||||
|
||||
@@ -14,9 +19,9 @@ type VariantIndexAndPrices = {
|
||||
prices: {
|
||||
region_id?: string
|
||||
currency_code?: string
|
||||
amount: number
|
||||
min_quantity?: number
|
||||
max_quantity?: number
|
||||
amount: BigNumberInput
|
||||
min_quantity?: BigNumberInput
|
||||
max_quantity?: BigNumberInput
|
||||
}[]
|
||||
}
|
||||
|
||||
|
||||
@@ -1,14 +1,19 @@
|
||||
import { Modules, ModulesDefinition } from "@medusajs/modules-sdk"
|
||||
import { ProductTypes, ProductWorkflow, WorkflowTypes } from "@medusajs/types"
|
||||
import {
|
||||
BigNumberInput,
|
||||
ProductTypes,
|
||||
ProductWorkflow,
|
||||
WorkflowTypes,
|
||||
} from "@medusajs/types"
|
||||
import { MedusaV2Flag } from "@medusajs/utils"
|
||||
import { WorkflowArguments } from "@medusajs/workflows-sdk"
|
||||
|
||||
type VariantPrice = {
|
||||
region_id?: string
|
||||
currency_code?: string
|
||||
amount: number
|
||||
min_quantity?: number
|
||||
max_quantity?: number
|
||||
amount: BigNumberInput
|
||||
min_quantity?: BigNumberInput
|
||||
max_quantity?: BigNumberInput
|
||||
}
|
||||
|
||||
export type UpdateProductVariantsPreparedData = {
|
||||
|
||||
@@ -1,4 +1,9 @@
|
||||
import { ProductDTO, SalesChannelDTO, WorkflowTypes } from "@medusajs/types"
|
||||
import {
|
||||
BigNumberInput,
|
||||
ProductDTO,
|
||||
SalesChannelDTO,
|
||||
WorkflowTypes,
|
||||
} from "@medusajs/types"
|
||||
import { MedusaV2Flag } from "@medusajs/utils"
|
||||
import { WorkflowArguments } from "@medusajs/workflows-sdk"
|
||||
|
||||
@@ -9,9 +14,9 @@ type ProductWithSalesChannelsDTO = ProductDTO & {
|
||||
type VariantPrice = {
|
||||
region_id?: string
|
||||
currency_code?: string
|
||||
amount: number
|
||||
min_quantity?: number
|
||||
max_quantity?: number
|
||||
amount: BigNumberInput
|
||||
min_quantity?: BigNumberInput
|
||||
max_quantity?: BigNumberInput
|
||||
}
|
||||
|
||||
export type UpdateProductsPreparedData = {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { PricingTypes } from "@medusajs/types"
|
||||
import { BigNumberInput, PricingTypes } from "@medusajs/types"
|
||||
import { MedusaV2Flag } from "@medusajs/utils"
|
||||
import { WorkflowArguments } from "@medusajs/workflows-sdk"
|
||||
|
||||
@@ -6,9 +6,9 @@ type VariantPrice = {
|
||||
id?: string
|
||||
region_id?: string
|
||||
currency_code: string
|
||||
amount: number
|
||||
min_quantity?: number
|
||||
max_quantity?: number
|
||||
amount: BigNumberInput
|
||||
min_quantity?: BigNumberInput
|
||||
max_quantity?: BigNumberInput
|
||||
rules: Record<string, string>
|
||||
}
|
||||
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
import { ModuleRegistrationName } from "@medusajs/modules-sdk"
|
||||
import { IPaymentModuleService } from "@medusajs/types"
|
||||
import { BigNumberInput, IPaymentModuleService } from "@medusajs/types"
|
||||
import { StepResponse, createStep } from "@medusajs/workflows-sdk"
|
||||
|
||||
type StepInput = {
|
||||
payment_id: string
|
||||
captured_by?: string
|
||||
amount?: number
|
||||
amount?: BigNumberInput
|
||||
}
|
||||
|
||||
export const capturePaymentStepId = "capture-payment-step"
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
import { ModuleRegistrationName } from "@medusajs/modules-sdk"
|
||||
import { IPaymentModuleService } from "@medusajs/types"
|
||||
import { BigNumberInput, IPaymentModuleService } from "@medusajs/types"
|
||||
import { StepResponse, createStep } from "@medusajs/workflows-sdk"
|
||||
|
||||
type StepInput = {
|
||||
payment_id: string
|
||||
created_by?: string
|
||||
amount?: number
|
||||
amount?: BigNumberInput
|
||||
}
|
||||
|
||||
export const refundPaymentStepId = "refund-payment-step"
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { PaymentDTO } from "@medusajs/types"
|
||||
import { BigNumberInput, PaymentDTO } from "@medusajs/types"
|
||||
import { WorkflowData, createWorkflow } from "@medusajs/workflows-sdk"
|
||||
import { capturePaymentStep } from "../steps/capture-payment"
|
||||
|
||||
@@ -9,7 +9,7 @@ export const capturePaymentWorkflow = createWorkflow(
|
||||
input: WorkflowData<{
|
||||
payment_id: string
|
||||
captured_by?: string
|
||||
amount?: number
|
||||
amount?: BigNumberInput
|
||||
}>
|
||||
): WorkflowData<PaymentDTO> => {
|
||||
const payment = capturePaymentStep(input)
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
import { BigNumberInput } from "@medusajs/types"
|
||||
import { WorkflowData, createWorkflow } from "@medusajs/workflows-sdk"
|
||||
import { refundPaymentStep } from "../steps/refund-payment"
|
||||
|
||||
@@ -8,7 +9,7 @@ export const refundPaymentWorkflow = createWorkflow(
|
||||
input: WorkflowData<{
|
||||
payment_id: string
|
||||
created_by?: string
|
||||
amount?: number
|
||||
amount?: BigNumberInput
|
||||
}>
|
||||
) => {
|
||||
const payment = refundPaymentStep(input)
|
||||
|
||||
Reference in New Issue
Block a user