@freedom_sky/feige-lib 4.56.0 → 4.58.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.
package/dist/index.d.ts CHANGED
@@ -33,6 +33,7 @@ import * as moment from 'moment';
33
33
  import Big from 'big.js';
34
34
  import { OrderTypeEnum } from './enum/order.enum';
35
35
  export * from './buffet/index';
36
+ export * from './order/index';
36
37
  export { Order, Process, Content, Checkout, CONST, DishSnapshot, User, UserSafe, CertificatePath, Task, VisitTask, moment, PrintStatusEnum, PrinterDeviceTypeEnum, PrinterWidthEnum, Big, };
37
38
  /**
38
39
  * 小数转化为金额,去除分位之后的尾数
package/dist/index.js CHANGED
@@ -37,6 +37,7 @@ var tax_enum_1 = require("./enum/tax.enum");
37
37
  var order_enum_1 = require("./enum/order.enum");
38
38
  var index_1 = require("./buffet/index");
39
39
  __export(require("./buffet/index"));
40
+ __export(require("./order/index"));
40
41
  /**
41
42
  * 小数转化为金额,去除分位之后的尾数
42
43
  *
@@ -106,6 +106,8 @@ export interface Store {
106
106
  };
107
107
  readonly buffetSetting: {
108
108
  enable: boolean;
109
+ showDishesOutOfBuffetInClient: boolean;
110
+ allowDishNumberExceedSetLimitInClient: boolean;
109
111
  buffetCombos: BuffetCombosItems[];
110
112
  };
111
113
  readonly allergenSetting: {
@@ -0,0 +1,17 @@
1
+ import { Order, Content } from '../index';
2
+ export interface PrinteDishInfo {
3
+ name: string;
4
+ count: number;
5
+ price: number;
6
+ specifications: string[];
7
+ }
8
+ /**
9
+ *
10
+ */
11
+ export declare function getDishArrFromContents({ contents, lang, specificationInNewLine, order, showBuffet, }: {
12
+ contents: Content[];
13
+ lang: string;
14
+ specificationInNewLine: boolean;
15
+ order: Order;
16
+ showBuffet?: boolean;
17
+ }): Promise<PrinteDishInfo[]>;
@@ -0,0 +1,110 @@
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ var __generator = (this && this.__generator) || function (thisArg, body) {
12
+ var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
13
+ return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
14
+ function verb(n) { return function (v) { return step([n, v]); }; }
15
+ function step(op) {
16
+ if (f) throw new TypeError("Generator is already executing.");
17
+ while (_) try {
18
+ if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
19
+ if (y = 0, t) op = [op[0] & 2, t.value];
20
+ switch (op[0]) {
21
+ case 0: case 1: t = op; break;
22
+ case 4: _.label++; return { value: op[1], done: false };
23
+ case 5: _.label++; y = op[1]; op = [0]; continue;
24
+ case 7: op = _.ops.pop(); _.trys.pop(); continue;
25
+ default:
26
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
27
+ if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
28
+ if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
29
+ if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
30
+ if (t[2]) _.ops.pop();
31
+ _.trys.pop(); continue;
32
+ }
33
+ op = body.call(thisArg, _);
34
+ } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
35
+ if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
36
+ }
37
+ };
38
+ Object.defineProperty(exports, "__esModule", { value: true });
39
+ var index_1 = require("../index");
40
+ /**
41
+ *
42
+ */
43
+ function getDishArrFromContents(_a) {
44
+ var contents = _a.contents, lang = _a.lang, specificationInNewLine = _a.specificationInNewLine, order = _a.order, showBuffet = _a.showBuffet;
45
+ return __awaiter(this, void 0, void 0, function () {
46
+ var result, specifications, _b, _c, _d, _e, _f, _g;
47
+ return __generator(this, function (_h) {
48
+ switch (_h.label) {
49
+ case 0:
50
+ result = contents.map(function (dishGroup) {
51
+ var _a;
52
+ var selectedNames = [];
53
+ dishGroup.dishSnapshot.selectedSpecifications.forEach(function (selectedItems) {
54
+ selectedItems.content.forEach(function (tag) {
55
+ selectedNames.push(tag.name);
56
+ });
57
+ });
58
+ var name = dishGroup.dishSnapshot.name;
59
+ if (!specificationInNewLine && selectedNames.length > 0) {
60
+ name += "(" + selectedNames.join() + ")";
61
+ }
62
+ if (dishGroup.dishSnapshot.type === index_1.DishType.Weigh) {
63
+ name += "(" + dishGroup.weight + (index_1.getNameFromNames(dishGroup.dishSnapshot.units, lang, index_1.CONST.DEFALUT_LANGUAGE) || '') + ")";
64
+ }
65
+ return {
66
+ name: name,
67
+ count: dishGroup.count,
68
+ price: index_1.calcContentPrice({
69
+ orderContentItem: dishGroup,
70
+ buffetItem: (_a = order.buffet) === null || _a === void 0 ? void 0 : _a.snapshot,
71
+ orderType: order.type,
72
+ adultNum: order.adultNum,
73
+ childNum: order.childNum,
74
+ contents: order.content,
75
+ }) / dishGroup.count,
76
+ specifications: selectedNames,
77
+ };
78
+ });
79
+ if (!(showBuffet && order.type === index_1.OrderTypeEnum.Buffet)) return [3 /*break*/, 5];
80
+ specifications = [];
81
+ if (!order.adultNum) return [3 /*break*/, 2];
82
+ _c = (_b = specifications).push;
83
+ _d = "";
84
+ return [4 /*yield*/, this.i18n.translate('printer.TEMPLATE.ADULT', { lang: lang })];
85
+ case 1:
86
+ _c.apply(_b, [_d + (_h.sent()) + order.adultNum]);
87
+ _h.label = 2;
88
+ case 2:
89
+ if (!order.childNum) return [3 /*break*/, 4];
90
+ _f = (_e = specifications).push;
91
+ _g = "";
92
+ return [4 /*yield*/, this.i18n.translate('printer.TEMPLATE.CHILD', { lang: lang })];
93
+ case 3:
94
+ _f.apply(_e, [_g + (_h.sent()) + order.childNum]);
95
+ _h.label = 4;
96
+ case 4:
97
+ result.unshift({
98
+ name: index_1.getNameFromNames(order.buffet.snapshot.names, lang, index_1.CONST.DEFALUT_LANGUAGE) +
99
+ ("(" + specifications.join() + ")"),
100
+ count: 1,
101
+ price: index_1.calcBuffetTotalPrice(order.buffet.snapshot, order.adultNum, order.childNum),
102
+ specifications: specifications,
103
+ });
104
+ _h.label = 5;
105
+ case 5: return [2 /*return*/, result];
106
+ }
107
+ });
108
+ });
109
+ }
110
+ exports.getDishArrFromContents = getDishArrFromContents;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@freedom_sky/feige-lib",
3
- "version": "4.56.0",
3
+ "version": "4.58.0",
4
4
  "description": "",
