@posx/core 5.5.331 → 5.5.332
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/build/index.d.ts +6 -2
- package/build/index.js +21 -26
- package/package.json +2 -2
- package/package.publish.json +2 -2
package/build/index.d.ts
CHANGED
|
@@ -316,7 +316,7 @@ interface IAppCoreModel {
|
|
|
316
316
|
* the date when the object is deleted
|
|
317
317
|
* @ignore
|
|
318
318
|
*/
|
|
319
|
-
deleted_at: Date;
|
|
319
|
+
deleted_at: Date | null;
|
|
320
320
|
/**
|
|
321
321
|
* timestamp in milliseconds
|
|
322
322
|
* @ignore
|
|
@@ -3553,6 +3553,8 @@ interface IOrderConfig {
|
|
|
3553
3553
|
hide_categories_when_ordering: boolean;
|
|
3554
3554
|
/** Flag to end shift with open tables */
|
|
3555
3555
|
end_shift_with_open_tables: boolean;
|
|
3556
|
+
/** Date time format for humanized dates */
|
|
3557
|
+
datetime_format: string;
|
|
3556
3558
|
}
|
|
3557
3559
|
declare class OrderConfig implements IOrderConfig {
|
|
3558
3560
|
separation_line: boolean;
|
|
@@ -3564,6 +3566,7 @@ declare class OrderConfig implements IOrderConfig {
|
|
|
3564
3566
|
hide_combo_item_on_interactive_view: boolean;
|
|
3565
3567
|
hide_categories_when_ordering: boolean;
|
|
3566
3568
|
end_shift_with_open_tables: boolean;
|
|
3569
|
+
datetime_format: string;
|
|
3567
3570
|
constructor();
|
|
3568
3571
|
}
|
|
3569
3572
|
interface IPaymentConfig {
|
|
@@ -4180,6 +4183,7 @@ declare class TemplateData implements ITemplateData {
|
|
|
4180
4183
|
normalized_printed_at: string;
|
|
4181
4184
|
meta: Record<string, any>;
|
|
4182
4185
|
is_cancel: boolean;
|
|
4186
|
+
constructor();
|
|
4183
4187
|
}
|
|
4184
4188
|
type IRenderPrintTemplateOptions = {
|
|
4185
4189
|
printer_name: string;
|
|
@@ -5616,7 +5620,7 @@ declare const filterByParams: (params: {
|
|
|
5616
5620
|
}) => (values: any) => boolean;
|
|
5617
5621
|
//#endregion
|
|
5618
5622
|
//#region src/utils/misc.utils.d.ts
|
|
5619
|
-
declare function humanizedData(date: Date): string;
|
|
5623
|
+
declare function humanizedData(date: Date, format?: string): string;
|
|
5620
5624
|
declare function normalizedDate(date: Date): string;
|
|
5621
5625
|
//#endregion
|
|
5622
5626
|
//#region src/types/ods.type.d.ts
|
package/build/index.js
CHANGED
|
@@ -1266,21 +1266,8 @@ var PrintCommand = class {
|
|
|
1266
1266
|
|
|
1267
1267
|
//#endregion
|
|
1268
1268
|
//#region src/utils/misc.utils.ts
|
|
1269
|
-
function humanizedData(date) {
|
|
1270
|
-
return
|
|
1271
|
-
"Jan",
|
|
1272
|
-
"Feb",
|
|
1273
|
-
"Mar",
|
|
1274
|
-
"Apr",
|
|
1275
|
-
"May",
|
|
1276
|
-
"Jun",
|
|
1277
|
-
"Jul",
|
|
1278
|
-
"Aug",
|
|
1279
|
-
"Sep",
|
|
1280
|
-
"Oct",
|
|
1281
|
-
"Nov",
|
|
1282
|
-
"Dec"
|
|
1283
|
-
][date.getMonth()]}-${date.getDate().toString().padStart(2, "0")} ${date.getHours().toString().padStart(2, "0")}:${date.getMinutes().toString().padStart(2, "0")}:${date.getSeconds().toString().padStart(2, "0")}`;
|
|
1269
|
+
function humanizedData(date, format) {
|
|
1270
|
+
return dayjs(date).format(format || "YYYY-MMM-DD HH:mm:ss");
|
|
1284
1271
|
}
|
|
1285
1272
|
function normalizedDate(date) {
|
|
1286
1273
|
return `${date.getFullYear()}-${(date.getMonth() + 1).toString().padStart(2, "0")}-${date.getDate().toString().padStart(2, "0")} ${date.getHours().toString().padStart(2, "0")}:${date.getMinutes().toString().padStart(2, "0")}:${date.getSeconds().toString().padStart(2, "0")}`;
|
|
@@ -1458,9 +1445,10 @@ var TemplateData = class {
|
|
|
1458
1445
|
_defineProperty(this, "section_item", {});
|
|
1459
1446
|
_defineProperty(this, "printer_name", "");
|
|
1460
1447
|
_defineProperty(this, "printed_at", /* @__PURE__ */ new Date());
|
|
1461
|
-
_defineProperty(this, "normalized_printed_at",
|
|
1448
|
+
_defineProperty(this, "normalized_printed_at", "");
|
|
1462
1449
|
_defineProperty(this, "meta", {});
|
|
1463
1450
|
_defineProperty(this, "is_cancel", false);
|
|
1451
|
+
this.normalized_printed_at = humanizedData(this.printed_at);
|
|
1464
1452
|
}
|
|
1465
1453
|
};
|
|
1466
1454
|
var RenderPrintTemplateOptions = class {
|
|
@@ -2062,6 +2050,7 @@ var OrderConfig = class {
|
|
|
2062
2050
|
_defineProperty(this, "hide_combo_item_on_interactive_view", false);
|
|
2063
2051
|
_defineProperty(this, "hide_categories_when_ordering", false);
|
|
2064
2052
|
_defineProperty(this, "end_shift_with_open_tables", false);
|
|
2053
|
+
_defineProperty(this, "datetime_format", "YYYY-MMM-DD HH:mm:ss");
|
|
2065
2054
|
}
|
|
2066
2055
|
};
|
|
2067
2056
|
var PaymentConfig = class {
|
|
@@ -3463,7 +3452,8 @@ var InvoiceOperationService = class extends LineOperationService {
|
|
|
3463
3452
|
this.addEmployeeToInvoice(invoice, employee);
|
|
3464
3453
|
invoice.created_at = /* @__PURE__ */ new Date();
|
|
3465
3454
|
invoice.created_at_timestamp = invoice.created_at.getTime();
|
|
3466
|
-
|
|
3455
|
+
const datetimeFormat = (await this.configService.getDefaultOne()).config?.order?.datetime_format;
|
|
3456
|
+
invoice.humanized_created_at = humanizedData(invoice.created_at, datetimeFormat);
|
|
3467
3457
|
sectionItem.invoice_created_at = /* @__PURE__ */ new Date();
|
|
3468
3458
|
const kitchenPrintJobs = await this.createKitchenPrintJobs(invoice);
|
|
3469
3459
|
const labelPrintJobs = await this.createLabelPrintJobs(invoice);
|
|
@@ -3662,7 +3652,8 @@ var InvoiceOperationService = class extends LineOperationService {
|
|
|
3662
3652
|
sectionItem.status = SectionItemStatus.CLOSED;
|
|
3663
3653
|
this.addEmployeeToInvoice(invoice, employee);
|
|
3664
3654
|
invoice.paid_at = /* @__PURE__ */ new Date();
|
|
3665
|
-
|
|
3655
|
+
const datetimeFormat = (await this.configService.getDefaultOne()).config?.order?.datetime_format;
|
|
3656
|
+
invoice.humanized_paid_at = humanizedData(invoice.paid_at, datetimeFormat);
|
|
3666
3657
|
invoice.payment_has_cash = invoice.payments?.some((payment) => payment.payment_method?.is_cash === true);
|
|
3667
3658
|
const stockChanges = await this.getStockChangeList(invoice, false);
|
|
3668
3659
|
const labelPrintJobs = await this.createLabelPrintJobs(invoice);
|
|
@@ -3715,10 +3706,11 @@ var InvoiceOperationService = class extends LineOperationService {
|
|
|
3715
3706
|
invoice.status = InvoiceStatus.Paid;
|
|
3716
3707
|
if (employee != null) this.addEmployeeToInvoice(invoice, employee);
|
|
3717
3708
|
invoice.paid_at = /* @__PURE__ */ new Date();
|
|
3718
|
-
|
|
3709
|
+
const datetimeFormat = (await this.configService.getDefaultOne()).config?.order?.datetime_format;
|
|
3710
|
+
invoice.humanized_paid_at = humanizedData(invoice.paid_at, datetimeFormat);
|
|
3719
3711
|
invoice.created_at = /* @__PURE__ */ new Date();
|
|
3720
3712
|
invoice.created_at_timestamp = invoice.created_at.getTime();
|
|
3721
|
-
invoice.humanized_created_at = humanizedData(invoice.created_at);
|
|
3713
|
+
invoice.humanized_created_at = humanizedData(invoice.created_at, datetimeFormat);
|
|
3722
3714
|
if (!invoice.ref_id) invoice.ref_id = await this.getRefId();
|
|
3723
3715
|
if (!invoice.call_num) invoice.call_num = invoice.ref_id.slice(-3);
|
|
3724
3716
|
invoice.payment_has_cash = invoice.payments?.some((payment) => payment.payment_method?.is_cash === true);
|
|
@@ -3763,7 +3755,8 @@ var InvoiceOperationService = class extends LineOperationService {
|
|
|
3763
3755
|
const originalStatus = invoice.status;
|
|
3764
3756
|
invoice.status = InvoiceStatus.Void;
|
|
3765
3757
|
invoice.voided_at = /* @__PURE__ */ new Date();
|
|
3766
|
-
|
|
3758
|
+
const datetimeFormat = (await this.configService.getDefaultOne()).config?.order?.datetime_format;
|
|
3759
|
+
invoice.humanized_voided_at = humanizedData(invoice.voided_at, datetimeFormat);
|
|
3767
3760
|
if (till) till.deleted_at = /* @__PURE__ */ new Date();
|
|
3768
3761
|
this.addEmployeeToInvoice(invoice, employee);
|
|
3769
3762
|
const config = (await this.configService.getDefaultOne()).config;
|
|
@@ -4909,12 +4902,12 @@ var AppReportService = class extends AppRemoteService {
|
|
|
4909
4902
|
if (!printer) throw new SystemError("No default receipt printer found");
|
|
4910
4903
|
const template = await this.printTemplateService.getOneByParams({ report_code_name: request.report_code_name });
|
|
4911
4904
|
if (!template) throw new SystemError("No print template found");
|
|
4912
|
-
const reportData = await this.getReportData(request);
|
|
4913
4905
|
const appConfig = await this.configService.getDefaultOne();
|
|
4906
|
+
const reportData = await this.getReportData(request, appConfig.config?.order?.datetime_format);
|
|
4914
4907
|
const printJob = new PrintJob(printer, await this.printTemplateService.renderReportPrintTemplate(reportData, appConfig.config, template), false, request.copies);
|
|
4915
4908
|
await this.printJobService.addOne(printJob);
|
|
4916
4909
|
}
|
|
4917
|
-
async getReportData(request) {
|
|
4910
|
+
async getReportData(request, datetimeFormat) {
|
|
4918
4911
|
const reportData = new ReportData();
|
|
4919
4912
|
if (request.shift_uid) {
|
|
4920
4913
|
await this.db.table("shifts").where("uid").equals(request.shift_uid).and((shift) => shift.deleted_at == null || shift.deleted_at == void 0).first();
|
|
@@ -4932,9 +4925,9 @@ var AppReportService = class extends AppRemoteService {
|
|
|
4932
4925
|
}
|
|
4933
4926
|
reportData.start_datetime = new Date(request.start_datetime).toISOString();
|
|
4934
4927
|
reportData.end_datetime = new Date(request.end_datetime).toISOString();
|
|
4935
|
-
reportData.humanized_start_datetime = humanizedData(new Date(request.start_datetime));
|
|
4936
|
-
reportData.humanized_end_datetime = humanizedData(new Date(request.end_datetime));
|
|
4937
|
-
reportData.humanized_printed_datetime = humanizedData(/* @__PURE__ */ new Date());
|
|
4928
|
+
reportData.humanized_start_datetime = humanizedData(new Date(request.start_datetime), datetimeFormat);
|
|
4929
|
+
reportData.humanized_end_datetime = humanizedData(new Date(request.end_datetime), datetimeFormat);
|
|
4930
|
+
reportData.humanized_printed_datetime = humanizedData(/* @__PURE__ */ new Date(), datetimeFormat);
|
|
4938
4931
|
const query = new QueryBuilder().addParam("paid_at", "GreaterThanOrEqualTo", new Date(request.start_datetime).toISOString()).addParam("paid_at", "LessThanOrEqualTo", new Date(request.end_datetime).toISOString()).addParam("deleted_at", "IsNull", true).includeTotal(true);
|
|
4939
4932
|
const invoices = (await this.invoiceService.autoQuery(query)).results || [];
|
|
4940
4933
|
return this.processReportInvoicesData(reportData, invoices);
|
|
@@ -5272,6 +5265,7 @@ var PrintTemplateService = class extends AppRemoteService {
|
|
|
5272
5265
|
const templateData = new TemplateData();
|
|
5273
5266
|
templateData.invoice = invoice;
|
|
5274
5267
|
templateData.config = config;
|
|
5268
|
+
templateData.normalized_printed_at = humanizedData(templateData.printed_at, config?.order?.datetime_format);
|
|
5275
5269
|
templateData.printer_name = options.printer_name;
|
|
5276
5270
|
if (options.is_cancel) templateData.is_cancel = options.is_cancel;
|
|
5277
5271
|
printCommand.items.push(...await this.renderPrintCommand(template.header, templateData));
|
|
@@ -5284,6 +5278,7 @@ var PrintTemplateService = class extends AppRemoteService {
|
|
|
5284
5278
|
const templateData = new TemplateData();
|
|
5285
5279
|
templateData.report_data = reportData;
|
|
5286
5280
|
templateData.config = config;
|
|
5281
|
+
templateData.normalized_printed_at = humanizedData(templateData.printed_at, config?.order?.datetime_format);
|
|
5287
5282
|
printCommand.codepage = template.codepage || Codepages.SimplifiedChinese;
|
|
5288
5283
|
printCommand.items.push(...await this.renderPrintCommand(template.header, templateData));
|
|
5289
5284
|
printCommand.items.push(...await this.renderPrintCommand(template.body, templateData));
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@posx/core",
|
|
3
|
-
"version": "5.5.
|
|
3
|
+
"version": "5.5.332",
|
|
4
4
|
"description": "POSX core libraries",
|
|
5
5
|
"main": "./build/index.js",
|
|
6
6
|
"author": "Steven Lee",
|
|
@@ -19,7 +19,7 @@
|
|
|
19
19
|
"buffer": "6.0.3",
|
|
20
20
|
"crypto-browserify": "3.12.0",
|
|
21
21
|
"crypto-js": "4.2.0",
|
|
22
|
-
"dayjs": "1.11.10",
|
|
22
|
+
"dayjs": "^1.11.10",
|
|
23
23
|
"dexie": "3.2.4",
|
|
24
24
|
"esc-pos-encoder-ionic": "1.1.3",
|
|
25
25
|
"handlebars": "4.7.8",
|
package/package.publish.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@posx/core",
|
|
3
|
-
"version": "5.5.
|
|
3
|
+
"version": "5.5.332",
|
|
4
4
|
"description": "POSX core libraries",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./build/index.js",
|
|
@@ -92,7 +92,7 @@
|
|
|
92
92
|
"buffer": "6.0.3",
|
|
93
93
|
"crypto-browserify": "3.12.0",
|
|
94
94
|
"crypto-js": "4.2.0",
|
|
95
|
-
"dayjs": "1.11.10",
|
|
95
|
+
"dayjs": "^1.11.10",
|
|
96
96
|
"dexie": "3.2.4",
|
|
97
97
|
"esc-pos-encoder-ionic": "1.1.3",
|
|
98
98
|
"handlebars": "4.7.8",
|