@mercurjs/core 2.2.0-canary.18 → 2.2.0-canary.19
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.medusa/server/src/api/admin/commission-rates/query-config.js +6 -4
- package/.medusa/server/src/api/admin/commission-rates/validators.d.ts +49 -22
- package/.medusa/server/src/api/admin/commission-rates/validators.js +11 -8
- package/.medusa/server/src/api/admin/orders/[id]/commission-lines/route.d.ts +7 -0
- package/.medusa/server/src/api/admin/orders/[id]/commission-lines/route.js +17 -0
- package/.medusa/server/src/api/admin/sellers/validators.d.ts +6 -7
- package/.medusa/server/src/api/admin/sellers/validators.js +3 -4
- package/.medusa/server/src/api/utils/order-commission-lines.d.ts +18 -0
- package/.medusa/server/src/api/utils/order-commission-lines.js +78 -0
- package/.medusa/server/src/api/vendor/customer-groups/[id]/customers/route.d.ts +4 -0
- package/.medusa/server/src/api/vendor/customer-groups/[id]/customers/route.js +20 -0
- package/.medusa/server/src/api/vendor/customer-groups/[id]/route.d.ts +6 -0
- package/.medusa/server/src/api/vendor/customer-groups/[id]/route.js +43 -0
- package/.medusa/server/src/api/vendor/customer-groups/helpers.d.ts +3 -0
- package/.medusa/server/src/api/vendor/customer-groups/helpers.js +38 -0
- package/.medusa/server/src/api/vendor/customer-groups/middlewares.d.ts +2 -0
- package/.medusa/server/src/api/vendor/customer-groups/middlewares.js +62 -0
- package/.medusa/server/src/api/vendor/customer-groups/query-config.d.ts +11 -0
- package/.medusa/server/src/api/vendor/customer-groups/query-config.js +22 -0
- package/.medusa/server/src/api/vendor/customer-groups/route.d.ts +5 -0
- package/.medusa/server/src/api/vendor/customer-groups/route.js +35 -0
- package/.medusa/server/src/api/vendor/customer-groups/validators.d.ts +157 -0
- package/.medusa/server/src/api/vendor/customer-groups/validators.js +35 -0
- package/.medusa/server/src/api/vendor/customers/[id]/customer-groups/route.d.ts +4 -0
- package/.medusa/server/src/api/vendor/customers/[id]/customer-groups/route.js +28 -0
- package/.medusa/server/src/api/vendor/customers/[id]/route.js +15 -1
- package/.medusa/server/src/api/vendor/customers/middlewares.js +9 -1
- package/.medusa/server/src/api/vendor/customers/validators.d.ts +14 -0
- package/.medusa/server/src/api/vendor/customers/validators.js +9 -2
- package/.medusa/server/src/api/vendor/middlewares.js +69 -67
- package/.medusa/server/src/api/vendor/orders/[id]/commission-lines/route.d.ts +7 -0
- package/.medusa/server/src/api/vendor/orders/[id]/commission-lines/route.js +18 -0
- package/.medusa/server/src/api/vendor/sellers/route.js +9 -2
- package/.medusa/server/src/api/vendor/sellers/validators.d.ts +3 -3
- package/.medusa/server/src/api/vendor/sellers/validators.js +5 -2
- package/.medusa/server/src/links/seller-customer-group-link.js +10 -0
- package/.medusa/server/src/migration-scripts/drop-fulfillment-global-unique-indexes.js +6 -1
- package/.medusa/server/src/modules/commission/index.d.ts +14 -0
- package/.medusa/server/src/modules/commission/index.js +3 -1
- package/.medusa/server/src/modules/commission/loaders/seed-default-commission-rate.d.ts +11 -0
- package/.medusa/server/src/modules/commission/loaders/seed-default-commission-rate.js +35 -0
- package/.medusa/server/src/modules/commission/migrations/Migration20260615120000.d.ts +5 -0
- package/.medusa/server/src/modules/commission/migrations/Migration20260615120000.js +46 -0
- package/.medusa/server/src/modules/commission/models/commission-line.d.ts +2 -1
- package/.medusa/server/src/modules/commission/models/commission-line.js +3 -2
- package/.medusa/server/src/modules/commission/models/commission-rate-value.d.ts +25 -0
- package/.medusa/server/src/modules/commission/models/commission-rate-value.js +17 -0
- package/.medusa/server/src/modules/commission/models/commission-rate.d.ts +9 -4
- package/.medusa/server/src/modules/commission/models/commission-rate.js +9 -6
- package/.medusa/server/src/modules/commission/models/commission-rule.d.ts +8 -3
- package/.medusa/server/src/modules/commission/models/index.d.ts +1 -0
- package/.medusa/server/src/modules/commission/models/index.js +4 -2
- package/.medusa/server/src/modules/commission/service.d.ts +74 -9
- package/.medusa/server/src/modules/commission/service.js +147 -114
- package/.medusa/server/src/modules/seller/migrations/Migration20260616120000.d.ts +5 -0
- package/.medusa/server/src/modules/seller/migrations/Migration20260616120000.js +16 -0
- package/.medusa/server/src/modules/seller/models/address.d.ts +2 -2
- package/.medusa/server/src/modules/seller/models/member-invite.d.ts +2 -2
- package/.medusa/server/src/modules/seller/models/member.d.ts +2 -2
- package/.medusa/server/src/modules/seller/models/payment-details.d.ts +2 -2
- package/.medusa/server/src/modules/seller/models/payment-details.js +3 -3
- package/.medusa/server/src/modules/seller/models/professional-details.d.ts +2 -2
- package/.medusa/server/src/modules/seller/models/seller-member.d.ts +4 -4
- package/.medusa/server/src/modules/seller/models/seller.d.ts +2 -2
- package/.medusa/server/src/modules/seller/service.d.ts +16 -16
- package/.medusa/server/src/subscribers/order-edit-confirmed.d.ts +9 -2
- package/.medusa/server/src/subscribers/order-edit-confirmed.js +18 -6
- package/.medusa/server/src/workflows/commission/steps/create-commission-rates.d.ts +13 -4
- package/.medusa/server/src/workflows/commission/steps/create-commission-rules.d.ts +13 -4
- package/.medusa/server/src/workflows/commission/steps/index.d.ts +1 -0
- package/.medusa/server/src/workflows/commission/steps/index.js +2 -1
- package/.medusa/server/src/workflows/commission/steps/update-commission-rates.d.ts +13 -4
- package/.medusa/server/src/workflows/commission/steps/update-commission-rules.d.ts +13 -4
- package/.medusa/server/src/workflows/commission/steps/upsert-commission-lines.d.ts +6 -2
- package/.medusa/server/src/workflows/commission/steps/upsert-commission-lines.js +5 -1
- package/.medusa/server/src/workflows/commission/steps/validate-commission-rates-deletable.d.ts +5 -0
- package/.medusa/server/src/workflows/commission/steps/validate-commission-rates-deletable.js +22 -0
- package/.medusa/server/src/workflows/commission/workflows/create-commission-rates.d.ts +13 -4
- package/.medusa/server/src/workflows/commission/workflows/delete-commission-rates.js +3 -1
- package/.medusa/server/src/workflows/commission/workflows/refresh-order-commission-lines.js +2 -1
- package/.medusa/server/src/workflows/commission/workflows/update-commission-rates.d.ts +13 -4
- package/.medusa/server/src/workflows/customer-group/index.d.ts +2 -0
- package/.medusa/server/src/workflows/customer-group/index.js +19 -0
- package/.medusa/server/src/workflows/customer-group/steps/index.d.ts +1 -0
- package/.medusa/server/src/workflows/customer-group/steps/index.js +18 -0
- package/.medusa/server/src/workflows/customer-group/steps/link-seller-customer-group.d.ts +6 -0
- package/.medusa/server/src/workflows/customer-group/steps/link-seller-customer-group.js +36 -0
- package/.medusa/server/src/workflows/customer-group/workflows/create-seller-customer-groups.d.ts +7 -0
- package/.medusa/server/src/workflows/customer-group/workflows/create-seller-customer-groups.js +20 -0
- package/.medusa/server/src/workflows/customer-group/workflows/index.d.ts +1 -0
- package/.medusa/server/src/workflows/customer-group/workflows/index.js +18 -0
- package/.medusa/server/src/workflows/index.d.ts +1 -0
- package/.medusa/server/src/workflows/index.js +2 -1
- package/.medusa/server/src/workflows/payout/workflows/create-payout.js +21 -8
- package/.medusa/server/src/workflows/seller/steps/create-seller-member.d.ts +4 -4
- package/.medusa/server/src/workflows/seller/steps/update-member.d.ts +2 -2
- package/.medusa/server/src/workflows/seller/steps/update-seller-member.d.ts +4 -4
- package/.medusa/server/src/workflows/seller/workflows/add-seller-member.d.ts +4 -4
- package/.medusa/server/src/workflows/seller/workflows/update-member.d.ts +2 -2
- package/package.json +1 -1
- package/.medusa/server/src/links/line-item-commission-line-link.js +0 -21
- /package/.medusa/server/src/links/{line-item-commission-line-link.d.ts → seller-customer-group-link.d.ts} +0 -0
|
@@ -1,21 +1,26 @@
|
|
|
1
|
-
import { CommissionRateType
|
|
1
|
+
import { CommissionRateType } from "@mercurjs/types";
|
|
2
2
|
declare const CommissionRate: import("@medusajs/framework/utils").DmlEntity<import("@medusajs/framework/utils").DMLEntitySchemaBuilder<{
|
|
3
3
|
id: import("@medusajs/framework/utils").PrimaryKeyModifier<string, import("@medusajs/framework/utils").IdProperty>;
|
|
4
4
|
is_enabled: import("@medusajs/framework/utils").BooleanProperty;
|
|
5
|
-
|
|
5
|
+
is_default: import("@medusajs/framework/utils").BooleanProperty;
|
|
6
6
|
currency_code: import("@medusajs/framework/utils").NullableModifier<string, import("@medusajs/framework/utils").TextProperty>;
|
|
7
7
|
name: import("@medusajs/framework/utils").TextProperty;
|
|
8
8
|
code: import("@medusajs/framework/utils").TextProperty;
|
|
9
9
|
type: import("@medusajs/framework/utils").EnumProperty<typeof CommissionRateType>;
|
|
10
|
-
target: import("@medusajs/framework/utils").EnumProperty<typeof CommissionRateTarget>;
|
|
11
10
|
value: import("@medusajs/framework/utils").BigNumberProperty;
|
|
12
|
-
min_amount: import("@medusajs/framework/utils").NullableModifier<number, import("@medusajs/framework/utils").BigNumberProperty>;
|
|
13
11
|
include_tax: import("@medusajs/framework/utils").BooleanProperty;
|
|
12
|
+
include_shipping: import("@medusajs/framework/utils").BooleanProperty;
|
|
14
13
|
rules: import("@medusajs/framework/utils").HasMany<() => import("@medusajs/framework/utils").DmlEntity<import("@medusajs/framework/utils").DMLEntitySchemaBuilder<{
|
|
15
14
|
id: import("@medusajs/framework/utils").PrimaryKeyModifier<string, import("@medusajs/framework/utils").IdProperty>;
|
|
16
15
|
reference: import("@medusajs/framework/utils").TextProperty;
|
|
17
16
|
reference_id: import("@medusajs/framework/utils").TextProperty;
|
|
18
17
|
commission_rate: import("@medusajs/framework/utils").BelongsTo<() => import("@medusajs/framework/utils").DmlEntity<import("@medusajs/framework/utils").DMLEntitySchemaBuilder</*elided*/ any>, "commission_rate">, undefined>;
|
|
19
18
|
}>, "commission_rule">>;
|
|
19
|
+
values: import("@medusajs/framework/utils").HasMany<() => import("@medusajs/framework/utils").DmlEntity<import("@medusajs/framework/utils").DMLEntitySchemaBuilder<{
|
|
20
|
+
id: import("@medusajs/framework/utils").PrimaryKeyModifier<string, import("@medusajs/framework/utils").IdProperty>;
|
|
21
|
+
currency_code: import("@medusajs/framework/utils").TextProperty;
|
|
22
|
+
amount: import("@medusajs/framework/utils").BigNumberProperty;
|
|
23
|
+
commission_rate: import("@medusajs/framework/utils").BelongsTo<() => import("@medusajs/framework/utils").DmlEntity<import("@medusajs/framework/utils").DMLEntitySchemaBuilder</*elided*/ any>, "commission_rate">, undefined>;
|
|
24
|
+
}>, "commission_rate_value">>;
|
|
20
25
|
}>, "commission_rate">;
|
|
21
26
|
export default CommissionRate;
|
|
@@ -6,21 +6,24 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
6
6
|
const utils_1 = require("@medusajs/framework/utils");
|
|
7
7
|
const types_1 = require("@mercurjs/types");
|
|
8
8
|
const commission_rule_1 = __importDefault(require("./commission-rule"));
|
|
9
|
+
const commission_rate_value_1 = __importDefault(require("./commission-rate-value"));
|
|
9
10
|
const CommissionRate = utils_1.model.define("commission_rate", {
|
|
10
11
|
id: utils_1.model.id({ prefix: "comrate" }).primaryKey(),
|
|
11
12
|
is_enabled: utils_1.model.boolean().default(true),
|
|
12
|
-
|
|
13
|
+
is_default: utils_1.model.boolean().default(false),
|
|
13
14
|
currency_code: utils_1.model.text().nullable(),
|
|
14
|
-
name: utils_1.model.text(),
|
|
15
|
-
code: utils_1.model.text().unique(),
|
|
15
|
+
name: utils_1.model.text().searchable(),
|
|
16
|
+
code: utils_1.model.text().unique().searchable(),
|
|
16
17
|
type: utils_1.model.enum(types_1.CommissionRateType),
|
|
17
|
-
target: utils_1.model.enum(types_1.CommissionRateTarget).default(types_1.CommissionRateTarget.ITEM),
|
|
18
18
|
value: utils_1.model.bigNumber(),
|
|
19
|
-
min_amount: utils_1.model.bigNumber().nullable(),
|
|
20
19
|
include_tax: utils_1.model.boolean().default(false),
|
|
20
|
+
include_shipping: utils_1.model.boolean().default(false),
|
|
21
21
|
rules: utils_1.model.hasMany(() => commission_rule_1.default, {
|
|
22
22
|
mappedBy: "commission_rate",
|
|
23
23
|
}),
|
|
24
|
+
values: utils_1.model.hasMany(() => commission_rate_value_1.default, {
|
|
25
|
+
mappedBy: "commission_rate",
|
|
26
|
+
}),
|
|
24
27
|
});
|
|
25
28
|
exports.default = CommissionRate;
|
|
26
|
-
//# sourceMappingURL=data:application/json;base64,
|
|
29
|
+
//# sourceMappingURL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UFLLENBQUM7SUFDM0MsZ0JBQWdCLEVBQUUsYUFBSyxDQUFDLE9BQU8sRUFBRSxDQUFDLE9BQU8sQ0FBQyxLQUFLLENBQUM7SUFDaEQsS0FBSyxFQUFFLGFBQUssQ0FBQyxPQUFPLENBQUMsR0FBRyxFQUFFLENBQUMseUJBQWMsRUFBRTtRQUN6QyxRQUFRLEVBQUUsaUJBQWlCO0tBQzVCLENBQUM7SUFDRixNQUFNLEVBQUUsYUFBSyxDQUFDLE9BQU8sQ0FBQyxHQUFHLEVBQUUsQ0FBQywrQkFBbUIsRUFBRTtRQUMvQyxRQUFRLEVBQUUsaUJBQWlCO0tBQzVCLENBQUM7Q0FDSCxDQUFDLENBQUE7QUFFRixrQkFBZSxjQUFjLENBQUEifQ==
|
|
@@ -5,16 +5,21 @@ declare const CommissionRule: import("@medusajs/framework/utils").DmlEntity<impo
|
|
|
5
5
|
commission_rate: import("@medusajs/framework/utils").BelongsTo<() => import("@medusajs/framework/utils").DmlEntity<import("@medusajs/framework/utils").DMLEntitySchemaBuilder<{
|
|
6
6
|
id: import("@medusajs/framework/utils").PrimaryKeyModifier<string, import("@medusajs/framework/utils").IdProperty>;
|
|
7
7
|
is_enabled: import("@medusajs/framework/utils").BooleanProperty;
|
|
8
|
-
|
|
8
|
+
is_default: import("@medusajs/framework/utils").BooleanProperty;
|
|
9
9
|
currency_code: import("@medusajs/framework/utils").NullableModifier<string, import("@medusajs/framework/utils").TextProperty>;
|
|
10
10
|
name: import("@medusajs/framework/utils").TextProperty;
|
|
11
11
|
code: import("@medusajs/framework/utils").TextProperty;
|
|
12
12
|
type: import("@medusajs/framework/utils").EnumProperty<typeof import("@mercurjs/types").CommissionRateType>;
|
|
13
|
-
target: import("@medusajs/framework/utils").EnumProperty<typeof import("@mercurjs/types").CommissionRateTarget>;
|
|
14
13
|
value: import("@medusajs/framework/utils").BigNumberProperty;
|
|
15
|
-
min_amount: import("@medusajs/framework/utils").NullableModifier<number, import("@medusajs/framework/utils").BigNumberProperty>;
|
|
16
14
|
include_tax: import("@medusajs/framework/utils").BooleanProperty;
|
|
15
|
+
include_shipping: import("@medusajs/framework/utils").BooleanProperty;
|
|
17
16
|
rules: import("@medusajs/framework/utils").HasMany<() => import("@medusajs/framework/utils").DmlEntity<import("@medusajs/framework/utils").DMLEntitySchemaBuilder</*elided*/ any>, "commission_rule">>;
|
|
17
|
+
values: import("@medusajs/framework/utils").HasMany<() => import("@medusajs/framework/utils").DmlEntity<import("@medusajs/framework/utils").DMLEntitySchemaBuilder<{
|
|
18
|
+
id: import("@medusajs/framework/utils").PrimaryKeyModifier<string, import("@medusajs/framework/utils").IdProperty>;
|
|
19
|
+
currency_code: import("@medusajs/framework/utils").TextProperty;
|
|
20
|
+
amount: import("@medusajs/framework/utils").BigNumberProperty;
|
|
21
|
+
commission_rate: import("@medusajs/framework/utils").BelongsTo<() => import("@medusajs/framework/utils").DmlEntity<import("@medusajs/framework/utils").DMLEntitySchemaBuilder</*elided*/ any>, "commission_rate">, undefined>;
|
|
22
|
+
}>, "commission_rate_value">>;
|
|
18
23
|
}>, "commission_rate">, undefined>;
|
|
19
24
|
}>, "commission_rule">;
|
|
20
25
|
export default CommissionRule;
|
|
@@ -3,11 +3,13 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.CommissionLine = exports.CommissionRule = exports.CommissionRate = void 0;
|
|
6
|
+
exports.CommissionLine = exports.CommissionRateValue = exports.CommissionRule = exports.CommissionRate = void 0;
|
|
7
7
|
var commission_rate_1 = require("./commission-rate");
|
|
8
8
|
Object.defineProperty(exports, "CommissionRate", { enumerable: true, get: function () { return __importDefault(commission_rate_1).default; } });
|
|
9
9
|
var commission_rule_1 = require("./commission-rule");
|
|
10
10
|
Object.defineProperty(exports, "CommissionRule", { enumerable: true, get: function () { return __importDefault(commission_rule_1).default; } });
|
|
11
|
+
var commission_rate_value_1 = require("./commission-rate-value");
|
|
12
|
+
Object.defineProperty(exports, "CommissionRateValue", { enumerable: true, get: function () { return __importDefault(commission_rate_value_1).default; } });
|
|
11
13
|
var commission_line_1 = require("./commission-line");
|
|
12
14
|
Object.defineProperty(exports, "CommissionLine", { enumerable: true, get: function () { return __importDefault(commission_line_1).default; } });
|
|
13
|
-
//# sourceMappingURL=data:application/json;base64,
|
|
15
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi8uLi8uLi8uLi8uLi9zcmMvbW9kdWxlcy9jb21taXNzaW9uL21vZGVscy9pbmRleC50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiOzs7Ozs7QUFBQSxxREFBNkQ7QUFBcEQsa0lBQUEsT0FBTyxPQUFrQjtBQUNsQyxxREFBNkQ7QUFBcEQsa0lBQUEsT0FBTyxPQUFrQjtBQUNsQyxpRUFBd0U7QUFBL0QsNklBQUEsT0FBTyxPQUF1QjtBQUN2QyxxREFBNkQ7QUFBcEQsa0lBQUEsT0FBTyxPQUFrQiJ9
|
|
@@ -1,25 +1,30 @@
|
|
|
1
1
|
import { Context, DAL, InferEntityType, ModulesSdkTypes } from "@medusajs/framework/types";
|
|
2
|
-
import { CommissionCalculationContext, CommissionLineDTO, CommissionRateType,
|
|
2
|
+
import { CommissionCalculationContext, CommissionLineDTO, CommissionRateType, CreateCommissionLineDTO } from "@mercurjs/types";
|
|
3
3
|
import { CommissionLine } from "./models";
|
|
4
4
|
declare const CommissionModuleService_base: import("@medusajs/framework/utils").MedusaServiceReturnType<import("@medusajs/framework/utils").ModelConfigurationsToConfigTemplate<{
|
|
5
5
|
readonly CommissionRate: import("@medusajs/framework/utils").DmlEntity<import("@medusajs/framework/utils").DMLEntitySchemaBuilder<{
|
|
6
6
|
id: import("@medusajs/framework/utils").PrimaryKeyModifier<string, import("@medusajs/framework/utils").IdProperty>;
|
|
7
7
|
is_enabled: import("@medusajs/framework/utils").BooleanProperty;
|
|
8
|
-
|
|
8
|
+
is_default: import("@medusajs/framework/utils").BooleanProperty;
|
|
9
9
|
currency_code: import("@medusajs/framework/utils").NullableModifier<string, import("@medusajs/framework/utils").TextProperty>;
|
|
10
10
|
name: import("@medusajs/framework/utils").TextProperty;
|
|
11
11
|
code: import("@medusajs/framework/utils").TextProperty;
|
|
12
12
|
type: import("@medusajs/framework/utils").EnumProperty<typeof CommissionRateType>;
|
|
13
|
-
target: import("@medusajs/framework/utils").EnumProperty<typeof CommissionRateTarget>;
|
|
14
13
|
value: import("@medusajs/framework/utils").BigNumberProperty;
|
|
15
|
-
min_amount: import("@medusajs/framework/utils").NullableModifier<number, import("@medusajs/framework/utils").BigNumberProperty>;
|
|
16
14
|
include_tax: import("@medusajs/framework/utils").BooleanProperty;
|
|
15
|
+
include_shipping: import("@medusajs/framework/utils").BooleanProperty;
|
|
17
16
|
rules: import("@medusajs/framework/utils").HasMany<() => import("@medusajs/framework/utils").DmlEntity<import("@medusajs/framework/utils").DMLEntitySchemaBuilder<{
|
|
18
17
|
id: import("@medusajs/framework/utils").PrimaryKeyModifier<string, import("@medusajs/framework/utils").IdProperty>;
|
|
19
18
|
reference: import("@medusajs/framework/utils").TextProperty;
|
|
20
19
|
reference_id: import("@medusajs/framework/utils").TextProperty;
|
|
21
20
|
commission_rate: import("@medusajs/framework/utils").BelongsTo<() => import("@medusajs/framework/utils").DmlEntity<import("@medusajs/framework/utils").DMLEntitySchemaBuilder</*elided*/ any>, "commission_rate">, undefined>;
|
|
22
21
|
}>, "commission_rule">>;
|
|
22
|
+
values: import("@medusajs/framework/utils").HasMany<() => import("@medusajs/framework/utils").DmlEntity<import("@medusajs/framework/utils").DMLEntitySchemaBuilder<{
|
|
23
|
+
id: import("@medusajs/framework/utils").PrimaryKeyModifier<string, import("@medusajs/framework/utils").IdProperty>;
|
|
24
|
+
currency_code: import("@medusajs/framework/utils").TextProperty;
|
|
25
|
+
amount: import("@medusajs/framework/utils").BigNumberProperty;
|
|
26
|
+
commission_rate: import("@medusajs/framework/utils").BelongsTo<() => import("@medusajs/framework/utils").DmlEntity<import("@medusajs/framework/utils").DMLEntitySchemaBuilder</*elided*/ any>, "commission_rate">, undefined>;
|
|
27
|
+
}>, "commission_rate_value">>;
|
|
23
28
|
}>, "commission_rate">;
|
|
24
29
|
readonly CommissionRule: import("@medusajs/framework/utils").DmlEntity<import("@medusajs/framework/utils").DMLEntitySchemaBuilder<{
|
|
25
30
|
id: import("@medusajs/framework/utils").PrimaryKeyModifier<string, import("@medusajs/framework/utils").IdProperty>;
|
|
@@ -28,21 +33,51 @@ declare const CommissionModuleService_base: import("@medusajs/framework/utils").
|
|
|
28
33
|
commission_rate: import("@medusajs/framework/utils").BelongsTo<() => import("@medusajs/framework/utils").DmlEntity<import("@medusajs/framework/utils").DMLEntitySchemaBuilder<{
|
|
29
34
|
id: import("@medusajs/framework/utils").PrimaryKeyModifier<string, import("@medusajs/framework/utils").IdProperty>;
|
|
30
35
|
is_enabled: import("@medusajs/framework/utils").BooleanProperty;
|
|
31
|
-
|
|
36
|
+
is_default: import("@medusajs/framework/utils").BooleanProperty;
|
|
32
37
|
currency_code: import("@medusajs/framework/utils").NullableModifier<string, import("@medusajs/framework/utils").TextProperty>;
|
|
33
38
|
name: import("@medusajs/framework/utils").TextProperty;
|
|
34
39
|
code: import("@medusajs/framework/utils").TextProperty;
|
|
35
40
|
type: import("@medusajs/framework/utils").EnumProperty<typeof CommissionRateType>;
|
|
36
|
-
target: import("@medusajs/framework/utils").EnumProperty<typeof CommissionRateTarget>;
|
|
37
41
|
value: import("@medusajs/framework/utils").BigNumberProperty;
|
|
38
|
-
min_amount: import("@medusajs/framework/utils").NullableModifier<number, import("@medusajs/framework/utils").BigNumberProperty>;
|
|
39
42
|
include_tax: import("@medusajs/framework/utils").BooleanProperty;
|
|
43
|
+
include_shipping: import("@medusajs/framework/utils").BooleanProperty;
|
|
40
44
|
rules: import("@medusajs/framework/utils").HasMany<() => import("@medusajs/framework/utils").DmlEntity<import("@medusajs/framework/utils").DMLEntitySchemaBuilder</*elided*/ any>, "commission_rule">>;
|
|
45
|
+
values: import("@medusajs/framework/utils").HasMany<() => import("@medusajs/framework/utils").DmlEntity<import("@medusajs/framework/utils").DMLEntitySchemaBuilder<{
|
|
46
|
+
id: import("@medusajs/framework/utils").PrimaryKeyModifier<string, import("@medusajs/framework/utils").IdProperty>;
|
|
47
|
+
currency_code: import("@medusajs/framework/utils").TextProperty;
|
|
48
|
+
amount: import("@medusajs/framework/utils").BigNumberProperty;
|
|
49
|
+
commission_rate: import("@medusajs/framework/utils").BelongsTo<() => import("@medusajs/framework/utils").DmlEntity<import("@medusajs/framework/utils").DMLEntitySchemaBuilder</*elided*/ any>, "commission_rate">, undefined>;
|
|
50
|
+
}>, "commission_rate_value">>;
|
|
41
51
|
}>, "commission_rate">, undefined>;
|
|
42
52
|
}>, "commission_rule">;
|
|
53
|
+
readonly CommissionRateValue: import("@medusajs/framework/utils").DmlEntity<import("@medusajs/framework/utils").DMLEntitySchemaBuilder<{
|
|
54
|
+
id: import("@medusajs/framework/utils").PrimaryKeyModifier<string, import("@medusajs/framework/utils").IdProperty>;
|
|
55
|
+
currency_code: import("@medusajs/framework/utils").TextProperty;
|
|
56
|
+
amount: import("@medusajs/framework/utils").BigNumberProperty;
|
|
57
|
+
commission_rate: import("@medusajs/framework/utils").BelongsTo<() => import("@medusajs/framework/utils").DmlEntity<import("@medusajs/framework/utils").DMLEntitySchemaBuilder<{
|
|
58
|
+
id: import("@medusajs/framework/utils").PrimaryKeyModifier<string, import("@medusajs/framework/utils").IdProperty>;
|
|
59
|
+
is_enabled: import("@medusajs/framework/utils").BooleanProperty;
|
|
60
|
+
is_default: import("@medusajs/framework/utils").BooleanProperty;
|
|
61
|
+
currency_code: import("@medusajs/framework/utils").NullableModifier<string, import("@medusajs/framework/utils").TextProperty>;
|
|
62
|
+
name: import("@medusajs/framework/utils").TextProperty;
|
|
63
|
+
code: import("@medusajs/framework/utils").TextProperty;
|
|
64
|
+
type: import("@medusajs/framework/utils").EnumProperty<typeof CommissionRateType>;
|
|
65
|
+
value: import("@medusajs/framework/utils").BigNumberProperty;
|
|
66
|
+
include_tax: import("@medusajs/framework/utils").BooleanProperty;
|
|
67
|
+
include_shipping: import("@medusajs/framework/utils").BooleanProperty;
|
|
68
|
+
rules: import("@medusajs/framework/utils").HasMany<() => import("@medusajs/framework/utils").DmlEntity<import("@medusajs/framework/utils").DMLEntitySchemaBuilder<{
|
|
69
|
+
id: import("@medusajs/framework/utils").PrimaryKeyModifier<string, import("@medusajs/framework/utils").IdProperty>;
|
|
70
|
+
reference: import("@medusajs/framework/utils").TextProperty;
|
|
71
|
+
reference_id: import("@medusajs/framework/utils").TextProperty;
|
|
72
|
+
commission_rate: import("@medusajs/framework/utils").BelongsTo<() => import("@medusajs/framework/utils").DmlEntity<import("@medusajs/framework/utils").DMLEntitySchemaBuilder</*elided*/ any>, "commission_rate">, undefined>;
|
|
73
|
+
}>, "commission_rule">>;
|
|
74
|
+
values: import("@medusajs/framework/utils").HasMany<() => import("@medusajs/framework/utils").DmlEntity<import("@medusajs/framework/utils").DMLEntitySchemaBuilder</*elided*/ any>, "commission_rate_value">>;
|
|
75
|
+
}>, "commission_rate">, undefined>;
|
|
76
|
+
}>, "commission_rate_value">;
|
|
43
77
|
readonly CommissionLine: import("@medusajs/framework/utils").DmlEntity<import("@medusajs/framework/utils").DMLEntitySchemaBuilder<{
|
|
44
78
|
id: import("@medusajs/framework/utils").PrimaryKeyModifier<string, import("@medusajs/framework/utils").IdProperty>;
|
|
45
|
-
item_id: import("@medusajs/framework/utils").TextProperty
|
|
79
|
+
item_id: import("@medusajs/framework/utils").NullableModifier<string, import("@medusajs/framework/utils").TextProperty>;
|
|
80
|
+
shipping_method_id: import("@medusajs/framework/utils").NullableModifier<string, import("@medusajs/framework/utils").TextProperty>;
|
|
46
81
|
commission_rate_id: import("@medusajs/framework/utils").NullableModifier<string, import("@medusajs/framework/utils").TextProperty>;
|
|
47
82
|
code: import("@medusajs/framework/utils").TextProperty;
|
|
48
83
|
rate: import("@medusajs/framework/utils").FloatProperty;
|
|
@@ -57,7 +92,37 @@ declare class CommissionModuleService extends CommissionModuleService_base {
|
|
|
57
92
|
commissionLineService: any;
|
|
58
93
|
baseRepository: any;
|
|
59
94
|
});
|
|
95
|
+
/**
|
|
96
|
+
* Does a single rule match a product?
|
|
97
|
+
*/
|
|
98
|
+
private ruleMatchesProduct;
|
|
99
|
+
/**
|
|
100
|
+
* A rate matches an item when **every** present dimension group (rules
|
|
101
|
+
* grouped by `reference`) has at least one matching rule
|
|
102
|
+
* (AND-across-dimension, OR-within-dimension). A rule-less rate is the
|
|
103
|
+
* default and matches everything.
|
|
104
|
+
*/
|
|
105
|
+
private rateMatchesItem;
|
|
106
|
+
/**
|
|
107
|
+
* Specificity = number of distinct dimension groups a rate scopes on.
|
|
108
|
+
* More dimensions → higher specificity → wins the tie-break.
|
|
109
|
+
*/
|
|
110
|
+
private rateSpecificity;
|
|
111
|
+
/**
|
|
112
|
+
* Resolve the commission amount + line `rate` for a base amount.
|
|
113
|
+
* Percentage uses the scalar `value`; Fixed reads the per-currency
|
|
114
|
+
* `values` (falling back to the legacy single `value`).
|
|
115
|
+
*/
|
|
116
|
+
private computeCommission;
|
|
60
117
|
getCommissionLines(context: CommissionCalculationContext, sharedContext?: Context): Promise<CreateCommissionLineDTO[]>;
|
|
61
|
-
|
|
118
|
+
/**
|
|
119
|
+
* Overrides the auto-generated upsert with idempotent **replace**
|
|
120
|
+
* semantics keyed on the line's anchor (item_id / shipping_method_id):
|
|
121
|
+
* delete any existing lines for the incoming anchors, then insert the new
|
|
122
|
+
* set, in a single transaction. The computed lines carry no `id`, so a
|
|
123
|
+
* plain primary-key upsert would duplicate them on every refresh; deleting
|
|
124
|
+
* by anchor first makes re-running the refresh idempotent.
|
|
125
|
+
*/
|
|
126
|
+
upsertCommissionLines(commissionLines: CreateCommissionLineDTO[], sharedContext?: Context): Promise<CommissionLineDTO[]>;
|
|
62
127
|
}
|
|
63
128
|
export default CommissionModuleService;
|
|
@@ -18,6 +18,7 @@ const models_1 = require("./models");
|
|
|
18
18
|
class CommissionModuleService extends (0, utils_1.MedusaService)({
|
|
19
19
|
CommissionRate: models_1.CommissionRate,
|
|
20
20
|
CommissionRule: models_1.CommissionRule,
|
|
21
|
+
CommissionRateValue: models_1.CommissionRateValue,
|
|
21
22
|
CommissionLine: models_1.CommissionLine,
|
|
22
23
|
}) {
|
|
23
24
|
constructor({ commissionLineService, baseRepository }) {
|
|
@@ -25,142 +26,174 @@ class CommissionModuleService extends (0, utils_1.MedusaService)({
|
|
|
25
26
|
this.commissionLineService_ = commissionLineService;
|
|
26
27
|
this.baseRepository_ = baseRepository;
|
|
27
28
|
}
|
|
29
|
+
/**
|
|
30
|
+
* Does a single rule match a product?
|
|
31
|
+
*/
|
|
32
|
+
ruleMatchesProduct(rule, product) {
|
|
33
|
+
if (!product) {
|
|
34
|
+
return false;
|
|
35
|
+
}
|
|
36
|
+
switch (rule.reference) {
|
|
37
|
+
case "product":
|
|
38
|
+
return product.id === rule.reference_id;
|
|
39
|
+
case "product_type":
|
|
40
|
+
return product.type_id === rule.reference_id;
|
|
41
|
+
case "product_collection":
|
|
42
|
+
return product.collection_id === rule.reference_id;
|
|
43
|
+
case "product_category":
|
|
44
|
+
return (product.categories?.some((cat) => cat.id === rule.reference_id) ??
|
|
45
|
+
false);
|
|
46
|
+
case "seller":
|
|
47
|
+
return product.seller?.id === rule.reference_id;
|
|
48
|
+
default:
|
|
49
|
+
return false;
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* A rate matches an item when **every** present dimension group (rules
|
|
54
|
+
* grouped by `reference`) has at least one matching rule
|
|
55
|
+
* (AND-across-dimension, OR-within-dimension). A rule-less rate is the
|
|
56
|
+
* default and matches everything.
|
|
57
|
+
*/
|
|
58
|
+
rateMatchesItem(rate, item) {
|
|
59
|
+
const rules = (rate.rules ?? []);
|
|
60
|
+
if (rules.length === 0) {
|
|
61
|
+
return true;
|
|
62
|
+
}
|
|
63
|
+
const groups = new Map();
|
|
64
|
+
for (const rule of rules) {
|
|
65
|
+
const bucket = groups.get(rule.reference) ?? [];
|
|
66
|
+
bucket.push(rule);
|
|
67
|
+
groups.set(rule.reference, bucket);
|
|
68
|
+
}
|
|
69
|
+
for (const groupRules of groups.values()) {
|
|
70
|
+
if (!groupRules.some((rule) => this.ruleMatchesProduct(rule, item.product))) {
|
|
71
|
+
return false;
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
return true;
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* Specificity = number of distinct dimension groups a rate scopes on.
|
|
78
|
+
* More dimensions → higher specificity → wins the tie-break.
|
|
79
|
+
*/
|
|
80
|
+
rateSpecificity(rate) {
|
|
81
|
+
return new Set((rate.rules ?? []).map((rule) => rule.reference)).size;
|
|
82
|
+
}
|
|
83
|
+
/**
|
|
84
|
+
* Resolve the commission amount + line `rate` for a base amount.
|
|
85
|
+
* Percentage uses the scalar `value`; Fixed reads the per-currency
|
|
86
|
+
* `values` (falling back to the legacy single `value`).
|
|
87
|
+
*/
|
|
88
|
+
computeCommission(rate, baseAmount, currencyCode) {
|
|
89
|
+
if (rate.type === types_1.CommissionRateType.PERCENTAGE) {
|
|
90
|
+
const amount = utils_1.MathBN.div(utils_1.MathBN.mult(baseAmount, rate.value), 100);
|
|
91
|
+
return {
|
|
92
|
+
rate: utils_1.MathBN.convert(rate.value).toNumber(),
|
|
93
|
+
amount: utils_1.MathBN.convert(amount).toNumber(),
|
|
94
|
+
};
|
|
95
|
+
}
|
|
96
|
+
const perCurrency = (rate.values ?? []).find((value) => value.currency_code === currencyCode);
|
|
97
|
+
const fixed = perCurrency ? perCurrency.amount : rate.value;
|
|
98
|
+
return {
|
|
99
|
+
rate: utils_1.MathBN.convert(fixed).toNumber(),
|
|
100
|
+
amount: utils_1.MathBN.convert(fixed).toNumber(),
|
|
101
|
+
};
|
|
102
|
+
}
|
|
28
103
|
async getCommissionLines(context, sharedContext = {}) {
|
|
29
104
|
const commissionLines = [];
|
|
30
105
|
const { items = [], shipping_methods = [], currency_code } = context;
|
|
31
|
-
//
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
106
|
+
// Load all enabled rates with their rules + per-currency values,
|
|
107
|
+
// oldest first (created_at ASC) so it is the deterministic tie-break.
|
|
108
|
+
const commissionRates = (await this.listCommissionRates({ is_enabled: true }, { relations: ["rules", "values"], order: { created_at: "ASC" } }, sharedContext));
|
|
109
|
+
// Legacy single-currency rates only apply to their currency; rates
|
|
110
|
+
// without a currency_code apply to any currency.
|
|
111
|
+
const applicableRates = commissionRates.filter((rate) => !rate.currency_code || rate.currency_code === currency_code);
|
|
112
|
+
// The Global Commission: the is_default rate (fallback: any rule-less rate).
|
|
113
|
+
const defaultRate = applicableRates.find((rate) => rate.is_default) ??
|
|
114
|
+
applicableRates.find((rate) => (rate.rules ?? []).length === 0);
|
|
115
|
+
// Item lines — match per item, most-specific rate wins.
|
|
37
116
|
for (const item of items) {
|
|
38
|
-
const
|
|
39
|
-
|
|
40
|
-
// Find matching rate based on rules (priority order)
|
|
41
|
-
for (const rate of itemRates) {
|
|
42
|
-
// Check currency code match if specified
|
|
43
|
-
if (rate.currency_code && rate.currency_code !== currency_code) {
|
|
44
|
-
continue;
|
|
45
|
-
}
|
|
46
|
-
// If no rules, this is a default rate
|
|
47
|
-
if (!rate.rules || rate.rules.length === 0) {
|
|
48
|
-
matchedRate = rate;
|
|
49
|
-
break;
|
|
50
|
-
}
|
|
51
|
-
// Check if any rule matches
|
|
52
|
-
const ruleMatches = rate.rules.some((rule) => {
|
|
53
|
-
if (!product)
|
|
54
|
-
return false;
|
|
55
|
-
switch (rule.reference) {
|
|
56
|
-
case "product":
|
|
57
|
-
return product.id === rule.reference_id;
|
|
58
|
-
case "product_type":
|
|
59
|
-
return product.type_id === rule.reference_id;
|
|
60
|
-
case "product_collection":
|
|
61
|
-
return product.collection_id === rule.reference_id;
|
|
62
|
-
case "product_category":
|
|
63
|
-
return product.categories?.some((cat) => cat.id === rule.reference_id) ?? false;
|
|
64
|
-
case "seller":
|
|
65
|
-
return product.seller?.id === rule.reference_id;
|
|
66
|
-
default:
|
|
67
|
-
return false;
|
|
68
|
-
}
|
|
69
|
-
});
|
|
70
|
-
if (ruleMatches) {
|
|
71
|
-
matchedRate = rate;
|
|
72
|
-
break;
|
|
73
|
-
}
|
|
74
|
-
}
|
|
75
|
-
if (!matchedRate) {
|
|
117
|
+
const candidates = applicableRates.filter((rate) => this.rateMatchesItem(rate, item));
|
|
118
|
+
if (!candidates.length) {
|
|
76
119
|
continue;
|
|
77
120
|
}
|
|
78
|
-
|
|
121
|
+
candidates.sort((a, b) => {
|
|
122
|
+
const specificityDiff = this.rateSpecificity(b) - this.rateSpecificity(a);
|
|
123
|
+
if (specificityDiff !== 0) {
|
|
124
|
+
return specificityDiff;
|
|
125
|
+
}
|
|
126
|
+
return (new Date(a.created_at).getTime() - new Date(b.created_at).getTime());
|
|
127
|
+
});
|
|
128
|
+
const matchedRate = candidates[0];
|
|
79
129
|
let baseAmount = item.subtotal;
|
|
80
130
|
if (matchedRate.include_tax && item.tax_total) {
|
|
81
131
|
baseAmount = utils_1.MathBN.add(item.subtotal, item.tax_total);
|
|
82
132
|
}
|
|
83
|
-
|
|
84
|
-
let amount;
|
|
85
|
-
if (matchedRate.type === types_1.CommissionRateType.PERCENTAGE) {
|
|
86
|
-
amount = utils_1.MathBN.div(utils_1.MathBN.mult(baseAmount, matchedRate.value), 100);
|
|
87
|
-
}
|
|
88
|
-
else {
|
|
89
|
-
amount = matchedRate.value;
|
|
90
|
-
}
|
|
91
|
-
// Apply minimum commission if set
|
|
92
|
-
if (matchedRate.min_amount !== null && utils_1.MathBN.lt(amount, matchedRate.min_amount)) {
|
|
93
|
-
amount = matchedRate.min_amount;
|
|
94
|
-
}
|
|
133
|
+
const { rate, amount } = this.computeCommission(matchedRate, baseAmount, currency_code);
|
|
95
134
|
commissionLines.push({
|
|
96
135
|
item_id: item.id,
|
|
136
|
+
shipping_method_id: null,
|
|
97
137
|
code: matchedRate.code,
|
|
98
|
-
rate
|
|
99
|
-
amount
|
|
138
|
+
rate,
|
|
139
|
+
amount,
|
|
100
140
|
commission_rate_id: matchedRate.id,
|
|
101
141
|
});
|
|
102
142
|
}
|
|
103
|
-
//
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
// If no rules, this is a default rate
|
|
112
|
-
if (!rate.rules || rate.rules.length === 0) {
|
|
113
|
-
matchedRate = rate;
|
|
114
|
-
break;
|
|
143
|
+
// Shipping lines — one per shipping method, governed by the global
|
|
144
|
+
// rate, only when its include_shipping is on (resolved independently
|
|
145
|
+
// of the items the method ships).
|
|
146
|
+
if (defaultRate?.include_shipping) {
|
|
147
|
+
for (const shippingMethod of shipping_methods) {
|
|
148
|
+
let baseAmount = shippingMethod.subtotal;
|
|
149
|
+
if (defaultRate.include_tax && shippingMethod.tax_total) {
|
|
150
|
+
baseAmount = utils_1.MathBN.add(shippingMethod.subtotal, shippingMethod.tax_total);
|
|
115
151
|
}
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
}
|
|
152
|
+
const { rate, amount } = this.computeCommission(defaultRate, baseAmount, currency_code);
|
|
153
|
+
commissionLines.push({
|
|
154
|
+
item_id: null,
|
|
155
|
+
shipping_method_id: shippingMethod.id,
|
|
156
|
+
code: defaultRate.code,
|
|
157
|
+
rate,
|
|
158
|
+
amount,
|
|
159
|
+
commission_rate_id: defaultRate.id,
|
|
160
|
+
description: "Shipping Commission",
|
|
126
161
|
});
|
|
127
|
-
if (ruleMatches) {
|
|
128
|
-
matchedRate = rate;
|
|
129
|
-
break;
|
|
130
|
-
}
|
|
131
|
-
}
|
|
132
|
-
if (!matchedRate) {
|
|
133
|
-
continue;
|
|
134
|
-
}
|
|
135
|
-
// Calculate base amount (include tax if specified)
|
|
136
|
-
let baseAmount = shippingMethod.subtotal;
|
|
137
|
-
if (matchedRate.include_tax && shippingMethod.tax_total) {
|
|
138
|
-
baseAmount = utils_1.MathBN.add(shippingMethod.subtotal, shippingMethod.tax_total);
|
|
139
|
-
}
|
|
140
|
-
// Calculate commission amount using MathBN
|
|
141
|
-
let amount;
|
|
142
|
-
if (matchedRate.type === types_1.CommissionRateType.PERCENTAGE) {
|
|
143
|
-
amount = utils_1.MathBN.div(utils_1.MathBN.mult(baseAmount, matchedRate.value), 100);
|
|
144
|
-
}
|
|
145
|
-
else {
|
|
146
|
-
amount = matchedRate.value;
|
|
147
|
-
}
|
|
148
|
-
// Apply minimum commission if set
|
|
149
|
-
if (matchedRate.min_amount !== null && utils_1.MathBN.lt(amount, matchedRate.min_amount)) {
|
|
150
|
-
amount = matchedRate.min_amount;
|
|
151
162
|
}
|
|
152
|
-
commissionLines.push({
|
|
153
|
-
item_id: shippingMethod.id,
|
|
154
|
-
code: matchedRate.code,
|
|
155
|
-
rate: matchedRate.value,
|
|
156
|
-
commission_rate_id: matchedRate.id,
|
|
157
|
-
description: `Shipping Commission`,
|
|
158
|
-
amount: utils_1.MathBN.convert(amount).toNumber(),
|
|
159
|
-
});
|
|
160
163
|
}
|
|
161
164
|
return commissionLines;
|
|
162
165
|
}
|
|
166
|
+
/**
|
|
167
|
+
* Overrides the auto-generated upsert with idempotent **replace**
|
|
168
|
+
* semantics keyed on the line's anchor (item_id / shipping_method_id):
|
|
169
|
+
* delete any existing lines for the incoming anchors, then insert the new
|
|
170
|
+
* set, in a single transaction. The computed lines carry no `id`, so a
|
|
171
|
+
* plain primary-key upsert would duplicate them on every refresh; deleting
|
|
172
|
+
* by anchor first makes re-running the refresh idempotent.
|
|
173
|
+
*/
|
|
163
174
|
async upsertCommissionLines(commissionLines, sharedContext = {}) {
|
|
175
|
+
const itemIds = commissionLines
|
|
176
|
+
.map((line) => line.item_id)
|
|
177
|
+
.filter((id) => !!id);
|
|
178
|
+
const shippingMethodIds = commissionLines
|
|
179
|
+
.map((line) => line.shipping_method_id)
|
|
180
|
+
.filter((id) => !!id);
|
|
181
|
+
const filters = [];
|
|
182
|
+
if (itemIds.length) {
|
|
183
|
+
filters.push({ item_id: itemIds });
|
|
184
|
+
}
|
|
185
|
+
if (shippingMethodIds.length) {
|
|
186
|
+
filters.push({ shipping_method_id: shippingMethodIds });
|
|
187
|
+
}
|
|
188
|
+
if (filters.length) {
|
|
189
|
+
const existing = await this.commissionLineService_.list({ $or: filters }, {}, sharedContext);
|
|
190
|
+
if (existing.length) {
|
|
191
|
+
await this.commissionLineService_.delete(existing.map((line) => line.id), sharedContext);
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
if (!commissionLines.length) {
|
|
195
|
+
return [];
|
|
196
|
+
}
|
|
164
197
|
const result = await this.commissionLineService_.upsert(commissionLines, sharedContext);
|
|
165
198
|
return await this.baseRepository_.serialize(result);
|
|
166
199
|
}
|
|
@@ -181,4 +214,4 @@ __decorate([
|
|
|
181
214
|
__metadata("design:returntype", Promise)
|
|
182
215
|
], CommissionModuleService.prototype, "upsertCommissionLines", null);
|
|
183
216
|
exports.default = CommissionModuleService;
|
|
184
|
-
//# sourceMappingURL=data:application/json;base64,
|
|
217
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic2VydmljZS5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uLy4uLy4uLy4uL3NyYy9tb2R1bGVzL2NvbW1pc3Npb24vc2VydmljZS50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiOzs7Ozs7Ozs7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FBQztRQUVELE1BQU0sTUFBTSxHQUFHLE1BQU0sSUFBSSxDQUFDLHNCQUFzQixDQUFDLE1BQU0sQ0FDckQsZUFBZSxFQUNmLGFBQWEsQ0FDZCxDQUFBO1FBRUQsT0FBTyxNQUFNLElBQUksQ0FBQyxlQUFlLENBQUMsU0FBUyxDQUFzQixNQUFNLENBQUMsQ0FBQTtJQUMxRSxDQUFDO0NBQ0Y7QUE3Sk87SUFETCxJQUFBLHFCQUFhLEdBQUU7SUFHYixXQUFBLElBQUEscUJBQWEsR0FBRSxDQUFBOzs7O2lFQW1HakI7QUFZSztJQUZMLElBQUEscUJBQWEsR0FBRTtJQUNmLElBQUEsa0JBQVUsR0FBRTtJQUdWLFdBQUEsSUFBQSxxQkFBYSxHQUFFLENBQUE7Ozs7b0VBeUNqQjtBQUdILGtCQUFlLHVCQUF1QixDQUFBIn0=
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Migration20260616120000 = void 0;
|
|
4
|
+
const migrations_1 = require("@medusajs/framework/mikro-orm/migrations");
|
|
5
|
+
class Migration20260616120000 extends migrations_1.Migration {
|
|
6
|
+
async up() {
|
|
7
|
+
this.addSql(`alter table if exists "payment_details" alter column "country_code" drop not null;`);
|
|
8
|
+
this.addSql(`alter table if exists "payment_details" alter column "holder_name" drop not null;`);
|
|
9
|
+
}
|
|
10
|
+
async down() {
|
|
11
|
+
this.addSql(`alter table if exists "payment_details" alter column "country_code" set not null;`);
|
|
12
|
+
this.addSql(`alter table if exists "payment_details" alter column "holder_name" set not null;`);
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
exports.Migration20260616120000 = Migration20260616120000;
|
|
16
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiTWlncmF0aW9uMjAyNjA2MTYxMjAwMDAuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi8uLi8uLi8uLi8uLi9zcmMvbW9kdWxlcy9zZWxsZXIvbWlncmF0aW9ucy9NaWdyYXRpb24yMDI2MDYxNjEyMDAwMC50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiOzs7QUFBQSx5RUFBcUU7QUFFckUsTUFBYSx1QkFBd0IsU0FBUSxzQkFBUztJQUMzQyxLQUFLLENBQUMsRUFBRTtRQUNmLElBQUksQ0FBQyxNQUFNLENBQUMsb0ZBQW9GLENBQUMsQ0FBQztRQUNsRyxJQUFJLENBQUMsTUFBTSxDQUFDLG1GQUFtRixDQUFDLENBQUM7SUFDbkcsQ0FBQztJQUVRLEtBQUssQ0FBQyxJQUFJO1FBQ2pCLElBQUksQ0FBQyxNQUFNLENBQUMsbUZBQW1GLENBQUMsQ0FBQztRQUNqRyxJQUFJLENBQUMsTUFBTSxDQUFDLGtGQUFrRixDQUFDLENBQUM7SUFDbEcsQ0FBQztDQUNGO0FBVkQsMERBVUMifQ==
|