@pmcretail/mapper-library 0.0.12 → 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 +207 -68
- 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 +190 -68
- package/esm5/lib/RJ-mapper.class.js +208 -69
- package/fesm2015/pmcretail-mapper-library.js +189 -67
- package/fesm2015/pmcretail-mapper-library.js.map +1 -1
- package/fesm5/pmcretail-mapper-library.js +207 -68
- package/fesm5/pmcretail-mapper-library.js.map +1 -1
- package/lib/RJ-mapper.class.d.ts +7 -4
- 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'] =
|
|
4895
|
-
obj['EffectiveNetValue'] =
|
|
4896
|
-
obj['Description'] = element.
|
|
4898
|
+
obj['XMLSchemaVersion'] = (/** @type {?} */ (_this)).xmlSchemaVersion;
|
|
4899
|
+
obj['NetValue'] = (/** @type {?} */ (_this)).convertToString(element.discountAmount * -1);
|
|
4900
|
+
obj['EffectiveNetValue'] = (/** @type {?} */ (_this)).convertToString(element.discountAmount * -1);
|
|
4901
|
+
obj['Description'] = element.reasonDisplayText;
|
|
4897
4902
|
obj['UserID'] = (/** @type {?} */ (_this)).transactionDocument.userName;
|
|
4898
4903
|
obj['ReasonCodeID'] = element.reasonCode;
|
|
4899
|
-
obj['DiscountType'] = element.discountType.toUpperCase() == DISCOUNTTYPE.PERCENT.toUpperCase() ? 0 : 1;
|
|
4900
|
-
obj['RoundingRule'] = 2;
|
|
4901
|
-
obj['ModifiedLineNumber
|
|
4902
|
-
obj['LineNumber'] = (/** @type {?} */ (_this)).generateLineNumber();
|
|
4903
|
-
|
|
4904
|
-
|
|
4904
|
+
obj['DiscountType'] = (/** @type {?} */ (_this)).convertToString(element.discountType.toUpperCase() == DISCOUNTTYPE.PERCENT.toUpperCase() ? 0 : 1);
|
|
4905
|
+
obj['RoundingRule'] = (/** @type {?} */ (_this)).convertToString(2);
|
|
4906
|
+
obj['ModifiedLineNumber'] = element.itemLineIds;
|
|
4907
|
+
obj['LineNumber'] = (/** @type {?} */ (_this)).convertToString((/** @type {?} */ (_this)).generateLineNumber());
|
|
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));
|
|
@@ -4979,56 +4990,51 @@ var RJMapperBuilderClass = /** @class */ (function () {
|
|
|
4979
4990
|
obj['TaxPercentage'] = element.VAT.toFixed(2); // todo
|
|
4980
4991
|
(/** @type {?} */ (_this)).rjObject['Trailer']['TaxItem'].push(obj);
|
|
4981
4992
|
}));
|
|
4982
|
-
// TODO: make Trailer object from promotion
|
|
4983
|
-
(/** @type {?} */ (this)).
|
|
4984
|
-
|
|
4985
|
-
|
|
4986
|
-
|
|
4987
|
-
*/
|
|
4988
|
-
function (element) {
|
|
4989
|
-
/** @type {?} */
|
|
4990
|
-
var obj = {};
|
|
4991
|
-
obj['PromotionID'] = element.promotionId;
|
|
4992
|
-
obj['PromotionSaving'] = element.promotionAmount < 0 ? element.promotionAmount : -element.promotionAmount;
|
|
4993
|
-
obj['PromotionQuantity'] = ""; // todo - not avaialble
|
|
4994
|
-
obj['PromotionDescription'] = element.displayText;
|
|
4995
|
-
obj['PromotionHit']['XMLSchemaVersion'] = (/** @type {?} */ (_this)).transactionDocument.storeId;
|
|
4996
|
-
obj['PromotionHit']['HitNumber'] = ""; // todo;
|
|
4997
|
-
obj['PromotionHit']['HitQuantity'] = ""; // todo;
|
|
4998
|
-
obj['PromotionHit']['HitSaving'] = ""; // todo;
|
|
4999
|
-
obj['PromotionHit']['PromotionTrigger'] = [];
|
|
5000
|
-
element.trigger.forEach((/**
|
|
5001
|
-
* @param {?} subElement
|
|
4993
|
+
// TODO: make Trailer object from promotion
|
|
4994
|
+
if ((/** @type {?} */ (this)).transactionDocument.basket.linePromotion.length > 0) {
|
|
4995
|
+
(/** @type {?} */ (this)).rjObject['Trailer']['PromotionItem'] = [];
|
|
4996
|
+
(/** @type {?} */ (this)).transactionDocument.basket.linePromotion.forEach((/**
|
|
4997
|
+
* @param {?} element
|
|
5002
4998
|
* @return {?}
|
|
5003
4999
|
*/
|
|
5004
|
-
function (
|
|
5005
|
-
/** @type {?} */
|
|
5006
|
-
var objSub = {};
|
|
5000
|
+
function (element) {
|
|
5007
5001
|
/** @type {?} */
|
|
5008
|
-
var
|
|
5009
|
-
|
|
5010
|
-
|
|
5011
|
-
|
|
5012
|
-
|
|
5013
|
-
|
|
5014
|
-
|
|
5015
|
-
|
|
5002
|
+
var obj = {};
|
|
5003
|
+
obj['PromotionID'] = element.promotionId;
|
|
5004
|
+
obj['PromotionSaving'] = element.promotionAmount < 0 ? element.promotionAmount : -element.promotionAmount;
|
|
5005
|
+
obj['PromotionQuantity'] = ""; // todo - not avaialble
|
|
5006
|
+
obj['PromotionDescription'] = element.displayText;
|
|
5007
|
+
obj['PromotionHit'] = {};
|
|
5008
|
+
obj['PromotionHit']['XMLSchemaVersion'] = (/** @type {?} */ (_this)).xmlSchemaVersion;
|
|
5009
|
+
obj['PromotionHit']['HitNumber'] = ""; // todo;
|
|
5010
|
+
obj['PromotionHit']['HitQuantity'] = ""; // todo;
|
|
5011
|
+
obj['PromotionHit']['HitSaving'] = ""; // todo;
|
|
5012
|
+
obj['PromotionHit']['PromotionTrigger'] = {};
|
|
5013
|
+
element.trigger.forEach((/**
|
|
5014
|
+
* @param {?} subElement
|
|
5016
5015
|
* @return {?}
|
|
5017
5016
|
*/
|
|
5018
|
-
function (
|
|
5019
|
-
|
|
5020
|
-
|
|
5021
|
-
|
|
5022
|
-
|
|
5023
|
-
|
|
5024
|
-
|
|
5025
|
-
|
|
5026
|
-
|
|
5027
|
-
|
|
5017
|
+
function (subElement) {
|
|
5018
|
+
/** @type {?} */
|
|
5019
|
+
var product = (/** @type {?} */ (_this)).transactionDocument.basket.products.find((/**
|
|
5020
|
+
* @param {?} item
|
|
5021
|
+
* @return {?}
|
|
5022
|
+
*/
|
|
5023
|
+
function (item) { return item.itemLineId == subElement.itemLineId; }));
|
|
5024
|
+
obj['PromotionHit']['PromotionTrigger']['XMLSchemaVersion'] = (/** @type {?} */ (_this)).xmlSchemaVersion;
|
|
5025
|
+
obj['PromotionHit']['PromotionTrigger']['ProductID'] = product.SKU;
|
|
5026
|
+
obj['PromotionHit']['PromotionTrigger']['UnitValue'] = (/** @type {?} */ (_this)).convertToString(element.promotionLinePrice / product.quantity);
|
|
5027
|
+
obj['PromotionHit']['PromotionTrigger']['LineNumber'] = (/** @type {?} */ (_this)).convertToString(subElement.itemLineId);
|
|
5028
|
+
obj['PromotionHit']['PromotionTrigger']['Quantity'] = (/** @type {?} */ (_this)).convertToString(subElement.quantity.toFixed(1));
|
|
5029
|
+
obj['PromotionHit']['PromotionTrigger']['TaxCode'] = (/** @type {?} */ (_this)).transactionDocument.basket.taxBreakdown.taxLines.find((/**
|
|
5030
|
+
* @param {?} item
|
|
5031
|
+
* @return {?}
|
|
5032
|
+
*/
|
|
5033
|
+
function (item) { return item.itemLineId == element.itemLineId; })).VATCode; // todo
|
|
5034
|
+
}));
|
|
5035
|
+
(/** @type {?} */ (_this)).rjObject['Trailer']['PromotionItem'].push(obj);
|
|
5028
5036
|
}));
|
|
5029
|
-
|
|
5030
|
-
}));
|
|
5031
|
-
//console.log(this.rjObject);
|
|
5037
|
+
}
|
|
5032
5038
|
return (/** @type {?} */ (this));
|
|
5033
5039
|
};
|
|
5034
5040
|
/**
|
|
@@ -5375,16 +5381,14 @@ var RJMapperBuilderClass = /** @class */ (function () {
|
|
|
5375
5381
|
/**
|
|
5376
5382
|
* @template THIS
|
|
5377
5383
|
* @this {THIS}
|
|
5378
|
-
* @param {?} value
|
|
5379
5384
|
* @return {THIS}
|
|
5380
5385
|
*/
|
|
5381
5386
|
RJMapperBuilderClass.prototype.setCashierID = /**
|
|
5382
5387
|
* @template THIS
|
|
5383
5388
|
* @this {THIS}
|
|
5384
|
-
* @param {?} value
|
|
5385
5389
|
* @return {THIS}
|
|
5386
5390
|
*/
|
|
5387
|
-
function (
|
|
5391
|
+
function () {
|
|
5388
5392
|
(/** @type {?} */ (this)).cashierId = ((/** @type {?} */ (this)).transactionDocument && (/** @type {?} */ (this)).transactionDocument.userName) ? (/** @type {?} */ (this)).transactionDocument.userName : '';
|
|
5389
5393
|
return (/** @type {?} */ (this));
|
|
5390
5394
|
};
|
|
@@ -5524,14 +5528,17 @@ var RJMapperBuilderClass = /** @class */ (function () {
|
|
|
5524
5528
|
/**
|
|
5525
5529
|
* @param {?} element
|
|
5526
5530
|
* @param {?} lineDiscount
|
|
5531
|
+
* @param {?} transactionDiscount
|
|
5527
5532
|
* @return {?}
|
|
5528
5533
|
*/
|
|
5529
5534
|
RJMapperBuilderClass.prototype.returnProduct = /**
|
|
5530
5535
|
* @param {?} element
|
|
5531
5536
|
* @param {?} lineDiscount
|
|
5537
|
+
* @param {?} transactionDiscount
|
|
5532
5538
|
* @return {?}
|
|
5533
5539
|
*/
|
|
5534
|
-
function (element, lineDiscount) {
|
|
5540
|
+
function (element, lineDiscount, transactionDiscount) {
|
|
5541
|
+
var _this = this;
|
|
5535
5542
|
/** @type {?} */
|
|
5536
5543
|
var obj = {};
|
|
5537
5544
|
/** @type {?} */
|
|
@@ -5550,7 +5557,7 @@ var RJMapperBuilderClass = /** @class */ (function () {
|
|
|
5550
5557
|
obj['DateTimeCreated'] = this.createdAt;
|
|
5551
5558
|
obj['ExtendedValue'] = this.removeDecimal(element['totalLinePrice'] * -1);
|
|
5552
5559
|
obj['UnitPrice'] = this.removeDecimal(element['price']);
|
|
5553
|
-
obj['Quantity'] =
|
|
5560
|
+
obj['Quantity'] = this.getQuantity(element);
|
|
5554
5561
|
obj['OriginalTaxAmountSet'] = 1;
|
|
5555
5562
|
obj['ProductID'] = element['SKU'];
|
|
5556
5563
|
obj['HandKeyed'] = 1;
|
|
@@ -5558,7 +5565,7 @@ var RJMapperBuilderClass = /** @class */ (function () {
|
|
|
5558
5565
|
obj['Return'] = {};
|
|
5559
5566
|
obj['Return']['ReturnReasonID'] = element['refundedReason'];
|
|
5560
5567
|
obj['Return']['ReturnDescription'] = element['refundedReasonDescription'];
|
|
5561
|
-
obj['Return']['ReturnToStock'] =
|
|
5568
|
+
obj['Return']['ReturnToStock'] = this.getQuantity(element);
|
|
5562
5569
|
obj['TaxCode'] = this.transactionDocument.basket['taxBreakdown']['taxLines'].find((/**
|
|
5563
5570
|
* @param {?} item
|
|
5564
5571
|
* @return {?}
|
|
@@ -5606,19 +5613,58 @@ var RJMapperBuilderClass = /** @class */ (function () {
|
|
|
5606
5613
|
obj.ExtendedValue = ((lineDiscount.discountedLinePrice || 0) + lineDiscount.discountAmount) * -1;
|
|
5607
5614
|
obj.UnitPrice = ((lineDiscount.discountedLinePrice || 0) + lineDiscount.discountAmount) * -1;
|
|
5608
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
|
+
}
|
|
5609
5652
|
return obj;
|
|
5610
5653
|
};
|
|
5611
5654
|
/**
|
|
5612
5655
|
* @param {?} element
|
|
5613
5656
|
* @param {?} lineDiscount
|
|
5657
|
+
* @param {?} transactionDiscount
|
|
5614
5658
|
* @return {?}
|
|
5615
5659
|
*/
|
|
5616
5660
|
RJMapperBuilderClass.prototype.addProduct = /**
|
|
5617
5661
|
* @param {?} element
|
|
5618
5662
|
* @param {?} lineDiscount
|
|
5663
|
+
* @param {?} transactionDiscount
|
|
5619
5664
|
* @return {?}
|
|
5620
5665
|
*/
|
|
5621
|
-
function (element, lineDiscount) {
|
|
5666
|
+
function (element, lineDiscount, transactionDiscount) {
|
|
5667
|
+
var _this = this;
|
|
5622
5668
|
/** @type {?} */
|
|
5623
5669
|
var taxTotal = this.transactionDocument.basket['taxBreakdown']['taxLines'].find((/**
|
|
5624
5670
|
* @param {?} item
|
|
@@ -5683,7 +5729,7 @@ var RJMapperBuilderClass = /** @class */ (function () {
|
|
|
5683
5729
|
obj['PriceOverride'].ModifierReasonID = lineDiscount.priceOverrideReasonCode;
|
|
5684
5730
|
obj['PriceOverride'].ModifierReasonDescription = lineDiscount.priceOverrideReasonName;
|
|
5685
5731
|
obj['PriceOverride'].AuthorisingUserID = this.transactionDocument.userName;
|
|
5686
|
-
obj['PriceOverride'].XMLSchemaVersion =
|
|
5732
|
+
obj['PriceOverride'].XMLSchemaVersion = this.xmlSchemaVersion;
|
|
5687
5733
|
obj['PriceOverride'].NewPrice = this.removeDecimal(lineDiscount.unitPrice);
|
|
5688
5734
|
obj['PriceOverride'].OriginalPrice = this.removeDecimal(lineDiscount.discountedLinePrice || 0 + lineDiscount.discountAmount);
|
|
5689
5735
|
}
|
|
@@ -5693,8 +5739,82 @@ var RJMapperBuilderClass = /** @class */ (function () {
|
|
|
5693
5739
|
obj['ExtendedValue'] = ((lineDiscount.discountedLinePrice || 0) + lineDiscount.discountAmount);
|
|
5694
5740
|
obj['UnitPrice'] = ((lineDiscount.discountedLinePrice || 0) + lineDiscount.discountAmount);
|
|
5695
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
|
+
}
|
|
5696
5778
|
return obj;
|
|
5697
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
|
+
};
|
|
5698
5818
|
/**
|
|
5699
5819
|
* @param {?} element
|
|
5700
5820
|
* @param {?} VAT
|
|
@@ -5726,7 +5846,7 @@ var RJMapperBuilderClass = /** @class */ (function () {
|
|
|
5726
5846
|
return value;
|
|
5727
5847
|
}
|
|
5728
5848
|
catch (e) {
|
|
5729
|
-
console.log(value, '
|
|
5849
|
+
console.log(value, 'can not be converted in string', e);
|
|
5730
5850
|
}
|
|
5731
5851
|
};
|
|
5732
5852
|
/**
|
|
@@ -5831,6 +5951,25 @@ var RJMapperBuilderClass = /** @class */ (function () {
|
|
|
5831
5951
|
this.rjObject['BasketDiscount']['RoundingRule'] = 2;
|
|
5832
5952
|
}
|
|
5833
5953
|
};
|
|
5954
|
+
/**
|
|
5955
|
+
* @param {?} element
|
|
5956
|
+
* @return {?}
|
|
5957
|
+
*/
|
|
5958
|
+
RJMapperBuilderClass.prototype.getQuantity = /**
|
|
5959
|
+
* @param {?} element
|
|
5960
|
+
* @return {?}
|
|
5961
|
+
*/
|
|
5962
|
+
function (element) {
|
|
5963
|
+
/** @type {?} */
|
|
5964
|
+
var quantity;
|
|
5965
|
+
if (this.transactionDocument.unreferencedRefund) {
|
|
5966
|
+
quantity = element['quantity'] < 0 ? element['quantity'].toFixed(1) : (-element['quantity']).toFixed(1);
|
|
5967
|
+
}
|
|
5968
|
+
else {
|
|
5969
|
+
quantity = element['refundedQuantity'] < 0 ? element['refundedQuantity'].toFixed(1) : (-element['refundedQuantity']).toFixed(1);
|
|
5970
|
+
}
|
|
5971
|
+
return quantity;
|
|
5972
|
+
};
|
|
5834
5973
|
return RJMapperBuilderClass;
|
|
5835
5974
|
}());
|
|
5836
5975
|
if (false) {
|