database-connector 2.5.0 → 2.5.2

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/models/Payment.js CHANGED
@@ -104,6 +104,7 @@ const paymentSchema = new mongoose.Schema(
104
104
  paymentCurrency: {
105
105
  type: String,
106
106
  required: true,
107
+ default: 'EUR',
107
108
  },
108
109
  paymentMethodId: {
109
110
  type: mongoose.Schema.Types.ObjectId,
package/models/Plan.js CHANGED
@@ -21,8 +21,17 @@ const mongoose = require('mongoose');
21
21
  * type: number
22
22
  * description: Number of months in the plan
23
23
  * price:
24
- * type: number
25
- * description: Plan price for one store
24
+ * type: array
25
+ * items:
26
+ * type: object
27
+ * properties:
28
+ * currency:
29
+ * type: string
30
+ * description: Currency code (EUR, USD, DZD, etc.)
31
+ * amount:
32
+ * type: number
33
+ * description: Price amount in the specified currency
34
+ * description: Array of prices in different currencies
26
35
  * storeReductionRules:
27
36
  * type: array
28
37
  * items:
@@ -49,7 +58,13 @@ const mongoose = require('mongoose');
49
58
  * id: "507f1f77bcf86cd799439011"
50
59
  * type: "Annual"
51
60
  * months: 12
52
- * price: 99.99
61
+ * price:
62
+ * - currency: "EUR"
63
+ * amount: 99.99
64
+ * - currency: "USD"
65
+ * amount: 109.99
66
+ * - currency: "DZD"
67
+ * amount: 13999.99
53
68
  * storeReductionRules:
54
69
  * - storeNumber: 2
55
70
  * reductionPercentage: 10
@@ -71,10 +86,18 @@ const planSchema = new mongoose.Schema(
71
86
  required: true,
72
87
  unique: false
73
88
  },
74
- price: {
75
- type: Number,
76
- required: true,
77
- },
89
+ price: [
90
+ {
91
+ currency: {
92
+ type: String,
93
+ required: true,
94
+ },
95
+ amount: {
96
+ type: Number,
97
+ required: true,
98
+ },
99
+ }
100
+ ],
78
101
  storeReductionRules: [
79
102
  {
80
103
  storeNumber: {
@@ -7,6 +7,7 @@ const buildSubscriptionHistorySnapshot = (subscriptionDoc) => ({
7
7
  planTypeId: subscriptionDoc.planTypeId,
8
8
  subscriptionOfferId: subscriptionDoc.subscriptionOfferId,
9
9
  paymentAmount: subscriptionDoc.paymentAmount,
10
+ paymentCurrency: subscriptionDoc.paymentCurrency,
10
11
  paymentTypeId: subscriptionDoc.paymentTypeId,
11
12
  paymentIntentId: subscriptionDoc.paymentIntentId,
12
13
  reductionOfferId: subscriptionDoc.reductionOfferId,
@@ -89,6 +90,10 @@ const recordSubscriptionHistory = async (oldSubscriptionDoc, updatedSubscription
89
90
  * paymentAmount:
90
91
  * type: number
91
92
  * description: Payment amount
93
+ * paymentCurrency:
94
+ * type: string
95
+ * default: EUR
96
+ * description: Payment currency (EUR, USD, DZD, etc.)
92
97
  * paymentTypeId:
93
98
  * type: string
94
99
  * description: Reference to payment type
@@ -136,6 +141,7 @@ const recordSubscriptionHistory = async (oldSubscriptionDoc, updatedSubscription
136
141
  * sellerId: "507f1f77bcf86cd799439012"
137
142
  * planId: "507f1f77bcf86cd799439013"
138
143
  * paymentAmount: 99.99
144
+ * paymentCurrency: "EUR"
139
145
  * paymentIntentId: "507f1f77bcf86cd799439099"
140
146
  * status: "active"
141
147
  * startDate: "2025-12-01T00:00:00.000Z"
@@ -201,6 +207,10 @@ const subscriptionSchema = new mongoose.Schema(
201
207
  type: Number,
202
208
  required: true,
203
209
  },
210
+ paymentCurrency: {
211
+ type: String,
212
+ default: 'EUR',
213
+ },
204
214
  paymentTypeId: {
205
215
  type: mongoose.Schema.Types.ObjectId,
206
216
  required: false,
@@ -266,6 +276,10 @@ const subscriptionSchema = new mongoose.Schema(
266
276
  type: Number,
267
277
  required: false,
268
278
  },
279
+ paymentCurrency: {
280
+ type: String,
281
+ default: 'EUR',
282
+ },
269
283
  paymentTypeId: {
270
284
  type: mongoose.Schema.Types.ObjectId,
271
285
  required: false,
@@ -363,6 +377,10 @@ const subscriptionSchema = new mongoose.Schema(
363
377
  type: Number,
364
378
  required: false,
365
379
  },
380
+ paymentCurrency: {
381
+ type: String,
382
+ default: 'EUR',
383
+ },
366
384
  paymentTypeId: {
367
385
  type: mongoose.Schema.Types.ObjectId,
368
386
  required: false,
package/models/User.js CHANGED
@@ -104,6 +104,10 @@ const { policySchema } = require('database-connector/models/Policy');
104
104
  * enum: [ar, en, fr]
105
105
  * default: en
106
106
  * description: User's preferred language
107
+ * currency:
108
+ * type: string
109
+ * default: EUR
110
+ * description: User's preferred currency (EUR, USD, DZD, etc.)
107
111
  * storeCategorieIds:
108
112
  * type: array
109
113
  * items:
@@ -253,6 +257,10 @@ const userSchema = new mongoose.Schema(
253
257
  enum: ['ar', 'en', 'fr'],
254
258
  default: 'en',
255
259
  },
260
+ currency: {
261
+ type: String,
262
+ default: 'EUR',
263
+ },
256
264
  storeCategorieIds: [
257
265
  {
258
266
  type: mongoose.Schema.Types.ObjectId,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "database-connector",
3
- "version": "2.5.0",
3
+ "version": "2.5.2",
4
4
  "description": "MongoDB models package with Mongoose schemas for e-commerce applications. Includes User, Product, Store, Order and more with built-in validation and virtual properties.",
5
5
  "main": "models/index.js",
6
6
  "scripts": {