addio-admin-sdk 1.7.133 → 1.7.135
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.
|
@@ -556,7 +556,6 @@ export default class Space {
|
|
|
556
556
|
* @param amount The amount to add or remove
|
|
557
557
|
* @param comment The reason for this change
|
|
558
558
|
* @param user The user doing the action
|
|
559
|
-
* @returns
|
|
560
559
|
*/
|
|
561
560
|
private _modifyStoreCredit;
|
|
562
561
|
private _getStoreCreditToUse;
|
|
@@ -760,7 +759,7 @@ export default class Space {
|
|
|
760
759
|
};
|
|
761
760
|
updateCustomerLastActivity: (customerId: string, user: string, date?: Date) => Promise<void>;
|
|
762
761
|
credits: {
|
|
763
|
-
modify: (customerId: string, creditSlug: string, amount: number, comment: string, user: string) => Promise<
|
|
762
|
+
modify: (customerId: string, creditSlug: string, amount: number, comment: string, user: string) => Promise<ICustomer['store_credits']>;
|
|
764
763
|
get: (customerId: string, creditSlug: string) => Promise<number>;
|
|
765
764
|
getHistory: (customerId: string, creditSlug: string) => Promise<IStoreCreditHistory[]>;
|
|
766
765
|
validate: (customerId: string, creditSlug: string, amount: number) => Promise<boolean>;
|
package/dist/lib/Space/index.js
CHANGED
|
@@ -4941,7 +4941,6 @@ class Space {
|
|
|
4941
4941
|
* @param amount The amount to add or remove
|
|
4942
4942
|
* @param comment The reason for this change
|
|
4943
4943
|
* @param user The user doing the action
|
|
4944
|
-
* @returns
|
|
4945
4944
|
*/
|
|
4946
4945
|
this._modifyStoreCredit = async (customerId, creditSlug, amount, comment, user) => {
|
|
4947
4946
|
if (!customerId)
|
|
@@ -4952,8 +4951,6 @@ class Space {
|
|
|
4952
4951
|
throw new Error('A comment is required');
|
|
4953
4952
|
if (!user)
|
|
4954
4953
|
throw new Error('The user doing the action is required');
|
|
4955
|
-
if (amount == 0)
|
|
4956
|
-
return true; // do nothing if amount is 0
|
|
4957
4954
|
const customerPath = DatabaseService_1.default.addToPath(this._space_ref.path, this._space_ref.id + '/customers');
|
|
4958
4955
|
const historyPath = DatabaseService_1.default.addToPath(this._space_ref.path, this._space_ref.id + '/store_credit_history');
|
|
4959
4956
|
// fetch the user document
|
|
@@ -4973,6 +4970,8 @@ class Space {
|
|
|
4973
4970
|
else {
|
|
4974
4971
|
credits[index] = Object.assign(Object.assign({}, credits[index]), { amount: credits[index].amount + amount });
|
|
4975
4972
|
}
|
|
4973
|
+
if (amount == 0)
|
|
4974
|
+
return credits; // do nothing, and return credit as-is if amount is 0
|
|
4976
4975
|
// create history
|
|
4977
4976
|
const history = {
|
|
4978
4977
|
amount: amount,
|
|
@@ -4988,7 +4987,7 @@ class Space {
|
|
|
4988
4987
|
// save the new amount
|
|
4989
4988
|
if (!(await DatabaseService_1.default.saveDocument(customerPath, customerId, 0, { store_credits: credits }, { merge: true })))
|
|
4990
4989
|
throw new Error('Unable to save new credit value');
|
|
4991
|
-
return
|
|
4990
|
+
return credits;
|
|
4992
4991
|
};
|
|
4993
4992
|
this._getStoreCreditToUse = () => {
|
|
4994
4993
|
const allCredits = this.data().store_credits || [];
|