addio-admin-sdk 1.7.21 → 1.7.23-canary-1
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/addio-sdk-doc.md +499 -406
- package/dist/Interfaces/Algolia/index.d.ts +8 -0
- package/dist/Interfaces/Cart/index.d.ts +2 -0
- package/dist/Interfaces/Cart/index.js.map +1 -1
- package/dist/Interfaces/Product/IInventoryItem.d.ts +10 -10
- package/dist/Interfaces/Schedule/index.d.ts +1 -0
- package/dist/Interfaces/Space/index.d.ts +16 -0
- package/dist/Interfaces/Space/index.js +18 -2
- package/dist/Interfaces/Space/index.js.map +1 -1
- package/dist/Interfaces/TransferRequest/index.d.ts +49 -17
- package/dist/Interfaces/TransferRequest/index.js +23 -16
- package/dist/Interfaces/TransferRequest/index.js.map +1 -1
- package/dist/Interfaces/Translation/index.d.ts +4 -0
- package/dist/Interfaces/Translation/index.js +3 -0
- package/dist/Interfaces/Translation/index.js.map +1 -1
- package/dist/lib/Cart/index.d.ts +12 -3
- package/dist/lib/Cart/index.js +288 -146
- package/dist/lib/Cart/index.js.map +1 -1
- package/dist/lib/Email/OrderConfirmationEmail.d.ts +1 -1
- package/dist/lib/Email/OrderConfirmationEmail.js +3 -2
- package/dist/lib/Email/OrderConfirmationEmail.js.map +1 -1
- package/dist/lib/Inventory/index.d.ts +20 -4
- package/dist/lib/Inventory/index.js +99 -49
- package/dist/lib/Inventory/index.js.map +1 -1
- package/dist/lib/Shipment/index.js +5 -4
- package/dist/lib/Shipment/index.js.map +1 -1
- package/dist/lib/Space/index.d.ts +19 -3
- package/dist/lib/Space/index.js +367 -248
- package/dist/lib/Space/index.js.map +1 -1
- package/dist/lib/TransferRequest/index.d.ts +82 -5
- package/dist/lib/TransferRequest/index.js +959 -112
- package/dist/lib/TransferRequest/index.js.map +1 -1
- package/dist/rules/GR/utils/expedition.js.map +1 -1
- package/dist/rules/GR/utils/invoices.js +1 -1
- package/dist/rules/GR/utils/products.d.ts +12 -5
- package/dist/rules/GR/utils/products.js +45 -29
- package/dist/rules/GR/utils/products.js.map +1 -1
- package/dist/rules/GR/utils/upsells.js +1 -1
- package/dist/rules/GR/utils/upsells.js.map +1 -1
- package/dist/services/database/DatabaseService.js.map +1 -1
- package/dist/utils/cart.d.ts +26 -1
- package/dist/utils/cart.js +128 -12
- package/dist/utils/cart.js.map +1 -1
- package/dist/utils/context.d.ts +1 -0
- package/dist/utils/context.js +19 -1
- package/dist/utils/context.js.map +1 -1
- package/dist/utils/inventories.d.ts +2 -1
- package/dist/utils/inventories.js +31 -16
- package/dist/utils/inventories.js.map +1 -1
- package/dist/utils/products.d.ts +6 -0
- package/dist/utils/products.js +7 -1
- package/dist/utils/products.js.map +1 -1
- package/dist/utils/transferRequests.d.ts +3 -0
- package/dist/utils/transferRequests.js +12 -1
- package/dist/utils/transferRequests.js.map +1 -1
- package/package.json +1 -1
package/dist/lib/Space/index.js
CHANGED
|
@@ -132,6 +132,7 @@ var Booking_2 = require("../../Interfaces/Booking");
|
|
|
132
132
|
var moment_1 = __importDefault(require("moment"));
|
|
133
133
|
var sdc_1 = require("../../utils/sdc");
|
|
134
134
|
var TransferRequest_1 = require("../TransferRequest");
|
|
135
|
+
var TransferRequest_2 = require("../../Interfaces/TransferRequest");
|
|
135
136
|
var Inventory_2 = __importDefault(require("../Inventory"));
|
|
136
137
|
var __1 = require("../..");
|
|
137
138
|
var Catalogue_1 = __importDefault(require("../Catalogue"));
|
|
@@ -154,6 +155,7 @@ var g2_1 = require("../../rules/GR/utils/g2");
|
|
|
154
155
|
var Consent_1 = __importDefault(require("../Consent"));
|
|
155
156
|
var cart_1 = require("../../rules/GR/utils/cart");
|
|
156
157
|
var FirstOrderTracking_1 = __importDefault(require("../FirstOrderTracking"));
|
|
158
|
+
var logs_1 = require("../../services/logs");
|
|
157
159
|
var Space = (function () {
|
|
158
160
|
function Space(space, user, space_ref) {
|
|
159
161
|
var _this = this;
|
|
@@ -227,6 +229,30 @@ var Space = (function () {
|
|
|
227
229
|
this.getCurrencies = function () {
|
|
228
230
|
return _this._currencies;
|
|
229
231
|
};
|
|
232
|
+
this.incrementTransferRef = function () { return __awaiter(_this, void 0, void 0, function () {
|
|
233
|
+
var spaceSnap, spaceData, actualRef;
|
|
234
|
+
return __generator(this, function (_c) {
|
|
235
|
+
switch (_c.label) {
|
|
236
|
+
case 0: return [4, DatabaseService_1.default.getDocument(this.getRef().path, this.getRef().id)];
|
|
237
|
+
case 1:
|
|
238
|
+
spaceSnap = _c.sent();
|
|
239
|
+
if (!spaceSnap.exists) {
|
|
240
|
+
throw new Error("could not find space, does not exist - ".concat(this.getRef().path, " - ").concat(this.getRef().id));
|
|
241
|
+
}
|
|
242
|
+
spaceData = spaceSnap.data;
|
|
243
|
+
if (!!!spaceData) {
|
|
244
|
+
throw new Error("space data is undefined - ".concat(this.getRef().path, " - ").concat(this.getRef().id));
|
|
245
|
+
}
|
|
246
|
+
actualRef = (0, object_1.recursiveCheckObject)(spaceData, 'transfer_settings.start_at') || 1;
|
|
247
|
+
return [4, this.save({
|
|
248
|
+
transfer_settings: __assign(__assign({}, (spaceData.transfer_settings || {})), { start_at: actualRef + ((0, object_1.recursiveCheckObject)(spaceData, 'transfer_settings.increment_by') || 1) })
|
|
249
|
+
})];
|
|
250
|
+
case 2:
|
|
251
|
+
_c.sent();
|
|
252
|
+
return [2, actualRef];
|
|
253
|
+
}
|
|
254
|
+
});
|
|
255
|
+
}); };
|
|
230
256
|
this.incrementOrderAndInvoiceRef = function () { return __awaiter(_this, void 0, void 0, function () {
|
|
231
257
|
var spaceSnap, spaceData, actualRef;
|
|
232
258
|
return __generator(this, function (_c) {
|
|
@@ -466,21 +492,20 @@ var Space = (function () {
|
|
|
466
492
|
}
|
|
467
493
|
});
|
|
468
494
|
}); };
|
|
469
|
-
this._addNewUnitToShippingPref = function () { return __awaiter(_this, void 0, void 0, function () {
|
|
470
|
-
var existingUnits,
|
|
495
|
+
this._addNewUnitToShippingPref = function (newUnitValues) { return __awaiter(_this, void 0, void 0, function () {
|
|
496
|
+
var existingUnits, newValuesToSave, saved;
|
|
471
497
|
return __generator(this, function (_c) {
|
|
472
498
|
switch (_c.label) {
|
|
473
499
|
case 0:
|
|
474
|
-
existingUnits = this.
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
case 1: return [2, _c.sent()];
|
|
500
|
+
existingUnits = this._space.transport_preferences.dimension_units || [];
|
|
501
|
+
newValuesToSave = __assign(__assign({}, this._space.transport_preferences), { dimension_units: __spreadArray(__spreadArray([], existingUnits, true), [newUnitValues], false) });
|
|
502
|
+
return [4, DatabaseService_1.default.saveDocument(this._space_ref.path, this._space_ref.id, 0, { transport_preferences: newValuesToSave }, { merge: true })];
|
|
503
|
+
case 1:
|
|
504
|
+
saved = _c.sent();
|
|
505
|
+
if (!!saved) {
|
|
506
|
+
this._space = __assign(__assign({}, this._space), { transport_preferences: newValuesToSave });
|
|
507
|
+
}
|
|
508
|
+
return [2, saved];
|
|
484
509
|
}
|
|
485
510
|
});
|
|
486
511
|
}); };
|
|
@@ -514,15 +539,19 @@ var Space = (function () {
|
|
|
514
539
|
});
|
|
515
540
|
}); };
|
|
516
541
|
this._deleteUnitToShippingPref = function (bIndex) { return __awaiter(_this, void 0, void 0, function () {
|
|
517
|
-
var exisitingUnits;
|
|
542
|
+
var exisitingUnits, newTransportPreferences, saved;
|
|
518
543
|
return __generator(this, function (_c) {
|
|
519
544
|
switch (_c.label) {
|
|
520
545
|
case 0:
|
|
521
546
|
exisitingUnits = this.data().transport_preferences.dimension_units || [];
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
547
|
+
newTransportPreferences = __assign(__assign({}, this.data().transport_preferences), { dimension_units: __spreadArray(__spreadArray([], exisitingUnits.slice(0, bIndex), true), exisitingUnits.slice(bIndex + 1), true) });
|
|
548
|
+
return [4, DatabaseService_1.default.saveDocument(this._space_ref.path, this._space_ref.id, 0, { transport_preferences: newTransportPreferences }, { merge: true })];
|
|
549
|
+
case 1:
|
|
550
|
+
saved = _c.sent();
|
|
551
|
+
if (!!saved) {
|
|
552
|
+
this._space = __assign(__assign({}, this._space), { transport_preferences: newTransportPreferences });
|
|
553
|
+
}
|
|
554
|
+
return [2, saved];
|
|
526
555
|
}
|
|
527
556
|
});
|
|
528
557
|
}); };
|
|
@@ -550,26 +579,41 @@ var Space = (function () {
|
|
|
550
579
|
}
|
|
551
580
|
});
|
|
552
581
|
}); };
|
|
553
|
-
this._updateUnitToShippingPref = function (
|
|
554
|
-
var existingUnits;
|
|
582
|
+
this._updateUnitToShippingPref = function (uIndex, value, forProps) { return __awaiter(_this, void 0, void 0, function () {
|
|
583
|
+
var existingUnits, newTransportPreferences, saved;
|
|
555
584
|
return __generator(this, function (_c) {
|
|
556
585
|
switch (_c.label) {
|
|
557
586
|
case 0:
|
|
558
587
|
existingUnits = this.data().transport_preferences.dimension_units || [];
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
return [4, DatabaseService_1.default.saveDocument(this._space_ref.path, this._space_ref.id, 0, {
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
588
|
+
newTransportPreferences = __assign(__assign({}, this._space.transport_preferences), { dimension_units: existingUnits.map(function (unit, i) {
|
|
589
|
+
var _c;
|
|
590
|
+
if (i !== uIndex)
|
|
591
|
+
return unit;
|
|
592
|
+
return __assign(__assign({}, unit), (_c = {}, _c[forProps] = value, _c));
|
|
593
|
+
}) });
|
|
594
|
+
return [4, DatabaseService_1.default.saveDocument(this._space_ref.path, this._space_ref.id, 0, { transport_preferences: newTransportPreferences }, { merge: true })];
|
|
595
|
+
case 1:
|
|
596
|
+
saved = _c.sent();
|
|
597
|
+
if (!!saved) {
|
|
598
|
+
this._space = __assign(__assign({}, this._space), { transport_preferences: newTransportPreferences });
|
|
599
|
+
}
|
|
600
|
+
return [2, saved];
|
|
601
|
+
}
|
|
602
|
+
});
|
|
603
|
+
}); };
|
|
604
|
+
this._updateFullUnitToShippingPref = function (uIndex, newValues) { return __awaiter(_this, void 0, void 0, function () {
|
|
605
|
+
var existingUnits, updatedValues;
|
|
606
|
+
return __generator(this, function (_c) {
|
|
607
|
+
switch (_c.label) {
|
|
608
|
+
case 0:
|
|
609
|
+
existingUnits = this.data().transport_preferences.dimension_units || [];
|
|
610
|
+
updatedValues = __assign(__assign({}, this._space.transport_preferences), { dimension_units: existingUnits.map(function (box, i) {
|
|
611
|
+
if (i !== uIndex)
|
|
612
|
+
return box;
|
|
613
|
+
return newValues;
|
|
614
|
+
}) });
|
|
615
|
+
this._space = __assign(__assign({}, this._space), { transport_preferences: updatedValues });
|
|
616
|
+
return [4, DatabaseService_1.default.saveDocument(this._space_ref.path, this._space_ref.id, 0, { transport_preferences: updatedValues }, { merge: true })];
|
|
573
617
|
case 1: return [2, _c.sent()];
|
|
574
618
|
}
|
|
575
619
|
});
|
|
@@ -2825,6 +2869,46 @@ var Space = (function () {
|
|
|
2825
2869
|
}
|
|
2826
2870
|
});
|
|
2827
2871
|
}); };
|
|
2872
|
+
this._getTransferRequestStatusOrderForSpace = function () {
|
|
2873
|
+
var shouldUseAltObj = !!(0, object_1.recursiveCheckObject)(_this.data(), 'space_options.transfer_requests.associate_origin_store_at_creation');
|
|
2874
|
+
return shouldUseAltObj ? TransferRequest_2.transferRequestAltStatusOrder : TransferRequest_2.transferRequestStatusOrder;
|
|
2875
|
+
};
|
|
2876
|
+
this._getTransferRequestByRef = function (ref) { return __awaiter(_this, void 0, void 0, function () {
|
|
2877
|
+
var call, transferquery, e_10;
|
|
2878
|
+
var _this = this;
|
|
2879
|
+
var _c;
|
|
2880
|
+
return __generator(this, function (_f) {
|
|
2881
|
+
switch (_f.label) {
|
|
2882
|
+
case 0:
|
|
2883
|
+
_f.trys.push([0, 4, , 5]);
|
|
2884
|
+
call = DatabaseService_1.default.addToPath(this._space_ref.path, this._space_ref.id + '/transfer_requests');
|
|
2885
|
+
return [4, DatabaseService_1.default.getDocuments(call, {
|
|
2886
|
+
query: [{ field: 'ref', operator: '==', value: ref }]
|
|
2887
|
+
})];
|
|
2888
|
+
case 1:
|
|
2889
|
+
transferquery = _f.sent();
|
|
2890
|
+
if (transferquery.length == 0)
|
|
2891
|
+
return [2, []];
|
|
2892
|
+
if (!(transferquery.length > 1)) return [3, 3];
|
|
2893
|
+
console.log("Found more than one transfer with ref ".concat(ref, "!"));
|
|
2894
|
+
return [4, (0, logs_1.SystemLog)({
|
|
2895
|
+
clientName: "sdk-admin | Space | _getTransferRequestByRef, space: ".concat((0, services_1.getSpaceInitialsByID)(this.data().id)),
|
|
2896
|
+
clientToken: (_c = process.env.NEXT_PUBLIC_LOG_SYSTEM_KEY) !== null && _c !== void 0 ? _c : ''
|
|
2897
|
+
}, logs_1.LogType.ERROR, "Found more than one transfer with ref ".concat(ref, "!"))];
|
|
2898
|
+
case 2:
|
|
2899
|
+
_f.sent();
|
|
2900
|
+
_f.label = 3;
|
|
2901
|
+
case 3: return [2, transferquery.map(function (transferRequestDoc) {
|
|
2902
|
+
return new TransferRequest_1.TransferRequest(__assign(__assign({}, transferRequestDoc.data), { id: transferRequestDoc.id }), DatabaseService_1.default.asCollectionObject(_this._space_ref.path, _this._space_ref.id + '/transfer_requests'), _this._user);
|
|
2903
|
+
})];
|
|
2904
|
+
case 4:
|
|
2905
|
+
e_10 = _f.sent();
|
|
2906
|
+
console.log('error on fetching transfer for ref: ', e_10.toString());
|
|
2907
|
+
return [3, 5];
|
|
2908
|
+
case 5: return [2];
|
|
2909
|
+
}
|
|
2910
|
+
});
|
|
2911
|
+
}); };
|
|
2828
2912
|
this._discountRulesListener = function (callback, options) {
|
|
2829
2913
|
if (!!!_this._user)
|
|
2830
2914
|
throw 'Invalid or unauthenticated user';
|
|
@@ -3736,7 +3820,7 @@ var Space = (function () {
|
|
|
3736
3820
|
});
|
|
3737
3821
|
}); };
|
|
3738
3822
|
this._generateNewPromiseId = function (customerId, useNextSeason, idToIncrement) { return __awaiter(_this, void 0, void 0, function () {
|
|
3739
|
-
var yearToUse, existingPAs,
|
|
3823
|
+
var yearToUse, existingPAs, e_11, idToUse, orderedPAs, mostRecentPAId, newId, alreadyExists, e_12;
|
|
3740
3824
|
return __generator(this, function (_c) {
|
|
3741
3825
|
switch (_c.label) {
|
|
3742
3826
|
case 0:
|
|
@@ -3755,8 +3839,8 @@ var Space = (function () {
|
|
|
3755
3839
|
existingPAs = _c.sent();
|
|
3756
3840
|
return [3, 4];
|
|
3757
3841
|
case 3:
|
|
3758
|
-
|
|
3759
|
-
console.error(
|
|
3842
|
+
e_11 = _c.sent();
|
|
3843
|
+
console.error(e_11);
|
|
3760
3844
|
return [3, 4];
|
|
3761
3845
|
case 4:
|
|
3762
3846
|
if (!!!existingPAs || !!!existingPAs.length)
|
|
@@ -3782,15 +3866,15 @@ var Space = (function () {
|
|
|
3782
3866
|
newId = _c.sent();
|
|
3783
3867
|
return [3, 8];
|
|
3784
3868
|
case 7:
|
|
3785
|
-
|
|
3786
|
-
console.error(
|
|
3869
|
+
e_12 = _c.sent();
|
|
3870
|
+
console.error(e_12);
|
|
3787
3871
|
return [3, 8];
|
|
3788
3872
|
case 8: return [2, newId];
|
|
3789
3873
|
}
|
|
3790
3874
|
});
|
|
3791
3875
|
}); };
|
|
3792
3876
|
this._incrementInvoiceRef = function (cartData) { return __awaiter(_this, void 0, void 0, function () {
|
|
3793
|
-
var spaceSnap, spaceData, invoiceData, newInvoiceRef,
|
|
3877
|
+
var spaceSnap, spaceData, invoiceData, newInvoiceRef, e_13, invoiceRefByStore, storeToUse, sameStore, wasPaidAtStore, invoiceRefByWeb, sameWebType, createdAtStore, processedAtStore, paidAtStore, e_14, e_15, sameInDB;
|
|
3794
3878
|
return __generator(this, function (_c) {
|
|
3795
3879
|
switch (_c.label) {
|
|
3796
3880
|
case 0: return [4, DatabaseService_1.default.getDocument(this.getRef().path, this.getRef().id)];
|
|
@@ -3814,8 +3898,8 @@ var Space = (function () {
|
|
|
3814
3898
|
newInvoiceRef = cartData.ref;
|
|
3815
3899
|
return [3, 5];
|
|
3816
3900
|
case 4:
|
|
3817
|
-
|
|
3818
|
-
console.log('error on saving invoice_settings to space: ',
|
|
3901
|
+
e_13 = _c.sent();
|
|
3902
|
+
console.log('error on saving invoice_settings to space: ', e_13.toString());
|
|
3819
3903
|
return [3, 5];
|
|
3820
3904
|
case 5: return [3, 18];
|
|
3821
3905
|
case 6:
|
|
@@ -3850,8 +3934,8 @@ var Space = (function () {
|
|
|
3850
3934
|
newInvoiceRef = _c.sent();
|
|
3851
3935
|
return [3, 10];
|
|
3852
3936
|
case 9:
|
|
3853
|
-
|
|
3854
|
-
console.log('error on saving new ref data to space for invoice : ',
|
|
3937
|
+
e_14 = _c.sent();
|
|
3938
|
+
console.log('error on saving new ref data to space for invoice : ', e_14.toString());
|
|
3855
3939
|
return [3, 10];
|
|
3856
3940
|
case 10: return [3, 18];
|
|
3857
3941
|
case 11:
|
|
@@ -3864,8 +3948,8 @@ var Space = (function () {
|
|
|
3864
3948
|
newInvoiceRef = _c.sent();
|
|
3865
3949
|
return [3, 15];
|
|
3866
3950
|
case 14:
|
|
3867
|
-
|
|
3868
|
-
console.log('error on saving new ref data to space for invoice : ',
|
|
3951
|
+
e_15 = _c.sent();
|
|
3952
|
+
console.log('error on saving new ref data to space for invoice : ', e_15.toString());
|
|
3869
3953
|
return [3, 15];
|
|
3870
3954
|
case 15: return [3, 18];
|
|
3871
3955
|
case 16: return [4, this._incrementGeneralInvoiceRef(invoiceData)];
|
|
@@ -3886,7 +3970,7 @@ var Space = (function () {
|
|
|
3886
3970
|
});
|
|
3887
3971
|
}); };
|
|
3888
3972
|
this._incrementGeneralInvoiceRef = function (invoiceData) { return __awaiter(_this, void 0, void 0, function () {
|
|
3889
|
-
var newInvoiceRef,
|
|
3973
|
+
var newInvoiceRef, e_16;
|
|
3890
3974
|
return __generator(this, function (_c) {
|
|
3891
3975
|
switch (_c.label) {
|
|
3892
3976
|
case 0:
|
|
@@ -3904,15 +3988,15 @@ var Space = (function () {
|
|
|
3904
3988
|
_c.sent();
|
|
3905
3989
|
return [2, newInvoiceRef];
|
|
3906
3990
|
case 3:
|
|
3907
|
-
|
|
3908
|
-
console.log('error on saving new invoice_settings to space: ',
|
|
3991
|
+
e_16 = _c.sent();
|
|
3992
|
+
console.log('error on saving new invoice_settings to space: ', e_16.toString());
|
|
3909
3993
|
return [2, ''];
|
|
3910
3994
|
case 4: return [2];
|
|
3911
3995
|
}
|
|
3912
3996
|
});
|
|
3913
3997
|
}); };
|
|
3914
3998
|
this._incrementStoreOrWebInvoiceRef = function (currentContent, objKey, storeOrWebTypeKey, currentInvoiceData) { return __awaiter(_this, void 0, void 0, function () {
|
|
3915
|
-
var newInvoiceRef, objData,
|
|
3999
|
+
var newInvoiceRef, objData, e_17;
|
|
3916
4000
|
var _c, _f;
|
|
3917
4001
|
return __generator(this, function (_g) {
|
|
3918
4002
|
switch (_g.label) {
|
|
@@ -3929,20 +4013,19 @@ var Space = (function () {
|
|
|
3929
4013
|
_g.sent();
|
|
3930
4014
|
return [3, 4];
|
|
3931
4015
|
case 3:
|
|
3932
|
-
|
|
3933
|
-
console.log('error on saving new ref data to space for invoice : ',
|
|
4016
|
+
e_17 = _g.sent();
|
|
4017
|
+
console.log('error on saving new ref data to space for invoice : ', e_17.toString());
|
|
3934
4018
|
return [3, 4];
|
|
3935
4019
|
case 4: return [2, newInvoiceRef];
|
|
3936
4020
|
}
|
|
3937
4021
|
});
|
|
3938
4022
|
}); };
|
|
3939
|
-
this._constructNewRefForInvoice = function (data) {
|
|
4023
|
+
this._constructNewRefForInvoice = function (data, valueToUse) {
|
|
3940
4024
|
var minRefLength = _this.data().id === services_1.SpaceIdEnum.GR ? 6 : 1;
|
|
3941
4025
|
var prefix = !!data.prefix ? data.prefix + '-' : '';
|
|
3942
4026
|
var suffix = !!data.suffix ? '-' + data.suffix : '';
|
|
3943
|
-
var
|
|
3944
|
-
|
|
3945
|
-
.padStart(minRefLength, '0');
|
|
4027
|
+
var value = valueToUse || (0, toNumber_1.default)(data.start_at || 0);
|
|
4028
|
+
var ref = value.toString().padStart(minRefLength, '0');
|
|
3946
4029
|
return "".concat(prefix).concat(ref).concat(suffix);
|
|
3947
4030
|
};
|
|
3948
4031
|
this._getSpaceBillingEmailsToSendInvoice = function (isDelivery) {
|
|
@@ -4114,7 +4197,7 @@ var Space = (function () {
|
|
|
4114
4197
|
}, DatabaseService_1.default.asCollectionObject(_this._space_ref.path, _this._space_ref.id + '/customers'), _this._user);
|
|
4115
4198
|
};
|
|
4116
4199
|
this._createCustomerWithId = function (id, customer) { return __awaiter(_this, void 0, void 0, function () {
|
|
4117
|
-
var
|
|
4200
|
+
var e_18;
|
|
4118
4201
|
return __generator(this, function (_c) {
|
|
4119
4202
|
switch (_c.label) {
|
|
4120
4203
|
case 0:
|
|
@@ -4124,7 +4207,7 @@ var Space = (function () {
|
|
|
4124
4207
|
_c.sent();
|
|
4125
4208
|
return [2, true];
|
|
4126
4209
|
case 2:
|
|
4127
|
-
|
|
4210
|
+
e_18 = _c.sent();
|
|
4128
4211
|
console.log('error on creating customer with id: ', id);
|
|
4129
4212
|
return [2, false];
|
|
4130
4213
|
case 3: return [2];
|
|
@@ -4132,7 +4215,7 @@ var Space = (function () {
|
|
|
4132
4215
|
});
|
|
4133
4216
|
}); };
|
|
4134
4217
|
this._deleteOneCustomer = function (id) { return __awaiter(_this, void 0, void 0, function () {
|
|
4135
|
-
var idDoc, customer,
|
|
4218
|
+
var idDoc, customer, e_19;
|
|
4136
4219
|
return __generator(this, function (_c) {
|
|
4137
4220
|
switch (_c.label) {
|
|
4138
4221
|
case 0:
|
|
@@ -4148,15 +4231,15 @@ var Space = (function () {
|
|
|
4148
4231
|
_c.sent();
|
|
4149
4232
|
return [2, true];
|
|
4150
4233
|
case 3:
|
|
4151
|
-
|
|
4152
|
-
console.log('error on deleting customer: ',
|
|
4234
|
+
e_19 = _c.sent();
|
|
4235
|
+
console.log('error on deleting customer: ', e_19);
|
|
4153
4236
|
return [3, 4];
|
|
4154
4237
|
case 4: return [2];
|
|
4155
4238
|
}
|
|
4156
4239
|
});
|
|
4157
4240
|
}); };
|
|
4158
4241
|
this.addCustomer = function (customer, oldID, skipEmailCheck) { return __awaiter(_this, void 0, void 0, function () {
|
|
4159
|
-
var customerToCreate, allCurrentCustomers, filteredOutCurrentUserId, allEmails, _i, filteredOutCurrentUserId_1, aCustomer, data, foundSameEmail,
|
|
4242
|
+
var customerToCreate, allCurrentCustomers, filteredOutCurrentUserId, allEmails, _i, filteredOutCurrentUserId_1, aCustomer, data, foundSameEmail, e_20, error_51;
|
|
4160
4243
|
return __generator(this, function (_c) {
|
|
4161
4244
|
switch (_c.label) {
|
|
4162
4245
|
case 0:
|
|
@@ -4228,8 +4311,8 @@ var Space = (function () {
|
|
|
4228
4311
|
}
|
|
4229
4312
|
return [3, 4];
|
|
4230
4313
|
case 3:
|
|
4231
|
-
|
|
4232
|
-
console.log('error on fetching customers to check if email exists: ',
|
|
4314
|
+
e_20 = _c.sent();
|
|
4315
|
+
console.log('error on fetching customers to check if email exists: ', e_20);
|
|
4233
4316
|
return [3, 4];
|
|
4234
4317
|
case 4:
|
|
4235
4318
|
if (!!!customerToCreate) {
|
|
@@ -4504,7 +4587,7 @@ var Space = (function () {
|
|
|
4504
4587
|
});
|
|
4505
4588
|
}); };
|
|
4506
4589
|
this._getPossibleActiveBanksForCustomer = function (customerID, promisesToCheck) { return __awaiter(_this, void 0, void 0, function () {
|
|
4507
|
-
var promisesForCustomer, promisesQuery, promisesData, possibleBanks,
|
|
4590
|
+
var promisesForCustomer, promisesQuery, promisesData, possibleBanks, e_21;
|
|
4508
4591
|
return __generator(this, function (_c) {
|
|
4509
4592
|
switch (_c.label) {
|
|
4510
4593
|
case 0:
|
|
@@ -4523,14 +4606,14 @@ var Space = (function () {
|
|
|
4523
4606
|
possibleBanks = this.bankTypes.get(undefined, true);
|
|
4524
4607
|
return [2, (0, promiseToPurchase_1.checkForApplicableBanks)(promisesData, possibleBanks)];
|
|
4525
4608
|
case 3:
|
|
4526
|
-
|
|
4527
|
-
throw new Error("error on fetching promises for customer ".concat(customerID, ": ").concat(
|
|
4609
|
+
e_21 = _c.sent();
|
|
4610
|
+
throw new Error("error on fetching promises for customer ".concat(customerID, ": ").concat(e_21.toString()));
|
|
4528
4611
|
case 4: return [2];
|
|
4529
4612
|
}
|
|
4530
4613
|
});
|
|
4531
4614
|
}); };
|
|
4532
4615
|
this._updateCustomerLastActivity = function (customerId, user, date) { return __awaiter(_this, void 0, void 0, function () {
|
|
4533
|
-
var org, newDate, customerQuery, customerData, customer,
|
|
4616
|
+
var org, newDate, customerQuery, customerData, customer, e_22;
|
|
4534
4617
|
return __generator(this, function (_c) {
|
|
4535
4618
|
switch (_c.label) {
|
|
4536
4619
|
case 0:
|
|
@@ -4555,140 +4638,173 @@ var Space = (function () {
|
|
|
4555
4638
|
_c.sent();
|
|
4556
4639
|
return [3, 5];
|
|
4557
4640
|
case 4:
|
|
4558
|
-
|
|
4559
|
-
console.log("Could not set last_activity prop for customer: ".concat(customerId, ", ").concat(
|
|
4641
|
+
e_22 = _c.sent();
|
|
4642
|
+
console.log("Could not set last_activity prop for customer: ".concat(customerId, ", ").concat(e_22));
|
|
4560
4643
|
return [3, 5];
|
|
4561
4644
|
case 5: return [2];
|
|
4562
4645
|
}
|
|
4563
4646
|
});
|
|
4564
4647
|
}); };
|
|
4565
|
-
this._ajustInventoryWithCart = function (items, cartState, cartType,
|
|
4566
|
-
|
|
4567
|
-
return
|
|
4568
|
-
|
|
4569
|
-
|
|
4570
|
-
|
|
4571
|
-
|
|
4572
|
-
|
|
4573
|
-
|
|
4574
|
-
|
|
4575
|
-
|
|
4576
|
-
|
|
4577
|
-
|
|
4578
|
-
|
|
4579
|
-
|
|
4580
|
-
|
|
4581
|
-
|
|
4582
|
-
|
|
4583
|
-
|
|
4584
|
-
|
|
4585
|
-
|
|
4586
|
-
|
|
4587
|
-
|
|
4588
|
-
|
|
4589
|
-
|
|
4590
|
-
|
|
4591
|
-
|
|
4592
|
-
|
|
4593
|
-
|
|
4594
|
-
|
|
4595
|
-
|
|
4596
|
-
|
|
4597
|
-
|
|
4598
|
-
|
|
4599
|
-
|
|
4600
|
-
|
|
4601
|
-
|
|
4602
|
-
|
|
4603
|
-
|
|
4604
|
-
|
|
4605
|
-
|
|
4606
|
-
(!!!
|
|
4607
|
-
|
|
4608
|
-
|
|
4609
|
-
|
|
4610
|
-
|
|
4611
|
-
|
|
4612
|
-
|
|
4613
|
-
|
|
4614
|
-
|
|
4615
|
-
|
|
4616
|
-
|
|
4617
|
-
|
|
4618
|
-
|
|
4619
|
-
|
|
4620
|
-
|
|
4621
|
-
|
|
4622
|
-
|
|
4623
|
-
|
|
4624
|
-
|
|
4625
|
-
|
|
4626
|
-
|
|
4627
|
-
|
|
4628
|
-
|
|
4629
|
-
|
|
4630
|
-
|
|
4631
|
-
|
|
4632
|
-
|
|
4633
|
-
|
|
4634
|
-
|
|
4635
|
-
|
|
4636
|
-
|
|
4637
|
-
|
|
4638
|
-
|
|
4639
|
-
|
|
4640
|
-
|
|
4641
|
-
|
|
4642
|
-
|
|
4643
|
-
|
|
4644
|
-
|
|
4645
|
-
|
|
4646
|
-
|
|
4647
|
-
|
|
4648
|
-
|
|
4649
|
-
|
|
4650
|
-
|
|
4651
|
-
|
|
4652
|
-
|
|
4653
|
-
|
|
4654
|
-
|
|
4655
|
-
|
|
4656
|
-
|
|
4657
|
-
|
|
4658
|
-
|
|
4659
|
-
|
|
4660
|
-
|
|
4661
|
-
|
|
4662
|
-
|
|
4663
|
-
|
|
4664
|
-
|
|
4665
|
-
|
|
4666
|
-
|
|
4667
|
-
|
|
4668
|
-
|
|
4669
|
-
|
|
4670
|
-
|
|
4671
|
-
|
|
4672
|
-
|
|
4673
|
-
|
|
4674
|
-
|
|
4675
|
-
|
|
4676
|
-
|
|
4677
|
-
|
|
4678
|
-
|
|
4679
|
-
|
|
4680
|
-
|
|
4681
|
-
|
|
4682
|
-
|
|
4683
|
-
|
|
4684
|
-
|
|
4685
|
-
|
|
4686
|
-
|
|
4687
|
-
|
|
4688
|
-
|
|
4689
|
-
|
|
4648
|
+
this._ajustInventoryWithCart = function (items, cartState, cartType, options) {
|
|
4649
|
+
if (options === void 0) { options = {}; }
|
|
4650
|
+
return __awaiter(_this, void 0, void 0, function () {
|
|
4651
|
+
var canShipStores, updatedInventory, _loop_3, this_2, _i, items_1, item;
|
|
4652
|
+
var _c;
|
|
4653
|
+
return __generator(this, function (_f) {
|
|
4654
|
+
switch (_f.label) {
|
|
4655
|
+
case 0:
|
|
4656
|
+
if (!!!this._space.stores_warehouses.length)
|
|
4657
|
+
return [2];
|
|
4658
|
+
canShipStores = this._space.stores_warehouses.filter(function (store) { return !store.no_inventory_for_store && (store.can_sell_online || store.allow_immediate_pickup); });
|
|
4659
|
+
if (!!!canShipStores.length)
|
|
4660
|
+
return [2];
|
|
4661
|
+
updatedInventory = [];
|
|
4662
|
+
_loop_3 = function (item) {
|
|
4663
|
+
var arrProductObj, _g, productObj, productData, declination, inventoryToRemove, inventoryItem, inventoryObj, result, reservedQteDiff, sameInPrev, e_23;
|
|
4664
|
+
return __generator(this, function (_h) {
|
|
4665
|
+
switch (_h.label) {
|
|
4666
|
+
case 0:
|
|
4667
|
+
if (!(!!item.is_temp_prod || !!item.is_service)) return [3, 1];
|
|
4668
|
+
_g = undefined;
|
|
4669
|
+
return [3, 3];
|
|
4670
|
+
case 1: return [4, this_2.products.get({
|
|
4671
|
+
query: [{ field: 'id', operator: '==', value: item.parent_product_id }]
|
|
4672
|
+
})];
|
|
4673
|
+
case 2:
|
|
4674
|
+
_g = _h.sent();
|
|
4675
|
+
_h.label = 3;
|
|
4676
|
+
case 3:
|
|
4677
|
+
arrProductObj = _g;
|
|
4678
|
+
if (!!!arrProductObj)
|
|
4679
|
+
return [2, "continue"];
|
|
4680
|
+
if (!!!arrProductObj.length)
|
|
4681
|
+
return [2, "continue"];
|
|
4682
|
+
productObj = arrProductObj[0];
|
|
4683
|
+
productData = productObj.data();
|
|
4684
|
+
if (!!!productData)
|
|
4685
|
+
return [2, "continue"];
|
|
4686
|
+
if (!!!productData.declinations)
|
|
4687
|
+
return [2, "continue"];
|
|
4688
|
+
declination = productData.declinations.find(function (declination) { return declination.sku === item.sku; });
|
|
4689
|
+
if (!!!declination)
|
|
4690
|
+
return [2, "continue"];
|
|
4691
|
+
inventoryToRemove = (0, inventories_1.getConvertedUnitQuantity)(item.other_units, item.qte);
|
|
4692
|
+
if (!((!!!options.currentStoreId && cartState === 'paid') ||
|
|
4693
|
+
(!!!options.currentStoreId && !!options.onlyWeb) ||
|
|
4694
|
+
!!canShipStores.some(function (store) { return store.id === options.currentStoreId; }))) return [3, 25];
|
|
4695
|
+
inventoryItem = !!options.inventoryItemsDataToUse
|
|
4696
|
+
? options.inventoryItemsDataToUse.find(function (inv) { return inv.sku == item.sku; })
|
|
4697
|
+
: undefined;
|
|
4698
|
+
if (!!!!inventoryItem) return [3, 5];
|
|
4699
|
+
return [4, this_2.inventoryItems.getOne(declination.sku)];
|
|
4700
|
+
case 4:
|
|
4701
|
+
inventoryItem = _h.sent();
|
|
4702
|
+
_h.label = 5;
|
|
4703
|
+
case 5:
|
|
4704
|
+
if (!!!inventoryItem)
|
|
4705
|
+
return [2, "continue"];
|
|
4706
|
+
inventoryObj = new Inventory_2.default(inventoryItem, DatabaseService_1.default.asCollectionObject(this_2._space_ref.path, this_2._space_ref.id + '/inventories'), this_2._user);
|
|
4707
|
+
result = undefined;
|
|
4708
|
+
_h.label = 6;
|
|
4709
|
+
case 6:
|
|
4710
|
+
_h.trys.push([6, 23, , 24]);
|
|
4711
|
+
if (!(cartState === 'picked')) return [3, 8];
|
|
4712
|
+
return [4, inventoryObj.handleOrderPickedupInStore(options.currentStoreId, inventoryToRemove, cartType)];
|
|
4713
|
+
case 7:
|
|
4714
|
+
result = _h.sent();
|
|
4715
|
+
return [3, 22];
|
|
4716
|
+
case 8:
|
|
4717
|
+
if (!(cartState === 'delivery')) return [3, 10];
|
|
4718
|
+
return [4, inventoryObj.handleOrderInDelivery(options.currentStoreId, inventoryToRemove, cartType)];
|
|
4719
|
+
case 9:
|
|
4720
|
+
result = _h.sent();
|
|
4721
|
+
return [3, 22];
|
|
4722
|
+
case 10:
|
|
4723
|
+
if (!(cartState === 'delivered')) return [3, 12];
|
|
4724
|
+
return [4, inventoryObj.handleOrderDelivered(options.currentStoreId, inventoryToRemove, cartType)];
|
|
4725
|
+
case 11:
|
|
4726
|
+
result = _h.sent();
|
|
4727
|
+
return [3, 22];
|
|
4728
|
+
case 12:
|
|
4729
|
+
if (!(cartState === 'shipped')) return [3, 14];
|
|
4730
|
+
return [4, inventoryObj.handleOrderProcessedForShipping(options.currentStoreId, inventoryToRemove, cartType)];
|
|
4731
|
+
case 13:
|
|
4732
|
+
result = _h.sent();
|
|
4733
|
+
return [3, 22];
|
|
4734
|
+
case 14:
|
|
4735
|
+
if (!(cartState === 'paid')) return [3, 16];
|
|
4736
|
+
return [4, inventoryObj.handleProductSold(options.currentStoreId, inventoryToRemove, cartType, cartType !== Cart_1.CartTypeEnum.POS_TRANSACTIONNAL)];
|
|
4737
|
+
case 15:
|
|
4738
|
+
result = _h.sent();
|
|
4739
|
+
return [3, 22];
|
|
4740
|
+
case 16:
|
|
4741
|
+
if (!(cartState === 'cancelled' || cartState === 'refunded')) return [3, 18];
|
|
4742
|
+
return [4, inventoryObj.handleOrderCancelled(options.currentStoreId, (_c = options.fromStoreId) !== null && _c !== void 0 ? _c : options.currentStoreId, inventoryToRemove, cartState, cartType, {
|
|
4743
|
+
deleteItem: false,
|
|
4744
|
+
onlyWeb: options.onlyWeb,
|
|
4745
|
+
orderAssociatedTransfers: options.associatedTransfersToCart,
|
|
4746
|
+
reservedQte: item.qte_reserved,
|
|
4747
|
+
otherUnits: item.other_units
|
|
4748
|
+
})];
|
|
4749
|
+
case 17:
|
|
4750
|
+
result = _h.sent();
|
|
4751
|
+
return [3, 22];
|
|
4752
|
+
case 18:
|
|
4753
|
+
if (!(cartState === 'modified')) return [3, 20];
|
|
4754
|
+
reservedQteDiff = undefined;
|
|
4755
|
+
if (!!options.previousItems) {
|
|
4756
|
+
sameInPrev = options.previousItems.find(function (i) { return i.sku == item.sku; });
|
|
4757
|
+
if (!!sameInPrev && typeof item.qte_reserved !== 'undefined') {
|
|
4758
|
+
reservedQteDiff = item.qte_reserved - (sameInPrev.qte_reserved || 0);
|
|
4759
|
+
}
|
|
4760
|
+
}
|
|
4761
|
+
return [4, inventoryObj.handleProductModified(options.currentStoreId, inventoryToRemove, cartType, {
|
|
4762
|
+
onlyWeb: options.onlyWeb && typeof reservedQteDiff === 'undefined',
|
|
4763
|
+
reservedQteDiff: typeof reservedQteDiff != 'undefined'
|
|
4764
|
+
? (0, inventories_1.getConvertedUnitQuantity)(item.other_units, reservedQteDiff)
|
|
4765
|
+
: undefined
|
|
4766
|
+
})];
|
|
4767
|
+
case 19:
|
|
4768
|
+
result = _h.sent();
|
|
4769
|
+
return [3, 22];
|
|
4770
|
+
case 20:
|
|
4771
|
+
if (!(cartState === 'updatedProcessingStore')) return [3, 22];
|
|
4772
|
+
if (!!!options.currentStoreId || !!!options.fromStoreId)
|
|
4773
|
+
throw 'Could not update inventory for unprovided store ids';
|
|
4774
|
+
return [4, inventoryObj.handleChangedProcessingStore(options.currentStoreId, options.fromStoreId, inventoryToRemove, cartType)];
|
|
4775
|
+
case 21:
|
|
4776
|
+
result = _h.sent();
|
|
4777
|
+
_h.label = 22;
|
|
4778
|
+
case 22: return [3, 24];
|
|
4779
|
+
case 23:
|
|
4780
|
+
e_23 = _h.sent();
|
|
4781
|
+
console.log("error on updating quantities in associated inventoryItem for sku ".concat(item.sku), e_23);
|
|
4782
|
+
return [3, 24];
|
|
4783
|
+
case 24:
|
|
4784
|
+
updatedInventory.push(result);
|
|
4785
|
+
_h.label = 25;
|
|
4786
|
+
case 25: return [2];
|
|
4787
|
+
}
|
|
4788
|
+
});
|
|
4789
|
+
};
|
|
4790
|
+
this_2 = this;
|
|
4791
|
+
_i = 0, items_1 = items;
|
|
4792
|
+
_f.label = 1;
|
|
4793
|
+
case 1:
|
|
4794
|
+
if (!(_i < items_1.length)) return [3, 4];
|
|
4795
|
+
item = items_1[_i];
|
|
4796
|
+
return [5, _loop_3(item)];
|
|
4797
|
+
case 2:
|
|
4798
|
+
_f.sent();
|
|
4799
|
+
_f.label = 3;
|
|
4800
|
+
case 3:
|
|
4801
|
+
_i++;
|
|
4802
|
+
return [3, 1];
|
|
4803
|
+
case 4: return [2, updatedInventory.filter(function (i) { return !!i; })];
|
|
4804
|
+
}
|
|
4805
|
+
});
|
|
4690
4806
|
});
|
|
4691
|
-
}
|
|
4807
|
+
};
|
|
4692
4808
|
this._checkIfSpaceHasMinInventoryOption = function () {
|
|
4693
4809
|
var spaceOptions = _this.options.get();
|
|
4694
4810
|
return !!(0, object_1.recursiveCheckObject)(spaceOptions, 'inventory.minimum_inventory_per_sku');
|
|
@@ -4821,7 +4937,7 @@ var Space = (function () {
|
|
|
4821
4937
|
});
|
|
4822
4938
|
}); };
|
|
4823
4939
|
this._getAllTags = function (options) { return __awaiter(_this, void 0, void 0, function () {
|
|
4824
|
-
var call, tagsQuery,
|
|
4940
|
+
var call, tagsQuery, e_24;
|
|
4825
4941
|
var _this = this;
|
|
4826
4942
|
return __generator(this, function (_c) {
|
|
4827
4943
|
switch (_c.label) {
|
|
@@ -4839,8 +4955,8 @@ var Space = (function () {
|
|
|
4839
4955
|
return new Tags_1.default(tagObj.data, DatabaseService_1.default.asCollectionObject(_this._space_ref.path, _this._space_ref.id + '/tags'), _this._user);
|
|
4840
4956
|
})];
|
|
4841
4957
|
case 3:
|
|
4842
|
-
|
|
4843
|
-
console.log('error fetching tags: ',
|
|
4958
|
+
e_24 = _c.sent();
|
|
4959
|
+
console.log('error fetching tags: ', e_24);
|
|
4844
4960
|
return [3, 4];
|
|
4845
4961
|
case 4: return [2];
|
|
4846
4962
|
}
|
|
@@ -5149,7 +5265,7 @@ var Space = (function () {
|
|
|
5149
5265
|
});
|
|
5150
5266
|
}); };
|
|
5151
5267
|
this._setHideProPrices = function (hideProPrices) { return __awaiter(_this, void 0, void 0, function () {
|
|
5152
|
-
var currentValue, currentHistory, newHistory, startDateWithEmptyEndDate,
|
|
5268
|
+
var currentValue, currentHistory, newHistory, startDateWithEmptyEndDate, e_25;
|
|
5153
5269
|
return __generator(this, function (_c) {
|
|
5154
5270
|
switch (_c.label) {
|
|
5155
5271
|
case 0:
|
|
@@ -5179,15 +5295,15 @@ var Space = (function () {
|
|
|
5179
5295
|
_c.sent();
|
|
5180
5296
|
return [2, true];
|
|
5181
5297
|
case 3:
|
|
5182
|
-
|
|
5183
|
-
console.log('error on saving values to space: ',
|
|
5298
|
+
e_25 = _c.sent();
|
|
5299
|
+
console.log('error on saving values to space: ', e_25.toString());
|
|
5184
5300
|
return [2, false];
|
|
5185
5301
|
case 4: return [2];
|
|
5186
5302
|
}
|
|
5187
5303
|
});
|
|
5188
5304
|
}); };
|
|
5189
5305
|
this._setFixedPromoBanner = function (fixedPromoBannerData) { return __awaiter(_this, void 0, void 0, function () {
|
|
5190
|
-
var
|
|
5306
|
+
var e_26;
|
|
5191
5307
|
return __generator(this, function (_c) {
|
|
5192
5308
|
switch (_c.label) {
|
|
5193
5309
|
case 0:
|
|
@@ -5199,8 +5315,8 @@ var Space = (function () {
|
|
|
5199
5315
|
_c.sent();
|
|
5200
5316
|
return [2, true];
|
|
5201
5317
|
case 2:
|
|
5202
|
-
|
|
5203
|
-
console.log('error on saving values to space: ',
|
|
5318
|
+
e_26 = _c.sent();
|
|
5319
|
+
console.log('error on saving values to space: ', e_26.toString());
|
|
5204
5320
|
return [2, false];
|
|
5205
5321
|
case 3: return [2];
|
|
5206
5322
|
}
|
|
@@ -5301,7 +5417,7 @@ var Space = (function () {
|
|
|
5301
5417
|
});
|
|
5302
5418
|
};
|
|
5303
5419
|
this._updateG2Calls = function (optionsToUpdate) { return __awaiter(_this, void 0, void 0, function () {
|
|
5304
|
-
var
|
|
5420
|
+
var e_27;
|
|
5305
5421
|
return __generator(this, function (_c) {
|
|
5306
5422
|
switch (_c.label) {
|
|
5307
5423
|
case 0:
|
|
@@ -5313,8 +5429,8 @@ var Space = (function () {
|
|
|
5313
5429
|
_c.sent();
|
|
5314
5430
|
return [2, true];
|
|
5315
5431
|
case 2:
|
|
5316
|
-
|
|
5317
|
-
console.log('error on saving g2Calls to space',
|
|
5432
|
+
e_27 = _c.sent();
|
|
5433
|
+
console.log('error on saving g2Calls to space', e_27);
|
|
5318
5434
|
return [2, false];
|
|
5319
5435
|
case 3: return [2];
|
|
5320
5436
|
}
|
|
@@ -5427,7 +5543,7 @@ var Space = (function () {
|
|
|
5427
5543
|
return allBankTypes.filter(function (bt) { return !!returnInactive || !!bt.active; });
|
|
5428
5544
|
};
|
|
5429
5545
|
this._addBankType = function (name, active, association_type, rules) { return __awaiter(_this, void 0, void 0, function () {
|
|
5430
|
-
var currentBankTypes, newBankType,
|
|
5546
|
+
var currentBankTypes, newBankType, e_28;
|
|
5431
5547
|
var _c;
|
|
5432
5548
|
return __generator(this, function (_f) {
|
|
5433
5549
|
switch (_f.label) {
|
|
@@ -5453,15 +5569,15 @@ var Space = (function () {
|
|
|
5453
5569
|
_f.sent();
|
|
5454
5570
|
return [2, true];
|
|
5455
5571
|
case 3:
|
|
5456
|
-
|
|
5457
|
-
console.log('error on saving new bankType: ',
|
|
5572
|
+
e_28 = _f.sent();
|
|
5573
|
+
console.log('error on saving new bankType: ', e_28.toString());
|
|
5458
5574
|
return [2, false];
|
|
5459
5575
|
case 4: return [2];
|
|
5460
5576
|
}
|
|
5461
5577
|
});
|
|
5462
5578
|
}); };
|
|
5463
5579
|
this._updateBankType = function (id, rules, name, active, association_type) { return __awaiter(_this, void 0, void 0, function () {
|
|
5464
|
-
var currentBankTypes, bankTypeIndex, newVersion, bankToUpdate, updatedBankTypes,
|
|
5580
|
+
var currentBankTypes, bankTypeIndex, newVersion, bankToUpdate, updatedBankTypes, e_29;
|
|
5465
5581
|
var _c;
|
|
5466
5582
|
return __generator(this, function (_f) {
|
|
5467
5583
|
switch (_f.label) {
|
|
@@ -5490,8 +5606,8 @@ var Space = (function () {
|
|
|
5490
5606
|
_f.sent();
|
|
5491
5607
|
return [2, true];
|
|
5492
5608
|
case 3:
|
|
5493
|
-
|
|
5494
|
-
console.log('error on updating existing bank_type : ',
|
|
5609
|
+
e_29 = _f.sent();
|
|
5610
|
+
console.log('error on updating existing bank_type : ', e_29.toString());
|
|
5495
5611
|
return [2, false];
|
|
5496
5612
|
case 4: return [2];
|
|
5497
5613
|
}
|
|
@@ -5666,7 +5782,7 @@ var Space = (function () {
|
|
|
5666
5782
|
});
|
|
5667
5783
|
}); };
|
|
5668
5784
|
this._getBanksUsedHistoryForCustomer = function (customerID, filterOptions, searchOptions) { return __awaiter(_this, void 0, void 0, function () {
|
|
5669
|
-
var results,
|
|
5785
|
+
var results, e_30;
|
|
5670
5786
|
return __generator(this, function (_c) {
|
|
5671
5787
|
switch (_c.label) {
|
|
5672
5788
|
case 0:
|
|
@@ -5676,8 +5792,8 @@ var Space = (function () {
|
|
|
5676
5792
|
results = _c.sent();
|
|
5677
5793
|
return [2, results];
|
|
5678
5794
|
case 2:
|
|
5679
|
-
|
|
5680
|
-
console.log('error on fetching banks used history for customer ', customerID, ': ',
|
|
5795
|
+
e_30 = _c.sent();
|
|
5796
|
+
console.log('error on fetching banks used history for customer ', customerID, ': ', e_30.toString());
|
|
5681
5797
|
return [2];
|
|
5682
5798
|
case 3: return [2];
|
|
5683
5799
|
}
|
|
@@ -5686,7 +5802,7 @@ var Space = (function () {
|
|
|
5686
5802
|
this._getAvailableBankAmountsByBankType = function (customerID, filterToApply) {
|
|
5687
5803
|
if (filterToApply === void 0) { filterToApply = 'active-and-before'; }
|
|
5688
5804
|
return __awaiter(_this, void 0, void 0, function () {
|
|
5689
|
-
var allCustomerPAs, allCustomerPAsData, historyForCustomer, currentlyActiveBanksInPAs, allCustomerBanks, _i, _c, pa, _loop_5, _f, _g, bank, orderedHistoryById, orderedByBankType, _loop_6, _h, allCustomerBanks_1, bank, _j, _k, _l, bankID, values,
|
|
5805
|
+
var allCustomerPAs, allCustomerPAsData, historyForCustomer, currentlyActiveBanksInPAs, allCustomerBanks, _i, _c, pa, _loop_5, _f, _g, bank, orderedHistoryById, orderedByBankType, _loop_6, _h, allCustomerBanks_1, bank, _j, _k, _l, bankID, values, e_31;
|
|
5690
5806
|
var _m;
|
|
5691
5807
|
return __generator(this, function (_o) {
|
|
5692
5808
|
switch (_o.label) {
|
|
@@ -5759,8 +5875,8 @@ var Space = (function () {
|
|
|
5759
5875
|
}
|
|
5760
5876
|
return [2, orderedByBankType];
|
|
5761
5877
|
case 3:
|
|
5762
|
-
|
|
5763
|
-
console.log('error on calulating remaining amount for customer banks: ',
|
|
5878
|
+
e_31 = _o.sent();
|
|
5879
|
+
console.log('error on calulating remaining amount for customer banks: ', e_31.toString());
|
|
5764
5880
|
return [2];
|
|
5765
5881
|
case 4: return [2];
|
|
5766
5882
|
}
|
|
@@ -5892,7 +6008,7 @@ var Space = (function () {
|
|
|
5892
6008
|
});
|
|
5893
6009
|
}); };
|
|
5894
6010
|
this._closeSeasonPromisesToPurchase = function (yearToClose, userClosingID) { return __awaiter(_this, void 0, void 0, function () {
|
|
5895
|
-
var currentClosed, yearAlreadyClosed, currentValues,
|
|
6011
|
+
var currentClosed, yearAlreadyClosed, currentValues, e_32;
|
|
5896
6012
|
return __generator(this, function (_c) {
|
|
5897
6013
|
switch (_c.label) {
|
|
5898
6014
|
case 0:
|
|
@@ -5917,15 +6033,15 @@ var Space = (function () {
|
|
|
5917
6033
|
_c.sent();
|
|
5918
6034
|
return [2, true];
|
|
5919
6035
|
case 3:
|
|
5920
|
-
|
|
5921
|
-
console.log('error on saving space: ',
|
|
6036
|
+
e_32 = _c.sent();
|
|
6037
|
+
console.log('error on saving space: ', e_32.toString());
|
|
5922
6038
|
return [2, false];
|
|
5923
6039
|
case 4: return [2];
|
|
5924
6040
|
}
|
|
5925
6041
|
});
|
|
5926
6042
|
}); };
|
|
5927
6043
|
this._openSeasonPromisesToPurchase = function (season, userOpeningId) { return __awaiter(_this, void 0, void 0, function () {
|
|
5928
|
-
var currentOpen, yearToOpen, yearAlreadyOpened, currentValues, newRecord,
|
|
6044
|
+
var currentOpen, yearToOpen, yearAlreadyOpened, currentValues, newRecord, e_33;
|
|
5929
6045
|
return __generator(this, function (_c) {
|
|
5930
6046
|
switch (_c.label) {
|
|
5931
6047
|
case 0:
|
|
@@ -5967,15 +6083,15 @@ var Space = (function () {
|
|
|
5967
6083
|
_c.sent();
|
|
5968
6084
|
return [2, true];
|
|
5969
6085
|
case 3:
|
|
5970
|
-
|
|
5971
|
-
console.log('error on saving space: ',
|
|
6086
|
+
e_33 = _c.sent();
|
|
6087
|
+
console.log('error on saving space: ', e_33.toString());
|
|
5972
6088
|
return [2, false];
|
|
5973
6089
|
case 4: return [2];
|
|
5974
6090
|
}
|
|
5975
6091
|
});
|
|
5976
6092
|
}); };
|
|
5977
6093
|
this._endSeasonPromisesToPurchase = function (yearToEnd, userEndingId) { return __awaiter(_this, void 0, void 0, function () {
|
|
5978
|
-
var currentEnded, yearAlreadyEnded, currentValues,
|
|
6094
|
+
var currentEnded, yearAlreadyEnded, currentValues, e_34;
|
|
5979
6095
|
return __generator(this, function (_c) {
|
|
5980
6096
|
switch (_c.label) {
|
|
5981
6097
|
case 0:
|
|
@@ -6000,8 +6116,8 @@ var Space = (function () {
|
|
|
6000
6116
|
_c.sent();
|
|
6001
6117
|
return [2, true];
|
|
6002
6118
|
case 3:
|
|
6003
|
-
|
|
6004
|
-
console.log('error on saving space: ',
|
|
6119
|
+
e_34 = _c.sent();
|
|
6120
|
+
console.log('error on saving space: ', e_34.toString());
|
|
6005
6121
|
return [2, false];
|
|
6006
6122
|
case 4: return [2];
|
|
6007
6123
|
}
|
|
@@ -6038,7 +6154,7 @@ var Space = (function () {
|
|
|
6038
6154
|
});
|
|
6039
6155
|
}); };
|
|
6040
6156
|
this._getBanksUsedHistory = function (filterOptions, searchOptions) { return __awaiter(_this, void 0, void 0, function () {
|
|
6041
|
-
var filtersToSet, filters, basicSearchInfo, results,
|
|
6157
|
+
var filtersToSet, filters, basicSearchInfo, results, e_35;
|
|
6042
6158
|
return __generator(this, function (_c) {
|
|
6043
6159
|
switch (_c.label) {
|
|
6044
6160
|
case 0:
|
|
@@ -6070,8 +6186,8 @@ var Space = (function () {
|
|
|
6070
6186
|
throw new Error('Could not complete search for history');
|
|
6071
6187
|
return [2, results.hits];
|
|
6072
6188
|
case 3:
|
|
6073
|
-
|
|
6074
|
-
console.log('error on fetching: ',
|
|
6189
|
+
e_35 = _c.sent();
|
|
6190
|
+
console.log('error on fetching: ', e_35.toString());
|
|
6075
6191
|
return [2];
|
|
6076
6192
|
case 4: return [2];
|
|
6077
6193
|
}
|
|
@@ -6102,7 +6218,7 @@ var Space = (function () {
|
|
|
6102
6218
|
return remainingAmounts;
|
|
6103
6219
|
};
|
|
6104
6220
|
this._getAvailableBankAmountsForPromise = function (promiseID, promiseObj) { return __awaiter(_this, void 0, void 0, function () {
|
|
6105
|
-
var promiseToCheck, promiseQuery,
|
|
6221
|
+
var promiseToCheck, promiseQuery, e_36, _c, banks, promise_unique_id_1, historyForPromise_1, historyQuery, e_37, remainingAmountsForBanks, e_38;
|
|
6106
6222
|
return __generator(this, function (_f) {
|
|
6107
6223
|
switch (_f.label) {
|
|
6108
6224
|
case 0:
|
|
@@ -6122,8 +6238,8 @@ var Space = (function () {
|
|
|
6122
6238
|
}
|
|
6123
6239
|
return [3, 4];
|
|
6124
6240
|
case 3:
|
|
6125
|
-
|
|
6126
|
-
console.log('error on fetching PA from DB: ',
|
|
6241
|
+
e_36 = _f.sent();
|
|
6242
|
+
console.log('error on fetching PA from DB: ', e_36.toString());
|
|
6127
6243
|
return [3, 4];
|
|
6128
6244
|
case 4:
|
|
6129
6245
|
if (!!!promiseToCheck)
|
|
@@ -6142,8 +6258,8 @@ var Space = (function () {
|
|
|
6142
6258
|
historyForPromise_1 = historyQuery;
|
|
6143
6259
|
return [3, 8];
|
|
6144
6260
|
case 7:
|
|
6145
|
-
|
|
6146
|
-
console.log('error on fetching history for promise: ',
|
|
6261
|
+
e_37 = _f.sent();
|
|
6262
|
+
console.log('error on fetching history for promise: ', e_37.toString());
|
|
6147
6263
|
return [3, 8];
|
|
6148
6264
|
case 8:
|
|
6149
6265
|
remainingAmountsForBanks = banks.map(function (bank) {
|
|
@@ -6154,15 +6270,15 @@ var Space = (function () {
|
|
|
6154
6270
|
});
|
|
6155
6271
|
return [2, remainingAmountsForBanks];
|
|
6156
6272
|
case 9:
|
|
6157
|
-
|
|
6158
|
-
console.log("error on calculating avaiable amounts for banks of promise ".concat(promiseID),
|
|
6273
|
+
e_38 = _f.sent();
|
|
6274
|
+
console.log("error on calculating avaiable amounts for banks of promise ".concat(promiseID), e_38.toString());
|
|
6159
6275
|
return [2];
|
|
6160
6276
|
case 10: return [2];
|
|
6161
6277
|
}
|
|
6162
6278
|
});
|
|
6163
6279
|
}); };
|
|
6164
6280
|
this._getSpecificAvailableBankAmount = function (promiseID, bankID, promiseObj) { return __awaiter(_this, void 0, void 0, function () {
|
|
6165
|
-
var promiseToCheck, promiseQuery,
|
|
6281
|
+
var promiseToCheck, promiseQuery, e_39, sameBankInPromise, initialAmount, bankHistory, calculatedValues, e_40;
|
|
6166
6282
|
return __generator(this, function (_c) {
|
|
6167
6283
|
switch (_c.label) {
|
|
6168
6284
|
case 0:
|
|
@@ -6182,8 +6298,8 @@ var Space = (function () {
|
|
|
6182
6298
|
}
|
|
6183
6299
|
return [3, 4];
|
|
6184
6300
|
case 3:
|
|
6185
|
-
|
|
6186
|
-
console.log('error on fetching PA from DB: ',
|
|
6301
|
+
e_39 = _c.sent();
|
|
6302
|
+
console.log('error on fetching PA from DB: ', e_39.toString());
|
|
6187
6303
|
return [3, 4];
|
|
6188
6304
|
case 4:
|
|
6189
6305
|
if (!!!promiseToCheck)
|
|
@@ -6202,8 +6318,8 @@ var Space = (function () {
|
|
|
6202
6318
|
calculatedValues = __assign({ promise_id: promiseID, promise_unique_id: promiseToCheck.data().promise_unique_id, bank_type_id: bankID }, (0, promiseToPurchase_1.calculatedRemainingBankAmount)(initialAmount, bankHistory));
|
|
6203
6319
|
return [2, calculatedValues];
|
|
6204
6320
|
case 7:
|
|
6205
|
-
|
|
6206
|
-
console.log('error on calculating amount remaining for specific bank: ',
|
|
6321
|
+
e_40 = _c.sent();
|
|
6322
|
+
console.log('error on calculating amount remaining for specific bank: ', e_40.toString());
|
|
6207
6323
|
return [2];
|
|
6208
6324
|
case 8: return [2];
|
|
6209
6325
|
}
|
|
@@ -6402,7 +6518,7 @@ var Space = (function () {
|
|
|
6402
6518
|
});
|
|
6403
6519
|
}); };
|
|
6404
6520
|
this._saveDocument = function (file, specificPath, imgixUrl, imgixKey) { return __awaiter(_this, void 0, void 0, function () {
|
|
6405
|
-
var ref, headers, data,
|
|
6521
|
+
var ref, headers, data, e_41;
|
|
6406
6522
|
return __generator(this, function (_c) {
|
|
6407
6523
|
switch (_c.label) {
|
|
6408
6524
|
case 0:
|
|
@@ -6434,8 +6550,8 @@ var Space = (function () {
|
|
|
6434
6550
|
_c.label = 3;
|
|
6435
6551
|
case 3: return [3, 5];
|
|
6436
6552
|
case 4:
|
|
6437
|
-
|
|
6438
|
-
console.log('Error while updating document in firebase bucket: ',
|
|
6553
|
+
e_41 = _c.sent();
|
|
6554
|
+
console.log('Error while updating document in firebase bucket: ', e_41);
|
|
6439
6555
|
return [3, 5];
|
|
6440
6556
|
case 5: return [2];
|
|
6441
6557
|
}
|
|
@@ -6519,7 +6635,9 @@ var Space = (function () {
|
|
|
6519
6635
|
this.transferRequests = {
|
|
6520
6636
|
get: this._getAllTransfertRequests,
|
|
6521
6637
|
snapshot: this._getTransfertRequestsSnapshot,
|
|
6522
|
-
getOne: this._getATransfertRequest
|
|
6638
|
+
getOne: this._getATransfertRequest,
|
|
6639
|
+
getTransferStatusOrder: this._getTransferRequestStatusOrderForSpace,
|
|
6640
|
+
getOneByRef: this._getTransferRequestByRef
|
|
6523
6641
|
};
|
|
6524
6642
|
this.cartItem = {
|
|
6525
6643
|
get: this._getCartItems,
|
|
@@ -6672,7 +6790,8 @@ var Space = (function () {
|
|
|
6672
6790
|
add: this._addNewUnitToShippingPref,
|
|
6673
6791
|
deleteAt: this._deleteUnitToShippingPref,
|
|
6674
6792
|
updateAt: this._updateUnitToShippingPref,
|
|
6675
|
-
get: this._getUnitToShippingPref
|
|
6793
|
+
get: this._getUnitToShippingPref,
|
|
6794
|
+
updateFullUnitAt: this._updateFullUnitToShippingPref
|
|
6676
6795
|
},
|
|
6677
6796
|
envelops: {
|
|
6678
6797
|
add: this._addNewEnvelopToShippingPref,
|