feat(promotion,dashboard,types,utils,medusa): Add statuses to promotions (#10950)
what: - adds a status column to promotion table - introduce active promotion query - scope revert, register and compute actions to active promotions - admin to create and update promotion with statuses RESOLVES CMRC-845 RESOLVES CMRC-846 RESOLVES CMRC-847 RESOLVES CMRC-848 RESOLVES CMRC-849 RESOLVES CMRC-850
This commit is contained in:
@@ -1,11 +1,12 @@
|
||||
import { RemoteLink } from "@medusajs/modules-sdk"
|
||||
import { medusaIntegrationTestRunner } from "@medusajs/test-utils"
|
||||
import { ICartModuleService, IPromotionModuleService } from "@medusajs/types"
|
||||
import {
|
||||
ContainerRegistrationKeys,
|
||||
Modules,
|
||||
PromotionStatus,
|
||||
PromotionType,
|
||||
} from "@medusajs/utils"
|
||||
import { medusaIntegrationTestRunner } from "@medusajs/test-utils"
|
||||
import {
|
||||
adminHeaders,
|
||||
createAdminUser,
|
||||
@@ -48,11 +49,12 @@ medusaIntegrationTestRunner({
|
||||
await promotionModuleService.createPromotions({
|
||||
code: "PROMOTION_APPLIED",
|
||||
type: PromotionType.STANDARD,
|
||||
status: PromotionStatus.ACTIVE,
|
||||
application_method: {
|
||||
type: "fixed",
|
||||
target_type: "items",
|
||||
allocation: "each",
|
||||
value: "300",
|
||||
value: 300,
|
||||
apply_to_quantity: 1,
|
||||
currency_code: "usd",
|
||||
max_quantity: 1,
|
||||
@@ -70,11 +72,12 @@ medusaIntegrationTestRunner({
|
||||
await promotionModuleService.createPromotions({
|
||||
code: "PROMOTION_TEST",
|
||||
type: PromotionType.STANDARD,
|
||||
status: PromotionStatus.ACTIVE,
|
||||
application_method: {
|
||||
type: "fixed",
|
||||
target_type: "items",
|
||||
allocation: "across",
|
||||
value: "1000",
|
||||
value: 1000,
|
||||
apply_to_quantity: 1,
|
||||
currency_code: "usd",
|
||||
target_rules: [
|
||||
@@ -165,6 +168,7 @@ medusaIntegrationTestRunner({
|
||||
{
|
||||
code: "PROMOTION_APPLIED",
|
||||
type: PromotionType.STANDARD,
|
||||
status: PromotionStatus.ACTIVE,
|
||||
rules: [
|
||||
{
|
||||
attribute: "customer_id",
|
||||
@@ -181,7 +185,7 @@ medusaIntegrationTestRunner({
|
||||
type: "fixed",
|
||||
target_type: "shipping_methods",
|
||||
allocation: "each",
|
||||
value: "100",
|
||||
value: 100,
|
||||
max_quantity: 1,
|
||||
currency_code: "usd",
|
||||
target_rules: [
|
||||
@@ -199,6 +203,7 @@ medusaIntegrationTestRunner({
|
||||
{
|
||||
code: "PROMOTION_NEW",
|
||||
type: PromotionType.STANDARD,
|
||||
status: PromotionStatus.ACTIVE,
|
||||
rules: [
|
||||
{
|
||||
attribute: "customer_id",
|
||||
@@ -215,7 +220,7 @@ medusaIntegrationTestRunner({
|
||||
type: "fixed",
|
||||
target_type: "shipping_methods",
|
||||
allocation: "each",
|
||||
value: "200",
|
||||
value: 200,
|
||||
max_quantity: 1,
|
||||
currency_code: "usd",
|
||||
target_rules: [
|
||||
|
||||
@@ -19,6 +19,7 @@ import {
|
||||
MedusaError,
|
||||
Modules,
|
||||
ProductStatus,
|
||||
PromotionStatus,
|
||||
PromotionType,
|
||||
} from "@medusajs/utils"
|
||||
import {
|
||||
@@ -1266,6 +1267,7 @@ medusaIntegrationTestRunner({
|
||||
{
|
||||
code: "TEST",
|
||||
type: PromotionType.STANDARD,
|
||||
status: PromotionStatus.ACTIVE,
|
||||
is_automatic: true,
|
||||
campaign: {
|
||||
campaign_identifier: "test",
|
||||
|
||||
@@ -1,11 +1,12 @@
|
||||
import { RemoteLink } from "@medusajs/modules-sdk"
|
||||
import { medusaIntegrationTestRunner } from "@medusajs/test-utils"
|
||||
import { ICartModuleService, IPromotionModuleService } from "@medusajs/types"
|
||||
import {
|
||||
ContainerRegistrationKeys,
|
||||
Modules,
|
||||
PromotionStatus,
|
||||
PromotionType,
|
||||
} from "@medusajs/utils"
|
||||
import { medusaIntegrationTestRunner } from "@medusajs/test-utils"
|
||||
import {
|
||||
adminHeaders,
|
||||
createAdminUser,
|
||||
@@ -48,11 +49,12 @@ medusaIntegrationTestRunner({
|
||||
await promotionModuleService.createPromotions({
|
||||
code: "PROMOTION_APPLIED",
|
||||
type: PromotionType.STANDARD,
|
||||
status: PromotionStatus.ACTIVE,
|
||||
application_method: {
|
||||
type: "fixed",
|
||||
target_type: "items",
|
||||
allocation: "each",
|
||||
value: "300",
|
||||
value: 300,
|
||||
apply_to_quantity: 1,
|
||||
currency_code: "usd",
|
||||
max_quantity: 1,
|
||||
@@ -70,11 +72,12 @@ medusaIntegrationTestRunner({
|
||||
await promotionModuleService.createPromotions({
|
||||
code: "PROMOTION_APPLIED_TO_REMOVE",
|
||||
type: PromotionType.STANDARD,
|
||||
status: PromotionStatus.ACTIVE,
|
||||
application_method: {
|
||||
type: "fixed",
|
||||
target_type: "items",
|
||||
allocation: "each",
|
||||
value: "300",
|
||||
value: 300,
|
||||
apply_to_quantity: 1,
|
||||
currency_code: "usd",
|
||||
max_quantity: 1,
|
||||
@@ -180,6 +183,7 @@ medusaIntegrationTestRunner({
|
||||
const appliedPromotion =
|
||||
await promotionModuleService.createPromotions({
|
||||
code: "PROMOTION_APPLIED",
|
||||
status: PromotionStatus.ACTIVE,
|
||||
type: PromotionType.STANDARD,
|
||||
rules: [
|
||||
{
|
||||
@@ -197,7 +201,7 @@ medusaIntegrationTestRunner({
|
||||
type: "fixed",
|
||||
target_type: "shipping_methods",
|
||||
allocation: "each",
|
||||
value: "100",
|
||||
value: 100,
|
||||
max_quantity: 1,
|
||||
currency_code: "usd",
|
||||
target_rules: [
|
||||
@@ -214,6 +218,7 @@ medusaIntegrationTestRunner({
|
||||
await promotionModuleService.createPromotions({
|
||||
code: "PROMOTION_APPLIED_TO_REMOVE",
|
||||
type: PromotionType.STANDARD,
|
||||
status: PromotionStatus.ACTIVE,
|
||||
rules: [
|
||||
{
|
||||
attribute: "customer_id",
|
||||
@@ -230,7 +235,7 @@ medusaIntegrationTestRunner({
|
||||
type: "fixed",
|
||||
target_type: "shipping_methods",
|
||||
allocation: "each",
|
||||
value: "100",
|
||||
value: 100,
|
||||
max_quantity: 1,
|
||||
currency_code: "usd",
|
||||
target_rules: [
|
||||
|
||||
Reference in New Issue
Block a user