@aglyn/plugins-commerce 1.10.0 → 1.12.0
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 +13 -13
- package/src/lib/components/console/host-quotes-card.component.js +20 -11
- package/src/lib/components/console/host-quotes-card.component.js.map +1 -1
- package/src/lib/components/console/invoice-send.component.d.ts +9 -2
- package/src/lib/components/console/invoice-send.component.js +58 -30
- package/src/lib/components/console/invoice-send.component.js.map +1 -1
- package/src/lib/components/console/pay-link-readiness-notice.component.d.ts +84 -0
- package/src/lib/components/console/pay-link-readiness-notice.component.js +164 -0
- package/src/lib/components/console/pay-link-readiness-notice.component.js.map +1 -0
- package/src/lib/components/console/pos-kiosk/kiosk-menu.d.ts +10 -3
- package/src/lib/components/console/pos-kiosk/kiosk-menu.js +29 -8
- package/src/lib/components/console/pos-kiosk/kiosk-menu.js.map +1 -1
- package/src/lib/components/console/pos-kiosk/pos-kiosk-api.d.ts +2 -0
- package/src/lib/components/console/pos-kiosk/pos-kiosk-api.js +7 -0
- package/src/lib/components/console/pos-kiosk/pos-kiosk-api.js.map +1 -1
- package/src/lib/components/console/pos-kiosk-page.component.d.ts +2 -0
- package/src/lib/components/console/pos-kiosk-page.component.js +54 -3
- package/src/lib/components/console/pos-kiosk-page.component.js.map +1 -1
- package/src/lib/components/console/product-add-ons-fields.component.d.ts +0 -2
- package/src/lib/components/console/product-add-ons-fields.component.js +1 -6
- package/src/lib/components/console/product-add-ons-fields.component.js.map +1 -1
- package/src/lib/components/console/quote-editor-dialog.component.d.ts +2 -0
- package/src/lib/components/console/quote-editor-dialog.component.js +35 -27
- package/src/lib/components/console/quote-editor-dialog.component.js.map +1 -1
- package/src/lib/components/console/quote-pay-link.component.d.ts +3 -0
- package/src/lib/components/console/quote-pay-link.component.js +9 -0
- package/src/lib/components/console/quote-pay-link.component.js.map +1 -1
- package/src/lib/components/console/quote-send.component.d.ts +3 -0
- package/src/lib/components/console/quote-send.component.js +9 -0
- package/src/lib/components/console/quote-send.component.js.map +1 -1
- package/src/lib/components/product-detail.js +1 -1
- package/src/lib/components/product-detail.js.map +1 -1
- package/src/lib/components/product-grid.js +5 -3
- package/src/lib/components/product-grid.js.map +1 -1
- package/src/lib/components/product-reviews.js +17 -12
- package/src/lib/components/product-reviews.js.map +1 -1
- package/src/lib/components/quote-page-body.js +5 -3
- package/src/lib/components/quote-page-body.js.map +1 -1
- package/src/lib/components/related-products.js +2 -1
- package/src/lib/components/related-products.js.map +1 -1
- package/src/lib/model/commerce-invoices.d.ts +45 -5
- package/src/lib/model/commerce-invoices.js +46 -9
- package/src/lib/model/commerce-invoices.js.map +1 -1
- package/src/lib/model/commerce-kiosk-search.d.ts +22 -0
- package/src/lib/model/commerce-kiosk-search.js +32 -0
- package/src/lib/model/commerce-kiosk-search.js.map +1 -0
- package/src/lib/model/commerce-pos-kiosk.d.ts +7 -1
- package/src/lib/model/commerce-pos-kiosk.js +1 -1
- package/src/lib/model/commerce-pos-kiosk.js.map +1 -1
- package/src/lib/model/commerce-quote-pay.d.ts +110 -6
- package/src/lib/model/commerce-quote-pay.js +182 -23
- package/src/lib/model/commerce-quote-pay.js.map +1 -1
- package/src/lib/model/product-modifiers.d.ts +4 -0
- package/src/lib/model/product-modifiers.js +5 -0
- package/src/lib/model/product-modifiers.js.map +1 -1
- package/src/lib/server/billing-webhook.js +4 -1
- package/src/lib/server/billing-webhook.js.map +1 -1
- package/src/lib/server/commerce-pdf.js +2 -1
- package/src/lib/server/commerce-pdf.js.map +1 -1
- package/src/lib/server/invoice-email.js +2 -1
- package/src/lib/server/invoice-email.js.map +1 -1
- package/src/lib/server/order-invoice-send.js +1 -1
- package/src/lib/server/order-invoice-send.js.map +1 -1
- package/src/lib/server/order-status.d.ts +5 -1
- package/src/lib/server/order-status.js +19 -5
- package/src/lib/server/order-status.js.map +1 -1
- package/src/lib/server/pos-kiosk.js +70 -15
- package/src/lib/server/pos-kiosk.js.map +1 -1
- package/src/lib/server/quote-email.js +2 -1
- package/src/lib/server/quote-email.js.map +1 -1
- package/src/lib/server/quote-pay.d.ts +39 -0
- package/src/lib/server/quote-pay.js +103 -43
- package/src/lib/server/quote-pay.js.map +1 -1
- package/src/lib/server/quote-proofs.js +20 -11
- package/src/lib/server/quote-proofs.js.map +1 -1
- package/src/lib/server/site-page-enricher.js +5 -1
- package/src/lib/server/site-page-enricher.js.map +1 -1
- package/src/lib/testing/fake-firestore.js +34 -5
- package/src/lib/testing/fake-firestore.js.map +1 -1
- package/src/lib/transfer/product-register-cells.d.ts +75 -0
- package/src/lib/transfer/product-register-cells.js +487 -0
- package/src/lib/transfer/product-register-cells.js.map +1 -0
- package/src/lib/transfer/product-transfer.d.ts +12 -0
- package/src/lib/transfer/product-transfer.js +174 -10
- package/src/lib/transfer/product-transfer.js.map +1 -1
- package/src/lib/transfer/products.server.js +24 -9
- package/src/lib/transfer/products.server.js.map +1 -1
- package/src/lib/utils/invoice-email-content.d.ts +3 -1
- package/src/lib/utils/invoice-email-content.js +1 -1
- package/src/lib/utils/invoice-email-content.js.map +1 -1
- package/src/lib/utils/quote-email-content.d.ts +3 -1
- package/src/lib/utils/quote-email-content.js +3 -3
- package/src/lib/utils/quote-email-content.js.map +1 -1
|
@@ -16,7 +16,8 @@ import { _ as _object_without_properties_loose } from "@swc/helpers/_/_object_wi
|
|
|
16
16
|
* See the License for the specific language governing permissions and
|
|
17
17
|
* limitations under the License.
|
|
18
18
|
*/ import { buildTransferPlan, isBlankTransferValue, TRANSFER_SYSTEM_GROUP, TRANSFER_WARNING_CLASSES } from "@aglyn/aglyn/data-transfer";
|
|
19
|
-
import { COMMERCE_MAX_VARIANTS, COMMERCE_SLUG_MAX_LENGTH, commerceSlug, productInventory, productPriceRange, validateProduct } from "../model/commerce.js";
|
|
19
|
+
import { COMMERCE_MAX_VARIANTS, COMMERCE_SLUG_MAX_LENGTH, commerceSlug, productInventory, productPriceRange, validateProduct, variantMatrixProblem } from "../model/commerce.js";
|
|
20
|
+
import { addOnCellOf, addOnVariantIds, checkInCellOf, checkInFromCell, modifierGroupsFromAddOnCell, readAddOnCell, readCheckInCell, writeAddOnCell, writeCheckInCell } from "./product-register-cells.js";
|
|
20
21
|
/*
|
|
21
22
|
* PRODUCTS ON THE TRANSFER FRAMEWORK (AGL-3531).
|
|
22
23
|
*
|
|
@@ -47,6 +48,13 @@ import { COMMERCE_MAX_VARIANTS, COMMERCE_SLUG_MAX_LENGTH, commerceSlug, productI
|
|
|
47
48
|
* finds what it already wrote — the variant's, and for a new product the
|
|
48
49
|
* whole document.
|
|
49
50
|
*
|
|
51
|
+
* ## Add-ons, check-in and quick keys
|
|
52
|
+
*
|
|
53
|
+
* The register's settings travel as plain cells (`product-register-cells.ts`).
|
|
54
|
+
* A file without their columns never touches them, and an add-ons cell is
|
|
55
|
+
* asked the questions the product editor's Save asks: `validateProduct` and
|
|
56
|
+
* the 100-combination rule, `variantMatrixProblem`.
|
|
57
|
+
*
|
|
50
58
|
* ## What a file never sets
|
|
51
59
|
*
|
|
52
60
|
* Option names already on a product (renaming one moves every variant, which
|
|
@@ -72,6 +80,9 @@ import { COMMERCE_MAX_VARIANTS, COMMERCE_SLUG_MAX_LENGTH, commerceSlug, productI
|
|
|
72
80
|
taxExempt: 'taxExempt',
|
|
73
81
|
oversellPolicy: 'oversellPolicy',
|
|
74
82
|
lowStockThreshold: 'lowStockThreshold',
|
|
83
|
+
posQuickKey: 'posQuickKey',
|
|
84
|
+
checkIn: 'checkIn',
|
|
85
|
+
modifierGroups: 'modifierGroups',
|
|
75
86
|
option1Value: 'option1Value',
|
|
76
87
|
option2Value: 'option2Value',
|
|
77
88
|
option3Value: 'option3Value',
|
|
@@ -82,6 +93,7 @@ import { COMMERCE_MAX_VARIANTS, COMMERCE_SLUG_MAX_LENGTH, commerceSlug, productI
|
|
|
82
93
|
inventory: 'inventory',
|
|
83
94
|
weightGrams: 'weightGrams',
|
|
84
95
|
variantImage: 'variantImage',
|
|
96
|
+
variantCheckIn: 'variantCheckIn',
|
|
85
97
|
priceFrom: 'priceFrom',
|
|
86
98
|
totalInventory: 'totalInventory',
|
|
87
99
|
soldOut: 'soldOut',
|
|
@@ -183,7 +195,19 @@ export const PRODUCT_TRANSFER_GROUPS = [
|
|
|
183
195
|
F.seoDescription,
|
|
184
196
|
F.taxExempt,
|
|
185
197
|
F.oversellPolicy,
|
|
186
|
-
F.lowStockThreshold
|
|
198
|
+
F.lowStockThreshold,
|
|
199
|
+
F.posQuickKey,
|
|
200
|
+
F.checkIn,
|
|
201
|
+
F.modifierGroups
|
|
202
|
+
];
|
|
203
|
+
/**
|
|
204
|
+
* The product fields a file may give on any of a product's rows: one value
|
|
205
|
+
* for the product, the first row's if it has one. A different value further
|
|
206
|
+
* down is reported, never dropped without a word.
|
|
207
|
+
*/ const REGISTER_PRODUCT_FIELDS = [
|
|
208
|
+
F.posQuickKey,
|
|
209
|
+
F.checkIn,
|
|
210
|
+
F.modifierGroups
|
|
187
211
|
];
|
|
188
212
|
/** The fields every row carries for its own variant. */ export const VARIANT_LEVEL_FIELDS = [
|
|
189
213
|
F.option1Value,
|
|
@@ -195,7 +219,8 @@ export const PRODUCT_TRANSFER_GROUPS = [
|
|
|
195
219
|
F.compareAtPrice,
|
|
196
220
|
F.inventory,
|
|
197
221
|
F.weightGrams,
|
|
198
|
-
F.variantImage
|
|
222
|
+
F.variantImage,
|
|
223
|
+
F.variantCheckIn
|
|
199
224
|
];
|
|
200
225
|
const OPTION_NAME_FIELDS = [
|
|
201
226
|
F.option1Name,
|
|
@@ -427,6 +452,17 @@ const OPTION_VALUE_FIELDS = [
|
|
|
427
452
|
'variant image url'
|
|
428
453
|
]
|
|
429
454
|
},
|
|
455
|
+
{
|
|
456
|
+
id: F.variantCheckIn,
|
|
457
|
+
label: 'Variant check-in',
|
|
458
|
+
group: 'variant',
|
|
459
|
+
type: 'text',
|
|
460
|
+
aliases: [
|
|
461
|
+
'variant needs check-in',
|
|
462
|
+
'variant check in'
|
|
463
|
+
],
|
|
464
|
+
description: 'This variant’s own check-in, in the words of Check-in. Blank follows the product.'
|
|
465
|
+
},
|
|
430
466
|
{
|
|
431
467
|
id: F.image,
|
|
432
468
|
label: 'Image',
|
|
@@ -493,6 +529,43 @@ const OPTION_VALUE_FIELDS = [
|
|
|
493
529
|
'low stock threshold',
|
|
494
530
|
'reorder point'
|
|
495
531
|
]
|
|
532
|
+
},
|
|
533
|
+
{
|
|
534
|
+
id: F.posQuickKey,
|
|
535
|
+
label: 'Quick key',
|
|
536
|
+
group: 'selling',
|
|
537
|
+
type: 'boolean',
|
|
538
|
+
aliases: [
|
|
539
|
+
'quick key at the register',
|
|
540
|
+
'pos quick key',
|
|
541
|
+
'register quick key'
|
|
542
|
+
],
|
|
543
|
+
description: 'Yes shows the product under Quick keys on the register’s first screen.'
|
|
544
|
+
},
|
|
545
|
+
{
|
|
546
|
+
id: F.checkIn,
|
|
547
|
+
label: 'Check-in',
|
|
548
|
+
group: 'selling',
|
|
549
|
+
type: 'text',
|
|
550
|
+
aliases: [
|
|
551
|
+
'needs check-in',
|
|
552
|
+
'check in',
|
|
553
|
+
'checkin'
|
|
554
|
+
],
|
|
555
|
+
description: 'No or Yes. Yes can add how many people one item admits and asking the day: Yes, 4 people, ask which day.'
|
|
556
|
+
},
|
|
557
|
+
{
|
|
558
|
+
id: F.modifierGroups,
|
|
559
|
+
label: 'Add-ons',
|
|
560
|
+
group: 'selling',
|
|
561
|
+
type: 'longText',
|
|
562
|
+
aliases: [
|
|
563
|
+
'add ons',
|
|
564
|
+
'addons',
|
|
565
|
+
'modifiers',
|
|
566
|
+
'modifier groups'
|
|
567
|
+
],
|
|
568
|
+
description: 'Groups split by semicolons: Milk (at least 1): Whole, Oat +$0.75; Extras (at most 3, register only): Extra shot +$1.00.'
|
|
496
569
|
}
|
|
497
570
|
];
|
|
498
571
|
export const PRODUCT_DERIVED_FIELDS = [
|
|
@@ -673,6 +746,9 @@ const isoOf = (value, ms)=>{
|
|
|
673
746
|
values[fieldId] = name ? (_ref = (_variant_options = variant.options) == null ? void 0 : _variant_options[name]) != null ? _ref : null : null;
|
|
674
747
|
});
|
|
675
748
|
if (variant.inventoryByLocation && Object.keys(variant.inventoryByLocation).length) values.$byLocation = true;
|
|
749
|
+
// Only when set: an undo snapshot written before this column compares equal.
|
|
750
|
+
const checkIn = checkInCellOf(variant.checkIn);
|
|
751
|
+
if (checkIn) values[F.variantCheckIn] = checkIn;
|
|
676
752
|
return values;
|
|
677
753
|
}
|
|
678
754
|
/**
|
|
@@ -681,7 +757,7 @@ const isoOf = (value, ms)=>{
|
|
|
681
757
|
* them. The lookup answers this shape, so the dry run's before → after and
|
|
682
758
|
* undo's "edited since" both read a product the way a file names it.
|
|
683
759
|
*/ export function productRecord(stored, categoryNames = new Map()) {
|
|
684
|
-
var _product_options, _product_slug, _product_name, _product_description, _product_type, _product_status, _product_status1, _product_categoryIds, _ref, _ref1, _product_taxExempt, _product_oversellPolicy, _product_lowStockThreshold;
|
|
760
|
+
var _product_options, _product_slug, _product_name, _product_description, _product_type, _product_status, _product_status1, _product_categoryIds, _ref, _ref1, _product_taxExempt, _product_oversellPolicy, _product_lowStockThreshold, _product_posQuickKey;
|
|
685
761
|
var _product_tags, _product_mediaUrls, _product_seo, _product_seo1;
|
|
686
762
|
const product = stored;
|
|
687
763
|
const options = (_product_options = product.options) != null ? _product_options : [];
|
|
@@ -712,6 +788,9 @@ const isoOf = (value, ms)=>{
|
|
|
712
788
|
[F.taxExempt]: (_product_taxExempt = product.taxExempt) != null ? _product_taxExempt : null,
|
|
713
789
|
[F.oversellPolicy]: fixedListLabel(PRODUCT_OVERSELL_PICKLIST, (_product_oversellPolicy = product.oversellPolicy) != null ? _product_oversellPolicy : 'deny'),
|
|
714
790
|
[F.lowStockThreshold]: (_product_lowStockThreshold = product.lowStockThreshold) != null ? _product_lowStockThreshold : null,
|
|
791
|
+
[F.posQuickKey]: (_product_posQuickKey = product.posQuickKey) != null ? _product_posQuickKey : null,
|
|
792
|
+
[F.checkIn]: checkInCellOf(product.checkIn),
|
|
793
|
+
[F.modifierGroups]: addOnCellOf(product.modifierGroups, variants),
|
|
715
794
|
[F.priceFrom]: low,
|
|
716
795
|
[F.totalInventory]: total,
|
|
717
796
|
[F.soldOut]: total !== null && total <= 0 && product.oversellPolicy !== 'backorder',
|
|
@@ -862,6 +941,20 @@ const text = (value)=>value === null || value === undefined ? '' : String(value)
|
|
|
862
941
|
if (slug) values[F.handle] = slug;
|
|
863
942
|
else drop(F.handle, 'invalidUrl', `"${text(values[F.handle])}" has no letters or numbers to make a handle from.`);
|
|
864
943
|
}
|
|
944
|
+
for (const fieldId of [
|
|
945
|
+
F.checkIn,
|
|
946
|
+
F.variantCheckIn
|
|
947
|
+
]){
|
|
948
|
+
if (isBlankTransferValue(values[fieldId])) continue;
|
|
949
|
+
const read = readCheckInCell(values[fieldId]);
|
|
950
|
+
if ('message' in read) drop(fieldId, 'invalidJson', read.message);
|
|
951
|
+
else values[fieldId] = writeCheckInCell(read.value);
|
|
952
|
+
}
|
|
953
|
+
if (!isBlankTransferValue(values[F.modifierGroups])) {
|
|
954
|
+
const read = readAddOnCell(values[F.modifierGroups]);
|
|
955
|
+
if ('message' in read) drop(F.modifierGroups, 'invalidJson', read.message);
|
|
956
|
+
else values[F.modifierGroups] = writeAddOnCell(read.value);
|
|
957
|
+
}
|
|
865
958
|
if (F.published in values) {
|
|
866
959
|
if (isBlankTransferValue(values[F.status]) && typeof values[F.published] === 'boolean') {
|
|
867
960
|
values[F.status] = values[F.published] ? STATUS_LABELS.active : STATUS_LABELS.draft;
|
|
@@ -977,6 +1070,7 @@ const hasAny = (values, fieldIds)=>fieldIds.some((fieldId)=>!isBlankTransferValu
|
|
|
977
1070
|
values: seen
|
|
978
1071
|
});
|
|
979
1072
|
});
|
|
1073
|
+
const checkIn = isBlankTransferValue(values[F.checkIn]) ? undefined : checkInFromCell(values[F.checkIn]);
|
|
980
1074
|
return _extends({
|
|
981
1075
|
name: text(values[F.title]),
|
|
982
1076
|
slug: text(values[F.handle]),
|
|
@@ -984,6 +1078,8 @@ const hasAny = (values, fieldIds)=>fieldIds.some((fieldId)=>!isBlankTransferValu
|
|
|
984
1078
|
status: (_fixedListId1 = fixedListId(PRODUCT_STATUS_PICKLIST, values[F.status])) != null ? _fixedListId1 : 'active'
|
|
985
1079
|
}, options.length ? {
|
|
986
1080
|
options
|
|
1081
|
+
} : {}, checkIn ? {
|
|
1082
|
+
checkIn
|
|
987
1083
|
} : {}, {
|
|
988
1084
|
variants: variants.map((variant)=>variantFromRecord(variant.id, variant.values, names))
|
|
989
1085
|
});
|
|
@@ -1000,6 +1096,7 @@ const hasAny = (values, fieldIds)=>fieldIds.some((fieldId)=>!isBlankTransferValu
|
|
|
1000
1096
|
return raw === null || raw === undefined || raw === '' || !Number.isFinite(Number(raw)) ? undefined : Number(raw);
|
|
1001
1097
|
};
|
|
1002
1098
|
const inventory = number(F.inventory);
|
|
1099
|
+
const checkIn = isBlankTransferValue(values[F.variantCheckIn]) ? undefined : checkInFromCell(values[F.variantCheckIn]);
|
|
1003
1100
|
return _extends({
|
|
1004
1101
|
id
|
|
1005
1102
|
}, Object.keys(options).length ? {
|
|
@@ -1018,7 +1115,9 @@ const hasAny = (values, fieldIds)=>fieldIds.some((fieldId)=>!isBlankTransferValu
|
|
|
1018
1115
|
imageUrl: text(values[F.variantImage])
|
|
1019
1116
|
} : {}, {
|
|
1020
1117
|
inventory: inventory === undefined ? null : Math.max(0, Math.round(inventory))
|
|
1021
|
-
}
|
|
1118
|
+
}, checkIn ? {
|
|
1119
|
+
checkIn
|
|
1120
|
+
} : {});
|
|
1022
1121
|
}
|
|
1023
1122
|
/** The fields a new product is refused without. */ const PRODUCT_PLAN_FIELDS = (fields)=>fields.filter((field)=>!VARIANT_LEVEL_FIELDS.includes(field.id)).map((field)=>field.id === F.title ? _extends({}, field, {
|
|
1024
1123
|
required: true
|
|
@@ -1073,6 +1172,22 @@ const VARIANT_PLAN_FIELDS = (fields)=>fields.filter((field)=>VARIANT_LEVEL_FIELD
|
|
|
1073
1172
|
}
|
|
1074
1173
|
}
|
|
1075
1174
|
});
|
|
1175
|
+
for (const fieldId of REGISTER_PRODUCT_FIELDS){
|
|
1176
|
+
for (const position of group.positions.slice(1)){
|
|
1177
|
+
const row = rows[position];
|
|
1178
|
+
const cell = row.values[fieldId];
|
|
1179
|
+
if (isBlankTransferValue(cell)) continue;
|
|
1180
|
+
if (isBlankTransferValue(values[fieldId])) values[fieldId] = cell;
|
|
1181
|
+
else if (cell !== values[fieldId]) {
|
|
1182
|
+
tally.add('droppedCell', {
|
|
1183
|
+
row: row.index,
|
|
1184
|
+
fieldId,
|
|
1185
|
+
value: text(cell),
|
|
1186
|
+
detail: 'A product holds one of these, and an earlier row of this product already gives it.'
|
|
1187
|
+
});
|
|
1188
|
+
}
|
|
1189
|
+
}
|
|
1190
|
+
}
|
|
1076
1191
|
return _extends({}, first, {
|
|
1077
1192
|
values
|
|
1078
1193
|
});
|
|
@@ -1207,6 +1322,21 @@ const VARIANT_PLAN_FIELDS = (fields)=>fields.filter((field)=>VARIANT_LEVEL_FIELD
|
|
|
1207
1322
|
});
|
|
1208
1323
|
}
|
|
1209
1324
|
}
|
|
1325
|
+
// A cell a row could not have read, on a row no variant plan reports it for.
|
|
1326
|
+
for (const position of group.positions){
|
|
1327
|
+
var _row_problems;
|
|
1328
|
+
if (position === leaderPosition || linePositions.includes(position)) continue;
|
|
1329
|
+
const row = rows[position];
|
|
1330
|
+
for (const problem of (_row_problems = row.problems) != null ? _row_problems : []){
|
|
1331
|
+
if (!REGISTER_PRODUCT_FIELDS.includes(problem.fieldId)) continue;
|
|
1332
|
+
tally.add('droppedCell', {
|
|
1333
|
+
row: row.index,
|
|
1334
|
+
fieldId: problem.fieldId,
|
|
1335
|
+
value: problem.raw,
|
|
1336
|
+
detail: problem.message
|
|
1337
|
+
});
|
|
1338
|
+
}
|
|
1339
|
+
}
|
|
1210
1340
|
const variantPlan = buildTransferPlan({
|
|
1211
1341
|
fields: variantFields,
|
|
1212
1342
|
rows: lineRows,
|
|
@@ -1321,10 +1451,26 @@ const VARIANT_PLAN_FIELDS = (fields)=>fields.filter((field)=>VARIANT_LEVEL_FIELD
|
|
|
1321
1451
|
}
|
|
1322
1452
|
for (const change of verdict.diff)entry.values[change.fieldId] = change.after;
|
|
1323
1453
|
}
|
|
1454
|
+
let addOnVariants;
|
|
1324
1455
|
if (finalVariants.length > COMMERCE_MAX_VARIANTS) {
|
|
1325
1456
|
problem = `A product holds at most ${COMMERCE_MAX_VARIANTS} variants; this file gives it ${finalVariants.length}.`;
|
|
1326
1457
|
} else {
|
|
1327
|
-
|
|
1458
|
+
var _planned_diff_find;
|
|
1459
|
+
const candidate = productFromRecord(productValues, finalVariants);
|
|
1460
|
+
let check = validateProduct(candidate);
|
|
1461
|
+
const addOns = (_planned_diff_find = planned.diff.find((change)=>change.fieldId === F.modifierGroups)) == null ? void 0 : _planned_diff_find.after;
|
|
1462
|
+
if (!check && !isBlankTransferValue(addOns)) {
|
|
1463
|
+
var _ref1, _resolved_problem, _resolved_groups;
|
|
1464
|
+
var _resolved_groups1;
|
|
1465
|
+
const variantIds = addOnVariantIds(candidate.variants);
|
|
1466
|
+
const resolved = modifierGroupsFromAddOnCell(addOns, [], variantIds);
|
|
1467
|
+
check = (_ref1 = (_resolved_problem = resolved.problem) != null ? _resolved_problem : validateProduct(_extends({}, candidate, {
|
|
1468
|
+
modifierGroups: (_resolved_groups = resolved.groups) != null ? _resolved_groups : []
|
|
1469
|
+
}))) != null ? _ref1 : variantMatrixProblem(candidate.options);
|
|
1470
|
+
if ((_resolved_groups1 = resolved.groups) == null ? void 0 : _resolved_groups1.some((entry)=>entry.options.some((option)=>option.priceCentsByVariant))) {
|
|
1471
|
+
addOnVariants = variantIds;
|
|
1472
|
+
}
|
|
1473
|
+
}
|
|
1328
1474
|
if (check) problem = check;
|
|
1329
1475
|
}
|
|
1330
1476
|
const create = creating ? {
|
|
@@ -1342,7 +1488,7 @@ const VARIANT_PLAN_FIELDS = (fields)=>fields.filter((field)=>VARIANT_LEVEL_FIELD
|
|
|
1342
1488
|
}))
|
|
1343
1489
|
} : undefined;
|
|
1344
1490
|
for (const position of group.positions){
|
|
1345
|
-
var
|
|
1491
|
+
var _ref2, _ref3;
|
|
1346
1492
|
const row = rows[position];
|
|
1347
1493
|
const isLeader = position === leaderPosition;
|
|
1348
1494
|
const line = lineVerdicts.get(position);
|
|
@@ -1391,12 +1537,12 @@ const VARIANT_PLAN_FIELDS = (fields)=>fields.filter((field)=>VARIANT_LEVEL_FIELD
|
|
|
1391
1537
|
const warnings = [
|
|
1392
1538
|
...new Set([
|
|
1393
1539
|
...isLeader ? planned.warnings : [],
|
|
1394
|
-
...(
|
|
1540
|
+
...(_ref2 = line == null ? void 0 : line.warnings) != null ? _ref2 : []
|
|
1395
1541
|
])
|
|
1396
1542
|
];
|
|
1397
1543
|
const heldBack = [
|
|
1398
1544
|
...isLeader ? planned.heldBack : [],
|
|
1399
|
-
...(
|
|
1545
|
+
...(_ref3 = line == null ? void 0 : line.heldBack) != null ? _ref3 : []
|
|
1400
1546
|
];
|
|
1401
1547
|
const plan = _extends({
|
|
1402
1548
|
productId,
|
|
@@ -1411,6 +1557,8 @@ const VARIANT_PLAN_FIELDS = (fields)=>fields.filter((field)=>VARIANT_LEVEL_FIELD
|
|
|
1411
1557
|
create
|
|
1412
1558
|
} : {}, problem ? {
|
|
1413
1559
|
problem
|
|
1560
|
+
} : {}, isLeader && addOnVariants ? {
|
|
1561
|
+
addOnVariants
|
|
1414
1562
|
} : {});
|
|
1415
1563
|
if (lineFailed && (!isLeader || !(productDiff.length || creating))) {
|
|
1416
1564
|
out[position] = _extends({}, base, {
|
|
@@ -1498,6 +1646,8 @@ const VARIANT_PLAN_FIELDS = (fields)=>fields.filter((field)=>VARIANT_LEVEL_FIELD
|
|
|
1498
1646
|
const threshold = Number(value(F.lowStockThreshold));
|
|
1499
1647
|
patch.lowStockThreshold = value(F.lowStockThreshold) === null || !Number.isFinite(threshold) ? undefined : Math.max(0, Math.round(threshold));
|
|
1500
1648
|
}
|
|
1649
|
+
if (has(F.posQuickKey)) patch.posQuickKey = value(F.posQuickKey) === null ? undefined : value(F.posQuickKey) === true;
|
|
1650
|
+
if (has(F.checkIn)) patch.checkIn = isBlankTransferValue(value(F.checkIn)) ? undefined : checkInFromCell(value(F.checkIn));
|
|
1501
1651
|
return patch;
|
|
1502
1652
|
}
|
|
1503
1653
|
/** A product with one planned row's changes written into it — the product's own on its first row, and the row's variant. */ export function applyProductRow(current, changes, categoryIdsOf) {
|
|
@@ -1519,6 +1669,14 @@ const VARIANT_PLAN_FIELDS = (fields)=>fields.filter((field)=>VARIANT_LEVEL_FIELD
|
|
|
1519
1669
|
if (F.seoDescription in product) seo.description = text(product[F.seoDescription]) || undefined;
|
|
1520
1670
|
next.seo = Object.fromEntries(Object.entries(seo).filter(([, entry])=>entry !== undefined));
|
|
1521
1671
|
}
|
|
1672
|
+
if (F.modifierGroups in product) {
|
|
1673
|
+
var _changes_addOnVariants;
|
|
1674
|
+
const { groups } = isBlankTransferValue(product[F.modifierGroups]) ? {
|
|
1675
|
+
groups: []
|
|
1676
|
+
} : modifierGroupsFromAddOnCell(product[F.modifierGroups], current.modifierGroups, (_changes_addOnVariants = changes.addOnVariants) != null ? _changes_addOnVariants : addOnVariantIds(next.variants));
|
|
1677
|
+
if (groups == null ? void 0 : groups.length) next.modifierGroups = groups;
|
|
1678
|
+
else if (groups) delete next.modifierGroups;
|
|
1679
|
+
}
|
|
1522
1680
|
// An option the product does not have yet takes its name.
|
|
1523
1681
|
const options = next.options;
|
|
1524
1682
|
OPTION_NAME_FIELDS.forEach((fieldId, axis)=>{
|
|
@@ -1551,6 +1709,9 @@ const VARIANT_PLAN_FIELDS = (fields)=>fields.filter((field)=>VARIANT_LEVEL_FIELD
|
|
|
1551
1709
|
]){
|
|
1552
1710
|
if (merged[key] === undefined) delete written[key];
|
|
1553
1711
|
}
|
|
1712
|
+
// Its check-in moves only when the file names it, and stays exactly as stored when not.
|
|
1713
|
+
if (F.variantCheckIn in variant.values ? merged.checkIn === undefined : (existing == null ? void 0 : existing.checkIn) === undefined) delete written.checkIn;
|
|
1714
|
+
else if (!(F.variantCheckIn in variant.values)) written.checkIn = existing == null ? void 0 : existing.checkIn;
|
|
1554
1715
|
if (at >= 0) next.variants[at] = written;
|
|
1555
1716
|
else next.variants.push(written);
|
|
1556
1717
|
// Each option value the variant holds is one its option offers.
|
|
@@ -1574,7 +1735,7 @@ const VARIANT_PLAN_FIELDS = (fields)=>fields.filter((field)=>VARIANT_LEVEL_FIELD
|
|
|
1574
1735
|
}, categoryIdsOf);
|
|
1575
1736
|
}
|
|
1576
1737
|
/** The values one planned row changes, split into the product's and its variant's. */ export function productRowChanges(row) {
|
|
1577
|
-
var _row_commerce;
|
|
1738
|
+
var _row_commerce, _row_commerce1;
|
|
1578
1739
|
const product = {};
|
|
1579
1740
|
const variant = {};
|
|
1580
1741
|
for (const change of row.diff){
|
|
@@ -1582,12 +1743,15 @@ const VARIANT_PLAN_FIELDS = (fields)=>fields.filter((field)=>VARIANT_LEVEL_FIELD
|
|
|
1582
1743
|
else if (PRODUCT_LEVEL_FIELDS.includes(change.fieldId)) product[change.fieldId] = change.after;
|
|
1583
1744
|
}
|
|
1584
1745
|
const target = (_row_commerce = row.commerce) == null ? void 0 : _row_commerce.variant;
|
|
1746
|
+
const addOnVariants = (_row_commerce1 = row.commerce) == null ? void 0 : _row_commerce1.addOnVariants;
|
|
1585
1747
|
return _extends({
|
|
1586
1748
|
product
|
|
1587
1749
|
}, target ? {
|
|
1588
1750
|
variant: _extends({}, target, {
|
|
1589
1751
|
values: variant
|
|
1590
1752
|
})
|
|
1753
|
+
} : {}, addOnVariants ? {
|
|
1754
|
+
addOnVariants
|
|
1591
1755
|
} : {});
|
|
1592
1756
|
}
|
|
1593
1757
|
|