@medusajs/order 0.1.3-preview-20240618060531 → 0.1.3-preview-20240618120636

Sign up to get free protection for your applications and to get access to all the features.
Files changed (80) hide show
  1. package/dist/migrations/Migration20240604100512.js +58 -28
  2. package/dist/migrations/Migration20240604100512.js.map +1 -1
  3. package/dist/models/claim-item-image.js +4 -2
  4. package/dist/models/claim-item-image.js.map +1 -1
  5. package/dist/models/claim-item.d.ts +6 -2
  6. package/dist/models/claim-item.js +33 -4
  7. package/dist/models/claim-item.js.map +1 -1
  8. package/dist/models/claim.d.ts +3 -2
  9. package/dist/models/claim.js +14 -7
  10. package/dist/models/claim.js.map +1 -1
  11. package/dist/models/exchange-item.d.ts +23 -0
  12. package/dist/models/exchange-item.js +138 -0
  13. package/dist/models/exchange-item.js.map +1 -0
  14. package/dist/models/exchange.d.ts +3 -4
  15. package/dist/models/exchange.js +13 -16
  16. package/dist/models/exchange.js.map +1 -1
  17. package/dist/models/index.d.ts +4 -2
  18. package/dist/models/index.js +7 -3
  19. package/dist/models/index.js.map +1 -1
  20. package/dist/models/order-change-action.d.ts +6 -0
  21. package/dist/models/order-change-action.js +56 -0
  22. package/dist/models/order-change-action.js.map +1 -1
  23. package/dist/models/order-change.d.ts +6 -0
  24. package/dist/models/order-change.js +54 -0
  25. package/dist/models/order-change.js.map +1 -1
  26. package/dist/models/order-item.d.ts +0 -9
  27. package/dist/models/order-item.js +0 -76
  28. package/dist/models/order-item.js.map +1 -1
  29. package/dist/models/order-shipping-method.js +2 -0
  30. package/dist/models/order-shipping-method.js.map +1 -1
  31. package/dist/models/return-item.d.ts +28 -0
  32. package/dist/models/return-item.js +170 -0
  33. package/dist/models/return-item.js.map +1 -0
  34. package/dist/models/return.d.ts +2 -0
  35. package/dist/models/return.js +9 -2
  36. package/dist/models/return.js.map +1 -1
  37. package/dist/models/transaction.js +6 -0
  38. package/dist/models/transaction.js.map +1 -1
  39. package/dist/repositories/claim.d.ts +8 -0
  40. package/dist/repositories/claim.js +11 -0
  41. package/dist/repositories/claim.js.map +1 -0
  42. package/dist/repositories/exchange.d.ts +8 -0
  43. package/dist/repositories/exchange.js +11 -0
  44. package/dist/repositories/exchange.js.map +1 -0
  45. package/dist/repositories/index.d.ts +1 -0
  46. package/dist/repositories/index.js +3 -1
  47. package/dist/repositories/index.js.map +1 -1
  48. package/dist/services/actions/create-claim.d.ts +2 -0
  49. package/dist/services/actions/create-claim.js +229 -0
  50. package/dist/services/actions/create-claim.js.map +1 -0
  51. package/dist/services/actions/create-exchange.d.ts +2 -0
  52. package/dist/services/actions/create-exchange.js +194 -0
  53. package/dist/services/actions/create-exchange.js.map +1 -0
  54. package/dist/services/actions/create-return.js +55 -34
  55. package/dist/services/actions/create-return.js.map +1 -1
  56. package/dist/services/actions/index.d.ts +2 -0
  57. package/dist/services/actions/index.js +2 -0
  58. package/dist/services/actions/index.js.map +1 -1
  59. package/dist/services/actions/receive-return.js +52 -31
  60. package/dist/services/actions/receive-return.js.map +1 -1
  61. package/dist/services/order-module-service.d.ts +38 -13
  62. package/dist/services/order-module-service.js +220 -10
  63. package/dist/services/order-module-service.js.map +1 -1
  64. package/dist/utils/actions/index.d.ts +1 -0
  65. package/dist/utils/actions/index.js +1 -0
  66. package/dist/utils/actions/index.js.map +1 -1
  67. package/dist/utils/actions/item-add.js +4 -7
  68. package/dist/utils/actions/item-add.js.map +1 -1
  69. package/dist/utils/actions/item-remove.js +4 -4
  70. package/dist/utils/actions/item-remove.js.map +1 -1
  71. package/dist/utils/apply-order-changes.js +14 -13
  72. package/dist/utils/apply-order-changes.js.map +1 -1
  73. package/dist/utils/base-repository-find.js +30 -33
  74. package/dist/utils/base-repository-find.js.map +1 -1
  75. package/dist/utils/calculate-order-change.js +5 -1
  76. package/dist/utils/calculate-order-change.js.map +1 -1
  77. package/dist/utils/transform-order.d.ts +3 -2
  78. package/dist/utils/transform-order.js +84 -17
  79. package/dist/utils/transform-order.js.map +1 -1
  80. package/package.json +5 -5
