feat(types): promotion module uses big number (#6522)
what: - promotion modules (application method and campaign budget) uses big number fields instead of numeric fields - refreshes the migrations to include new fields for big numbers - adds a promotion_ prefix to promotion models - uses `take: null` within the module to prevent the default pagination on performing actions within the module
This commit is contained in:
@@ -0,0 +1,5 @@
|
|||||||
|
---
|
||||||
|
"@medusajs/types": patch
|
||||||
|
---
|
||||||
|
|
||||||
|
feat(types): promotion module uses big number
|
||||||
@@ -1,13 +1,13 @@
|
|||||||
import { initDb, useDb } from "../../../../environment-helpers/use-db"
|
import { initDb, useDb } from "../../../../environment-helpers/use-db"
|
||||||
|
|
||||||
import { CampaignBudgetType } from "@medusajs/utils"
|
|
||||||
import { IPromotionModuleService } from "@medusajs/types"
|
|
||||||
import { ModuleRegistrationName } from "@medusajs/modules-sdk"
|
import { ModuleRegistrationName } from "@medusajs/modules-sdk"
|
||||||
import { createAdminUser } from "../../../helpers/create-admin-user"
|
import { IPromotionModuleService } from "@medusajs/types"
|
||||||
import { getContainer } from "../../../../environment-helpers/use-container"
|
import { CampaignBudgetType } from "@medusajs/utils"
|
||||||
import path from "path"
|
import path from "path"
|
||||||
import { startBootstrapApp } from "../../../../environment-helpers/bootstrap-app"
|
import { startBootstrapApp } from "../../../../environment-helpers/bootstrap-app"
|
||||||
import { useApi } from "../../../../environment-helpers/use-api"
|
import { useApi } from "../../../../environment-helpers/use-api"
|
||||||
|
import { getContainer } from "../../../../environment-helpers/use-container"
|
||||||
|
import { createAdminUser } from "../../../helpers/create-admin-user"
|
||||||
|
|
||||||
jest.setTimeout(50000)
|
jest.setTimeout(50000)
|
||||||
|
|
||||||
@@ -101,6 +101,14 @@ describe("GET /admin/campaigns", () => {
|
|||||||
type: "spend",
|
type: "spend",
|
||||||
limit: 1000,
|
limit: 1000,
|
||||||
used: 0,
|
used: 0,
|
||||||
|
raw_limit: {
|
||||||
|
precision: 20,
|
||||||
|
value: "1000",
|
||||||
|
},
|
||||||
|
raw_used: {
|
||||||
|
precision: 20,
|
||||||
|
value: "0",
|
||||||
|
},
|
||||||
created_at: expect.any(String),
|
created_at: expect.any(String),
|
||||||
updated_at: expect.any(String),
|
updated_at: expect.any(String),
|
||||||
deleted_at: null,
|
deleted_at: null,
|
||||||
@@ -123,6 +131,14 @@ describe("GET /admin/campaigns", () => {
|
|||||||
type: "usage",
|
type: "usage",
|
||||||
limit: 1000,
|
limit: 1000,
|
||||||
used: 0,
|
used: 0,
|
||||||
|
raw_limit: {
|
||||||
|
precision: 20,
|
||||||
|
value: "1000",
|
||||||
|
},
|
||||||
|
raw_used: {
|
||||||
|
precision: 20,
|
||||||
|
value: "0",
|
||||||
|
},
|
||||||
created_at: expect.any(String),
|
created_at: expect.any(String),
|
||||||
updated_at: expect.any(String),
|
updated_at: expect.any(String),
|
||||||
deleted_at: null,
|
deleted_at: null,
|
||||||
|
|||||||
@@ -1,13 +1,13 @@
|
|||||||
import { initDb, useDb } from "../../../../environment-helpers/use-db"
|
import { initDb, useDb } from "../../../../environment-helpers/use-db"
|
||||||
|
|
||||||
import { CampaignBudgetType } from "@medusajs/utils"
|
|
||||||
import { IPromotionModuleService } from "@medusajs/types"
|
|
||||||
import { ModuleRegistrationName } from "@medusajs/modules-sdk"
|
import { ModuleRegistrationName } from "@medusajs/modules-sdk"
|
||||||
import { createAdminUser } from "../../../helpers/create-admin-user"
|
import { IPromotionModuleService } from "@medusajs/types"
|
||||||
import { getContainer } from "../../../../environment-helpers/use-container"
|
import { CampaignBudgetType } from "@medusajs/utils"
|
||||||
import path from "path"
|
import path from "path"
|
||||||
import { startBootstrapApp } from "../../../../environment-helpers/bootstrap-app"
|
import { startBootstrapApp } from "../../../../environment-helpers/bootstrap-app"
|
||||||
import { useApi } from "../../../../environment-helpers/use-api"
|
import { useApi } from "../../../../environment-helpers/use-api"
|
||||||
|
import { getContainer } from "../../../../environment-helpers/use-container"
|
||||||
|
import { createAdminUser } from "../../../helpers/create-admin-user"
|
||||||
|
|
||||||
jest.setTimeout(50000)
|
jest.setTimeout(50000)
|
||||||
|
|
||||||
@@ -102,6 +102,14 @@ describe("GET /admin/campaigns", () => {
|
|||||||
campaign: expect.any(Object),
|
campaign: expect.any(Object),
|
||||||
type: "spend",
|
type: "spend",
|
||||||
limit: 1000,
|
limit: 1000,
|
||||||
|
raw_limit: {
|
||||||
|
precision: 20,
|
||||||
|
value: "1000",
|
||||||
|
},
|
||||||
|
raw_used: {
|
||||||
|
precision: 20,
|
||||||
|
value: "0",
|
||||||
|
},
|
||||||
used: 0,
|
used: 0,
|
||||||
created_at: expect.any(String),
|
created_at: expect.any(String),
|
||||||
updated_at: expect.any(String),
|
updated_at: expect.any(String),
|
||||||
|
|||||||
+4
-4
@@ -1,11 +1,11 @@
|
|||||||
|
import { Modules } from "@medusajs/modules-sdk"
|
||||||
import { IPromotionModuleService } from "@medusajs/types"
|
import { IPromotionModuleService } from "@medusajs/types"
|
||||||
import { SqlEntityManager } from "@mikro-orm/postgresql"
|
import { SqlEntityManager } from "@mikro-orm/postgresql"
|
||||||
|
import { initModules } from "medusa-test-utils"
|
||||||
import { createCampaigns } from "../../../__fixtures__/campaigns"
|
import { createCampaigns } from "../../../__fixtures__/campaigns"
|
||||||
import { createPromotions } from "../../../__fixtures__/promotion"
|
import { createPromotions } from "../../../__fixtures__/promotion"
|
||||||
import { MikroOrmWrapper } from "../../../utils"
|
import { MikroOrmWrapper } from "../../../utils"
|
||||||
import { getInitModuleConfig } from "../../../utils/get-init-module-config"
|
import { getInitModuleConfig } from "../../../utils/get-init-module-config"
|
||||||
import { initModules } from "medusa-test-utils"
|
|
||||||
import { Modules } from "@medusajs/modules-sdk"
|
|
||||||
|
|
||||||
jest.setTimeout(30000)
|
jest.setTimeout(30000)
|
||||||
|
|
||||||
@@ -92,11 +92,11 @@ describe("Promotion Module Service: Campaigns", () => {
|
|||||||
{
|
{
|
||||||
id: "campaign-id-1",
|
id: "campaign-id-1",
|
||||||
name: "campaign 1",
|
name: "campaign 1",
|
||||||
budget: {
|
budget: expect.objectContaining({
|
||||||
id: expect.any(String),
|
id: expect.any(String),
|
||||||
campaign: expect.any(Object),
|
campaign: expect.any(Object),
|
||||||
limit: 1000,
|
limit: 1000,
|
||||||
},
|
}),
|
||||||
},
|
},
|
||||||
])
|
])
|
||||||
})
|
})
|
||||||
|
|||||||
+74
-74
@@ -83,7 +83,7 @@ describe("Promotion Service: computeActions", () => {
|
|||||||
type: "fixed",
|
type: "fixed",
|
||||||
target_type: "items",
|
target_type: "items",
|
||||||
allocation: "each",
|
allocation: "each",
|
||||||
value: "200",
|
value: 200,
|
||||||
max_quantity: 1,
|
max_quantity: 1,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@@ -126,7 +126,7 @@ describe("Promotion Service: computeActions", () => {
|
|||||||
type: "fixed",
|
type: "fixed",
|
||||||
target_type: "items",
|
target_type: "items",
|
||||||
allocation: "each",
|
allocation: "each",
|
||||||
value: "200",
|
value: 200,
|
||||||
max_quantity: 1,
|
max_quantity: 1,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@@ -179,7 +179,7 @@ describe("Promotion Service: computeActions", () => {
|
|||||||
type: "fixed",
|
type: "fixed",
|
||||||
target_type: "items",
|
target_type: "items",
|
||||||
allocation: "each",
|
allocation: "each",
|
||||||
value: "200",
|
value: 200,
|
||||||
max_quantity: 1,
|
max_quantity: 1,
|
||||||
target_rules: [
|
target_rules: [
|
||||||
{
|
{
|
||||||
@@ -256,7 +256,7 @@ describe("Promotion Service: computeActions", () => {
|
|||||||
type: "fixed",
|
type: "fixed",
|
||||||
target_type: "items",
|
target_type: "items",
|
||||||
allocation: "each",
|
allocation: "each",
|
||||||
value: "30",
|
value: 30,
|
||||||
max_quantity: 2,
|
max_quantity: 2,
|
||||||
target_rules: [
|
target_rules: [
|
||||||
{
|
{
|
||||||
@@ -284,7 +284,7 @@ describe("Promotion Service: computeActions", () => {
|
|||||||
type: "fixed",
|
type: "fixed",
|
||||||
target_type: "items",
|
target_type: "items",
|
||||||
allocation: "each",
|
allocation: "each",
|
||||||
value: "50",
|
value: 50,
|
||||||
max_quantity: 1,
|
max_quantity: 1,
|
||||||
target_rules: [
|
target_rules: [
|
||||||
{
|
{
|
||||||
@@ -376,7 +376,7 @@ describe("Promotion Service: computeActions", () => {
|
|||||||
type: "fixed",
|
type: "fixed",
|
||||||
target_type: "items",
|
target_type: "items",
|
||||||
allocation: "each",
|
allocation: "each",
|
||||||
value: "500",
|
value: 500,
|
||||||
max_quantity: 2,
|
max_quantity: 2,
|
||||||
target_rules: [
|
target_rules: [
|
||||||
{
|
{
|
||||||
@@ -404,7 +404,7 @@ describe("Promotion Service: computeActions", () => {
|
|||||||
type: "fixed",
|
type: "fixed",
|
||||||
target_type: "items",
|
target_type: "items",
|
||||||
allocation: "each",
|
allocation: "each",
|
||||||
value: "50",
|
value: 50,
|
||||||
max_quantity: 1,
|
max_quantity: 1,
|
||||||
target_rules: [
|
target_rules: [
|
||||||
{
|
{
|
||||||
@@ -487,7 +487,7 @@ describe("Promotion Service: computeActions", () => {
|
|||||||
type: "fixed",
|
type: "fixed",
|
||||||
target_type: "items",
|
target_type: "items",
|
||||||
allocation: "each",
|
allocation: "each",
|
||||||
value: "500",
|
value: 500,
|
||||||
max_quantity: 5,
|
max_quantity: 5,
|
||||||
target_rules: [
|
target_rules: [
|
||||||
{
|
{
|
||||||
@@ -550,7 +550,7 @@ describe("Promotion Service: computeActions", () => {
|
|||||||
type: "fixed",
|
type: "fixed",
|
||||||
target_type: "items",
|
target_type: "items",
|
||||||
allocation: "each",
|
allocation: "each",
|
||||||
value: "500",
|
value: 500,
|
||||||
max_quantity: 5,
|
max_quantity: 5,
|
||||||
target_rules: [
|
target_rules: [
|
||||||
{
|
{
|
||||||
@@ -612,7 +612,7 @@ describe("Promotion Service: computeActions", () => {
|
|||||||
type: ApplicationMethodType.PERCENTAGE,
|
type: ApplicationMethodType.PERCENTAGE,
|
||||||
target_type: "items",
|
target_type: "items",
|
||||||
allocation: "each",
|
allocation: "each",
|
||||||
value: "10",
|
value: 10,
|
||||||
max_quantity: 1,
|
max_quantity: 1,
|
||||||
target_rules: [
|
target_rules: [
|
||||||
{
|
{
|
||||||
@@ -689,7 +689,7 @@ describe("Promotion Service: computeActions", () => {
|
|||||||
type: ApplicationMethodType.PERCENTAGE,
|
type: ApplicationMethodType.PERCENTAGE,
|
||||||
target_type: "items",
|
target_type: "items",
|
||||||
allocation: "each",
|
allocation: "each",
|
||||||
value: "30",
|
value: 30,
|
||||||
max_quantity: 2,
|
max_quantity: 2,
|
||||||
target_rules: [
|
target_rules: [
|
||||||
{
|
{
|
||||||
@@ -717,7 +717,7 @@ describe("Promotion Service: computeActions", () => {
|
|||||||
type: ApplicationMethodType.PERCENTAGE,
|
type: ApplicationMethodType.PERCENTAGE,
|
||||||
target_type: "items",
|
target_type: "items",
|
||||||
allocation: "each",
|
allocation: "each",
|
||||||
value: "10",
|
value: 10,
|
||||||
max_quantity: 1,
|
max_quantity: 1,
|
||||||
target_rules: [
|
target_rules: [
|
||||||
{
|
{
|
||||||
@@ -809,7 +809,7 @@ describe("Promotion Service: computeActions", () => {
|
|||||||
type: ApplicationMethodType.PERCENTAGE,
|
type: ApplicationMethodType.PERCENTAGE,
|
||||||
target_type: "items",
|
target_type: "items",
|
||||||
allocation: "each",
|
allocation: "each",
|
||||||
value: "100",
|
value: 100,
|
||||||
max_quantity: 10,
|
max_quantity: 10,
|
||||||
target_rules: [
|
target_rules: [
|
||||||
{
|
{
|
||||||
@@ -837,7 +837,7 @@ describe("Promotion Service: computeActions", () => {
|
|||||||
type: ApplicationMethodType.PERCENTAGE,
|
type: ApplicationMethodType.PERCENTAGE,
|
||||||
target_type: "items",
|
target_type: "items",
|
||||||
allocation: "each",
|
allocation: "each",
|
||||||
value: "50",
|
value: 50,
|
||||||
max_quantity: 10,
|
max_quantity: 10,
|
||||||
target_rules: [
|
target_rules: [
|
||||||
{
|
{
|
||||||
@@ -920,7 +920,7 @@ describe("Promotion Service: computeActions", () => {
|
|||||||
type: ApplicationMethodType.PERCENTAGE,
|
type: ApplicationMethodType.PERCENTAGE,
|
||||||
target_type: "items",
|
target_type: "items",
|
||||||
allocation: "each",
|
allocation: "each",
|
||||||
value: "100",
|
value: 100,
|
||||||
max_quantity: 5,
|
max_quantity: 5,
|
||||||
target_rules: [
|
target_rules: [
|
||||||
{
|
{
|
||||||
@@ -978,7 +978,7 @@ describe("Promotion Service: computeActions", () => {
|
|||||||
type: ApplicationMethodType.PERCENTAGE,
|
type: ApplicationMethodType.PERCENTAGE,
|
||||||
target_type: "items",
|
target_type: "items",
|
||||||
allocation: "each",
|
allocation: "each",
|
||||||
value: "10",
|
value: 10,
|
||||||
max_quantity: 5,
|
max_quantity: 5,
|
||||||
target_rules: [
|
target_rules: [
|
||||||
{
|
{
|
||||||
@@ -1042,7 +1042,7 @@ describe("Promotion Service: computeActions", () => {
|
|||||||
type: "fixed",
|
type: "fixed",
|
||||||
target_type: "items",
|
target_type: "items",
|
||||||
allocation: "across",
|
allocation: "across",
|
||||||
value: "400",
|
value: 400,
|
||||||
target_rules: [
|
target_rules: [
|
||||||
{
|
{
|
||||||
attribute: "product_category.id",
|
attribute: "product_category.id",
|
||||||
@@ -1119,7 +1119,7 @@ describe("Promotion Service: computeActions", () => {
|
|||||||
type: "fixed",
|
type: "fixed",
|
||||||
target_type: "items",
|
target_type: "items",
|
||||||
allocation: "across",
|
allocation: "across",
|
||||||
value: "400",
|
value: 400,
|
||||||
target_rules: [
|
target_rules: [
|
||||||
{
|
{
|
||||||
attribute: "product_category.id",
|
attribute: "product_category.id",
|
||||||
@@ -1195,7 +1195,7 @@ describe("Promotion Service: computeActions", () => {
|
|||||||
type: "fixed",
|
type: "fixed",
|
||||||
target_type: "items",
|
target_type: "items",
|
||||||
allocation: "across",
|
allocation: "across",
|
||||||
value: "30",
|
value: 30,
|
||||||
target_rules: [
|
target_rules: [
|
||||||
{
|
{
|
||||||
attribute: "product_category.id",
|
attribute: "product_category.id",
|
||||||
@@ -1222,7 +1222,7 @@ describe("Promotion Service: computeActions", () => {
|
|||||||
type: "fixed",
|
type: "fixed",
|
||||||
target_type: "items",
|
target_type: "items",
|
||||||
allocation: "across",
|
allocation: "across",
|
||||||
value: "50",
|
value: 50,
|
||||||
target_rules: [
|
target_rules: [
|
||||||
{
|
{
|
||||||
attribute: "product_category.id",
|
attribute: "product_category.id",
|
||||||
@@ -1313,7 +1313,7 @@ describe("Promotion Service: computeActions", () => {
|
|||||||
type: "fixed",
|
type: "fixed",
|
||||||
target_type: "items",
|
target_type: "items",
|
||||||
allocation: "across",
|
allocation: "across",
|
||||||
value: "1000",
|
value: 1000,
|
||||||
target_rules: [
|
target_rules: [
|
||||||
{
|
{
|
||||||
attribute: "product_category.id",
|
attribute: "product_category.id",
|
||||||
@@ -1340,7 +1340,7 @@ describe("Promotion Service: computeActions", () => {
|
|||||||
type: "fixed",
|
type: "fixed",
|
||||||
target_type: "items",
|
target_type: "items",
|
||||||
allocation: "across",
|
allocation: "across",
|
||||||
value: "50",
|
value: 50,
|
||||||
target_rules: [
|
target_rules: [
|
||||||
{
|
{
|
||||||
attribute: "product_category.id",
|
attribute: "product_category.id",
|
||||||
@@ -1422,7 +1422,7 @@ describe("Promotion Service: computeActions", () => {
|
|||||||
type: "fixed",
|
type: "fixed",
|
||||||
target_type: "items",
|
target_type: "items",
|
||||||
allocation: "across",
|
allocation: "across",
|
||||||
value: "1500",
|
value: 1500,
|
||||||
target_rules: [
|
target_rules: [
|
||||||
{
|
{
|
||||||
attribute: "product_category.id",
|
attribute: "product_category.id",
|
||||||
@@ -1479,7 +1479,7 @@ describe("Promotion Service: computeActions", () => {
|
|||||||
type: "fixed",
|
type: "fixed",
|
||||||
target_type: "items",
|
target_type: "items",
|
||||||
allocation: "across",
|
allocation: "across",
|
||||||
value: "500",
|
value: 500,
|
||||||
target_rules: [
|
target_rules: [
|
||||||
{
|
{
|
||||||
attribute: "product_category.id",
|
attribute: "product_category.id",
|
||||||
@@ -1540,7 +1540,7 @@ describe("Promotion Service: computeActions", () => {
|
|||||||
type: ApplicationMethodType.PERCENTAGE,
|
type: ApplicationMethodType.PERCENTAGE,
|
||||||
target_type: "items",
|
target_type: "items",
|
||||||
allocation: "across",
|
allocation: "across",
|
||||||
value: "10",
|
value: 10,
|
||||||
target_rules: [
|
target_rules: [
|
||||||
{
|
{
|
||||||
attribute: "product_category.id",
|
attribute: "product_category.id",
|
||||||
@@ -1617,7 +1617,7 @@ describe("Promotion Service: computeActions", () => {
|
|||||||
type: ApplicationMethodType.PERCENTAGE,
|
type: ApplicationMethodType.PERCENTAGE,
|
||||||
target_type: "items",
|
target_type: "items",
|
||||||
allocation: "across",
|
allocation: "across",
|
||||||
value: "10",
|
value: 10,
|
||||||
target_rules: [
|
target_rules: [
|
||||||
{
|
{
|
||||||
attribute: "product_category.id",
|
attribute: "product_category.id",
|
||||||
@@ -1693,7 +1693,7 @@ describe("Promotion Service: computeActions", () => {
|
|||||||
type: ApplicationMethodType.PERCENTAGE,
|
type: ApplicationMethodType.PERCENTAGE,
|
||||||
target_type: "items",
|
target_type: "items",
|
||||||
allocation: "across",
|
allocation: "across",
|
||||||
value: "10",
|
value: 10,
|
||||||
target_rules: [
|
target_rules: [
|
||||||
{
|
{
|
||||||
attribute: "product_category.id",
|
attribute: "product_category.id",
|
||||||
@@ -1720,7 +1720,7 @@ describe("Promotion Service: computeActions", () => {
|
|||||||
type: ApplicationMethodType.PERCENTAGE,
|
type: ApplicationMethodType.PERCENTAGE,
|
||||||
target_type: "items",
|
target_type: "items",
|
||||||
allocation: "across",
|
allocation: "across",
|
||||||
value: "10",
|
value: 10,
|
||||||
target_rules: [
|
target_rules: [
|
||||||
{
|
{
|
||||||
attribute: "product_category.id",
|
attribute: "product_category.id",
|
||||||
@@ -1811,7 +1811,7 @@ describe("Promotion Service: computeActions", () => {
|
|||||||
type: ApplicationMethodType.PERCENTAGE,
|
type: ApplicationMethodType.PERCENTAGE,
|
||||||
target_type: "items",
|
target_type: "items",
|
||||||
allocation: "across",
|
allocation: "across",
|
||||||
value: "10",
|
value: 10,
|
||||||
target_rules: [
|
target_rules: [
|
||||||
{
|
{
|
||||||
attribute: "product_category.id",
|
attribute: "product_category.id",
|
||||||
@@ -1838,7 +1838,7 @@ describe("Promotion Service: computeActions", () => {
|
|||||||
type: ApplicationMethodType.PERCENTAGE,
|
type: ApplicationMethodType.PERCENTAGE,
|
||||||
target_type: "items",
|
target_type: "items",
|
||||||
allocation: "across",
|
allocation: "across",
|
||||||
value: "10",
|
value: 10,
|
||||||
target_rules: [
|
target_rules: [
|
||||||
{
|
{
|
||||||
attribute: "product_category.id",
|
attribute: "product_category.id",
|
||||||
@@ -1932,7 +1932,7 @@ describe("Promotion Service: computeActions", () => {
|
|||||||
type: ApplicationMethodType.PERCENTAGE,
|
type: ApplicationMethodType.PERCENTAGE,
|
||||||
target_type: "items",
|
target_type: "items",
|
||||||
allocation: "across",
|
allocation: "across",
|
||||||
value: "100",
|
value: 100,
|
||||||
target_rules: [
|
target_rules: [
|
||||||
{
|
{
|
||||||
attribute: "product_category.id",
|
attribute: "product_category.id",
|
||||||
@@ -1989,7 +1989,7 @@ describe("Promotion Service: computeActions", () => {
|
|||||||
type: ApplicationMethodType.PERCENTAGE,
|
type: ApplicationMethodType.PERCENTAGE,
|
||||||
target_type: "items",
|
target_type: "items",
|
||||||
allocation: "across",
|
allocation: "across",
|
||||||
value: "10",
|
value: 10,
|
||||||
target_rules: [
|
target_rules: [
|
||||||
{
|
{
|
||||||
attribute: "product_category.id",
|
attribute: "product_category.id",
|
||||||
@@ -2052,7 +2052,7 @@ describe("Promotion Service: computeActions", () => {
|
|||||||
type: "fixed",
|
type: "fixed",
|
||||||
target_type: "shipping_methods",
|
target_type: "shipping_methods",
|
||||||
allocation: "each",
|
allocation: "each",
|
||||||
value: "200",
|
value: 200,
|
||||||
max_quantity: 2,
|
max_quantity: 2,
|
||||||
target_rules: [
|
target_rules: [
|
||||||
{
|
{
|
||||||
@@ -2129,7 +2129,7 @@ describe("Promotion Service: computeActions", () => {
|
|||||||
type: "fixed",
|
type: "fixed",
|
||||||
target_type: "shipping_methods",
|
target_type: "shipping_methods",
|
||||||
allocation: "each",
|
allocation: "each",
|
||||||
value: "200",
|
value: 200,
|
||||||
max_quantity: 2,
|
max_quantity: 2,
|
||||||
target_rules: [
|
target_rules: [
|
||||||
{
|
{
|
||||||
@@ -2206,7 +2206,7 @@ describe("Promotion Service: computeActions", () => {
|
|||||||
type: "fixed",
|
type: "fixed",
|
||||||
target_type: "shipping_methods",
|
target_type: "shipping_methods",
|
||||||
allocation: "each",
|
allocation: "each",
|
||||||
value: "200",
|
value: 200,
|
||||||
max_quantity: 2,
|
max_quantity: 2,
|
||||||
target_rules: [
|
target_rules: [
|
||||||
{
|
{
|
||||||
@@ -2273,7 +2273,7 @@ describe("Promotion Service: computeActions", () => {
|
|||||||
type: "fixed",
|
type: "fixed",
|
||||||
target_type: "shipping_methods",
|
target_type: "shipping_methods",
|
||||||
allocation: "each",
|
allocation: "each",
|
||||||
value: "200",
|
value: 200,
|
||||||
max_quantity: 2,
|
max_quantity: 2,
|
||||||
target_rules: [
|
target_rules: [
|
||||||
{
|
{
|
||||||
@@ -2301,7 +2301,7 @@ describe("Promotion Service: computeActions", () => {
|
|||||||
type: "fixed",
|
type: "fixed",
|
||||||
target_type: "shipping_methods",
|
target_type: "shipping_methods",
|
||||||
allocation: "each",
|
allocation: "each",
|
||||||
value: "200",
|
value: 200,
|
||||||
max_quantity: 2,
|
max_quantity: 2,
|
||||||
target_rules: [
|
target_rules: [
|
||||||
{
|
{
|
||||||
@@ -2386,7 +2386,7 @@ describe("Promotion Service: computeActions", () => {
|
|||||||
type: "fixed",
|
type: "fixed",
|
||||||
target_type: "shipping_methods",
|
target_type: "shipping_methods",
|
||||||
allocation: "each",
|
allocation: "each",
|
||||||
value: "500",
|
value: 500,
|
||||||
max_quantity: 2,
|
max_quantity: 2,
|
||||||
target_rules: [
|
target_rules: [
|
||||||
{
|
{
|
||||||
@@ -2414,7 +2414,7 @@ describe("Promotion Service: computeActions", () => {
|
|||||||
type: "fixed",
|
type: "fixed",
|
||||||
target_type: "shipping_methods",
|
target_type: "shipping_methods",
|
||||||
allocation: "each",
|
allocation: "each",
|
||||||
value: "200",
|
value: 200,
|
||||||
max_quantity: 2,
|
max_quantity: 2,
|
||||||
target_rules: [
|
target_rules: [
|
||||||
{
|
{
|
||||||
@@ -2496,7 +2496,7 @@ describe("Promotion Service: computeActions", () => {
|
|||||||
type: "fixed",
|
type: "fixed",
|
||||||
target_type: "shipping_methods",
|
target_type: "shipping_methods",
|
||||||
allocation: "each",
|
allocation: "each",
|
||||||
value: "1200",
|
value: 1200,
|
||||||
max_quantity: 2,
|
max_quantity: 2,
|
||||||
target_rules: [
|
target_rules: [
|
||||||
{
|
{
|
||||||
@@ -2550,7 +2550,7 @@ describe("Promotion Service: computeActions", () => {
|
|||||||
type: "fixed",
|
type: "fixed",
|
||||||
target_type: "shipping_methods",
|
target_type: "shipping_methods",
|
||||||
allocation: "each",
|
allocation: "each",
|
||||||
value: "1200",
|
value: 1200,
|
||||||
max_quantity: 2,
|
max_quantity: 2,
|
||||||
target_rules: [
|
target_rules: [
|
||||||
{
|
{
|
||||||
@@ -2608,7 +2608,7 @@ describe("Promotion Service: computeActions", () => {
|
|||||||
type: ApplicationMethodType.PERCENTAGE,
|
type: ApplicationMethodType.PERCENTAGE,
|
||||||
target_type: "shipping_methods",
|
target_type: "shipping_methods",
|
||||||
allocation: "each",
|
allocation: "each",
|
||||||
value: "10",
|
value: 10,
|
||||||
max_quantity: 2,
|
max_quantity: 2,
|
||||||
target_rules: [
|
target_rules: [
|
||||||
{
|
{
|
||||||
@@ -2685,7 +2685,7 @@ describe("Promotion Service: computeActions", () => {
|
|||||||
type: ApplicationMethodType.PERCENTAGE,
|
type: ApplicationMethodType.PERCENTAGE,
|
||||||
target_type: "shipping_methods",
|
target_type: "shipping_methods",
|
||||||
allocation: "each",
|
allocation: "each",
|
||||||
value: "10",
|
value: 10,
|
||||||
max_quantity: 2,
|
max_quantity: 2,
|
||||||
target_rules: [
|
target_rules: [
|
||||||
{
|
{
|
||||||
@@ -2762,7 +2762,7 @@ describe("Promotion Service: computeActions", () => {
|
|||||||
type: ApplicationMethodType.PERCENTAGE,
|
type: ApplicationMethodType.PERCENTAGE,
|
||||||
target_type: "shipping_methods",
|
target_type: "shipping_methods",
|
||||||
allocation: "each",
|
allocation: "each",
|
||||||
value: "10",
|
value: 10,
|
||||||
max_quantity: 2,
|
max_quantity: 2,
|
||||||
target_rules: [
|
target_rules: [
|
||||||
{
|
{
|
||||||
@@ -2829,7 +2829,7 @@ describe("Promotion Service: computeActions", () => {
|
|||||||
type: ApplicationMethodType.PERCENTAGE,
|
type: ApplicationMethodType.PERCENTAGE,
|
||||||
target_type: "shipping_methods",
|
target_type: "shipping_methods",
|
||||||
allocation: "each",
|
allocation: "each",
|
||||||
value: "10",
|
value: 10,
|
||||||
max_quantity: 2,
|
max_quantity: 2,
|
||||||
target_rules: [
|
target_rules: [
|
||||||
{
|
{
|
||||||
@@ -2857,7 +2857,7 @@ describe("Promotion Service: computeActions", () => {
|
|||||||
type: ApplicationMethodType.PERCENTAGE,
|
type: ApplicationMethodType.PERCENTAGE,
|
||||||
target_type: "shipping_methods",
|
target_type: "shipping_methods",
|
||||||
allocation: "each",
|
allocation: "each",
|
||||||
value: "10",
|
value: 10,
|
||||||
max_quantity: 2,
|
max_quantity: 2,
|
||||||
target_rules: [
|
target_rules: [
|
||||||
{
|
{
|
||||||
@@ -2948,7 +2948,7 @@ describe("Promotion Service: computeActions", () => {
|
|||||||
type: ApplicationMethodType.PERCENTAGE,
|
type: ApplicationMethodType.PERCENTAGE,
|
||||||
target_type: "shipping_methods",
|
target_type: "shipping_methods",
|
||||||
allocation: "each",
|
allocation: "each",
|
||||||
value: "10",
|
value: 10,
|
||||||
max_quantity: 2,
|
max_quantity: 2,
|
||||||
target_rules: [
|
target_rules: [
|
||||||
{
|
{
|
||||||
@@ -2976,7 +2976,7 @@ describe("Promotion Service: computeActions", () => {
|
|||||||
type: ApplicationMethodType.PERCENTAGE,
|
type: ApplicationMethodType.PERCENTAGE,
|
||||||
target_type: "shipping_methods",
|
target_type: "shipping_methods",
|
||||||
allocation: "each",
|
allocation: "each",
|
||||||
value: "10",
|
value: 10,
|
||||||
max_quantity: 2,
|
max_quantity: 2,
|
||||||
target_rules: [
|
target_rules: [
|
||||||
{
|
{
|
||||||
@@ -3070,7 +3070,7 @@ describe("Promotion Service: computeActions", () => {
|
|||||||
type: ApplicationMethodType.PERCENTAGE,
|
type: ApplicationMethodType.PERCENTAGE,
|
||||||
target_type: "shipping_methods",
|
target_type: "shipping_methods",
|
||||||
allocation: "each",
|
allocation: "each",
|
||||||
value: "100",
|
value: 100,
|
||||||
max_quantity: 2,
|
max_quantity: 2,
|
||||||
target_rules: [
|
target_rules: [
|
||||||
{
|
{
|
||||||
@@ -3124,7 +3124,7 @@ describe("Promotion Service: computeActions", () => {
|
|||||||
type: ApplicationMethodType.PERCENTAGE,
|
type: ApplicationMethodType.PERCENTAGE,
|
||||||
target_type: "shipping_methods",
|
target_type: "shipping_methods",
|
||||||
allocation: "each",
|
allocation: "each",
|
||||||
value: "10",
|
value: 10,
|
||||||
max_quantity: 2,
|
max_quantity: 2,
|
||||||
target_rules: [
|
target_rules: [
|
||||||
{
|
{
|
||||||
@@ -3184,7 +3184,7 @@ describe("Promotion Service: computeActions", () => {
|
|||||||
type: ApplicationMethodType.FIXED,
|
type: ApplicationMethodType.FIXED,
|
||||||
target_type: "shipping_methods",
|
target_type: "shipping_methods",
|
||||||
allocation: "across",
|
allocation: "across",
|
||||||
value: "200",
|
value: 200,
|
||||||
target_rules: [
|
target_rules: [
|
||||||
{
|
{
|
||||||
attribute: "shipping_option.id",
|
attribute: "shipping_option.id",
|
||||||
@@ -3260,7 +3260,7 @@ describe("Promotion Service: computeActions", () => {
|
|||||||
type: ApplicationMethodType.FIXED,
|
type: ApplicationMethodType.FIXED,
|
||||||
target_type: "shipping_methods",
|
target_type: "shipping_methods",
|
||||||
allocation: "across",
|
allocation: "across",
|
||||||
value: "200",
|
value: 200,
|
||||||
target_rules: [
|
target_rules: [
|
||||||
{
|
{
|
||||||
attribute: "shipping_option.id",
|
attribute: "shipping_option.id",
|
||||||
@@ -3335,7 +3335,7 @@ describe("Promotion Service: computeActions", () => {
|
|||||||
type: ApplicationMethodType.FIXED,
|
type: ApplicationMethodType.FIXED,
|
||||||
target_type: "shipping_methods",
|
target_type: "shipping_methods",
|
||||||
allocation: "across",
|
allocation: "across",
|
||||||
value: "200",
|
value: 200,
|
||||||
target_rules: [
|
target_rules: [
|
||||||
{
|
{
|
||||||
attribute: "shipping_option.id",
|
attribute: "shipping_option.id",
|
||||||
@@ -3362,7 +3362,7 @@ describe("Promotion Service: computeActions", () => {
|
|||||||
type: ApplicationMethodType.FIXED,
|
type: ApplicationMethodType.FIXED,
|
||||||
target_type: "shipping_methods",
|
target_type: "shipping_methods",
|
||||||
allocation: "across",
|
allocation: "across",
|
||||||
value: "200",
|
value: 200,
|
||||||
target_rules: [
|
target_rules: [
|
||||||
{
|
{
|
||||||
attribute: "shipping_option.id",
|
attribute: "shipping_option.id",
|
||||||
@@ -3452,7 +3452,7 @@ describe("Promotion Service: computeActions", () => {
|
|||||||
type: ApplicationMethodType.FIXED,
|
type: ApplicationMethodType.FIXED,
|
||||||
target_type: "shipping_methods",
|
target_type: "shipping_methods",
|
||||||
allocation: "across",
|
allocation: "across",
|
||||||
value: "1000",
|
value: 1000,
|
||||||
target_rules: [
|
target_rules: [
|
||||||
{
|
{
|
||||||
attribute: "shipping_option.id",
|
attribute: "shipping_option.id",
|
||||||
@@ -3479,7 +3479,7 @@ describe("Promotion Service: computeActions", () => {
|
|||||||
type: ApplicationMethodType.FIXED,
|
type: ApplicationMethodType.FIXED,
|
||||||
target_type: "shipping_methods",
|
target_type: "shipping_methods",
|
||||||
allocation: "across",
|
allocation: "across",
|
||||||
value: "200",
|
value: 200,
|
||||||
target_rules: [
|
target_rules: [
|
||||||
{
|
{
|
||||||
attribute: "shipping_option.id",
|
attribute: "shipping_option.id",
|
||||||
@@ -3560,7 +3560,7 @@ describe("Promotion Service: computeActions", () => {
|
|||||||
type: ApplicationMethodType.FIXED,
|
type: ApplicationMethodType.FIXED,
|
||||||
target_type: "shipping_methods",
|
target_type: "shipping_methods",
|
||||||
allocation: "across",
|
allocation: "across",
|
||||||
value: "1200",
|
value: 1200,
|
||||||
target_rules: [
|
target_rules: [
|
||||||
{
|
{
|
||||||
attribute: "shipping_option.id",
|
attribute: "shipping_option.id",
|
||||||
@@ -3613,7 +3613,7 @@ describe("Promotion Service: computeActions", () => {
|
|||||||
type: ApplicationMethodType.FIXED,
|
type: ApplicationMethodType.FIXED,
|
||||||
target_type: "shipping_methods",
|
target_type: "shipping_methods",
|
||||||
allocation: "across",
|
allocation: "across",
|
||||||
value: "1200",
|
value: 1200,
|
||||||
target_rules: [
|
target_rules: [
|
||||||
{
|
{
|
||||||
attribute: "shipping_option.id",
|
attribute: "shipping_option.id",
|
||||||
@@ -3670,7 +3670,7 @@ describe("Promotion Service: computeActions", () => {
|
|||||||
type: ApplicationMethodType.PERCENTAGE,
|
type: ApplicationMethodType.PERCENTAGE,
|
||||||
target_type: "shipping_methods",
|
target_type: "shipping_methods",
|
||||||
allocation: "across",
|
allocation: "across",
|
||||||
value: "10",
|
value: 10,
|
||||||
target_rules: [
|
target_rules: [
|
||||||
{
|
{
|
||||||
attribute: "shipping_option.id",
|
attribute: "shipping_option.id",
|
||||||
@@ -3746,7 +3746,7 @@ describe("Promotion Service: computeActions", () => {
|
|||||||
type: ApplicationMethodType.PERCENTAGE,
|
type: ApplicationMethodType.PERCENTAGE,
|
||||||
target_type: "shipping_methods",
|
target_type: "shipping_methods",
|
||||||
allocation: "across",
|
allocation: "across",
|
||||||
value: "10",
|
value: 10,
|
||||||
target_rules: [
|
target_rules: [
|
||||||
{
|
{
|
||||||
attribute: "shipping_option.id",
|
attribute: "shipping_option.id",
|
||||||
@@ -3821,7 +3821,7 @@ describe("Promotion Service: computeActions", () => {
|
|||||||
type: ApplicationMethodType.PERCENTAGE,
|
type: ApplicationMethodType.PERCENTAGE,
|
||||||
target_type: "shipping_methods",
|
target_type: "shipping_methods",
|
||||||
allocation: "across",
|
allocation: "across",
|
||||||
value: "10",
|
value: 10,
|
||||||
target_rules: [
|
target_rules: [
|
||||||
{
|
{
|
||||||
attribute: "shipping_option.id",
|
attribute: "shipping_option.id",
|
||||||
@@ -3848,7 +3848,7 @@ describe("Promotion Service: computeActions", () => {
|
|||||||
type: ApplicationMethodType.PERCENTAGE,
|
type: ApplicationMethodType.PERCENTAGE,
|
||||||
target_type: "shipping_methods",
|
target_type: "shipping_methods",
|
||||||
allocation: "across",
|
allocation: "across",
|
||||||
value: "10",
|
value: 10,
|
||||||
target_rules: [
|
target_rules: [
|
||||||
{
|
{
|
||||||
attribute: "shipping_option.id",
|
attribute: "shipping_option.id",
|
||||||
@@ -3938,7 +3938,7 @@ describe("Promotion Service: computeActions", () => {
|
|||||||
type: ApplicationMethodType.PERCENTAGE,
|
type: ApplicationMethodType.PERCENTAGE,
|
||||||
target_type: "shipping_methods",
|
target_type: "shipping_methods",
|
||||||
allocation: "across",
|
allocation: "across",
|
||||||
value: "100",
|
value: 100,
|
||||||
target_rules: [
|
target_rules: [
|
||||||
{
|
{
|
||||||
attribute: "shipping_option.id",
|
attribute: "shipping_option.id",
|
||||||
@@ -3965,7 +3965,7 @@ describe("Promotion Service: computeActions", () => {
|
|||||||
type: ApplicationMethodType.PERCENTAGE,
|
type: ApplicationMethodType.PERCENTAGE,
|
||||||
target_type: "shipping_methods",
|
target_type: "shipping_methods",
|
||||||
allocation: "across",
|
allocation: "across",
|
||||||
value: "10",
|
value: 10,
|
||||||
target_rules: [
|
target_rules: [
|
||||||
{
|
{
|
||||||
attribute: "shipping_option.id",
|
attribute: "shipping_option.id",
|
||||||
@@ -4046,7 +4046,7 @@ describe("Promotion Service: computeActions", () => {
|
|||||||
type: ApplicationMethodType.PERCENTAGE,
|
type: ApplicationMethodType.PERCENTAGE,
|
||||||
target_type: "shipping_methods",
|
target_type: "shipping_methods",
|
||||||
allocation: "across",
|
allocation: "across",
|
||||||
value: "100",
|
value: 100,
|
||||||
target_rules: [
|
target_rules: [
|
||||||
{
|
{
|
||||||
attribute: "shipping_option.id",
|
attribute: "shipping_option.id",
|
||||||
@@ -4099,7 +4099,7 @@ describe("Promotion Service: computeActions", () => {
|
|||||||
type: ApplicationMethodType.PERCENTAGE,
|
type: ApplicationMethodType.PERCENTAGE,
|
||||||
target_type: "shipping_methods",
|
target_type: "shipping_methods",
|
||||||
allocation: "across",
|
allocation: "across",
|
||||||
value: "10",
|
value: 10,
|
||||||
target_rules: [
|
target_rules: [
|
||||||
{
|
{
|
||||||
attribute: "shipping_option.id",
|
attribute: "shipping_option.id",
|
||||||
@@ -4156,7 +4156,7 @@ describe("Promotion Service: computeActions", () => {
|
|||||||
application_method: {
|
application_method: {
|
||||||
type: "fixed",
|
type: "fixed",
|
||||||
target_type: "order",
|
target_type: "order",
|
||||||
value: "200",
|
value: 200,
|
||||||
max_quantity: 2,
|
max_quantity: 2,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@@ -4226,7 +4226,7 @@ describe("Promotion Service: computeActions", () => {
|
|||||||
application_method: {
|
application_method: {
|
||||||
type: "fixed",
|
type: "fixed",
|
||||||
target_type: "order",
|
target_type: "order",
|
||||||
value: "200",
|
value: 200,
|
||||||
max_quantity: 2,
|
max_quantity: 2,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@@ -4295,7 +4295,7 @@ describe("Promotion Service: computeActions", () => {
|
|||||||
application_method: {
|
application_method: {
|
||||||
type: "fixed",
|
type: "fixed",
|
||||||
target_type: "order",
|
target_type: "order",
|
||||||
value: "30",
|
value: 30,
|
||||||
max_quantity: 2,
|
max_quantity: 2,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@@ -4315,7 +4315,7 @@ describe("Promotion Service: computeActions", () => {
|
|||||||
application_method: {
|
application_method: {
|
||||||
type: "fixed",
|
type: "fixed",
|
||||||
target_type: "order",
|
target_type: "order",
|
||||||
value: "50",
|
value: 50,
|
||||||
max_quantity: 1,
|
max_quantity: 1,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@@ -4399,7 +4399,7 @@ describe("Promotion Service: computeActions", () => {
|
|||||||
application_method: {
|
application_method: {
|
||||||
type: "fixed",
|
type: "fixed",
|
||||||
target_type: "order",
|
target_type: "order",
|
||||||
value: "500",
|
value: 500,
|
||||||
max_quantity: 2,
|
max_quantity: 2,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@@ -4419,7 +4419,7 @@ describe("Promotion Service: computeActions", () => {
|
|||||||
application_method: {
|
application_method: {
|
||||||
type: "fixed",
|
type: "fixed",
|
||||||
target_type: "order",
|
target_type: "order",
|
||||||
value: "50",
|
value: 50,
|
||||||
max_quantity: 1,
|
max_quantity: 1,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@@ -4501,7 +4501,7 @@ describe("Promotion Service: computeActions", () => {
|
|||||||
type: "fixed",
|
type: "fixed",
|
||||||
target_type: "items",
|
target_type: "items",
|
||||||
allocation: "each",
|
allocation: "each",
|
||||||
value: "200",
|
value: 200,
|
||||||
max_quantity: 1,
|
max_quantity: 1,
|
||||||
target_rules: [
|
target_rules: [
|
||||||
{
|
{
|
||||||
@@ -4596,7 +4596,7 @@ describe("Promotion Service: computeActions", () => {
|
|||||||
type: "fixed",
|
type: "fixed",
|
||||||
target_type: "shipping_methods",
|
target_type: "shipping_methods",
|
||||||
allocation: "across",
|
allocation: "across",
|
||||||
value: "200",
|
value: 200,
|
||||||
target_rules: [
|
target_rules: [
|
||||||
{
|
{
|
||||||
attribute: "shipping_option.id",
|
attribute: "shipping_option.id",
|
||||||
|
|||||||
@@ -102,7 +102,7 @@
|
|||||||
"mappedType": "datetime"
|
"mappedType": "datetime"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"name": "campaign",
|
"name": "promotion_campaign",
|
||||||
"schema": "public",
|
"schema": "public",
|
||||||
"indexes": [
|
"indexes": [
|
||||||
{
|
{
|
||||||
@@ -113,7 +113,7 @@
|
|||||||
"unique": true
|
"unique": true
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"keyName": "campaign_pkey",
|
"keyName": "promotion_campaign_pkey",
|
||||||
"columnNames": ["id"],
|
"columnNames": ["id"],
|
||||||
"composite": false,
|
"composite": false,
|
||||||
"primary": true,
|
"primary": true,
|
||||||
@@ -160,19 +160,35 @@
|
|||||||
"autoincrement": false,
|
"autoincrement": false,
|
||||||
"primary": false,
|
"primary": false,
|
||||||
"nullable": true,
|
"nullable": true,
|
||||||
"default": "null",
|
|
||||||
"mappedType": "decimal"
|
"mappedType": "decimal"
|
||||||
},
|
},
|
||||||
|
"raw_limit": {
|
||||||
|
"name": "raw_limit",
|
||||||
|
"type": "jsonb",
|
||||||
|
"unsigned": false,
|
||||||
|
"autoincrement": false,
|
||||||
|
"primary": false,
|
||||||
|
"nullable": true,
|
||||||
|
"mappedType": "json"
|
||||||
|
},
|
||||||
"used": {
|
"used": {
|
||||||
"name": "used",
|
"name": "used",
|
||||||
"type": "numeric",
|
"type": "numeric",
|
||||||
"unsigned": false,
|
"unsigned": false,
|
||||||
"autoincrement": false,
|
"autoincrement": false,
|
||||||
"primary": false,
|
"primary": false,
|
||||||
"nullable": false,
|
"nullable": true,
|
||||||
"default": "0",
|
|
||||||
"mappedType": "decimal"
|
"mappedType": "decimal"
|
||||||
},
|
},
|
||||||
|
"raw_used": {
|
||||||
|
"name": "raw_used",
|
||||||
|
"type": "jsonb",
|
||||||
|
"unsigned": false,
|
||||||
|
"autoincrement": false,
|
||||||
|
"primary": false,
|
||||||
|
"nullable": true,
|
||||||
|
"mappedType": "json"
|
||||||
|
},
|
||||||
"created_at": {
|
"created_at": {
|
||||||
"name": "created_at",
|
"name": "created_at",
|
||||||
"type": "timestamptz",
|
"type": "timestamptz",
|
||||||
@@ -206,7 +222,7 @@
|
|||||||
"mappedType": "datetime"
|
"mappedType": "datetime"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"name": "campaign_budget",
|
"name": "promotion_campaign_budget",
|
||||||
"schema": "public",
|
"schema": "public",
|
||||||
"indexes": [
|
"indexes": [
|
||||||
{
|
{
|
||||||
@@ -219,12 +235,12 @@
|
|||||||
{
|
{
|
||||||
"columnNames": ["campaign_id"],
|
"columnNames": ["campaign_id"],
|
||||||
"composite": false,
|
"composite": false,
|
||||||
"keyName": "campaign_budget_campaign_id_unique",
|
"keyName": "promotion_campaign_budget_campaign_id_unique",
|
||||||
"primary": false,
|
"primary": false,
|
||||||
"unique": true
|
"unique": true
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"keyName": "campaign_budget_pkey",
|
"keyName": "promotion_campaign_budget_pkey",
|
||||||
"columnNames": ["id"],
|
"columnNames": ["id"],
|
||||||
"composite": false,
|
"composite": false,
|
||||||
"primary": true,
|
"primary": true,
|
||||||
@@ -233,12 +249,12 @@
|
|||||||
],
|
],
|
||||||
"checks": [],
|
"checks": [],
|
||||||
"foreignKeys": {
|
"foreignKeys": {
|
||||||
"campaign_budget_campaign_id_foreign": {
|
"promotion_campaign_budget_campaign_id_foreign": {
|
||||||
"constraintName": "campaign_budget_campaign_id_foreign",
|
"constraintName": "promotion_campaign_budget_campaign_id_foreign",
|
||||||
"columnNames": ["campaign_id"],
|
"columnNames": ["campaign_id"],
|
||||||
"localTableName": "public.campaign_budget",
|
"localTableName": "public.promotion_campaign_budget",
|
||||||
"referencedColumnNames": ["id"],
|
"referencedColumnNames": ["id"],
|
||||||
"referencedTableName": "public.campaign",
|
"referencedTableName": "public.promotion_campaign",
|
||||||
"updateRule": "cascade"
|
"updateRule": "cascade"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -364,7 +380,7 @@
|
|||||||
"columnNames": ["campaign_id"],
|
"columnNames": ["campaign_id"],
|
||||||
"localTableName": "public.promotion",
|
"localTableName": "public.promotion",
|
||||||
"referencedColumnNames": ["id"],
|
"referencedColumnNames": ["id"],
|
||||||
"referencedTableName": "public.campaign",
|
"referencedTableName": "public.promotion_campaign",
|
||||||
"deleteRule": "set null"
|
"deleteRule": "set null"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -389,6 +405,15 @@
|
|||||||
"nullable": true,
|
"nullable": true,
|
||||||
"mappedType": "decimal"
|
"mappedType": "decimal"
|
||||||
},
|
},
|
||||||
|
"raw_value": {
|
||||||
|
"name": "raw_value",
|
||||||
|
"type": "jsonb",
|
||||||
|
"unsigned": false,
|
||||||
|
"autoincrement": false,
|
||||||
|
"primary": false,
|
||||||
|
"nullable": true,
|
||||||
|
"mappedType": "json"
|
||||||
|
},
|
||||||
"max_quantity": {
|
"max_quantity": {
|
||||||
"name": "max_quantity",
|
"name": "max_quantity",
|
||||||
"type": "numeric",
|
"type": "numeric",
|
||||||
@@ -488,7 +513,7 @@
|
|||||||
"mappedType": "datetime"
|
"mappedType": "datetime"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"name": "application_method",
|
"name": "promotion_application_method",
|
||||||
"schema": "public",
|
"schema": "public",
|
||||||
"indexes": [
|
"indexes": [
|
||||||
{
|
{
|
||||||
@@ -515,12 +540,12 @@
|
|||||||
{
|
{
|
||||||
"columnNames": ["promotion_id"],
|
"columnNames": ["promotion_id"],
|
||||||
"composite": false,
|
"composite": false,
|
||||||
"keyName": "application_method_promotion_id_unique",
|
"keyName": "promotion_application_method_promotion_id_unique",
|
||||||
"primary": false,
|
"primary": false,
|
||||||
"unique": true
|
"unique": true
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"keyName": "application_method_pkey",
|
"keyName": "promotion_application_method_pkey",
|
||||||
"columnNames": ["id"],
|
"columnNames": ["id"],
|
||||||
"composite": false,
|
"composite": false,
|
||||||
"primary": true,
|
"primary": true,
|
||||||
@@ -529,10 +554,10 @@
|
|||||||
],
|
],
|
||||||
"checks": [],
|
"checks": [],
|
||||||
"foreignKeys": {
|
"foreignKeys": {
|
||||||
"application_method_promotion_id_foreign": {
|
"promotion_application_method_promotion_id_foreign": {
|
||||||
"constraintName": "application_method_promotion_id_foreign",
|
"constraintName": "promotion_application_method_promotion_id_foreign",
|
||||||
"columnNames": ["promotion_id"],
|
"columnNames": ["promotion_id"],
|
||||||
"localTableName": "public.application_method",
|
"localTableName": "public.promotion_application_method",
|
||||||
"referencedColumnNames": ["id"],
|
"referencedColumnNames": ["id"],
|
||||||
"referencedTableName": "public.promotion",
|
"referencedTableName": "public.promotion",
|
||||||
"deleteRule": "cascade",
|
"deleteRule": "cascade",
|
||||||
@@ -733,7 +758,7 @@
|
|||||||
"columnNames": ["application_method_id"],
|
"columnNames": ["application_method_id"],
|
||||||
"localTableName": "public.application_method_target_rules",
|
"localTableName": "public.application_method_target_rules",
|
||||||
"referencedColumnNames": ["id"],
|
"referencedColumnNames": ["id"],
|
||||||
"referencedTableName": "public.application_method",
|
"referencedTableName": "public.promotion_application_method",
|
||||||
"deleteRule": "cascade",
|
"deleteRule": "cascade",
|
||||||
"updateRule": "cascade"
|
"updateRule": "cascade"
|
||||||
},
|
},
|
||||||
@@ -787,7 +812,7 @@
|
|||||||
"columnNames": ["application_method_id"],
|
"columnNames": ["application_method_id"],
|
||||||
"localTableName": "public.application_method_buy_rules",
|
"localTableName": "public.application_method_buy_rules",
|
||||||
"referencedColumnNames": ["id"],
|
"referencedColumnNames": ["id"],
|
||||||
"referencedTableName": "public.application_method",
|
"referencedTableName": "public.promotion_application_method",
|
||||||
"deleteRule": "cascade",
|
"deleteRule": "cascade",
|
||||||
"updateRule": "cascade"
|
"updateRule": "cascade"
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -1,113 +0,0 @@
|
|||||||
import { Migration } from "@mikro-orm/migrations"
|
|
||||||
|
|
||||||
export class Migration20240122084316 extends Migration {
|
|
||||||
async up(): Promise<void> {
|
|
||||||
this.addSql(
|
|
||||||
'create table "campaign" ("id" text not null, "name" text not null, "description" text null, "currency" text null, "campaign_identifier" text not null, "starts_at" timestamptz null, "ends_at" timestamptz null, "created_at" timestamptz not null default now(), "updated_at" timestamptz not null default now(), "deleted_at" timestamptz null, constraint "campaign_pkey" primary key ("id"));'
|
|
||||||
)
|
|
||||||
this.addSql(
|
|
||||||
'alter table "campaign" add constraint "IDX_campaign_identifier_unique" unique ("campaign_identifier");'
|
|
||||||
)
|
|
||||||
|
|
||||||
this.addSql(
|
|
||||||
'create table "campaign_budget" ("id" text not null, "type" text check ("type" in (\'spend\', \'usage\')) not null, "campaign_id" text not null, "limit" numeric null default null, "used" numeric not null default 0, "created_at" timestamptz not null default now(), "updated_at" timestamptz not null default now(), "deleted_at" timestamptz null, constraint "campaign_budget_pkey" primary key ("id"));'
|
|
||||||
)
|
|
||||||
this.addSql(
|
|
||||||
'create index "IDX_campaign_budget_type" on "campaign_budget" ("type");'
|
|
||||||
)
|
|
||||||
this.addSql(
|
|
||||||
'alter table "campaign_budget" add constraint "campaign_budget_campaign_id_unique" unique ("campaign_id");'
|
|
||||||
)
|
|
||||||
|
|
||||||
this.addSql(
|
|
||||||
'create table "promotion" ("id" text not null, "code" text not null, "campaign_id" text null, "is_automatic" boolean not null default false, "type" text check ("type" in (\'standard\', \'buyget\')) not null, "created_at" timestamptz not null default now(), "updated_at" timestamptz not null default now(), "deleted_at" timestamptz null, constraint "promotion_pkey" primary key ("id"));'
|
|
||||||
)
|
|
||||||
this.addSql('create index "IDX_promotion_code" on "promotion" ("code");')
|
|
||||||
this.addSql('create index "IDX_promotion_type" on "promotion" ("type");')
|
|
||||||
this.addSql(
|
|
||||||
'alter table "promotion" add constraint "IDX_promotion_code_unique" unique ("code");'
|
|
||||||
)
|
|
||||||
|
|
||||||
this.addSql(
|
|
||||||
'create table "application_method" ("id" text not null, "value" numeric null, "max_quantity" numeric null, "apply_to_quantity" numeric null, "buy_rules_min_quantity" numeric null, "type" text check ("type" in (\'fixed\', \'percentage\')) not null, "target_type" text check ("target_type" in (\'order\', \'shipping_methods\', \'items\')) not null, "allocation" text check ("allocation" in (\'each\', \'across\')) null, "promotion_id" text not null, "created_at" timestamptz not null default now(), "updated_at" timestamptz not null default now(), "deleted_at" timestamptz null, constraint "application_method_pkey" primary key ("id"));'
|
|
||||||
)
|
|
||||||
this.addSql(
|
|
||||||
'create index "IDX_application_method_type" on "application_method" ("type");'
|
|
||||||
)
|
|
||||||
this.addSql(
|
|
||||||
'create index "IDX_application_method_target_type" on "application_method" ("target_type");'
|
|
||||||
)
|
|
||||||
this.addSql(
|
|
||||||
'create index "IDX_application_method_allocation" on "application_method" ("allocation");'
|
|
||||||
)
|
|
||||||
this.addSql(
|
|
||||||
'alter table "application_method" add constraint "application_method_promotion_id_unique" unique ("promotion_id");'
|
|
||||||
)
|
|
||||||
|
|
||||||
this.addSql(
|
|
||||||
'create table "promotion_rule" ("id" text not null, "description" text null, "attribute" text not null, "operator" text check ("operator" in (\'gte\', \'lte\', \'gt\', \'lt\', \'eq\', \'ne\', \'in\')) not null, "created_at" timestamptz not null default now(), "updated_at" timestamptz not null default now(), "deleted_at" timestamptz null, constraint "promotion_rule_pkey" primary key ("id"));'
|
|
||||||
)
|
|
||||||
this.addSql(
|
|
||||||
'create index "IDX_promotion_rule_attribute" on "promotion_rule" ("attribute");'
|
|
||||||
)
|
|
||||||
this.addSql(
|
|
||||||
'create index "IDX_promotion_rule_operator" on "promotion_rule" ("operator");'
|
|
||||||
)
|
|
||||||
|
|
||||||
this.addSql(
|
|
||||||
'create table "promotion_promotion_rule" ("promotion_id" text not null, "promotion_rule_id" text not null, constraint "promotion_promotion_rule_pkey" primary key ("promotion_id", "promotion_rule_id"));'
|
|
||||||
)
|
|
||||||
|
|
||||||
this.addSql(
|
|
||||||
'create table "application_method_target_rules" ("application_method_id" text not null, "promotion_rule_id" text not null, constraint "application_method_target_rules_pkey" primary key ("application_method_id", "promotion_rule_id"));'
|
|
||||||
)
|
|
||||||
|
|
||||||
this.addSql(
|
|
||||||
'create table "application_method_buy_rules" ("application_method_id" text not null, "promotion_rule_id" text not null, constraint "application_method_buy_rules_pkey" primary key ("application_method_id", "promotion_rule_id"));'
|
|
||||||
)
|
|
||||||
|
|
||||||
this.addSql(
|
|
||||||
'create table "promotion_rule_value" ("id" text not null, "promotion_rule_id" text not null, "value" text not null, "created_at" timestamptz not null default now(), "updated_at" timestamptz not null default now(), "deleted_at" timestamptz null, constraint "promotion_rule_value_pkey" primary key ("id"));'
|
|
||||||
)
|
|
||||||
this.addSql(
|
|
||||||
'create index "IDX_promotion_rule_promotion_rule_value_id" on "promotion_rule_value" ("promotion_rule_id");'
|
|
||||||
)
|
|
||||||
|
|
||||||
this.addSql(
|
|
||||||
'alter table "campaign_budget" add constraint "campaign_budget_campaign_id_foreign" foreign key ("campaign_id") references "campaign" ("id") on update cascade;'
|
|
||||||
)
|
|
||||||
|
|
||||||
this.addSql(
|
|
||||||
'alter table "promotion" add constraint "promotion_campaign_id_foreign" foreign key ("campaign_id") references "campaign" ("id") on delete set null;'
|
|
||||||
)
|
|
||||||
|
|
||||||
this.addSql(
|
|
||||||
'alter table "application_method" add constraint "application_method_promotion_id_foreign" foreign key ("promotion_id") references "promotion" ("id") on update cascade on delete cascade;'
|
|
||||||
)
|
|
||||||
|
|
||||||
this.addSql(
|
|
||||||
'alter table "promotion_promotion_rule" add constraint "promotion_promotion_rule_promotion_id_foreign" foreign key ("promotion_id") references "promotion" ("id") on update cascade on delete cascade;'
|
|
||||||
)
|
|
||||||
this.addSql(
|
|
||||||
'alter table "promotion_promotion_rule" add constraint "promotion_promotion_rule_promotion_rule_id_foreign" foreign key ("promotion_rule_id") references "promotion_rule" ("id") on update cascade on delete cascade;'
|
|
||||||
)
|
|
||||||
|
|
||||||
this.addSql(
|
|
||||||
'alter table "application_method_target_rules" add constraint "application_method_target_rules_application_method_id_foreign" foreign key ("application_method_id") references "application_method" ("id") on update cascade on delete cascade;'
|
|
||||||
)
|
|
||||||
this.addSql(
|
|
||||||
'alter table "application_method_target_rules" add constraint "application_method_target_rules_promotion_rule_id_foreign" foreign key ("promotion_rule_id") references "promotion_rule" ("id") on update cascade on delete cascade;'
|
|
||||||
)
|
|
||||||
|
|
||||||
this.addSql(
|
|
||||||
'alter table "application_method_buy_rules" add constraint "application_method_buy_rules_application_method_id_foreign" foreign key ("application_method_id") references "application_method" ("id") on update cascade on delete cascade;'
|
|
||||||
)
|
|
||||||
this.addSql(
|
|
||||||
'alter table "application_method_buy_rules" add constraint "application_method_buy_rules_promotion_rule_id_foreign" foreign key ("promotion_rule_id") references "promotion_rule" ("id") on update cascade on delete cascade;'
|
|
||||||
)
|
|
||||||
|
|
||||||
this.addSql(
|
|
||||||
'alter table "promotion_rule_value" add constraint "promotion_rule_value_promotion_rule_id_foreign" foreign key ("promotion_rule_id") references "promotion_rule" ("id") on update cascade on delete cascade;'
|
|
||||||
)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -0,0 +1,117 @@
|
|||||||
|
import { Migration } from "@mikro-orm/migrations"
|
||||||
|
|
||||||
|
export class Migration20240227120221 extends Migration {
|
||||||
|
async up(): Promise<void> {
|
||||||
|
this.addSql(
|
||||||
|
'create table if not exists "promotion_campaign" ("id" text not null, "name" text not null, "description" text null, "currency" text null, "campaign_identifier" text not null, "starts_at" timestamptz null, "ends_at" timestamptz null, "created_at" timestamptz not null default now(), "updated_at" timestamptz not null default now(), "deleted_at" timestamptz null, constraint "promotion_campaign_pkey" primary key ("id"));'
|
||||||
|
)
|
||||||
|
this.addSql(
|
||||||
|
'alter table if exists "promotion_campaign" add constraint "IDX_campaign_identifier_unique" unique ("campaign_identifier");'
|
||||||
|
)
|
||||||
|
|
||||||
|
this.addSql(
|
||||||
|
'create table if not exists "promotion_campaign_budget" ("id" text not null, "type" text check ("type" in (\'spend\', \'usage\')) not null, "campaign_id" text not null, "limit" numeric null, "raw_limit" jsonb null, "used" numeric null, "raw_used" jsonb null, "created_at" timestamptz not null default now(), "updated_at" timestamptz not null default now(), "deleted_at" timestamptz null, constraint "promotion_campaign_budget_pkey" primary key ("id"));'
|
||||||
|
)
|
||||||
|
this.addSql(
|
||||||
|
'create index if not exists "IDX_campaign_budget_type" on "promotion_campaign_budget" ("type");'
|
||||||
|
)
|
||||||
|
this.addSql(
|
||||||
|
'alter table if exists "promotion_campaign_budget" add constraint "promotion_campaign_budget_campaign_id_unique" unique ("campaign_id");'
|
||||||
|
)
|
||||||
|
|
||||||
|
this.addSql(
|
||||||
|
'create table if not exists "promotion" ("id" text not null, "code" text not null, "campaign_id" text null, "is_automatic" boolean not null default false, "type" text check ("type" in (\'standard\', \'buyget\')) not null, "created_at" timestamptz not null default now(), "updated_at" timestamptz not null default now(), "deleted_at" timestamptz null, constraint "promotion_pkey" primary key ("id"));'
|
||||||
|
)
|
||||||
|
this.addSql(
|
||||||
|
'create index if not exists "IDX_promotion_code" on "promotion" ("code");'
|
||||||
|
)
|
||||||
|
this.addSql(
|
||||||
|
'create index if not exists "IDX_promotion_type" on "promotion" ("type");'
|
||||||
|
)
|
||||||
|
this.addSql(
|
||||||
|
'alter table if exists "promotion" add constraint "IDX_promotion_code_unique" unique ("code");'
|
||||||
|
)
|
||||||
|
|
||||||
|
this.addSql(
|
||||||
|
'create table if not exists "promotion_application_method" ("id" text not null, "value" numeric null, "raw_value" jsonb null, "max_quantity" numeric null, "apply_to_quantity" numeric null, "buy_rules_min_quantity" numeric null, "type" text check ("type" in (\'fixed\', \'percentage\')) not null, "target_type" text check ("target_type" in (\'order\', \'shipping_methods\', \'items\')) not null, "allocation" text check ("allocation" in (\'each\', \'across\')) null, "promotion_id" text not null, "created_at" timestamptz not null default now(), "updated_at" timestamptz not null default now(), "deleted_at" timestamptz null, constraint "promotion_application_method_pkey" primary key ("id"));'
|
||||||
|
)
|
||||||
|
this.addSql(
|
||||||
|
'create index if not exists "IDX_application_method_type" on "promotion_application_method" ("type");'
|
||||||
|
)
|
||||||
|
this.addSql(
|
||||||
|
'create index if not exists "IDX_application_method_target_type" on "promotion_application_method" ("target_type");'
|
||||||
|
)
|
||||||
|
this.addSql(
|
||||||
|
'create index if not exists "IDX_application_method_allocation" on "promotion_application_method" ("allocation");'
|
||||||
|
)
|
||||||
|
this.addSql(
|
||||||
|
'alter table if exists "promotion_application_method" add constraint "promotion_application_method_promotion_id_unique" unique ("promotion_id");'
|
||||||
|
)
|
||||||
|
|
||||||
|
this.addSql(
|
||||||
|
'create table if not exists "promotion_rule" ("id" text not null, "description" text null, "attribute" text not null, "operator" text check ("operator" in (\'gte\', \'lte\', \'gt\', \'lt\', \'eq\', \'ne\', \'in\')) not null, "created_at" timestamptz not null default now(), "updated_at" timestamptz not null default now(), "deleted_at" timestamptz null, constraint "promotion_rule_pkey" primary key ("id"));'
|
||||||
|
)
|
||||||
|
this.addSql(
|
||||||
|
'create index if not exists "IDX_promotion_rule_attribute" on "promotion_rule" ("attribute");'
|
||||||
|
)
|
||||||
|
this.addSql(
|
||||||
|
'create index if not exists "IDX_promotion_rule_operator" on "promotion_rule" ("operator");'
|
||||||
|
)
|
||||||
|
|
||||||
|
this.addSql(
|
||||||
|
'create table if not exists "promotion_promotion_rule" ("promotion_id" text not null, "promotion_rule_id" text not null, constraint "promotion_promotion_rule_pkey" primary key ("promotion_id", "promotion_rule_id"));'
|
||||||
|
)
|
||||||
|
|
||||||
|
this.addSql(
|
||||||
|
'create table if not exists "application_method_target_rules" ("application_method_id" text not null, "promotion_rule_id" text not null, constraint "application_method_target_rules_pkey" primary key ("application_method_id", "promotion_rule_id"));'
|
||||||
|
)
|
||||||
|
|
||||||
|
this.addSql(
|
||||||
|
'create table if not exists "application_method_buy_rules" ("application_method_id" text not null, "promotion_rule_id" text not null, constraint "application_method_buy_rules_pkey" primary key ("application_method_id", "promotion_rule_id"));'
|
||||||
|
)
|
||||||
|
|
||||||
|
this.addSql(
|
||||||
|
'create table if not exists "promotion_rule_value" ("id" text not null, "promotion_rule_id" text not null, "value" text not null, "created_at" timestamptz not null default now(), "updated_at" timestamptz not null default now(), "deleted_at" timestamptz null, constraint "promotion_rule_value_pkey" primary key ("id"));'
|
||||||
|
)
|
||||||
|
this.addSql(
|
||||||
|
'create index if not exists "IDX_promotion_rule_promotion_rule_value_id" on "promotion_rule_value" ("promotion_rule_id");'
|
||||||
|
)
|
||||||
|
|
||||||
|
this.addSql(
|
||||||
|
'alter table if exists "promotion_campaign_budget" add constraint "promotion_campaign_budget_campaign_id_foreign" foreign key ("campaign_id") references "promotion_campaign" ("id") on update cascade;'
|
||||||
|
)
|
||||||
|
|
||||||
|
this.addSql(
|
||||||
|
'alter table if exists "promotion" add constraint "promotion_campaign_id_foreign" foreign key ("campaign_id") references "promotion_campaign" ("id") on delete set null;'
|
||||||
|
)
|
||||||
|
|
||||||
|
this.addSql(
|
||||||
|
'alter table if exists "promotion_application_method" add constraint "promotion_application_method_promotion_id_foreign" foreign key ("promotion_id") references "promotion" ("id") on update cascade on delete cascade;'
|
||||||
|
)
|
||||||
|
|
||||||
|
this.addSql(
|
||||||
|
'alter table if exists "promotion_promotion_rule" add constraint "promotion_promotion_rule_promotion_id_foreign" foreign key ("promotion_id") references "promotion" ("id") on update cascade on delete cascade;'
|
||||||
|
)
|
||||||
|
this.addSql(
|
||||||
|
'alter table if exists "promotion_promotion_rule" add constraint "promotion_promotion_rule_promotion_rule_id_foreign" foreign key ("promotion_rule_id") references "promotion_rule" ("id") on update cascade on delete cascade;'
|
||||||
|
)
|
||||||
|
|
||||||
|
this.addSql(
|
||||||
|
'alter table if exists "application_method_target_rules" add constraint "application_method_target_rules_application_method_id_foreign" foreign key ("application_method_id") references "promotion_application_method" ("id") on update cascade on delete cascade;'
|
||||||
|
)
|
||||||
|
this.addSql(
|
||||||
|
'alter table if exists "application_method_target_rules" add constraint "application_method_target_rules_promotion_rule_id_foreign" foreign key ("promotion_rule_id") references "promotion_rule" ("id") on update cascade on delete cascade;'
|
||||||
|
)
|
||||||
|
|
||||||
|
this.addSql(
|
||||||
|
'alter table if exists "application_method_buy_rules" add constraint "application_method_buy_rules_application_method_id_foreign" foreign key ("application_method_id") references "promotion_application_method" ("id") on update cascade on delete cascade;'
|
||||||
|
)
|
||||||
|
this.addSql(
|
||||||
|
'alter table if exists "application_method_buy_rules" add constraint "application_method_buy_rules_promotion_rule_id_foreign" foreign key ("promotion_rule_id") references "promotion_rule" ("id") on update cascade on delete cascade;'
|
||||||
|
)
|
||||||
|
|
||||||
|
this.addSql(
|
||||||
|
'alter table if exists "promotion_rule_value" add constraint "promotion_rule_value_promotion_rule_id_foreign" foreign key ("promotion_rule_id") references "promotion_rule" ("id") on update cascade on delete cascade;'
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -2,9 +2,16 @@ import {
|
|||||||
ApplicationMethodAllocationValues,
|
ApplicationMethodAllocationValues,
|
||||||
ApplicationMethodTargetTypeValues,
|
ApplicationMethodTargetTypeValues,
|
||||||
ApplicationMethodTypeValues,
|
ApplicationMethodTypeValues,
|
||||||
|
BigNumberRawValue,
|
||||||
DAL,
|
DAL,
|
||||||
} from "@medusajs/types"
|
} from "@medusajs/types"
|
||||||
import { DALUtils, PromotionUtils, generateEntityId } from "@medusajs/utils"
|
import {
|
||||||
|
BigNumber,
|
||||||
|
DALUtils,
|
||||||
|
MikroOrmBigNumberProperty,
|
||||||
|
PromotionUtils,
|
||||||
|
generateEntityId,
|
||||||
|
} from "@medusajs/utils"
|
||||||
import {
|
import {
|
||||||
BeforeCreate,
|
BeforeCreate,
|
||||||
Collection,
|
Collection,
|
||||||
@@ -30,7 +37,7 @@ type OptionalFields =
|
|||||||
| "allocation"
|
| "allocation"
|
||||||
| DAL.SoftDeletableEntityDateColumns
|
| DAL.SoftDeletableEntityDateColumns
|
||||||
|
|
||||||
@Entity({ tableName: "application_method" })
|
@Entity({ tableName: "promotion_application_method" })
|
||||||
@Filter(DALUtils.mikroOrmSoftDeletableFilterOptions)
|
@Filter(DALUtils.mikroOrmSoftDeletableFilterOptions)
|
||||||
export default class ApplicationMethod {
|
export default class ApplicationMethod {
|
||||||
[OptionalProps]?: OptionalFields
|
[OptionalProps]?: OptionalFields
|
||||||
@@ -38,8 +45,11 @@ export default class ApplicationMethod {
|
|||||||
@PrimaryKey({ columnType: "text" })
|
@PrimaryKey({ columnType: "text" })
|
||||||
id!: string
|
id!: string
|
||||||
|
|
||||||
@Property({ columnType: "numeric", nullable: true, serializer: Number })
|
@MikroOrmBigNumberProperty({ nullable: true })
|
||||||
value?: string | null = null
|
value: BigNumber | number | null = null
|
||||||
|
|
||||||
|
@Property({ columnType: "jsonb", nullable: true })
|
||||||
|
raw_value: BigNumberRawValue | null = null
|
||||||
|
|
||||||
@Property({ columnType: "numeric", nullable: true, serializer: Number })
|
@Property({ columnType: "numeric", nullable: true, serializer: Number })
|
||||||
max_quantity?: number | null = null
|
max_quantity?: number | null = null
|
||||||
|
|||||||
@@ -1,5 +1,15 @@
|
|||||||
import { CampaignBudgetTypeValues, DAL } from "@medusajs/types"
|
import {
|
||||||
import { DALUtils, PromotionUtils, generateEntityId } from "@medusajs/utils"
|
BigNumberRawValue,
|
||||||
|
CampaignBudgetTypeValues,
|
||||||
|
DAL,
|
||||||
|
} from "@medusajs/types"
|
||||||
|
import {
|
||||||
|
BigNumber,
|
||||||
|
DALUtils,
|
||||||
|
MikroOrmBigNumberProperty,
|
||||||
|
PromotionUtils,
|
||||||
|
generateEntityId,
|
||||||
|
} from "@medusajs/utils"
|
||||||
import {
|
import {
|
||||||
BeforeCreate,
|
BeforeCreate,
|
||||||
Entity,
|
Entity,
|
||||||
@@ -20,7 +30,7 @@ type OptionalFields =
|
|||||||
| "used"
|
| "used"
|
||||||
| DAL.SoftDeletableEntityDateColumns
|
| DAL.SoftDeletableEntityDateColumns
|
||||||
|
|
||||||
@Entity({ tableName: "campaign_budget" })
|
@Entity({ tableName: "promotion_campaign_budget" })
|
||||||
@Filter(DALUtils.mikroOrmSoftDeletableFilterOptions)
|
@Filter(DALUtils.mikroOrmSoftDeletableFilterOptions)
|
||||||
export default class CampaignBudget {
|
export default class CampaignBudget {
|
||||||
[OptionalProps]?: OptionalFields
|
[OptionalProps]?: OptionalFields
|
||||||
@@ -37,20 +47,17 @@ export default class CampaignBudget {
|
|||||||
})
|
})
|
||||||
campaign: Campaign | null = null
|
campaign: Campaign | null = null
|
||||||
|
|
||||||
@Property({
|
@MikroOrmBigNumberProperty({ nullable: true })
|
||||||
columnType: "numeric",
|
limit: BigNumber | number | null = null
|
||||||
nullable: true,
|
|
||||||
serializer: Number,
|
|
||||||
default: null,
|
|
||||||
})
|
|
||||||
limit: number | null = null
|
|
||||||
|
|
||||||
@Property({
|
@Property({ columnType: "jsonb", nullable: true })
|
||||||
columnType: "numeric",
|
raw_limit: BigNumberRawValue | null = null
|
||||||
serializer: Number,
|
|
||||||
default: 0,
|
@MikroOrmBigNumberProperty({ nullable: true })
|
||||||
})
|
used: BigNumber | number | null = null
|
||||||
used: number
|
|
||||||
|
@Property({ columnType: "jsonb", nullable: true })
|
||||||
|
raw_used: BigNumberRawValue | null = null
|
||||||
|
|
||||||
@Property({
|
@Property({
|
||||||
onCreate: () => new Date(),
|
onCreate: () => new Date(),
|
||||||
|
|||||||
@@ -24,7 +24,7 @@ type OptionalFields =
|
|||||||
| "ends_at"
|
| "ends_at"
|
||||||
| DAL.SoftDeletableEntityDateColumns
|
| DAL.SoftDeletableEntityDateColumns
|
||||||
|
|
||||||
@Entity({ tableName: "campaign" })
|
@Entity({ tableName: "promotion_campaign" })
|
||||||
@Filter(DALUtils.mikroOrmSoftDeletableFilterOptions)
|
@Filter(DALUtils.mikroOrmSoftDeletableFilterOptions)
|
||||||
export default class Campaign {
|
export default class Campaign {
|
||||||
[OptionalProps]?: OptionalFields | OptionalRelations
|
[OptionalProps]?: OptionalFields | OptionalRelations
|
||||||
|
|||||||
@@ -247,7 +247,7 @@ export default class PromotionModuleService<
|
|||||||
? []
|
? []
|
||||||
: await this.list(
|
: await this.list(
|
||||||
{ is_automatic: true },
|
{ is_automatic: true },
|
||||||
{ select: ["code"] },
|
{ select: ["code"], take: null },
|
||||||
sharedContext
|
sharedContext
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -303,6 +303,7 @@ export default class PromotionModuleService<
|
|||||||
"campaign",
|
"campaign",
|
||||||
"campaign.budget",
|
"campaign.budget",
|
||||||
],
|
],
|
||||||
|
take: null,
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -462,6 +463,7 @@ export default class PromotionModuleService<
|
|||||||
"campaign",
|
"campaign",
|
||||||
"campaign.budget",
|
"campaign.budget",
|
||||||
],
|
],
|
||||||
|
take: null,
|
||||||
},
|
},
|
||||||
sharedContext
|
sharedContext
|
||||||
)
|
)
|
||||||
@@ -674,6 +676,7 @@ export default class PromotionModuleService<
|
|||||||
"campaign",
|
"campaign",
|
||||||
"campaign.budget",
|
"campaign.budget",
|
||||||
],
|
],
|
||||||
|
take: null,
|
||||||
},
|
},
|
||||||
sharedContext
|
sharedContext
|
||||||
)
|
)
|
||||||
@@ -1046,6 +1049,7 @@ export default class PromotionModuleService<
|
|||||||
{ id: createdCampaigns.map((p) => p!.id) },
|
{ id: createdCampaigns.map((p) => p!.id) },
|
||||||
{
|
{
|
||||||
relations: ["budget", "promotions"],
|
relations: ["budget", "promotions"],
|
||||||
|
take: null,
|
||||||
},
|
},
|
||||||
sharedContext
|
sharedContext
|
||||||
)
|
)
|
||||||
@@ -1075,7 +1079,7 @@ export default class PromotionModuleService<
|
|||||||
const promotionsToAdd = promotions
|
const promotionsToAdd = promotions
|
||||||
? await this.list(
|
? await this.list(
|
||||||
{ id: promotions.map((p) => p.id) },
|
{ id: promotions.map((p) => p.id) },
|
||||||
{},
|
{ take: null },
|
||||||
sharedContext
|
sharedContext
|
||||||
)
|
)
|
||||||
: []
|
: []
|
||||||
@@ -1137,13 +1141,13 @@ export default class PromotionModuleService<
|
|||||||
@MedusaContext() sharedContext: Context = {}
|
@MedusaContext() sharedContext: Context = {}
|
||||||
): Promise<PromotionTypes.CampaignDTO | PromotionTypes.CampaignDTO[]> {
|
): Promise<PromotionTypes.CampaignDTO | PromotionTypes.CampaignDTO[]> {
|
||||||
const input = Array.isArray(data) ? data : [data]
|
const input = Array.isArray(data) ? data : [data]
|
||||||
|
|
||||||
const updatedCampaigns = await this.updateCampaigns_(input, sharedContext)
|
const updatedCampaigns = await this.updateCampaigns_(input, sharedContext)
|
||||||
|
|
||||||
const campaigns = await this.listCampaigns(
|
const campaigns = await this.listCampaigns(
|
||||||
{ id: updatedCampaigns.map((p) => p!.id) },
|
{ id: updatedCampaigns.map((p) => p!.id) },
|
||||||
{
|
{
|
||||||
relations: ["budget", "promotions"],
|
relations: ["budget", "promotions"],
|
||||||
|
take: null,
|
||||||
},
|
},
|
||||||
sharedContext
|
sharedContext
|
||||||
)
|
)
|
||||||
@@ -1162,7 +1166,7 @@ export default class PromotionModuleService<
|
|||||||
|
|
||||||
const existingCampaigns = await this.listCampaigns(
|
const existingCampaigns = await this.listCampaigns(
|
||||||
{ id: campaignIds },
|
{ id: campaignIds },
|
||||||
{ relations: ["budget"] },
|
{ relations: ["budget"], take: null },
|
||||||
sharedContext
|
sharedContext
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -1186,10 +1190,16 @@ export default class PromotionModuleService<
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const updatedCampaigns = await this.campaignService_.update(campaignsData)
|
const updatedCampaigns = await this.campaignService_.update(
|
||||||
|
campaignsData,
|
||||||
|
sharedContext
|
||||||
|
)
|
||||||
|
|
||||||
if (campaignBudgetsData.length) {
|
if (campaignBudgetsData.length) {
|
||||||
await this.campaignBudgetService_.update(campaignBudgetsData)
|
await this.campaignBudgetService_.update(
|
||||||
|
campaignBudgetsData,
|
||||||
|
sharedContext
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
return updatedCampaigns
|
return updatedCampaigns
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ export interface CreateApplicationMethodDTO {
|
|||||||
type: ApplicationMethodTypeValues
|
type: ApplicationMethodTypeValues
|
||||||
target_type: ApplicationMethodTargetTypeValues
|
target_type: ApplicationMethodTargetTypeValues
|
||||||
allocation?: ApplicationMethodAllocationValues
|
allocation?: ApplicationMethodAllocationValues
|
||||||
value?: string | null
|
value?: number
|
||||||
promotion: Promotion | string | PromotionDTO
|
promotion: Promotion | string | PromotionDTO
|
||||||
max_quantity?: number | null
|
max_quantity?: number | null
|
||||||
buy_rules_min_quantity?: number | null
|
buy_rules_min_quantity?: number | null
|
||||||
@@ -23,7 +23,7 @@ export interface UpdateApplicationMethodDTO {
|
|||||||
type?: ApplicationMethodTypeValues
|
type?: ApplicationMethodTypeValues
|
||||||
target_type?: ApplicationMethodTargetTypeValues
|
target_type?: ApplicationMethodTargetTypeValues
|
||||||
allocation?: ApplicationMethodAllocationValues
|
allocation?: ApplicationMethodAllocationValues
|
||||||
value?: string | null
|
value?: number
|
||||||
promotion?: Promotion | string | PromotionDTO
|
promotion?: Promotion | string | PromotionDTO
|
||||||
max_quantity?: number | null
|
max_quantity?: number | null
|
||||||
buy_rules_min_quantity?: number | null
|
buy_rules_min_quantity?: number | null
|
||||||
|
|||||||
@@ -75,9 +75,8 @@ export function applyPromotionToItems(
|
|||||||
)
|
)
|
||||||
const totalItemValue =
|
const totalItemValue =
|
||||||
(method.subtotal / method.quantity) * quantityMultiplier
|
(method.subtotal / method.quantity) * quantityMultiplier
|
||||||
let promotionValue = parseFloat(applicationMethod!.value!)
|
let promotionValue = applicationMethod?.value ?? 0
|
||||||
const applicableTotal = totalItemValue - appliedPromoValue
|
const applicableTotal = totalItemValue - appliedPromoValue
|
||||||
|
|
||||||
if (applicationMethod?.type === ApplicationMethodType.PERCENTAGE) {
|
if (applicationMethod?.type === ApplicationMethodType.PERCENTAGE) {
|
||||||
promotionValue = (promotionValue / 100) * applicableTotal
|
promotionValue = (promotionValue / 100) * applicableTotal
|
||||||
}
|
}
|
||||||
@@ -130,7 +129,7 @@ export function applyPromotionToItems(
|
|||||||
}
|
}
|
||||||
|
|
||||||
const appliedPromoValue = methodIdPromoValueMap.get(method.id) ?? 0
|
const appliedPromoValue = methodIdPromoValueMap.get(method.id) ?? 0
|
||||||
const promotionValue = parseFloat(applicationMethod!.value!)
|
const promotionValue = applicationMethod?.value ?? 0
|
||||||
const applicableTotal =
|
const applicableTotal =
|
||||||
(method.subtotal / method.quantity) * method.quantity -
|
(method.subtotal / method.quantity) * method.quantity -
|
||||||
appliedPromoValue
|
appliedPromoValue
|
||||||
|
|||||||
@@ -60,7 +60,7 @@ export function applyPromotionToShippingMethods(
|
|||||||
}
|
}
|
||||||
|
|
||||||
const appliedPromoValue = methodIdPromoValueMap.get(method.id) ?? 0
|
const appliedPromoValue = methodIdPromoValueMap.get(method.id) ?? 0
|
||||||
let promotionValue = parseFloat(applicationMethod!.value!)
|
let promotionValue = applicationMethod?.value ?? 0
|
||||||
const applicableTotal = method.subtotal - appliedPromoValue
|
const applicableTotal = method.subtotal - appliedPromoValue
|
||||||
|
|
||||||
if (applicationMethod?.type === ApplicationMethodType.PERCENTAGE) {
|
if (applicationMethod?.type === ApplicationMethodType.PERCENTAGE) {
|
||||||
@@ -111,7 +111,7 @@ export function applyPromotionToShippingMethods(
|
|||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
const promotionValue = parseFloat(applicationMethod!.value!)
|
const promotionValue = applicationMethod?.value ?? 0
|
||||||
const applicableTotal = method.subtotal
|
const applicableTotal = method.subtotal
|
||||||
const appliedPromoValue = methodIdPromoValueMap.get(method.id) ?? 0
|
const appliedPromoValue = methodIdPromoValueMap.get(method.id) ?? 0
|
||||||
|
|
||||||
|
|||||||
@@ -36,14 +36,14 @@ export function validateApplicationMethodAttributes(
|
|||||||
const targetType = data.target_type || applicationMethod?.target_type
|
const targetType = data.target_type || applicationMethod?.target_type
|
||||||
const type = data.type || applicationMethod?.type
|
const type = data.type || applicationMethod?.type
|
||||||
const applicationMethodType = data.type || applicationMethod?.type
|
const applicationMethodType = data.type || applicationMethod?.type
|
||||||
const value = parseFloat(data.value! || applicationMethod?.value!)
|
const value = data.value || applicationMethod.value
|
||||||
const maxQuantity = data.max_quantity || applicationMethod.max_quantity
|
const maxQuantity = data.max_quantity || applicationMethod.max_quantity
|
||||||
const allocation = data.allocation || applicationMethod.allocation
|
const allocation = data.allocation || applicationMethod.allocation
|
||||||
const allTargetTypes: string[] = Object.values(ApplicationMethodTargetType)
|
const allTargetTypes: string[] = Object.values(ApplicationMethodTargetType)
|
||||||
|
|
||||||
if (
|
if (
|
||||||
type === ApplicationMethodType.PERCENTAGE &&
|
type === ApplicationMethodType.PERCENTAGE &&
|
||||||
(value <= 0 || value > 100)
|
(typeof value !== "number" || value <= 0 || value > 100)
|
||||||
) {
|
) {
|
||||||
throw new MedusaError(
|
throw new MedusaError(
|
||||||
MedusaError.Types.INVALID_DATA,
|
MedusaError.Types.INVALID_DATA,
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ export interface ApplicationMethodDTO {
|
|||||||
type?: ApplicationMethodTypeValues
|
type?: ApplicationMethodTypeValues
|
||||||
target_type?: ApplicationMethodTargetTypeValues
|
target_type?: ApplicationMethodTargetTypeValues
|
||||||
allocation?: ApplicationMethodAllocationValues
|
allocation?: ApplicationMethodAllocationValues
|
||||||
value?: string | null
|
value?: number
|
||||||
max_quantity?: number | null
|
max_quantity?: number | null
|
||||||
buy_rules_min_quantity?: number | null
|
buy_rules_min_quantity?: number | null
|
||||||
apply_to_quantity?: number | null
|
apply_to_quantity?: number | null
|
||||||
@@ -27,7 +27,7 @@ export interface CreateApplicationMethodDTO {
|
|||||||
type: ApplicationMethodTypeValues
|
type: ApplicationMethodTypeValues
|
||||||
target_type: ApplicationMethodTargetTypeValues
|
target_type: ApplicationMethodTargetTypeValues
|
||||||
allocation?: ApplicationMethodAllocationValues
|
allocation?: ApplicationMethodAllocationValues
|
||||||
value?: string | null
|
value?: number
|
||||||
max_quantity?: number | null
|
max_quantity?: number | null
|
||||||
buy_rules_min_quantity?: number | null
|
buy_rules_min_quantity?: number | null
|
||||||
apply_to_quantity?: number | null
|
apply_to_quantity?: number | null
|
||||||
@@ -41,7 +41,7 @@ export interface UpdateApplicationMethodDTO {
|
|||||||
type?: ApplicationMethodTypeValues
|
type?: ApplicationMethodTypeValues
|
||||||
target_type?: ApplicationMethodTargetTypeValues
|
target_type?: ApplicationMethodTargetTypeValues
|
||||||
allocation?: ApplicationMethodAllocationValues
|
allocation?: ApplicationMethodAllocationValues
|
||||||
value?: string | null
|
value?: number
|
||||||
max_quantity?: number | null
|
max_quantity?: number | null
|
||||||
buy_rules_min_quantity?: number | null
|
buy_rules_min_quantity?: number | null
|
||||||
apply_to_quantity?: number | null
|
apply_to_quantity?: number | null
|
||||||
|
|||||||
Reference in New Issue
Block a user