@pmcretail/mapper-library 0.0.10 → 0.0.12
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/bundles/pmcretail-mapper-library.umd.js +58 -82
- package/bundles/pmcretail-mapper-library.umd.js.map +1 -1
- package/bundles/pmcretail-mapper-library.umd.min.js +1 -1
- package/bundles/pmcretail-mapper-library.umd.min.js.map +1 -1
- package/esm2015/lib/RJ-mapper.class.js +55 -70
- package/esm5/lib/RJ-mapper.class.js +59 -83
- package/fesm2015/pmcretail-mapper-library.js +54 -69
- package/fesm2015/pmcretail-mapper-library.js.map +1 -1
- package/fesm5/pmcretail-mapper-library.js +58 -82
- package/fesm5/pmcretail-mapper-library.js.map +1 -1
- package/lib/RJ-mapper.class.d.ts +4 -7
- package/package.json +1 -1
- package/pmcretail-mapper-library.metadata.json +1 -1
|
@@ -3516,8 +3516,8 @@ class RJMapperBuilderClass {
|
|
|
3516
3516
|
}
|
|
3517
3517
|
this.initilizeItemCount();
|
|
3518
3518
|
this.setLineNumberForProducts();
|
|
3519
|
-
this.createdAt = this.
|
|
3520
|
-
this.updatedAt = this.
|
|
3519
|
+
this.createdAt = this.getDate(this.transactionDocument.createdAt);
|
|
3520
|
+
this.updatedAt = this.getDate(this.transactionDocument.updatedAt);
|
|
3521
3521
|
}
|
|
3522
3522
|
/**
|
|
3523
3523
|
* @template THIS
|
|
@@ -3601,6 +3601,12 @@ class RJMapperBuilderClass {
|
|
|
3601
3601
|
(/** @type {?} */ (this)).rjObject['ProductSale'].push(data);
|
|
3602
3602
|
(/** @type {?} */ (this)).getModifierItem(lineDiscount.length > 0 ? lineDiscount[0] : null, element.itemLineId);
|
|
3603
3603
|
}));
|
|
3604
|
+
/** @type {?} */
|
|
3605
|
+
let transactionPromotion = [];
|
|
3606
|
+
if ((/** @type {?} */ (this)).transactionDocument.basket.transactionPromotion && (/** @type {?} */ (this)).transactionDocument.basket.transactionPromotion.length > 0) {
|
|
3607
|
+
transactionPromotion = (/** @type {?} */ (this)).transactionDocument.basket.transactionPromotion;
|
|
3608
|
+
(/** @type {?} */ (this)).getTransactionPromotion(transactionPromotion);
|
|
3609
|
+
}
|
|
3604
3610
|
}
|
|
3605
3611
|
else if ((/** @type {?} */ (this)).transactionDocument.type === TRANSACTION_TYPE.REFUND) {
|
|
3606
3612
|
(/** @type {?} */ (this)).rjObject['ProductReturn'] = [];
|
|
@@ -3682,9 +3688,9 @@ class RJMapperBuilderClass {
|
|
|
3682
3688
|
* @return {THIS}
|
|
3683
3689
|
*/
|
|
3684
3690
|
getBasketDiscount() {
|
|
3685
|
-
(/** @type {?} */ (this)).rjObject['BasketDiscount'] = [];
|
|
3686
3691
|
if (!(/** @type {?} */ (this)).transactionDocument.basket.transactionDiscount)
|
|
3687
3692
|
return (/** @type {?} */ (this));
|
|
3693
|
+
(/** @type {?} */ (this)).rjObject['BasketDiscount'] = [];
|
|
3688
3694
|
(/** @type {?} */ (this)).transactionDocument.basket.transactionDiscount.forEach((/**
|
|
3689
3695
|
* @param {?} element
|
|
3690
3696
|
* @return {?}
|
|
@@ -3700,14 +3706,7 @@ class RJMapperBuilderClass {
|
|
|
3700
3706
|
obj['ReasonCodeID'] = element.reasonCode;
|
|
3701
3707
|
obj['DiscountType'] = element.discountType.toUpperCase() == DISCOUNTTYPE.PERCENT.toUpperCase() ? 0 : 1; // todo - compare values
|
|
3702
3708
|
obj['RoundingRule'] = 2;
|
|
3703
|
-
obj['ModifiedLineNumber '] =
|
|
3704
|
-
element.itemLineIds.forEach((/**
|
|
3705
|
-
* @param {?} element
|
|
3706
|
-
* @return {?}
|
|
3707
|
-
*/
|
|
3708
|
-
(element) => {
|
|
3709
|
-
obj['ModifiedLineNumber'].push(element);
|
|
3710
|
-
}));
|
|
3709
|
+
obj['ModifiedLineNumber '] = element.itemLineIds;
|
|
3711
3710
|
obj['LineNumber'] = (/** @type {?} */ (this)).generateLineNumber();
|
|
3712
3711
|
// obj['DiscountedValue'] = obj['discountAmount'] // todo - confirm value before discount;
|
|
3713
3712
|
// obj['DiscountPercentage'] = obj['discountAmount'] / 100 ; // todo - optional
|
|
@@ -3732,7 +3731,7 @@ class RJMapperBuilderClass {
|
|
|
3732
3731
|
obj.DeviceID = this.deviceId;
|
|
3733
3732
|
obj.UserID = this.transactionDocument.userName;
|
|
3734
3733
|
obj.DateTimeCreated = this.updatedAt;
|
|
3735
|
-
obj.AuthorisingUserID = this.
|
|
3734
|
+
obj.AuthorisingUserID = this.transactionDocument.userName;
|
|
3736
3735
|
obj.ReasonCodeID = data.percentageDiscountReasonCode ? data.percentageDiscountReasonCode : data.priceOverrideReasonCode;
|
|
3737
3736
|
obj.ModifiedLineNumber = lineNo;
|
|
3738
3737
|
obj.ModifiedIndex = 1;
|
|
@@ -3842,12 +3841,6 @@ class RJMapperBuilderClass {
|
|
|
3842
3841
|
* @return {?}
|
|
3843
3842
|
*/
|
|
3844
3843
|
(element) => {
|
|
3845
|
-
/** @type {?} */
|
|
3846
|
-
let value = (/** @type {?} */ (this)).paymentTypes.filter((/**
|
|
3847
|
-
* @param {?} x
|
|
3848
|
-
* @return {?}
|
|
3849
|
-
*/
|
|
3850
|
-
x => x.name.toUpperCase() === element.paymentType.toUpperCase()));
|
|
3851
3844
|
if (element.paymentType.toUpperCase() === 'GIFT CARD') {
|
|
3852
3845
|
/** @type {?} */
|
|
3853
3846
|
let obj = {
|
|
@@ -3855,12 +3848,12 @@ class RJMapperBuilderClass {
|
|
|
3855
3848
|
LineNumber: (/** @type {?} */ (this)).generateLineNumber(),
|
|
3856
3849
|
NetValue: (/** @type {?} */ (this)).convertToString(-1 * (/** @type {?} */ (this)).removeDecimal((Math.round(element.amount)))),
|
|
3857
3850
|
EffectiveNetValue: (/** @type {?} */ (this)).convertToString(-1 * (/** @type {?} */ (this)).removeDecimal((Math.round(element.amount)))),
|
|
3858
|
-
Description: (/** @type {?} */ (this)).getDescription(
|
|
3851
|
+
Description: (/** @type {?} */ (this)).getDescription(element),
|
|
3859
3852
|
DeviceID: (/** @type {?} */ (this)).deviceId,
|
|
3860
3853
|
UserID: (/** @type {?} */ (this)).transactionDocument.userName,
|
|
3861
3854
|
DateTimeCreated: (/** @type {?} */ (this)).updatedAt,
|
|
3862
|
-
TenderType:
|
|
3863
|
-
TenderSubType:
|
|
3855
|
+
TenderType: element.externalTenderType ? element.externalTenderType : '',
|
|
3856
|
+
TenderSubType: element.externalSubTenderType ? element.externalSubTenderType : '',
|
|
3864
3857
|
TenderAmount: (/** @type {?} */ (this)).convertToString(-1 * (/** @type {?} */ (this)).removeDecimal((Math.round(element.amount)))),
|
|
3865
3858
|
CurrencyID: (/** @type {?} */ (this)).transactionDocument.baseCurrency,
|
|
3866
3859
|
CurrencyDescription: (/** @type {?} */ (this)).transactionDocument.baseCurrency,
|
|
@@ -3880,12 +3873,12 @@ class RJMapperBuilderClass {
|
|
|
3880
3873
|
//todo
|
|
3881
3874
|
NetValue: JSON.stringify(-1 * (Math.round(element.amount))),
|
|
3882
3875
|
EffectiveNetValue: JSON.stringify(-1 * (Math.round(element.amount))),
|
|
3883
|
-
Description: (/** @type {?} */ (this)).getDescription(
|
|
3876
|
+
Description: (/** @type {?} */ (this)).getDescription(element),
|
|
3884
3877
|
DeviceID: (/** @type {?} */ (this)).deviceId,
|
|
3885
3878
|
UserID: (/** @type {?} */ (this)).transactionDocument.userName,
|
|
3886
3879
|
DateTimeCreated: (/** @type {?} */ (this)).updatedAt,
|
|
3887
|
-
TenderType:
|
|
3888
|
-
TenderSubType:
|
|
3880
|
+
TenderType: element.externalTenderType ? element.externalTenderType : '',
|
|
3881
|
+
TenderSubType: element.externalSubTenderType ? element.externalSubTenderType : '',
|
|
3889
3882
|
TenderAmount: JSON.stringify(-1 * (Math.round(element.amount))),
|
|
3890
3883
|
CurrencyID: (/** @type {?} */ (this)).transactionDocument.baseCurrency,
|
|
3891
3884
|
CurrencyDescription: (/** @type {?} */ (this)).transactionDocument.baseCurrency,
|
|
@@ -3940,16 +3933,15 @@ class RJMapperBuilderClass {
|
|
|
3940
3933
|
return this.rjObject;
|
|
3941
3934
|
}
|
|
3942
3935
|
/**
|
|
3943
|
-
* @param {?} paymentType
|
|
3944
3936
|
* @param {?} element
|
|
3945
3937
|
* @return {?}
|
|
3946
3938
|
*/
|
|
3947
|
-
getDescription(
|
|
3948
|
-
if (paymentType.toUpperCase() === 'CARD') {
|
|
3939
|
+
getDescription(element) {
|
|
3940
|
+
if (element.paymentType.toUpperCase() === 'CARD') {
|
|
3949
3941
|
return element.cardType;
|
|
3950
3942
|
}
|
|
3951
3943
|
else {
|
|
3952
|
-
return paymentType;
|
|
3944
|
+
return element.paymentType;
|
|
3953
3945
|
}
|
|
3954
3946
|
}
|
|
3955
3947
|
/**
|
|
@@ -3962,16 +3954,6 @@ class RJMapperBuilderClass {
|
|
|
3962
3954
|
(/** @type {?} */ (this)).deviceId = id;
|
|
3963
3955
|
return (/** @type {?} */ (this));
|
|
3964
3956
|
}
|
|
3965
|
-
/**
|
|
3966
|
-
* @template THIS
|
|
3967
|
-
* @this {THIS}
|
|
3968
|
-
* @param {?} id
|
|
3969
|
-
* @return {THIS}
|
|
3970
|
-
*/
|
|
3971
|
-
setUserInfo(id) {
|
|
3972
|
-
(/** @type {?} */ (this)).userId = id;
|
|
3973
|
-
return (/** @type {?} */ (this));
|
|
3974
|
-
}
|
|
3975
3957
|
/**
|
|
3976
3958
|
* @param {?} value
|
|
3977
3959
|
* @return {?}
|
|
@@ -4149,16 +4131,6 @@ class RJMapperBuilderClass {
|
|
|
4149
4131
|
(/** @type {?} */ (this)).branchId = value;
|
|
4150
4132
|
return (/** @type {?} */ (this));
|
|
4151
4133
|
}
|
|
4152
|
-
/**
|
|
4153
|
-
* @template THIS
|
|
4154
|
-
* @this {THIS}
|
|
4155
|
-
* @param {?} value
|
|
4156
|
-
* @return {THIS}
|
|
4157
|
-
*/
|
|
4158
|
-
setPaymentDetails(value) {
|
|
4159
|
-
(/** @type {?} */ (this)).paymentTypes = value;
|
|
4160
|
-
return (/** @type {?} */ (this));
|
|
4161
|
-
}
|
|
4162
4134
|
/**
|
|
4163
4135
|
* @param {?} date
|
|
4164
4136
|
* @return {?}
|
|
@@ -4218,11 +4190,11 @@ class RJMapperBuilderClass {
|
|
|
4218
4190
|
obj['EffectiveNetValue'] = this.removeDecimal(element['refundedTotal']);
|
|
4219
4191
|
obj['Description'] = element['description'];
|
|
4220
4192
|
obj['DeviceID'] = this.transactionDocument['terminalId'];
|
|
4221
|
-
obj['UserID'] = this.
|
|
4193
|
+
obj['UserID'] = this.transactionDocument.userName;
|
|
4222
4194
|
obj['DateTimeCreated'] = this.createdAt;
|
|
4223
4195
|
obj['ExtendedValue'] = this.removeDecimal(element['totalLinePrice'] * -1);
|
|
4224
4196
|
obj['UnitPrice'] = this.removeDecimal(element['price']);
|
|
4225
|
-
obj['Quantity'] = element['refundedQuantity'] < 0 ? element['refundedQuantity'].toFixed(1) : -element['refundedQuantity'].toFixed(1);
|
|
4197
|
+
obj['Quantity'] = element['refundedQuantity'] < 0 ? element['refundedQuantity'].toFixed(1) : (-element['refundedQuantity']).toFixed(1);
|
|
4226
4198
|
obj['OriginalTaxAmountSet'] = 1;
|
|
4227
4199
|
obj['ProductID'] = element['SKU'];
|
|
4228
4200
|
obj['HandKeyed'] = 1;
|
|
@@ -4242,7 +4214,7 @@ class RJMapperBuilderClass {
|
|
|
4242
4214
|
obj['MMGroupID'] = this.getAttributes();
|
|
4243
4215
|
obj['CustomerDetails'] = ""; // todo - blank
|
|
4244
4216
|
obj['TotalPromotionSaving'] = element['promotionAmount'] || -1; // TODO
|
|
4245
|
-
obj['OriginalTaxAmount'] = this.convertToString(this.
|
|
4217
|
+
obj['OriginalTaxAmount'] = this.convertToString(this.getOriginalTax(element, taxTotal.VAT) * -1);
|
|
4246
4218
|
obj['taxAmount'] = taxTotal.taxLineTotal < 0 ? (taxTotal.taxLineTotal) : (-taxTotal.taxLineTotal);
|
|
4247
4219
|
if (lineDiscount) {
|
|
4248
4220
|
if (lineDiscount.percentageDiscountReasonName && lineDiscount.percentageDiscountReasonCode) {
|
|
@@ -4252,7 +4224,7 @@ class RJMapperBuilderClass {
|
|
|
4252
4224
|
obj['Discount'].ModifierDateTime = obj.DateTimeCreated;
|
|
4253
4225
|
obj['Discount'].ModifierReasonID = lineDiscount.percentageDiscountReasonCode;
|
|
4254
4226
|
obj['Discount'].ModifierDescription = lineDiscount.percentageDiscountReasonName;
|
|
4255
|
-
obj['Discount'].AuthorisingUserID = this.
|
|
4227
|
+
obj['Discount'].AuthorisingUserID = this.transactionDocument.userName;
|
|
4256
4228
|
obj['Discount'].DiscountType = lineDiscount.discountType;
|
|
4257
4229
|
obj['Discount'].XMLSchemaVersion = 1;
|
|
4258
4230
|
obj['Discount'].OriginalPrice = this.removeDecimal(lineDiscount.discountAmount + (lineDiscount.discountedLinePrice || 0));
|
|
@@ -4267,7 +4239,7 @@ class RJMapperBuilderClass {
|
|
|
4267
4239
|
obj['PriceOverride'].ModifierDateTime = obj.DateTimeCreated;
|
|
4268
4240
|
obj['PriceOverride'].ModifierReasonID = lineDiscount.priceOverrideReasonCode;
|
|
4269
4241
|
obj['PriceOverride'].ModifierReasonDescription = lineDiscount.priceOverrideReasonName;
|
|
4270
|
-
obj['PriceOverride'].AuthorisingUserID = this.
|
|
4242
|
+
obj['PriceOverride'].AuthorisingUserID = this.transactionDocument.userName;
|
|
4271
4243
|
obj['PriceOverride'].XMLSchemaVersion = 1;
|
|
4272
4244
|
obj['PriceOverride'].NewPrice = this.removeDecimal(lineDiscount.unitPrice);
|
|
4273
4245
|
obj['PriceOverride'].OriginalPrice = this.removeDecimal(lineDiscount.discountedLinePrice || 0 + lineDiscount.discountAmount);
|
|
@@ -4316,7 +4288,7 @@ class RJMapperBuilderClass {
|
|
|
4316
4288
|
(item) => item.itemLineId == element['itemLineId'])).VATCode,
|
|
4317
4289
|
TaxModifiable: 1,
|
|
4318
4290
|
//todo
|
|
4319
|
-
OriginalTaxAmount: this.convertToString(this.
|
|
4291
|
+
OriginalTaxAmount: this.convertToString(this.getOriginalTax(element, taxTotal.VAT)),
|
|
4320
4292
|
TaxAmount: this.convertToString(taxTotal.taxLineTotal),
|
|
4321
4293
|
OriginalTaxAmountSet: 1,
|
|
4322
4294
|
//todo
|
|
@@ -4334,7 +4306,7 @@ class RJMapperBuilderClass {
|
|
|
4334
4306
|
obj['Discount'].ModifierDateTime = obj.DateTimeCreated;
|
|
4335
4307
|
obj['Discount'].ModifierReasonID = lineDiscount.percentageDiscountReasonCode;
|
|
4336
4308
|
obj['Discount'].ModifierDescription = lineDiscount.percentageDiscountReasonName;
|
|
4337
|
-
obj['Discount'].AuthorisingUserID = this.
|
|
4309
|
+
obj['Discount'].AuthorisingUserID = this.transactionDocument.userName;
|
|
4338
4310
|
obj['Discount'].DiscountType = lineDiscount.discountType;
|
|
4339
4311
|
obj['Discount'].XMLSchemaVersion = 1;
|
|
4340
4312
|
obj['Discount'].OriginalPrice = this.removeDecimal(lineDiscount.discountAmount + (lineDiscount.discountedLinePrice || 0));
|
|
@@ -4349,7 +4321,7 @@ class RJMapperBuilderClass {
|
|
|
4349
4321
|
obj['PriceOverride'].ModifierDateTime = obj.DateTimeCreated;
|
|
4350
4322
|
obj['PriceOverride'].ModifierReasonID = lineDiscount.priceOverrideReasonCode;
|
|
4351
4323
|
obj['PriceOverride'].ModifierReasonDescription = lineDiscount.priceOverrideReasonName;
|
|
4352
|
-
obj['PriceOverride'].AuthorisingUserID = this.
|
|
4324
|
+
obj['PriceOverride'].AuthorisingUserID = this.transactionDocument.userName;
|
|
4353
4325
|
obj['PriceOverride'].XMLSchemaVersion = 1;
|
|
4354
4326
|
obj['PriceOverride'].NewPrice = this.removeDecimal(lineDiscount.unitPrice);
|
|
4355
4327
|
obj['PriceOverride'].OriginalPrice = this.removeDecimal(lineDiscount.discountedLinePrice || 0 + lineDiscount.discountAmount);
|
|
@@ -4367,7 +4339,7 @@ class RJMapperBuilderClass {
|
|
|
4367
4339
|
* @param {?} VAT
|
|
4368
4340
|
* @return {?}
|
|
4369
4341
|
*/
|
|
4370
|
-
|
|
4342
|
+
getOriginalTax(element, VAT) {
|
|
4371
4343
|
/** @type {?} */
|
|
4372
4344
|
let pricebeforetax = (element.price * 100) / (100 + VAT);
|
|
4373
4345
|
/** @type {?} */
|
|
@@ -4434,7 +4406,7 @@ class RJMapperBuilderClass {
|
|
|
4434
4406
|
* @param {?} date
|
|
4435
4407
|
* @return {?}
|
|
4436
4408
|
*/
|
|
4437
|
-
|
|
4409
|
+
getDate(date) {
|
|
4438
4410
|
/** @type {?} */
|
|
4439
4411
|
let offset = this.generateTimezoneoffset(date) * -1;
|
|
4440
4412
|
/** @type {?} */
|
|
@@ -4449,9 +4421,32 @@ class RJMapperBuilderClass {
|
|
|
4449
4421
|
/** @type {?} */
|
|
4450
4422
|
let newdate = date.substring(0, 19);
|
|
4451
4423
|
/** @type {?} */
|
|
4452
|
-
|
|
4424
|
+
const x = (newdate + offsetSign + String(offsetHours).padStart(2, '0') + ':' + String(offsetMinutes).padStart(2, '0')).toString();
|
|
4453
4425
|
return x;
|
|
4454
4426
|
}
|
|
4427
|
+
/**
|
|
4428
|
+
* @param {?} transactionPromotion
|
|
4429
|
+
* @return {?}
|
|
4430
|
+
*/
|
|
4431
|
+
getTransactionPromotion(transactionPromotion) {
|
|
4432
|
+
if (transactionPromotion && transactionPromotion.length > 0) {
|
|
4433
|
+
this.rjObject['BasketDiscount'] = {};
|
|
4434
|
+
this.rjObject['BasketDiscount']['XMLSchemaVersion'] = 1;
|
|
4435
|
+
this.rjObject['BasketDiscount']['LineNumber'] = this.generateLineNumber();
|
|
4436
|
+
this.rjObject['BasketDiscount']['NetValue'] = this.removeDecimal(transactionPromotion[0].promotionLinePrice) * -1;
|
|
4437
|
+
this.rjObject['BasketDiscount']['EffectiveNetValue'] = this.removeDecimal(transactionPromotion[0].promotionLinePrice) * -1;
|
|
4438
|
+
this.rjObject['BasketDiscount']['Description'] = transactionPromotion[0].promotionInfo;
|
|
4439
|
+
this.rjObject['BasketDiscount']['DeviceID'] = this.deviceId;
|
|
4440
|
+
this.rjObject['BasketDiscount']['UserID'] = this.transactionDocument.userName;
|
|
4441
|
+
this.rjObject['BasketDiscount']['DateTimeCreated'] = this.createdAt;
|
|
4442
|
+
this.rjObject['BasketDiscount']['ModifiedLineNumber'] = transactionPromotion[0].itemLineIds;
|
|
4443
|
+
this.rjObject['BasketDiscount']['ReasonCodeID'] = 0;
|
|
4444
|
+
this.rjObject['BasketDiscount']['DiscountType'] = transactionPromotion[0].promotionType == 'TRANSACTION_OFF' ? 1 : 0;
|
|
4445
|
+
this.rjObject['BasketDiscount']['DiscountPercentage'] = 0; //todo
|
|
4446
|
+
this.rjObject['BasketDiscount']['DiscountedValue'] = 0; //todo
|
|
4447
|
+
this.rjObject['BasketDiscount']['RoundingRule'] = 2;
|
|
4448
|
+
}
|
|
4449
|
+
}
|
|
4455
4450
|
}
|
|
4456
4451
|
if (false) {
|
|
4457
4452
|
/**
|
|
@@ -4459,11 +4454,6 @@ if (false) {
|
|
|
4459
4454
|
* @private
|
|
4460
4455
|
*/
|
|
4461
4456
|
RJMapperBuilderClass.prototype.transactionDocument;
|
|
4462
|
-
/**
|
|
4463
|
-
* @type {?}
|
|
4464
|
-
* @private
|
|
4465
|
-
*/
|
|
4466
|
-
RJMapperBuilderClass.prototype.userId;
|
|
4467
4457
|
/**
|
|
4468
4458
|
* @type {?}
|
|
4469
4459
|
* @private
|
|
@@ -4579,11 +4569,6 @@ if (false) {
|
|
|
4579
4569
|
* @private
|
|
4580
4570
|
*/
|
|
4581
4571
|
RJMapperBuilderClass.prototype.rjObject;
|
|
4582
|
-
/**
|
|
4583
|
-
* @type {?}
|
|
4584
|
-
* @private
|
|
4585
|
-
*/
|
|
4586
|
-
RJMapperBuilderClass.prototype.paymentTypes;
|
|
4587
4572
|
}
|
|
4588
4573
|
|
|
4589
4574
|
/**
|