@@ -0,0 +1,170 @@
1
+ "use strict";
2
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
3
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
5
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
6
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
7
+ };
8
+ var __metadata = (this && this.__metadata) || function (k, v) {
9
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
10
+ };
11
+ var __importDefault = (this && this.__importDefault) || function (mod) {
12
+ return (mod && mod.__esModule) ? mod : { "default": mod };
13
+ };
14
+ Object.defineProperty(exports, "__esModule", { value: true });
15
+ const utils_1 = require("@medusajs/utils");
16
+ const core_1 = require("@mikro-orm/core");
17
+ const line_item_1 = __importDefault(require("./line-item"));
18
+ const return_1 = __importDefault(require("./return"));
19
+ const return_reason_1 = __importDefault(require("./return-reason"));
20
+ const ReturnIdIndex = (0, utils_1.createPsqlIndexStatementHelper)({
21
+ tableName: "return_item",
22
+ columns: "return_id",
23
+ where: "deleted_at IS NOT NULL",
24
+ });
25
+ const ReturnReasonIdIndex = (0, utils_1.createPsqlIndexStatementHelper)({
26
+ tableName: "return_item",
27
+ columns: "reason_id",
28
+ where: "deleted_at IS NOT NULL",
29
+ });
30
+ const ItemIdIndex = (0, utils_1.createPsqlIndexStatementHelper)({
31
+ tableName: "return_item",
32
+ columns: "item_id",
33
+ where: "deleted_at IS NOT NULL",
34
+ });
35
+ const DeletedAtIndex = (0, utils_1.createPsqlIndexStatementHelper)({
36
+ tableName: "order_claim_item_image",
37
+ columns: "deleted_at",
38
+ where: "deleted_at IS NOT NULL",
39
+ });
40
+ let ReturnItem = class ReturnItem {
41
+ constructor() {
42
+ this.reason_id = null;
43
+ this.received_quantity = 0;
44
+ this.metadata = null;
45
+ this.deleted_at = null;
46
+ }
47
+ onCreate() {
48
+ this.id = (0, utils_1.generateEntityId)(this.id, "retitem");
49
+ this.return_id = this.return?.id;
50
+ }
51
+ onInit() {
52
+ this.id = (0, utils_1.generateEntityId)(this.id, "retitem");
53
+ this.return_id = this.return?.id;
54
+ }
55
+ };
56
+ __decorate([
57
+ (0, core_1.PrimaryKey)({ columnType: "text" }),
58
+ __metadata("design:type", String)
59
+ ], ReturnItem.prototype, "id", void 0);
60
+ __decorate([
61
+ (0, core_1.ManyToOne)(() => return_reason_1.default, {
62
+ columnType: "text",
63
+ fieldName: "reason_id",
64
+ mapToPk: true,
65
+ nullable: true,
66
+ }),
67
+ ReturnReasonIdIndex.MikroORMIndex(),
68
+ __metadata("design:type", Object)
69
+ ], ReturnItem.prototype, "reason_id", void 0);
70
+ __decorate([
71
+ (0, core_1.ManyToOne)(() => return_reason_1.default, {
72
+ persist: false,
73
+ }),
74
+ __metadata("design:type", return_reason_1.default)
75
+ ], ReturnItem.prototype, "reason", void 0);
76
+ __decorate([
77
+ (0, utils_1.MikroOrmBigNumberProperty)(),
78
+ __metadata("design:type", Number)
79
+ ], ReturnItem.prototype, "quantity", void 0);
80
+ __decorate([
81
+ (0, core_1.Property)({ columnType: "jsonb" }),
82
+ __metadata("design:type", Object)
83
+ ], ReturnItem.prototype, "raw_quantity", void 0);
84
+ __decorate([
85
+ (0, utils_1.MikroOrmBigNumberProperty)(),
86
+ __metadata("design:type", Number)
87
+ ], ReturnItem.prototype, "received_quantity", void 0);
88
+ __decorate([
89
+ (0, core_1.Property)({ columnType: "jsonb" }),
90
+ __metadata("design:type", Object)
91
+ ], ReturnItem.prototype, "raw_received_quantity", void 0);
92
+ __decorate([
93
+ (0, core_1.ManyToOne)(() => return_1.default, {
94
+ columnType: "text",
95
+ fieldName: "return_id",
96
+ mapToPk: true,
97
+ onDelete: "cascade",
98
+ }),
99
+ ReturnIdIndex.MikroORMIndex(),
100
+ __metadata("design:type", String)
101
+ ], ReturnItem.prototype, "return_id", void 0);
102
+ __decorate([
103
+ (0, core_1.ManyToOne)(() => return_1.default, {
104
+ persist: false,
105
+ }),
106
+ __metadata("design:type", return_1.default)
107
+ ], ReturnItem.prototype, "return", void 0);
108
+ __decorate([
109
+ (0, core_1.ManyToOne)({
110
+ entity: () => line_item_1.default,
111
+ fieldName: "item_id",
112
+ mapToPk: true,
113
+ columnType: "text",
114
+ }),
115
+ ItemIdIndex.MikroORMIndex(),
116
+ __metadata("design:type", String)
117
+ ], ReturnItem.prototype, "item_id", void 0);
118
+ __decorate([
119
+ (0, core_1.ManyToOne)(() => line_item_1.default, {
120
+ persist: false,
121
+ }),
122
+ __metadata("design:type", line_item_1.default)
123
+ ], ReturnItem.prototype, "item", void 0);
124
+ __decorate([
125
+ (0, core_1.Property)({ columnType: "text", nullable: true }),
126
+ __metadata("design:type", String)
127
+ ], ReturnItem.prototype, "note", void 0);
128
+ __decorate([
129
+ (0, core_1.Property)({ columnType: "jsonb", nullable: true }),
130
+ __metadata("design:type", Object)
131
+ ], ReturnItem.prototype, "metadata", void 0);
132
+ __decorate([
133
+ (0, core_1.Property)({
134
+ onCreate: () => new Date(),
135
+ columnType: "timestamptz",
136
+ defaultRaw: "now()",
137
+ }),
138
+ __metadata("design:type", Date)
139
+ ], ReturnItem.prototype, "created_at", void 0);
140
+ __decorate([
141
+ (0, core_1.Property)({
142
+ onCreate: () => new Date(),
143
+ onUpdate: () => new Date(),
144
+ columnType: "timestamptz",
145
+ defaultRaw: "now()",
146
+ }),
147
+ __metadata("design:type", Date)
148
+ ], ReturnItem.prototype, "updated_at", void 0);
149
+ __decorate([
150
+ (0, core_1.Property)({ columnType: "timestamptz", nullable: true }),
151
+ DeletedAtIndex.MikroORMIndex(),
152
+ __metadata("design:type", Object)
153
+ ], ReturnItem.prototype, "deleted_at", void 0);
154
+ __decorate([
155
+ (0, core_1.BeforeCreate)(),
156
+ __metadata("design:type", Function),
157
+ __metadata("design:paramtypes", []),
158
+ __metadata("design:returntype", void 0)
159
+ ], ReturnItem.prototype, "onCreate", null);
160
+ __decorate([
161
+ (0, core_1.OnInit)(),
162
+ __metadata("design:type", Function),
163
+ __metadata("design:paramtypes", []),
164
+ __metadata("design:returntype", void 0)
165
+ ], ReturnItem.prototype, "onInit", null);
166
+ ReturnItem = __decorate([
167
+ (0, core_1.Entity)({ tableName: "return_item" })
168
+ ], ReturnItem);
169
+ exports.default = ReturnItem;
170
+ //# sourceMappingURL=return-item.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"return-item.js","sourceRoot":"","sources":["../../src/models/return-item.ts"],"names":[],"mappings":";;;;;;;;;;;;;;AACA,2CAIwB;AACxB,0CAQwB;AACxB,4DAAkC;AAClC,sDAA6B;AAC7B,oEAA0C;AAI1C,MAAM,aAAa,GAAG,IAAA,sCAA8B,EAAC;IACnD,SAAS,EAAE,aAAa;IACxB,OAAO,EAAE,WAAW;IACpB,KAAK,EAAE,wBAAwB;CAChC,CAAC,CAAA;AAEF,MAAM,mBAAmB,GAAG,IAAA,sCAA8B,EAAC;IACzD,SAAS,EAAE,aAAa;IACxB,OAAO,EAAE,WAAW;IACpB,KAAK,EAAE,wBAAwB;CAChC,CAAC,CAAA;AAEF,MAAM,WAAW,GAAG,IAAA,sCAA8B,EAAC;IACjD,SAAS,EAAE,aAAa;IACxB,OAAO,EAAE,SAAS;IAClB,KAAK,EAAE,wBAAwB;CAChC,CAAC,CAAA;AAEF,MAAM,cAAc,GAAG,IAAA,sCAA8B,EAAC;IACpD,SAAS,EAAE,wBAAwB;IACnC,OAAO,EAAE,YAAY;IACrB,KAAK,EAAE,wBAAwB;CAChC,CAAC,CAAA;AAGa,IAAM,UAAU,GAAhB,MAAM,UAAU;IAAhB;QAab,cAAS,GAAkB,IAAI,CAAA;QAc/B,sBAAiB,GAAoB,CAAC,CAAA;QAqCtC,aAAQ,GAAmC,IAAI,CAAA;QAmB/C,eAAU,GAAgB,IAAI,CAAA;IAahC,CAAC;IAVC,QAAQ;QACN,IA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UAAU;IAD9B,IAAA,aAAM,EAAC,EAAE,SAAS,EAAE,aAAa,EAAE,CAAC;GAChB,UAAU,CAgG9B;kBAhGoB,UAAU"}
@@ -1,6 +1,7 @@
1
1
  import { BigNumberRawValue, DAL } from "@medusajs/types";
