@munchi_oy/cart-engine 0.1.2 → 0.1.4

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.cts CHANGED
@@ -1,4 +1,4 @@
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';
1
+ import { CurrencyCode, PosBusinessDto, OrderTypePOS, ProviderEnum, CheckoutModelEnum, PosOrderTableServiceDto, PosOrderEqualSplitStateDto, PosDiscountDto, PosOrderItemDto, LocatorType, OrderFormat, OrderRefundStatus, OrderStatusEnum, PosOrderDto, PosCustomerDto, PaymentRefundDto, InvoiceCompanyResponseDto, PosOrderPriceDto, KitchenStatus, PosPaymentStatus, PosOrderItemSplitSeatDto, PosOrderItemSplitSeatAssignmentDto, PosOrderEqualSplitPartDto, TransactionDto, DiscountType, MoneyDto, ItemPriceDto, PosOrderDtoTaxSummary } from '@munchi_oy/core';
2
2
 
3
3
  declare enum ApplyTo {
4
4
  Order = "order",
@@ -19,7 +19,8 @@ interface CartCreateOptions {
19
19
  orderType?: OrderTypePOS;
20
20
  provider?: ProviderEnum;
21
21
  checkoutModel?: CheckoutModelEnum;
22
- tableService?: PosOrderDtoTableService | null;
22
+ tableService?: PosOrderTableServiceDto | null;
23
+ equalSplitState?: PosOrderEqualSplitStateDto | null;
23
24
  createdAt?: Date;
24
25
  staffId?: string | null;
25
26
  shiftId?: string | null;
@@ -53,6 +54,7 @@ declare class Cart {
53
54
  private _customer;
54
55
  private _refunds;
55
56
  private _tableService;
57
+ private _equalSplitState;
56
58
  private _taxSummary;
57
59
  private _newlyCancelledItemIds;
58
60
  private _invoiceCompany;
@@ -73,7 +75,9 @@ declare class Cart {
73
75
  get loyaltyTransactionIds(): readonly string[];
74
76
  get invoiceCompany(): InvoiceCompanyResponseDto | null;
75
77
  get guestCount(): number | null;
76
- get tableService(): PosOrderDtoTableService | null;
78
+ get tableService(): PosOrderTableServiceDto | null;
79
+ get equalSplitState(): PosOrderEqualSplitStateDto | null;
80
+ get equalSplitPartCount(): number | null;
77
81
  get price(): PosOrderPriceDto;
78
82
  setInvoiceCompany(company: InvoiceCompanyResponseDto | null): void;
79
83
  addItem(itemData: CartItemAddData, requiresPrep?: boolean): void;
@@ -84,6 +88,9 @@ declare class Cart {
84
88
  clearCancellationTracking(): void;
85
89
  applyDiscountToCart(discountData: Omit<PosDiscountDto, "scope" | "lineItemId" | "createdAt">): void;
86
90
  applyDiscountToItem(lineItemId: string, discountData: Omit<PosDiscountDto, "scope" | "lineItemId" | "createdAt">): void;
91
+ applyDiscountToItemSplitSeat(seatId: string, discountData: Omit<PosDiscountDto, "scope" | "lineItemId" | "createdAt">): void;
92
+ applyDiscountToItemSplitAssignment(assignmentId: string, discountData: Omit<PosDiscountDto, "scope" | "lineItemId" | "createdAt">): void;
93
+ applyDiscountToEqualSplitPart(partId: string, discountData: Omit<PosDiscountDto, "scope" | "lineItemId" | "createdAt">): void;
87
94
  removeItemDiscount(lineItemId: string): void;
88
95
  removeDiscount(discountId: string): void;
89
96
  setCustomer(customer: PosCustomerDto | null): void;
@@ -98,6 +105,47 @@ declare class Cart {
98
105
  setCheckoutType(checkoutModel: CheckoutModelEnum): void;
99
106
  setGuestCount(guestCount: number | null): void;
100
107
  setSeatNumber(guestCount: number | null): void;
108
+ getTableService(): PosOrderTableServiceDto | null;
109
+ setTableService(tableService: PosOrderTableServiceDto | null): this;
110
+ clearTableService(): this;
111
+ getTableName(): string | null;
112
+ setTableName(name: string | null): this;
113
+ getSeatsCount(): number | null;
114
+ setSeatsCount(seats: number): this;
115
+ getItemSplitSeats(): PosOrderItemSplitSeatDto[];
116
+ setItemSplitSeats(seats: PosOrderItemSplitSeatDto[]): this;
117
+ clearItemSplitSeats(): this;
118
+ addItemSplitSeat(seat: PosOrderItemSplitSeatDto): this;
119
+ updateItemSplitSeat(seatId: string, updater: (seat: PosOrderItemSplitSeatDto) => PosOrderItemSplitSeatDto): this;
120
+ removeItemSplitSeat(seatId: string): this;
121
+ getItemSplitSeatById(seatId: string): PosOrderItemSplitSeatDto | null;
122
+ setItemSplitSeatAssignments(seatId: string, assignments: PosOrderItemSplitSeatAssignmentDto[]): this;
123
+ addItemSplitSeatAssignment(seatId: string, assignment: PosOrderItemSplitSeatAssignmentDto): this;
124
+ removeItemSplitSeatAssignmentsByLineItem(seatId: string, lineItemId: string): this;
125
+ clearItemSplitSeatAssignments(seatId: string): this;
126
+ setItemSplitSeatLoyalty(seatId: string, loyaltyId: string | null, loyaltyUserName: string | null): this;
127
+ clearItemSplitSeatLoyalty(seatId: string): this;
128
+ setItemSplitSeatAppliedDiscountIds(seatId: string, appliedDiscountIds: string[]): this;
129
+ addItemSplitSeatAppliedDiscountId(seatId: string, discountId: string): this;
130
+ removeItemSplitSeatAppliedDiscountId(seatId: string, discountId: string): this;
131
+ clearItemSplitSeatAppliedDiscountIds(seatId: string): this;
132
+ getEqualSplitState(): PosOrderEqualSplitStateDto | null;
133
+ setEqualSplitState(equalSplitState: PosOrderEqualSplitStateDto | null): this;
134
+ clearEqualSplitState(): this;
135
+ getEqualSplitParts(): PosOrderEqualSplitPartDto[];
136
+ setEqualSplitParts(parts: PosOrderEqualSplitPartDto[]): this;
137
+ clearEqualSplitParts(): this;
138
+ addEqualSplitPart(part: PosOrderEqualSplitPartDto): this;
139
+ updateEqualSplitPart(partId: string, updater: (part: PosOrderEqualSplitPartDto) => PosOrderEqualSplitPartDto): this;
140
+ removeEqualSplitPart(partId: string): this;
141
+ getEqualSplitPartById(partId: string): PosOrderEqualSplitPartDto | null;
142
+ getEqualSplitPartCount(): number | null;
143
+ setEqualSplitPartCount(partCount: number | null): this;
144
+ clearEqualSplitPartCount(): this;
145
+ setEqualSplitPartAppliedDiscountIds(partId: string, appliedDiscountIds: string[]): this;
146
+ addEqualSplitPartAppliedDiscountId(partId: string, discountId: string): this;
147
+ removeEqualSplitPartAppliedDiscountId(partId: string, discountId: string): this;
148
+ clearEqualSplitPartAppliedDiscountIds(partId: string): this;
101
149
  updateOrderStatus(newStatus: OrderStatusEnum): void;
102
150
  updateOrderFormat(newFormat: OrderFormat): void;
103
151
  updateLoyaltyProgramId(id: string): void;
@@ -106,6 +154,7 @@ declare class Cart {
106
154
  toJSON(paymentEvents?: TransactionDto[]): PosOrderDto;
107
155
  clone(): Cart;
108
156
  private calculateOrderTaxSummary;
157
+ private createDiscountRecord;
109
158
  private touch;
110
159
  }
111
160
 
@@ -130,10 +179,34 @@ interface CartPriceSnapshot {
130
179
  totalBeforeDiscountsAmount: number;
131
180
  subtotalItemDiscountsAmount: number;
132
181
  subtotalBasketDiscountsAmount: number;
182
+ subtotalTargetedDiscountsAmount: number;
133
183
  totalDiscountsAmount: number;
134
184
  totalAmount: number;
185
+ itemSplitSeatPricing: SplitPricingResult | null;
186
+ equalSplitPartPricing: SplitPricingResult | null;
135
187
  price: PosOrderPriceDto;
136
188
  }
189
+ interface SplitTargetAmount {
190
+ id: string;
191
+ grossAmount: number;
192
+ discountAmount: number;
193
+ netAmount: number;
194
+ }
195
+ interface SplitPricingResult {
196
+ targets: SplitTargetAmount[];
197
+ totalGrossAmount: number;
198
+ totalDiscountAmount: number;
199
+ totalNetAmount: number;
200
+ }
201
+ declare function calculateItemSplitSeatPricing(details: {
202
+ tableService: PosOrderTableServiceDto | null | undefined;
203
+ discounts: readonly InternalPosDiscount[];
204
+ }): SplitPricingResult;
205
+ declare function calculateEqualSplitPartPricing(details: {
206
+ totalAmount: number;
207
+ equalSplitState: PosOrderEqualSplitStateDto | null | undefined;
208
+ discounts: readonly InternalPosDiscount[];
209
+ }): SplitPricingResult;
137
210
  declare function calculateItemPrice(details: {
138
211
  basePriceInMinorUnit: number;
139
212
  quantity: number;
@@ -149,6 +222,9 @@ declare function calculateCartPriceSnapshot(details: {
149
222
  items: readonly PosOrderItemDto[];
150
223
  discounts: readonly InternalPosDiscount[];
151
224
  currency: CurrencyCode;
225
+ checkoutModel?: CheckoutModelEnum;
226
+ tableService?: PosOrderTableServiceDto | null;
227
+ equalSplitState?: PosOrderEqualSplitStateDto | null;
152
228
  }): CartPriceSnapshot;
153
229
 
154
230
  interface TaxInclusiveSplitResult {
@@ -164,6 +240,6 @@ declare function calculateOrderTaxSummary(details: {
164
240
  currency: CurrencyCode;
165
241
  }): PosOrderDtoTaxSummary;
166
242
 
167
- declare const VERSION = "0.1.2";
243
+ declare const VERSION = "0.1.4";
168
244
 
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 };
245
+ export { ApplyTo, Cart, type CartCreateOptions, type CartItemAddData, type CartOptionPayload, type CartPriceSnapshot, type DiscountStrategyFn, type InternalPosDiscount, type SequentialDiscountCalculation, type SplitPricingResult, type SplitTargetAmount, type TaxInclusiveSplitResult, type UpdatableCartDetails, VERSION, allocateProportionalMinorUnits, calculateCartPriceSnapshot, calculateDiscountAmount, calculateEqualSplitPartPricing, calculateItemPrice, calculateItemSplitSeatPricing, calculateOrderTaxSummary, calculateSequentialDiscountTotal, splitTaxInclusiveAmount };
package/dist/index.d.ts CHANGED
@@ -1,4 +1,4 @@
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';
1
+ import { CurrencyCode, PosBusinessDto, OrderTypePOS, ProviderEnum, CheckoutModelEnum, PosOrderTableServiceDto, PosOrderEqualSplitStateDto, PosDiscountDto, PosOrderItemDto, LocatorType, OrderFormat, OrderRefundStatus, OrderStatusEnum, PosOrderDto, PosCustomerDto, PaymentRefundDto, InvoiceCompanyResponseDto, PosOrderPriceDto, KitchenStatus, PosPaymentStatus, PosOrderItemSplitSeatDto, PosOrderItemSplitSeatAssignmentDto, PosOrderEqualSplitPartDto, TransactionDto, DiscountType, MoneyDto, ItemPriceDto, PosOrderDtoTaxSummary } from '@munchi_oy/core';
2
2
 
3
3
  declare enum ApplyTo {
4
4
  Order = "order",
@@ -19,7 +19,8 @@ interface CartCreateOptions {
19
19
  orderType?: OrderTypePOS;
20
20
  provider?: ProviderEnum;
21
21
  checkoutModel?: CheckoutModelEnum;
22
- tableService?: PosOrderDtoTableService | null;
22
+ tableService?: PosOrderTableServiceDto | null;
23
+ equalSplitState?: PosOrderEqualSplitStateDto | null;
23
24
  createdAt?: Date;
24
25
  staffId?: string | null;
25
26
  shiftId?: string | null;
@@ -53,6 +54,7 @@ declare class Cart {
53
54
  private _customer;
54
55
  private _refunds;
55
56
  private _tableService;
57
+ private _equalSplitState;
56
58
  private _taxSummary;
57
59
  private _newlyCancelledItemIds;
58
60
  private _invoiceCompany;
@@ -73,7 +75,9 @@ declare class Cart {
73
75
  get loyaltyTransactionIds(): readonly string[];
74
76
  get invoiceCompany(): InvoiceCompanyResponseDto | null;
75
77
  get guestCount(): number | null;
76
- get tableService(): PosOrderDtoTableService | null;
78
+ get tableService(): PosOrderTableServiceDto | null;
79
+ get equalSplitState(): PosOrderEqualSplitStateDto | null;
80
+ get equalSplitPartCount(): number | null;
77
81
  get price(): PosOrderPriceDto;
78
82
  setInvoiceCompany(company: InvoiceCompanyResponseDto | null): void;
79
83
  addItem(itemData: CartItemAddData, requiresPrep?: boolean): void;
@@ -84,6 +88,9 @@ declare class Cart {
84
88
  clearCancellationTracking(): void;
85
89
  applyDiscountToCart(discountData: Omit<PosDiscountDto, "scope" | "lineItemId" | "createdAt">): void;
86
90
  applyDiscountToItem(lineItemId: string, discountData: Omit<PosDiscountDto, "scope" | "lineItemId" | "createdAt">): void;
91
+ applyDiscountToItemSplitSeat(seatId: string, discountData: Omit<PosDiscountDto, "scope" | "lineItemId" | "createdAt">): void;
92
+ applyDiscountToItemSplitAssignment(assignmentId: string, discountData: Omit<PosDiscountDto, "scope" | "lineItemId" | "createdAt">): void;
93
+ applyDiscountToEqualSplitPart(partId: string, discountData: Omit<PosDiscountDto, "scope" | "lineItemId" | "createdAt">): void;
87
94
  removeItemDiscount(lineItemId: string): void;
88
95
  removeDiscount(discountId: string): void;
89
96
  setCustomer(customer: PosCustomerDto | null): void;
@@ -98,6 +105,47 @@ declare class Cart {
98
105
  setCheckoutType(checkoutModel: CheckoutModelEnum): void;
99
106
  setGuestCount(guestCount: number | null): void;
100
107
  setSeatNumber(guestCount: number | null): void;
108
+ getTableService(): PosOrderTableServiceDto | null;
109
+ setTableService(tableService: PosOrderTableServiceDto | null): this;
110
+ clearTableService(): this;
111
+ getTableName(): string | null;
112
+ setTableName(name: string | null): this;
113
+ getSeatsCount(): number | null;
114
+ setSeatsCount(seats: number): this;
115
+ getItemSplitSeats(): PosOrderItemSplitSeatDto[];
116
+ setItemSplitSeats(seats: PosOrderItemSplitSeatDto[]): this;
117
+ clearItemSplitSeats(): this;
118
+ addItemSplitSeat(seat: PosOrderItemSplitSeatDto): this;
119
+ updateItemSplitSeat(seatId: string, updater: (seat: PosOrderItemSplitSeatDto) => PosOrderItemSplitSeatDto): this;
120
+ removeItemSplitSeat(seatId: string): this;
121
+ getItemSplitSeatById(seatId: string): PosOrderItemSplitSeatDto | null;
122
+ setItemSplitSeatAssignments(seatId: string, assignments: PosOrderItemSplitSeatAssignmentDto[]): this;
123
+ addItemSplitSeatAssignment(seatId: string, assignment: PosOrderItemSplitSeatAssignmentDto): this;
124
+ removeItemSplitSeatAssignmentsByLineItem(seatId: string, lineItemId: string): this;
125
+ clearItemSplitSeatAssignments(seatId: string): this;
126
+ setItemSplitSeatLoyalty(seatId: string, loyaltyId: string | null, loyaltyUserName: string | null): this;
127
+ clearItemSplitSeatLoyalty(seatId: string): this;
128
+ setItemSplitSeatAppliedDiscountIds(seatId: string, appliedDiscountIds: string[]): this;
129
+ addItemSplitSeatAppliedDiscountId(seatId: string, discountId: string): this;
130
+ removeItemSplitSeatAppliedDiscountId(seatId: string, discountId: string): this;
131
+ clearItemSplitSeatAppliedDiscountIds(seatId: string): this;
132
+ getEqualSplitState(): PosOrderEqualSplitStateDto | null;
133
+ setEqualSplitState(equalSplitState: PosOrderEqualSplitStateDto | null): this;
134
+ clearEqualSplitState(): this;
135
+ getEqualSplitParts(): PosOrderEqualSplitPartDto[];
136
+ setEqualSplitParts(parts: PosOrderEqualSplitPartDto[]): this;
137
+ clearEqualSplitParts(): this;
138
+ addEqualSplitPart(part: PosOrderEqualSplitPartDto): this;
139
+ updateEqualSplitPart(partId: string, updater: (part: PosOrderEqualSplitPartDto) => PosOrderEqualSplitPartDto): this;
140
+ removeEqualSplitPart(partId: string): this;
141
+ getEqualSplitPartById(partId: string): PosOrderEqualSplitPartDto | null;
142
+ getEqualSplitPartCount(): number | null;
143
+ setEqualSplitPartCount(partCount: number | null): this;
144
+ clearEqualSplitPartCount(): this;
145
+ setEqualSplitPartAppliedDiscountIds(partId: string, appliedDiscountIds: string[]): this;
146
+ addEqualSplitPartAppliedDiscountId(partId: string, discountId: string): this;
147
+ removeEqualSplitPartAppliedDiscountId(partId: string, discountId: string): this;
148
+ clearEqualSplitPartAppliedDiscountIds(partId: string): this;
101
149
  updateOrderStatus(newStatus: OrderStatusEnum): void;
102
150
  updateOrderFormat(newFormat: OrderFormat): void;
103
151
  updateLoyaltyProgramId(id: string): void;
@@ -106,6 +154,7 @@ declare class Cart {
106
154
  toJSON(paymentEvents?: TransactionDto[]): PosOrderDto;
107
155
  clone(): Cart;
108
156
  private calculateOrderTaxSummary;
157
+ private createDiscountRecord;
109
158
  private touch;
110
159
  }
111
160
 
@@ -130,10 +179,34 @@ interface CartPriceSnapshot {
130
179
  totalBeforeDiscountsAmount: number;
131
180
  subtotalItemDiscountsAmount: number;
132
181
  subtotalBasketDiscountsAmount: number;
182
+ subtotalTargetedDiscountsAmount: number;
133
183
  totalDiscountsAmount: number;
134
184
  totalAmount: number;
185
+ itemSplitSeatPricing: SplitPricingResult | null;
186
+ equalSplitPartPricing: SplitPricingResult | null;
135
187
  price: PosOrderPriceDto;
136
188
  }
189
+ interface SplitTargetAmount {
190
+ id: string;
191
+ grossAmount: number;
192
+ discountAmount: number;
193
+ netAmount: number;
194
+ }
195
+ interface SplitPricingResult {
196
+ targets: SplitTargetAmount[];
197
+ totalGrossAmount: number;
198
+ totalDiscountAmount: number;
199
+ totalNetAmount: number;
200
+ }
201
+ declare function calculateItemSplitSeatPricing(details: {
202
+ tableService: PosOrderTableServiceDto | null | undefined;
203
+ discounts: readonly InternalPosDiscount[];
204
+ }): SplitPricingResult;
205
+ declare function calculateEqualSplitPartPricing(details: {
206
+ totalAmount: number;
207
+ equalSplitState: PosOrderEqualSplitStateDto | null | undefined;
208
+ discounts: readonly InternalPosDiscount[];
209
+ }): SplitPricingResult;
137
210
  declare function calculateItemPrice(details: {
138
211
  basePriceInMinorUnit: number;
139
212
  quantity: number;
@@ -149,6 +222,9 @@ declare function calculateCartPriceSnapshot(details: {
149
222
  items: readonly PosOrderItemDto[];
150
223
  discounts: readonly InternalPosDiscount[];
151
224
  currency: CurrencyCode;
225
+ checkoutModel?: CheckoutModelEnum;
226
+ tableService?: PosOrderTableServiceDto | null;
227
+ equalSplitState?: PosOrderEqualSplitStateDto | null;
152
228
  }): CartPriceSnapshot;
153
229
 
154
230
  interface TaxInclusiveSplitResult {
@@ -164,6 +240,6 @@ declare function calculateOrderTaxSummary(details: {
164
240
  currency: CurrencyCode;
165
241
  }): PosOrderDtoTaxSummary;
166
242
 
167
- declare const VERSION = "0.1.2";
243
+ declare const VERSION = "0.1.4";
168
244
 
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 };
245
+ export { ApplyTo, Cart, type CartCreateOptions, type CartItemAddData, type CartOptionPayload, type CartPriceSnapshot, type DiscountStrategyFn, type InternalPosDiscount, type SequentialDiscountCalculation, type SplitPricingResult, type SplitTargetAmount, type TaxInclusiveSplitResult, type UpdatableCartDetails, VERSION, allocateProportionalMinorUnits, calculateCartPriceSnapshot, calculateDiscountAmount, calculateEqualSplitPartPricing, calculateItemPrice, calculateItemSplitSeatPricing, calculateOrderTaxSummary, calculateSequentialDiscountTotal, splitTaxInclusiveAmount };