5
5
  "main": "dist/index.js",
6
6
  "scripts": {
package/src/index.ts CHANGED
@@ -36,6 +36,7 @@ import { TaxTypeEnum } from './enum/tax.enum';
36
36
  import { OrderTypeEnum } from './enum/order.enum';
37
37
  import { calcBuffetTotalPrice, getDishItemInBuffet, getMaxBuffetDishUpperLimit } from './buffet/index';
38
38
  export * from './buffet/index';
39
+ export * from './order/index';
39
40
  export {
40
41
  Order,
41
42
  Process,
@@ -117,6 +117,8 @@ export interface Store {
117
117
  };
118
118
  readonly buffetSetting: {
119
119
  enable: boolean;
120
+ showDishesOutOfBuffetInClient: boolean;
121
+ allowDishNumberExceedSetLimitInClient: boolean;
120
122
  buffetCombos: BuffetCombosItems[];
121
123
  };
122
124
  readonly allergenSetting: {
@@ -0,0 +1,84 @@
1
+ import {
2
+ DishType,
3
+ Order,
4
+ CONST,
5
+ getNameFromNames,
6
+ Content,
7
+ calcBuffetTotalPrice,
8
+ calcContentPrice,
9
+ OrderTypeEnum,
10
+ } from '../index';
11
+
12
+ export interface PrinteDishInfo {
13
+ name: string;
14
+ count: number;
15
+ price: number;
16
+ specifications: string[];
17
+ }
18
+
19
+ /**
20
+ *
21
+ */
22
+ export async function getDishArrFromContents({
23
+ contents,
24
+ lang,
25
+ specificationInNewLine,
26
+ order,
27
+ showBuffet,
28
+ }: {
29
+ contents: Content[];
30
+ lang: string;
31
+ specificationInNewLine: boolean;
32
+ order: Order;
33
+ showBuffet?: boolean;
34
+ }): Promise<PrinteDishInfo[]> {
35
+ const result = contents.map((dishGroup) => {
36
+ const selectedNames = [];
37
+ dishGroup.dishSnapshot.selectedSpecifications.forEach((selectedItems) => {
38
+ selectedItems.content.forEach((tag) => {
39
+ selectedNames.push(tag.name);
40
+ });
41
+ });
42
+ let name = dishGroup.dishSnapshot.name;
43
+ if (!specificationInNewLine && selectedNames.length > 0) {
44
+ name += `(${selectedNames.join()})`;
45
+ }
46
+ if (dishGroup.dishSnapshot.type === DishType.Weigh) {
47
+ name += `(${dishGroup.weight}${
48
+ getNameFromNames(dishGroup.dishSnapshot.units, lang, CONST.DEFALUT_LANGUAGE) || ''
49
+ })`;
50
+ }
51
+ return {
52
+ name,
53
+ count: dishGroup.count,
54
+ price:
55
+ calcContentPrice({
56
+ orderContentItem: dishGroup,
57
+ buffetItem: order.buffet?.snapshot,
58
+ orderType: order.type,
59
+ adultNum: order.adultNum,
60
+ childNum: order.childNum,
61
+ contents: order.content,
62
+ }) / dishGroup.count,
63
+ specifications: selectedNames,
64
+ };
65
+ });
66
+ if (showBuffet && order.type === OrderTypeEnum.Buffet) {
67
+ const specifications = [];
68
+ if (order.adultNum) {
69
+ specifications.push(`${await this.i18n.translate('printer.TEMPLATE.ADULT', { lang })}${order.adultNum}`);
70
+ }
71
+ if (order.childNum) {
72
+ specifications.push(`${await this.i18n.translate('printer.TEMPLATE.CHILD', { lang })}${order.childNum}`);
73
+ }
74
+ result.unshift({
75
+ name:
76
+ getNameFromNames(order.buffet.snapshot.names, lang, CONST.DEFALUT_LANGUAGE) +
77
+ `(${specifications.join()})`,
78
+ count: 1,
79
+ price: calcBuffetTotalPrice(order.buffet.snapshot, order.adultNum, order.childNum),
80
+ specifications: specifications,
81
+ });
82
+ }
83
+ return result;
84
+ }