addio-admin-sdk 1.7.96 → 1.7.98
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/Interfaces/CartReservedQuantities/index.d.ts +8 -0
- package/dist/Interfaces/CartReservedQuantities/index.js +3 -0
- package/dist/Interfaces/CartReservedQuantities/index.js.map +1 -0
- package/dist/Interfaces/Space/index.d.ts +7 -5
- package/dist/Interfaces/Space/index.js +3 -1
- package/dist/Interfaces/Space/index.js.map +1 -1
- package/dist/Interfaces/Store/index.d.ts +1 -0
- package/dist/Interfaces/Store/index.js.map +1 -1
- package/dist/lib/Cart/index.d.ts +2 -0
- package/dist/lib/Cart/index.js +43 -20
- package/dist/lib/Cart/index.js.map +1 -1
- package/dist/lib/CartReservedQuantities/index.d.ts +12 -0
- package/dist/lib/CartReservedQuantities/index.js +106 -0
- package/dist/lib/CartReservedQuantities/index.js.map +1 -0
- package/dist/lib/Inventory/index.d.ts +2 -0
- package/dist/lib/Inventory/index.js +10 -0
- package/dist/lib/Inventory/index.js.map +1 -1
- package/dist/lib/Space/index.d.ts +1 -0
- package/dist/utils/cart.js +1 -1
- package/dist/utils/cart.js.map +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/Interfaces/CartReservedQuantities/index.ts"],"names":[],"mappings":""}
|
|
@@ -42,6 +42,10 @@ export default interface ISpace {
|
|
|
42
42
|
end?: Date;
|
|
43
43
|
}[];
|
|
44
44
|
readonly fixed_promo_banner?: IFixedPromoBanner;
|
|
45
|
+
readonly available_menu_positions?: {
|
|
46
|
+
name: string;
|
|
47
|
+
slug: string;
|
|
48
|
+
}[];
|
|
45
49
|
};
|
|
46
50
|
readonly models?: {
|
|
47
51
|
readonly cms?: {
|
|
@@ -300,7 +304,8 @@ export declare enum spaceCollectionNames {
|
|
|
300
304
|
CATALOGUES = "catalogues",
|
|
301
305
|
ATTRIBUTES = "attributes",
|
|
302
306
|
TRANSFER_REQUESTS = "transfer_requests",
|
|
303
|
-
NOTES = "notes"
|
|
307
|
+
NOTES = "notes",
|
|
308
|
+
CART_RESERVED_QUANTITIES = "cart_reserved_quantities"
|
|
304
309
|
}
|
|
305
310
|
export declare enum POSTypeEnum {
|
|
306
311
|
PUBLIC = "public",
|
|
@@ -318,6 +323,7 @@ export interface ISpaceOptions {
|
|
|
318
323
|
readonly inventory?: {
|
|
319
324
|
readonly minimum_inventory_per_sku: boolean;
|
|
320
325
|
readonly bulk_inventory_edit?: boolean;
|
|
326
|
+
readonly reserve_on_add_to_cart?: boolean;
|
|
321
327
|
};
|
|
322
328
|
readonly tags: {
|
|
323
329
|
readonly available: boolean;
|
|
@@ -335,10 +341,6 @@ export interface ISpaceOptions {
|
|
|
335
341
|
readonly can_edit_sliders?: boolean;
|
|
336
342
|
readonly can_set_detailed_store_schedule?: boolean;
|
|
337
343
|
readonly custom_menu?: boolean;
|
|
338
|
-
readonly available_menu_positions?: {
|
|
339
|
-
name: string;
|
|
340
|
-
slug: string;
|
|
341
|
-
}[];
|
|
342
344
|
};
|
|
343
345
|
readonly security?: {
|
|
344
346
|
readonly no_nip_from_pos?: boolean;
|
|
@@ -30,6 +30,7 @@ var spaceCollectionNames;
|
|
|
30
30
|
spaceCollectionNames["ATTRIBUTES"] = "attributes";
|
|
31
31
|
spaceCollectionNames["TRANSFER_REQUESTS"] = "transfer_requests";
|
|
32
32
|
spaceCollectionNames["NOTES"] = "notes";
|
|
33
|
+
spaceCollectionNames["CART_RESERVED_QUANTITIES"] = "cart_reserved_quantities";
|
|
33
34
|
})(spaceCollectionNames = exports.spaceCollectionNames || (exports.spaceCollectionNames = {}));
|
|
34
35
|
var POSTypeEnum;
|
|
35
36
|
(function (POSTypeEnum) {
|
|
@@ -47,7 +48,8 @@ const getDefaultSpaceOptions = () => ({
|
|
|
47
48
|
},
|
|
48
49
|
inventory: {
|
|
49
50
|
minimum_inventory_per_sku: false,
|
|
50
|
-
bulk_inventory_edit: false
|
|
51
|
+
bulk_inventory_edit: false,
|
|
52
|
+
reserve_on_add_to_cart: false
|
|
51
53
|
},
|
|
52
54
|
tags: {
|
|
53
55
|
available: false,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/Interfaces/Space/index.ts"],"names":[],"mappings":";;;AAWA,kCAAgE;AAMhE,gDAAqE;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/Interfaces/Space/index.ts"],"names":[],"mappings":";;;AAWA,kCAAgE;AAMhE,gDAAqE;AAuSrE,IAAY,oBA2BX;AA3BD,WAAY,oBAAoB;IAC/B,mDAA2B,CAAA;IAC3B,0DAAkC,CAAA;IAClC,iDAAyB,CAAA;IACzB,+CAAuB,CAAA;IACvB,uCAAe,CAAA;IACf,yCAAiB,CAAA;IACjB,6CAAqB,CAAA;IACrB,+CAAuB,CAAA;IACvB,mDAA2B,CAAA;IAC3B,6CAAqB,CAAA;IACrB,qCAAa,CAAA;IACb,6CAAqB,CAAA;IACrB,yDAAiC,CAAA;IACjC,2CAAmB,CAAA;IACnB,2CAAmB,CAAA;IACnB,+DAAuC,CAAA;IACvC,yCAAiB,CAAA;IACjB,iDAAyB,CAAA;IACzB,uDAA+B,CAAA;IAC/B,2DAAmC,CAAA;IACnC,uDAA+B,CAAA;IAC/B,iDAAyB,CAAA;IACzB,iDAAyB,CAAA;IACzB,+DAAuC,CAAA;IACvC,uCAAe,CAAA;IACf,6EAAqD,CAAA;AACtD,CAAC,EA3BW,oBAAoB,GAApB,4BAAoB,KAApB,4BAAoB,QA2B/B;AAED,IAAY,WAGX;AAHD,WAAY,WAAW;IACtB,gCAAiB,CAAA;IACjB,wCAAyB,CAAA;AAC1B,CAAC,EAHW,WAAW,GAAX,mBAAW,KAAX,mBAAW,QAGtB;AA8DM,MAAM,sBAAsB,GAAG,GAAkB,EAAE,CAAC,CAAC;IAC3D,QAAQ,EAAE;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CAAC;IACzE,IAAI,EAAE,EAAE;IACR,IAAI,EAAE,EAAE;IACR,OAAO,EAAE;QACR,6BAA6B,EAAE,KAAK;QACpC,2BAA2B,EAAE,KAAK;KAClC;IACD,SAAS,EAAE;QACV,wCAAwC,EAAE,KAAK;KAC/C;IACD,iBAAiB,EAAE,IAAA,oCAAsB,EAAC,KAAK,CAAC,WAAW,CAAC,SAAS,EAAE,CAAC;IACxE,uBAAuB,EAAE,IAAA,oCAAsB,EAAC,KAAK,CAAC,WAAW,CAAC,SAAS,EAAE,CAAC;IAC9E,wBAAwB,EAAE,IAAA,oCAAsB,EAAC,KAAK,CAAC,WAAW,CAAC,SAAS,EAAE,CAAC;CAC/E,CAAC,CAAA;AAbW,QAAA,uBAAuB,2BAalC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/Interfaces/Store/index.ts"],"names":[],"mappings":";;;AAAA,wCAAwD;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/Interfaces/Store/index.ts"],"names":[],"mappings":";;;AAAA,wCAAwD;AA+BxD,IAAY,aAGX;AAHD,WAAY,aAAa;IACxB,gCAAe,CAAA;IACf,wCAAuB,CAAA;AACxB,CAAC,EAHW,aAAa,GAAb,qBAAa,KAAb,qBAAa,QAGxB;AAEM,MAAM,eAAe,GAAG,GAAG,EAAE;IACnC,OAAO;QACN,EAAE,EAAE,EAAE;QACN,IAAI,EAAE,aAAa,CAAC,KAAK;QACzB,IAAI,EAAE,EAAE;QACR,QAAQ,EAAE,KAAK;QACf,eAAe,EAAE,KAAK;QACtB,eAAe,EAAE,IAAI;QACrB,eAAe,EAAE,IAAI;QACrB,OAAO,EAAE,IAAA,2BAAiB,GAAE;QAC5B,KAAK,EAAE,EAAE;QACT,KAAK,EAAE,EAAE;QACT,sBAAsB,EAAE,IAAI;QAC5B,wBAAwB,EAAE,KAAK;QAC/B,iBAAiB,EAAE,EAAE;KACrB,CAAA;AACF,CAAC,CAAA;AAhBY,QAAA,eAAe,mBAgB3B"}
|
package/dist/lib/Cart/index.d.ts
CHANGED
|
@@ -21,6 +21,7 @@ import { BaseServiceClass } from '../baseService';
|
|
|
21
21
|
import { TransferRequest } from '../TransferRequest';
|
|
22
22
|
import ITransferRequest from '../../Interfaces/TransferRequest';
|
|
23
23
|
import { IExternalServices } from '../../Interfaces/Space/IExternalService';
|
|
24
|
+
import CartReservedQuantities from '../CartReservedQuantities';
|
|
24
25
|
export default class Cart extends BaseServiceClass<ICart> {
|
|
25
26
|
private _allTaxes;
|
|
26
27
|
constructor(data: any, collection: {
|
|
@@ -49,6 +50,7 @@ export default class Cart extends BaseServiceClass<ICart> {
|
|
|
49
50
|
checkIfAmountLeftToPayOnTotal: () => boolean;
|
|
50
51
|
getCustomerById: () => Promise<Customer | undefined>;
|
|
51
52
|
getCustomerByEmail: () => Promise<Customer | undefined>;
|
|
53
|
+
getReservedQuantities: () => Promise<CartReservedQuantities>;
|
|
52
54
|
canEnterPredefinedBox: (box: IPredefinedBox, subtotalToRespect?: number, weightToRespect?: number, totalItemsToRespect?: number, space?: Space) => boolean;
|
|
53
55
|
getTotalHeight: (unit?: 'inches' | 'centimeters') => number;
|
|
54
56
|
getTotalLength: (unit?: 'inches' | 'centimeters') => number;
|
package/dist/lib/Cart/index.js
CHANGED
|
@@ -31,13 +31,14 @@ const chunk_1 = __importDefault(require("lodash/chunk"));
|
|
|
31
31
|
const discount_1 = require("../../utils/discount");
|
|
32
32
|
const data_1 = require("../../utils/data");
|
|
33
33
|
const Cart_1 = require("../../Interfaces/Cart");
|
|
34
|
+
const Space_1 = require("../../Interfaces/Space");
|
|
34
35
|
const Customer_1 = __importDefault(require("../Customer"));
|
|
35
36
|
const console_1 = require("../../utils/console");
|
|
36
37
|
const weight_1 = require("../../utils/weight");
|
|
37
38
|
const dimensions_1 = require("../../utils/dimensions");
|
|
38
39
|
const Tax_1 = __importDefault(require("../Tax"));
|
|
39
40
|
const IDiscountRule_1 = require("../../Interfaces/Rules/IDiscountRule");
|
|
40
|
-
const
|
|
41
|
+
const Space_2 = __importDefault(require("../Space"));
|
|
41
42
|
const Shipment_1 = __importDefault(require("../Shipment"));
|
|
42
43
|
const Customer_2 = require("../../Interfaces/Customer");
|
|
43
44
|
const algolia_1 = require("../../utils/algolia");
|
|
@@ -68,6 +69,7 @@ const cart_3 = require("../../rules/GR/interfaces/cart");
|
|
|
68
69
|
const TransferRequest_1 = require("../TransferRequest");
|
|
69
70
|
const TransferRequest_2 = require("../../Interfaces/TransferRequest");
|
|
70
71
|
const inventories_1 = require("../../utils/inventories");
|
|
72
|
+
const CartReservedQuantities_1 = __importDefault(require("../CartReservedQuantities"));
|
|
71
73
|
class Cart extends baseService_1.BaseServiceClass {
|
|
72
74
|
constructor(data, collection, user, resetErrors) {
|
|
73
75
|
super(data, collection, user);
|
|
@@ -116,7 +118,7 @@ class Cart extends baseService_1.BaseServiceClass {
|
|
|
116
118
|
if (!!this._data.items && !!this._data.items.length) {
|
|
117
119
|
try {
|
|
118
120
|
if (!!!space)
|
|
119
|
-
space = await
|
|
121
|
+
space = await Space_2.default.getCurrentSpaceWithRef(this._collection.path, this._user);
|
|
120
122
|
if (!!!this._data.current_store_id && this._data.status >= Cart_1.CartStatusEnum.CART_READY_TO_PROCESS)
|
|
121
123
|
throw new Error('No store associated to cart');
|
|
122
124
|
await space.inventory.ajust(this._data.items, 'cancelled', this._data.cart_type, {
|
|
@@ -132,7 +134,7 @@ class Cart extends baseService_1.BaseServiceClass {
|
|
|
132
134
|
if (!!associatedTransfers && !!associatedTransfers.toCancel) {
|
|
133
135
|
try {
|
|
134
136
|
if (!!!space)
|
|
135
|
-
space = await
|
|
137
|
+
space = await Space_2.default.getCurrentSpaceWithRef(this._collection.path, this._user);
|
|
136
138
|
for (let transfer of associatedTransfers.toCancel) {
|
|
137
139
|
try {
|
|
138
140
|
const transferObj = new TransferRequest_1.TransferRequest(transfer, DatabaseService_1.default.asCollectionObject(space.getRef().path, space.getRef().id + '/transfer_requests'), this._user);
|
|
@@ -209,7 +211,7 @@ class Cart extends baseService_1.BaseServiceClass {
|
|
|
209
211
|
}
|
|
210
212
|
}
|
|
211
213
|
let partialCartToSave = Object.assign(Object.assign({}, this._data), partial);
|
|
212
|
-
const space = await
|
|
214
|
+
const space = await Space_2.default.getCurrentSpaceWithRef(this._collection.path, this._user);
|
|
213
215
|
if (!space.isMultiPromo()) {
|
|
214
216
|
const { cart_promos_applied } = partialCartToSave, rest = __rest(partialCartToSave, ["cart_promos_applied"]);
|
|
215
217
|
if (!!partialCartToSave.cart_promos_applied && !!partialCartToSave.cart_promos_applied.length) {
|
|
@@ -322,6 +324,27 @@ class Cart extends baseService_1.BaseServiceClass {
|
|
|
322
324
|
return undefined;
|
|
323
325
|
}
|
|
324
326
|
};
|
|
327
|
+
this.getReservedQuantities = async () => {
|
|
328
|
+
if (!this._data.id)
|
|
329
|
+
throw new Error(`Can't create reservation on unsaved cart`);
|
|
330
|
+
if (DatabaseService_1.default.getPathParent(this._collection.path) == '/')
|
|
331
|
+
throw new Error(`Can't access parent collections`);
|
|
332
|
+
const docPath = DatabaseService_1.default.addToPath(DatabaseService_1.default.getPathParent(this._collection.path), Space_1.spaceCollectionNames.CART_RESERVED_QUANTITIES);
|
|
333
|
+
const doc = await DatabaseService_1.default.getDocuments(docPath, {
|
|
334
|
+
query: [
|
|
335
|
+
{
|
|
336
|
+
field: 'cart_id',
|
|
337
|
+
operator: '==',
|
|
338
|
+
value: this._data.id
|
|
339
|
+
}
|
|
340
|
+
]
|
|
341
|
+
});
|
|
342
|
+
if (!!doc && !!doc.length)
|
|
343
|
+
return new CartReservedQuantities_1.default(doc[0].data, { path: doc[0].path }, this._user);
|
|
344
|
+
return new CartReservedQuantities_1.default({ cart_id: this._data.id, items: [] }, {
|
|
345
|
+
path: docPath
|
|
346
|
+
}, this._user);
|
|
347
|
+
};
|
|
325
348
|
this.canEnterPredefinedBox = (box, subtotalToRespect, weightToRespect, totalItemsToRespect, space) => {
|
|
326
349
|
if (!!subtotalToRespect) {
|
|
327
350
|
if (!!!this.data().subtotal && !!space) {
|
|
@@ -917,7 +940,7 @@ class Cart extends baseService_1.BaseServiceClass {
|
|
|
917
940
|
return this._data;
|
|
918
941
|
};
|
|
919
942
|
this.createPaymentIntent = async () => {
|
|
920
|
-
const space = await
|
|
943
|
+
const space = await Space_2.default.getCurrentSpaceWithRef(this._collection.path, this._user);
|
|
921
944
|
const shippingServiceCredz = space.data().external_services.find((es) => !!es.is_active && es.type === 'payment');
|
|
922
945
|
if (!!!shippingServiceCredz)
|
|
923
946
|
throw new Error(`Must have a payment service to use this`);
|
|
@@ -1105,7 +1128,7 @@ class Cart extends baseService_1.BaseServiceClass {
|
|
|
1105
1128
|
!!!other_payment_method &&
|
|
1106
1129
|
!!!multi_payment_methods)
|
|
1107
1130
|
throw new Error(`Payment intent payload must be set`);
|
|
1108
|
-
const space = await
|
|
1131
|
+
const space = await Space_2.default.getCurrentSpaceWithRef(this._collection.path, this._user);
|
|
1109
1132
|
const getPaymentRef = () => !!other_payment_method && !!other_payment_method.payment_ref
|
|
1110
1133
|
? other_payment_method.payment_ref
|
|
1111
1134
|
: !!pandapay_payload
|
|
@@ -1260,7 +1283,7 @@ class Cart extends baseService_1.BaseServiceClass {
|
|
|
1260
1283
|
console.log('====================');
|
|
1261
1284
|
console.log('in setCartAsCompleted');
|
|
1262
1285
|
try {
|
|
1263
|
-
const space = await
|
|
1286
|
+
const space = await Space_2.default.getCurrentSpaceWithRef(this._collection.path, this._user);
|
|
1264
1287
|
if (!!!space)
|
|
1265
1288
|
throw new Error('could not init space obj');
|
|
1266
1289
|
console.log('---------------');
|
|
@@ -1297,7 +1320,7 @@ class Cart extends baseService_1.BaseServiceClass {
|
|
|
1297
1320
|
const shouldSaveToDB = typeof options.saveToDatabase == 'boolean' ? options.saveToDatabase : true;
|
|
1298
1321
|
try {
|
|
1299
1322
|
const itemsForInventory = (0, cart_1.getModifiedItems)(newItems, oldItems);
|
|
1300
|
-
const space = await
|
|
1323
|
+
const space = await Space_2.default.getCurrentSpaceWithRef(this._collection.path, this._user);
|
|
1301
1324
|
if (!!!space)
|
|
1302
1325
|
throw new Error('could not init space obj');
|
|
1303
1326
|
if (!!options.usedPromise) {
|
|
@@ -1414,7 +1437,7 @@ class Cart extends baseService_1.BaseServiceClass {
|
|
|
1414
1437
|
};
|
|
1415
1438
|
this.checkPromoCode = async (promoCode, oldPromos) => {
|
|
1416
1439
|
var _b;
|
|
1417
|
-
const space = await
|
|
1440
|
+
const space = await Space_2.default.getCurrentSpaceWithRef(this._collection.path, this._user);
|
|
1418
1441
|
const cartData = this._data;
|
|
1419
1442
|
if (!!!cartData)
|
|
1420
1443
|
return "Une erreur s'est produite";
|
|
@@ -1532,7 +1555,7 @@ class Cart extends baseService_1.BaseServiceClass {
|
|
|
1532
1555
|
console.log('skipping discount rule check for booking cart!');
|
|
1533
1556
|
return;
|
|
1534
1557
|
}
|
|
1535
|
-
const space = await
|
|
1558
|
+
const space = await Space_2.default.getCurrentSpaceWithRef(this._collection.path, this._user);
|
|
1536
1559
|
if (!!!space)
|
|
1537
1560
|
return new Error(`Can't find space`);
|
|
1538
1561
|
const allDiscountRules = await space.discountRules.get({
|
|
@@ -1708,7 +1731,7 @@ class Cart extends baseService_1.BaseServiceClass {
|
|
|
1708
1731
|
};
|
|
1709
1732
|
this.calculateTotals = async (currency, forcedPromos) => {
|
|
1710
1733
|
var _b, _c, _d;
|
|
1711
|
-
const space = await
|
|
1734
|
+
const space = await Space_2.default.getCurrentSpaceWithRef(this._collection.path, this._user);
|
|
1712
1735
|
if (!!!space)
|
|
1713
1736
|
return new Error(`Can't find space`);
|
|
1714
1737
|
let allTaxes = this._allTaxes;
|
|
@@ -1924,7 +1947,7 @@ class Cart extends baseService_1.BaseServiceClass {
|
|
|
1924
1947
|
};
|
|
1925
1948
|
this.getAssociatedTransferRequests = async () => {
|
|
1926
1949
|
try {
|
|
1927
|
-
const space = await
|
|
1950
|
+
const space = await Space_2.default.getCurrentSpaceWithRef(this._collection.path, this._user);
|
|
1928
1951
|
const cartTransferRequestQuery = await DatabaseService_1.default.getDocuments(DatabaseService_1.default.addToPath(space.getRef().path, space.getRef().id + '/transfer_requests'), { query: [{ field: 'associated_order', operator: '==', value: this._data.ref }] });
|
|
1929
1952
|
return cartTransferRequestQuery;
|
|
1930
1953
|
}
|
|
@@ -1971,7 +1994,7 @@ class Cart extends baseService_1.BaseServiceClass {
|
|
|
1971
1994
|
: {})), { free_shipping: false });
|
|
1972
1995
|
};
|
|
1973
1996
|
this._getCredz = async () => {
|
|
1974
|
-
const space = await
|
|
1997
|
+
const space = await Space_2.default.getCurrentSpaceWithRef(this._collection.path, this._user);
|
|
1975
1998
|
const shippingServiceCredz = space.data().external_services.filter((es) => !!es.is_active && es.type === 'shipping');
|
|
1976
1999
|
if (!!!shippingServiceCredz) {
|
|
1977
2000
|
const baseShippingCostDeterminedByTheOwner = space.data().transport_preferences.override_shipping_with_cost;
|
|
@@ -2031,7 +2054,7 @@ class Cart extends baseService_1.BaseServiceClass {
|
|
|
2031
2054
|
}, undefined);
|
|
2032
2055
|
return shipmentInfo;
|
|
2033
2056
|
}
|
|
2034
|
-
const space = await
|
|
2057
|
+
const space = await Space_2.default.getCurrentSpaceWithRef(this._collection.path, this._user);
|
|
2035
2058
|
if (!!!space)
|
|
2036
2059
|
return new Error(`Can't find space`);
|
|
2037
2060
|
this.calculateSubtotal(space);
|
|
@@ -2049,7 +2072,7 @@ class Cart extends baseService_1.BaseServiceClass {
|
|
|
2049
2072
|
return shipmentInfo.base_fee || 0;
|
|
2050
2073
|
};
|
|
2051
2074
|
this.packageCartInOneBox = async (dontSaveToCart = false) => {
|
|
2052
|
-
const space = await
|
|
2075
|
+
const space = await Space_2.default.getCurrentSpaceWithRef(this._collection.path, this._user);
|
|
2053
2076
|
const spaceData = space.data();
|
|
2054
2077
|
let boxes = [];
|
|
2055
2078
|
if (!!!spaceData.transport_preferences.predefined_boxes ||
|
|
@@ -2098,7 +2121,7 @@ class Cart extends baseService_1.BaseServiceClass {
|
|
|
2098
2121
|
return boxes;
|
|
2099
2122
|
};
|
|
2100
2123
|
this.packageCart = async (dontSaveToCart = false) => {
|
|
2101
|
-
const space = await
|
|
2124
|
+
const space = await Space_2.default.getCurrentSpaceWithRef(this._collection.path, this._user);
|
|
2102
2125
|
const spaceData = space.data();
|
|
2103
2126
|
let boxes = [];
|
|
2104
2127
|
if (!!!spaceData.transport_preferences.predefined_boxes ||
|
|
@@ -2403,7 +2426,7 @@ class Cart extends baseService_1.BaseServiceClass {
|
|
|
2403
2426
|
return false;
|
|
2404
2427
|
const { shippingServiceCredz } = resCredz;
|
|
2405
2428
|
const shipment = new Shipment_1.default(this, shippingServiceCredz);
|
|
2406
|
-
const space = await
|
|
2429
|
+
const space = await Space_2.default.getCurrentSpaceWithRef(this._collection.path, this._user);
|
|
2407
2430
|
try {
|
|
2408
2431
|
const quoteRes = await shipment.approveQuote(quote, false, {
|
|
2409
2432
|
cartItem: this,
|
|
@@ -2482,7 +2505,7 @@ class Cart extends baseService_1.BaseServiceClass {
|
|
|
2482
2505
|
defLabel = label.data || '';
|
|
2483
2506
|
if (!!__1.isTestEnv)
|
|
2484
2507
|
console.log('def', defLabel);
|
|
2485
|
-
const spaceObj = await
|
|
2508
|
+
const spaceObj = await Space_2.default.getCurrentSpaceWithRef(this._collection.path, this._user);
|
|
2486
2509
|
const useService = spaceObj.preferences.storage.getServiceToUse();
|
|
2487
2510
|
const downloadUrl = (await (0, file_1.uploadStringToPath)(useService, defLabel, spacePath, `order-${this.data().ref}`, 'pdf', {
|
|
2488
2511
|
generateFirebasePublicUrl: true
|
|
@@ -2635,7 +2658,7 @@ class Cart extends baseService_1.BaseServiceClass {
|
|
|
2635
2658
|
throw new Error(PromiseToPurchase_2.ApplyBanksToCartErrorsEnum.CUSTOM_PRICE_LIST_UNDEFINED);
|
|
2636
2659
|
await this._savePromiseToPurchaseInCart(applicableBanks, false);
|
|
2637
2660
|
try {
|
|
2638
|
-
const space = await
|
|
2661
|
+
const space = await Space_2.default.getCurrentSpaceWithRef(this._collection.path, this._user);
|
|
2639
2662
|
const remainingAmounts = await PromiseToPurchase_1.default.calculateRemainingAmounts(this, applicableBanks, applicableBanksHistory, space);
|
|
2640
2663
|
const potentialRemainingAmounts = this.calculatePotentialRemainingAmountsAndSetBanksUsedAmounts(remainingAmounts, applicableBanks, forcedBankTypeId);
|
|
2641
2664
|
if (!!!potentialRemainingAmounts.length) {
|
|
@@ -3091,7 +3114,7 @@ class Cart extends baseService_1.BaseServiceClass {
|
|
|
3091
3114
|
this.setCartAsRefunded = async (partial, itemsToReturnInventory, storeId) => {
|
|
3092
3115
|
if (!!itemsToReturnInventory && !!itemsToReturnInventory.length) {
|
|
3093
3116
|
try {
|
|
3094
|
-
const space = await
|
|
3117
|
+
const space = await Space_2.default.getCurrentSpaceWithRef(this._collection.path, this._user);
|
|
3095
3118
|
if (!!!this._data.current_store_id)
|
|
3096
3119
|
throw new Error('No store associated to cart');
|
|
3097
3120
|
await space.inventory.ajust(itemsToReturnInventory, 'refunded', this._data.cart_type, {
|