@munchi_oy/cart-engine 0.1.0 → 0.1.1
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.cjs +47 -1
- package/dist/index.d.cts +14 -2
- package/dist/index.d.ts +14 -2
- package/dist/index.js +50 -2
- package/package.json +3 -3
package/dist/index.cjs
CHANGED
|
@@ -378,10 +378,12 @@ var { isEqual } = import_lodash.default;
|
|
|
378
378
|
var Cart = class _Cart {
|
|
379
379
|
id;
|
|
380
380
|
businessId;
|
|
381
|
+
provider;
|
|
381
382
|
currency;
|
|
382
383
|
createdAt;
|
|
383
384
|
orderNumber;
|
|
384
385
|
orderType;
|
|
386
|
+
checkoutModel;
|
|
385
387
|
orderFormat;
|
|
386
388
|
spotNumber;
|
|
387
389
|
comments;
|
|
@@ -396,6 +398,7 @@ var Cart = class _Cart {
|
|
|
396
398
|
_discounts = [];
|
|
397
399
|
_customer = null;
|
|
398
400
|
_refunds = [];
|
|
401
|
+
_tableService;
|
|
399
402
|
_taxSummary;
|
|
400
403
|
_newlyCancelledItemIds;
|
|
401
404
|
_invoiceCompany;
|
|
@@ -406,8 +409,10 @@ var Cart = class _Cart {
|
|
|
406
409
|
this.id = id;
|
|
407
410
|
this.createdAt = createdAt;
|
|
408
411
|
this.businessId = options.businessId;
|
|
412
|
+
this.provider = options.provider;
|
|
409
413
|
this.orderType = options.orderType;
|
|
410
414
|
this.orderNumber = options.orderNumber;
|
|
415
|
+
this.checkoutModel = options.checkoutModel;
|
|
411
416
|
this._business = options.business;
|
|
412
417
|
this.currency = options.currency;
|
|
413
418
|
this.updatedAt = createdAt;
|
|
@@ -419,6 +424,7 @@ var Cart = class _Cart {
|
|
|
419
424
|
this.status = import_core4.OrderStatusEnum.Draft;
|
|
420
425
|
this.orderFormat = import_core4.OrderFormat.Instant;
|
|
421
426
|
this._locatorType = import_core4.LocatorType.Table;
|
|
427
|
+
this._tableService = options.tableService ?? null;
|
|
422
428
|
this._newlyCancelledItemIds = /* @__PURE__ */ new Set();
|
|
423
429
|
this._staffId = options.staffId ?? null;
|
|
424
430
|
this._shiftId = options.shiftId ?? null;
|
|
@@ -427,8 +433,11 @@ var Cart = class _Cart {
|
|
|
427
433
|
static create(options) {
|
|
428
434
|
return new _Cart((0, import_cuid2.createId)(), options.createdAt ?? (0, import_dayjs.default)().toDate(), {
|
|
429
435
|
businessId: options.businessId,
|
|
436
|
+
provider: options.provider ?? import_core4.ProviderEnum.MunchiPos,
|
|
430
437
|
orderType: options.orderType ?? import_core4.OrderTypePOS.DineIn,
|
|
431
438
|
orderNumber: options.orderNumber,
|
|
439
|
+
checkoutModel: options.checkoutModel ?? import_core4.CheckoutModelEnum.Full,
|
|
440
|
+
tableService: options.tableService ?? null,
|
|
432
441
|
currency: options.currency,
|
|
433
442
|
business: options.business,
|
|
434
443
|
staffId: options.staffId,
|
|
@@ -438,8 +447,11 @@ var Cart = class _Cart {
|
|
|
438
447
|
static fromData(orderDto) {
|
|
439
448
|
const cart = new _Cart(orderDto.id, (0, import_dayjs.default)(orderDto.createdAt).toDate(), {
|
|
440
449
|
businessId: orderDto.businessId,
|
|
450
|
+
provider: orderDto.provider,
|
|
441
451
|
orderType: orderDto.orderType,
|
|
442
452
|
orderNumber: orderDto.orderNumber,
|
|
453
|
+
checkoutModel: orderDto.checkoutModel,
|
|
454
|
+
tableService: orderDto.tableService ?? null,
|
|
443
455
|
currency: orderDto.currency,
|
|
444
456
|
business: orderDto.business,
|
|
445
457
|
staffId: orderDto.staffId ?? null,
|
|
@@ -461,6 +473,7 @@ var Cart = class _Cart {
|
|
|
461
473
|
cart._refunds = orderDto.refunds ? [...orderDto.refunds] : [];
|
|
462
474
|
cart._loyaltyTransactionIds = [...orderDto.loyaltyTransactionIds];
|
|
463
475
|
cart._loyaltyProgramId = orderDto.loyaltyProgramId ?? null;
|
|
476
|
+
cart._tableService = orderDto.tableService ? { ...orderDto.tableService } : null;
|
|
464
477
|
cart._newlyCancelledItemIds = /* @__PURE__ */ new Set();
|
|
465
478
|
cart._taxSummary = orderDto.taxSummary;
|
|
466
479
|
cart._invoiceCompany = orderDto.invoiceCompany ?? null;
|
|
@@ -496,6 +509,12 @@ var Cart = class _Cart {
|
|
|
496
509
|
get invoiceCompany() {
|
|
497
510
|
return this._invoiceCompany;
|
|
498
511
|
}
|
|
512
|
+
get guestCount() {
|
|
513
|
+
return this._tableService?.seats ?? null;
|
|
514
|
+
}
|
|
515
|
+
get tableService() {
|
|
516
|
+
return this._tableService;
|
|
517
|
+
}
|
|
499
518
|
get price() {
|
|
500
519
|
return calculateCartPriceSnapshot({
|
|
501
520
|
items: this._items,
|
|
@@ -749,6 +768,26 @@ var Cart = class _Cart {
|
|
|
749
768
|
this._shiftId = shiftId;
|
|
750
769
|
this.touch();
|
|
751
770
|
}
|
|
771
|
+
setCheckoutModel(checkoutModel) {
|
|
772
|
+
if (this.checkoutModel === checkoutModel) {
|
|
773
|
+
return;
|
|
774
|
+
}
|
|
775
|
+
this.checkoutModel = checkoutModel;
|
|
776
|
+
this.touch();
|
|
777
|
+
}
|
|
778
|
+
setCheckoutType(checkoutModel) {
|
|
779
|
+
this.setCheckoutModel(checkoutModel);
|
|
780
|
+
}
|
|
781
|
+
setGuestCount(guestCount) {
|
|
782
|
+
if (this._tableService?.seats ?? null === guestCount) {
|
|
783
|
+
return;
|
|
784
|
+
}
|
|
785
|
+
this._tableService = guestCount === null ? null : { seats: guestCount };
|
|
786
|
+
this.touch();
|
|
787
|
+
}
|
|
788
|
+
setSeatNumber(guestCount) {
|
|
789
|
+
this.setGuestCount(guestCount);
|
|
790
|
+
}
|
|
752
791
|
updateOrderStatus(newStatus) {
|
|
753
792
|
if (this.status === newStatus) {
|
|
754
793
|
return;
|
|
@@ -795,16 +834,19 @@ var Cart = class _Cart {
|
|
|
795
834
|
return {
|
|
796
835
|
id: this.id,
|
|
797
836
|
businessId: this.businessId,
|
|
837
|
+
provider: this.provider,
|
|
798
838
|
business: this._business,
|
|
799
839
|
currency: this.currency,
|
|
800
840
|
createdAt: this.createdAt.toISOString(),
|
|
801
841
|
updatedAt: this.updatedAt.toISOString(),
|
|
802
842
|
orderNumber: this.orderNumber,
|
|
843
|
+
checkoutModel: this.checkoutModel,
|
|
803
844
|
orderFormat: this.orderFormat,
|
|
804
845
|
orderType: this.orderType,
|
|
805
846
|
locatorType: this._locatorType,
|
|
806
847
|
spotNumber: this.spotNumber,
|
|
807
848
|
comments: this.comments,
|
|
849
|
+
tableService: this._tableService,
|
|
808
850
|
orderRefundStatus: this.orderRefundStatus,
|
|
809
851
|
items: this._items,
|
|
810
852
|
status: this.status,
|
|
@@ -828,8 +870,11 @@ var Cart = class _Cart {
|
|
|
828
870
|
clone() {
|
|
829
871
|
const newCart = new _Cart(this.id, this.createdAt, {
|
|
830
872
|
businessId: this.businessId,
|
|
873
|
+
provider: this.provider,
|
|
831
874
|
orderType: this.orderType,
|
|
832
875
|
orderNumber: this.orderNumber,
|
|
876
|
+
checkoutModel: this.checkoutModel,
|
|
877
|
+
tableService: this._tableService,
|
|
833
878
|
currency: this.currency,
|
|
834
879
|
business: this._business,
|
|
835
880
|
staffId: this._staffId,
|
|
@@ -848,6 +893,7 @@ var Cart = class _Cart {
|
|
|
848
893
|
newCart._refunds = [...this._refunds];
|
|
849
894
|
newCart._loyaltyProgramId = this._loyaltyProgramId;
|
|
850
895
|
newCart._loyaltyTransactionIds = [...this._loyaltyTransactionIds];
|
|
896
|
+
newCart._tableService = this._tableService ? { ...this._tableService } : null;
|
|
851
897
|
newCart._taxSummary = this._taxSummary;
|
|
852
898
|
newCart._newlyCancelledItemIds = new Set(this._newlyCancelledItemIds);
|
|
853
899
|
newCart._invoiceCompany = this._invoiceCompany ? { ...this._invoiceCompany } : null;
|
|
@@ -873,7 +919,7 @@ var ApplyTo = /* @__PURE__ */ ((ApplyTo2) => {
|
|
|
873
919
|
})(ApplyTo || {});
|
|
874
920
|
|
|
875
921
|
// src/version.ts
|
|
876
|
-
var VERSION = "0.1.
|
|
922
|
+
var VERSION = "0.1.1";
|
|
877
923
|
// Annotate the CommonJS export names for ESM import in node:
|
|
878
924
|
0 && (module.exports = {
|
|
879
925
|
ApplyTo,
|
package/dist/index.d.cts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { CurrencyCode, PosBusinessDto, OrderTypePOS, PosDiscountDto, PosOrderItemDto, LocatorType, OrderFormat, OrderRefundStatus, OrderStatusEnum, PosOrderDto, PosCustomerDto, PaymentRefundDto, InvoiceCompanyResponseDto, PosOrderPriceDto, KitchenStatus, PosPaymentStatus, TransactionDto, DiscountType, MoneyDto, ItemPriceDto, PosOrderDtoTaxSummary } from '@munchi_oy/core';
|
|
1
|
+
import { CurrencyCode, PosBusinessDto, OrderTypePOS, ProviderEnum, CheckoutModelEnum, PosOrderDtoTableService, PosDiscountDto, PosOrderItemDto, LocatorType, OrderFormat, OrderRefundStatus, OrderStatusEnum, PosOrderDto, PosCustomerDto, PaymentRefundDto, InvoiceCompanyResponseDto, PosOrderPriceDto, KitchenStatus, PosPaymentStatus, TransactionDto, DiscountType, MoneyDto, ItemPriceDto, PosOrderDtoTaxSummary } from '@munchi_oy/core';
|
|
2
2
|
|
|
3
3
|
declare enum ApplyTo {
|
|
4
4
|
Order = "order",
|
|
@@ -17,6 +17,9 @@ interface CartCreateOptions {
|
|
|
17
17
|
business: PosBusinessDto;
|
|
18
18
|
orderNumber: string;
|
|
19
19
|
orderType?: OrderTypePOS;
|
|
20
|
+
provider?: ProviderEnum;
|
|
21
|
+
checkoutModel?: CheckoutModelEnum;
|
|
22
|
+
tableService?: PosOrderDtoTableService | null;
|
|
20
23
|
createdAt?: Date;
|
|
21
24
|
staffId?: string | null;
|
|
22
25
|
shiftId?: string | null;
|
|
@@ -29,10 +32,12 @@ type InternalPosDiscount = Omit<PosDiscountDto, "createdAt"> & {
|
|
|
29
32
|
declare class Cart {
|
|
30
33
|
readonly id: string;
|
|
31
34
|
readonly businessId: string;
|
|
35
|
+
readonly provider: ProviderEnum;
|
|
32
36
|
readonly currency: CurrencyCode;
|
|
33
37
|
readonly createdAt: Date;
|
|
34
38
|
orderNumber: string;
|
|
35
39
|
orderType: OrderTypePOS;
|
|
40
|
+
checkoutModel: CheckoutModelEnum;
|
|
36
41
|
orderFormat: OrderFormat;
|
|
37
42
|
spotNumber: string | null;
|
|
38
43
|
comments: string | null;
|
|
@@ -47,6 +52,7 @@ declare class Cart {
|
|
|
47
52
|
private _discounts;
|
|
48
53
|
private _customer;
|
|
49
54
|
private _refunds;
|
|
55
|
+
private _tableService;
|
|
50
56
|
private _taxSummary;
|
|
51
57
|
private _newlyCancelledItemIds;
|
|
52
58
|
private _invoiceCompany;
|
|
@@ -66,6 +72,8 @@ declare class Cart {
|
|
|
66
72
|
get loyaltyProgramId(): string | null;
|
|
67
73
|
get loyaltyTransactionIds(): readonly string[];
|
|
68
74
|
get invoiceCompany(): InvoiceCompanyResponseDto | null;
|
|
75
|
+
get guestCount(): number | null;
|
|
76
|
+
get tableService(): PosOrderDtoTableService | null;
|
|
69
77
|
get price(): PosOrderPriceDto;
|
|
70
78
|
setInvoiceCompany(company: InvoiceCompanyResponseDto | null): void;
|
|
71
79
|
addItem(itemData: CartItemAddData, requiresPrep?: boolean): void;
|
|
@@ -86,6 +94,10 @@ declare class Cart {
|
|
|
86
94
|
lineItemId?: string;
|
|
87
95
|
}): void;
|
|
88
96
|
setStaffContext(staffId: string | null, shiftId: string | null): void;
|
|
97
|
+
setCheckoutModel(checkoutModel: CheckoutModelEnum): void;
|
|
98
|
+
setCheckoutType(checkoutModel: CheckoutModelEnum): void;
|
|
99
|
+
setGuestCount(guestCount: number | null): void;
|
|
100
|
+
setSeatNumber(guestCount: number | null): void;
|
|
89
101
|
updateOrderStatus(newStatus: OrderStatusEnum): void;
|
|
90
102
|
updateOrderFormat(newFormat: OrderFormat): void;
|
|
91
103
|
updateLoyaltyProgramId(id: string): void;
|
|
@@ -152,6 +164,6 @@ declare function calculateOrderTaxSummary(details: {
|
|
|
152
164
|
currency: CurrencyCode;
|
|
153
165
|
}): PosOrderDtoTaxSummary;
|
|
154
166
|
|
|
155
|
-
declare const VERSION = "0.1.
|
|
167
|
+
declare const VERSION = "0.1.1";
|
|
156
168
|
|
|
157
169
|
export { ApplyTo, Cart, type CartCreateOptions, type CartItemAddData, type CartOptionPayload, type CartPriceSnapshot, type DiscountStrategyFn, type InternalPosDiscount, type SequentialDiscountCalculation, type TaxInclusiveSplitResult, type UpdatableCartDetails, VERSION, allocateProportionalMinorUnits, calculateCartPriceSnapshot, calculateDiscountAmount, calculateItemPrice, calculateOrderTaxSummary, calculateSequentialDiscountTotal, splitTaxInclusiveAmount };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { CurrencyCode, PosBusinessDto, OrderTypePOS, PosDiscountDto, PosOrderItemDto, LocatorType, OrderFormat, OrderRefundStatus, OrderStatusEnum, PosOrderDto, PosCustomerDto, PaymentRefundDto, InvoiceCompanyResponseDto, PosOrderPriceDto, KitchenStatus, PosPaymentStatus, TransactionDto, DiscountType, MoneyDto, ItemPriceDto, PosOrderDtoTaxSummary } from '@munchi_oy/core';
|
|
1
|
+
import { CurrencyCode, PosBusinessDto, OrderTypePOS, ProviderEnum, CheckoutModelEnum, PosOrderDtoTableService, PosDiscountDto, PosOrderItemDto, LocatorType, OrderFormat, OrderRefundStatus, OrderStatusEnum, PosOrderDto, PosCustomerDto, PaymentRefundDto, InvoiceCompanyResponseDto, PosOrderPriceDto, KitchenStatus, PosPaymentStatus, TransactionDto, DiscountType, MoneyDto, ItemPriceDto, PosOrderDtoTaxSummary } from '@munchi_oy/core';
|
|
2
2
|
|
|
3
3
|
declare enum ApplyTo {
|
|
4
4
|
Order = "order",
|
|
@@ -17,6 +17,9 @@ interface CartCreateOptions {
|
|
|
17
17
|
business: PosBusinessDto;
|
|
18
18
|
orderNumber: string;
|
|
19
19
|
orderType?: OrderTypePOS;
|
|
20
|
+
provider?: ProviderEnum;
|
|
21
|
+
checkoutModel?: CheckoutModelEnum;
|
|
22
|
+
tableService?: PosOrderDtoTableService | null;
|
|
20
23
|
createdAt?: Date;
|
|
21
24
|
staffId?: string | null;
|
|
22
25
|
shiftId?: string | null;
|
|
@@ -29,10 +32,12 @@ type InternalPosDiscount = Omit<PosDiscountDto, "createdAt"> & {
|
|
|
29
32
|
declare class Cart {
|
|
30
33
|
readonly id: string;
|
|
31
34
|
readonly businessId: string;
|
|
35
|
+
readonly provider: ProviderEnum;
|
|
32
36
|
readonly currency: CurrencyCode;
|
|
33
37
|
readonly createdAt: Date;
|
|
34
38
|
orderNumber: string;
|
|
35
39
|
orderType: OrderTypePOS;
|
|
40
|
+
checkoutModel: CheckoutModelEnum;
|
|
36
41
|
orderFormat: OrderFormat;
|
|
37
42
|
spotNumber: string | null;
|
|
38
43
|
comments: string | null;
|
|
@@ -47,6 +52,7 @@ declare class Cart {
|
|
|
47
52
|
private _discounts;
|
|
48
53
|
private _customer;
|
|
49
54
|
private _refunds;
|
|
55
|
+
private _tableService;
|
|
50
56
|
private _taxSummary;
|
|
51
57
|
private _newlyCancelledItemIds;
|
|
52
58
|
private _invoiceCompany;
|
|
@@ -66,6 +72,8 @@ declare class Cart {
|
|
|
66
72
|
get loyaltyProgramId(): string | null;
|
|
67
73
|
get loyaltyTransactionIds(): readonly string[];
|
|
68
74
|
get invoiceCompany(): InvoiceCompanyResponseDto | null;
|
|
75
|
+
get guestCount(): number | null;
|
|
76
|
+
get tableService(): PosOrderDtoTableService | null;
|
|
69
77
|
get price(): PosOrderPriceDto;
|
|
70
78
|
setInvoiceCompany(company: InvoiceCompanyResponseDto | null): void;
|
|
71
79
|
addItem(itemData: CartItemAddData, requiresPrep?: boolean): void;
|
|
@@ -86,6 +94,10 @@ declare class Cart {
|
|
|
86
94
|
lineItemId?: string;
|
|
87
95
|
}): void;
|
|
88
96
|
setStaffContext(staffId: string | null, shiftId: string | null): void;
|
|
97
|
+
setCheckoutModel(checkoutModel: CheckoutModelEnum): void;
|
|
98
|
+
setCheckoutType(checkoutModel: CheckoutModelEnum): void;
|
|
99
|
+
setGuestCount(guestCount: number | null): void;
|
|
100
|
+
setSeatNumber(guestCount: number | null): void;
|
|
89
101
|
updateOrderStatus(newStatus: OrderStatusEnum): void;
|
|
90
102
|
updateOrderFormat(newFormat: OrderFormat): void;
|
|
91
103
|
updateLoyaltyProgramId(id: string): void;
|
|
@@ -152,6 +164,6 @@ declare function calculateOrderTaxSummary(details: {
|
|
|
152
164
|
currency: CurrencyCode;
|
|
153
165
|
}): PosOrderDtoTaxSummary;
|
|
154
166
|
|
|
155
|
-
declare const VERSION = "0.1.
|
|
167
|
+
declare const VERSION = "0.1.1";
|
|
156
168
|
|
|
157
169
|
export { ApplyTo, Cart, type CartCreateOptions, type CartItemAddData, type CartOptionPayload, type CartPriceSnapshot, type DiscountStrategyFn, type InternalPosDiscount, type SequentialDiscountCalculation, type TaxInclusiveSplitResult, type UpdatableCartDetails, VERSION, allocateProportionalMinorUnits, calculateCartPriceSnapshot, calculateDiscountAmount, calculateItemPrice, calculateOrderTaxSummary, calculateSequentialDiscountTotal, splitTaxInclusiveAmount };
|
package/dist/index.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
// src/cart/Cart.ts
|
|
2
2
|
import {
|
|
3
|
+
CheckoutModelEnum as CheckoutModel,
|
|
3
4
|
DiscountScope as DiscountScope2,
|
|
4
5
|
KitchenStatus as KitchenStatus3,
|
|
5
6
|
LocatorType,
|
|
@@ -7,7 +8,8 @@ import {
|
|
|
7
8
|
OrderRefundStatus,
|
|
8
9
|
OrderStatusEnum,
|
|
9
10
|
OrderTypePOS,
|
|
10
|
-
PosPaymentStatus
|
|
11
|
+
PosPaymentStatus,
|
|
12
|
+
ProviderEnum as Provider
|
|
11
13
|
} from "@munchi_oy/core";
|
|
12
14
|
import { createId } from "@paralleldrive/cuid2";
|
|
13
15
|
import dayjs from "dayjs";
|
|
@@ -342,10 +344,12 @@ var { isEqual } = lodash;
|
|
|
342
344
|
var Cart = class _Cart {
|
|
343
345
|
id;
|
|
344
346
|
businessId;
|
|
347
|
+
provider;
|
|
345
348
|
currency;
|
|
346
349
|
createdAt;
|
|
347
350
|
orderNumber;
|
|
348
351
|
orderType;
|
|
352
|
+
checkoutModel;
|
|
349
353
|
orderFormat;
|
|
350
354
|
spotNumber;
|
|
351
355
|
comments;
|
|
@@ -360,6 +364,7 @@ var Cart = class _Cart {
|
|
|
360
364
|
_discounts = [];
|
|
361
365
|
_customer = null;
|
|
362
366
|
_refunds = [];
|
|
367
|
+
_tableService;
|
|
363
368
|
_taxSummary;
|
|
364
369
|
_newlyCancelledItemIds;
|
|
365
370
|
_invoiceCompany;
|
|
@@ -370,8 +375,10 @@ var Cart = class _Cart {
|
|
|
370
375
|
this.id = id;
|
|
371
376
|
this.createdAt = createdAt;
|
|
372
377
|
this.businessId = options.businessId;
|
|
378
|
+
this.provider = options.provider;
|
|
373
379
|
this.orderType = options.orderType;
|
|
374
380
|
this.orderNumber = options.orderNumber;
|
|
381
|
+
this.checkoutModel = options.checkoutModel;
|
|
375
382
|
this._business = options.business;
|
|
376
383
|
this.currency = options.currency;
|
|
377
384
|
this.updatedAt = createdAt;
|
|
@@ -383,6 +390,7 @@ var Cart = class _Cart {
|
|
|
383
390
|
this.status = OrderStatusEnum.Draft;
|
|
384
391
|
this.orderFormat = OrderFormat.Instant;
|
|
385
392
|
this._locatorType = LocatorType.Table;
|
|
393
|
+
this._tableService = options.tableService ?? null;
|
|
386
394
|
this._newlyCancelledItemIds = /* @__PURE__ */ new Set();
|
|
387
395
|
this._staffId = options.staffId ?? null;
|
|
388
396
|
this._shiftId = options.shiftId ?? null;
|
|
@@ -391,8 +399,11 @@ var Cart = class _Cart {
|
|
|
391
399
|
static create(options) {
|
|
392
400
|
return new _Cart(createId(), options.createdAt ?? dayjs().toDate(), {
|
|
393
401
|
businessId: options.businessId,
|
|
402
|
+
provider: options.provider ?? Provider.MunchiPos,
|
|
394
403
|
orderType: options.orderType ?? OrderTypePOS.DineIn,
|
|
395
404
|
orderNumber: options.orderNumber,
|
|
405
|
+
checkoutModel: options.checkoutModel ?? CheckoutModel.Full,
|
|
406
|
+
tableService: options.tableService ?? null,
|
|
396
407
|
currency: options.currency,
|
|
397
408
|
business: options.business,
|
|
398
409
|
staffId: options.staffId,
|
|
@@ -402,8 +413,11 @@ var Cart = class _Cart {
|
|
|
402
413
|
static fromData(orderDto) {
|
|
403
414
|
const cart = new _Cart(orderDto.id, dayjs(orderDto.createdAt).toDate(), {
|
|
404
415
|
businessId: orderDto.businessId,
|
|
416
|
+
provider: orderDto.provider,
|
|
405
417
|
orderType: orderDto.orderType,
|
|
406
418
|
orderNumber: orderDto.orderNumber,
|
|
419
|
+
checkoutModel: orderDto.checkoutModel,
|
|
420
|
+
tableService: orderDto.tableService ?? null,
|
|
407
421
|
currency: orderDto.currency,
|
|
408
422
|
business: orderDto.business,
|
|
409
423
|
staffId: orderDto.staffId ?? null,
|
|
@@ -425,6 +439,7 @@ var Cart = class _Cart {
|
|
|
425
439
|
cart._refunds = orderDto.refunds ? [...orderDto.refunds] : [];
|
|
426
440
|
cart._loyaltyTransactionIds = [...orderDto.loyaltyTransactionIds];
|
|
427
441
|
cart._loyaltyProgramId = orderDto.loyaltyProgramId ?? null;
|
|
442
|
+
cart._tableService = orderDto.tableService ? { ...orderDto.tableService } : null;
|
|
428
443
|
cart._newlyCancelledItemIds = /* @__PURE__ */ new Set();
|
|
429
444
|
cart._taxSummary = orderDto.taxSummary;
|
|
430
445
|
cart._invoiceCompany = orderDto.invoiceCompany ?? null;
|
|
@@ -460,6 +475,12 @@ var Cart = class _Cart {
|
|
|
460
475
|
get invoiceCompany() {
|
|
461
476
|
return this._invoiceCompany;
|
|
462
477
|
}
|
|
478
|
+
get guestCount() {
|
|
479
|
+
return this._tableService?.seats ?? null;
|
|
480
|
+
}
|
|
481
|
+
get tableService() {
|
|
482
|
+
return this._tableService;
|
|
483
|
+
}
|
|
463
484
|
get price() {
|
|
464
485
|
return calculateCartPriceSnapshot({
|
|
465
486
|
items: this._items,
|
|
@@ -713,6 +734,26 @@ var Cart = class _Cart {
|
|
|
713
734
|
this._shiftId = shiftId;
|
|
714
735
|
this.touch();
|
|
715
736
|
}
|
|
737
|
+
setCheckoutModel(checkoutModel) {
|
|
738
|
+
if (this.checkoutModel === checkoutModel) {
|
|
739
|
+
return;
|
|
740
|
+
}
|
|
741
|
+
this.checkoutModel = checkoutModel;
|
|
742
|
+
this.touch();
|
|
743
|
+
}
|
|
744
|
+
setCheckoutType(checkoutModel) {
|
|
745
|
+
this.setCheckoutModel(checkoutModel);
|
|
746
|
+
}
|
|
747
|
+
setGuestCount(guestCount) {
|
|
748
|
+
if (this._tableService?.seats ?? null === guestCount) {
|
|
749
|
+
return;
|
|
750
|
+
}
|
|
751
|
+
this._tableService = guestCount === null ? null : { seats: guestCount };
|
|
752
|
+
this.touch();
|
|
753
|
+
}
|
|
754
|
+
setSeatNumber(guestCount) {
|
|
755
|
+
this.setGuestCount(guestCount);
|
|
756
|
+
}
|
|
716
757
|
updateOrderStatus(newStatus) {
|
|
717
758
|
if (this.status === newStatus) {
|
|
718
759
|
return;
|
|
@@ -759,16 +800,19 @@ var Cart = class _Cart {
|
|
|
759
800
|
return {
|
|
760
801
|
id: this.id,
|
|
761
802
|
businessId: this.businessId,
|
|
803
|
+
provider: this.provider,
|
|
762
804
|
business: this._business,
|
|
763
805
|
currency: this.currency,
|
|
764
806
|
createdAt: this.createdAt.toISOString(),
|
|
765
807
|
updatedAt: this.updatedAt.toISOString(),
|
|
766
808
|
orderNumber: this.orderNumber,
|
|
809
|
+
checkoutModel: this.checkoutModel,
|
|
767
810
|
orderFormat: this.orderFormat,
|
|
768
811
|
orderType: this.orderType,
|
|
769
812
|
locatorType: this._locatorType,
|
|
770
813
|
spotNumber: this.spotNumber,
|
|
771
814
|
comments: this.comments,
|
|
815
|
+
tableService: this._tableService,
|
|
772
816
|
orderRefundStatus: this.orderRefundStatus,
|
|
773
817
|
items: this._items,
|
|
774
818
|
status: this.status,
|
|
@@ -792,8 +836,11 @@ var Cart = class _Cart {
|
|
|
792
836
|
clone() {
|
|
793
837
|
const newCart = new _Cart(this.id, this.createdAt, {
|
|
794
838
|
businessId: this.businessId,
|
|
839
|
+
provider: this.provider,
|
|
795
840
|
orderType: this.orderType,
|
|
796
841
|
orderNumber: this.orderNumber,
|
|
842
|
+
checkoutModel: this.checkoutModel,
|
|
843
|
+
tableService: this._tableService,
|
|
797
844
|
currency: this.currency,
|
|
798
845
|
business: this._business,
|
|
799
846
|
staffId: this._staffId,
|
|
@@ -812,6 +859,7 @@ var Cart = class _Cart {
|
|
|
812
859
|
newCart._refunds = [...this._refunds];
|
|
813
860
|
newCart._loyaltyProgramId = this._loyaltyProgramId;
|
|
814
861
|
newCart._loyaltyTransactionIds = [...this._loyaltyTransactionIds];
|
|
862
|
+
newCart._tableService = this._tableService ? { ...this._tableService } : null;
|
|
815
863
|
newCart._taxSummary = this._taxSummary;
|
|
816
864
|
newCart._newlyCancelledItemIds = new Set(this._newlyCancelledItemIds);
|
|
817
865
|
newCart._invoiceCompany = this._invoiceCompany ? { ...this._invoiceCompany } : null;
|
|
@@ -837,7 +885,7 @@ var ApplyTo = /* @__PURE__ */ ((ApplyTo2) => {
|
|
|
837
885
|
})(ApplyTo || {});
|
|
838
886
|
|
|
839
887
|
// src/version.ts
|
|
840
|
-
var VERSION = "0.1.
|
|
888
|
+
var VERSION = "0.1.1";
|
|
841
889
|
export {
|
|
842
890
|
ApplyTo,
|
|
843
891
|
Cart,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@munchi_oy/cart-engine",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.1",
|
|
4
4
|
"description": "Headless settlement engine for Munchi POS, kiosk, and mobile flows",
|
|
5
5
|
"license": "UNLICENSED",
|
|
6
6
|
"private": false,
|
|
@@ -39,7 +39,7 @@
|
|
|
39
39
|
},
|
|
40
40
|
"devDependencies": {
|
|
41
41
|
"@jest/globals": "^30.3.0",
|
|
42
|
-
"@munchi_oy/core": "^1.4.
|
|
42
|
+
"@munchi_oy/core": "^1.4.2",
|
|
43
43
|
"@paralleldrive/cuid2": "^3.3.0",
|
|
44
44
|
"@types/jest": "^30.0.0",
|
|
45
45
|
"@types/lodash": "^4.17.20",
|
|
@@ -52,7 +52,7 @@
|
|
|
52
52
|
"yalc": "^1.0.0-pre.53"
|
|
53
53
|
},
|
|
54
54
|
"peerDependencies": {
|
|
55
|
-
"@munchi_oy/core": "^1.4.
|
|
55
|
+
"@munchi_oy/core": "^1.4.2",
|
|
56
56
|
"@paralleldrive/cuid2": "^3.3.0",
|
|
57
57
|
"dayjs": "^1.11.20",
|
|
58
58
|
"lodash": "^4.17.21"
|