addio-admin-sdk 1.7.199 → 1.7.200
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/lib/Space/index.d.ts +1 -1
- package/dist/lib/Space/index.js +28 -4
- package/dist/lib/Space/index.js.map +1 -1
- package/dist/services/database/DatabaseService.d.ts +2 -1
- package/dist/services/database/DatabaseService.js +4 -1
- package/dist/services/database/DatabaseService.js.map +1 -1
- package/package.json +1 -1
|
@@ -93,7 +93,7 @@ export default class Space {
|
|
|
93
93
|
getCurrencies: () => ICurrencies | undefined;
|
|
94
94
|
incrementTransferRef: () => Promise<number>;
|
|
95
95
|
incrementOrderAndInvoiceRef: () => Promise<number>;
|
|
96
|
-
save: (partialSpace: Partial<ISpace>, saveToDatabase?: boolean) => Promise<
|
|
96
|
+
save: (partialSpace: Partial<ISpace>, saveToDatabase?: boolean) => Promise<boolean | null>;
|
|
97
97
|
listenOnChange: (callback: any) => string;
|
|
98
98
|
private _getAllCustomerGroups;
|
|
99
99
|
private _updateShippingFee;
|
package/dist/lib/Space/index.js
CHANGED
|
@@ -207,10 +207,12 @@ class Space {
|
|
|
207
207
|
};
|
|
208
208
|
this.save = async (partialSpace, saveToDatabase = true) => {
|
|
209
209
|
try {
|
|
210
|
+
let saved = null;
|
|
210
211
|
if (saveToDatabase) {
|
|
211
|
-
await DatabaseService_1.default.saveDocument(this._space_ref.path, this._space_ref.id, 0, partialSpace, { merge: true });
|
|
212
|
+
saved = await DatabaseService_1.default.saveDocument(this._space_ref.path, this._space_ref.id, 0, partialSpace, { merge: true });
|
|
212
213
|
}
|
|
213
214
|
this._space = Object.assign(Object.assign({}, this.data()), partialSpace);
|
|
215
|
+
return saved;
|
|
214
216
|
}
|
|
215
217
|
catch (error) {
|
|
216
218
|
(0, console_1.errorMessage)(error);
|
|
@@ -2977,7 +2979,7 @@ class Space {
|
|
|
2977
2979
|
let triesLeft = 3;
|
|
2978
2980
|
while (triesLeft > 0) {
|
|
2979
2981
|
try {
|
|
2980
|
-
const resp = await (0, isomorphic_unfetch_1.default)(`${api}/invoicenumber/${cartData.cart_type === Cart_1.CartTypeEnum.WEB ? 'numbered_by_web_type' : 'numbered_by_store'}?storeslug=${storeToUse}&webexpeditiontype=${wasPaidAtStore ? 'pickup' : !!cartData.is_pickup ? 'pickup' : 'delivery'}`, {
|
|
2982
|
+
const resp = await (0, isomorphic_unfetch_1.default)(`${api}/invoicenumber/${cartData.cart_type === Cart_1.CartTypeEnum.WEB ? 'numbered_by_web_type' : 'numbered_by_store'}?storeslug=${storeToUse}&webexpeditiontype=${wasPaidAtStore ? 'pickup' : !!cartData.is_pickup ? 'pickup' : 'delivery'}&cartref=${cartData.ref || ''}`, {
|
|
2981
2983
|
method: 'GET',
|
|
2982
2984
|
headers: {
|
|
2983
2985
|
'Content-Type': 'application/json',
|
|
@@ -3004,32 +3006,54 @@ class Space {
|
|
|
3004
3006
|
return newInvoiceRef;
|
|
3005
3007
|
};
|
|
3006
3008
|
this._incrementGeneralInvoiceRef = async (invoiceData) => {
|
|
3009
|
+
var _c, _f;
|
|
3007
3010
|
if (!!!invoiceData) {
|
|
3008
3011
|
throw new Error('invoice data not set in space');
|
|
3009
3012
|
}
|
|
3010
3013
|
// get min invoice ref number length
|
|
3011
3014
|
const newInvoiceRef = this._constructNewRefForInvoice(invoiceData);
|
|
3012
3015
|
try {
|
|
3013
|
-
await this.save({
|
|
3016
|
+
const saved = await this.save({
|
|
3014
3017
|
invoice_settings: Object.assign(Object.assign({}, invoiceData), { start_at: (0, toNumber_1.default)(invoiceData.start_at || 1) + (0, toNumber_1.default)(invoiceData.increment_by || 1) })
|
|
3015
3018
|
});
|
|
3019
|
+
if (!!!saved) {
|
|
3020
|
+
await (0, logs_1.SystemLog)({
|
|
3021
|
+
clientName: `sdk-admin | Space | invoiceRef | ${(0, services_1.getSpaceInitialsByID)(this.data().id)}`,
|
|
3022
|
+
clientToken: (_c = process.env.NEXT_PUBLIC_LOG_SYSTEM_KEY) !== null && _c !== void 0 ? _c : ''
|
|
3023
|
+
}, logs_1.LogType.ERROR, `${__1.isTestEnv ? 'TESTENV - ' : ''}INVOICE REF COUNTER NOT SAVED %%${newInvoiceRef}%%general%%${invoiceData.start_at}%%save refused`);
|
|
3024
|
+
}
|
|
3016
3025
|
return newInvoiceRef;
|
|
3017
3026
|
}
|
|
3018
3027
|
catch (e) {
|
|
3019
3028
|
console.log('error on saving new invoice_settings to space: ', e.toString());
|
|
3029
|
+
await (0, logs_1.SystemLog)({
|
|
3030
|
+
clientName: `sdk-admin | Space | invoiceRef | ${(0, services_1.getSpaceInitialsByID)(this.data().id)}`,
|
|
3031
|
+
clientToken: (_f = process.env.NEXT_PUBLIC_LOG_SYSTEM_KEY) !== null && _f !== void 0 ? _f : ''
|
|
3032
|
+
}, logs_1.LogType.ERROR, `${__1.isTestEnv ? 'TESTENV - ' : ''}INVOICE REF COUNTER NOT SAVED %%${newInvoiceRef}%%general%%${invoiceData.start_at}%%${e.toString()}`);
|
|
3020
3033
|
return '';
|
|
3021
3034
|
}
|
|
3022
3035
|
};
|
|
3023
3036
|
this._incrementStoreOrWebInvoiceRef = async (currentContent, objKey, storeOrWebTypeKey, currentInvoiceData) => {
|
|
3037
|
+
var _c, _f;
|
|
3024
3038
|
const newInvoiceRef = this._constructNewRefForInvoice(currentContent);
|
|
3025
3039
|
const objData = currentInvoiceData[objKey];
|
|
3026
3040
|
try {
|
|
3027
|
-
await this.save({
|
|
3041
|
+
const saved = await this.save({
|
|
3028
3042
|
invoice_settings: Object.assign(Object.assign({}, currentInvoiceData), { [objKey]: Object.assign(Object.assign({}, objData), { [storeOrWebTypeKey]: Object.assign(Object.assign({}, currentContent), { start_at: (0, toNumber_1.default)(currentContent.start_at || 1) + (0, toNumber_1.default)(currentContent.increment_by || 1) }) }) })
|
|
3029
3043
|
});
|
|
3044
|
+
if (!!!saved) {
|
|
3045
|
+
await (0, logs_1.SystemLog)({
|
|
3046
|
+
clientName: `sdk-admin | Space | invoiceRef | ${(0, services_1.getSpaceInitialsByID)(this.data().id)}`,
|
|
3047
|
+
clientToken: (_c = process.env.NEXT_PUBLIC_LOG_SYSTEM_KEY) !== null && _c !== void 0 ? _c : ''
|
|
3048
|
+
}, logs_1.LogType.ERROR, `${__1.isTestEnv ? 'TESTENV - ' : ''}INVOICE REF COUNTER NOT SAVED %%${newInvoiceRef}%%${objKey}.${storeOrWebTypeKey}%%${currentContent.start_at}%%save refused`);
|
|
3049
|
+
}
|
|
3030
3050
|
}
|
|
3031
3051
|
catch (e) {
|
|
3032
3052
|
console.log('error on saving new ref data to space for invoice : ', e.toString());
|
|
3053
|
+
await (0, logs_1.SystemLog)({
|
|
3054
|
+
clientName: `sdk-admin | Space | invoiceRef | ${(0, services_1.getSpaceInitialsByID)(this.data().id)}`,
|
|
3055
|
+
clientToken: (_f = process.env.NEXT_PUBLIC_LOG_SYSTEM_KEY) !== null && _f !== void 0 ? _f : ''
|
|
3056
|
+
}, logs_1.LogType.ERROR, `${__1.isTestEnv ? 'TESTENV - ' : ''}INVOICE REF COUNTER NOT SAVED %%${newInvoiceRef}%%${objKey}.${storeOrWebTypeKey}%%${currentContent.start_at}%%${e.toString()}`);
|
|
3033
3057
|
}
|
|
3034
3058
|
return newInvoiceRef;
|
|
3035
3059
|
};
|