@darkpos/pricing 1.0.137 → 1.0.138
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/__TEST__/order/order-payment-modifier.test.js +1845 -12
- package/__TEST__/order/order.test.js +882 -3
- package/lib/index.js +11 -0
- package/lib/invoice/getStatusByItems.js +22 -0
- package/lib/invoice/getTotalByItems.js +12 -0
- package/lib/invoice/index.js +24 -0
- package/lib/item/applyPayment.js +22 -0
- package/lib/item/calculate.js +13 -7
- package/lib/item/getAmountToPayById.js +6 -0
- package/lib/item/getBalanceForPaymentModifier.js +30 -0
- package/lib/item/getPaidStatus.js +29 -0
- package/lib/item/index.js +8 -2
- package/lib/item/patchItem.js +3 -1
- package/lib/modifier/patchModifier.js +4 -0
- package/lib/order/calculate.js +47 -3
- package/lib/order/calculateWithPayment.js +36 -0
- package/lib/order/getPaidStatus.js +35 -0
- package/lib/order/getPickedStatus.js +4 -0
- package/lib/order/index.js +6 -2
- package/lib/order/updatePaidStatus.js +0 -0
- package/package.json +4 -3
- package/lib/item/getUpdatedStatus.js +0 -17
- package/lib/order/getUpdatedStatus.js +0 -17
|
@@ -3740,6 +3740,9 @@ describe('Order actions', () => {
|
|
|
3740
3740
|
const orderItem = {
|
|
3741
3741
|
price: 0,
|
|
3742
3742
|
quantity: 1,
|
|
3743
|
+
status: {
|
|
3744
|
+
picked: { value: true },
|
|
3745
|
+
},
|
|
3743
3746
|
};
|
|
3744
3747
|
const order = { items: [orderItem] };
|
|
3745
3748
|
const pricing = usePricing({
|
|
@@ -3748,6 +3751,7 @@ describe('Order actions', () => {
|
|
|
3748
3751
|
const newOrder = pricing.order.calculate(order);
|
|
3749
3752
|
|
|
3750
3753
|
expect(newOrder).toHaveProperty('total', 0);
|
|
3754
|
+
|
|
3751
3755
|
expect(newOrder.status).toMatchObject({ paid: true });
|
|
3752
3756
|
expect(newOrder.items[0].total).toBe(0);
|
|
3753
3757
|
expect(newOrder.items[0].status).toMatchObject({
|
|
@@ -3759,9 +3763,16 @@ describe('Order actions', () => {
|
|
|
3759
3763
|
const newOrder2 = pricingService.order.calculate(order);
|
|
3760
3764
|
|
|
3761
3765
|
expect(newOrder2).toHaveProperty('total', 0);
|
|
3762
|
-
expect(newOrder2.status).
|
|
3766
|
+
expect(newOrder2.status).toEqual({
|
|
3767
|
+
paid: false,
|
|
3768
|
+
picked: true,
|
|
3769
|
+
order: 'open',
|
|
3770
|
+
});
|
|
3763
3771
|
expect(newOrder2.items[0].total).toBe(0);
|
|
3764
|
-
expect(newOrder2.items[0].status).
|
|
3772
|
+
expect(newOrder2.items[0].status).toEqual({
|
|
3773
|
+
paid: undefined,
|
|
3774
|
+
picked: { value: true },
|
|
3775
|
+
});
|
|
3765
3776
|
});
|
|
3766
3777
|
|
|
3767
3778
|
test('Unset paid status if total is > 0 and autoMarkAsPaid: true', () => {
|
|
@@ -3785,11 +3796,15 @@ describe('Order actions', () => {
|
|
|
3785
3796
|
paid: undefined,
|
|
3786
3797
|
});
|
|
3787
3798
|
|
|
3788
|
-
const newOrder2 = pricingService.order.calculate(
|
|
3799
|
+
const newOrder2 = pricingService.order.calculate({
|
|
3800
|
+
...order,
|
|
3801
|
+
items: [{ ...orderItem, totalPaid: 25 }],
|
|
3802
|
+
});
|
|
3789
3803
|
|
|
3790
3804
|
expect(newOrder2).toHaveProperty('total', 25);
|
|
3791
3805
|
expect(newOrder2.status).toMatchObject({ paid: true });
|
|
3792
3806
|
expect(newOrder2.items[0].total).toBe(25);
|
|
3807
|
+
|
|
3793
3808
|
expect(newOrder2.items[0].status).toMatchObject({ paid: { value: true } });
|
|
3794
3809
|
});
|
|
3795
3810
|
|
|
@@ -4069,4 +4084,868 @@ describe('Order actions', () => {
|
|
|
4069
4084
|
});
|
|
4070
4085
|
});
|
|
4071
4086
|
});
|
|
4087
|
+
|
|
4088
|
+
test('Should calculate order and not use invalid modifiers for adjusting a decimals difference', () => {
|
|
4089
|
+
const prePay = {
|
|
4090
|
+
_id: '696ff00f11527d9252127519',
|
|
4091
|
+
attributes: [],
|
|
4092
|
+
modifierId: '68a1005bb49860bc58c2ce90',
|
|
4093
|
+
_parentId: null,
|
|
4094
|
+
locked: false,
|
|
4095
|
+
name: 'Prepay discount',
|
|
4096
|
+
sku: '',
|
|
4097
|
+
description: '',
|
|
4098
|
+
group: 'Discount',
|
|
4099
|
+
type: 'discount',
|
|
4100
|
+
tags: ['default'],
|
|
4101
|
+
order: 0,
|
|
4102
|
+
included: false,
|
|
4103
|
+
direct: true,
|
|
4104
|
+
hidden: false,
|
|
4105
|
+
print: true,
|
|
4106
|
+
required: false,
|
|
4107
|
+
recommended: false,
|
|
4108
|
+
default: true,
|
|
4109
|
+
code: '',
|
|
4110
|
+
properties: {
|
|
4111
|
+
override: null,
|
|
4112
|
+
sort: 3,
|
|
4113
|
+
isQuantityMultiplier: true,
|
|
4114
|
+
},
|
|
4115
|
+
|
|
4116
|
+
conditions: {
|
|
4117
|
+
valid: false,
|
|
4118
|
+
rules: [
|
|
4119
|
+
{
|
|
4120
|
+
key: 'payment',
|
|
4121
|
+
value: 'prepay',
|
|
4122
|
+
operand: '$in',
|
|
4123
|
+
},
|
|
4124
|
+
],
|
|
4125
|
+
},
|
|
4126
|
+
compute: {
|
|
4127
|
+
type: 'percentage',
|
|
4128
|
+
action: 'subtract',
|
|
4129
|
+
amount: 10,
|
|
4130
|
+
},
|
|
4131
|
+
_createdAt: '2025-08-16T22:04:11.497Z',
|
|
4132
|
+
_updatedAt: '2026-01-20T21:13:15.668Z',
|
|
4133
|
+
__typename: 'Modifier',
|
|
4134
|
+
};
|
|
4135
|
+
const ccfee = {
|
|
4136
|
+
_id: '696ff00f11527d925212751a',
|
|
4137
|
+
attributes: [],
|
|
4138
|
+
modifierId: '68a4f71a7d9879299ccd2d53',
|
|
4139
|
+
_parentId: null,
|
|
4140
|
+
locked: false,
|
|
4141
|
+
name: 'CC Fee',
|
|
4142
|
+
sku: '',
|
|
4143
|
+
description: '',
|
|
4144
|
+
group: 'Fee',
|
|
4145
|
+
type: 'fee',
|
|
4146
|
+
tags: ['default'],
|
|
4147
|
+
order: 0,
|
|
4148
|
+
included: false,
|
|
4149
|
+
direct: true,
|
|
4150
|
+
hidden: false,
|
|
4151
|
+
print: true,
|
|
4152
|
+
required: true,
|
|
4153
|
+
recommended: false,
|
|
4154
|
+
default: false,
|
|
4155
|
+
code: '',
|
|
4156
|
+
properties: {
|
|
4157
|
+
override: null,
|
|
4158
|
+
sort: 6,
|
|
4159
|
+
isQuantityMultiplier: false,
|
|
4160
|
+
},
|
|
4161
|
+
conditions: {
|
|
4162
|
+
valid: false,
|
|
4163
|
+
rules: [
|
|
4164
|
+
{
|
|
4165
|
+
key: 'paymentTypes',
|
|
4166
|
+
value: ['credit-card'],
|
|
4167
|
+
operand: '$in',
|
|
4168
|
+
},
|
|
4169
|
+
],
|
|
4170
|
+
},
|
|
4171
|
+
compute: {
|
|
4172
|
+
type: 'percentage',
|
|
4173
|
+
action: 'add',
|
|
4174
|
+
amount: 3,
|
|
4175
|
+
},
|
|
4176
|
+
};
|
|
4177
|
+
const tax = {
|
|
4178
|
+
_id: '696ff00f11527d9252127518',
|
|
4179
|
+
attributes: [],
|
|
4180
|
+
modifierId: '68a10008a4582a7ef17eb3ec',
|
|
4181
|
+
_parentId: null,
|
|
4182
|
+
locked: false,
|
|
4183
|
+
name: 'Tax 5%',
|
|
4184
|
+
sku: '',
|
|
4185
|
+
description: '',
|
|
4186
|
+
group: 'Tax',
|
|
4187
|
+
type: 'tax',
|
|
4188
|
+
tags: ['default'],
|
|
4189
|
+
order: 0,
|
|
4190
|
+
included: false,
|
|
4191
|
+
direct: true,
|
|
4192
|
+
hidden: false,
|
|
4193
|
+
print: false,
|
|
4194
|
+
required: true,
|
|
4195
|
+
recommended: false,
|
|
4196
|
+
default: false,
|
|
4197
|
+
code: '',
|
|
4198
|
+
properties: {
|
|
4199
|
+
override: null,
|
|
4200
|
+
sort: 5,
|
|
4201
|
+
isQuantityMultiplier: true,
|
|
4202
|
+
},
|
|
4203
|
+
|
|
4204
|
+
conditions: {
|
|
4205
|
+
valid: true,
|
|
4206
|
+
rules: [],
|
|
4207
|
+
},
|
|
4208
|
+
compute: {
|
|
4209
|
+
type: 'percentage',
|
|
4210
|
+
action: 'add',
|
|
4211
|
+
amount: 5,
|
|
4212
|
+
},
|
|
4213
|
+
};
|
|
4214
|
+
|
|
4215
|
+
const order = {
|
|
4216
|
+
parentId: null,
|
|
4217
|
+
isParent: false,
|
|
4218
|
+
subTotal: 21.5,
|
|
4219
|
+
tax: 0,
|
|
4220
|
+
modifiers: [],
|
|
4221
|
+
discount: 0,
|
|
4222
|
+
total: 22.58,
|
|
4223
|
+
description: '',
|
|
4224
|
+
displayId: '',
|
|
4225
|
+
type: '',
|
|
4226
|
+
location: {},
|
|
4227
|
+
status: {
|
|
4228
|
+
detailed: false,
|
|
4229
|
+
},
|
|
4230
|
+
attributes: [],
|
|
4231
|
+
properties: {
|
|
4232
|
+
pieceCount: 2,
|
|
4233
|
+
},
|
|
4234
|
+
fee: 0,
|
|
4235
|
+
user: null,
|
|
4236
|
+
items: [
|
|
4237
|
+
{
|
|
4238
|
+
notes: [],
|
|
4239
|
+
quantity: 1,
|
|
4240
|
+
pieces: 1,
|
|
4241
|
+
price: 8.5,
|
|
4242
|
+
serial: null,
|
|
4243
|
+
description: '',
|
|
4244
|
+
name: 'jacket',
|
|
4245
|
+
location: {},
|
|
4246
|
+
status: {
|
|
4247
|
+
picked: {
|
|
4248
|
+
value: false,
|
|
4249
|
+
date: '',
|
|
4250
|
+
},
|
|
4251
|
+
paid: {
|
|
4252
|
+
value: false,
|
|
4253
|
+
date: '',
|
|
4254
|
+
},
|
|
4255
|
+
tracker: [],
|
|
4256
|
+
},
|
|
4257
|
+
modifiersTotalAmount: 0,
|
|
4258
|
+
total: 8.93,
|
|
4259
|
+
totalPaid: 0,
|
|
4260
|
+
path: ',68a0ea81aa30dd1524162285,68a102e959fd1012e3aaa97e,',
|
|
4261
|
+
sku: '',
|
|
4262
|
+
modifiers: [prePay, ccfee, tax],
|
|
4263
|
+
_id: '696ff00f11527d9252127516',
|
|
4264
|
+
_updatedAt: '2026-01-20T21:05:23.179Z',
|
|
4265
|
+
_createdAt: '2025-08-16T21:18:33.605Z',
|
|
4266
|
+
weight: 0,
|
|
4267
|
+
properties: {
|
|
4268
|
+
priceChanged: true,
|
|
4269
|
+
},
|
|
4270
|
+
hasInventory: true,
|
|
4271
|
+
inventoryType: 'push',
|
|
4272
|
+
serialRequired: null,
|
|
4273
|
+
tags: [],
|
|
4274
|
+
category: null,
|
|
4275
|
+
__typename: 'OrderItem',
|
|
4276
|
+
priceLevels: [
|
|
4277
|
+
{
|
|
4278
|
+
value: 8.5,
|
|
4279
|
+
tags: ['default'],
|
|
4280
|
+
},
|
|
4281
|
+
{
|
|
4282
|
+
value: 6,
|
|
4283
|
+
tags: ['default', 'press only'],
|
|
4284
|
+
},
|
|
4285
|
+
],
|
|
4286
|
+
costLevels: [],
|
|
4287
|
+
itemId: '68a0f5a9a4582a7ef17ea244',
|
|
4288
|
+
menuRuleId: '68a1037d59fd1012e3aaa98c',
|
|
4289
|
+
subTotals: {
|
|
4290
|
+
_included: 0,
|
|
4291
|
+
_xincluded: 0.43,
|
|
4292
|
+
_direct: 0.43,
|
|
4293
|
+
_xdirect: 0,
|
|
4294
|
+
_simple: 8.5,
|
|
4295
|
+
_actual: 8.5,
|
|
4296
|
+
tax: 0.425,
|
|
4297
|
+
discount: 0.005,
|
|
4298
|
+
},
|
|
4299
|
+
},
|
|
4300
|
+
{
|
|
4301
|
+
location: {},
|
|
4302
|
+
status: {
|
|
4303
|
+
picked: {
|
|
4304
|
+
value: false,
|
|
4305
|
+
date: '',
|
|
4306
|
+
},
|
|
4307
|
+
paid: {
|
|
4308
|
+
value: false,
|
|
4309
|
+
date: '',
|
|
4310
|
+
},
|
|
4311
|
+
tracker: [],
|
|
4312
|
+
},
|
|
4313
|
+
name: 'Coat',
|
|
4314
|
+
description: '',
|
|
4315
|
+
pieces: 1,
|
|
4316
|
+
modifiersTotalAmount: 0,
|
|
4317
|
+
total: 13.65,
|
|
4318
|
+
totalPaid: 0,
|
|
4319
|
+
price: 13,
|
|
4320
|
+
quantity: 1,
|
|
4321
|
+
path: ',68a0ea81aa30dd1524162285,68a102e959fd1012e3aaa97b,',
|
|
4322
|
+
notes: [],
|
|
4323
|
+
serial: null,
|
|
4324
|
+
sku: '',
|
|
4325
|
+
modifiers: [prePay, ccfee, tax],
|
|
4326
|
+
_id: '696feff511527d92521274fd',
|
|
4327
|
+
_updatedAt: '2026-01-20T21:05:22.239Z',
|
|
4328
|
+
_createdAt: '2025-08-16T21:19:58.509Z',
|
|
4329
|
+
weight: 0,
|
|
4330
|
+
properties: {},
|
|
4331
|
+
hasInventory: true,
|
|
4332
|
+
inventoryType: 'push',
|
|
4333
|
+
serialRequired: null,
|
|
4334
|
+
tags: [],
|
|
4335
|
+
category: null,
|
|
4336
|
+
__typename: 'OrderItem',
|
|
4337
|
+
priceLevels: [
|
|
4338
|
+
{
|
|
4339
|
+
value: 13,
|
|
4340
|
+
tags: ['default'],
|
|
4341
|
+
},
|
|
4342
|
+
{
|
|
4343
|
+
value: 6,
|
|
4344
|
+
tags: ['police'],
|
|
4345
|
+
},
|
|
4346
|
+
{
|
|
4347
|
+
value: 11,
|
|
4348
|
+
tags: ['default', 'press only'],
|
|
4349
|
+
},
|
|
4350
|
+
{
|
|
4351
|
+
value: 4,
|
|
4352
|
+
tags: ['police', 'press only'],
|
|
4353
|
+
},
|
|
4354
|
+
],
|
|
4355
|
+
costLevels: [],
|
|
4356
|
+
itemId: '68a0f5feaa30dd15241630e1',
|
|
4357
|
+
menuRuleId: '68a1039559fd1012e3aaa98e',
|
|
4358
|
+
subTotals: {
|
|
4359
|
+
_included: 0,
|
|
4360
|
+
_xincluded: 0.65,
|
|
4361
|
+
_direct: 0.65,
|
|
4362
|
+
_xdirect: 0,
|
|
4363
|
+
_simple: 13,
|
|
4364
|
+
_actual: 13,
|
|
4365
|
+
tax: 0.65,
|
|
4366
|
+
},
|
|
4367
|
+
},
|
|
4368
|
+
],
|
|
4369
|
+
notes: [],
|
|
4370
|
+
customer: {
|
|
4371
|
+
_id: '68ab3e9f1a3b4b470c5fd3e4',
|
|
4372
|
+
},
|
|
4373
|
+
|
|
4374
|
+
subTotals: {
|
|
4375
|
+
tax: 1.075,
|
|
4376
|
+
discount: 0.005,
|
|
4377
|
+
},
|
|
4378
|
+
};
|
|
4379
|
+
|
|
4380
|
+
const newOrder = pricingService.order.calculate(order);
|
|
4381
|
+
|
|
4382
|
+
expect(newOrder).toHaveProperty('total', 22.58);
|
|
4383
|
+
expect(newOrder).toHaveProperty('subTotal', 21.5);
|
|
4384
|
+
expect(newOrder.subTotals).toEqual({ tax: 1.08 });
|
|
4385
|
+
});
|
|
4386
|
+
|
|
4387
|
+
test('Should calculate order, patch an item and then calculate that item to confirm the patched difference is still there', () => {
|
|
4388
|
+
const tax5Percent = {
|
|
4389
|
+
_id: '6971272885ebcfa8a24e83cf',
|
|
4390
|
+
attributes: [],
|
|
4391
|
+
modifierId: '68a10008a4582a7ef17eb3ec',
|
|
4392
|
+
_parentId: null,
|
|
4393
|
+
locked: false,
|
|
4394
|
+
name: 'Tax 5%',
|
|
4395
|
+
sku: '',
|
|
4396
|
+
description: '',
|
|
4397
|
+
group: 'Tax',
|
|
4398
|
+
type: 'tax',
|
|
4399
|
+
tags: ['default'],
|
|
4400
|
+
order: 0,
|
|
4401
|
+
included: false,
|
|
4402
|
+
direct: true,
|
|
4403
|
+
hidden: false,
|
|
4404
|
+
print: false,
|
|
4405
|
+
required: true,
|
|
4406
|
+
recommended: false,
|
|
4407
|
+
default: false,
|
|
4408
|
+
code: '',
|
|
4409
|
+
properties: {
|
|
4410
|
+
override: null,
|
|
4411
|
+
sort: 5,
|
|
4412
|
+
isQuantityMultiplier: true,
|
|
4413
|
+
},
|
|
4414
|
+
conditions: {
|
|
4415
|
+
valid: true,
|
|
4416
|
+
rules: [],
|
|
4417
|
+
},
|
|
4418
|
+
compute: {
|
|
4419
|
+
type: 'percentage',
|
|
4420
|
+
action: 'add',
|
|
4421
|
+
amount: 5,
|
|
4422
|
+
},
|
|
4423
|
+
_createdAt: '2025-08-16T22:02:48.698Z',
|
|
4424
|
+
_updatedAt: '2026-01-20T20:19:08.047Z',
|
|
4425
|
+
__typename: 'Modifier',
|
|
4426
|
+
addModifiers: [],
|
|
4427
|
+
delModifiers: [],
|
|
4428
|
+
};
|
|
4429
|
+
const order = {
|
|
4430
|
+
subTotal: 49.5,
|
|
4431
|
+
tax: 0,
|
|
4432
|
+
modifiers: [
|
|
4433
|
+
{
|
|
4434
|
+
_id: '696fe3f0be69c4c8316cf174',
|
|
4435
|
+
attributes: [],
|
|
4436
|
+
modifierId: null,
|
|
4437
|
+
_parentId: null,
|
|
4438
|
+
locked: false,
|
|
4439
|
+
name: 'Modifier 30 days (Orders Ready Fee)',
|
|
4440
|
+
sku: '',
|
|
4441
|
+
description: '',
|
|
4442
|
+
group: 'Fee',
|
|
4443
|
+
type: 'fee',
|
|
4444
|
+
tags: ['default'],
|
|
4445
|
+
order: 0,
|
|
4446
|
+
included: false,
|
|
4447
|
+
direct: true,
|
|
4448
|
+
hidden: false,
|
|
4449
|
+
print: true,
|
|
4450
|
+
required: false,
|
|
4451
|
+
recommended: false,
|
|
4452
|
+
default: false,
|
|
4453
|
+
code: '',
|
|
4454
|
+
properties: {
|
|
4455
|
+
override: null,
|
|
4456
|
+
sort: 4,
|
|
4457
|
+
},
|
|
4458
|
+
_computed: null,
|
|
4459
|
+
conditions: null,
|
|
4460
|
+
compute: {
|
|
4461
|
+
type: 'percentage',
|
|
4462
|
+
action: 'add',
|
|
4463
|
+
amount: 10,
|
|
4464
|
+
},
|
|
4465
|
+
_createdAt: '2026-01-20T20:22:08.072Z',
|
|
4466
|
+
_updatedAt: '2026-01-20T20:22:36.398Z',
|
|
4467
|
+
__typename: 'Modifier',
|
|
4468
|
+
addModifiers: [],
|
|
4469
|
+
delModifiers: [],
|
|
4470
|
+
},
|
|
4471
|
+
],
|
|
4472
|
+
total: 57.18,
|
|
4473
|
+
items: [
|
|
4474
|
+
{
|
|
4475
|
+
name: 'Suit 2pcs',
|
|
4476
|
+
total: 25.41,
|
|
4477
|
+
totalPaid: 0,
|
|
4478
|
+
price: 22,
|
|
4479
|
+
quantity: 1,
|
|
4480
|
+
modifiers: [
|
|
4481
|
+
{
|
|
4482
|
+
name: 'Modifier 30 days (Orders Ready Fee)',
|
|
4483
|
+
sku: '',
|
|
4484
|
+
description: '',
|
|
4485
|
+
group: 'Fee',
|
|
4486
|
+
type: 'fee',
|
|
4487
|
+
attributes: [],
|
|
4488
|
+
color: '',
|
|
4489
|
+
backgroundColor: '',
|
|
4490
|
+
icon: '',
|
|
4491
|
+
url: '',
|
|
4492
|
+
code: '',
|
|
4493
|
+
tags: ['default'],
|
|
4494
|
+
order: 0,
|
|
4495
|
+
included: false,
|
|
4496
|
+
direct: false,
|
|
4497
|
+
hidden: false,
|
|
4498
|
+
required: false,
|
|
4499
|
+
print: true,
|
|
4500
|
+
delModifiers: [],
|
|
4501
|
+
addModifiers: [],
|
|
4502
|
+
conditions: {
|
|
4503
|
+
valid: true,
|
|
4504
|
+
},
|
|
4505
|
+
compute: {
|
|
4506
|
+
type: 'fixed',
|
|
4507
|
+
amount: 2.2,
|
|
4508
|
+
action: 'add',
|
|
4509
|
+
},
|
|
4510
|
+
properties: {
|
|
4511
|
+
override: null,
|
|
4512
|
+
sort: 4,
|
|
4513
|
+
isQuantityMultiplier: false,
|
|
4514
|
+
},
|
|
4515
|
+
_id: '6971275b85ebcfa8a24e83e5',
|
|
4516
|
+
modifierId: '696fe3f0be69c4c8316cf174',
|
|
4517
|
+
__typename: 'Modifier',
|
|
4518
|
+
_parentId: '696fe3f0be69c4c8316cf174',
|
|
4519
|
+
locked: false,
|
|
4520
|
+
recommended: false,
|
|
4521
|
+
default: false,
|
|
4522
|
+
_computed: {
|
|
4523
|
+
amount: 2.2,
|
|
4524
|
+
description: 'Modifier 30 days (Orders Ready Fee) ($2.20)',
|
|
4525
|
+
},
|
|
4526
|
+
_createdAt: '2026-01-20T20:22:08.072Z',
|
|
4527
|
+
_updatedAt: '2026-01-20T20:22:36.398Z',
|
|
4528
|
+
},
|
|
4529
|
+
tax5Percent,
|
|
4530
|
+
],
|
|
4531
|
+
_id: '6971272d85ebcfa8a24e83dc',
|
|
4532
|
+
_updatedAt: '2026-01-21T15:56:58.479Z',
|
|
4533
|
+
_createdAt: '2025-08-16T21:14:15.065Z',
|
|
4534
|
+
weight: 0,
|
|
4535
|
+
properties: {},
|
|
4536
|
+
hasInventory: true,
|
|
4537
|
+
inventoryType: 'push',
|
|
4538
|
+
serialRequired: null,
|
|
4539
|
+
tags: [],
|
|
4540
|
+
category: {
|
|
4541
|
+
_id: '68a0ea8359fd1012e3aaa823',
|
|
4542
|
+
},
|
|
4543
|
+
__typename: 'OrderItem',
|
|
4544
|
+
priceLevels: [
|
|
4545
|
+
{
|
|
4546
|
+
value: 22,
|
|
4547
|
+
tags: ['default'],
|
|
4548
|
+
},
|
|
4549
|
+
{
|
|
4550
|
+
value: 18,
|
|
4551
|
+
tags: ['default', 'press only'],
|
|
4552
|
+
},
|
|
4553
|
+
],
|
|
4554
|
+
costLevels: [],
|
|
4555
|
+
itemId: '68a0f4a7aa30dd1524162cea',
|
|
4556
|
+
categoryId: '68a0ea8359fd1012e3aaa823',
|
|
4557
|
+
menuRuleId: '68a1034959fd1012e3aaa986',
|
|
4558
|
+
subTotals: {
|
|
4559
|
+
_included: 0,
|
|
4560
|
+
_xincluded: 3.41,
|
|
4561
|
+
_direct: 1.21,
|
|
4562
|
+
_xdirect: 2.2,
|
|
4563
|
+
_simple: 22,
|
|
4564
|
+
_actual: 22,
|
|
4565
|
+
fee: 2.2,
|
|
4566
|
+
tax: 1.21,
|
|
4567
|
+
},
|
|
4568
|
+
},
|
|
4569
|
+
{
|
|
4570
|
+
location: {},
|
|
4571
|
+
status: {
|
|
4572
|
+
picked: {
|
|
4573
|
+
value: false,
|
|
4574
|
+
date: '',
|
|
4575
|
+
},
|
|
4576
|
+
paid: {
|
|
4577
|
+
value: false,
|
|
4578
|
+
date: '',
|
|
4579
|
+
},
|
|
4580
|
+
tracker: [],
|
|
4581
|
+
},
|
|
4582
|
+
name: 'Vest',
|
|
4583
|
+
description: '',
|
|
4584
|
+
pieces: 1,
|
|
4585
|
+
modifiersTotalAmount: 0,
|
|
4586
|
+
total: 6.93,
|
|
4587
|
+
totalPaid: 0,
|
|
4588
|
+
price: 6,
|
|
4589
|
+
quantity: 1,
|
|
4590
|
+
path: ',68a0ea81aa30dd1524162285,68a102e959fd1012e3aaa981,',
|
|
4591
|
+
notes: [],
|
|
4592
|
+
serial: 'Test0000005576',
|
|
4593
|
+
sku: '',
|
|
4594
|
+
modifiers: [
|
|
4595
|
+
{
|
|
4596
|
+
name: 'Modifier 30 days (Orders Ready Fee)',
|
|
4597
|
+
sku: '',
|
|
4598
|
+
description: '',
|
|
4599
|
+
group: 'Fee',
|
|
4600
|
+
type: 'fee',
|
|
4601
|
+
attributes: [],
|
|
4602
|
+
color: '',
|
|
4603
|
+
backgroundColor: '',
|
|
4604
|
+
icon: '',
|
|
4605
|
+
url: '',
|
|
4606
|
+
code: '',
|
|
4607
|
+
tags: ['default'],
|
|
4608
|
+
order: 0,
|
|
4609
|
+
included: false,
|
|
4610
|
+
direct: false,
|
|
4611
|
+
hidden: false,
|
|
4612
|
+
required: false,
|
|
4613
|
+
print: true,
|
|
4614
|
+
delModifiers: [],
|
|
4615
|
+
addModifiers: [],
|
|
4616
|
+
conditions: {
|
|
4617
|
+
valid: true,
|
|
4618
|
+
},
|
|
4619
|
+
compute: {
|
|
4620
|
+
type: 'fixed',
|
|
4621
|
+
amount: 0.6,
|
|
4622
|
+
action: 'add',
|
|
4623
|
+
},
|
|
4624
|
+
properties: {
|
|
4625
|
+
override: null,
|
|
4626
|
+
sort: 4,
|
|
4627
|
+
isQuantityMultiplier: false,
|
|
4628
|
+
},
|
|
4629
|
+
_id: '6971275b85ebcfa8a24e83e6',
|
|
4630
|
+
modifierId: '696fe3f0be69c4c8316cf174',
|
|
4631
|
+
__typename: 'Modifier',
|
|
4632
|
+
_parentId: '696fe3f0be69c4c8316cf174',
|
|
4633
|
+
locked: false,
|
|
4634
|
+
recommended: false,
|
|
4635
|
+
default: false,
|
|
4636
|
+
_computed: {
|
|
4637
|
+
amount: 0.6,
|
|
4638
|
+
description: 'Modifier 30 days (Orders Ready Fee) ($0.60)',
|
|
4639
|
+
},
|
|
4640
|
+
_createdAt: '2026-01-20T20:22:08.072Z',
|
|
4641
|
+
_updatedAt: '2026-01-20T20:22:36.398Z',
|
|
4642
|
+
},
|
|
4643
|
+
tax5Percent,
|
|
4644
|
+
],
|
|
4645
|
+
_id: '6971272c85ebcfa8a24e83d7',
|
|
4646
|
+
_updatedAt: '2026-01-21T19:07:53.556Z',
|
|
4647
|
+
_createdAt: '2025-08-16T21:23:40.809Z',
|
|
4648
|
+
weight: 0,
|
|
4649
|
+
properties: {},
|
|
4650
|
+
hasInventory: true,
|
|
4651
|
+
inventoryType: 'push',
|
|
4652
|
+
serialRequired: null,
|
|
4653
|
+
tags: [],
|
|
4654
|
+
category: null,
|
|
4655
|
+
__typename: 'OrderItem',
|
|
4656
|
+
priceLevels: [
|
|
4657
|
+
{
|
|
4658
|
+
value: 6,
|
|
4659
|
+
tags: ['default'],
|
|
4660
|
+
},
|
|
4661
|
+
{
|
|
4662
|
+
value: 5,
|
|
4663
|
+
tags: ['default', 'press only'],
|
|
4664
|
+
},
|
|
4665
|
+
],
|
|
4666
|
+
costLevels: [],
|
|
4667
|
+
itemId: '68a0f6dca4582a7ef17ea70b',
|
|
4668
|
+
menuRuleId: '68a1039f59fd1012e3aaa991',
|
|
4669
|
+
subTotals: {
|
|
4670
|
+
_included: 0,
|
|
4671
|
+
_xincluded: 0.93,
|
|
4672
|
+
_direct: 0.33,
|
|
4673
|
+
_xdirect: 0.6,
|
|
4674
|
+
_simple: 6,
|
|
4675
|
+
_actual: 6,
|
|
4676
|
+
fee: 0.6,
|
|
4677
|
+
tax: 0.33,
|
|
4678
|
+
},
|
|
4679
|
+
},
|
|
4680
|
+
{
|
|
4681
|
+
location: {},
|
|
4682
|
+
status: {
|
|
4683
|
+
picked: {
|
|
4684
|
+
value: false,
|
|
4685
|
+
date: '',
|
|
4686
|
+
},
|
|
4687
|
+
paid: {
|
|
4688
|
+
value: false,
|
|
4689
|
+
date: '',
|
|
4690
|
+
},
|
|
4691
|
+
tracker: [],
|
|
4692
|
+
},
|
|
4693
|
+
name: 'Jacket',
|
|
4694
|
+
description: '',
|
|
4695
|
+
pieces: 1,
|
|
4696
|
+
modifiersTotalAmount: 0,
|
|
4697
|
+
total: 9.82,
|
|
4698
|
+
totalPaid: 0,
|
|
4699
|
+
price: 8.5,
|
|
4700
|
+
quantity: 1,
|
|
4701
|
+
path: ',68a0ea81aa30dd1524162285,68a102e959fd1012e3aaa97e,',
|
|
4702
|
+
notes: [],
|
|
4703
|
+
serial: 'Test0000005575',
|
|
4704
|
+
sku: '',
|
|
4705
|
+
modifiers: [
|
|
4706
|
+
{
|
|
4707
|
+
name: 'Modifier 30 days (Orders Ready Fee)',
|
|
4708
|
+
sku: '',
|
|
4709
|
+
description: '',
|
|
4710
|
+
group: 'Fee',
|
|
4711
|
+
type: 'fee',
|
|
4712
|
+
attributes: [],
|
|
4713
|
+
color: '',
|
|
4714
|
+
backgroundColor: '',
|
|
4715
|
+
icon: '',
|
|
4716
|
+
url: '',
|
|
4717
|
+
code: '',
|
|
4718
|
+
tags: ['default'],
|
|
4719
|
+
order: 0,
|
|
4720
|
+
included: false,
|
|
4721
|
+
direct: false,
|
|
4722
|
+
hidden: false,
|
|
4723
|
+
required: false,
|
|
4724
|
+
print: true,
|
|
4725
|
+
delModifiers: [],
|
|
4726
|
+
addModifiers: [],
|
|
4727
|
+
conditions: {
|
|
4728
|
+
valid: true,
|
|
4729
|
+
},
|
|
4730
|
+
compute: {
|
|
4731
|
+
type: 'fixed',
|
|
4732
|
+
amount: 0.85,
|
|
4733
|
+
action: 'add',
|
|
4734
|
+
},
|
|
4735
|
+
properties: {
|
|
4736
|
+
override: null,
|
|
4737
|
+
sort: 4,
|
|
4738
|
+
isQuantityMultiplier: false,
|
|
4739
|
+
},
|
|
4740
|
+
_id: '6971275b85ebcfa8a24e83e7',
|
|
4741
|
+
modifierId: '696fe3f0be69c4c8316cf174',
|
|
4742
|
+
__typename: 'Modifier',
|
|
4743
|
+
_parentId: '696fe3f0be69c4c8316cf174',
|
|
4744
|
+
locked: false,
|
|
4745
|
+
recommended: false,
|
|
4746
|
+
default: false,
|
|
4747
|
+
_computed: {
|
|
4748
|
+
amount: 0.85,
|
|
4749
|
+
description: 'Modifier 30 days (Orders Ready Fee) ($0.85)',
|
|
4750
|
+
},
|
|
4751
|
+
_createdAt: '2026-01-20T20:22:08.072Z',
|
|
4752
|
+
_updatedAt: '2026-01-20T20:22:36.398Z',
|
|
4753
|
+
},
|
|
4754
|
+
{
|
|
4755
|
+
...tax5Percent,
|
|
4756
|
+
properties: {
|
|
4757
|
+
...tax5Percent.properties,
|
|
4758
|
+
},
|
|
4759
|
+
},
|
|
4760
|
+
],
|
|
4761
|
+
_id: '6971272a85ebcfa8a24e83d2',
|
|
4762
|
+
_updatedAt: '2026-01-21T18:58:30.611Z',
|
|
4763
|
+
_createdAt: '2025-08-16T21:18:33.605Z',
|
|
4764
|
+
weight: 0,
|
|
4765
|
+
properties: {},
|
|
4766
|
+
hasInventory: true,
|
|
4767
|
+
inventoryType: 'push',
|
|
4768
|
+
serialRequired: null,
|
|
4769
|
+
tags: [],
|
|
4770
|
+
category: null,
|
|
4771
|
+
__typename: 'OrderItem',
|
|
4772
|
+
priceLevels: [
|
|
4773
|
+
{
|
|
4774
|
+
value: 8.5,
|
|
4775
|
+
tags: ['default'],
|
|
4776
|
+
},
|
|
4777
|
+
{
|
|
4778
|
+
value: 6,
|
|
4779
|
+
tags: ['default', 'press only'],
|
|
4780
|
+
},
|
|
4781
|
+
],
|
|
4782
|
+
costLevels: [],
|
|
4783
|
+
itemId: '68a0f5a9a4582a7ef17ea244',
|
|
4784
|
+
menuRuleId: '68a1037d59fd1012e3aaa98c',
|
|
4785
|
+
subTotals: {
|
|
4786
|
+
_included: 0,
|
|
4787
|
+
_xincluded: 1.3225,
|
|
4788
|
+
_direct: 0.4725,
|
|
4789
|
+
_xdirect: 0.85,
|
|
4790
|
+
_simple: 8.5,
|
|
4791
|
+
_actual: 8.5,
|
|
4792
|
+
fee: 0.85,
|
|
4793
|
+
tax: 0.4725,
|
|
4794
|
+
},
|
|
4795
|
+
},
|
|
4796
|
+
{
|
|
4797
|
+
location: {},
|
|
4798
|
+
status: {
|
|
4799
|
+
picked: {
|
|
4800
|
+
value: false,
|
|
4801
|
+
date: '',
|
|
4802
|
+
},
|
|
4803
|
+
paid: {
|
|
4804
|
+
value: false,
|
|
4805
|
+
date: '',
|
|
4806
|
+
},
|
|
4807
|
+
tracker: [],
|
|
4808
|
+
},
|
|
4809
|
+
name: 'Coat',
|
|
4810
|
+
description: '',
|
|
4811
|
+
pieces: 1,
|
|
4812
|
+
modifiersTotalAmount: 0,
|
|
4813
|
+
total: 15.02,
|
|
4814
|
+
totalPaid: 0,
|
|
4815
|
+
price: 13,
|
|
4816
|
+
quantity: 1,
|
|
4817
|
+
path: ',68a0ea81aa30dd1524162285,68a102e959fd1012e3aaa97b,',
|
|
4818
|
+
notes: [],
|
|
4819
|
+
serial: 'Test0000005574',
|
|
4820
|
+
sku: '',
|
|
4821
|
+
modifiers: [
|
|
4822
|
+
{
|
|
4823
|
+
name: 'Modifier 30 days (Orders Ready Fee)',
|
|
4824
|
+
sku: '',
|
|
4825
|
+
description: '',
|
|
4826
|
+
group: 'Fee',
|
|
4827
|
+
type: 'fee',
|
|
4828
|
+
attributes: [],
|
|
4829
|
+
color: '',
|
|
4830
|
+
backgroundColor: '',
|
|
4831
|
+
icon: '',
|
|
4832
|
+
url: '',
|
|
4833
|
+
code: '',
|
|
4834
|
+
tags: ['default'],
|
|
4835
|
+
order: 0,
|
|
4836
|
+
included: false,
|
|
4837
|
+
direct: false,
|
|
4838
|
+
hidden: false,
|
|
4839
|
+
required: false,
|
|
4840
|
+
print: true,
|
|
4841
|
+
delModifiers: [],
|
|
4842
|
+
addModifiers: [],
|
|
4843
|
+
conditions: {
|
|
4844
|
+
valid: true,
|
|
4845
|
+
},
|
|
4846
|
+
compute: {
|
|
4847
|
+
type: 'fixed',
|
|
4848
|
+
amount: 1.3,
|
|
4849
|
+
action: 'add',
|
|
4850
|
+
},
|
|
4851
|
+
properties: {
|
|
4852
|
+
override: null,
|
|
4853
|
+
sort: 4,
|
|
4854
|
+
isQuantityMultiplier: false,
|
|
4855
|
+
},
|
|
4856
|
+
_id: '6971275b85ebcfa8a24e83e8',
|
|
4857
|
+
modifierId: '696fe3f0be69c4c8316cf174',
|
|
4858
|
+
__typename: 'Modifier',
|
|
4859
|
+
_parentId: '696fe3f0be69c4c8316cf174',
|
|
4860
|
+
locked: false,
|
|
4861
|
+
recommended: false,
|
|
4862
|
+
default: false,
|
|
4863
|
+
_computed: {
|
|
4864
|
+
amount: 1.3,
|
|
4865
|
+
description: 'Modifier 30 days (Orders Ready Fee) ($1.30)',
|
|
4866
|
+
},
|
|
4867
|
+
_createdAt: '2026-01-20T20:22:08.072Z',
|
|
4868
|
+
_updatedAt: '2026-01-20T20:22:36.398Z',
|
|
4869
|
+
},
|
|
4870
|
+
tax5Percent,
|
|
4871
|
+
],
|
|
4872
|
+
_id: '6971272885ebcfa8a24e83cd',
|
|
4873
|
+
_updatedAt: '2026-01-21T18:58:30.490Z',
|
|
4874
|
+
_createdAt: '2025-08-16T21:19:58.509Z',
|
|
4875
|
+
weight: 0,
|
|
4876
|
+
properties: {},
|
|
4877
|
+
hasInventory: true,
|
|
4878
|
+
inventoryType: 'push',
|
|
4879
|
+
serialRequired: null,
|
|
4880
|
+
tags: [],
|
|
4881
|
+
category: null,
|
|
4882
|
+
__typename: 'OrderItem',
|
|
4883
|
+
priceLevels: [
|
|
4884
|
+
{
|
|
4885
|
+
value: 13,
|
|
4886
|
+
tags: ['default'],
|
|
4887
|
+
},
|
|
4888
|
+
{
|
|
4889
|
+
value: 6,
|
|
4890
|
+
tags: ['police'],
|
|
4891
|
+
},
|
|
4892
|
+
{
|
|
4893
|
+
value: 11,
|
|
4894
|
+
tags: ['default', 'press only'],
|
|
4895
|
+
},
|
|
4896
|
+
{
|
|
4897
|
+
value: 4,
|
|
4898
|
+
tags: ['police', 'press only'],
|
|
4899
|
+
},
|
|
4900
|
+
],
|
|
4901
|
+
costLevels: [],
|
|
4902
|
+
itemId: '68a0f5feaa30dd15241630e1',
|
|
4903
|
+
menuRuleId: '68a1039559fd1012e3aaa98e',
|
|
4904
|
+
subTotals: {
|
|
4905
|
+
_included: 0,
|
|
4906
|
+
_xincluded: 2.015,
|
|
4907
|
+
_direct: 0.715,
|
|
4908
|
+
_xdirect: 1.3,
|
|
4909
|
+
_simple: 13,
|
|
4910
|
+
_actual: 13,
|
|
4911
|
+
fee: 1.3,
|
|
4912
|
+
tax: 0.715,
|
|
4913
|
+
},
|
|
4914
|
+
},
|
|
4915
|
+
],
|
|
4916
|
+
customer: {
|
|
4917
|
+
_id: '68ab3e9f1a3b4b470c5fd3e4',
|
|
4918
|
+
},
|
|
4919
|
+
subTotals: {
|
|
4920
|
+
fee: 4.95,
|
|
4921
|
+
tax: 2.7275,
|
|
4922
|
+
},
|
|
4923
|
+
};
|
|
4924
|
+
|
|
4925
|
+
const newOrder = pricingService.order.calculate(order);
|
|
4926
|
+
|
|
4927
|
+
expect(newOrder).toHaveProperty('total', 57.18);
|
|
4928
|
+
expect(newOrder).toHaveProperty('subTotal', 49.5);
|
|
4929
|
+
expect(newOrder.subTotals).toEqual({ fee: 4.946, tax: 2.7225 });
|
|
4930
|
+
expect(newOrder.items[0].total).toEqual(25.41);
|
|
4931
|
+
expect(newOrder.items[1].total).toEqual(6.93);
|
|
4932
|
+
expect(newOrder.items[2].total).toEqual(9.82);
|
|
4933
|
+
expect(newOrder.items[3].total).toEqual(15.02);
|
|
4934
|
+
|
|
4935
|
+
const itemPatched = pricingService.item.calculate(newOrder.items[2]);
|
|
4936
|
+
expect(itemPatched.total).toEqual(9.82);
|
|
4937
|
+
|
|
4938
|
+
const newOrder2 = pricingService.order.calculate(newOrder);
|
|
4939
|
+
|
|
4940
|
+
expect(newOrder2).toHaveProperty('total', 57.18);
|
|
4941
|
+
expect(newOrder2).toHaveProperty('subTotal', 49.5);
|
|
4942
|
+
expect(newOrder2.subTotals).toEqual({ fee: 4.946, tax: 2.7225 });
|
|
4943
|
+
expect(newOrder2.items[0].total).toEqual(25.41);
|
|
4944
|
+
expect(newOrder2.items[1].total).toEqual(6.93);
|
|
4945
|
+
expect(newOrder2.items[2].total).toEqual(9.82);
|
|
4946
|
+
expect(newOrder2.items[3].total).toEqual(15.02);
|
|
4947
|
+
|
|
4948
|
+
const itemPatched2 = pricingService.item.calculate(newOrder2.items[2]);
|
|
4949
|
+
expect(itemPatched2.total).toEqual(9.82);
|
|
4950
|
+
});
|
|
4072
4951
|
});
|