@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
|
@@ -4978,6 +4978,11 @@
|
|
|
4978
4978
|
*/
|
|
4979
4979
|
function () {
|
|
4980
4980
|
var _this = this;
|
|
4981
|
+
/** @type {?} */
|
|
4982
|
+
var transactionDiscount = [];
|
|
4983
|
+
if ((/** @type {?} */ (this)).transactionDocument.basket.transactionDiscount && (/** @type {?} */ (this)).transactionDocument.basket.transactionDiscount.length > 0) {
|
|
4984
|
+
transactionDiscount = (/** @type {?} */ (this)).transactionDocument.basket.transactionDiscount;
|
|
4985
|
+
}
|
|
4981
4986
|
if ((/** @type {?} */ (this)).transactionDocument.type === TRANSACTION_TYPE.SALE) {
|
|
4982
4987
|
(/** @type {?} */ (this)).rjObject['ProductSale'] = [];
|
|
4983
4988
|
(/** @type {?} */ (this)).rjObject['ModifierItem'] = [];
|
|
@@ -5003,7 +5008,7 @@
|
|
|
5003
5008
|
}
|
|
5004
5009
|
}
|
|
5005
5010
|
/** @type {?} */
|
|
5006
|
-
var data = (/** @type {?} */ (_this)).addProduct(element, (lineDiscount.length > 0 ? lineDiscount[0] : null));
|
|
5011
|
+
var data = (/** @type {?} */ (_this)).addProduct(element, (lineDiscount.length > 0 ? lineDiscount[0] : null), (transactionDiscount.length > 0 ? transactionDiscount : null));
|
|
5007
5012
|
(/** @type {?} */ (_this)).rjObject['ProductSale'].push(data);
|
|
5008
5013
|
(/** @type {?} */ (_this)).getModifierItem(lineDiscount.length > 0 ? lineDiscount[0] : null, element.itemLineId);
|
|
5009
5014
|
}));
|
|
@@ -5023,7 +5028,7 @@
|
|
|
5023
5028
|
*/
|
|
5024
5029
|
function (element) {
|
|
5025
5030
|
/** @type {?} */
|
|
5026
|
-
var data = (/** @type {?} */ (_this)).returnProduct(element, (element.hasOwnProperty('lineDiscount') ? element.lineDiscount : null));
|
|
5031
|
+
var data = (/** @type {?} */ (_this)).returnProduct(element, (element.hasOwnProperty('lineDiscount') ? element.lineDiscount : null), (transactionDiscount.length > 0 ? transactionDiscount : null));
|
|
5027
5032
|
(/** @type {?} */ (_this)).rjObject['ProductReturn'].push(data);
|
|
5028
5033
|
(/** @type {?} */ (_this)).getModifierItem(element.lineDiscount, element.itemLineId);
|
|
5029
5034
|
}));
|
|
@@ -5039,7 +5044,7 @@
|
|
|
5039
5044
|
*/
|
|
5040
5045
|
function (element) {
|
|
5041
5046
|
/** @type {?} */
|
|
5042
|
-
var data = (/** @type {?} */ (_this)).returnProduct(element, (element.hasOwnProperty('lineDiscount') ? element.lineDiscount : null));
|
|
5047
|
+
var data = (/** @type {?} */ (_this)).returnProduct(element, (element.hasOwnProperty('lineDiscount') ? element.lineDiscount : null), (transactionDiscount.length > 0 ? transactionDiscount : null));
|
|
5043
5048
|
/** @type {?} */
|
|
5044
5049
|
var obj = {
|
|
5045
5050
|
"OriginalReceiptSupplied": 0,
|
|
@@ -5066,7 +5071,7 @@
|
|
|
5066
5071
|
function (element) {
|
|
5067
5072
|
if (element.refundedQuantity > 0) {
|
|
5068
5073
|
/** @type {?} */
|
|
5069
|
-
var returnProduct = (/** @type {?} */ (_this)).returnProduct(element, (element.hasOwnProperty('lineDiscount') ? element.lineDiscount : null));
|
|
5074
|
+
var returnProduct = (/** @type {?} */ (_this)).returnProduct(element, (element.hasOwnProperty('lineDiscount') ? element.lineDiscount : null), (transactionDiscount.length > 0 ? transactionDiscount : null));
|
|
5070
5075
|
/** @type {?} */
|
|
5071
5076
|
var obj = {
|
|
5072
5077
|
"OriginalReceiptSupplied": 0,
|
|
@@ -5080,7 +5085,7 @@
|
|
|
5080
5085
|
}
|
|
5081
5086
|
else {
|
|
5082
5087
|
/** @type {?} */
|
|
5083
|
-
var addProduct = (/** @type {?} */ (_this)).addProduct(element, (element.hasOwnProperty('lineDiscount') ? element.lineDiscount : null));
|
|
5088
|
+
var addProduct = (/** @type {?} */ (_this)).addProduct(element, (element.hasOwnProperty('lineDiscount') ? element.lineDiscount : null), (transactionDiscount.length > 0 ? transactionDiscount : null));
|
|
5084
5089
|
(/** @type {?} */ (_this)).rjObject['ProductSale'].push(addProduct);
|
|
5085
5090
|
}
|
|
5086
5091
|
(/** @type {?} */ (_this)).getModifierItem(element.lineDiscount, element.itemLineId);
|
|
@@ -5110,18 +5115,24 @@
|
|
|
5110
5115
|
function (element) {
|
|
5111
5116
|
/** @type {?} */
|
|
5112
5117
|
var obj = {};
|
|
5113
|
-
obj['XMLSchemaVersion'] =
|
|
5114
|
-
obj['NetValue'] = (/** @type {?} */ (_this)).convertToString(element.discountAmount
|
|
5115
|
-
obj['EffectiveNetValue'] = (/** @type {?} */ (_this)).convertToString(element.discountAmount
|
|
5118
|
+
obj['XMLSchemaVersion'] = (/** @type {?} */ (_this)).xmlSchemaVersion;
|
|
5119
|
+
obj['NetValue'] = (/** @type {?} */ (_this)).convertToString(element.discountAmount * -1);
|
|
5120
|
+
obj['EffectiveNetValue'] = (/** @type {?} */ (_this)).convertToString(element.discountAmount * -1);
|
|
5116
5121
|
obj['Description'] = element.reasonDisplayText;
|
|
5117
5122
|
obj['UserID'] = (/** @type {?} */ (_this)).transactionDocument.userName;
|
|
5118
5123
|
obj['ReasonCodeID'] = element.reasonCode;
|
|
5119
|
-
obj['DiscountType'] = (/** @type {?} */ (_this)).convertToString(element.discountType.toUpperCase() == DISCOUNTTYPE.PERCENT.toUpperCase() ? 0 : 1);
|
|
5124
|
+
obj['DiscountType'] = (/** @type {?} */ (_this)).convertToString(element.discountType.toUpperCase() == DISCOUNTTYPE.PERCENT.toUpperCase() ? 0 : 1);
|
|
5120
5125
|
obj['RoundingRule'] = (/** @type {?} */ (_this)).convertToString(2);
|
|
5121
5126
|
obj['ModifiedLineNumber'] = element.itemLineIds;
|
|
5122
5127
|
obj['LineNumber'] = (/** @type {?} */ (_this)).convertToString((/** @type {?} */ (_this)).generateLineNumber());
|
|
5123
|
-
|
|
5124
|
-
|
|
5128
|
+
obj['DiscountedValue'] = (/** @type {?} */ (_this)).transactionDocument.basketSummary.basketTotal + (/** @type {?} */ (_this)).transactionDocument.basketSummary.discountTotal;
|
|
5129
|
+
if (element.discountType.toUpperCase() == DISCOUNTTYPE.PERCENT.toUpperCase()) {
|
|
5130
|
+
obj['DiscountPercentage'] = (/** @type {?} */ (_this)).convertToString((element.discountAmount / (/** @type {?} */ (_this)).transactionDocument.basketSummary.basketTotal).toFixed(1));
|
|
5131
|
+
}
|
|
5132
|
+
if ((/** @type {?} */ (_this)).transactionDocument.type === 'REFUND') {
|
|
5133
|
+
obj['NetValue'] = (/** @type {?} */ (_this)).convertToString(element.discountAmount < 0 ? -element.discountAmount : element.discountAmount);
|
|
5134
|
+
obj['EffectiveNetValue'] = (/** @type {?} */ (_this)).convertToString(element.discountAmount < 0 ? -element.discountAmount : element.discountAmount);
|
|
5135
|
+
}
|
|
5125
5136
|
(/** @type {?} */ (_this)).rjObject['BasketDiscount'].push(obj);
|
|
5126
5137
|
}));
|
|
5127
5138
|
return (/** @type {?} */ (this));
|
|
@@ -5207,7 +5218,6 @@
|
|
|
5207
5218
|
* @return {?}
|
|
5208
5219
|
*/
|
|
5209
5220
|
function (element) {
|
|
5210
|
-
console.log('element', element);
|
|
5211
5221
|
/** @type {?} */
|
|
5212
5222
|
var obj = {};
|
|
5213
5223
|
obj['PromotionID'] = element.promotionId;
|
|
@@ -5738,14 +5748,17 @@
|
|
|
5738
5748
|
/**
|
|
5739
5749
|
* @param {?} element
|
|
5740
5750
|
* @param {?} lineDiscount
|
|
5751
|
+
* @param {?} transactionDiscount
|
|
5741
5752
|
* @return {?}
|
|
5742
5753
|
*/
|
|
5743
5754
|
RJMapperBuilderClass.prototype.returnProduct = /**
|
|
5744
5755
|
* @param {?} element
|
|
5745
5756
|
* @param {?} lineDiscount
|
|
5757
|
+
* @param {?} transactionDiscount
|
|
5746
5758
|
* @return {?}
|
|
5747
5759
|
*/
|
|
5748
|
-
function (element, lineDiscount) {
|
|
5760
|
+
function (element, lineDiscount, transactionDiscount) {
|
|
5761
|
+
var _this = this;
|
|
5749
5762
|
/** @type {?} */
|
|
5750
5763
|
var obj = {};
|
|
5751
5764
|
/** @type {?} */
|
|
@@ -5820,19 +5833,58 @@
|
|
|
5820
5833
|
obj.ExtendedValue = ((lineDiscount.discountedLinePrice || 0) + lineDiscount.discountAmount) * -1;
|
|
5821
5834
|
obj.UnitPrice = ((lineDiscount.discountedLinePrice || 0) + lineDiscount.discountAmount) * -1;
|
|
5822
5835
|
}
|
|
5836
|
+
if (transactionDiscount) {
|
|
5837
|
+
obj['BasketDiscountModifier'] = [];
|
|
5838
|
+
this.transactionDocument.basket.transactionDiscount.forEach((/**
|
|
5839
|
+
* @param {?} e
|
|
5840
|
+
* @return {?}
|
|
5841
|
+
*/
|
|
5842
|
+
function (e) {
|
|
5843
|
+
/** @type {?} */
|
|
5844
|
+
var obj1 = {};
|
|
5845
|
+
e.itemLineIds.forEach((/**
|
|
5846
|
+
* @param {?} x
|
|
5847
|
+
* @return {?}
|
|
5848
|
+
*/
|
|
5849
|
+
function (x) {
|
|
5850
|
+
if (x == element.itemLineId) {
|
|
5851
|
+
/** @type {?} */
|
|
5852
|
+
var discountAmount = _this.convertToString(e.discountAmount * -1);
|
|
5853
|
+
obj1.BasketDiscountLineNumber = _this.getLineNumber(e, discountAmount);
|
|
5854
|
+
obj1.XMLSchemaVersion = _this.xmlSchemaVersion;
|
|
5855
|
+
obj1.DiscountedValue = _this.getDiscountedValue(element.totalLinePrice, e.discountAmount);
|
|
5856
|
+
obj['BasketDiscountModifier'].push(obj1);
|
|
5857
|
+
}
|
|
5858
|
+
}));
|
|
5859
|
+
}));
|
|
5860
|
+
/** @type {?} */
|
|
5861
|
+
var totaltransactionDiscount = 0;
|
|
5862
|
+
obj['BasketDiscountModifier'].forEach((/**
|
|
5863
|
+
* @param {?} value
|
|
5864
|
+
* @return {?}
|
|
5865
|
+
*/
|
|
5866
|
+
function (value) {
|
|
5867
|
+
totaltransactionDiscount = totaltransactionDiscount + value.DiscountedValue;
|
|
5868
|
+
}));
|
|
5869
|
+
//update the product price
|
|
5870
|
+
obj['EffectiveNetValue'] = obj.EffectiveNetValue + totaltransactionDiscount;
|
|
5871
|
+
}
|
|
5823
5872
|
return obj;
|
|
5824
5873
|
};
|
|
5825
5874
|
/**
|
|
5826
5875
|
* @param {?} element
|
|
5827
5876
|
* @param {?} lineDiscount
|
|
5877
|
+
* @param {?} transactionDiscount
|
|
5828
5878
|
* @return {?}
|
|
5829
5879
|
*/
|
|
5830
5880
|
RJMapperBuilderClass.prototype.addProduct = /**
|
|
5831
5881
|
* @param {?} element
|
|
5832
5882
|
* @param {?} lineDiscount
|
|
5883
|
+
* @param {?} transactionDiscount
|
|
5833
5884
|
* @return {?}
|
|
5834
5885
|
*/
|
|
5835
|
-
function (element, lineDiscount) {
|
|
5886
|
+
function (element, lineDiscount, transactionDiscount) {
|
|
5887
|
+
var _this = this;
|
|
5836
5888
|
/** @type {?} */
|
|
5837
5889
|
var taxTotal = this.transactionDocument.basket['taxBreakdown']['taxLines'].find((/**
|
|
5838
5890
|
* @param {?} item
|
|
@@ -5897,7 +5949,7 @@
|
|
|
5897
5949
|
obj['PriceOverride'].ModifierReasonID = lineDiscount.priceOverrideReasonCode;
|
|
5898
5950
|
obj['PriceOverride'].ModifierReasonDescription = lineDiscount.priceOverrideReasonName;
|
|
5899
5951
|
obj['PriceOverride'].AuthorisingUserID = this.transactionDocument.userName;
|
|
5900
|
-
obj['PriceOverride'].XMLSchemaVersion =
|
|
5952
|
+
obj['PriceOverride'].XMLSchemaVersion = this.xmlSchemaVersion;
|
|
5901
5953
|
obj['PriceOverride'].NewPrice = this.removeDecimal(lineDiscount.unitPrice);
|
|
5902
5954
|
obj['PriceOverride'].OriginalPrice = this.removeDecimal(lineDiscount.discountedLinePrice || 0 + lineDiscount.discountAmount);
|
|
5903
5955
|
}
|
|
@@ -5907,8 +5959,82 @@
|
|
|
5907
5959
|
obj['ExtendedValue'] = ((lineDiscount.discountedLinePrice || 0) + lineDiscount.discountAmount);
|
|
5908
5960
|
obj['UnitPrice'] = ((lineDiscount.discountedLinePrice || 0) + lineDiscount.discountAmount);
|
|
5909
5961
|
}
|
|
5962
|
+
if (transactionDiscount) {
|
|
5963
|
+
obj['BasketDiscountModifier'] = [];
|
|
5964
|
+
this.transactionDocument.basket.transactionDiscount.forEach((/**
|
|
5965
|
+
* @param {?} e
|
|
5966
|
+
* @return {?}
|
|
5967
|
+
*/
|
|
5968
|
+
function (e) {
|
|
5969
|
+
/** @type {?} */
|
|
5970
|
+
var obj1 = {};
|
|
5971
|
+
e.itemLineIds.forEach((/**
|
|
5972
|
+
* @param {?} x
|
|
5973
|
+
* @return {?}
|
|
5974
|
+
*/
|
|
5975
|
+
function (x) {
|
|
5976
|
+
if (x == element.itemLineId) {
|
|
5977
|
+
/** @type {?} */
|
|
5978
|
+
var discountAmount = _this.convertToString(e.discountAmount * -1);
|
|
5979
|
+
obj1.XMLSchemaVersion = _this.xmlSchemaVersion;
|
|
5980
|
+
obj1.DiscountedValue = -(_this.getDiscountedValue(element.totalLinePrice, e.discountAmount).toFixed(0));
|
|
5981
|
+
obj1.BasketDiscountLineNumber = _this.getLineNumber(e, discountAmount);
|
|
5982
|
+
obj['BasketDiscountModifier'].push(obj1);
|
|
5983
|
+
}
|
|
5984
|
+
}));
|
|
5985
|
+
}));
|
|
5986
|
+
/** @type {?} */
|
|
5987
|
+
var totaltransactionDiscount = 0;
|
|
5988
|
+
obj['BasketDiscountModifier'].forEach((/**
|
|
5989
|
+
* @param {?} value
|
|
5990
|
+
* @return {?}
|
|
5991
|
+
*/
|
|
5992
|
+
function (value) {
|
|
5993
|
+
totaltransactionDiscount = totaltransactionDiscount + value.DiscountedValue;
|
|
5994
|
+
}));
|
|
5995
|
+
//update the product price
|
|
5996
|
+
obj['EffectiveNetValue'] = obj.EffectiveNetValue + totaltransactionDiscount;
|
|
5997
|
+
}
|
|
5910
5998
|
return obj;
|
|
5911
5999
|
};
|
|
6000
|
+
/**
|
|
6001
|
+
* @param {?} value
|
|
6002
|
+
* @param {?} discountAmount
|
|
6003
|
+
* @return {?}
|
|
6004
|
+
*/
|
|
6005
|
+
RJMapperBuilderClass.prototype.getLineNumber = /**
|
|
6006
|
+
* @param {?} value
|
|
6007
|
+
* @param {?} discountAmount
|
|
6008
|
+
* @return {?}
|
|
6009
|
+
*/
|
|
6010
|
+
function (value, discountAmount) {
|
|
6011
|
+
/** @type {?} */
|
|
6012
|
+
var lineNumber;
|
|
6013
|
+
for (var i = 0; i < this.rjObject['BasketDiscount'].length; i++) {
|
|
6014
|
+
/** @type {?} */
|
|
6015
|
+
var element = this.rjObject['BasketDiscount'][i];
|
|
6016
|
+
if (value.reasonCode === element.ReasonCodeID && discountAmount === element.NetValue) {
|
|
6017
|
+
lineNumber = element.LineNumber;
|
|
6018
|
+
break;
|
|
6019
|
+
}
|
|
6020
|
+
}
|
|
6021
|
+
return lineNumber;
|
|
6022
|
+
};
|
|
6023
|
+
/**
|
|
6024
|
+
* @param {?} price
|
|
6025
|
+
* @param {?} discountAmount
|
|
6026
|
+
* @return {?}
|
|
6027
|
+
*/
|
|
6028
|
+
RJMapperBuilderClass.prototype.getDiscountedValue = /**
|
|
6029
|
+
* @param {?} price
|
|
6030
|
+
* @param {?} discountAmount
|
|
6031
|
+
* @return {?}
|
|
6032
|
+
*/
|
|
6033
|
+
function (price, discountAmount) {
|
|
6034
|
+
/** @type {?} */
|
|
6035
|
+
var DiscountedValue = (price * discountAmount) / this.transactionDocument.basketSummary.saleTotal;
|
|
6036
|
+
return DiscountedValue;
|
|
6037
|
+
};
|
|
5912
6038
|
/**
|
|
5913
6039
|
* @param {?} element
|
|
5914
6040
|
* @param {?} VAT
|
|
@@ -5940,7 +6066,7 @@
|
|
|
5940
6066
|
return value;
|
|
5941
6067
|
}
|
|
5942
6068
|
catch (e) {
|
|
5943
|
-
console.log(value, '
|
|
6069
|
+
console.log(value, 'can not be converted in string', e);
|
|
5944
6070
|
}
|
|
5945
6071
|
};
|
|
5946
6072
|
/**
|