@unchainedshop/core-orders 1.1.3 → 1.1.4
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/package.json +8 -5
- package/tests/orders-index.test.ts +1 -1
- package/.npm/package/README +0 -7
- package/.npm/package/npm-shrinkwrap.json +0 -190
- package/.versions +0 -54
- package/package.js +0 -33
- package/plugins/discount-100-off.ts +0 -44
- package/plugins/discount-half-price-manual.ts +0 -43
- package/plugins/discount-half-price.ts +0 -46
- package/plugins/order-delivery.ts +0 -45
- package/plugins/order-discount.ts +0 -158
- package/plugins/order-items-discount.ts +0 -116
- package/plugins/order-items.ts +0 -61
- package/plugins/order-payment.ts +0 -46
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@unchainedshop/core-orders",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.4",
|
|
4
4
|
"main": "lib/orders-index.js",
|
|
5
5
|
"types": "lib/orders-index.d.ts",
|
|
6
6
|
"type": "module",
|
|
@@ -27,15 +27,18 @@
|
|
|
27
27
|
},
|
|
28
28
|
"homepage": "https://github.com/unchainedshop/unchained#readme",
|
|
29
29
|
"dependencies": {
|
|
30
|
-
"@unchainedshop/
|
|
31
|
-
"@unchainedshop/
|
|
32
|
-
"@unchainedshop/utils": "latest",
|
|
30
|
+
"@unchainedshop/logger": "1.1.3",
|
|
31
|
+
"@unchainedshop/utils": "1.1.3",
|
|
33
32
|
"simpl-schema": "^1.12.2"
|
|
34
33
|
},
|
|
34
|
+
"peerDependencies": {
|
|
35
|
+
"@unchainedshop/events": "1.1.3"
|
|
36
|
+
},
|
|
35
37
|
"devDependencies": {
|
|
36
38
|
"@types/chai": "^4.3.1",
|
|
37
39
|
"@types/mocha": "^9.1.1",
|
|
38
|
-
"@unchainedshop/
|
|
40
|
+
"@unchainedshop/events": "1.1.3",
|
|
41
|
+
"@unchainedshop/types": "^1.1.2",
|
|
39
42
|
"chai": "^4.3.6",
|
|
40
43
|
"cross-env": "^7.0.3",
|
|
41
44
|
"typescript": "^4.7.4"
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { assert } from 'chai';
|
|
2
2
|
import { initDb } from 'meteor/unchained:mongodb';
|
|
3
|
-
import { configureOrdersModule } from '
|
|
3
|
+
import { configureOrdersModule } from '@unchainedshop/core-orders';
|
|
4
4
|
import { OrdersModule } from '@unchainedshop/types/orders';
|
|
5
5
|
|
|
6
6
|
describe('Test exports', () => {
|
package/.npm/package/README
DELETED
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
This directory and the files immediately inside it are automatically generated
|
|
2
|
-
when you change this package's NPM dependencies. Commit the files in this
|
|
3
|
-
directory (npm-shrinkwrap.json, .gitignore, and this README) to source control
|
|
4
|
-
so that others run the same versions of sub-dependencies.
|
|
5
|
-
|
|
6
|
-
You should NOT check in the node_modules directory that Meteor automatically
|
|
7
|
-
creates; if you are using git, the .gitignore file tells git to ignore it.
|
|
@@ -1,190 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"lockfileVersion": 1,
|
|
3
|
-
"dependencies": {
|
|
4
|
-
"@colors/colors": {
|
|
5
|
-
"version": "1.5.0",
|
|
6
|
-
"resolved": "https://registry.npmjs.org/@colors/colors/-/colors-1.5.0.tgz",
|
|
7
|
-
"integrity": "sha512-ooWCrlZP11i8GImSjTHYHLkvFDP48nS4+204nGb1RiX/WXYHmJA2III9/e2DWVabCESdW7hBAEzHRqUn9OUVvQ=="
|
|
8
|
-
},
|
|
9
|
-
"@dabh/diagnostics": {
|
|
10
|
-
"version": "2.0.3",
|
|
11
|
-
"resolved": "https://registry.npmjs.org/@dabh/diagnostics/-/diagnostics-2.0.3.tgz",
|
|
12
|
-
"integrity": "sha512-hrlQOIi7hAfzsMqlGSFyVucrx38O+j6wiGOf//H2ecvIEqYN4ADBSS2iLMh5UFyDunCNniUIPk/q3riFv45xRA=="
|
|
13
|
-
},
|
|
14
|
-
"@unchainedshop/logger": {
|
|
15
|
-
"version": "1.1.0",
|
|
16
|
-
"resolved": "https://registry.npmjs.org/@unchainedshop/logger/-/logger-1.1.0.tgz",
|
|
17
|
-
"integrity": "sha512-PwS2wtlwzRo1RlfRbKQN6cLCz7XEp2dGmVbXCQ1E49O9VvAYNh5mdTg2BNoWYZ1Sl7KWpLkANNYispb+X/Y4jw=="
|
|
18
|
-
},
|
|
19
|
-
"async": {
|
|
20
|
-
"version": "3.2.4",
|
|
21
|
-
"resolved": "https://registry.npmjs.org/async/-/async-3.2.4.tgz",
|
|
22
|
-
"integrity": "sha512-iAB+JbDEGXhyIUavoDl9WP/Jj106Kz9DEn1DPgYw5ruDn0e3Wgi3sKFm55sASdGBNOQB8F59d9qQ7deqrHA8wQ=="
|
|
23
|
-
},
|
|
24
|
-
"clone": {
|
|
25
|
-
"version": "2.1.2",
|
|
26
|
-
"resolved": "https://registry.npmjs.org/clone/-/clone-2.1.2.tgz",
|
|
27
|
-
"integrity": "sha512-3Pe/CF1Nn94hyhIYpjtiLhdCoEoz0DqQ+988E9gmeEdQZlojxnOb74wctFyuwWQHzqyf9X7C7MG8juUpqBJT8w=="
|
|
28
|
-
},
|
|
29
|
-
"color": {
|
|
30
|
-
"version": "3.2.1",
|
|
31
|
-
"resolved": "https://registry.npmjs.org/color/-/color-3.2.1.tgz",
|
|
32
|
-
"integrity": "sha512-aBl7dZI9ENN6fUGC7mWpMTPNHmWUSNan9tuWN6ahh5ZLNk9baLJOnSMlrQkHcrfFgz2/RigjUVAjdx36VcemKA=="
|
|
33
|
-
},
|
|
34
|
-
"color-convert": {
|
|
35
|
-
"version": "1.9.3",
|
|
36
|
-
"resolved": "https://registry.npmjs.org/color-convert/-/color-convert-1.9.3.tgz",
|
|
37
|
-
"integrity": "sha512-QfAUtd+vFdAtFQcC8CCyYt1fYWxSqAiK2cSD6zDB8N3cpsEBAvRxp9zOGg6G/SHHJYAT88/az/IuDGALsNVbGg=="
|
|
38
|
-
},
|
|
39
|
-
"color-name": {
|
|
40
|
-
"version": "1.1.3",
|
|
41
|
-
"resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.3.tgz",
|
|
42
|
-
"integrity": "sha512-72fSenhMw2HZMTVHeCA9KCmpEIbzWiQsjN+BHcBbS9vr1mtt+vJjPdksIBNUmKAW8TFUDPJK5SUU3QhE9NEXDw=="
|
|
43
|
-
},
|
|
44
|
-
"color-string": {
|
|
45
|
-
"version": "1.9.1",
|
|
46
|
-
"resolved": "https://registry.npmjs.org/color-string/-/color-string-1.9.1.tgz",
|
|
47
|
-
"integrity": "sha512-shrVawQFojnZv6xM40anx4CkoDP+fZsw/ZerEMsW/pyzsRbElpsL/DBVW7q3ExxwusdNXI3lXpuhEZkzs8p5Eg=="
|
|
48
|
-
},
|
|
49
|
-
"colorspace": {
|
|
50
|
-
"version": "1.1.4",
|
|
51
|
-
"resolved": "https://registry.npmjs.org/colorspace/-/colorspace-1.1.4.tgz",
|
|
52
|
-
"integrity": "sha512-BgvKJiuVu1igBUF2kEjRCZXol6wiiGbY5ipL/oVPwm0BL9sIpMIzM8IK7vwuxIIzOXMV3Ey5w+vxhm0rR/TN8w=="
|
|
53
|
-
},
|
|
54
|
-
"enabled": {
|
|
55
|
-
"version": "2.0.0",
|
|
56
|
-
"resolved": "https://registry.npmjs.org/enabled/-/enabled-2.0.0.tgz",
|
|
57
|
-
"integrity": "sha512-AKrN98kuwOzMIdAizXGI86UFBoo26CL21UM763y1h/GMSJ4/OHU9k2YlsmBpyScFo/wbLzWQJBMCW4+IO3/+OQ=="
|
|
58
|
-
},
|
|
59
|
-
"fecha": {
|
|
60
|
-
"version": "4.2.3",
|
|
61
|
-
"resolved": "https://registry.npmjs.org/fecha/-/fecha-4.2.3.tgz",
|
|
62
|
-
"integrity": "sha512-OP2IUU6HeYKJi3i0z4A19kHMQoLVs4Hc+DPqqxI2h/DPZHTm/vjsfC6P0b4jCMy14XizLBqvndQ+UilD7707Jw=="
|
|
63
|
-
},
|
|
64
|
-
"fn.name": {
|
|
65
|
-
"version": "1.1.0",
|
|
66
|
-
"resolved": "https://registry.npmjs.org/fn.name/-/fn.name-1.1.0.tgz",
|
|
67
|
-
"integrity": "sha512-GRnmB5gPyJpAhTQdSZTSp9uaPSvl09KoYcMQtsB9rQoOmzs9dH6ffeccH+Z+cv6P68Hu5bC6JjRh4Ah/mHSNRw=="
|
|
68
|
-
},
|
|
69
|
-
"inherits": {
|
|
70
|
-
"version": "2.0.4",
|
|
71
|
-
"resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.4.tgz",
|
|
72
|
-
"integrity": "sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ=="
|
|
73
|
-
},
|
|
74
|
-
"is-arrayish": {
|
|
75
|
-
"version": "0.3.2",
|
|
76
|
-
"resolved": "https://registry.npmjs.org/is-arrayish/-/is-arrayish-0.3.2.tgz",
|
|
77
|
-
"integrity": "sha512-eVRqCvVlZbuw3GrM63ovNSNAeA1K16kaR/LRY/92w0zxQ5/1YzwblUX652i4Xs9RwAGjW9d9y6X88t8OaAJfWQ=="
|
|
78
|
-
},
|
|
79
|
-
"is-stream": {
|
|
80
|
-
"version": "2.0.1",
|
|
81
|
-
"resolved": "https://registry.npmjs.org/is-stream/-/is-stream-2.0.1.tgz",
|
|
82
|
-
"integrity": "sha512-hFoiJiTl63nn+kstHGBtewWSKnQLpyb155KHheA1l39uvtO9nWIop1p3udqPcUd/xbF1VLMO4n7OI6p7RbngDg=="
|
|
83
|
-
},
|
|
84
|
-
"kuler": {
|
|
85
|
-
"version": "2.0.0",
|
|
86
|
-
"resolved": "https://registry.npmjs.org/kuler/-/kuler-2.0.0.tgz",
|
|
87
|
-
"integrity": "sha512-Xq9nH7KlWZmXAtodXDDRE7vs6DU1gTU8zYDHDiWLSip45Egwq3plLHzPn27NgvzL2r1LMPC1vdqh98sQxtqj4A=="
|
|
88
|
-
},
|
|
89
|
-
"lodash._reinterpolate": {
|
|
90
|
-
"version": "3.0.0",
|
|
91
|
-
"resolved": "https://registry.npmjs.org/lodash._reinterpolate/-/lodash._reinterpolate-3.0.0.tgz",
|
|
92
|
-
"integrity": "sha512-xYHt68QRoYGjeeM/XOE1uJtvXQAgvszfBhjV4yvsQH0u2i9I6cI6c6/eG4Hh3UAOVn0y/xAXwmTzEay49Q//HA=="
|
|
93
|
-
},
|
|
94
|
-
"lodash.template": {
|
|
95
|
-
"version": "4.5.0",
|
|
96
|
-
"resolved": "https://registry.npmjs.org/lodash.template/-/lodash.template-4.5.0.tgz",
|
|
97
|
-
"integrity": "sha512-84vYFxIkmidUiFxidA/KjjH9pAycqW+h980j7Fuz5qxRtO9pgB7MDFTdys1N7A5mcucRiDyEq4fusljItR1T/A=="
|
|
98
|
-
},
|
|
99
|
-
"lodash.templatesettings": {
|
|
100
|
-
"version": "4.2.0",
|
|
101
|
-
"resolved": "https://registry.npmjs.org/lodash.templatesettings/-/lodash.templatesettings-4.2.0.tgz",
|
|
102
|
-
"integrity": "sha512-stgLz+i3Aa9mZgnjr/O+v9ruKZsPsndy7qPZOchbqk2cnTU1ZaldKK+v7m54WoKIyxiuMZTKT2H81F8BeAc3ZQ=="
|
|
103
|
-
},
|
|
104
|
-
"logform": {
|
|
105
|
-
"version": "2.4.0",
|
|
106
|
-
"resolved": "https://registry.npmjs.org/logform/-/logform-2.4.0.tgz",
|
|
107
|
-
"integrity": "sha512-CPSJw4ftjf517EhXZGGvTHHkYobo7ZCc0kvwUoOYcjfR2UVrI66RHj8MCrfAdEitdmFqbu2BYdYs8FHHZSb6iw=="
|
|
108
|
-
},
|
|
109
|
-
"message-box": {
|
|
110
|
-
"version": "0.2.7",
|
|
111
|
-
"resolved": "https://registry.npmjs.org/message-box/-/message-box-0.2.7.tgz",
|
|
112
|
-
"integrity": "sha512-C4ccA5nHb58kTS+pLrgF/JWtr7fAIkHxRDceH7tdy5fMA783nUfbYwZ7H2XLvSeYfcnWIYCig5dWW+icK9X/Ag=="
|
|
113
|
-
},
|
|
114
|
-
"mongo-object": {
|
|
115
|
-
"version": "0.1.4",
|
|
116
|
-
"resolved": "https://registry.npmjs.org/mongo-object/-/mongo-object-0.1.4.tgz",
|
|
117
|
-
"integrity": "sha512-QtYk0gupWEn2+iB+DDRt1L+WbcNYvJRaHdih/dcqthOa1DbnREUGSs2WGcW478GNYpElflo/yybZXu0sTiRXHg=="
|
|
118
|
-
},
|
|
119
|
-
"ms": {
|
|
120
|
-
"version": "2.1.3",
|
|
121
|
-
"resolved": "https://registry.npmjs.org/ms/-/ms-2.1.3.tgz",
|
|
122
|
-
"integrity": "sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA=="
|
|
123
|
-
},
|
|
124
|
-
"one-time": {
|
|
125
|
-
"version": "1.0.0",
|
|
126
|
-
"resolved": "https://registry.npmjs.org/one-time/-/one-time-1.0.0.tgz",
|
|
127
|
-
"integrity": "sha512-5DXOiRKwuSEcQ/l0kGCF6Q3jcADFv5tSmRaJck/OqkVFcOzutB134KRSfF0xDrL39MNnqxbHBbUUcjZIhTgb2g=="
|
|
128
|
-
},
|
|
129
|
-
"readable-stream": {
|
|
130
|
-
"version": "3.6.0",
|
|
131
|
-
"resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-3.6.0.tgz",
|
|
132
|
-
"integrity": "sha512-BViHy7LKeTz4oNnkcLJ+lVSL6vpiFeX6/d3oSH8zCW7UxP2onchk+vTGB143xuFjHS3deTgkKoXXymXqymiIdA=="
|
|
133
|
-
},
|
|
134
|
-
"safe-buffer": {
|
|
135
|
-
"version": "5.2.1",
|
|
136
|
-
"resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.2.1.tgz",
|
|
137
|
-
"integrity": "sha512-rp3So07KcdmmKbGvgaNxQSJr7bGVSVk5S9Eq1F+ppbRo70+YeaDxkw5Dd8NPN+GD6bjnYm2VuPuCXmpuYvmCXQ=="
|
|
138
|
-
},
|
|
139
|
-
"safe-stable-stringify": {
|
|
140
|
-
"version": "2.3.1",
|
|
141
|
-
"resolved": "https://registry.npmjs.org/safe-stable-stringify/-/safe-stable-stringify-2.3.1.tgz",
|
|
142
|
-
"integrity": "sha512-kYBSfT+troD9cDA85VDnHZ1rpHC50O0g1e6WlGHVCz/g+JS+9WKLj+XwFYyR8UbrZN8ll9HUpDAAddY58MGisg=="
|
|
143
|
-
},
|
|
144
|
-
"simpl-schema": {
|
|
145
|
-
"version": "1.12.0",
|
|
146
|
-
"resolved": "https://registry.npmjs.org/simpl-schema/-/simpl-schema-1.12.0.tgz",
|
|
147
|
-
"integrity": "sha512-lzXC3L8jJbPhNXGR3cjlyIauqqrC5WUJS4O34Ym/wLIvb8K3ZieK+1OfTzs4mBpDc3Y8u53gQFAr1X37DmTcEg=="
|
|
148
|
-
},
|
|
149
|
-
"simple-swizzle": {
|
|
150
|
-
"version": "0.2.2",
|
|
151
|
-
"resolved": "https://registry.npmjs.org/simple-swizzle/-/simple-swizzle-0.2.2.tgz",
|
|
152
|
-
"integrity": "sha512-JA//kQgZtbuY83m+xT+tXJkmJncGMTFT+C+g2h2R9uxkYIrE2yy9sgmcLhCnw57/WSD+Eh3J97FPEDFnbXnDUg=="
|
|
153
|
-
},
|
|
154
|
-
"stack-trace": {
|
|
155
|
-
"version": "0.0.10",
|
|
156
|
-
"resolved": "https://registry.npmjs.org/stack-trace/-/stack-trace-0.0.10.tgz",
|
|
157
|
-
"integrity": "sha512-KGzahc7puUKkzyMt+IqAep+TVNbKP+k2Lmwhub39m1AsTSkaDutx56aDCo+HLDzf/D26BIHTJWNiTG1KAJiQCg=="
|
|
158
|
-
},
|
|
159
|
-
"string_decoder": {
|
|
160
|
-
"version": "1.3.0",
|
|
161
|
-
"resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.3.0.tgz",
|
|
162
|
-
"integrity": "sha512-hkRX8U1WjJFd8LsDJ2yQ/wWWxaopEsABU1XfkM8A+j0+85JAGppt16cr1Whg6KIbb4okU6Mql6BOj+uup/wKeA=="
|
|
163
|
-
},
|
|
164
|
-
"text-hex": {
|
|
165
|
-
"version": "1.0.0",
|
|
166
|
-
"resolved": "https://registry.npmjs.org/text-hex/-/text-hex-1.0.0.tgz",
|
|
167
|
-
"integrity": "sha512-uuVGNWzgJ4yhRaNSiubPY7OjISw4sw4E5Uv0wbjp+OzcbmVU/rsT8ujgcXJhn9ypzsgr5vlzpPqP+MBBKcGvbg=="
|
|
168
|
-
},
|
|
169
|
-
"triple-beam": {
|
|
170
|
-
"version": "1.3.0",
|
|
171
|
-
"resolved": "https://registry.npmjs.org/triple-beam/-/triple-beam-1.3.0.tgz",
|
|
172
|
-
"integrity": "sha512-XrHUvV5HpdLmIj4uVMxHggLbFSZYIn7HEWsqePZcI50pco+MPqJ50wMGY794X7AOOhxOBAjbkqfAbEe/QMp2Lw=="
|
|
173
|
-
},
|
|
174
|
-
"util-deprecate": {
|
|
175
|
-
"version": "1.0.2",
|
|
176
|
-
"resolved": "https://registry.npmjs.org/util-deprecate/-/util-deprecate-1.0.2.tgz",
|
|
177
|
-
"integrity": "sha512-EPD5q1uXyFxJpCrLnCc1nHnq3gOa6DZBocAIiI2TaSCA7VCJ1UJDMagCzIkXNsUYfD1daK//LTEQ8xiIbrHtcw=="
|
|
178
|
-
},
|
|
179
|
-
"winston": {
|
|
180
|
-
"version": "3.7.2",
|
|
181
|
-
"resolved": "https://registry.npmjs.org/winston/-/winston-3.7.2.tgz",
|
|
182
|
-
"integrity": "sha512-QziIqtojHBoyzUOdQvQiar1DH0Xp9nF1A1y7NVy2DGEsz82SBDtOalS0ulTRGVT14xPX3WRWkCsdcJKqNflKng=="
|
|
183
|
-
},
|
|
184
|
-
"winston-transport": {
|
|
185
|
-
"version": "4.5.0",
|
|
186
|
-
"resolved": "https://registry.npmjs.org/winston-transport/-/winston-transport-4.5.0.tgz",
|
|
187
|
-
"integrity": "sha512-YpZzcUzBedhlTAfJg6vJDlyEai/IFMIVcaEZZyl3UXIl4gmqRpU7AE89AHLkbzLUsv0NVmw7ts+iztqKxxPW1Q=="
|
|
188
|
-
}
|
|
189
|
-
}
|
|
190
|
-
}
|
package/.versions
DELETED
|
@@ -1,54 +0,0 @@
|
|
|
1
|
-
allow-deny@1.1.1
|
|
2
|
-
babel-compiler@7.9.0
|
|
3
|
-
babel-runtime@1.5.1
|
|
4
|
-
base64@1.0.12
|
|
5
|
-
binary-heap@1.0.11
|
|
6
|
-
boilerplate-generator@1.7.1
|
|
7
|
-
callback-hook@1.4.0
|
|
8
|
-
check@1.3.1
|
|
9
|
-
ddp@1.4.0
|
|
10
|
-
ddp-client@2.5.0
|
|
11
|
-
ddp-common@1.4.0
|
|
12
|
-
ddp-server@2.5.0
|
|
13
|
-
diff-sequence@1.1.1
|
|
14
|
-
dynamic-import@0.7.2
|
|
15
|
-
ecmascript@0.16.2
|
|
16
|
-
ecmascript-runtime@0.8.0
|
|
17
|
-
ecmascript-runtime-client@0.12.1
|
|
18
|
-
ecmascript-runtime-server@0.11.0
|
|
19
|
-
ejson@1.1.2
|
|
20
|
-
fetch@0.1.1
|
|
21
|
-
geojson-utils@1.0.10
|
|
22
|
-
id-map@1.1.1
|
|
23
|
-
inter-process-messaging@0.1.1
|
|
24
|
-
local-test:unchained:core-orders@1.1.2
|
|
25
|
-
logging@1.3.1
|
|
26
|
-
meteor@1.10.0
|
|
27
|
-
meteortesting:browser-tests@0.1.2
|
|
28
|
-
meteortesting:mocha@0.4.4
|
|
29
|
-
minimongo@1.8.0
|
|
30
|
-
modern-browsers@0.1.8
|
|
31
|
-
modules@0.18.0
|
|
32
|
-
modules-runtime@0.13.0
|
|
33
|
-
mongo@1.15.0
|
|
34
|
-
mongo-decimal@0.1.3
|
|
35
|
-
mongo-dev-server@1.1.0
|
|
36
|
-
mongo-id@1.0.8
|
|
37
|
-
npm-mongo@4.3.1
|
|
38
|
-
ordered-dict@1.1.0
|
|
39
|
-
practicalmeteor:mocha-core@1.0.1
|
|
40
|
-
promise@0.12.0
|
|
41
|
-
random@1.2.0
|
|
42
|
-
react-fast-refresh@0.2.3
|
|
43
|
-
reload@1.3.1
|
|
44
|
-
retry@1.1.0
|
|
45
|
-
routepolicy@1.1.1
|
|
46
|
-
socket-stream-client@0.5.0
|
|
47
|
-
tracker@1.2.0
|
|
48
|
-
typescript@4.5.4
|
|
49
|
-
unchained:core-orders@1.1.2
|
|
50
|
-
|
|
51
|
-
unchained:mongodb@1.0.0
|
|
52
|
-
underscore@1.0.10
|
|
53
|
-
webapp@1.13.1
|
|
54
|
-
webapp-hashing@1.1.0
|
package/package.js
DELETED
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
Package.describe({
|
|
2
|
-
name: 'unchained:core-orders',
|
|
3
|
-
version: '1.1.3',
|
|
4
|
-
summary: 'Unchained Engine Core: Orders',
|
|
5
|
-
git: 'https://github.com/unchainedshop/unchained',
|
|
6
|
-
documentation: 'README.md',
|
|
7
|
-
});
|
|
8
|
-
|
|
9
|
-
Npm.depends({
|
|
10
|
-
'simpl-schema': '1.12.0',
|
|
11
|
-
'@unchainedshop/logger': '1.1.3',
|
|
12
|
-
'@unchainedshop/utils': '1.1.3',
|
|
13
|
-
// '@unchainedshop/events': '1.1.4', // PEER
|
|
14
|
-
});
|
|
15
|
-
|
|
16
|
-
Package.onUse((api) => {
|
|
17
|
-
api.versionsFrom('2.7.3');
|
|
18
|
-
api.use('ecmascript');
|
|
19
|
-
api.use('typescript');
|
|
20
|
-
|
|
21
|
-
api.mainModule('src/orders-index.ts', 'server');
|
|
22
|
-
});
|
|
23
|
-
|
|
24
|
-
Package.onTest((api) => {
|
|
25
|
-
api.use('meteortesting:mocha');
|
|
26
|
-
api.use('ecmascript');
|
|
27
|
-
api.use('typescript');
|
|
28
|
-
|
|
29
|
-
api.use('unchained:mongodb');
|
|
30
|
-
api.use('unchained:core-orders');
|
|
31
|
-
|
|
32
|
-
api.mainModule('tests/orders-index.test.ts');
|
|
33
|
-
});
|
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
import { IDiscountAdapter } from '@unchainedshop/types/discount';
|
|
2
|
-
import { OrderDiscountDirector, OrderDiscountAdapter } from 'meteor/unchained:core-orders';
|
|
3
|
-
|
|
4
|
-
const HundredOff: IDiscountAdapter = {
|
|
5
|
-
...OrderDiscountAdapter,
|
|
6
|
-
|
|
7
|
-
key: 'shop.unchained.discount.100-off',
|
|
8
|
-
label: '100 Off',
|
|
9
|
-
version: '1.0',
|
|
10
|
-
orderIndex: 1,
|
|
11
|
-
|
|
12
|
-
// return true if a discount is allowed to get added manually by a user
|
|
13
|
-
isManualAdditionAllowed: async () => {
|
|
14
|
-
return true;
|
|
15
|
-
},
|
|
16
|
-
|
|
17
|
-
// return true if a discount is allowed to get removed manually by a user
|
|
18
|
-
isManualRemovalAllowed: async () => {
|
|
19
|
-
return true;
|
|
20
|
-
},
|
|
21
|
-
|
|
22
|
-
actions: async ({ context }) => ({
|
|
23
|
-
...(await OrderDiscountAdapter.actions({ context })),
|
|
24
|
-
|
|
25
|
-
isValidForSystemTriggering: async () => {
|
|
26
|
-
return false;
|
|
27
|
-
},
|
|
28
|
-
|
|
29
|
-
isValidForCodeTriggering: async ({ code }) => {
|
|
30
|
-
return code.toUpperCase() === '100OFF';
|
|
31
|
-
},
|
|
32
|
-
|
|
33
|
-
// returns the appropriate discount context for a calculation adapter
|
|
34
|
-
discountForPricingAdapterKey: ({ pricingAdapterKey }) => {
|
|
35
|
-
if (pricingAdapterKey === 'shop.unchained.pricing.order-discount') {
|
|
36
|
-
return { fixedRate: 10000 };
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
return null;
|
|
40
|
-
},
|
|
41
|
-
}),
|
|
42
|
-
};
|
|
43
|
-
|
|
44
|
-
OrderDiscountDirector.registerAdapter(HundredOff);
|
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
import { IDiscountAdapter } from '@unchainedshop/types/discount';
|
|
2
|
-
import { OrderDiscountDirector, OrderDiscountAdapter } from 'meteor/unchained:core-orders';
|
|
3
|
-
|
|
4
|
-
const HalfPriceManual: IDiscountAdapter = {
|
|
5
|
-
...OrderDiscountAdapter,
|
|
6
|
-
|
|
7
|
-
key: 'shop.unchained.discount.half-price-manual',
|
|
8
|
-
label: 'Half Price',
|
|
9
|
-
version: '1.0',
|
|
10
|
-
orderIndex: 2,
|
|
11
|
-
|
|
12
|
-
// return true if a discount is allowed to get added manually by a user
|
|
13
|
-
isManualAdditionAllowed: async () => {
|
|
14
|
-
return true;
|
|
15
|
-
},
|
|
16
|
-
|
|
17
|
-
// return true if a discount is allowed to get removed manually by a user
|
|
18
|
-
isManualRemovalAllowed: async () => {
|
|
19
|
-
return true;
|
|
20
|
-
},
|
|
21
|
-
|
|
22
|
-
actions: async ({ context }) => ({
|
|
23
|
-
...(await OrderDiscountAdapter.actions({ context })),
|
|
24
|
-
|
|
25
|
-
isValidForSystemTriggering: async () => {
|
|
26
|
-
return false;
|
|
27
|
-
},
|
|
28
|
-
|
|
29
|
-
isValidForCodeTriggering: async ({ code }) => {
|
|
30
|
-
return code === 'HALFPRICE';
|
|
31
|
-
},
|
|
32
|
-
|
|
33
|
-
// returns the appropriate discount context for a calculation adapter
|
|
34
|
-
discountForPricingAdapterKey({ pricingAdapterKey }) {
|
|
35
|
-
if (pricingAdapterKey === 'shop.unchained.pricing.product-discount') {
|
|
36
|
-
return { rate: 0.5 };
|
|
37
|
-
}
|
|
38
|
-
return null;
|
|
39
|
-
},
|
|
40
|
-
}),
|
|
41
|
-
};
|
|
42
|
-
|
|
43
|
-
OrderDiscountDirector.registerAdapter(HalfPriceManual);
|
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
import { IDiscountAdapter } from '@unchainedshop/types/discount';
|
|
2
|
-
import { OrderDiscountDirector, OrderDiscountAdapter } from 'meteor/unchained:director-discounting';
|
|
3
|
-
|
|
4
|
-
const HalfPrice: IDiscountAdapter = {
|
|
5
|
-
...OrderDiscountAdapter,
|
|
6
|
-
|
|
7
|
-
key: 'shop.unchained.discount.half-price',
|
|
8
|
-
label: 'Half Price',
|
|
9
|
-
version: '1.0',
|
|
10
|
-
orderIndex: 3,
|
|
11
|
-
|
|
12
|
-
// return true if a discount is allowed to get added manually by a user
|
|
13
|
-
isManualAdditionAllowed: async () => {
|
|
14
|
-
return false;
|
|
15
|
-
},
|
|
16
|
-
|
|
17
|
-
// return true if a discount is allowed to get removed manually by a user
|
|
18
|
-
isManualRemovalAllowed: async () => {
|
|
19
|
-
return false;
|
|
20
|
-
},
|
|
21
|
-
|
|
22
|
-
actions: async ({ context }) => ({
|
|
23
|
-
...(await OrderDiscountAdapter.actions({ context })),
|
|
24
|
-
|
|
25
|
-
isValidForSystemTriggering: async () => {
|
|
26
|
-
const { order } = context;
|
|
27
|
-
const user = await context.modules.users.findUserById(order.userId);
|
|
28
|
-
const isUserEligibleForHalfPrice = user?.tags && user.tags.indexOf('half-price') !== -1;
|
|
29
|
-
return !!isUserEligibleForHalfPrice;
|
|
30
|
-
},
|
|
31
|
-
|
|
32
|
-
isValidForCodeTriggering: async () => {
|
|
33
|
-
return false;
|
|
34
|
-
},
|
|
35
|
-
|
|
36
|
-
// returns the appropriate discount context for a calculation adapter
|
|
37
|
-
discountForPricingAdapterKey({ pricingAdapterKey }) {
|
|
38
|
-
if (pricingAdapterKey === 'shop.unchained.pricing.product-discount') {
|
|
39
|
-
return { rate: 0.5 };
|
|
40
|
-
}
|
|
41
|
-
return null;
|
|
42
|
-
},
|
|
43
|
-
}),
|
|
44
|
-
};
|
|
45
|
-
|
|
46
|
-
OrderDiscountDirector.registerAdapter(HalfPrice);
|
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
import { IOrderPricingAdapter } from '@unchainedshop/types/orders.pricing';
|
|
2
|
-
import { OrderPricingDirector, OrderPricingAdapter } from 'meteor/unchained:core-orders';
|
|
3
|
-
|
|
4
|
-
const OrderDelivery: IOrderPricingAdapter = {
|
|
5
|
-
...OrderPricingAdapter,
|
|
6
|
-
|
|
7
|
-
key: 'shop.unchained.pricing.order-delivery',
|
|
8
|
-
version: '1.0',
|
|
9
|
-
label: 'Add Delivery Fees to Order',
|
|
10
|
-
orderIndex: 10,
|
|
11
|
-
|
|
12
|
-
isActivatedFor: () => {
|
|
13
|
-
return true;
|
|
14
|
-
},
|
|
15
|
-
|
|
16
|
-
actions: (params) => {
|
|
17
|
-
const pricingAdapter = OrderPricingAdapter.actions(params);
|
|
18
|
-
const { order, orderDelivery, modules } = params.context;
|
|
19
|
-
|
|
20
|
-
return {
|
|
21
|
-
...pricingAdapter,
|
|
22
|
-
|
|
23
|
-
calculate: async () => {
|
|
24
|
-
// just add tax + net price to order pricing
|
|
25
|
-
if (!orderDelivery) return null;
|
|
26
|
-
const pricing = modules.orders.deliveries.pricingSheet(
|
|
27
|
-
orderDelivery,
|
|
28
|
-
order.currency,
|
|
29
|
-
params.context,
|
|
30
|
-
);
|
|
31
|
-
const tax = pricing.taxSum();
|
|
32
|
-
const shipping = pricing.gross();
|
|
33
|
-
|
|
34
|
-
pricingAdapter.resultSheet().addDelivery({ amount: shipping });
|
|
35
|
-
if (tax !== 0) {
|
|
36
|
-
pricingAdapter.resultSheet().addTax({ amount: tax });
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
return pricingAdapter.calculate();
|
|
40
|
-
},
|
|
41
|
-
};
|
|
42
|
-
},
|
|
43
|
-
};
|
|
44
|
-
|
|
45
|
-
OrderPricingDirector.registerAdapter(OrderDelivery);
|
|
@@ -1,158 +0,0 @@
|
|
|
1
|
-
import { IOrderPricingAdapter, OrderPricingRowCategory } from '@unchainedshop/types/orders.pricing';
|
|
2
|
-
import { OrderPricingDirector, OrderPricingAdapter } from 'meteor/unchained:core-orders';
|
|
3
|
-
|
|
4
|
-
const resolveRatioAndTaxDivisorForPricingSheet = (pricing, total) => {
|
|
5
|
-
if (total === 0 || !pricing) {
|
|
6
|
-
return {
|
|
7
|
-
ratio: 1,
|
|
8
|
-
taxDivisor: 1,
|
|
9
|
-
};
|
|
10
|
-
}
|
|
11
|
-
const tax = pricing.taxSum();
|
|
12
|
-
const gross = pricing.gross();
|
|
13
|
-
if (gross - tax === 0) {
|
|
14
|
-
return {
|
|
15
|
-
ratio: 0,
|
|
16
|
-
taxDivisor: 0,
|
|
17
|
-
};
|
|
18
|
-
}
|
|
19
|
-
return {
|
|
20
|
-
ratio: gross / total,
|
|
21
|
-
taxDivisor: gross / (gross - tax),
|
|
22
|
-
};
|
|
23
|
-
};
|
|
24
|
-
|
|
25
|
-
const resolveAmountAndTax = ({ ratio, taxDivisor }, amount) => {
|
|
26
|
-
const shareAmount = Number.isFinite(ratio) ? amount * ratio : 0;
|
|
27
|
-
const shareTaxAmount =
|
|
28
|
-
Number.isFinite(taxDivisor) && taxDivisor !== 0 ? shareAmount - shareAmount / taxDivisor : 0;
|
|
29
|
-
return [shareAmount, shareTaxAmount];
|
|
30
|
-
};
|
|
31
|
-
|
|
32
|
-
const applyDiscountToMultipleShares = (shares, amount) => {
|
|
33
|
-
return shares.reduce(
|
|
34
|
-
([currentDiscountAmount, currentTaxAmount], share) => {
|
|
35
|
-
const [shareAmount, shareTaxAmount] = resolveAmountAndTax(share, amount);
|
|
36
|
-
return [currentDiscountAmount + shareAmount, currentTaxAmount + shareTaxAmount];
|
|
37
|
-
},
|
|
38
|
-
[0, 0],
|
|
39
|
-
);
|
|
40
|
-
};
|
|
41
|
-
|
|
42
|
-
const calculateAmountToSplit = (configuration, amount) => {
|
|
43
|
-
const deductionAmount = configuration.rate ? amount * configuration.rate : configuration.fixedRate;
|
|
44
|
-
|
|
45
|
-
const leftInDiscount = Math.max(0, deductionAmount - (configuration.alreadyDeductedForDiscount || 0));
|
|
46
|
-
const leftToDeduct = Math.min(configuration.amountLeft, leftInDiscount);
|
|
47
|
-
return Math.max(0, leftToDeduct);
|
|
48
|
-
};
|
|
49
|
-
|
|
50
|
-
const OrderDiscount: IOrderPricingAdapter = {
|
|
51
|
-
...OrderPricingAdapter,
|
|
52
|
-
|
|
53
|
-
key: 'shop.unchained.pricing.order-discount',
|
|
54
|
-
version: '1.0',
|
|
55
|
-
label: 'Apply Discounts on Total Order Value',
|
|
56
|
-
orderIndex: 90,
|
|
57
|
-
|
|
58
|
-
isActivatedFor: () => {
|
|
59
|
-
return true;
|
|
60
|
-
},
|
|
61
|
-
|
|
62
|
-
actions: (params) => {
|
|
63
|
-
const pricingAdapter = OrderPricingAdapter.actions(params);
|
|
64
|
-
const { order, orderDelivery, orderPositions, orderPayment, modules } = params.context;
|
|
65
|
-
|
|
66
|
-
return {
|
|
67
|
-
...pricingAdapter,
|
|
68
|
-
|
|
69
|
-
calculate: async () => {
|
|
70
|
-
// discounts need to provide a *fixedRate*
|
|
71
|
-
// if you want to add percentual discounts,
|
|
72
|
-
// add it to the order item calculation
|
|
73
|
-
const totalAmountOfItems = params.calculationSheet.sum({
|
|
74
|
-
category: OrderPricingRowCategory.Items,
|
|
75
|
-
});
|
|
76
|
-
const totalAmountOfPaymentAndDelivery =
|
|
77
|
-
params.calculationSheet.sum({
|
|
78
|
-
category: OrderPricingRowCategory.Payment,
|
|
79
|
-
}) +
|
|
80
|
-
params.calculationSheet.sum({
|
|
81
|
-
category: OrderPricingRowCategory.Delivery,
|
|
82
|
-
});
|
|
83
|
-
|
|
84
|
-
const itemShares = orderPositions.map((orderPosition) =>
|
|
85
|
-
resolveRatioAndTaxDivisorForPricingSheet(
|
|
86
|
-
modules.orders.positions.pricingSheet(orderPosition, order.currency, params.context),
|
|
87
|
-
totalAmountOfItems,
|
|
88
|
-
),
|
|
89
|
-
);
|
|
90
|
-
|
|
91
|
-
const deliveryShare = resolveRatioAndTaxDivisorForPricingSheet(
|
|
92
|
-
orderDelivery &&
|
|
93
|
-
modules.orders.deliveries.pricingSheet(orderDelivery, order.currency, params.context),
|
|
94
|
-
totalAmountOfPaymentAndDelivery,
|
|
95
|
-
);
|
|
96
|
-
const paymentShare = resolveRatioAndTaxDivisorForPricingSheet(
|
|
97
|
-
orderPayment &&
|
|
98
|
-
modules.orders.payments.pricingSheet(orderPayment, order.currency, params.context),
|
|
99
|
-
totalAmountOfPaymentAndDelivery,
|
|
100
|
-
);
|
|
101
|
-
|
|
102
|
-
let amountLeft = totalAmountOfPaymentAndDelivery + totalAmountOfItems;
|
|
103
|
-
|
|
104
|
-
params.discounts.forEach(({ configuration, discountId }) => {
|
|
105
|
-
// First, we deduce the discount from the items
|
|
106
|
-
let alreadyDeductedForDiscount = 0;
|
|
107
|
-
const [itemsDiscountAmount, itemsTaxAmount] = applyDiscountToMultipleShares(
|
|
108
|
-
itemShares,
|
|
109
|
-
calculateAmountToSplit(
|
|
110
|
-
{ ...configuration, amountLeft, alreadyDeductedForDiscount },
|
|
111
|
-
totalAmountOfItems,
|
|
112
|
-
),
|
|
113
|
-
);
|
|
114
|
-
amountLeft -= itemsDiscountAmount;
|
|
115
|
-
alreadyDeductedForDiscount += itemsDiscountAmount;
|
|
116
|
-
|
|
117
|
-
// After the items, we deduct the remaining discount from payment & delivery fees
|
|
118
|
-
const [deliveryAndPaymentDiscountAmount, deliveryAndPaymentTaxAmount] =
|
|
119
|
-
applyDiscountToMultipleShares(
|
|
120
|
-
[deliveryShare, paymentShare],
|
|
121
|
-
calculateAmountToSplit(
|
|
122
|
-
{ ...configuration, amountLeft, alreadyDeductedForDiscount },
|
|
123
|
-
totalAmountOfPaymentAndDelivery,
|
|
124
|
-
),
|
|
125
|
-
);
|
|
126
|
-
amountLeft -= deliveryAndPaymentDiscountAmount;
|
|
127
|
-
alreadyDeductedForDiscount += itemsDiscountAmount;
|
|
128
|
-
|
|
129
|
-
const discountAmount = itemsDiscountAmount + deliveryAndPaymentDiscountAmount;
|
|
130
|
-
const taxAmount = itemsTaxAmount + deliveryAndPaymentTaxAmount;
|
|
131
|
-
|
|
132
|
-
if (discountAmount) {
|
|
133
|
-
pricingAdapter.resultSheet().addDiscount({
|
|
134
|
-
amount: discountAmount * -1,
|
|
135
|
-
discountId,
|
|
136
|
-
meta: {
|
|
137
|
-
adapter: OrderDiscount.key,
|
|
138
|
-
},
|
|
139
|
-
});
|
|
140
|
-
if (taxAmount !== 0) {
|
|
141
|
-
pricingAdapter.resultSheet().addTax({
|
|
142
|
-
amount: taxAmount * -1,
|
|
143
|
-
meta: {
|
|
144
|
-
discountId,
|
|
145
|
-
adapter: OrderDiscount.key,
|
|
146
|
-
},
|
|
147
|
-
});
|
|
148
|
-
}
|
|
149
|
-
}
|
|
150
|
-
});
|
|
151
|
-
|
|
152
|
-
return pricingAdapter.calculate();
|
|
153
|
-
},
|
|
154
|
-
};
|
|
155
|
-
},
|
|
156
|
-
};
|
|
157
|
-
|
|
158
|
-
OrderPricingDirector.registerAdapter(OrderDiscount);
|
|
@@ -1,116 +0,0 @@
|
|
|
1
|
-
import { IOrderPricingAdapter, OrderPricingRowCategory } from '@unchainedshop/types/orders.pricing';
|
|
2
|
-
import { OrderPricingDirector, OrderPricingAdapter } from 'meteor/unchained:core-orders';
|
|
3
|
-
|
|
4
|
-
const resolveRatioAndTaxDivisorForPricingSheet = (pricing, total) => {
|
|
5
|
-
if (total === 0 || !pricing) {
|
|
6
|
-
return {
|
|
7
|
-
ratio: 1,
|
|
8
|
-
taxDivisor: 1,
|
|
9
|
-
};
|
|
10
|
-
}
|
|
11
|
-
const tax = pricing.taxSum();
|
|
12
|
-
const gross = pricing.gross();
|
|
13
|
-
return {
|
|
14
|
-
ratio: gross / total,
|
|
15
|
-
taxDivisor: gross / (gross - tax),
|
|
16
|
-
};
|
|
17
|
-
};
|
|
18
|
-
|
|
19
|
-
const resolveAmountAndTax = ({ ratio, taxDivisor }, amount) => {
|
|
20
|
-
const shareAmount = Number.isFinite(ratio) ? amount * ratio : 0;
|
|
21
|
-
const shareTaxAmount = Number.isFinite(taxDivisor) ? shareAmount - shareAmount / taxDivisor : 0;
|
|
22
|
-
return [shareAmount, shareTaxAmount];
|
|
23
|
-
};
|
|
24
|
-
|
|
25
|
-
const applyDiscountToMultipleShares = (shares, amount) => {
|
|
26
|
-
return shares.reduce(
|
|
27
|
-
([currentDiscountAmount, currentTaxAmount], share) => {
|
|
28
|
-
const [shareAmount, shareTaxAmount] = resolveAmountAndTax(share, amount);
|
|
29
|
-
return [currentDiscountAmount + shareAmount, currentTaxAmount + shareTaxAmount];
|
|
30
|
-
},
|
|
31
|
-
[0, 0],
|
|
32
|
-
);
|
|
33
|
-
};
|
|
34
|
-
|
|
35
|
-
const calculateAmountToSplit = (configuration, amount) => {
|
|
36
|
-
const deductionAmount = configuration.rate
|
|
37
|
-
? amount * configuration.rate
|
|
38
|
-
: Math.min(configuration.fixedRate, amount);
|
|
39
|
-
|
|
40
|
-
return Math.max(0, deductionAmount - (configuration.alreadyDeducted || 0));
|
|
41
|
-
};
|
|
42
|
-
|
|
43
|
-
const OrderItemsDiscount: IOrderPricingAdapter = {
|
|
44
|
-
...OrderPricingAdapter,
|
|
45
|
-
|
|
46
|
-
key: 'shop.unchained.pricing.order-items-discount',
|
|
47
|
-
version: '1.0',
|
|
48
|
-
label: 'Apply Discounts on Total Value Of Goods',
|
|
49
|
-
orderIndex: 89,
|
|
50
|
-
|
|
51
|
-
isActivatedFor: () => {
|
|
52
|
-
return true;
|
|
53
|
-
},
|
|
54
|
-
|
|
55
|
-
actions: (params) => {
|
|
56
|
-
const pricingAdapter = OrderPricingAdapter.actions(params);
|
|
57
|
-
const { order, orderPositions, modules } = params.context;
|
|
58
|
-
|
|
59
|
-
return {
|
|
60
|
-
...pricingAdapter,
|
|
61
|
-
|
|
62
|
-
calculate: async () => {
|
|
63
|
-
// discounts need to provide a *fixedRate*
|
|
64
|
-
// if you want to add percentual discounts,
|
|
65
|
-
// add it to the order item calculation
|
|
66
|
-
|
|
67
|
-
const totalAmountOfItems = params.calculationSheet.sum({
|
|
68
|
-
category: OrderPricingRowCategory.Items,
|
|
69
|
-
});
|
|
70
|
-
|
|
71
|
-
const itemShares = orderPositions.map((orderPosition) =>
|
|
72
|
-
resolveRatioAndTaxDivisorForPricingSheet(
|
|
73
|
-
modules.orders.positions.pricingSheet(orderPosition, order.currency, params.context),
|
|
74
|
-
totalAmountOfItems,
|
|
75
|
-
),
|
|
76
|
-
);
|
|
77
|
-
|
|
78
|
-
let alreadyDeducted = 0;
|
|
79
|
-
|
|
80
|
-
params.discounts.forEach(({ configuration, discountId }) => {
|
|
81
|
-
// First, we deduce the discount from the items
|
|
82
|
-
const [itemsDiscountAmount, itemsTaxAmount] = applyDiscountToMultipleShares(
|
|
83
|
-
itemShares,
|
|
84
|
-
calculateAmountToSplit({ ...configuration, alreadyDeducted }, totalAmountOfItems),
|
|
85
|
-
);
|
|
86
|
-
alreadyDeducted = +itemsDiscountAmount;
|
|
87
|
-
|
|
88
|
-
const discountAmount = itemsDiscountAmount;
|
|
89
|
-
const taxAmount = itemsTaxAmount;
|
|
90
|
-
if (discountAmount) {
|
|
91
|
-
pricingAdapter.resultSheet().addDiscount({
|
|
92
|
-
amount: discountAmount * -1,
|
|
93
|
-
discountId,
|
|
94
|
-
meta: {
|
|
95
|
-
adapter: OrderItemsDiscount.key,
|
|
96
|
-
},
|
|
97
|
-
});
|
|
98
|
-
if (taxAmount !== 0) {
|
|
99
|
-
pricingAdapter.resultSheet().addTax({
|
|
100
|
-
amount: taxAmount * -1,
|
|
101
|
-
meta: {
|
|
102
|
-
discountId,
|
|
103
|
-
adapter: OrderItemsDiscount.key,
|
|
104
|
-
},
|
|
105
|
-
});
|
|
106
|
-
}
|
|
107
|
-
}
|
|
108
|
-
});
|
|
109
|
-
|
|
110
|
-
return pricingAdapter.calculate();
|
|
111
|
-
},
|
|
112
|
-
};
|
|
113
|
-
},
|
|
114
|
-
};
|
|
115
|
-
|
|
116
|
-
OrderPricingDirector.registerAdapter(OrderItemsDiscount);
|
package/plugins/order-items.ts
DELETED
|
@@ -1,61 +0,0 @@
|
|
|
1
|
-
import { IOrderPricingAdapter } from '@unchainedshop/types/orders.pricing';
|
|
2
|
-
import { OrderPricingDirector, OrderPricingAdapter } from 'meteor/unchained:core-orders';
|
|
3
|
-
|
|
4
|
-
const OrderItems: IOrderPricingAdapter = {
|
|
5
|
-
...OrderPricingAdapter,
|
|
6
|
-
|
|
7
|
-
key: 'shop.unchained.pricing.order-items',
|
|
8
|
-
version: '1.0',
|
|
9
|
-
label: 'Add Total Value Of Goods to Order',
|
|
10
|
-
orderIndex: 0,
|
|
11
|
-
|
|
12
|
-
isActivatedFor: () => {
|
|
13
|
-
return true;
|
|
14
|
-
},
|
|
15
|
-
|
|
16
|
-
actions: (params) => {
|
|
17
|
-
const pricingAdapter = OrderPricingAdapter.actions(params);
|
|
18
|
-
const { order, orderPositions, modules } = params.context;
|
|
19
|
-
|
|
20
|
-
return {
|
|
21
|
-
...pricingAdapter,
|
|
22
|
-
|
|
23
|
-
calculate: async () => {
|
|
24
|
-
// just sum up all products items prices, taxes & fees
|
|
25
|
-
const totalAndTaxesOfAllItems = orderPositions.reduce(
|
|
26
|
-
(current, orderPosition) => {
|
|
27
|
-
const pricing = modules.orders.positions.pricingSheet(
|
|
28
|
-
orderPosition,
|
|
29
|
-
order.currency,
|
|
30
|
-
params.context,
|
|
31
|
-
);
|
|
32
|
-
const tax = pricing.taxSum();
|
|
33
|
-
const items = pricing.gross();
|
|
34
|
-
return {
|
|
35
|
-
taxes: current.taxes + tax,
|
|
36
|
-
items: current.items + items,
|
|
37
|
-
};
|
|
38
|
-
},
|
|
39
|
-
{
|
|
40
|
-
taxes: 0,
|
|
41
|
-
items: 0,
|
|
42
|
-
},
|
|
43
|
-
);
|
|
44
|
-
|
|
45
|
-
pricingAdapter.resultSheet().addItems({
|
|
46
|
-
amount: totalAndTaxesOfAllItems.items,
|
|
47
|
-
});
|
|
48
|
-
|
|
49
|
-
if (totalAndTaxesOfAllItems.taxes !== 0) {
|
|
50
|
-
pricingAdapter.resultSheet().addTax({
|
|
51
|
-
amount: totalAndTaxesOfAllItems.taxes,
|
|
52
|
-
});
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
return pricingAdapter.calculate();
|
|
56
|
-
},
|
|
57
|
-
};
|
|
58
|
-
},
|
|
59
|
-
};
|
|
60
|
-
|
|
61
|
-
OrderPricingDirector.registerAdapter(OrderItems);
|
package/plugins/order-payment.ts
DELETED
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
import { IOrderPricingAdapter } from '@unchainedshop/types/orders.pricing';
|
|
2
|
-
import { OrderPricingDirector, OrderPricingAdapter } from 'meteor/unchained:core-orders';
|
|
3
|
-
|
|
4
|
-
const OrderPayment: IOrderPricingAdapter = {
|
|
5
|
-
...OrderPricingAdapter,
|
|
6
|
-
|
|
7
|
-
key: 'shop.unchained.pricing.order-payment',
|
|
8
|
-
version: '1.0',
|
|
9
|
-
label: 'Add Payment Fees to Order',
|
|
10
|
-
orderIndex: 20,
|
|
11
|
-
|
|
12
|
-
isActivatedFor: () => {
|
|
13
|
-
return true;
|
|
14
|
-
},
|
|
15
|
-
|
|
16
|
-
actions: (params) => {
|
|
17
|
-
const pricingAdapter = OrderPricingAdapter.actions(params);
|
|
18
|
-
const { order, orderPayment, modules } = params.context;
|
|
19
|
-
|
|
20
|
-
return {
|
|
21
|
-
...pricingAdapter,
|
|
22
|
-
|
|
23
|
-
calculate: async () => {
|
|
24
|
-
// just add tax + net price to order pricing
|
|
25
|
-
if (!orderPayment) return null;
|
|
26
|
-
|
|
27
|
-
const pricing = modules.orders.payments.pricingSheet(
|
|
28
|
-
orderPayment,
|
|
29
|
-
order.currency,
|
|
30
|
-
params.context,
|
|
31
|
-
);
|
|
32
|
-
const tax = pricing.taxSum();
|
|
33
|
-
const paymentFees = pricing.gross();
|
|
34
|
-
|
|
35
|
-
pricingAdapter.resultSheet().addPayment({ amount: paymentFees });
|
|
36
|
-
if (tax !== 0) {
|
|
37
|
-
pricingAdapter.resultSheet().addTax({ amount: tax });
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
return pricingAdapter.calculate();
|
|
41
|
-
},
|
|
42
|
-
};
|
|
43
|
-
},
|
|
44
|
-
};
|
|
45
|
-
|
|
46
|
-
OrderPricingDirector.registerAdapter(OrderPayment);
|