@vendure/core 3.7.4-master-202610040244 → 3.7.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/dist/config/catalog/default-stock-location-strategy.d.ts +57 -2
- package/dist/config/catalog/default-stock-location-strategy.js +101 -5
- package/dist/config/catalog/default-stock-location-strategy.js.map +1 -1
- package/dist/config/catalog/multi-channel-stock-location-strategy.d.ts +0 -5
- package/dist/config/catalog/multi-channel-stock-location-strategy.js +13 -27
- package/dist/config/catalog/multi-channel-stock-location-strategy.js.map +1 -1
- package/dist/config/order/default-order-process.js +13 -1
- package/dist/config/order/default-order-process.js.map +1 -1
- package/dist/config/order/stock-allocation-strategy.d.ts +4 -0
- package/dist/entity/order-line/order-line.entity.d.ts +3 -29
- package/dist/entity/order-line/order-line.entity.js +20 -66
- package/dist/entity/order-line/order-line.entity.js.map +1 -1
- package/dist/event-bus/events/stock-shortfall-event.d.ts +40 -0
- package/dist/event-bus/events/stock-shortfall-event.js +29 -0
- package/dist/event-bus/events/stock-shortfall-event.js.map +1 -0
- package/dist/event-bus/index.d.ts +1 -0
- package/dist/event-bus/index.js +1 -0
- package/dist/event-bus/index.js.map +1 -1
- package/dist/migration-utils/index.d.ts +0 -1
- package/dist/migration-utils/index.js +1 -3
- package/dist/migration-utils/index.js.map +1 -1
- package/dist/service/helpers/order-modifier/order-modifier.d.ts +15 -2
- package/dist/service/helpers/order-modifier/order-modifier.js +37 -12
- package/dist/service/helpers/order-modifier/order-modifier.js.map +1 -1
- package/dist/service/helpers/utils/stock-lock-order.d.ts +11 -0
- package/dist/service/helpers/utils/stock-lock-order.js +22 -0
- package/dist/service/helpers/utils/stock-lock-order.js.map +1 -0
- package/dist/service/services/product-variant.service.d.ts +9 -2
- package/dist/service/services/product-variant.service.js +18 -2
- package/dist/service/services/product-variant.service.js.map +1 -1
- package/dist/service/services/stock-level.service.d.ts +124 -2
- package/dist/service/services/stock-level.service.js +181 -12
- package/dist/service/services/stock-level.service.js.map +1 -1
- package/dist/service/services/stock-movement.service.d.ts +9 -0
- package/dist/service/services/stock-movement.service.js +143 -50
- package/dist/service/services/stock-movement.service.js.map +1 -1
- package/package.json +2 -2
- package/dist/migration-utils/v3_8_orderline_promotion_rescale.d.ts +0 -57
- package/dist/migration-utils/v3_8_orderline_promotion_rescale.js +0 -232
- package/dist/migration-utils/v3_8_orderline_promotion_rescale.js.map +0 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vendure/core",
|
|
3
|
-
"version": "3.7.4
|
|
3
|
+
"version": "3.7.4",
|
|
4
4
|
"description": "A modern, headless ecommerce framework",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -51,7 +51,7 @@
|
|
|
51
51
|
"@nestjs/platform-express": "^11.0.12",
|
|
52
52
|
"@nestjs/typeorm": "^11.0.0",
|
|
53
53
|
"@types/express": "^5.0.1",
|
|
54
|
-
"@vendure/common": "
|
|
54
|
+
"@vendure/common": "3.7.4",
|
|
55
55
|
"bcrypt": "^6.0.0",
|
|
56
56
|
"cookie-session": "^2.1.0",
|
|
57
57
|
"cron-time-generator": "^2.0.3",
|
|
@@ -1,57 +0,0 @@
|
|
|
1
|
-
import { QueryRunner } from 'typeorm';
|
|
2
|
-
/**
|
|
3
|
-
* @description
|
|
4
|
-
* Options for {@link rescaleOrderLinePromotionAdjustments}.
|
|
5
|
-
*/
|
|
6
|
-
export interface RescaleOrderLinePromotionAdjustmentsOptions {
|
|
7
|
-
/**
|
|
8
|
-
* @description
|
|
9
|
-
* The quantity basis for each OrderLine whose cancellation and containing Order's latest
|
|
10
|
-
* modification have the same timestamp. Use the current quantity when the modification
|
|
11
|
-
* happened last, or the quantity before the later cancellation when the cancellation happened
|
|
12
|
-
* last.
|
|
13
|
-
*/
|
|
14
|
-
ambiguousOrderLineQuantityBases?: Readonly<Record<string, number>>;
|
|
15
|
-
}
|
|
16
|
-
/**
|
|
17
|
-
* @description
|
|
18
|
-
* Rescales `PROMOTION`-type `Adjustment`s on `order_line` rows that were partially
|
|
19
|
-
* cancelled by a pre-#5127 `cancelOrderByOrderLines()`, which reduced `quantity`
|
|
20
|
-
* without rescaling `adjustments`. Reading those rows with the fixed `OrderLine`
|
|
21
|
-
* getters (which divide a `PROMOTION` adjustment by the *current* `quantity`,
|
|
22
|
-
* instead of `orderPlacedQuantity`) would otherwise inflate their discount.
|
|
23
|
-
*
|
|
24
|
-
* `OrderModifier.modifyOrder()` ends in `applyPriceAdjustments()`, which recomputes the
|
|
25
|
-
* `PROMOTION` amounts for every line in the order, including lines not referenced by the
|
|
26
|
-
* `OrderModification`. For a subsequently-cancelled line, the stored basis is its current
|
|
27
|
-
* quantity plus the quantities in order-cancellation history after the order's latest
|
|
28
|
-
* `OrderModification`.
|
|
29
|
-
*
|
|
30
|
-
* Some databases can store a modification and cancellation with the same timestamp. Their
|
|
31
|
-
* order is then unknowable from persisted data, so the helper throws before writing anything.
|
|
32
|
-
* Inspect those lines and pass `ambiguousOrderLineQuantityBases`: use the current quantity if
|
|
33
|
-
* the modification happened last, or the quantity before cancellation if cancellation happened
|
|
34
|
-
* last.
|
|
35
|
-
*
|
|
36
|
-
* Call this from your migration's `up()` method - it needs no schema change, so it
|
|
37
|
-
* can run at any point in the migration.
|
|
38
|
-
*
|
|
39
|
-
* ```ts
|
|
40
|
-
* import { MigrationInterface, QueryRunner } from 'typeorm';
|
|
41
|
-
* import { rescaleOrderLinePromotionAdjustments } from '\@vendure/core';
|
|
42
|
-
*
|
|
43
|
-
* export class RescaleOrderLinePromotionAdjustments1234567890 implements MigrationInterface {
|
|
44
|
-
* public async up(queryRunner: QueryRunner): Promise<any> {
|
|
45
|
-
* await rescaleOrderLinePromotionAdjustments(queryRunner);
|
|
46
|
-
* }
|
|
47
|
-
*
|
|
48
|
-
* public async down(queryRunner: QueryRunner): Promise<any> {
|
|
49
|
-
* // This is a one-way data migration - the pre-migration amounts are not recoverable.
|
|
50
|
-
* }
|
|
51
|
-
* }
|
|
52
|
-
* ```
|
|
53
|
-
*
|
|
54
|
-
* @since 3.8.0
|
|
55
|
-
* @docsCategory migration
|
|
56
|
-
*/
|
|
57
|
-
export declare function rescaleOrderLinePromotionAdjustments(queryRunner: QueryRunner, options?: RescaleOrderLinePromotionAdjustmentsOptions): Promise<void>;
|
|
@@ -1,232 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.rescaleOrderLinePromotionAdjustments = rescaleOrderLinePromotionAdjustments;
|
|
4
|
-
/* eslint-disable no-console */
|
|
5
|
-
const generated_types_1 = require("@vendure/common/lib/generated-types");
|
|
6
|
-
const order_history_entry_entity_1 = require("../entity/history-entry/order-history-entry.entity");
|
|
7
|
-
const order_line_entity_1 = require("../entity/order-line/order-line.entity");
|
|
8
|
-
const order_modification_entity_1 = require("../entity/order-modification/order-modification.entity");
|
|
9
|
-
const UPDATE_CHUNK_SIZE = 100;
|
|
10
|
-
const AMBIGUOUS_BASIS = Symbol('AMBIGUOUS_BASIS');
|
|
11
|
-
function toTime(value) {
|
|
12
|
-
if (value == null) {
|
|
13
|
-
return null;
|
|
14
|
-
}
|
|
15
|
-
const time = value instanceof Date ? value.getTime() : new Date(value).getTime();
|
|
16
|
-
return Number.isNaN(time) ? null : time;
|
|
17
|
-
}
|
|
18
|
-
/**
|
|
19
|
-
* Returns the quantity that the row's stored `PROMOTION` amounts are scaled to, or `undefined`
|
|
20
|
-
* if they are already scaled to the current quantity and must be left alone.
|
|
21
|
-
*
|
|
22
|
-
* `PROMOTION` amounts are rewritten in full whenever `OrderCalculator` runs, which is what
|
|
23
|
-
* `OrderModifier.modifyOrder()` ends in for every line in the order. A pre-#5127
|
|
24
|
-
* `cancelOrderByOrderLines()` is the only thing that reduced `quantity` without rewriting them,
|
|
25
|
-
* so only a line whose most recent order-wide recalculation predates its cancellation is stale.
|
|
26
|
-
*/
|
|
27
|
-
function getStoredQuantityBasis(row, modifications, cancellations) {
|
|
28
|
-
if (modifications.length === 0) {
|
|
29
|
-
// Never modified, so the whole reduction came from cancellations and the amounts are
|
|
30
|
-
// still on the placement basis.
|
|
31
|
-
return row.orderPlacedQuantity;
|
|
32
|
-
}
|
|
33
|
-
const modificationTimes = modifications.map(modification => toTime(modification.createdAt));
|
|
34
|
-
const cancellationTimes = cancellations.map(cancellation => toTime(cancellation.createdAt));
|
|
35
|
-
if (modificationTimes.some(time => time == null) || cancellationTimes.some(time => time == null)) {
|
|
36
|
-
return AMBIGUOUS_BASIS;
|
|
37
|
-
}
|
|
38
|
-
const lastModifiedAt = Math.max(...modificationTimes);
|
|
39
|
-
if (cancellationTimes.includes(lastModifiedAt)) {
|
|
40
|
-
return AMBIGUOUS_BASIS;
|
|
41
|
-
}
|
|
42
|
-
const quantityCancelledAfterModification = cancellations
|
|
43
|
-
.filter((_cancellation, index) => cancellationTimes[index] > lastModifiedAt)
|
|
44
|
-
.reduce((total, cancellation) => total + cancellation.quantity, 0);
|
|
45
|
-
return quantityCancelledAfterModification > 0
|
|
46
|
-
? row.quantity + quantityCancelledAfterModification
|
|
47
|
-
: undefined;
|
|
48
|
-
}
|
|
49
|
-
function parseCancellationLines(row) {
|
|
50
|
-
const data = typeof row.data === 'string' ? JSON.parse(row.data) : row.data;
|
|
51
|
-
return Array.isArray(data === null || data === void 0 ? void 0 : data.lines) ? data.lines : [];
|
|
52
|
-
}
|
|
53
|
-
function getColumnName(metadata, propertyName) {
|
|
54
|
-
const column = metadata.findColumnWithPropertyName(propertyName);
|
|
55
|
-
if (!column) {
|
|
56
|
-
throw new Error(`Could not find ${metadata.name}.${propertyName} column metadata.`);
|
|
57
|
-
}
|
|
58
|
-
return column.databaseName;
|
|
59
|
-
}
|
|
60
|
-
function getRelationColumnName(metadata, propertyName) {
|
|
61
|
-
var _a;
|
|
62
|
-
const column = (_a = metadata.findRelationWithPropertyPath(propertyName)) === null || _a === void 0 ? void 0 : _a.joinColumns[0];
|
|
63
|
-
if (!column) {
|
|
64
|
-
throw new Error(`Could not find ${metadata.name}.${propertyName} relation column metadata.`);
|
|
65
|
-
}
|
|
66
|
-
return column.databaseName;
|
|
67
|
-
}
|
|
68
|
-
/**
|
|
69
|
-
* @description
|
|
70
|
-
* Rescales `PROMOTION`-type `Adjustment`s on `order_line` rows that were partially
|
|
71
|
-
* cancelled by a pre-#5127 `cancelOrderByOrderLines()`, which reduced `quantity`
|
|
72
|
-
* without rescaling `adjustments`. Reading those rows with the fixed `OrderLine`
|
|
73
|
-
* getters (which divide a `PROMOTION` adjustment by the *current* `quantity`,
|
|
74
|
-
* instead of `orderPlacedQuantity`) would otherwise inflate their discount.
|
|
75
|
-
*
|
|
76
|
-
* `OrderModifier.modifyOrder()` ends in `applyPriceAdjustments()`, which recomputes the
|
|
77
|
-
* `PROMOTION` amounts for every line in the order, including lines not referenced by the
|
|
78
|
-
* `OrderModification`. For a subsequently-cancelled line, the stored basis is its current
|
|
79
|
-
* quantity plus the quantities in order-cancellation history after the order's latest
|
|
80
|
-
* `OrderModification`.
|
|
81
|
-
*
|
|
82
|
-
* Some databases can store a modification and cancellation with the same timestamp. Their
|
|
83
|
-
* order is then unknowable from persisted data, so the helper throws before writing anything.
|
|
84
|
-
* Inspect those lines and pass `ambiguousOrderLineQuantityBases`: use the current quantity if
|
|
85
|
-
* the modification happened last, or the quantity before cancellation if cancellation happened
|
|
86
|
-
* last.
|
|
87
|
-
*
|
|
88
|
-
* Call this from your migration's `up()` method - it needs no schema change, so it
|
|
89
|
-
* can run at any point in the migration.
|
|
90
|
-
*
|
|
91
|
-
* ```ts
|
|
92
|
-
* import { MigrationInterface, QueryRunner } from 'typeorm';
|
|
93
|
-
* import { rescaleOrderLinePromotionAdjustments } from '\@vendure/core';
|
|
94
|
-
*
|
|
95
|
-
* export class RescaleOrderLinePromotionAdjustments1234567890 implements MigrationInterface {
|
|
96
|
-
* public async up(queryRunner: QueryRunner): Promise<any> {
|
|
97
|
-
* await rescaleOrderLinePromotionAdjustments(queryRunner);
|
|
98
|
-
* }
|
|
99
|
-
*
|
|
100
|
-
* public async down(queryRunner: QueryRunner): Promise<any> {
|
|
101
|
-
* // This is a one-way data migration - the pre-migration amounts are not recoverable.
|
|
102
|
-
* }
|
|
103
|
-
* }
|
|
104
|
-
* ```
|
|
105
|
-
*
|
|
106
|
-
* @since 3.8.0
|
|
107
|
-
* @docsCategory migration
|
|
108
|
-
*/
|
|
109
|
-
async function rescaleOrderLinePromotionAdjustments(queryRunner, options = {}) {
|
|
110
|
-
var _a, _b, _c, _d, _e;
|
|
111
|
-
const esc = (name) => queryRunner.connection.driver.escape(name);
|
|
112
|
-
const escTable = (tablePath) => tablePath.split('.').map(esc).join('.');
|
|
113
|
-
const param = (index) => queryRunner.connection.driver.createParameter('p', index);
|
|
114
|
-
const orderLineMetadata = queryRunner.connection.getMetadata(order_line_entity_1.OrderLine);
|
|
115
|
-
const modificationMetadata = queryRunner.connection.getMetadata(order_modification_entity_1.OrderModification);
|
|
116
|
-
const historyMetadata = queryRunner.connection.getMetadata(order_history_entry_entity_1.OrderHistoryEntry);
|
|
117
|
-
const orderLineTable = escTable(orderLineMetadata.tablePath);
|
|
118
|
-
const orderLineId = esc(getColumnName(orderLineMetadata, 'id'));
|
|
119
|
-
const orderLineOrderId = esc(getRelationColumnName(orderLineMetadata, 'order'));
|
|
120
|
-
const orderLineQuantity = esc(getColumnName(orderLineMetadata, 'quantity'));
|
|
121
|
-
const orderLinePlacedQuantity = esc(getColumnName(orderLineMetadata, 'orderPlacedQuantity'));
|
|
122
|
-
const orderLineAdjustments = esc(getColumnName(orderLineMetadata, 'adjustments'));
|
|
123
|
-
const modificationTable = escTable(modificationMetadata.tablePath);
|
|
124
|
-
const modificationOrderId = esc(getRelationColumnName(modificationMetadata, 'order'));
|
|
125
|
-
const modificationCreatedAt = esc(getColumnName(modificationMetadata, 'createdAt'));
|
|
126
|
-
const historyTable = escTable(historyMetadata.tablePath);
|
|
127
|
-
const historyOrderId = esc(getRelationColumnName(historyMetadata, 'order'));
|
|
128
|
-
const historyCreatedAt = esc(getColumnName(historyMetadata, 'createdAt'));
|
|
129
|
-
const historyData = esc(getColumnName(historyMetadata, 'data'));
|
|
130
|
-
const historyType = esc(getColumnName(historyMetadata, 'type'));
|
|
131
|
-
const rows = await queryRunner.query(`SELECT ol.${orderLineId} AS ${esc('id')},
|
|
132
|
-
ol.${orderLineOrderId} AS ${esc('orderId')},
|
|
133
|
-
ol.${orderLineQuantity} AS ${esc('quantity')},
|
|
134
|
-
ol.${orderLinePlacedQuantity} AS ${esc('orderPlacedQuantity')},
|
|
135
|
-
ol.${orderLineAdjustments} AS ${esc('adjustments')}
|
|
136
|
-
FROM ${orderLineTable} ol
|
|
137
|
-
WHERE ol.${orderLineQuantity} < ol.${orderLinePlacedQuantity}
|
|
138
|
-
AND ol.${orderLineQuantity} > 0
|
|
139
|
-
AND ol.${orderLinePlacedQuantity} > 0`);
|
|
140
|
-
const modifications = await queryRunner.query(`SELECT om.${modificationOrderId} AS ${esc('orderId')},
|
|
141
|
-
om.${modificationCreatedAt} AS ${esc('createdAt')}
|
|
142
|
-
FROM ${modificationTable} om
|
|
143
|
-
WHERE EXISTS (
|
|
144
|
-
SELECT 1 FROM ${orderLineTable} ol
|
|
145
|
-
WHERE ol.${orderLineOrderId} = om.${modificationOrderId}
|
|
146
|
-
AND ol.${orderLineQuantity} < ol.${orderLinePlacedQuantity}
|
|
147
|
-
AND ol.${orderLineQuantity} > 0
|
|
148
|
-
AND ol.${orderLinePlacedQuantity} > 0
|
|
149
|
-
)`);
|
|
150
|
-
const cancellationHistory = await queryRunner.query(`SELECT h.${historyCreatedAt} AS ${esc('createdAt')},
|
|
151
|
-
h.${historyData} AS ${esc('data')}
|
|
152
|
-
FROM ${historyTable} h
|
|
153
|
-
WHERE h.${historyType} = ${param(0)}
|
|
154
|
-
AND EXISTS (
|
|
155
|
-
SELECT 1 FROM ${orderLineTable} ol
|
|
156
|
-
WHERE ol.${orderLineOrderId} = h.${historyOrderId}
|
|
157
|
-
AND ol.${orderLineQuantity} < ol.${orderLinePlacedQuantity}
|
|
158
|
-
AND ol.${orderLineQuantity} > 0
|
|
159
|
-
AND ol.${orderLinePlacedQuantity} > 0
|
|
160
|
-
)`, [generated_types_1.HistoryEntryType.ORDER_CANCELLATION]);
|
|
161
|
-
const modificationsByOrderId = new Map();
|
|
162
|
-
for (const modification of modifications) {
|
|
163
|
-
const orderId = String(modification.orderId);
|
|
164
|
-
modificationsByOrderId.set(orderId, [...((_a = modificationsByOrderId.get(orderId)) !== null && _a !== void 0 ? _a : []), modification]);
|
|
165
|
-
}
|
|
166
|
-
const cancellationsByLineId = new Map();
|
|
167
|
-
for (const historyRow of cancellationHistory) {
|
|
168
|
-
for (const line of parseCancellationLines(historyRow)) {
|
|
169
|
-
const lineId = String(line.orderLineId);
|
|
170
|
-
cancellationsByLineId.set(lineId, [
|
|
171
|
-
...((_b = cancellationsByLineId.get(lineId)) !== null && _b !== void 0 ? _b : []),
|
|
172
|
-
{ createdAt: historyRow.createdAt, quantity: Number(line.quantity) },
|
|
173
|
-
]);
|
|
174
|
-
}
|
|
175
|
-
}
|
|
176
|
-
const updates = [];
|
|
177
|
-
const unresolvedLineIds = [];
|
|
178
|
-
for (const row of rows) {
|
|
179
|
-
if (row.quantity <= 0 || !row.adjustments) {
|
|
180
|
-
continue;
|
|
181
|
-
}
|
|
182
|
-
const adjustments = JSON.parse(row.adjustments);
|
|
183
|
-
if (!Array.isArray(adjustments) || !adjustments.some((a) => a.type === 'PROMOTION')) {
|
|
184
|
-
continue;
|
|
185
|
-
}
|
|
186
|
-
const lineId = String(row.id);
|
|
187
|
-
const inferredBasis = getStoredQuantityBasis(row, (_c = modificationsByOrderId.get(String(row.orderId))) !== null && _c !== void 0 ? _c : [], (_d = cancellationsByLineId.get(lineId)) !== null && _d !== void 0 ? _d : []);
|
|
188
|
-
let basis;
|
|
189
|
-
if (inferredBasis === AMBIGUOUS_BASIS) {
|
|
190
|
-
const configuredBasis = (_e = options.ambiguousOrderLineQuantityBases) === null || _e === void 0 ? void 0 : _e[lineId];
|
|
191
|
-
if (configuredBasis == null) {
|
|
192
|
-
unresolvedLineIds.push(row.id);
|
|
193
|
-
continue;
|
|
194
|
-
}
|
|
195
|
-
if (!Number.isInteger(configuredBasis) || configuredBasis < row.quantity) {
|
|
196
|
-
throw new Error(`The configured quantity basis for OrderLine ${row.id} must be an integer greater than or equal to its current quantity (${row.quantity}).`);
|
|
197
|
-
}
|
|
198
|
-
basis = configuredBasis;
|
|
199
|
-
}
|
|
200
|
-
else {
|
|
201
|
-
basis = inferredBasis;
|
|
202
|
-
}
|
|
203
|
-
if (!basis || basis === row.quantity) {
|
|
204
|
-
continue;
|
|
205
|
-
}
|
|
206
|
-
const scaleFactor = row.quantity / basis;
|
|
207
|
-
const rescaledAdjustments = adjustments.map((adjustment) => adjustment.type === 'PROMOTION'
|
|
208
|
-
? Object.assign(Object.assign({}, adjustment), { amount: Math.round(adjustment.amount * scaleFactor) }) : adjustment);
|
|
209
|
-
updates.push({ id: row.id, adjustments: JSON.stringify(rescaledAdjustments) });
|
|
210
|
-
}
|
|
211
|
-
if (unresolvedLineIds.length > 0) {
|
|
212
|
-
throw new Error(`Cannot safely determine the stored quantity basis for OrderLine IDs: ${unresolvedLineIds.join(', ')}. ` +
|
|
213
|
-
'Pass ambiguousOrderLineQuantityBases for each listed ID before rerunning this migration.');
|
|
214
|
-
}
|
|
215
|
-
for (let offset = 0; offset < updates.length; offset += UPDATE_CHUNK_SIZE) {
|
|
216
|
-
const chunk = updates.slice(offset, offset + UPDATE_CHUNK_SIZE);
|
|
217
|
-
const params = [];
|
|
218
|
-
const whenClauses = chunk
|
|
219
|
-
.map(update => {
|
|
220
|
-
const idParam = param(params.push(update.id) - 1);
|
|
221
|
-
const adjustmentsParam = param(params.push(update.adjustments) - 1);
|
|
222
|
-
return `WHEN ${idParam} THEN ${adjustmentsParam}`;
|
|
223
|
-
})
|
|
224
|
-
.join(' ');
|
|
225
|
-
const idParams = chunk.map(update => param(params.push(update.id) - 1)).join(', ');
|
|
226
|
-
await queryRunner.query(`UPDATE ${orderLineTable}
|
|
227
|
-
SET ${orderLineAdjustments} = CASE ${orderLineId} ${whenClauses} END
|
|
228
|
-
WHERE ${orderLineId} IN (${idParams})`, params);
|
|
229
|
-
}
|
|
230
|
-
console.log(`Rescaled PROMOTION adjustments on ${updates.length} partially-cancelled OrderLine row(s).`);
|
|
231
|
-
}
|
|
232
|
-
//# sourceMappingURL=v3_8_orderline_promotion_rescale.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"v3_8_orderline_promotion_rescale.js","sourceRoot":"","sources":["../../src/migration-utils/v3_8_orderline_promotion_rescale.ts"],"names":[],"mappings":";;AA2JA,oFAwJC;AAnTD,+BAA+B;AAC/B,yEAAuE;AAGvE,mGAAuF;AACvF,8EAAmE;AACnE,sGAA2F;AAyB3F,MAAM,iBAAiB,GAAG,GAAG,CAAC;AAC9B,MAAM,eAAe,GAAG,MAAM,CAAC,iBAAiB,CAAC,CAAC;AAiBlD,SAAS,MAAM,CAAC,KAA2B;IACvC,IAAI,KAAK,IAAI,IAAI,EAAE,CAAC;QAChB,OAAO,IAAI,CAAC;IAChB,CAAC;IACD,MAAM,IAAI,GAAG,KAAK,YAAY,IAAI,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,EAAE,CAAC,CAAC,CAAC,IAAI,IAAI,CAAC,KAAK,CAAC,CAAC,OAAO,EAAE,CAAC;IACjF,OAAO,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC;AAC5C,CAAC;AAED;;;;;;;;GAQG;AACH,SAAS,sBAAsB,CAC3B,GAAiB,EACjB,aAAgC,EAChC,aAAkC;IAElC,IAAI,aAAa,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QAC7B,qFAAqF;QACrF,gCAAgC;QA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