import { CashDrawerActionEnum, ICashDrawerShift } from '../../Interfaces/CashDrawers'; import { BaseServiceClass } from '../baseService'; import Space from '../Space'; export default class CashDrawerShift extends BaseServiceClass { private _space; private _cashDrawerId; constructor(space: Space, cashDrawerId: string, _data: ICashDrawerShift, _collection: { path: string; }, _user: string); data: () => ICashDrawerShift; save: (partialShift?: Partial) => Promise; /** * Delete function overriden so it can't be called though class */ delete: () => Promise; /** * Get cash drawer interaction string for specified action, in specified locale. * @static * @param action A streamlined enum of cash drawer actions - supports all EXCEPT manual actions (MANUAL_CASH_IN and MANUAL_CASH_OUT) * @param locale Optionnal. The local to use. Defaults to 'fr'. * @param orderRef Optionnal. Order ref number to add to string. Only used in ORDER type actions, and defaults to 'ND' if undefined. * @returns The translated string. */ static getTranslatedGenericInteractionReason: (action: Exclude, locale: string | undefined, orderRef?: string) => string; /** * Create a new open shift entry, and save result to database. Also calls function to generate the corresponding interaction. * @static * @param amountInDrawer The cash amount in drawer on open. * @param space Space obj instance. * @param associatedDrawerId The cash drawer id associated to shift * @param userEmail The user that initiated cash drawer opening. * @throws If something goes wrong on save for new shift obj. * @returns The newly generated CashDrawerShift instance. */ static openShift: (amountInDrawer: number, space: Space, associatedDrawerId: string, userEmail: string) => Promise; /** * Generates a new CashDrawerInteraction with provided data and saves entry to database. * @private * @param type The action done on cash drawer * @param amount The amount of cash "moved" with the interaction. * @param options.reason The string reason for the interaction. Will either be generated string for all "normal" interactions, or a user generated string if a manual interaction. * @throws If current shift data has no ID set (meaning it was never saved to database). * @returns If the interaction was saved successfully. */ private _saveNewInteraction; /** * Generate data needed to close the shift and update data in database. Also calls function to generate corresponding interaction. * @param amountInDrawer The cash amount in drawer on close * @param note Optionnal. If a custom note should be passed to reason props of interaction object. * @param userEmail Optionnal. If user who initiated the close if different from the class initiating user. Defaults to value sent to constructor if undefined. * @throws If shift is not currently "open". * @throws If something goes wrong on saving Shift. * @returns If close was successfull. */ closeShift: (amountInDrawer: number, note?: string, userEmail?: string) => Promise; /** * Calls function to generate and save new interaction for cash added to drawer. * @param amount The cash amount added to the drawer * @param type The interaction type. Either 'from_order' or 'manual' * @param options.reason The reason for the added cash interaction. * @param options.userEmail Optionnal. If user who added cash to drawer is different from the class initiating user. Defaults to value sent to constructor if undefined. * @throws If shift is not currently "open". * @throws If something goes wrong on saving Shift. * @returns If interaction was saved successfully or not */ newCashIn: (amount: number, type: 'manual' | 'from_order', options: { reason: string; userEmail?: string; }) => Promise; /** * Calls function to generate and save new interaction for cash removed from drawer. * @param amount The cash amount removed from the drawer * @param type The interaction type. Either 'from_order' or 'manual' * @param options.reason The reason for the removed cash interaction. * @param options.userEmail Optionnal. If user who removed cash from drawer is different from the class initiating user. Defaults to value sent to constructor if undefined. * @throws If shift is not currently "open". * @throws If something goes wrong on saving Shift. * @returns If interaction was saved successfully or not */ newCashOut: (amount: number, type: 'manual' | 'from_order', options: { reason: string; userEmail?: string; }) => Promise; }