@pmcretail/mapper-library 0.0.11 → 0.0.13
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 +111 -70
- 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 +104 -70
- package/esm5/lib/RJ-mapper.class.js +112 -71
- package/fesm2015/pmcretail-mapper-library.js +103 -69
- package/fesm2015/pmcretail-mapper-library.js.map +1 -1
- package/fesm5/pmcretail-mapper-library.js +111 -70
- package/fesm5/pmcretail-mapper-library.js.map +1 -1
- package/lib/RJ-mapper.class.d.ts +5 -4
- package/package.json +1 -1
- package/pmcretail-mapper-library.metadata.json +1 -1
|
@@ -4906,8 +4906,8 @@
|
|
|
4906
4906
|
}
|
|
4907
4907
|
this.initilizeItemCount();
|
|
4908
4908
|
this.setLineNumberForProducts();
|
|
4909
|
-
this.createdAt = this.
|
|
4910
|
-
this.updatedAt = this.
|
|
4909
|
+
this.createdAt = this.getDate(this.transactionDocument.createdAt);
|
|
4910
|
+
this.updatedAt = this.getDate(this.transactionDocument.updatedAt);
|
|
4911
4911
|
}
|
|
4912
4912
|
/**
|
|
4913
4913
|
* @template THIS
|
|
@@ -5007,6 +5007,12 @@
|
|
|
5007
5007
|
(/** @type {?} */ (_this)).rjObject['ProductSale'].push(data);
|
|
5008
5008
|
(/** @type {?} */ (_this)).getModifierItem(lineDiscount.length > 0 ? lineDiscount[0] : null, element.itemLineId);
|
|
5009
5009
|
}));
|
|
5010
|
+
/** @type {?} */
|
|
5011
|
+
var transactionPromotion = [];
|
|
5012
|
+
if ((/** @type {?} */ (this)).transactionDocument.basket.transactionPromotion && (/** @type {?} */ (this)).transactionDocument.basket.transactionPromotion.length > 0) {
|
|
5013
|
+
transactionPromotion = (/** @type {?} */ (this)).transactionDocument.basket.transactionPromotion;
|
|
5014
|
+
(/** @type {?} */ (this)).getTransactionPromotion(transactionPromotion);
|
|
5015
|
+
}
|
|
5010
5016
|
}
|
|
5011
5017
|
else if ((/** @type {?} */ (this)).transactionDocument.type === TRANSACTION_TYPE.REFUND) {
|
|
5012
5018
|
(/** @type {?} */ (this)).rjObject['ProductReturn'] = [];
|
|
@@ -5094,9 +5100,9 @@
|
|
|
5094
5100
|
*/
|
|
5095
5101
|
function () {
|
|
5096
5102
|
var _this = this;
|
|
5097
|
-
(/** @type {?} */ (this)).rjObject['BasketDiscount'] = [];
|
|
5098
5103
|
if (!(/** @type {?} */ (this)).transactionDocument.basket.transactionDiscount)
|
|
5099
5104
|
return (/** @type {?} */ (this));
|
|
5105
|
+
(/** @type {?} */ (this)).rjObject['BasketDiscount'] = [];
|
|
5100
5106
|
(/** @type {?} */ (this)).transactionDocument.basket.transactionDiscount.forEach((/**
|
|
5101
5107
|
* @param {?} element
|
|
5102
5108
|
* @return {?}
|
|
@@ -5104,16 +5110,16 @@
|
|
|
5104
5110
|
function (element) {
|
|
5105
5111
|
/** @type {?} */
|
|
5106
5112
|
var obj = {};
|
|
5107
|
-
obj['XMLSchemaVersion'] = 1;
|
|
5108
|
-
obj['NetValue'] = element.discountAmount < 0 ? element.discountAmount : -element.discountAmount;
|
|
5109
|
-
obj['EffectiveNetValue'] = element.discountAmount < 0 ? element.discountAmount : -element.discountAmount;
|
|
5110
|
-
obj['Description'] = element.
|
|
5113
|
+
obj['XMLSchemaVersion'] = "1";
|
|
5114
|
+
obj['NetValue'] = (/** @type {?} */ (_this)).convertToString(element.discountAmount < 0 ? element.discountAmount : -element.discountAmount);
|
|
5115
|
+
obj['EffectiveNetValue'] = (/** @type {?} */ (_this)).convertToString(element.discountAmount < 0 ? element.discountAmount : -element.discountAmount);
|
|
5116
|
+
obj['Description'] = element.reasonDisplayText;
|
|
5111
5117
|
obj['UserID'] = (/** @type {?} */ (_this)).transactionDocument.userName;
|
|
5112
5118
|
obj['ReasonCodeID'] = element.reasonCode;
|
|
5113
|
-
obj['DiscountType'] = element.discountType.toUpperCase() == DISCOUNTTYPE.PERCENT.toUpperCase() ? 0 : 1; // todo - compare values
|
|
5114
|
-
obj['RoundingRule'] = 2;
|
|
5115
|
-
obj['ModifiedLineNumber
|
|
5116
|
-
obj['LineNumber'] = (/** @type {?} */ (_this)).generateLineNumber();
|
|
5119
|
+
obj['DiscountType'] = (/** @type {?} */ (_this)).convertToString(element.discountType.toUpperCase() == DISCOUNTTYPE.PERCENT.toUpperCase() ? 0 : 1); // todo - compare values
|
|
5120
|
+
obj['RoundingRule'] = (/** @type {?} */ (_this)).convertToString(2);
|
|
5121
|
+
obj['ModifiedLineNumber'] = element.itemLineIds;
|
|
5122
|
+
obj['LineNumber'] = (/** @type {?} */ (_this)).convertToString((/** @type {?} */ (_this)).generateLineNumber());
|
|
5117
5123
|
// obj['DiscountedValue'] = obj['discountAmount'] // todo - confirm value before discount;
|
|
5118
5124
|
// obj['DiscountPercentage'] = obj['discountAmount'] / 100 ; // todo - optional
|
|
5119
5125
|
(/** @type {?} */ (_this)).rjObject['BasketDiscount'].push(obj);
|
|
@@ -5193,56 +5199,52 @@
|
|
|
5193
5199
|
obj['TaxPercentage'] = element.VAT.toFixed(2); // todo
|
|
5194
5200
|
(/** @type {?} */ (_this)).rjObject['Trailer']['TaxItem'].push(obj);
|
|
5195
5201
|
}));
|
|
5196
|
-
// TODO: make Trailer object from promotion
|
|
5197
|
-
(/** @type {?} */ (this)).
|
|
5198
|
-
|
|
5199
|
-
|
|
5200
|
-
|
|
5201
|
-
*/
|
|
5202
|
-
function (element) {
|
|
5203
|
-
/** @type {?} */
|
|
5204
|
-
var obj = {};
|
|
5205
|
-
obj['PromotionID'] = element.promotionId;
|
|
5206
|
-
obj['PromotionSaving'] = element.promotionAmount < 0 ? element.promotionAmount : -element.promotionAmount;
|
|
5207
|
-
obj['PromotionQuantity'] = ""; // todo - not avaialble
|
|
5208
|
-
obj['PromotionDescription'] = element.displayText;
|
|
5209
|
-
obj['PromotionHit']['XMLSchemaVersion'] = (/** @type {?} */ (_this)).transactionDocument.storeId;
|
|
5210
|
-
obj['PromotionHit']['HitNumber'] = ""; // todo;
|
|
5211
|
-
obj['PromotionHit']['HitQuantity'] = ""; // todo;
|
|
5212
|
-
obj['PromotionHit']['HitSaving'] = ""; // todo;
|
|
5213
|
-
obj['PromotionHit']['PromotionTrigger'] = [];
|
|
5214
|
-
element.trigger.forEach((/**
|
|
5215
|
-
* @param {?} subElement
|
|
5202
|
+
// TODO: make Trailer object from promotion
|
|
5203
|
+
if ((/** @type {?} */ (this)).transactionDocument.basket.linePromotion.length > 0) {
|
|
5204
|
+
(/** @type {?} */ (this)).rjObject['Trailer']['PromotionItem'] = [];
|
|
5205
|
+
(/** @type {?} */ (this)).transactionDocument.basket.linePromotion.forEach((/**
|
|
5206
|
+
* @param {?} element
|
|
5216
5207
|
* @return {?}
|
|
5217
5208
|
*/
|
|
5218
|
-
function (
|
|
5219
|
-
|
|
5220
|
-
var objSub = {};
|
|
5209
|
+
function (element) {
|
|
5210
|
+
console.log('element', element);
|
|
5221
5211
|
/** @type {?} */
|
|
5222
|
-
var
|
|
5223
|
-
|
|
5224
|
-
|
|
5225
|
-
|
|
5226
|
-
|
|
5227
|
-
|
|
5228
|
-
|
|
5229
|
-
|
|
5230
|
-
|
|
5231
|
-
|
|
5232
|
-
|
|
5233
|
-
|
|
5234
|
-
|
|
5235
|
-
objSub['Quantity'] = (/** @type {?} */ (_this)).convertToString(subElement.quantity.toFixed(1));
|
|
5236
|
-
objSub['TaxCode'] = (/** @type {?} */ (_this)).transactionDocument.basket.taxBreakdown.taxLines.find((/**
|
|
5237
|
-
* @param {?} item
|
|
5212
|
+
var obj = {};
|
|
5213
|
+
obj['PromotionID'] = element.promotionId;
|
|
5214
|
+
obj['PromotionSaving'] = element.promotionAmount < 0 ? element.promotionAmount : -element.promotionAmount;
|
|
5215
|
+
obj['PromotionQuantity'] = ""; // todo - not avaialble
|
|
5216
|
+
obj['PromotionDescription'] = element.displayText;
|
|
5217
|
+
obj['PromotionHit'] = {};
|
|
5218
|
+
obj['PromotionHit']['XMLSchemaVersion'] = (/** @type {?} */ (_this)).xmlSchemaVersion;
|
|
5219
|
+
obj['PromotionHit']['HitNumber'] = ""; // todo;
|
|
5220
|
+
obj['PromotionHit']['HitQuantity'] = ""; // todo;
|
|
5221
|
+
obj['PromotionHit']['HitSaving'] = ""; // todo;
|
|
5222
|
+
obj['PromotionHit']['PromotionTrigger'] = {};
|
|
5223
|
+
element.trigger.forEach((/**
|
|
5224
|
+
* @param {?} subElement
|
|
5238
5225
|
* @return {?}
|
|
5239
5226
|
*/
|
|
5240
|
-
function (
|
|
5241
|
-
|
|
5227
|
+
function (subElement) {
|
|
5228
|
+
/** @type {?} */
|
|
5229
|
+
var product = (/** @type {?} */ (_this)).transactionDocument.basket.products.find((/**
|
|
5230
|
+
* @param {?} item
|
|
5231
|
+
* @return {?}
|
|
5232
|
+
*/
|
|
5233
|
+
function (item) { return item.itemLineId == subElement.itemLineId; }));
|
|
5234
|
+
obj['PromotionHit']['PromotionTrigger']['XMLSchemaVersion'] = (/** @type {?} */ (_this)).xmlSchemaVersion;
|
|
5235
|
+
obj['PromotionHit']['PromotionTrigger']['ProductID'] = product.SKU;
|
|
5236
|
+
obj['PromotionHit']['PromotionTrigger']['UnitValue'] = (/** @type {?} */ (_this)).convertToString(element.promotionLinePrice / product.quantity);
|
|
5237
|
+
obj['PromotionHit']['PromotionTrigger']['LineNumber'] = (/** @type {?} */ (_this)).convertToString(subElement.itemLineId);
|
|
5238
|
+
obj['PromotionHit']['PromotionTrigger']['Quantity'] = (/** @type {?} */ (_this)).convertToString(subElement.quantity.toFixed(1));
|
|
5239
|
+
obj['PromotionHit']['PromotionTrigger']['TaxCode'] = (/** @type {?} */ (_this)).transactionDocument.basket.taxBreakdown.taxLines.find((/**
|
|
5240
|
+
* @param {?} item
|
|
5241
|
+
* @return {?}
|
|
5242
|
+
*/
|
|
5243
|
+
function (item) { return item.itemLineId == element.itemLineId; })).VATCode; // todo
|
|
5244
|
+
}));
|
|
5245
|
+
(/** @type {?} */ (_this)).rjObject['Trailer']['PromotionItem'].push(obj);
|
|
5242
5246
|
}));
|
|
5243
|
-
|
|
5244
|
-
}));
|
|
5245
|
-
//console.log(this.rjObject);
|
|
5247
|
+
}
|
|
5246
5248
|
return (/** @type {?} */ (this));
|
|
5247
5249
|
};
|
|
5248
5250
|
/**
|
|
@@ -5589,16 +5591,14 @@
|
|
|
5589
5591
|
/**
|
|
5590
5592
|
* @template THIS
|
|
5591
5593
|
* @this {THIS}
|
|
5592
|
-
* @param {?} value
|
|
5593
5594
|
* @return {THIS}
|
|
5594
5595
|
*/
|
|
5595
5596
|
RJMapperBuilderClass.prototype.setCashierID = /**
|
|
5596
5597
|
* @template THIS
|
|
5597
5598
|
* @this {THIS}
|
|
5598
|
-
* @param {?} value
|
|
5599
5599
|
* @return {THIS}
|
|
5600
5600
|
*/
|
|
5601
|
-
function (
|
|
5601
|
+
function () {
|
|
5602
5602
|
(/** @type {?} */ (this)).cashierId = ((/** @type {?} */ (this)).transactionDocument && (/** @type {?} */ (this)).transactionDocument.userName) ? (/** @type {?} */ (this)).transactionDocument.userName : '';
|
|
5603
5603
|
return (/** @type {?} */ (this));
|
|
5604
5604
|
};
|
|
@@ -5764,7 +5764,7 @@
|
|
|
5764
5764
|
obj['DateTimeCreated'] = this.createdAt;
|
|
5765
5765
|
obj['ExtendedValue'] = this.removeDecimal(element['totalLinePrice'] * -1);
|
|
5766
5766
|
obj['UnitPrice'] = this.removeDecimal(element['price']);
|
|
5767
|
-
obj['Quantity'] =
|
|
5767
|
+
obj['Quantity'] = this.getQuantity(element);
|
|
5768
5768
|
obj['OriginalTaxAmountSet'] = 1;
|
|
5769
5769
|
obj['ProductID'] = element['SKU'];
|
|
5770
5770
|
obj['HandKeyed'] = 1;
|
|
@@ -5772,7 +5772,7 @@
|
|
|
5772
5772
|
obj['Return'] = {};
|
|
5773
5773
|
obj['Return']['ReturnReasonID'] = element['refundedReason'];
|
|
5774
5774
|
obj['Return']['ReturnDescription'] = element['refundedReasonDescription'];
|
|
5775
|
-
obj['Return']['ReturnToStock'] =
|
|
5775
|
+
obj['Return']['ReturnToStock'] = this.getQuantity(element);
|
|
5776
5776
|
obj['TaxCode'] = this.transactionDocument.basket['taxBreakdown']['taxLines'].find((/**
|
|
5777
5777
|
* @param {?} item
|
|
5778
5778
|
* @return {?}
|
|
@@ -5784,7 +5784,7 @@
|
|
|
5784
5784
|
obj['MMGroupID'] = this.getAttributes();
|
|
5785
5785
|
obj['CustomerDetails'] = ""; // todo - blank
|
|
5786
5786
|
obj['TotalPromotionSaving'] = element['promotionAmount'] || -1; // TODO
|
|
5787
|
-
obj['OriginalTaxAmount'] = this.convertToString(this.
|
|
5787
|
+
obj['OriginalTaxAmount'] = this.convertToString(this.getOriginalTax(element, taxTotal.VAT) * -1);
|
|
5788
5788
|
obj['taxAmount'] = taxTotal.taxLineTotal < 0 ? (taxTotal.taxLineTotal) : (-taxTotal.taxLineTotal);
|
|
5789
5789
|
if (lineDiscount) {
|
|
5790
5790
|
if (lineDiscount.percentageDiscountReasonName && lineDiscount.percentageDiscountReasonCode) {
|
|
@@ -5863,7 +5863,7 @@
|
|
|
5863
5863
|
function (item) { return item.itemLineId == element['itemLineId']; })).VATCode,
|
|
5864
5864
|
TaxModifiable: 1,
|
|
5865
5865
|
//todo
|
|
5866
|
-
OriginalTaxAmount: this.convertToString(this.
|
|
5866
|
+
OriginalTaxAmount: this.convertToString(this.getOriginalTax(element, taxTotal.VAT)),
|
|
5867
5867
|
TaxAmount: this.convertToString(taxTotal.taxLineTotal),
|
|
5868
5868
|
OriginalTaxAmountSet: 1,
|
|
5869
5869
|
//todo
|
|
@@ -5914,7 +5914,7 @@
|
|
|
5914
5914
|
* @param {?} VAT
|
|
5915
5915
|
* @return {?}
|
|
5916
5916
|
*/
|
|
5917
|
-
RJMapperBuilderClass.prototype.
|
|
5917
|
+
RJMapperBuilderClass.prototype.getOriginalTax = /**
|
|
5918
5918
|
* @param {?} element
|
|
5919
5919
|
* @param {?} VAT
|
|
5920
5920
|
* @return {?}
|
|
@@ -5996,7 +5996,7 @@
|
|
|
5996
5996
|
* @param {?} date
|
|
5997
5997
|
* @return {?}
|
|
5998
5998
|
*/
|
|
5999
|
-
RJMapperBuilderClass.prototype.
|
|
5999
|
+
RJMapperBuilderClass.prototype.getDate = /**
|
|
6000
6000
|
* @param {?} date
|
|
6001
6001
|
* @return {?}
|
|
6002
6002
|
*/
|
|
@@ -6015,9 +6015,55 @@
|
|
|
6015
6015
|
/** @type {?} */
|
|
6016
6016
|
var newdate = date.substring(0, 19);
|
|
6017
6017
|
/** @type {?} */
|
|
6018
|
-
var x = (newdate + offsetSign + offsetHours + ':' + offsetMinutes).toString();
|
|
6018
|
+
var x = (newdate + offsetSign + String(offsetHours).padStart(2, '0') + ':' + String(offsetMinutes).padStart(2, '0')).toString();
|
|
6019
6019
|
return x;
|
|
6020
6020
|
};
|
|
6021
|
+
/**
|
|
6022
|
+
* @param {?} transactionPromotion
|
|
6023
|
+
* @return {?}
|
|
6024
|
+
*/
|
|
6025
|
+
RJMapperBuilderClass.prototype.getTransactionPromotion = /**
|
|
6026
|
+
* @param {?} transactionPromotion
|
|
6027
|
+
* @return {?}
|
|
6028
|
+
*/
|
|
6029
|
+
function (transactionPromotion) {
|
|
6030
|
+
if (transactionPromotion && transactionPromotion.length > 0) {
|
|
6031
|
+
this.rjObject['BasketDiscount'] = {};
|
|
6032
|
+
this.rjObject['BasketDiscount']['XMLSchemaVersion'] = 1;
|
|
6033
|
+
this.rjObject['BasketDiscount']['LineNumber'] = this.generateLineNumber();
|
|
6034
|
+
this.rjObject['BasketDiscount']['NetValue'] = this.removeDecimal(transactionPromotion[0].promotionLinePrice) * -1;
|
|
6035
|
+
this.rjObject['BasketDiscount']['EffectiveNetValue'] = this.removeDecimal(transactionPromotion[0].promotionLinePrice) * -1;
|
|
6036
|
+
this.rjObject['BasketDiscount']['Description'] = transactionPromotion[0].promotionInfo;
|
|
6037
|
+
this.rjObject['BasketDiscount']['DeviceID'] = this.deviceId;
|
|
6038
|
+
this.rjObject['BasketDiscount']['UserID'] = this.transactionDocument.userName;
|
|
6039
|
+
this.rjObject['BasketDiscount']['DateTimeCreated'] = this.createdAt;
|
|
6040
|
+
this.rjObject['BasketDiscount']['ModifiedLineNumber'] = transactionPromotion[0].itemLineIds;
|
|
6041
|
+
this.rjObject['BasketDiscount']['ReasonCodeID'] = 0;
|
|
6042
|
+
this.rjObject['BasketDiscount']['DiscountType'] = transactionPromotion[0].promotionType == 'TRANSACTION_OFF' ? 1 : 0;
|
|
6043
|
+
this.rjObject['BasketDiscount']['DiscountPercentage'] = 0; //todo
|
|
6044
|
+
this.rjObject['BasketDiscount']['DiscountedValue'] = 0; //todo
|
|
6045
|
+
this.rjObject['BasketDiscount']['RoundingRule'] = 2;
|
|
6046
|
+
}
|
|
6047
|
+
};
|
|
6048
|
+
/**
|
|
6049
|
+
* @param {?} element
|
|
6050
|
+
* @return {?}
|
|
6051
|
+
*/
|
|
6052
|
+
RJMapperBuilderClass.prototype.getQuantity = /**
|
|
6053
|
+
* @param {?} element
|
|
6054
|
+
* @return {?}
|
|
6055
|
+
*/
|
|
6056
|
+
function (element) {
|
|
6057
|
+
/** @type {?} */
|
|
6058
|
+
var quantity;
|
|
6059
|
+
if (this.transactionDocument.unreferencedRefund) {
|
|
6060
|
+
quantity = element['quantity'] < 0 ? element['quantity'].toFixed(1) : (-element['quantity']).toFixed(1);
|
|
6061
|
+
}
|
|
6062
|
+
else {
|
|
6063
|
+
quantity = element['refundedQuantity'] < 0 ? element['refundedQuantity'].toFixed(1) : (-element['refundedQuantity']).toFixed(1);
|
|
6064
|
+
}
|
|
6065
|
+
return quantity;
|
|
6066
|
+
};
|
|
6021
6067
|
return RJMapperBuilderClass;
|
|
6022
6068
|
}());
|
|
6023
6069
|
if (false) {
|
|
@@ -6141,11 +6187,6 @@
|
|
|
6141
6187
|
* @private
|
|
6142
6188
|
*/
|
|
6143
6189
|
RJMapperBuilderClass.prototype.rjObject;
|
|
6144
|
-
/**
|
|
6145
|
-
* @type {?}
|
|
6146
|
-
* @private
|
|
6147
|
-
*/
|
|
6148
|
-
RJMapperBuilderClass.prototype.paymentTypes;
|
|
6149
6190
|
}
|
|
6150
6191
|
|
|
6151
6192
|
exports.MapperLibraryComponent = MapperLibraryComponent;
|