@freedom_sky/feige-lib 5.5.1 → 5.6.0

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.
@@ -37,7 +37,7 @@ export declare function dishShowPriceWithBuffet({ dishPrice, dishId, buffet, ord
37
37
  /**
38
38
  *
39
39
  */
40
- export declare function getRoundCoundAndSecondsToNextTurn({ order }: {
40
+ export declare function getRoundCoundAndSecondsToNextTurn({ order, }: {
41
41
  order: Order;
42
42
  }): {
43
43
  roundCount?: number;
@@ -63,11 +63,10 @@ function getRoundCoundAndSecondsToNextTurn(_a) {
63
63
  if (!((_c = buffetCombosItems.orderingByTurns) === null || _c === void 0 ? void 0 : _c.enable)) {
64
64
  throw 'Buffet ordering by turns is not enabled';
65
65
  }
66
- ;
67
66
  var _d = buffetCombosItems.orderingByTurns, interval = _d.interval, maxRounds = _d.maxRounds;
68
67
  var previousBuffetSubmitTasks = order.tasks.filter(function (task) {
69
68
  return (task.type === index_1.CONST.TASK_TYPE.CHECK || task.type === index_1.CONST.TASK_TYPE.APPEND) &&
70
- _haveAtLeastOneSameItem(task.content.map(function (content) { return content.dishSnapshot._id; }), buffetCombosItems.dishes.map(function (dish) { return dish.dishId; }));
69
+ _haveAtLeastOneSameItem(task.content.map(function (content) { return String(content.dishSnapshot._id); }), buffetCombosItems.dishes.map(function (dish) { return String(dish.dishId); }));
71
70
  });
72
71
  if (previousBuffetSubmitTasks.length === 0) {
73
72
  secondsToNextTurn = 0;
@@ -82,10 +81,14 @@ function getRoundCoundAndSecondsToNextTurn(_a) {
82
81
  return {
83
82
  roundCount: previousBuffetSubmitTasks.length,
84
83
  secondsToNextTurn: secondsToNextTurn,
85
- maxRounds: maxRounds
84
+ maxRounds: maxRounds,
86
85
  };
87
86
  }
88
87
  exports.getRoundCoundAndSecondsToNextTurn = getRoundCoundAndSecondsToNextTurn;
88
+ /**
89
+ * @param arr1
90
+ * @param arr2
91
+ */
89
92
  function _haveAtLeastOneSameItem(arr1, arr2) {
90
93
  var set1 = new Set(arr1);
91
94
  return arr2.some(function (item) { return set1.has(item); });
@@ -492,6 +492,18 @@ var Const = /** @class */ (function () {
492
492
  codepage: 'cp1253',
493
493
  defaultPrintEncodeType: printer_enum_1.EncodeTypeEnum.IMG,
494
494
  },
495
+ {
496
+ name: 'العربية',
497
+ img: '',
498
+ code: 'ar',
499
+ speechCode: 'ar-AE',
500
+ speechLang: 'ar',
501
+ dateFormat: common_enum_1.DateFormat.YEAR_MONTH_DAY,
502
+ defaultAreaCode: '971',
503
+ rtl: true,
504
+ codepage: 'utf-8',
505
+ defaultPrintEncodeType: printer_enum_1.EncodeTypeEnum.IMG
506
+ }
495
507
  ];
496
508
  this.DATE_FORMAT = {
497
509
  YEAR_MONTH_DAY: {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@freedom_sky/feige-lib",
3
- "version": "5.5.1",
3
+ "version": "5.6.0",
4
4
  "description": "",
5
5
  "main": "dist/index.js",
6
6
  "scripts": {
@@ -76,40 +76,48 @@ export function dishShowPriceWithBuffet({
76
76
  *
77
77
  */
78
78
  export function getRoundCoundAndSecondsToNextTurn({
79
- order
79
+ order,
80
80
  }: {
81
- order: Order
81
+ order: Order;
82
82
  }): {
83
- roundCount?: number,
84
- maxRounds?: number,
85
- secondsToNextTurn: number
83
+ roundCount?: number;
84
+ maxRounds?: number;
85
+ secondsToNextTurn: number;
86
86
  } {
87
87
  let secondsToNextTurn = 0;
88
88
  const buffetCombosItems = order.buffet?.snapshot;
89
89
  if (!buffetCombosItems.orderingByTurns?.enable) {
90
90
  throw 'Buffet ordering by turns is not enabled';
91
- };
91
+ }
92
92
  const { interval, maxRounds } = buffetCombosItems.orderingByTurns;
93
- const previousBuffetSubmitTasks = order.tasks.filter(task =>
94
- (task.type === CONST.TASK_TYPE.CHECK || task.type === CONST.TASK_TYPE.APPEND) &&
95
- _haveAtLeastOneSameItem(task.content.map(content => content.dishSnapshot._id), buffetCombosItems.dishes.map(dish => dish.dishId))
93
+ const previousBuffetSubmitTasks = order.tasks.filter(
94
+ (task) =>
95
+ (task.type === CONST.TASK_TYPE.CHECK || task.type === CONST.TASK_TYPE.APPEND) &&
96
+ _haveAtLeastOneSameItem(
97
+ task.content.map((content) => String(content.dishSnapshot._id)),
98
+ buffetCombosItems.dishes.map((dish) => String(dish.dishId)),
99
+ ),
96
100
  );
97
- if(previousBuffetSubmitTasks.length === 0) {
98
- secondsToNextTurn = 0
99
- }else if(previousBuffetSubmitTasks.length >= maxRounds) {
100
- secondsToNextTurn = Infinity
101
- }else {
102
- const lastBuffetSubmitTime = previousBuffetSubmitTasks[previousBuffetSubmitTasks.length -1].date;
101
+ if (previousBuffetSubmitTasks.length === 0) {
102
+ secondsToNextTurn = 0;
103
+ } else if (previousBuffetSubmitTasks.length >= maxRounds) {
104
+ secondsToNextTurn = Infinity;
105
+ } else {
106
+ const lastBuffetSubmitTime = previousBuffetSubmitTasks[previousBuffetSubmitTasks.length - 1].date;
103
107
  secondsToNextTurn = interval * 60 - Math.floor((Date.now() - new Date(lastBuffetSubmitTime).getTime()) / 1000);
104
108
  }
105
109
  return {
106
110
  roundCount: previousBuffetSubmitTasks.length,
107
111
  secondsToNextTurn,
108
- maxRounds
109
- }
112
+ maxRounds,
113
+ };
110
114
  }
111
115
 
116
+ /**
117
+ * @param arr1
118
+ * @param arr2
119
+ */
112
120
  function _haveAtLeastOneSameItem<T>(arr1: T[], arr2: T[]): boolean {
113
121
  const set1 = new Set(arr1);
114
- return arr2.some(item => set1.has(item));
115
- }
122
+ return arr2.some((item) => set1.has(item));
123
+ }
@@ -490,6 +490,18 @@ class Const {
490
490
  codepage: 'cp1253',
491
491
  defaultPrintEncodeType: EncodeTypeEnum.IMG,
492
492
  },
493
+ {
494
+ name: 'العربية',
495
+ img: '',
496
+ code: 'ar',
497
+ speechCode: 'ar-AE',
498
+ speechLang: 'ar',
499
+ dateFormat: DateFormat.YEAR_MONTH_DAY,
500
+ defaultAreaCode: '971',
501
+ rtl: true,
502
+ codepage: 'utf-8',
503
+ defaultPrintEncodeType: EncodeTypeEnum.IMG
504
+ }
493
505
  ];
494
506
  DATE_FORMAT = {
495
507
  YEAR_MONTH_DAY: {