@darkpos/pricing 1.0.167 → 1.0.168
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.
|
@@ -4969,4 +4969,609 @@ describe('Order actions', () => {
|
|
|
4969
4969
|
const itemPatched2 = pricingService.item.calculate(newOrder2.items[2]);
|
|
4970
4970
|
expect(itemPatched2.total).toEqual(9.82);
|
|
4971
4971
|
});
|
|
4972
|
+
test('CU-86e2jpq5e: Calculate Order with full precision and total 7.11', () => {
|
|
4973
|
+
const order = {
|
|
4974
|
+
parentId: null,
|
|
4975
|
+
isParent: false,
|
|
4976
|
+
subTotal: 5.5,
|
|
4977
|
+
tax: 0,
|
|
4978
|
+
modifiers: [
|
|
4979
|
+
{
|
|
4980
|
+
_id: '698666f3951a06401bd31fdb',
|
|
4981
|
+
attributes: [],
|
|
4982
|
+
modifierId: null,
|
|
4983
|
+
_parentId: null,
|
|
4984
|
+
locked: false,
|
|
4985
|
+
name: '25% Family discount',
|
|
4986
|
+
sku: '',
|
|
4987
|
+
description: '',
|
|
4988
|
+
group: 'Discount',
|
|
4989
|
+
type: 'discount',
|
|
4990
|
+
tags: ['default'],
|
|
4991
|
+
order: 0,
|
|
4992
|
+
included: false,
|
|
4993
|
+
direct: true,
|
|
4994
|
+
hidden: false,
|
|
4995
|
+
print: true,
|
|
4996
|
+
required: false,
|
|
4997
|
+
recommended: false,
|
|
4998
|
+
default: false,
|
|
4999
|
+
code: '',
|
|
5000
|
+
properties: {
|
|
5001
|
+
override: null,
|
|
5002
|
+
sort: 1,
|
|
5003
|
+
},
|
|
5004
|
+
_computed: null,
|
|
5005
|
+
conditions: null,
|
|
5006
|
+
compute: {
|
|
5007
|
+
type: 'percentage',
|
|
5008
|
+
action: 'subtract',
|
|
5009
|
+
amount: 25,
|
|
5010
|
+
},
|
|
5011
|
+
_createdAt: '2026-02-06T22:10:59.265Z',
|
|
5012
|
+
_updatedAt: '2026-05-28T16:23:04.792Z',
|
|
5013
|
+
__typename: 'Modifier',
|
|
5014
|
+
addModifiers: [],
|
|
5015
|
+
delModifiers: [],
|
|
5016
|
+
},
|
|
5017
|
+
],
|
|
5018
|
+
discount: 0,
|
|
5019
|
+
total: 8.36,
|
|
5020
|
+
description: '',
|
|
5021
|
+
displayId: '',
|
|
5022
|
+
type: '',
|
|
5023
|
+
location: {},
|
|
5024
|
+
status: {
|
|
5025
|
+
detailed: false,
|
|
5026
|
+
picked: false,
|
|
5027
|
+
paid: false,
|
|
5028
|
+
order: 'open',
|
|
5029
|
+
},
|
|
5030
|
+
attributes: [],
|
|
5031
|
+
properties: {
|
|
5032
|
+
pieceCount: 0,
|
|
5033
|
+
},
|
|
5034
|
+
fee: 0,
|
|
5035
|
+
user: null,
|
|
5036
|
+
items: [
|
|
5037
|
+
{
|
|
5038
|
+
location: {},
|
|
5039
|
+
status: {
|
|
5040
|
+
picked: {
|
|
5041
|
+
value: false,
|
|
5042
|
+
date: '',
|
|
5043
|
+
},
|
|
5044
|
+
paid: {
|
|
5045
|
+
value: false,
|
|
5046
|
+
date: '',
|
|
5047
|
+
},
|
|
5048
|
+
tracker: [],
|
|
5049
|
+
},
|
|
5050
|
+
name: 'Blouse',
|
|
5051
|
+
description: '',
|
|
5052
|
+
pieces: 0,
|
|
5053
|
+
modifiersTotalAmount: 0,
|
|
5054
|
+
total: 8.36,
|
|
5055
|
+
totalPaid: 0,
|
|
5056
|
+
price: 4.5,
|
|
5057
|
+
quantity: 1,
|
|
5058
|
+
path: ',68a0ea81aa30dd1524162285,68a102e959fd1012e3aaa97a,',
|
|
5059
|
+
notes: [],
|
|
5060
|
+
serial: null,
|
|
5061
|
+
sku: '',
|
|
5062
|
+
modifiers: [
|
|
5063
|
+
{
|
|
5064
|
+
_id: '6a6b8f98fae18a2551677e86',
|
|
5065
|
+
attributes: [],
|
|
5066
|
+
modifierId: '68a4f71a7d9879299ccd2d53',
|
|
5067
|
+
_parentId: null,
|
|
5068
|
+
locked: false,
|
|
5069
|
+
name: 'CC Fee',
|
|
5070
|
+
sku: '',
|
|
5071
|
+
description: '',
|
|
5072
|
+
group: 'Fee',
|
|
5073
|
+
type: 'fee',
|
|
5074
|
+
tags: ['default'],
|
|
5075
|
+
order: 0,
|
|
5076
|
+
included: false,
|
|
5077
|
+
direct: true,
|
|
5078
|
+
hidden: false,
|
|
5079
|
+
print: true,
|
|
5080
|
+
required: true,
|
|
5081
|
+
recommended: false,
|
|
5082
|
+
default: false,
|
|
5083
|
+
code: '',
|
|
5084
|
+
properties: {
|
|
5085
|
+
override: null,
|
|
5086
|
+
sort: 6,
|
|
5087
|
+
isQuantityMultiplier: false,
|
|
5088
|
+
},
|
|
5089
|
+
_computed: {
|
|
5090
|
+
amount: 0,
|
|
5091
|
+
description: 'CC Fee',
|
|
5092
|
+
},
|
|
5093
|
+
conditions: {
|
|
5094
|
+
valid: false,
|
|
5095
|
+
rules: [
|
|
5096
|
+
{
|
|
5097
|
+
key: 'paymentTypes',
|
|
5098
|
+
value: ['credit-card-manual'],
|
|
5099
|
+
operand: '$in',
|
|
5100
|
+
},
|
|
5101
|
+
],
|
|
5102
|
+
},
|
|
5103
|
+
compute: {
|
|
5104
|
+
type: 'percentage',
|
|
5105
|
+
action: 'add',
|
|
5106
|
+
amount: 10,
|
|
5107
|
+
},
|
|
5108
|
+
_createdAt: '2025-08-19T22:13:46.535Z',
|
|
5109
|
+
_updatedAt: '2026-03-24T20:57:17.834Z',
|
|
5110
|
+
__typename: 'Modifier',
|
|
5111
|
+
addModifiers: [],
|
|
5112
|
+
delModifiers: [],
|
|
5113
|
+
},
|
|
5114
|
+
{
|
|
5115
|
+
_id: '6a6b8fa2fae18a2551677e88',
|
|
5116
|
+
attributes: [],
|
|
5117
|
+
modifierId: '68a5ed97cca35ebbfd70a95c',
|
|
5118
|
+
_parentId: null,
|
|
5119
|
+
locked: false,
|
|
5120
|
+
name: 'Linen',
|
|
5121
|
+
sku: '',
|
|
5122
|
+
description: '',
|
|
5123
|
+
group: 'Material',
|
|
5124
|
+
type: '',
|
|
5125
|
+
tags: ['default'],
|
|
5126
|
+
order: 0,
|
|
5127
|
+
included: true,
|
|
5128
|
+
direct: true,
|
|
5129
|
+
hidden: false,
|
|
5130
|
+
print: true,
|
|
5131
|
+
required: false,
|
|
5132
|
+
recommended: false,
|
|
5133
|
+
default: false,
|
|
5134
|
+
code: '',
|
|
5135
|
+
properties: {
|
|
5136
|
+
override: null,
|
|
5137
|
+
sort: 1,
|
|
5138
|
+
isQuantityMultiplier: true,
|
|
5139
|
+
},
|
|
5140
|
+
_computed: {
|
|
5141
|
+
amount: 1,
|
|
5142
|
+
description: 'Linen ($1.00)',
|
|
5143
|
+
},
|
|
5144
|
+
conditions: {
|
|
5145
|
+
valid: true,
|
|
5146
|
+
},
|
|
5147
|
+
compute: {
|
|
5148
|
+
type: 'fixed',
|
|
5149
|
+
action: 'add',
|
|
5150
|
+
amount: 1,
|
|
5151
|
+
},
|
|
5152
|
+
_createdAt: '2025-08-20T15:45:27.711Z',
|
|
5153
|
+
_updatedAt: '2026-05-13T21:00:28.223Z',
|
|
5154
|
+
__typename: 'Modifier',
|
|
5155
|
+
addModifiers: [],
|
|
5156
|
+
delModifiers: [],
|
|
5157
|
+
},
|
|
5158
|
+
{
|
|
5159
|
+
_id: '6a6b8fa3fae18a2551677e89',
|
|
5160
|
+
attributes: [],
|
|
5161
|
+
modifierId: '68a5ed7acca35ebbfd70a6df',
|
|
5162
|
+
_parentId: null,
|
|
5163
|
+
locked: false,
|
|
5164
|
+
name: 'Silk',
|
|
5165
|
+
sku: '',
|
|
5166
|
+
description: '',
|
|
5167
|
+
group: 'Material',
|
|
5168
|
+
type: '',
|
|
5169
|
+
tags: ['default'],
|
|
5170
|
+
order: 0,
|
|
5171
|
+
included: false,
|
|
5172
|
+
direct: true,
|
|
5173
|
+
hidden: false,
|
|
5174
|
+
print: true,
|
|
5175
|
+
required: false,
|
|
5176
|
+
recommended: false,
|
|
5177
|
+
default: false,
|
|
5178
|
+
code: '',
|
|
5179
|
+
properties: {
|
|
5180
|
+
override: null,
|
|
5181
|
+
sort: 1,
|
|
5182
|
+
isQuantityMultiplier: true,
|
|
5183
|
+
},
|
|
5184
|
+
_computed: {
|
|
5185
|
+
amount: 2,
|
|
5186
|
+
description: 'Silk ($2.00)',
|
|
5187
|
+
},
|
|
5188
|
+
conditions: {
|
|
5189
|
+
valid: true,
|
|
5190
|
+
},
|
|
5191
|
+
compute: {
|
|
5192
|
+
type: 'fixed',
|
|
5193
|
+
action: 'add',
|
|
5194
|
+
amount: 2,
|
|
5195
|
+
},
|
|
5196
|
+
_createdAt: '2025-08-20T15:44:58.470Z',
|
|
5197
|
+
_updatedAt: '2025-08-20T15:44:58.470Z',
|
|
5198
|
+
__typename: 'Modifier',
|
|
5199
|
+
addModifiers: [],
|
|
5200
|
+
delModifiers: [],
|
|
5201
|
+
},
|
|
5202
|
+
{
|
|
5203
|
+
_id: '6a6b8f98fae18a2551677e85',
|
|
5204
|
+
attributes: [],
|
|
5205
|
+
modifierId: '68a10008a4582a7ef17eb3ec',
|
|
5206
|
+
_parentId: null,
|
|
5207
|
+
locked: false,
|
|
5208
|
+
name: 'Tax 5%',
|
|
5209
|
+
sku: '',
|
|
5210
|
+
description: '',
|
|
5211
|
+
group: 'Tax',
|
|
5212
|
+
type: 'tax',
|
|
5213
|
+
tags: ['default'],
|
|
5214
|
+
order: 0,
|
|
5215
|
+
included: false,
|
|
5216
|
+
direct: false,
|
|
5217
|
+
hidden: false,
|
|
5218
|
+
print: true,
|
|
5219
|
+
required: true,
|
|
5220
|
+
recommended: false,
|
|
5221
|
+
default: false,
|
|
5222
|
+
code: '',
|
|
5223
|
+
properties: {
|
|
5224
|
+
override: null,
|
|
5225
|
+
sort: 5,
|
|
5226
|
+
isQuantityMultiplier: false,
|
|
5227
|
+
extractCalculatedValue: false,
|
|
5228
|
+
},
|
|
5229
|
+
_computed: {
|
|
5230
|
+
amount: 0.8625,
|
|
5231
|
+
description: 'Tax 5% ($0.86)',
|
|
5232
|
+
},
|
|
5233
|
+
conditions: {
|
|
5234
|
+
valid: true,
|
|
5235
|
+
},
|
|
5236
|
+
compute: {
|
|
5237
|
+
type: 'percentage',
|
|
5238
|
+
action: 'add',
|
|
5239
|
+
amount: 11.5,
|
|
5240
|
+
},
|
|
5241
|
+
_createdAt: '2025-08-16T22:02:48.698Z',
|
|
5242
|
+
_updatedAt: '2026-05-13T21:04:53.985Z',
|
|
5243
|
+
__typename: 'Modifier',
|
|
5244
|
+
addModifiers: [],
|
|
5245
|
+
delModifiers: [],
|
|
5246
|
+
},
|
|
5247
|
+
],
|
|
5248
|
+
_id: '6a6b8f98fae18a2551677e84',
|
|
5249
|
+
_updatedAt: '2026-05-13T21:38:14.962Z',
|
|
5250
|
+
_createdAt: '2025-08-16T21:48:12.777Z',
|
|
5251
|
+
weight: 0,
|
|
5252
|
+
properties: {},
|
|
5253
|
+
cost: 0,
|
|
5254
|
+
hasInventory: true,
|
|
5255
|
+
inStock: true,
|
|
5256
|
+
enforceStock: null,
|
|
5257
|
+
inventoryType: 'push',
|
|
5258
|
+
serialRequired: null,
|
|
5259
|
+
autoSerial: false,
|
|
5260
|
+
tags: ['default', 'police'],
|
|
5261
|
+
category: {
|
|
5262
|
+
_id: '68a0ebc2a4582a7ef17e9598',
|
|
5263
|
+
},
|
|
5264
|
+
__typename: 'OrderItem',
|
|
5265
|
+
priceLevels: [
|
|
5266
|
+
{
|
|
5267
|
+
value: 4.5,
|
|
5268
|
+
tags: ['default'],
|
|
5269
|
+
},
|
|
5270
|
+
{
|
|
5271
|
+
value: 3.5,
|
|
5272
|
+
tags: ['police'],
|
|
5273
|
+
},
|
|
5274
|
+
{
|
|
5275
|
+
value: 11.5,
|
|
5276
|
+
tags: ['default', 'press only'],
|
|
5277
|
+
},
|
|
5278
|
+
{
|
|
5279
|
+
value: 2.5,
|
|
5280
|
+
tags: ['police', 'press only'],
|
|
5281
|
+
},
|
|
5282
|
+
],
|
|
5283
|
+
costLevels: [],
|
|
5284
|
+
itemId: '68a0fc9caa30dd1524163766',
|
|
5285
|
+
categoryId: '68a0ebc2a4582a7ef17e9598',
|
|
5286
|
+
menuRuleId: '68a103ad59fd1012e3aaa992',
|
|
5287
|
+
subTotals: {
|
|
5288
|
+
_included: 1,
|
|
5289
|
+
_xincluded: 2.8625,
|
|
5290
|
+
_direct: 3,
|
|
5291
|
+
_xdirect: 0.8625,
|
|
5292
|
+
_simple: 4.5,
|
|
5293
|
+
_actual: 5.5,
|
|
5294
|
+
'': 2,
|
|
5295
|
+
tax: 0.8625,
|
|
5296
|
+
},
|
|
5297
|
+
picked: {
|
|
5298
|
+
value: false,
|
|
5299
|
+
date: '',
|
|
5300
|
+
},
|
|
5301
|
+
paid: {
|
|
5302
|
+
value: false,
|
|
5303
|
+
date: '',
|
|
5304
|
+
},
|
|
5305
|
+
tracker: [],
|
|
5306
|
+
},
|
|
5307
|
+
],
|
|
5308
|
+
customer: {
|
|
5309
|
+
_id: '68a89c3b0b356e7d28850c0a',
|
|
5310
|
+
username: 'wallydc@mailinator.com',
|
|
5311
|
+
firstName: 'Wally',
|
|
5312
|
+
lastName: ' West',
|
|
5313
|
+
description: null,
|
|
5314
|
+
attributes: [],
|
|
5315
|
+
properties: {
|
|
5316
|
+
company: 'Young Justice DC',
|
|
5317
|
+
charge: {
|
|
5318
|
+
walletCard: null,
|
|
5319
|
+
},
|
|
5320
|
+
billing: {
|
|
5321
|
+
cycle: null,
|
|
5322
|
+
limit: '0',
|
|
5323
|
+
},
|
|
5324
|
+
loyalty: {
|
|
5325
|
+
config: {
|
|
5326
|
+
points: 0,
|
|
5327
|
+
},
|
|
5328
|
+
},
|
|
5329
|
+
events: [],
|
|
5330
|
+
relationships: [
|
|
5331
|
+
{
|
|
5332
|
+
type: 'Parent',
|
|
5333
|
+
customerId: '68a89c187d9879299cd2666b',
|
|
5334
|
+
firstName: 'Barry',
|
|
5335
|
+
lastName: 'Allen',
|
|
5336
|
+
email: 'bflash@mailinator.com',
|
|
5337
|
+
phone: '',
|
|
5338
|
+
},
|
|
5339
|
+
],
|
|
5340
|
+
specialnstructions: '',
|
|
5341
|
+
},
|
|
5342
|
+
tags: ['default'],
|
|
5343
|
+
status: null,
|
|
5344
|
+
parent: null,
|
|
5345
|
+
parentId: null,
|
|
5346
|
+
loyalty: null,
|
|
5347
|
+
stats: {
|
|
5348
|
+
lastVisit: '2026-07-30T17:05:22.523Z',
|
|
5349
|
+
lastPayment: '2026-06-16T17:36:34.480Z',
|
|
5350
|
+
totalVisits: 16,
|
|
5351
|
+
totalSales: 402.39,
|
|
5352
|
+
salesRank: 12,
|
|
5353
|
+
totalPoints: 0,
|
|
5354
|
+
balance: 964.74,
|
|
5355
|
+
},
|
|
5356
|
+
modifiers: [
|
|
5357
|
+
{
|
|
5358
|
+
_id: '69e7ceb04e7c1afd24dff1b5',
|
|
5359
|
+
modifierId: null,
|
|
5360
|
+
_parentId: null,
|
|
5361
|
+
locked: false,
|
|
5362
|
+
name: 'Subscription ( 5 Pants )_Pants',
|
|
5363
|
+
sku: null,
|
|
5364
|
+
group: null,
|
|
5365
|
+
type: null,
|
|
5366
|
+
attributes: ['subscription'],
|
|
5367
|
+
cost: 0,
|
|
5368
|
+
tags: [],
|
|
5369
|
+
order: null,
|
|
5370
|
+
included: false,
|
|
5371
|
+
direct: true,
|
|
5372
|
+
hidden: false,
|
|
5373
|
+
required: false,
|
|
5374
|
+
recommended: false,
|
|
5375
|
+
default: false,
|
|
5376
|
+
code: null,
|
|
5377
|
+
conditions: null,
|
|
5378
|
+
compute: null,
|
|
5379
|
+
_computed: null,
|
|
5380
|
+
_hidden: false,
|
|
5381
|
+
properties: {
|
|
5382
|
+
subscription: {
|
|
5383
|
+
subscriptionId: '69e7ceb04e7c1afd24dff16a',
|
|
5384
|
+
dateLimit: {
|
|
5385
|
+
from: '2026-04-21T19:23:28.555Z',
|
|
5386
|
+
to: '1970-01-01T00:00:00.000Z',
|
|
5387
|
+
},
|
|
5388
|
+
item: {
|
|
5389
|
+
id: '69e7cea515b672a5ff3fd124',
|
|
5390
|
+
itemId: '68a0f4eda4582a7ef17ea048',
|
|
5391
|
+
name: 'Pants',
|
|
5392
|
+
serial: null,
|
|
5393
|
+
limit: 5,
|
|
5394
|
+
usesLimit: 5,
|
|
5395
|
+
uses: 0,
|
|
5396
|
+
renewalType: 'none',
|
|
5397
|
+
},
|
|
5398
|
+
},
|
|
5399
|
+
},
|
|
5400
|
+
},
|
|
5401
|
+
{
|
|
5402
|
+
_id: '69f4bc96b310cad1679dae99',
|
|
5403
|
+
modifierId: null,
|
|
5404
|
+
_parentId: null,
|
|
5405
|
+
locked: false,
|
|
5406
|
+
name: 'Subscription ( 5 Pants + 5 Shorts + 5 Pants + 5 Shorts )_Pants',
|
|
5407
|
+
sku: null,
|
|
5408
|
+
group: null,
|
|
5409
|
+
type: null,
|
|
5410
|
+
attributes: ['subscription'],
|
|
5411
|
+
cost: 0,
|
|
5412
|
+
tags: [],
|
|
5413
|
+
order: null,
|
|
5414
|
+
included: false,
|
|
5415
|
+
direct: true,
|
|
5416
|
+
hidden: false,
|
|
5417
|
+
required: false,
|
|
5418
|
+
recommended: false,
|
|
5419
|
+
default: false,
|
|
5420
|
+
code: null,
|
|
5421
|
+
conditions: null,
|
|
5422
|
+
compute: null,
|
|
5423
|
+
_computed: null,
|
|
5424
|
+
_hidden: false,
|
|
5425
|
+
properties: {
|
|
5426
|
+
subscription: {
|
|
5427
|
+
subscriptionId: '69f4bc95b310cad1679dadc0',
|
|
5428
|
+
dateLimit: {
|
|
5429
|
+
from: '2026-05-01T14:45:41.855Z',
|
|
5430
|
+
to: '1970-01-01T00:00:00.000Z',
|
|
5431
|
+
},
|
|
5432
|
+
item: {
|
|
5433
|
+
id: '69f4bc94f38c6e001cc8bb98',
|
|
5434
|
+
itemId: '68a0f4eda4582a7ef17ea048',
|
|
5435
|
+
name: 'Pants',
|
|
5436
|
+
serial: null,
|
|
5437
|
+
limit: 10,
|
|
5438
|
+
usesLimit: 10,
|
|
5439
|
+
uses: 0,
|
|
5440
|
+
renewalType: 'none',
|
|
5441
|
+
},
|
|
5442
|
+
},
|
|
5443
|
+
},
|
|
5444
|
+
},
|
|
5445
|
+
{
|
|
5446
|
+
_id: '69f4bc96b310cad1679dae9a',
|
|
5447
|
+
modifierId: null,
|
|
5448
|
+
_parentId: null,
|
|
5449
|
+
locked: false,
|
|
5450
|
+
name: 'Subscription ( 5 Pants + 5 Shorts + 5 Pants + 5 Shorts )_Shorts',
|
|
5451
|
+
sku: null,
|
|
5452
|
+
group: null,
|
|
5453
|
+
type: null,
|
|
5454
|
+
attributes: ['subscription'],
|
|
5455
|
+
cost: 0,
|
|
5456
|
+
tags: [],
|
|
5457
|
+
order: null,
|
|
5458
|
+
included: false,
|
|
5459
|
+
direct: true,
|
|
5460
|
+
hidden: false,
|
|
5461
|
+
required: false,
|
|
5462
|
+
recommended: false,
|
|
5463
|
+
default: false,
|
|
5464
|
+
code: null,
|
|
5465
|
+
conditions: null,
|
|
5466
|
+
compute: null,
|
|
5467
|
+
_computed: null,
|
|
5468
|
+
_hidden: false,
|
|
5469
|
+
properties: {
|
|
5470
|
+
subscription: {
|
|
5471
|
+
subscriptionId: '69f4bc95b310cad1679dadc0',
|
|
5472
|
+
dateLimit: {
|
|
5473
|
+
from: '2026-05-01T14:45:41.855Z',
|
|
5474
|
+
to: '1970-01-01T00:00:00.000Z',
|
|
5475
|
+
},
|
|
5476
|
+
item: {
|
|
5477
|
+
id: '69f4bc94f38c6e001cc8bb96',
|
|
5478
|
+
itemId: '68a0f509aa30dd1524162e51',
|
|
5479
|
+
name: 'Shorts',
|
|
5480
|
+
serial: null,
|
|
5481
|
+
limit: 10,
|
|
5482
|
+
usesLimit: 10,
|
|
5483
|
+
uses: 0,
|
|
5484
|
+
renewalType: 'none',
|
|
5485
|
+
},
|
|
5486
|
+
},
|
|
5487
|
+
},
|
|
5488
|
+
},
|
|
5489
|
+
],
|
|
5490
|
+
addresses: [
|
|
5491
|
+
{
|
|
5492
|
+
address1: '5672 Minute Man Ct, Orlando, FL 32821, USA',
|
|
5493
|
+
address2: '',
|
|
5494
|
+
city: 'Orlando',
|
|
5495
|
+
state: 'Florida',
|
|
5496
|
+
zip: '32821',
|
|
5497
|
+
country: null,
|
|
5498
|
+
primary: true,
|
|
5499
|
+
type: 'Home',
|
|
5500
|
+
description: null,
|
|
5501
|
+
location: {
|
|
5502
|
+
lat: 28.417331,
|
|
5503
|
+
lng: -81.451517,
|
|
5504
|
+
},
|
|
5505
|
+
autoAssignDeliveryRoute: false,
|
|
5506
|
+
},
|
|
5507
|
+
],
|
|
5508
|
+
contacts: [
|
|
5509
|
+
{
|
|
5510
|
+
value: 'waly@darkpos.com',
|
|
5511
|
+
description: '',
|
|
5512
|
+
type: 'email',
|
|
5513
|
+
tags: ['corporate'],
|
|
5514
|
+
messageTypes: [],
|
|
5515
|
+
primary: true,
|
|
5516
|
+
notification: true,
|
|
5517
|
+
config: null,
|
|
5518
|
+
verified: false,
|
|
5519
|
+
lastInboundMessage: null,
|
|
5520
|
+
},
|
|
5521
|
+
],
|
|
5522
|
+
notes: [
|
|
5523
|
+
{
|
|
5524
|
+
_id: '6a626075bfa637b6aed5152b',
|
|
5525
|
+
attributes: ['screen', 'print'],
|
|
5526
|
+
date: '2026-07-23T18:42:21.325Z',
|
|
5527
|
+
message: 'PANTS NEED CREASE',
|
|
5528
|
+
name: null,
|
|
5529
|
+
type: '68a49f095aa2a598d48f46af',
|
|
5530
|
+
url: null,
|
|
5531
|
+
file: null,
|
|
5532
|
+
user: null,
|
|
5533
|
+
},
|
|
5534
|
+
],
|
|
5535
|
+
_accountId: '68a0b1b7aa30dd1524152178',
|
|
5536
|
+
_storeId: '68a0b1b7f53773001282b971',
|
|
5537
|
+
_isDeleted: false,
|
|
5538
|
+
_deletedAt: null,
|
|
5539
|
+
_updatedAt: '2026-07-30T17:05:22.460Z',
|
|
5540
|
+
_createdAt: '2025-08-22T16:35:07.477Z',
|
|
5541
|
+
isEmbedded: true,
|
|
5542
|
+
},
|
|
5543
|
+
start: {
|
|
5544
|
+
location: {
|
|
5545
|
+
locationType: 'delivery',
|
|
5546
|
+
deliveryId: '69e90822d309524f80e76f71',
|
|
5547
|
+
name: "Ale's Route",
|
|
5548
|
+
},
|
|
5549
|
+
requestDate: '2026-07-30T17:44:16.876Z',
|
|
5550
|
+
},
|
|
5551
|
+
end: {
|
|
5552
|
+
location: {
|
|
5553
|
+
locationType: 'delivery',
|
|
5554
|
+
deliveryId: '69e90822d309524f80e76f71',
|
|
5555
|
+
name: "Ale's Route",
|
|
5556
|
+
},
|
|
5557
|
+
requestDate: '2026-08-03T21:00:00Z',
|
|
5558
|
+
},
|
|
5559
|
+
_storeId: '',
|
|
5560
|
+
__typename: 'Order',
|
|
5561
|
+
subTotals: {
|
|
5562
|
+
'': 2,
|
|
5563
|
+
tax: 0.8625,
|
|
5564
|
+
},
|
|
5565
|
+
};
|
|
5566
|
+
|
|
5567
|
+
const newOrder = pricingService.order.calculate(order);
|
|
5568
|
+
|
|
5569
|
+
expect(newOrder).toHaveProperty('total', 7.11);
|
|
5570
|
+
expect(newOrder.items[0].total).toEqual(7.11);
|
|
5571
|
+
expect(newOrder).toHaveProperty('subTotals', {
|
|
5572
|
+
'': 2,
|
|
5573
|
+
discount: -1.123125,
|
|
5574
|
+
tax: 0.733125,
|
|
5575
|
+
});
|
|
5576
|
+
});
|
|
4972
5577
|
});
|
|
@@ -6,8 +6,13 @@ module.exports = ({ utils, actions }) => {
|
|
|
6
6
|
const subTotals = {};
|
|
7
7
|
let subTotal = 0;
|
|
8
8
|
let total = 0;
|
|
9
|
+
let subTotalIncluded = 0;
|
|
9
10
|
|
|
10
11
|
for (const item of items) {
|
|
12
|
+
subTotalIncluded = math.add(
|
|
13
|
+
subTotalIncluded,
|
|
14
|
+
actions.getSubtotalIncluded(item)
|
|
15
|
+
);
|
|
11
16
|
subTotal = math.add(subTotal, actions.getSubtotal(item));
|
|
12
17
|
const keys = Object.keys(item.subTotals).filter(
|
|
13
18
|
key => !key.includes('_')
|
|
@@ -19,6 +24,7 @@ module.exports = ({ utils, actions }) => {
|
|
|
19
24
|
}
|
|
20
25
|
|
|
21
26
|
return {
|
|
27
|
+
subTotalIncluded,
|
|
22
28
|
subTotals,
|
|
23
29
|
subTotal,
|
|
24
30
|
total,
|
|
@@ -1,20 +1,22 @@
|
|
|
1
|
-
module.exports = ({ utils }) =>
|
|
1
|
+
module.exports = ({ utils, actions }) =>
|
|
2
2
|
function getTotalsDifference({ items }) {
|
|
3
|
-
const { total,
|
|
4
|
-
(
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
acc.subTotalsTotal,
|
|
8
|
-
utils.math.add(item.subTotals._actual, item.subTotals._xincluded)
|
|
9
|
-
),
|
|
10
|
-
}),
|
|
11
|
-
{ total: 0, subTotalsTotal: 0 }
|
|
12
|
-
);
|
|
13
|
-
const difference = utils.math.sub(subTotalsTotal, total);
|
|
3
|
+
const { total, subTotals, subTotal, subTotalIncluded } =
|
|
4
|
+
actions.getItemsTotals(items);
|
|
5
|
+
|
|
6
|
+
const difference = utils.math.sub(subTotalIncluded, total);
|
|
14
7
|
|
|
15
8
|
if (difference < -0.005) return -0.004;
|
|
16
9
|
if (difference === -0.005) return 0.005;
|
|
17
10
|
if (difference > 0.005) return 0.004;
|
|
18
11
|
if (difference === 0.005) return -0.005;
|
|
12
|
+
|
|
13
|
+
const roundedSubTotalsTotal = Object.values(subTotals).reduce(
|
|
14
|
+
(acc, amount) => utils.math.add(acc, utils.math.toDecimalPlaces(amount)),
|
|
15
|
+
utils.math.toDecimalPlaces(subTotal)
|
|
16
|
+
);
|
|
17
|
+
|
|
18
|
+
if (roundedSubTotalsTotal !== total)
|
|
19
|
+
return utils.math.sub(total, subTotalIncluded);
|
|
20
|
+
|
|
19
21
|
return 0;
|
|
20
22
|
};
|
package/lib/item/index.js
CHANGED
|
@@ -85,6 +85,7 @@ const applyPayment = require('./applyPayment');
|
|
|
85
85
|
const getBalanceForPaymentModifier = require('./getBalanceForPaymentModifier');
|
|
86
86
|
const isOverpaid = require('./isOverpaid');
|
|
87
87
|
const capOverPaidItem = require('./capOverPaidItem');
|
|
88
|
+
const getSubtotalIncluded = require('./getSubtotalIncluded');
|
|
88
89
|
|
|
89
90
|
const itemActions = (deps = {}) => {
|
|
90
91
|
const actions = {};
|
|
@@ -183,6 +184,7 @@ const itemActions = (deps = {}) => {
|
|
|
183
184
|
getBalanceForPaymentModifier: getBalanceForPaymentModifier(innerDeps),
|
|
184
185
|
isOverpaid: isOverpaid(innerDeps),
|
|
185
186
|
capOverPaidItem: capOverPaidItem(innerDeps),
|
|
187
|
+
getSubtotalIncluded: getSubtotalIncluded(innerDeps),
|
|
186
188
|
});
|
|
187
189
|
|
|
188
190
|
Object.keys(freezedActions).forEach(actionName => {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@darkpos/pricing",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.168",
|
|
4
4
|
"description": "Pricing calculator",
|
|
5
5
|
"author": "Dark POS",
|
|
6
6
|
"license": "ISC",
|
|
@@ -54,5 +54,5 @@
|
|
|
54
54
|
"supertest": "^6.2.3",
|
|
55
55
|
"supervisor": "^0.12.0"
|
|
56
56
|
},
|
|
57
|
-
"gitHead": "
|
|
57
|
+
"gitHead": "1bc1edb850f77832fa01bbe81a56f91f48ab1177"
|
|
58
58
|
}
|