addio-admin-sdk 1.7.158 → 1.7.160

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.
@@ -33,5 +33,6 @@ export declare enum CashDrawerActionEnum {
33
33
  MANUAL_CASH_OUT = "manual_cash_out",
34
34
  END_SHIFT = "end_shift"
35
35
  }
36
+ export type CashDrawerOnlyUpdateActions = Extract<CashDrawerActionEnum, CashDrawerActionEnum.MANUAL_CASH_IN | CashDrawerActionEnum.MANUAL_CASH_OUT | CashDrawerActionEnum.ORDER_CASH_IN | CashDrawerActionEnum.ORDER_CASH_OUT>;
36
37
  export declare const getDefaultCashDrawer: () => ICashDrawer;
37
38
  export {};
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/Interfaces/CashDrawers/index.ts"],"names":[],"mappings":";;;AAAA,+BAAyB;AAiCzB,IAAY,oBAOX;AAPD,WAAY,oBAAoB;IAC/B,kDAA0B,CAAA;IAC1B,uDAA+B,CAAA;IAC/B,yDAAiC,CAAA;IACjC,yDAAiC,CAAA;IACjC,2DAAmC,CAAA;IACnC,+CAAuB,CAAA;AACxB,CAAC,EAPW,oBAAoB,GAApB,4BAAoB,KAApB,4BAAoB,QAO/B;AAEM,MAAM,oBAAoB,GAAG,GAAgB,EAAE,CAAC,CAAC;IACvD,EAAE,EAAE,IAAA,SAAE,GAAE;IACR,QAAQ,EAAE,EAAE;IACZ,MAAM,EAAE,IAAI;CACZ,CAAC,CAAA;AAJW,QAAA,oBAAoB,wBAI/B"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/Interfaces/CashDrawers/index.ts"],"names":[],"mappings":";;;AAAA,+BAAyB;AAiCzB,IAAY,oBAOX;AAPD,WAAY,oBAAoB;IAC/B,kDAA0B,CAAA;IAC1B,uDAA+B,CAAA;IAC/B,yDAAiC,CAAA;IACjC,yDAAiC,CAAA;IACjC,2DAAmC,CAAA;IACnC,+CAAuB,CAAA;AACxB,CAAC,EAPW,oBAAoB,GAApB,4BAAoB,KAApB,4BAAoB,QAO/B;AAUM,MAAM,oBAAoB,GAAG,GAAgB,EAAE,CAAC,CAAC;IACvD,EAAE,EAAE,IAAA,SAAE,GAAE;IACR,QAAQ,EAAE,EAAE;IACZ,MAAM,EAAE,IAAI;CACZ,CAAC,CAAA;AAJW,QAAA,oBAAoB,wBAI/B"}
@@ -64,7 +64,7 @@ import { MenuPositionEnum } from '../../Interfaces/Menu';
64
64
  import Menu from '../../lib/Menu';
65
65
  import Note from '../Note';
66
66
  import { NoteTypeEnum } from '../../Interfaces/Note';
67
- import { CashDrawerActionEnum, ICashDrawer, ICashDrawerInteraction } from '../../Interfaces/CashDrawers';
67
+ import { CashDrawerOnlyUpdateActions, CashDrawerActionEnum, ICashDrawer, ICashDrawerInteraction } from '../../Interfaces/CashDrawers';
68
68
  import CashDrawerShift from '../CashDrawerShift';
69
69
  /**
70
70
  * Class Space
@@ -669,6 +669,14 @@ export default class Space {
669
669
  * @param note Optionnal. The custom note added by user on close
670
670
  */
671
671
  private _closeCashDrawer;
672
+ /**
673
+ * Generate and save new update to amount for a cash drawer's open shift.
674
+ * @param drawerId The current drawer
675
+ * @param cashAmount The amount of the manual update (can be negative)
676
+ * @param reason The reason for the update.
677
+ * @param note The note added by user on update (only passed if generated manually and nor from order)
678
+ */
679
+ private _saveNewCashUpdateInteraction;
672
680
  attributes: {
673
681
  get: (options?: IQueryOptions) => Promise<Attribute[]>;
674
682
  add: (attribute: IAttribute) => Promise<void>;
@@ -1140,6 +1148,7 @@ export default class Space {
1140
1148
  }) => Promise<ICashDrawerInteraction[]>;
1141
1149
  open: (drawerId: string, cashDownAmount: number) => Promise<boolean>;
1142
1150
  close: (drawerId: string, cashAmount: number, note?: string) => Promise<boolean>;
1151
+ addManualUpdate: (drawerId: string, cashAmount: number, reason: CashDrawerOnlyUpdateActions, note?: string) => Promise<boolean>;
1143
1152
  };
1144
1153
  /**
1145
1154
  * Get all space properties
@@ -5286,6 +5286,26 @@ class Space {
5286
5286
  const closed = await sameShift.closeShift(cashAmount, note);
5287
5287
  return closed;
5288
5288
  };
5289
+ /**
5290
+ * Generate and save new update to amount for a cash drawer's open shift.
5291
+ * @param drawerId The current drawer
5292
+ * @param cashAmount The amount of the manual update (can be negative)
5293
+ * @param reason The reason for the update.
5294
+ * @param note The note added by user on update (only passed if generated manually and nor from order)
5295
+ */
5296
+ this._saveNewCashUpdateInteraction = async (drawerId, cashAmount, reason, note) => {
5297
+ const sameShift = await this.cashDrawers.getOpenShift(drawerId);
5298
+ if (!sameShift)
5299
+ throw new Error('Could not find corresponding shift!');
5300
+ const type = [CashDrawers_1.CashDrawerActionEnum.MANUAL_CASH_OUT, CashDrawers_1.CashDrawerActionEnum.MANUAL_CASH_IN].includes(reason)
5301
+ ? 'manual'
5302
+ : 'from_order';
5303
+ const fncToCall = [CashDrawers_1.CashDrawerActionEnum.MANUAL_CASH_OUT, CashDrawers_1.CashDrawerActionEnum.ORDER_CASH_OUT].includes(reason)
5304
+ ? sameShift.newCashOut
5305
+ : sameShift.newCashIn;
5306
+ const addedManualUpdate = await fncToCall(cashAmount, type, { reason: note || '' });
5307
+ return addedManualUpdate;
5308
+ };
5289
5309
  // #endregion
5290
5310
  // -------------------------------------------------------------------------------
5291
5311
  // #region PUBLIC GETTER FUNCTIONS
@@ -5683,7 +5703,8 @@ class Space {
5683
5703
  getOpenShift: this._getOpenShiftForDrawer,
5684
5704
  getInteractionHistory: this._getInteractionHistoryForDrawer,
5685
5705
  open: this._openCashDrawer,
5686
- close: this._closeCashDrawer
5706
+ close: this._closeCashDrawer,
5707
+ addManualUpdate: this._saveNewCashUpdateInteraction
5687
5708
  };
5688
5709
  // #endregion
5689
5710
  /**