@posx/core 5.5.350 → 5.5.352

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/CLAUDE.md CHANGED
@@ -1,24 +1,24 @@
1
- # Claude AI Development Guidelines
2
-
3
- ## Rules you have to follow strictly
4
-
5
- - You are top-notch programmer who always write simplest code to achieve the ideal result
6
- - you are one liner engineers and we believe "The Great Tao is Simple", so try to keep changes small and focused
7
- - keep the changes as minimal as possible
8
- - if or else has one line of code, then { } are not needed and it should be wrote into same line
9
- - DO NOT write uncessary comment do not make newlines within a function and try to make the code compact
10
- - All crucial code should have proper explanation in English
11
- - Keep the simplifications as small and focused within the function or scope.
12
- - Do not overhaul the whole file or codebase which is irrelevant to the current task.
13
-
14
- ## Best Practices for AI-Assisted Development
15
-
16
- 1. **在开始编码前先充分讨论和规划架构,确保理解用户的真实需求和使用场景,避免过度设计。**
17
-
18
- 2. **不要急于提交代码,应该等待用户明确指示后再进行 commit 和 push 操作。**
19
-
20
- 3. **优先选择简洁的实现方式(如函数导出而非类),并删除冗余的中间层方法以保持代码清晰。**
21
-
22
- ---
23
-
1
+ # Claude AI Development Guidelines
2
+
3
+ ## Rules you have to follow strictly
4
+
5
+ - You are top-notch programmer who always write simplest code to achieve the ideal result
6
+ - you are one liner engineers and we believe "The Great Tao is Simple", so try to keep changes small and focused
7
+ - keep the changes as minimal as possible
8
+ - if or else has one line of code, then { } are not needed and it should be wrote into same line
9
+ - DO NOT write uncessary comment do not make newlines within a function and try to make the code compact
10
+ - All crucial code should have proper explanation in English
11
+ - Keep the simplifications as small and focused within the function or scope.
12
+ - Do not overhaul the whole file or codebase which is irrelevant to the current task.
13
+
14
+ ## Best Practices for AI-Assisted Development
15
+
16
+ 1. **在开始编码前先充分讨论和规划架构,确保理解用户的真实需求和使用场景,避免过度设计。**
17
+
18
+ 2. **不要急于提交代码,应该等待用户明确指示后再进行 commit 和 push 操作。**
19
+
20
+ 3. **优先选择简洁的实现方式(如函数导出而非类),并删除冗余的中间层方法以保持代码清晰。**
21
+
22
+ ---
23
+
24
24
  *This file contains guidelines learned from AI-human collaboration to improve development efficiency and code quality.*