2
2
  import { BigNumber, ReturnStatus } from "@medusajs/utils";
3
3
  import { Collection, OptionalProps } from "@mikro-orm/core";
4
+ import { Transaction } from ".";
4
5
  import Claim from "./claim";
5
6
  import Exchange from "./exchange";
6
7
  import Order from "./order";
@@ -24,6 +25,7 @@ export default class Return {
24
25
  raw_refund_amount: BigNumberRawValue;
25
26
  items: Collection<OrderItem, object>;
26
27
  shipping_methods: Collection<OrderShippingMethod, object>;
28
+ transactions: Collection<Transaction, object>;
27
29
  metadata: Record<string, unknown> | null;
28
30
  created_at: Date;
29
31
  updated_at: Date;
@@ -14,10 +14,10 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
14
14
  Object.defineProperty(exports, "__esModule", { value: true });
15
15
  const utils_1 = require("@medusajs/utils");
16
16
  const core_1 = require("@mikro-orm/core");
17
+ const _models_1 = require(".");
17
18
  const claim_1 = __importDefault(require("./claim"));
18
19
  const exchange_1 = __importDefault(require("./exchange"));
19
20
  const order_1 = __importDefault(require("./order"));
20
- const order_item_1 = __importDefault(require("./order-item"));
21
21
  const order_shipping_method_1 = __importDefault(require("./order-shipping-method"));
22
22
  const DisplayIdIndex = (0, utils_1.createPsqlIndexStatementHelper)({
23
23
  tableName: "return",
@@ -52,6 +52,7 @@ let Return = class Return {
52
52
  this.no_notification = null;
53
53
  this.items = new core_1.Collection(this);
54
54
  this.shipping_methods = new core_1.Collection(this);
55
+ this.transactions = new core_1.Collection(this);
55
56
  this.metadata = null;
56
57
  this.deleted_at = null;
57
58
  this.received_at = null;
@@ -142,7 +143,7 @@ __decorate([
142
143
  __metadata("design:type", Object)
143
144
  ], Return.prototype, "raw_refund_amount", void 0);
144
145
  __decorate([
145
- (0, core_1.OneToMany)(() => order_item_1.default, (itemDetail) => itemDetail.return, {
146
+ (0, core_1.OneToMany)(() => _models_1.ReturnItem, (itemDetail) => itemDetail.return, {
146
147
  cascade: [core_1.Cascade.PERSIST],
147
148
  }),
148
149
  __metadata("design:type", Object)
@@ -153,6 +154,12 @@ __decorate([
153
154
  }),
154
155
  __metadata("design:type", Object)
155
156
  ], Return.prototype, "shipping_methods", void 0);
157
+ __decorate([
158
+ (0, core_1.OneToMany)(() => _models_1.Transaction, (transaction) => transaction.return, {
159
+ cascade: [core_1.Cascade.PERSIST],
160
+ }),
161
+ __metadata("design:type", Object)
162
+ ], Return.prototype, "transactions", void 0);
156
163
  __decorate([
157
164
  (0, core_1.Property)({ columnType: "jsonb", nullable: true }),
158
165
  __metadata("design:type", Object)
@@ -1 +1 @@
1
- {"version":3,"file":"return.js","sourceRoot":"","sources":["../../src/models/return.ts"],"names":[],"mappings":";;;;;;;;;;;;;;AACA,2CAMwB;AACxB,0CAawB;AACxB,oDAA2B;AAC3B,0DAAiC;AACjC,oDAA2B;AAC3B,8DAAoC;AACpC,oFAAyD;AAIzD,MAAM,cAAc,GAAG,IAAA,sCAA8B,EAAC;IACpD,SAAS,EAAE,QAAQ;IACnB,OAAO,EAAE,YAAY;IACrB,KAAK,EAAE,wBAAwB;CAChC,CAAC,CAAA;AAEF,MAAM,oBAAoB,GAAG,IAAA,sCAA8B,EAAC;IAC1D,SAAS,EAAE,QAAQ;IACnB,OAAO,EAAE,YAAY;IACrB,KAAK,EAAE,wBAAwB;CAChC,CAAC,CAAA;AAEF,MAAM,YAAY,GAAG,IAAA,sCAA8B,EAAC;IAClD,SAAS,EAAE,QAAQ;IACnB,OAAO,EAAE,CAAC,UAAU,CAAC;IACrB,KAAK,EAAE,wBAAwB;CAChC,CAAC,CAAA;AAEF,MAAM,eAAe,GAAG,IAAA,sCAA8B,EAAC;IACrD,SAAS,EAAE,QAAQ;IACnB,OAAO,EAAE,CAAC,aAAa,CAAC;IACxB,KAAK,EAAE,oDAAoD;CAC5D,CAAC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AAA,mBAAY,GAAE;;;;sCAGd;AAGD;IADC,IAAA,aAAM,GAAE;;;;oCAGR;AA1HkB,MAAM;IAD1B,IAAA,aAAM,EAAC,EAAE,SAAS,EAAE,QAAQ,EAAE,CAAC;GACX,MAAM,CA2H1B;kBA3HoB,MAAM"}
@@ -69,10 +69,16 @@ let Transaction = class Transaction {
69
69
  onCreate() {
70
70
  this.id = (0, utils_1.generateEntityId)(this.id, "ordtrx");
71
71
  this.order_id ??= this.order?.id;
72
+ this.return_id ??= this.return?.id;
73
+ this.claim_id ??= this.claim?.id;
74
+ this.exchange_id ??= this.exchange?.id;
72
75
  }
73
76
  onInit() {
74
77
  this.id = (0, utils_1.generateEntityId)(this.id, "ordtrx");
75
78
  this.order_id ??= this.order?.id;
79
+ this.return_id ??= this.return?.id;
80
+ this.claim_id ??= this.claim?.id;
81
+ this.exchange_id ??= this.exchange?.id;
76
82
  }
77
83
  };
78
84
  __decorate([
@@ -1 +1 @@
1
- {"version":3,"file":"transaction.js","sourceRoot":"","sources":["../../src/models/transaction.ts"],"names":[],"mappings":";;;;;;;;;;;;;;AACA,2CAKwB;AACxB,0CAQwB;AACxB,oDAA2B;AAC3B,0DAAiC;AACjC,oDAA2B;AAC3B,sDAA6B;AAI7B,MAAM,gBAAgB,GAAG,IAAA,sCAA8B,EAAC;IACtD,SAAS,EAAE,mBAAmB;IAC9B,OAAO,EAAE,cAAc;IACvB,KAAK,EAAE,wBAAwB;CAChC,CAAC,CAAA;AAEF,MAAM,YAAY,GAAG,IAAA,sCAA8B,EAAC;IAClD,SAAS,EAAE,mBAAmB;IAC9B,OAAO,EAAE,UAAU;IACnB,KAAK,EAAE,wBAAwB;CAChC,CAAC,CAAA;AAEF,MAAM,aAAa,GAAG,IAAA,sCAA8B,EAAC;IACnD,SAAS,EAAE,mBAAmB;IAC9B,OAAO,EAAE,WAAW;IACpB,KAAK,EAAE,kDAAkD;CAC1D,CAAC,CAAA;AAEF,MAAM,eAAe,GAAG,IAAA,sCAA8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C1B,QAAQ,EAAE,GAAG,EAAE,CAAC,IAAI,IAAI,EAAE;QAC1B,UAAU,EAAE,aAAa;QACzB,UAAU,EAAE,OAAO;KACpB,CAAC;8BACU,IAAI;+CAAA;AAIhB;IAFC,IAAA,eAAQ,EAAC,EAAE,UAAU,EAAE,aAAa,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;IACvD,cAAc,CAAC,aAAa,EAAE;;+CACD;AAG9B;IADC,IAAA,mBAAY,GAAE;;;;2CAOd;AAGD;IADC,IAAA,aAAM,GAAE;;;;yCAOR;AAlIkB,WAAW;IAF/B,IAAA,aAAM,EAAC,EAAE,SAAS,EAAE,mBAAmB,EAAE,CAAC;IAC1C,mBAAmB,CAAC,aAAa,EAAE;GACf,WAAW,CAmI/B;kBAnIoB,WAAW"}
@@ -0,0 +1,8 @@
1
+ import { DALUtils } from "@medusajs/utils";
2
+ import { OrderClaim } from "../models";
3
+ declare const OrderClaimRepository_base: new ({ manager }: {
4
+ manager: any;
5
+ }) => DALUtils.MikroOrmBaseRepository<OrderClaim>;
6
+ export declare class OrderClaimRepository extends OrderClaimRepository_base {
7
+ }
8
+ export {};
@@ -0,0 +1,11 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.OrderClaimRepository = void 0;
4
+ const utils_1 = require("@medusajs/utils");
5
+ const _models_1 = require("../models");
6
+ const base_repository_find_1 = require("../utils/base-repository-find");
7
+ class OrderClaimRepository extends utils_1.DALUtils.mikroOrmBaseRepositoryFactory(_models_1.OrderClaim) {
8
+ }
9
+ exports.OrderClaimRepository = OrderClaimRepository;
10
+ (0, base_repository_find_1.setFindMethods)(OrderClaimRepository, _models_1.OrderClaim);
11
+ //# sourceMappingURL=claim.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"claim.js","sourceRoot":"","sources":["../../src/repositories/claim.ts"],"names":[],"mappings":";;;AAAA,2CAA0C;AAC1C,qCAAoC;AACpC,wEAA8D;AAE9D,MAAa,oBAAqB,SAAQ,gBAAQ,CAAC,6BAA6B,CAC9E,oBAAU,CACX;CAAG;AAFJ,oDAEI;AAEJ,IAAA,qCAAc,EAAC,oBAAoB,EAAE,oBAAU,CAAC,CAAA"}
@@ -0,0 +1,8 @@
1
+ import { DALUtils } from "@medusajs/utils";
2
+ import { OrderExchange } from "../models";
3
+ declare const OrderExchangeRepository_base: new ({ manager }: {
4
+ manager: any;
5
+ }) => DALUtils.MikroOrmBaseRepository<OrderExchange>;
6
+ export declare class OrderExchangeRepository extends OrderExchangeRepository_base {
7
+ }
8
+ export {};
@@ -0,0 +1,11 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.OrderExchangeRepository = void 0;
4
+ const utils_1 = require("@medusajs/utils");
5
+ const _models_1 = require("../models");
6
+ const base_repository_find_1 = require("../utils/base-repository-find");
7
+ class OrderExchangeRepository extends utils_1.DALUtils.mikroOrmBaseRepositoryFactory(_models_1.OrderExchange) {
8
+ }
9
+ exports.OrderExchangeRepository = OrderExchangeRepository;
10
+ (0, base_repository_find_1.setFindMethods)(OrderExchangeRepository, _models_1.OrderExchange);
11
+ //# sourceMappingURL=exchange.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"exchange.js","sourceRoot":"","sources":["../../src/repositories/exchange.ts"],"names":[],"mappings":";;;AAAA,2CAA0C;AAC1C,qCAAuC;AACvC,wEAA8D;AAE9D,MAAa,uBAAwB,SAAQ,gBAAQ,CAAC,6BAA6B,CACjF,uBAAa,CACd;CAAG;AAFJ,0DAEI;AAEJ,IAAA,qCAAc,EAAC,uBAAuB,EAAE,uBAAa,CAAC,CAAA"}
@@ -1,3 +1,4 @@
1
1
  export { MikroOrmBaseRepository as BaseRepository } from "@medusajs/utils";
2
+ export { OrderClaimRepository } from "./claim";
2
3
  export { OrderRepository } from "./order";
3
4
  export { ReturnRepository } from "./return";
@@ -1,8 +1,10 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.ReturnRepository = exports.OrderRepository = exports.BaseRepository = void 0;
3
+ exports.ReturnRepository = exports.OrderRepository = exports.OrderClaimRepository = exports.BaseRepository = void 0;
4
4
  var utils_1 = require("@medusajs/utils");
5
5
  Object.defineProperty(exports, "BaseRepository", { enumerable: true, get: function () { return utils_1.MikroOrmBaseRepository; } });
6
+ var claim_1 = require("./claim");
7
+ Object.defineProperty(exports, "OrderClaimRepository", { enumerable: true, get: function () { return claim_1.OrderClaimRepository; } });
6
8
  var order_1 = require("./order");
7
9
  Object.defineProperty(exports, "OrderRepository", { enumerable: true, get: function () { return order_1.OrderRepository; } });
8
10
  var return_1 = require("./return");
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/repositories/index.ts"],"names":[],"mappings":";;;AAAA,yCAA0E;AAAjE,uGAAA,sBAAsB,OAAkB;AACjD,iCAAyC;AAAhC,wGAAA,eAAe,OAAA;AACxB,mCAA2C;AAAlC,0GAAA,gBAAgB,OAAA"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/repositories/index.ts"],"names":[],"mappings":";;;AAAA,yCAA0E;AAAjE,uGAAA,sBAAsB,OAAkB;AACjD,iCAA8C;AAArC,6GAAA,oBAAoB,OAAA;AAC7B,iCAAyC;AAAhC,wGAAA,eAAe,OAAA;AACxB,mCAA2C;AAAlC,0GAAA,gBAAgB,OAAA"}
@@ -0,0 +1,2 @@
1
+ import { Context, OrderTypes } from "@medusajs/types";
2
+ export declare function createClaim(this: any, data: OrderTypes.CreateOrderClaimDTO, sharedContext?: Context): Promise<any>;
@@ -0,0 +1,229 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.createClaim = void 0;
4
+ const utils_1 = require("@medusajs/utils");
5
+ const _models_1 = require("../../models");
6
+ const _types_1 = require("../../types");
7
+ const utils_2 = require("../../utils");
8
+ function createClaimAndReturnEntities(em, data, order) {
9
+ const claimReference = em.create(_models_1.OrderClaim, {
10
+ order_id: data.order_id,
11
+ order_version: order.version,
12
+ type: data.type,
13
+ no_notification: data.no_notification,
14
+ refund_amount: data.refund_amount ?? null,
15
+ });
16
+ const returnReference = data.type === utils_1.ClaimType.REPLACE
17
+ ? em.create(_models_1.Return, {
18
+ order_id: data.order_id,
19
+ order_version: order.version,
20
+ status: utils_1.ReturnStatus.REQUESTED,
21
+ claim_id: claimReference.id,
22
+ refund_amount: data.refund_amount ?? null,
23
+ })
24
+ : undefined;
25
+ claimReference.return_id = returnReference?.id;
26
+ return { claimReference, returnReference };
27
+ }
28
+ function createReturnItem(em, item, claimReference, returnReference, actions) {
29
+ actions.push({
30
+ action: utils_2.ChangeActionType.RETURN_ITEM,
31
+ reference: "return",
32
+ reference_id: returnReference.id,
33
+ details: {
34
+ reference_id: item.id,
35
+ return_id: returnReference.id,
36
+ claim_id: claimReference.id,
37
+ quantity: item.quantity,
38
+ metadata: item.metadata,
39
+ },
40
+ });
41
+ return em.create(_models_1.ReturnItem, {
42
+ item_id: item.id,
43
+ return_id: returnReference.id,
44
+ quantity: item.quantity,
45
+ note: item.note,
46
+ metadata: item.metadata,
47
+ });
48
+ }
49
+ function createClaimAndReturnItems(em, data, claimReference, returnReference, actions) {
50
+ const returnItems = [];
51
+ const claimItems = data.claim_items?.map((item) => {
52
+ actions.push({
53
+ action: utils_2.ChangeActionType.WRITE_OFF_ITEM,
54
+ reference: "claim",
55
+ reference_id: claimReference.id,
56
+ details: {
57
+ reference_id: item.id,
58
+ claim_id: claimReference.id,
59
+ quantity: item.quantity,
60
+ metadata: item.metadata,
61
+ },
62
+ });
63
+ returnItems.push(returnReference
64
+ ? createReturnItem(em, item, claimReference, returnReference, actions)
65
+ : undefined);
66
+ return em.create(_models_1.ClaimItem, {
67
+ item_id: item.id,
68
+ reason: item.reason,
69
+ quantity: item.quantity,
70
+ note: item.note,
71
+ metadata: item.metadata,
72
+ });
73
+ });
74
+ return [claimItems, returnItems];
75
+ }
76
+ async function processAdditionalItems(em, service, data, order, claimReference, actions, sharedContext) {
77
+ const itemsToAdd = [];
78
+ const additionalNewItems = [];
79
+ const additionalItems = [];
80
+ data.additional_items?.forEach((item) => {
81
+ const hasItem = item.id
82
+ ? order.items.find((o) => o.item.id === item.id)
83
+ : false;
84
+ if (hasItem) {
85
+ actions.push({
86
+ action: utils_2.ChangeActionType.ITEM_ADD,
87
+ claim_id: claimReference.id,
88
+ internal_note: item.internal_note,
89
+ reference: "claim",
90
+ reference_id: claimReference.id,
91
+ details: {
92
+ reference_id: item.id,
93
+ claim_id: claimReference.id,
94
+ quantity: item.quantity,
95
+ metadata: item.metadata,
96
+ },
97
+ });
98
+ additionalItems.push(em.create(_models_1.ClaimItem, {
99
+ item_id: item.id,
100
+ quantity: item.quantity,
101
+ note: item.note,
102
+ metadata: item.metadata,
103
+ is_additional_item: true,
104
+ }));
105
+ }
106
+ else {
107
+ itemsToAdd.push(item);
108
+ additionalNewItems.push(em.create(_models_1.ClaimItem, {
109
+ quantity: item.quantity,
110
+ note: item.note,
111
+ metadata: item.metadata,
112
+ is_additional_item: true,
113
+ }));
114
+ }
115
+ });
116
+ const createItems = await service.lineItemService_.create(itemsToAdd, sharedContext);
117
+ createItems.forEach((item, index) => {
118
+ const addedItem = itemsToAdd[index];
119
+ additionalNewItems[index].item_id = item.id;
120
+ actions.push({
121
+ action: utils_2.ChangeActionType.ITEM_ADD,
122
+ claim_id: claimReference.id,
123
+ internal_note: addedItem.internal_note,
124
+ reference: "claim",
125
+ reference_id: claimReference.id,
126
+ details: {
127
+ reference_id: item.id,
128
+ claim_id: claimReference.id,
129
+ quantity: addedItem.quantity,
130
+ metadata: addedItem.metadata,
131
+ },
132
+ });
133
+ });
134
+ return additionalNewItems.concat(additionalItems);
135
+ }
136
+ async function processShippingMethods(service, data, claimReference, actions, sharedContext) {
137
+ for (const shippingMethod of data.shipping_methods ?? []) {
138
+ let shippingMethodId;
139
+ if (!(0, utils_1.isString)(shippingMethod)) {
140
+ const methods = await service.createShippingMethods([
141
+ {
142
+ order_id: data.order_id,
143
+ claim_id: claimReference.id,
144
+ ...shippingMethod,
145
+ },
146
+ ], sharedContext);
147
+ shippingMethodId = methods[0].id;
148
+ }
149
+ else {
150
+ shippingMethodId = shippingMethod;
151
+ }
152
+ const method = await service.retrieveShippingMethod(shippingMethodId, { relations: ["tax_lines", "adjustments"] }, sharedContext);
153
+ const calculatedAmount = (0, utils_1.getShippingMethodsTotals)([method], {})[method.id];
154
+ actions.push({
155
+ action: utils_2.ChangeActionType.SHIPPING_ADD,
156
+ reference: "order_shipping_method",
157
+ reference_id: shippingMethodId,
158
+ claim_id: claimReference.id,
159
+ amount: calculatedAmount.total,
160
+ });
161
+ }
162
+ }
163
+ async function processReturnShipping(service, data, claimReference, returnReference, actions, sharedContext) {
164
+ if (!returnReference) {
165
+ return;
166
+ }
167
+ if (data.return_shipping) {
168
+ let returnShippingMethodId;
169
+ if (!(0, utils_1.isString)(data.return_shipping)) {
170
+ const methods = await service.createShippingMethods([
171
+ {
172
+ order_id: data.order_id,
173
+ claim_id: claimReference.id,
174
+ return_id: returnReference.id,
175
+ ...data.return_shipping,
176
+ },
177
+ ], sharedContext);
178
+ returnShippingMethodId = methods[0].id;
179
+ }
180
+ else {
181
+ returnShippingMethodId = data.return_shipping;
182
+ }
183
+ const method = await service.retrieveShippingMethod(returnShippingMethodId, { relations: ["tax_lines", "adjustments"] }, sharedContext);
184
+ const calculatedAmount = (0, utils_1.getShippingMethodsTotals)([method], {})[method.id];
185
+ actions.push({
186
+ action: utils_2.ChangeActionType.SHIPPING_ADD,
187
+ reference: "order_shipping_method",
188
+ reference_id: returnShippingMethodId,
189
+ return_id: returnReference.id,
190
+ claim_id: claimReference.id,
191
+ amount: calculatedAmount.total,
192
+ });
193
+ }
194
+ }
195
+ async function createClaim(data, sharedContext) {
196
+ const order = await this.orderService_.retrieve(data.order_id, { relations: ["items"] }, sharedContext);
197
+ const actions = [];
198
+ const em = sharedContext.transactionManager;
199
+ const { claimReference, returnReference } = createClaimAndReturnEntities(em, data, order);
200
+ const [claimItems, returnItems] = createClaimAndReturnItems(em, data, claimReference, returnReference, actions);
201
+ claimReference.claim_items = claimItems;
202
+ if (returnReference) {
203
+ returnReference.items = returnItems;
204
+ }
205
+ claimReference.additional_items = await processAdditionalItems(em, this, data, order, claimReference, actions, sharedContext);
206
+ await processShippingMethods(this, data, claimReference, actions, sharedContext);
207
+ await processReturnShipping(this, data, claimReference, returnReference, actions, sharedContext);
208
+ const change = await this.createOrderChange_({
209
+ order_id: data.order_id,
210
+ claim_id: claimReference.id,
211
+ return_id: returnReference.id,
212
+ change_type: _types_1.OrderChangeType.CLAIM,
213
+ reference: "claim",
214
+ reference_id: claimReference.id,
215
+ description: data.description,
216
+ internal_note: data.internal_note,
217
+ created_by: data.created_by,
218
+ metadata: data.metadata,
219
+ actions,
220
+ }, sharedContext);
221
+ await (0, utils_1.promiseAll)([
222
+ this.createReturns([returnReference], sharedContext),
223
+ this.createOrderClaims([claimReference], sharedContext),
224
+ this.confirmOrderChange(change[0].id, sharedContext),
225
+ ]);
226
+ return claimReference;
227
+ }
228
+ exports.createClaim = createClaim;
229
+ //# sourceMappingURL=create-claim.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"create-claim.js","sourceRoot":"","sources":["../../../src/services/actions/create-claim.ts"],"names":[],"mappings":";;;AAKA,2CAMwB;AACxB,qCAAmE;AACnE,mCAAwC;AACxC,uCAA8C;AAE9C,SAAS,4BAA4B,CAAC,EAAE,EAAE,IAAI,EAAE,KAAK;IACnD,MAAM,cAAc,GAAG,EAAE,CAAC,MAAM,CAAC,oBAAU,EAAE;QAC3C,QAAQ,EAAE,IAAI,CAAC,QAAQ;QACvB,aAAa,EAAE,KAAK,CAAC,OAAO;QAC5B,IAAI,EAAE,IAAI,CAAC,IAAiB;QAC5B,eAAe,EAAE,IAAI,CAAC,eAAe;QACrC,aAAa,EAAG,IAAI,CAAC,aAAyB,IAAI,IAAI;KACvD,CAAC,CAAA;IAEF,MAAM,e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usajs/types";
2
+ export declare function createExchange(this: any, data: OrderTypes.CreateOrderExchangeDTO, sharedContext?: Context): Promise<any>;