@pmcretail/mapper-library 0.0.13 → 0.0.14
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 +142 -16
- 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 +129 -17
- package/esm5/lib/RJ-mapper.class.js +143 -17
- package/fesm2015/pmcretail-mapper-library.js +128 -16
- package/fesm2015/pmcretail-mapper-library.js.map +1 -1
- package/fesm5/pmcretail-mapper-library.js +142 -16
- package/fesm5/pmcretail-mapper-library.js.map +1 -1
- package/lib/RJ-mapper.class.d.ts +5 -3
- package/package.json +1 -1
- package/pmcretail-mapper-library.metadata.json +1 -1
|
@@ -4758,6 +4758,11 @@ var RJMapperBuilderClass = /** @class */ (function () {
|
|
|
4758
4758
|
*/
|
|
4759
4759
|
function () {
|
|
4760
4760
|
var _this = this;
|
|
4761
|
+
/** @type {?} */
|
|
4762
|
+
var transactionDiscount = [];
|
|
4763
|
+
if ((/** @type {?} */ (this)).transactionDocument.basket.transactionDiscount && (/** @type {?} */ (this)).transactionDocument.basket.transactionDiscount.length > 0) {
|
|
4764
|
+
transactionDiscount = (/** @type {?} */ (this)).transactionDocument.basket.transactionDiscount;
|
|
4765
|
+
}
|
|
4761
4766
|
if ((/** @type {?} */ (this)).transactionDocument.type === TRANSACTION_TYPE.SALE) {
|
|
4762
4767
|
(/** @type {?} */ (this)).rjObject['ProductSale'] = [];
|
|
4763
4768
|
(/** @type {?} */ (this)).rjObject['ModifierItem'] = [];
|
|
@@ -4783,7 +4788,7 @@ var RJMapperBuilderClass = /** @class */ (function () {
|
|
|
4783
4788
|
}
|
|
4784
4789
|
}
|
|
4785
4790
|
/** @type {?} */
|
|
4786
|
-
var data = (/** @type {?} */ (_this)).addProduct(element, (lineDiscount.length > 0 ? lineDiscount[0] : null));
|
|
4791
|
+
var data = (/** @type {?} */ (_this)).addProduct(element, (lineDiscount.length > 0 ? lineDiscount[0] : null), (transactionDiscount.length > 0 ? transactionDiscount : null));
|
|
4787
4792
|
(/** @type {?} */ (_this)).rjObject['ProductSale'].push(data);
|
|
4788
4793
|
(/** @type {?} */ (_this)).getModifierItem(lineDiscount.length > 0 ? lineDiscount[0] : null, element.itemLineId);
|
|
4789
4794
|
}));
|
|
@@ -4803,7 +4808,7 @@ var RJMapperBuilderClass = /** @class */ (function () {
|
|
|
4803
4808
|
*/
|
|
4804
4809
|
function (element) {
|
|
4805
4810
|
/** @type {?} */
|
|
4806
|
-
var data = (/** @type {?} */ (_this)).returnProduct(element, (element.hasOwnProperty('lineDiscount') ? element.lineDiscount : null));
|
|
4811
|
+
var data = (/** @type {?} */ (_this)).returnProduct(element, (element.hasOwnProperty('lineDiscount') ? element.lineDiscount : null), (transactionDiscount.length > 0 ? transactionDiscount : null));
|
|
4807
4812
|
(/** @type {?} */ (_this)).rjObject['ProductReturn'].push(data);
|
|
4808
4813
|
(/** @type {?} */ (_this)).getModifierItem(element.lineDiscount, element.itemLineId);
|
|
4809
4814
|
}));
|
|
@@ -4819,7 +4824,7 @@ var RJMapperBuilderClass = /** @class */ (function () {
|
|
|
4819
4824
|
*/
|
|
4820
4825
|
function (element) {
|
|
4821
4826
|
/** @type {?} */
|
|
4822
|
-
var data = (/** @type {?} */ (_this)).returnProduct(element, (element.hasOwnProperty('lineDiscount') ? element.lineDiscount : null));
|
|
4827
|
+
var data = (/** @type {?} */ (_this)).returnProduct(element, (element.hasOwnProperty('lineDiscount') ? element.lineDiscount : null), (transactionDiscount.length > 0 ? transactionDiscount : null));
|
|
4823
4828
|
/** @type {?} */
|
|
4824
4829
|
var obj = {
|
|
4825
4830
|
"OriginalReceiptSupplied": 0,
|
|
@@ -4846,7 +4851,7 @@ var RJMapperBuilderClass = /** @class */ (function () {
|
|
|
4846
4851
|
function (element) {
|
|
4847
4852
|
if (element.refundedQuantity > 0) {
|
|
4848
4853
|
/** @type {?} */
|
|
4849
|
-
var returnProduct = (/** @type {?} */ (_this)).returnProduct(element, (element.hasOwnProperty('lineDiscount') ? element.lineDiscount : null));
|
|
4854
|
+
var returnProduct = (/** @type {?} */ (_this)).returnProduct(element, (element.hasOwnProperty('lineDiscount') ? element.lineDiscount : null), (transactionDiscount.length > 0 ? transactionDiscount : null));
|
|
4850
4855
|
/** @type {?} */
|
|
4851
4856
|
var obj = {
|
|
4852
4857
|
"OriginalReceiptSupplied": 0,
|
|
@@ -4860,7 +4865,7 @@ var RJMapperBuilderClass = /** @class */ (function () {
|
|
|
4860
4865
|
}
|
|
4861
4866
|
else {
|
|
4862
4867
|
/** @type {?} */
|
|
4863
|
-
var addProduct = (/** @type {?} */ (_this)).addProduct(element, (element.hasOwnProperty('lineDiscount') ? element.lineDiscount : null));
|
|
4868
|
+
var addProduct = (/** @type {?} */ (_this)).addProduct(element, (element.hasOwnProperty('lineDiscount') ? element.lineDiscount : null), (transactionDiscount.length > 0 ? transactionDiscount : null));
|
|
4864
4869
|
(/** @type {?} */ (_this)).rjObject['ProductSale'].push(addProduct);
|
|
4865
4870
|
}
|
|
4866
4871
|
(/** @type {?} */ (_this)).getModifierItem(element.lineDiscount, element.itemLineId);
|
|
@@ -4890,18 +4895,24 @@ var RJMapperBuilderClass = /** @class */ (function () {
|
|
|
4890
4895
|
function (element) {
|
|
4891
4896
|
/** @type {?} */
|
|
4892
4897
|
var obj = {};
|
|
4893
|
-
obj['XMLSchemaVersion'] =
|
|
4894
|
-
obj['NetValue'] = (/** @type {?} */ (_this)).convertToString(element.discountAmount
|
|
4895
|
-
obj['EffectiveNetValue'] = (/** @type {?} */ (_this)).convertToString(element.discountAmount
|
|
4898
|
+
obj['XMLSchemaVersion'] = (/** @type {?} */ (_this)).xmlSchemaVersion;
|
|
4899
|
+
obj['NetValue'] = (/** @type {?} */ (_this)).convertToString(element.discountAmount * -1);
|
|
4900
|
+
obj['EffectiveNetValue'] = (/** @type {?} */ (_this)).convertToString(element.discountAmount * -1);
|
|
4896
4901
|
obj['Description'] = element.reasonDisplayText;
|
|
4897
4902
|
obj['UserID'] = (/** @type {?} */ (_this)).transactionDocument.userName;
|
|
4898
4903
|
obj['ReasonCodeID'] = element.reasonCode;
|
|
4899
|
-
obj['DiscountType'] = (/** @type {?} */ (_this)).convertToString(element.discountType.toUpperCase() == DISCOUNTTYPE.PERCENT.toUpperCase() ? 0 : 1);
|
|
4904
|
+
obj['DiscountType'] = (/** @type {?} */ (_this)).convertToString(element.discountType.toUpperCase() == DISCOUNTTYPE.PERCENT.toUpperCase() ? 0 : 1);
|
|
4900
4905
|
obj['RoundingRule'] = (/** @type {?} */ (_this)).convertToString(2);
|
|
4901
4906
|
obj['ModifiedLineNumber'] = element.itemLineIds;
|
|
4902
4907
|
obj['LineNumber'] = (/** @type {?} */ (_this)).convertToString((/** @type {?} */ (_this)).generateLineNumber());
|
|
4903
|
-
|
|
4904
|
-
|
|
4908
|
+
obj['DiscountedValue'] = (/** @type {?} */ (_this)).transactionDocument.basketSummary.basketTotal + (/** @type {?} */ (_this)).transactionDocument.basketSummary.discountTotal;
|
|
4909
|
+
if (element.discountType.toUpperCase() == DISCOUNTTYPE.PERCENT.toUpperCase()) {
|
|
4910
|
+
obj['DiscountPercentage'] = (/** @type {?} */ (_this)).convertToString((element.discountAmount / (/** @type {?} */ (_this)).transactionDocument.basketSummary.basketTotal).toFixed(1));
|
|
4911
|
+
}
|
|
4912
|
+
if ((/** @type {?} */ (_this)).transactionDocument.type === 'REFUND') {
|
|
4913
|
+
obj['NetValue'] = (/** @type {?} */ (_this)).convertToString(element.discountAmount < 0 ? -element.discountAmount : element.discountAmount);
|
|
4914
|
+
obj['EffectiveNetValue'] = (/** @type {?} */ (_this)).convertToString(element.discountAmount < 0 ? -element.discountAmount : element.discountAmount);
|
|
4915
|
+
}
|
|
4905
4916
|
(/** @type {?} */ (_this)).rjObject['BasketDiscount'].push(obj);
|
|
4906
4917
|
}));
|
|
4907
4918
|
return (/** @type {?} */ (this));
|
|
@@ -4987,7 +4998,6 @@ var RJMapperBuilderClass = /** @class */ (function () {
|
|
|
4987
4998
|
* @return {?}
|
|
4988
4999
|
*/
|
|
4989
5000
|
function (element) {
|
|
4990
|
-
console.log('element', element);
|
|
4991
5001
|
/** @type {?} */
|
|
4992
5002
|
var obj = {};
|
|
4993
5003
|
obj['PromotionID'] = element.promotionId;
|
|
@@ -5518,14 +5528,17 @@ var RJMapperBuilderClass = /** @class */ (function () {
|
|
|
5518
5528
|
/**
|
|
5519
5529
|
* @param {?} element
|
|
5520
5530
|
* @param {?} lineDiscount
|
|
5531
|
+
* @param {?} transactionDiscount
|
|
5521
5532
|
* @return {?}
|
|
5522
5533
|
*/
|
|
5523
5534
|
RJMapperBuilderClass.prototype.returnProduct = /**
|
|
5524
5535
|
* @param {?} element
|
|
5525
5536
|
* @param {?} lineDiscount
|
|
5537
|
+
* @param {?} transactionDiscount
|
|
5526
5538
|
* @return {?}
|
|
5527
5539
|
*/
|
|
5528
|
-
function (element, lineDiscount) {
|
|
5540
|
+
function (element, lineDiscount, transactionDiscount) {
|
|
5541
|
+
var _this = this;
|
|
5529
5542
|
/** @type {?} */
|
|
5530
5543
|
var obj = {};
|
|
5531
5544
|
/** @type {?} */
|
|
@@ -5600,19 +5613,58 @@ var RJMapperBuilderClass = /** @class */ (function () {
|
|
|
5600
5613
|
obj.ExtendedValue = ((lineDiscount.discountedLinePrice || 0) + lineDiscount.discountAmount) * -1;
|
|
5601
5614
|
obj.UnitPrice = ((lineDiscount.discountedLinePrice || 0) + lineDiscount.discountAmount) * -1;
|
|
5602
5615
|
}
|
|
5616
|
+
if (transactionDiscount) {
|
|
5617
|
+
obj['BasketDiscountModifier'] = [];
|
|
5618
|
+
this.transactionDocument.basket.transactionDiscount.forEach((/**
|
|
5619
|
+
* @param {?} e
|
|
5620
|
+
* @return {?}
|
|
5621
|
+
*/
|
|
5622
|
+
function (e) {
|
|
5623
|
+
/** @type {?} */
|
|
5624
|
+
var obj1 = {};
|
|
5625
|
+
e.itemLineIds.forEach((/**
|
|
5626
|
+
* @param {?} x
|
|
5627
|
+
* @return {?}
|
|
5628
|
+
*/
|
|
5629
|
+
function (x) {
|
|
5630
|
+
if (x == element.itemLineId) {
|
|
5631
|
+
/** @type {?} */
|
|
5632
|
+
var discountAmount = _this.convertToString(e.discountAmount * -1);
|
|
5633
|
+
obj1.BasketDiscountLineNumber = _this.getLineNumber(e, discountAmount);
|
|
5634
|
+
obj1.XMLSchemaVersion = _this.xmlSchemaVersion;
|
|
5635
|
+
obj1.DiscountedValue = _this.getDiscountedValue(element.totalLinePrice, e.discountAmount);
|
|
5636
|
+
obj['BasketDiscountModifier'].push(obj1);
|
|
5637
|
+
}
|
|
5638
|
+
}));
|
|
5639
|
+
}));
|
|
5640
|
+
/** @type {?} */
|
|
5641
|
+
var totaltransactionDiscount = 0;
|
|
5642
|
+
obj['BasketDiscountModifier'].forEach((/**
|
|
5643
|
+
* @param {?} value
|
|
5644
|
+
* @return {?}
|
|
5645
|
+
*/
|
|
5646
|
+
function (value) {
|
|
5647
|
+
totaltransactionDiscount = totaltransactionDiscount + value.DiscountedValue;
|
|
5648
|
+
}));
|
|
5649
|
+
//update the product price
|
|
5650
|
+
obj['EffectiveNetValue'] = obj.EffectiveNetValue + totaltransactionDiscount;
|
|
5651
|
+
}
|
|
5603
5652
|
return obj;
|
|
5604
5653
|
};
|
|
5605
5654
|
/**
|
|
5606
5655
|
* @param {?} element
|
|
5607
5656
|
* @param {?} lineDiscount
|
|
5657
|
+
* @param {?} transactionDiscount
|
|
5608
5658
|
* @return {?}
|
|
5609
5659
|
*/
|
|
5610
5660
|
RJMapperBuilderClass.prototype.addProduct = /**
|
|
5611
5661
|
* @param {?} element
|
|
5612
5662
|
* @param {?} lineDiscount
|
|
5663
|
+
* @param {?} transactionDiscount
|
|
5613
5664
|
* @return {?}
|
|
5614
5665
|
*/
|
|
5615
|
-
function (element, lineDiscount) {
|
|
5666
|
+
function (element, lineDiscount, transactionDiscount) {
|
|
5667
|
+
var _this = this;
|
|
5616
5668
|
/** @type {?} */
|
|
5617
5669
|
var taxTotal = this.transactionDocument.basket['taxBreakdown']['taxLines'].find((/**
|
|
5618
5670
|
* @param {?} item
|
|
@@ -5677,7 +5729,7 @@ var RJMapperBuilderClass = /** @class */ (function () {
|
|
|
5677
5729
|
obj['PriceOverride'].ModifierReasonID = lineDiscount.priceOverrideReasonCode;
|
|
5678
5730
|
obj['PriceOverride'].ModifierReasonDescription = lineDiscount.priceOverrideReasonName;
|
|
5679
5731
|
obj['PriceOverride'].AuthorisingUserID = this.transactionDocument.userName;
|
|
5680
|
-
obj['PriceOverride'].XMLSchemaVersion =
|
|
5732
|
+
obj['PriceOverride'].XMLSchemaVersion = this.xmlSchemaVersion;
|
|
5681
5733
|
obj['PriceOverride'].NewPrice = this.removeDecimal(lineDiscount.unitPrice);
|
|
5682
5734
|
obj['PriceOverride'].OriginalPrice = this.removeDecimal(lineDiscount.discountedLinePrice || 0 + lineDiscount.discountAmount);
|
|
5683
5735
|
}
|
|
@@ -5687,8 +5739,82 @@ var RJMapperBuilderClass = /** @class */ (function () {
|
|
|
5687
5739
|
obj['ExtendedValue'] = ((lineDiscount.discountedLinePrice || 0) + lineDiscount.discountAmount);
|
|
5688
5740
|
obj['UnitPrice'] = ((lineDiscount.discountedLinePrice || 0) + lineDiscount.discountAmount);
|
|
5689
5741
|
}
|
|
5742
|
+
if (transactionDiscount) {
|
|
5743
|
+
obj['BasketDiscountModifier'] = [];
|
|
5744
|
+
this.transactionDocument.basket.transactionDiscount.forEach((/**
|
|
5745
|
+
* @param {?} e
|
|
5746
|
+
* @return {?}
|
|
5747
|
+
*/
|
|
5748
|
+
function (e) {
|
|
5749
|
+
/** @type {?} */
|
|
5750
|
+
var obj1 = {};
|
|
5751
|
+
e.itemLineIds.forEach((/**
|
|
5752
|
+
* @param {?} x
|
|
5753
|
+
* @return {?}
|
|
5754
|
+
*/
|
|
5755
|
+
function (x) {
|
|
5756
|
+
if (x == element.itemLineId) {
|
|
5757
|
+
/** @type {?} */
|
|
5758
|
+
var discountAmount = _this.convertToString(e.discountAmount * -1);
|
|
5759
|
+
obj1.XMLSchemaVersion = _this.xmlSchemaVersion;
|
|
5760
|
+
obj1.DiscountedValue = -(_this.getDiscountedValue(element.totalLinePrice, e.discountAmount).toFixed(0));
|
|
5761
|
+
obj1.BasketDiscountLineNumber = _this.getLineNumber(e, discountAmount);
|
|
5762
|
+
obj['BasketDiscountModifier'].push(obj1);
|
|
5763
|
+
}
|
|
5764
|
+
}));
|
|
5765
|
+
}));
|
|
5766
|
+
/** @type {?} */
|
|
5767
|
+
var totaltransactionDiscount = 0;
|
|
5768
|
+
obj['BasketDiscountModifier'].forEach((/**
|
|
5769
|
+
* @param {?} value
|
|
5770
|
+
* @return {?}
|
|
5771
|
+
*/
|
|
5772
|
+
function (value) {
|
|
5773
|
+
totaltransactionDiscount = totaltransactionDiscount + value.DiscountedValue;
|
|
5774
|
+
}));
|
|
5775
|
+
//update the product price
|
|
5776
|
+
obj['EffectiveNetValue'] = obj.EffectiveNetValue + totaltransactionDiscount;
|
|
5777
|
+
}
|
|
5690
5778
|
return obj;
|
|
5691
5779
|
};
|
|
5780
|
+
/**
|
|
5781
|
+
* @param {?} value
|
|
5782
|
+
* @param {?} discountAmount
|
|
5783
|
+
* @return {?}
|
|
5784
|
+
*/
|
|
5785
|
+
RJMapperBuilderClass.prototype.getLineNumber = /**
|
|
5786
|
+
* @param {?} value
|
|
5787
|
+
* @param {?} discountAmount
|
|
5788
|
+
* @return {?}
|
|
5789
|
+
*/
|
|
5790
|
+
function (value, discountAmount) {
|
|
5791
|
+
/** @type {?} */
|
|
5792
|
+
var lineNumber;
|
|
5793
|
+
for (var i = 0; i < this.rjObject['BasketDiscount'].length; i++) {
|
|
5794
|
+
/** @type {?} */
|
|
5795
|
+
var element = this.rjObject['BasketDiscount'][i];
|
|
5796
|
+
if (value.reasonCode === element.ReasonCodeID && discountAmount === element.NetValue) {
|
|
5797
|
+
lineNumber = element.LineNumber;
|
|
5798
|
+
break;
|
|
5799
|
+
}
|
|
5800
|
+
}
|
|
5801
|
+
return lineNumber;
|
|
5802
|
+
};
|
|
5803
|
+
/**
|
|
5804
|
+
* @param {?} price
|
|
5805
|
+
* @param {?} discountAmount
|
|
5806
|
+
* @return {?}
|
|
5807
|
+
*/
|
|
5808
|
+
RJMapperBuilderClass.prototype.getDiscountedValue = /**
|
|
5809
|
+
* @param {?} price
|
|
5810
|
+
* @param {?} discountAmount
|
|
5811
|
+
* @return {?}
|
|
5812
|
+
*/
|
|
5813
|
+
function (price, discountAmount) {
|
|
5814
|
+
/** @type {?} */
|
|
5815
|
+
var DiscountedValue = (price * discountAmount) / this.transactionDocument.basketSummary.saleTotal;
|
|
5816
|
+
return DiscountedValue;
|
|
5817
|
+
};
|
|
5692
5818
|
/**
|
|
5693
5819
|
* @param {?} element
|
|
5694
5820
|
* @param {?} VAT
|
|
@@ -5720,7 +5846,7 @@ var RJMapperBuilderClass = /** @class */ (function () {
|
|
|
5720
5846
|
return value;
|
|
5721
5847
|
}
|
|
5722
5848
|
catch (e) {
|
|
5723
|
-
console.log(value, '
|
|
5849
|
+
console.log(value, 'can not be converted in string', e);
|
|
5724
5850
|
}
|
|
5725
5851
|
};
|
|
5726
5852
|
/**
|