package/LICENSE CHANGED
@@ -1,21 +1,21 @@
1
- MIT License
2
-
3
- Copyright (c) 2019 Francisco Hodge
4
-
5
- Permission is hereby granted, free of charge, to any person obtaining a copy
6
- of this software and associated documentation files (the "Software"), to deal
7
- in the Software without restriction, including without limitation the rights
8
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- copies of the Software, and to permit persons to whom the Software is
10
- furnished to do so, subject to the following conditions:
11
-
12
- The above copyright notice and this permission notice shall be included in all
13
- copies or substantial portions of the Software.
14
-
15
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
- SOFTWARE.
1
+ MIT License
2
+
3
+ Copyright (c) 2019 Francisco Hodge
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,85 +1,85 @@
1
- # 第一阶段
2
- - 1. 创建,更新,删除都是通过 -> Http API
3
- - 2. 读取是通过本地数据库 -> 本地, (例外:订单从云端读取)
4
-
5
- # 第二阶段 (单机版)
6
- 1. 创建,更新,删除,读取都通过本地数据库,然后进行数据和云端同步(Web Worker)
7
-
8
-
9
-
10
-
11
-
12
-
13
-
14
-
15
-
16
-
17
-
18
- <div align="center">
19
- <img align="center" width="230" src="https://i.imgur.com/iHgtvmg.png" />
20
- <h2>Typescript Library Boilerplate Basic</h2>
21
- <blockquote>Minimal Library Starter Kit for your Typescript projects</blockquote>
22
-
23
- <a href="https://www.npmjs.com/package/@hodgef/ts-library-boilerplate-basic"><img src="https://badgen.net/npm/v/@hodgef/ts-library-boilerplate-basic?color=blue" alt="npm version"></a> <a href="https://github.com/hodgef/ts-library-boilerplate"><img src="https://img.shields.io/github/last-commit/hodgef/ts-library-boilerplate" alt="latest commit"></a> <a href="https://github.com/hodgef/ts-library-boilerplate-basic/actions"><img alt="Build Status" src="https://github.com/hodgef/ts-library-boilerplate-basic/workflows/Build/badge.svg?color=green" /></a> <a href="https://github.com/hodgef/ts-library-boilerplate-basic/actions"> <img alt="Publish Status" src="https://github.com/hodgef/ts-library-boilerplate-basic/workflows/Publish/badge.svg?color=green" /></a>
24
-
25
- <strong>For a plain Javascript alternative, check out [js-library-boilerplate-basic](https://github.com/hodgef/js-library-boilerplate-basic).</strong>
26
-
27
- </div>
28
-
29
- ## ⭐️ Features
30
-
31
- - Webpack 5
32
- - Babel 7
33
- - Hot reloading (`npm start`)
34
- - Automatic Types file generation (index.d.ts)
35
- - UMD exports, so your library works everywhere.
36
- - Jest unit testing
37
- - Customizable file headers for your build [(Example 1)](https://github.com/hodgef/ts-library-boilerplate-basic/blob/master/build/index.js) [(Example2)](https://github.com/hodgef/ts-library-boilerplate-basic/blob/master/build/css/index.css)
38
- - Daily [dependabot](https://dependabot.com) dependency updates
39
-
40
- ## 📦 Getting Started
41
-
42
- ```
43
- git clone https://github.com/hodgef/ts-library-boilerplate-basic.git myLibrary
44
- npm install
45
- ```
46
-
47
- ## 💎 Customization
48
-
49
- > Before shipping, make sure to:
50
-
51
- 1. Edit `LICENSE` file
52
- 2. Edit `package.json` information (These will be used to generate the headers for your built files)
53
- 3. Edit `library: "MyLibrary"` with your library's export name in `./webpack.config.js`
54
-
55
- ## 🚀 Deployment
56
-
57
- 1. `npm publish`
58
- 2. Your users can include your library as usual
59
-
60
- ### npm
61
-
62
- ```
63
- import MyLibrary from 'my-library';
64
- const libraryInstance = new MyLibrary();
65
- ...
66
- ```
67
-
68
- ### self-host/cdn
69
-
70
- ```
71
- <script src="build/index.js"></script>
72
-
73
- const MyLibrary = window.MyLibrary.default;
74
- const libraryInstance = new MyLibrary();
75
- ...
76
- ```
77
-
78
- ## ✅ Libraries built with this boilerplate
79
-
80
- > Made a library using this starter kit? Share it here by [submitting a pull request](https://github.com/hodgef/ts-library-boilerplate-basic/pulls)!
81
-
82
- - [simple-keyboard](https://github.com/hodgef/simple-keyboard) - Javascript Virtual Keyboard
83
- - [react-simple-keyboard](https://github.com/hodgef/react-simple-keyboard) - React Virtual Keyboard
84
- - [simple-keyboard-layouts](https://github.com/hodgef/simple-keyboard-layouts) - Keyboard layouts for simple-keyboard
85
- - [atlas-monaco](https://github.com/datdao/atlas-monaco) - AtlasHCL for monaco editor
1
+ # 第一阶段
2
+ - 1. 创建,更新,删除都是通过 -> Http API
3
+ - 2. 读取是通过本地数据库 -> 本地, (例外:订单从云端读取)
4
+
5
+ # 第二阶段 (单机版)
6
+ 1. 创建,更新,删除,读取都通过本地数据库,然后进行数据和云端同步(Web Worker)
7
+
8
+
9
+
10
+
11
+
12
+
13
+
14
+
15
+
16
+
17
+
18
+ <div align="center">
19
+ <img align="center" width="230" src="https://i.imgur.com/iHgtvmg.png" />
20
+ <h2>Typescript Library Boilerplate Basic</h2>
21
+ <blockquote>Minimal Library Starter Kit for your Typescript projects</blockquote>
22
+
23
+ <a href="https://www.npmjs.com/package/@hodgef/ts-library-boilerplate-basic"><img src="https://badgen.net/npm/v/@hodgef/ts-library-boilerplate-basic?color=blue" alt="npm version"></a> <a href="https://github.com/hodgef/ts-library-boilerplate"><img src="https://img.shields.io/github/last-commit/hodgef/ts-library-boilerplate" alt="latest commit"></a> <a href="https://github.com/hodgef/ts-library-boilerplate-basic/actions"><img alt="Build Status" src="https://github.com/hodgef/ts-library-boilerplate-basic/workflows/Build/badge.svg?color=green" /></a> <a href="https://github.com/hodgef/ts-library-boilerplate-basic/actions"> <img alt="Publish Status" src="https://github.com/hodgef/ts-library-boilerplate-basic/workflows/Publish/badge.svg?color=green" /></a>
24
+
25
+ <strong>For a plain Javascript alternative, check out [js-library-boilerplate-basic](https://github.com/hodgef/js-library-boilerplate-basic).</strong>
26
+
27
+ </div>
28
+
29
+ ## ⭐️ Features
30
+
31
+ - Webpack 5
32
+ - Babel 7
33
+ - Hot reloading (`npm start`)
34
+ - Automatic Types file generation (index.d.ts)
35
+ - UMD exports, so your library works everywhere.
36
+ - Jest unit testing
37
+ - Customizable file headers for your build [(Example 1)](https://github.com/hodgef/ts-library-boilerplate-basic/blob/master/build/index.js) [(Example2)](https://github.com/hodgef/ts-library-boilerplate-basic/blob/master/build/css/index.css)
38
+ - Daily [dependabot](https://dependabot.com) dependency updates
39
+
40
+ ## 📦 Getting Started
41
+
42
+ ```
43
+ git clone https://github.com/hodgef/ts-library-boilerplate-basic.git myLibrary
44
+ npm install
45
+ ```
46
+
47
+ ## 💎 Customization
48
+
49
+ > Before shipping, make sure to:
50
+
51
+ 1. Edit `LICENSE` file
52
+ 2. Edit `package.json` information (These will be used to generate the headers for your built files)
53
+ 3. Edit `library: "MyLibrary"` with your library's export name in `./webpack.config.js`
54
+
55
+ ## 🚀 Deployment
56
+
57
+ 1. `npm publish`
58
+ 2. Your users can include your library as usual
59
+
60
+ ### npm
61
+
62
+ ```
63
+ import MyLibrary from 'my-library';
64
+ const libraryInstance = new MyLibrary();
65
+ ...
66
+ ```
67
+
68
+ ### self-host/cdn
69
+
70
+ ```
71
+ <script src="build/index.js"></script>
72
+
73
+ const MyLibrary = window.MyLibrary.default;
74
+ const libraryInstance = new MyLibrary();
75
+ ...
76
+ ```
77
+
78
+ ## ✅ Libraries built with this boilerplate
79
+
80
+ > Made a library using this starter kit? Share it here by [submitting a pull request](https://github.com/hodgef/ts-library-boilerplate-basic/pulls)!
81
+
82
+ - [simple-keyboard](https://github.com/hodgef/simple-keyboard) - Javascript Virtual Keyboard
83
+ - [react-simple-keyboard](https://github.com/hodgef/react-simple-keyboard) - React Virtual Keyboard
84
+ - [simple-keyboard-layouts](https://github.com/hodgef/simple-keyboard-layouts) - Keyboard layouts for simple-keyboard
85
+ - [atlas-monaco](https://github.com/datdao/atlas-monaco) - AtlasHCL for monaco editor
package/build/index.d.ts CHANGED
@@ -3589,10 +3589,11 @@ declare class OrderConfig implements IOrderConfig {
3589
3589
  constructor();
3590
3590
  }
3591
3591
  interface IOrderDisplaySystemConfig {
3592
- /** Language for order display */
3592
+ enabled: boolean;
3593
3593
  language: string;
3594
3594
  }
3595
3595
  declare class OrderDisplaySystemConfig implements IOrderDisplaySystemConfig {
3596
+ enabled: boolean;
3596
3597
  language: string;
3597
3598
  constructor();
3598
3599
  }
@@ -3656,9 +3657,11 @@ declare class ChargeConfig implements IChargeConfig {
3656
3657
  }
3657
3658
  interface ICurrencyConfig {
3658
3659
  currency_symbol: string;
3660
+ is_symbol_after_amount: boolean;
3659
3661
  }
3660
3662
  declare class CurrencyConfig implements ICurrencyConfig {
3661
3663
  currency_symbol: string;
3664
+ is_symbol_after_amount: boolean;
3662
3665
  constructor();
3663
3666
  }
3664
3667
  declare class RoundingConfig implements IRoundingConfig {
@@ -5005,6 +5008,56 @@ declare class PrinterService extends AppRemoteService<IPrinter> implements IPrin
5005
5008
  openCashDrawer(): Promise<void>;
5006
5009
  }
5007
5010
  //#endregion
5011
+ //#region src/types/ods.type.d.ts
5012
+ interface IOrderDisplay extends IAppCoreModel {
5013
+ order_number: string;
5014
+ status: OrderDisplayStatus;
5015
+ }
5016
+ declare class OrderDisplay extends AppCoreModel implements IOrderDisplay {
5017
+ uid: string;
5018
+ order_number: string;
5019
+ status: OrderDisplayStatus;
5020
+ constructor();
5021
+ }
5022
+ declare enum OrderDisplayStatus {
5023
+ Preparing = "preparing",
5024
+ ReadyForPickup = "ready_for_pickup",
5025
+ }
5026
+ //#endregion
5027
+ //#region src/services/ods.service.d.ts
5028
+ /**
5029
+ * Represents the interface for the Order Display Service.
5030
+ * Extends the IAppRemoteService interface with the IOrderDisplay type.
5031
+ */
5032
+ interface IOrderDisplayService extends IAppRemoteService<IOrderDisplay> {
5033
+ /**
5034
+ * Changes the status of the order to ready for pickup
5035
+ * @param uid The uid of the order
5036
+ * @returns The updated order
5037
+ */
5038
+ toPickUp(uid: string): Promise<IOrderDisplay>;
5039
+ /**
5040
+ * Changes the status of the order to preparing
5041
+ * @param uid The uid of the order
5042
+ */
5043
+ toPreparing(uid: string): Promise<IOrderDisplay>;
5044
+ /**
5045
+ * Undoes the last order that was marked as ready for pickup
5046
+ */
5047
+ undo(): Promise<IOrderDisplay>;
5048
+ }
5049
+ declare class OrderDisplayService extends AppRemoteService<IOrderDisplay> implements IOrderDisplayService {
5050
+ readonly http: AxiosInstance$1;
5051
+ readonly db: Dexie;
5052
+ readonly options: IServiceOptions;
5053
+ readonly moduleName: string;
5054
+ readonly methodName: string;
5055
+ constructor(http: AxiosInstance$1, db: Dexie, options: IServiceOptions, moduleName?: string, methodName?: string);
5056
+ toPickUp(uid: string): Promise<IOrderDisplay>;
5057
+ toPreparing(uid: string): Promise<IOrderDisplay>;
5058
+ undo(): Promise<IOrderDisplay>;
5059
+ }
5060
+ //#endregion
5008
5061
  //#region src/services/invoice.service.d.ts
5009
5062
  interface IInvoiceBaseService extends IAppRemoteService<IInvoice> {
5010
5063
  calculate(invoice: IInvoice, appConfig: IAppConfig, disableRounding?: boolean): IInvoice;
@@ -5032,7 +5085,7 @@ type LineOptions = {
5032
5085
  remark?: string;
5033
5086
  };
5034
5087
  declare class InvoiceBaseService extends AppRemoteService<IInvoice> implements IInvoiceBaseService {
5035
- readonly http: AxiosInstance$1;
5088
+ readonly http: AxiosInstance;
5036
5089
  readonly db: Dexie;
5037
5090
  readonly options: IServiceOptions;
5038
5091
  readonly moduleName: string;
@@ -5044,7 +5097,8 @@ declare class InvoiceBaseService extends AppRemoteService<IInvoice> implements I
5044
5097
  protected printerService: PrinterService;
5045
5098
  protected printJobService: PrintJobService;
5046
5099
  protected itemService: IItemService;
5047
- constructor(http: AxiosInstance$1, db: Dexie, options: IServiceOptions, moduleName?: string, methodName?: string);
5100
+ protected orderDisplayService: OrderDisplayService;
5101
+ constructor(http: AxiosInstance, db: Dexie, options: IServiceOptions, moduleName?: string, methodName?: string);
5048
5102
  calculate(invoice: IInvoice, appConfig: IAppConfig, disableRounding?: boolean): IInvoice;
5049
5103
  calculateLines(invoice: IInvoice): void;
5050
5104
  calculateLine(line: IInvoiceLine): void;
@@ -5650,56 +5704,6 @@ declare const filterByParams: (params: {
5650
5704
  declare function humanizedData(date: Date, format?: string): string;
5651
5705
  declare function normalizedDate(date: Date): string;
5652
5706
  //#endregion
5653
- //#region src/types/ods.type.d.ts
5654
- interface IOrderDisplay extends IAppCoreModel {
5655
- order_number: string;
5656
- status: OrderDisplayStatus;
5657
- }
5658
- declare class OrderDisplay extends AppCoreModel implements IOrderDisplay {
5659
- uid: string;
5660
- order_number: string;
5661
- status: OrderDisplayStatus;
5662
- constructor();
5663
- }
5664
- declare enum OrderDisplayStatus {
5665
- Preparing = "preparing",
5666
- ReadyForPickup = "ready_for_pickup",
5667
- }
5668
- //#endregion
5669
- //#region src/services/ods.service.d.ts
5670
- /**
5671
- * Represents the interface for the Order Display Service.
5672
- * Extends the IAppRemoteService interface with the IOrderDisplay type.
5673
- */
5674
- interface IOrderDisplayService extends IAppRemoteService<IOrderDisplay> {
5675
- /**
5676
- * Changes the status of the order to ready for pickup
5677
- * @param uid The uid of the order
5678
- * @returns The updated order
5679
- */
5680
- toPickUp(uid: string): Promise<IOrderDisplay>;
5681
- /**
5682
- * Changes the status of the order to preparing
5683
- * @param uid The uid of the order
5684
- */
5685
- toPreparing(uid: string): Promise<IOrderDisplay>;
5686
- /**
5687
- * Undoes the last order that was marked as ready for pickup
5688
- */
5689
- undo(): Promise<IOrderDisplay>;
5690
- }
5691
- declare class OrderDisplayService extends AppRemoteService<IOrderDisplay> implements IOrderDisplayService {
5692
- readonly http: AxiosInstance;
5693
- readonly db: Dexie;
5694
- readonly options: IServiceOptions;
5695
- readonly moduleName: string;
5696
- readonly methodName: string;
5697
- constructor(http: AxiosInstance, db: Dexie, options: IServiceOptions, moduleName?: string, methodName?: string);
5698
- toPickUp(uid: string): Promise<IOrderDisplay>;
5699
- toPreparing(uid: string): Promise<IOrderDisplay>;
5700
- undo(): Promise<IOrderDisplay>;
5701
- }
5702
- //#endregion
5703
5707
  //#region src/types/csv.type.d.ts
5704
5708
  /**
5705
5709
  * Interface for CSV export rows
package/build/index.js CHANGED
@@ -2063,6 +2063,7 @@ var OrderConfig = class {
2063
2063
  };
2064
2064
  var OrderDisplaySystemConfig = class {
2065
2065
  constructor() {
2066
+ _defineProperty(this, "enabled", false);
2066
2067
  _defineProperty(this, "language", "en");
2067
2068
  }
2068
2069
  };
@@ -2095,6 +2096,7 @@ var ChargeConfig = class {
2095
2096
  var CurrencyConfig = class {
2096
2097
  constructor() {
2097
2098
  _defineProperty(this, "currency_symbol", "$");
2099
+ _defineProperty(this, "is_symbol_after_amount", false);
2098
2100
  }
2099
2101
  };
2100
2102
  var RoundingConfig = class {
@@ -3191,6 +3193,69 @@ function helpers(options) {
3191
3193
  */
3192
3194
  var helpers_register_default = helpers;
3193
3195
 
3196
+ //#endregion
3197
+ //#region src/types/ods.type.ts
3198
+ var OrderDisplay = class extends AppCoreModel {
3199
+ constructor() {
3200
+ super();
3201
+ _defineProperty(this, "uid", ModelPrefix.OrderDisplaySystem + nanoid());
3202
+ _defineProperty(this, "order_number", "");
3203
+ _defineProperty(this, "status", OrderDisplayStatus.Preparing);
3204
+ }
3205
+ };
3206
+ let OrderDisplayStatus = /* @__PURE__ */ function(OrderDisplayStatus$1) {
3207
+ OrderDisplayStatus$1["Preparing"] = "preparing";
3208
+ OrderDisplayStatus$1["ReadyForPickup"] = "ready_for_pickup";
3209
+ return OrderDisplayStatus$1;
3210
+ }({});
3211
+
3212
+ //#endregion
3213
+ //#region src/services/ods.service.ts
3214
+ var OrderDisplayService = class extends AppRemoteService {
3215
+ constructor(http, db, options, moduleName = "order_displays", methodName = "order_display") {
3216
+ super();
3217
+ this.http = http;
3218
+ this.db = db;
3219
+ this.options = options;
3220
+ this.moduleName = moduleName;
3221
+ this.methodName = methodName;
3222
+ }
3223
+ async toPickUp(uid) {
3224
+ const orderDisplay = await this.getOne(uid);
3225
+ if (!orderDisplay) throw new SystemError("Display order not found");
3226
+ if (orderDisplay.status == "ready_for_pickup") throw new SystemError("Order is already ready for pickup");
3227
+ orderDisplay.status = OrderDisplayStatus.ReadyForPickup;
3228
+ orderDisplay.updated_at = /* @__PURE__ */ new Date();
3229
+ if (orderDisplay.id_in_server == 0) throw new SystemError("Order is not synced with server");
3230
+ await this.updateOne(orderDisplay.id_in_server, orderDisplay);
3231
+ return orderDisplay;
3232
+ }
3233
+ async toPreparing(uid) {
3234
+ const orderDisplay = await this.getOne(uid);
3235
+ if (!orderDisplay) throw new SystemError("Display order not found");
3236
+ if (orderDisplay.status == "preparing") throw new SystemError("Order is already preparing");
3237
+ orderDisplay.status = OrderDisplayStatus.Preparing;
3238
+ orderDisplay.updated_at = /* @__PURE__ */ new Date();
3239
+ if (orderDisplay.id_in_server == 0) throw new SystemError("Order is not synced with server");
3240
+ await this.updateOne(orderDisplay.id_in_server, orderDisplay);
3241
+ return orderDisplay;
3242
+ }
3243
+ async undo() {
3244
+ const orderDisplays = await this.db.table(this.moduleName).filter((x) => x.status == OrderDisplayStatus.ReadyForPickup).reverse().limit(100).toArray();
3245
+ if (orderDisplays.length === 0) throw new SystemError("No order to undo");
3246
+ orderDisplays.sort((a, b) => {
3247
+ const dateA = new Date(a.updated_at).getTime();
3248
+ return new Date(b.updated_at).getTime() - dateA;
3249
+ });
3250
+ const latestOrderDisplay = orderDisplays[0];
3251
+ latestOrderDisplay.status = OrderDisplayStatus.Preparing;
3252
+ latestOrderDisplay.updated_at = /* @__PURE__ */ new Date();
3253
+ if (latestOrderDisplay.id_in_server == 0) throw new SystemError("Order is not synced with server");
3254
+ await this.updateOne(latestOrderDisplay.id_in_server, latestOrderDisplay);
3255
+ return latestOrderDisplay;
3256
+ }
3257
+ };
3258
+
3194
3259
  //#endregion
3195
3260
  //#region src/services/invoice.service.ts
3196
3261
  helpers_register_default({ handlebars: Handlebars });
@@ -3214,6 +3279,7 @@ var InvoiceBaseService = class extends AppRemoteService {
3214
3279
  _defineProperty(this, "printerService", void 0);
3215
3280
  _defineProperty(this, "printJobService", void 0);
3216
3281
  _defineProperty(this, "itemService", void 0);
3282
+ _defineProperty(this, "orderDisplayService", void 0);
3217
3283
  this.tillService = new TillService(http, db, options, "tills", "till");
3218
3284
  this.sectionItemService = new SectionItemService(http, db, options, "section_items", "section_item");
3219
3285
  this.configService = new ConfigService(http, db, options, "configs", "config");
@@ -3221,6 +3287,7 @@ var InvoiceBaseService = class extends AppRemoteService {
3221
3287
  this.printerService = new PrinterService(http, db, options, "printers", "printer");
3222
3288
  this.printJobService = new PrintJobService(http, db, options, "print_jobs", "print_job");
3223
3289
  this.itemService = new ItemService(http, db, options, "items", "item");
3290
+ this.orderDisplayService = new OrderDisplayService(http, db, options);
3224
3291
  }
3225
3292
  calculate(invoice, appConfig, disableRounding = false) {
3226
3293
  if (invoice.lines == null || invoice.lines.length < 1) {
@@ -3968,7 +4035,8 @@ var InvoiceOperationService = class extends LineOperationService {
3968
4035
  sectionItem.status = SectionItemStatus.CLOSED;
3969
4036
  this.addEmployeeToInvoice(invoice, employee);
3970
4037
  invoice.paid_at = /* @__PURE__ */ new Date();
3971
- const datetimeFormat = (await this.configService.getDefaultOne()).config?.order?.datetime_format;
4038
+ const config = (await this.configService.getDefaultOne()).config;
4039
+ const datetimeFormat = config?.order?.datetime_format;
3972
4040
  invoice.humanized_paid_at = humanizedData(invoice.paid_at, datetimeFormat);
3973
4041
  invoice.payment_has_cash = invoice.payments?.some((payment) => payment.payment_method?.is_cash === true);
3974
4042
  const stockChanges = await this.getStockChangeList(invoice, false);
@@ -4010,7 +4078,13 @@ var InvoiceOperationService = class extends LineOperationService {
4010
4078
  this.sectionItemService.saveOne(res.data);
4011
4079
  options.section_item = res.data;
4012
4080
  throw new SystemError(`${res.error}, system has updated the data and please try again`);
4013
- } else if (stockChanges.length > 0) await this.itemService.changeItemsStock(stockChanges);
4081
+ }
4082
+ if (stockChanges.length > 0) await this.itemService.changeItemsStock(stockChanges);
4083
+ if (invoice.call_num && config?.ods?.enabled) {
4084
+ const orderDisplay = new OrderDisplay();
4085
+ orderDisplay.order_number = invoice.call_num;
4086
+ await this.orderDisplayService.addOne(orderDisplay);
4087
+ }
4014
4088
  return options;
4015
4089
  } catch (error) {
4016
4090
  invoice.kitchen_print_job_uids.length = previousKitchenUidsLength;
@@ -4022,7 +4096,8 @@ var InvoiceOperationService = class extends LineOperationService {
4022
4096
  invoice.status = InvoiceStatus.Paid;
4023
4097
  if (employee != null) this.addEmployeeToInvoice(invoice, employee);
4024
4098
  invoice.paid_at = /* @__PURE__ */ new Date();
4025
- const datetimeFormat = (await this.configService.getDefaultOne()).config?.order?.datetime_format;
4099
+ const config = (await this.configService.getDefaultOne()).config;
4100
+ const datetimeFormat = config?.order?.datetime_format;
4026
4101
  invoice.humanized_paid_at = humanizedData(invoice.paid_at, datetimeFormat);
4027
4102
  invoice.created_at = /* @__PURE__ */ new Date();
4028
4103
  invoice.created_at_timestamp = invoice.created_at.getTime();
@@ -4063,7 +4138,13 @@ var InvoiceOperationService = class extends LineOperationService {
4063
4138
  this.saveOne(res.data);
4064
4139
  options.invoice = res.data;
4065
4140
  throw new SystemError(res.error);
4066
- } else if (stockChanges.length > 0) await this.itemService.changeItemsStock(stockChanges);
4141
+ }
4142
+ if (stockChanges.length > 0) await this.itemService.changeItemsStock(stockChanges);
4143
+ if (invoice.call_num && config?.ods?.enabled) {
4144
+ const orderDisplay = new OrderDisplay();
4145
+ orderDisplay.order_number = invoice.call_num;
4146
+ await this.orderDisplayService.addOne(orderDisplay);
4147
+ }
4067
4148
  return options;
4068
4149
  }
4069
4150
  async voidInvoice(invoice, till, reason, employee) {
@@ -5707,69 +5788,6 @@ function createInstance(baseURL, uid, token) {
5707
5788
  return instance;
5708
5789
  }
5709
5790
 
5710
- //#endregion
5711
- //#region src/types/ods.type.ts
5712
- var OrderDisplay = class extends AppCoreModel {
5713
- constructor() {
5714
- super();
5715
- _defineProperty(this, "uid", ModelPrefix.OrderDisplaySystem + nanoid());
5716
- _defineProperty(this, "order_number", "");
5717
- _defineProperty(this, "status", OrderDisplayStatus.Preparing);
5718
- }
5719
- };
5720
- let OrderDisplayStatus = /* @__PURE__ */ function(OrderDisplayStatus$1) {
5721
- OrderDisplayStatus$1["Preparing"] = "preparing";
5722
- OrderDisplayStatus$1["ReadyForPickup"] = "ready_for_pickup";
5723
- return OrderDisplayStatus$1;
5724
- }({});
5725
-
5726
- //#endregion
5727
- //#region src/services/ods.service.ts
5728
- var OrderDisplayService = class extends AppRemoteService {
5729
- constructor(http, db, options, moduleName = "order_displays", methodName = "order_display") {
5730
- super();
5731
- this.http = http;
5732
- this.db = db;
5733
- this.options = options;
5734
- this.moduleName = moduleName;
5735
- this.methodName = methodName;
5736
- }
5737
- async toPickUp(uid) {
5738
- const orderDisplay = await this.getOne(uid);
5739
- if (!orderDisplay) throw new SystemError("Display order not found");
5740
- if (orderDisplay.status == "ready_for_pickup") throw new SystemError("Order is already ready for pickup");
5741
- orderDisplay.status = OrderDisplayStatus.ReadyForPickup;
5742
- orderDisplay.updated_at = /* @__PURE__ */ new Date();
5743
- if (orderDisplay.id_in_server == 0) throw new SystemError("Order is not synced with server");
5744
- await this.updateOne(orderDisplay.id_in_server, orderDisplay);
5745
- return orderDisplay;
5746
- }
5747
- async toPreparing(uid) {
5748
- const orderDisplay = await this.getOne(uid);
5749
- if (!orderDisplay) throw new SystemError("Display order not found");
5750
- if (orderDisplay.status == "preparing") throw new SystemError("Order is already preparing");
5751
- orderDisplay.status = OrderDisplayStatus.Preparing;
5752
- orderDisplay.updated_at = /* @__PURE__ */ new Date();
5753
- if (orderDisplay.id_in_server == 0) throw new SystemError("Order is not synced with server");
5754
- await this.updateOne(orderDisplay.id_in_server, orderDisplay);
5755
- return orderDisplay;
5756
- }
5757
- async undo() {
5758
- const orderDisplays = await this.db.table(this.moduleName).filter((x) => x.status == OrderDisplayStatus.ReadyForPickup).reverse().limit(100).toArray();
5759
- if (orderDisplays.length === 0) throw new SystemError("No order to undo");
5760
- orderDisplays.sort((a, b) => {
5761
- const dateA = new Date(a.updated_at).getTime();
5762
- return new Date(b.updated_at).getTime() - dateA;
5763
- });
5764
- const latestOrderDisplay = orderDisplays[0];
5765
- latestOrderDisplay.status = OrderDisplayStatus.Preparing;
5766
- latestOrderDisplay.updated_at = /* @__PURE__ */ new Date();
5767
- if (latestOrderDisplay.id_in_server == 0) throw new SystemError("Order is not synced with server");
5768
- await this.updateOne(latestOrderDisplay.id_in_server, latestOrderDisplay);
5769
- return latestOrderDisplay;
5770
- }
5771
- };
5772
-
5773
5791
  //#endregion
5774
5792
  //#region src/service.factory.ts
5775
5793
  const serviceProvider = new Map([