@pmcretail/mapper-library 0.0.44 → 0.0.45

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.
@@ -1,6 +1,7 @@
1
1
  import * as i0 from '@angular/core';
2
2
  import { Component, NgModule, Injectable } from '@angular/core';
3
3
  import { BehaviorSubject } from 'rxjs';
4
+ import { AppLoggerService } from '@pmcretail/common-services/common/app-logger.service';
4
5
  import * as i1 from '@angular/common';
5
6
 
6
7
  class MapperLibraryComponent {
@@ -103,6 +104,7 @@ class BasketService {
103
104
  this.peerSync = this.peerSource.asObservable();
104
105
  this.scanSource = new BehaviorSubject(false);
105
106
  this.scanner = this.scanSource.asObservable();
107
+ this.className = "BasketService";
106
108
  }
107
109
  get isMixedBasketSales() {
108
110
  return this._isMixedBasketSales;
@@ -129,7 +131,9 @@ class BasketService {
129
131
  this.numberUtilService.trimTo2Decimal(basketDetails.total) +
130
132
  this.numberUtilService.trimTo2Decimal(p.total);
131
133
  }
132
- console.log("e:basket :basket service : basketDetails updated values for transaction id", basketDetails.transactionId, JSON.stringify(basketDetails));
134
+ AppLoggerService.logDebug(this.className, "updateBasketTotal", `basketDetails updated values for transaction id
135
+ ${basketDetails.transactionId}, basketDetails
136
+ ${JSON.stringify(basketDetails)}`);
133
137
  basketDetails.basketTotal = basketDetails.total;
134
138
  basketState.updateBasket(basketDetails);
135
139
  }
@@ -139,7 +143,9 @@ class BasketService {
139
143
  * @returns basketDetails
140
144
  */
141
145
  addlinePromotion(promotionList, basketDetails) {
142
- console.log("e:basket :basket Service : promotionList and basketDetails for linePromotions", JSON.stringify(promotionList), JSON.stringify(basketDetails));
146
+ AppLoggerService.logDebug(this.className, "addlinePromotion", `promotionList ${JSON.stringify(promotionList)} and
147
+ basketDetails
148
+ ${JSON.stringify(basketDetails)} for linePromotions`);
143
149
  if (promotionList &&
144
150
  promotionList.result &&
145
151
  promotionList.result.linePromotions &&
@@ -161,7 +167,9 @@ class BasketService {
161
167
  * @returns basketDetails
162
168
  */
163
169
  addTransactionPromotion(promotionList, basketdetails) {
164
- console.log("e:basket :basket Service : promotionList and basketDetails for transactionPromotion", JSON.stringify(promotionList), JSON.stringify(basketdetails), JSON.stringify(basketdetails.transactionPromotion));
170
+ AppLoggerService.logDebug(this.className, "addTransactionPromotion", `promotionList ${JSON.stringify(promotionList)} and
171
+ basketDetails
172
+ ${JSON.stringify(basketdetails)} for transactionPromotions ${JSON.stringify(basketdetails.transactionPromotion)}`);
165
173
  if (promotionList &&
166
174
  promotionList.result &&
167
175
  promotionList.result.transactionPromotion &&
@@ -178,7 +186,7 @@ class BasketService {
178
186
  basketdetails = this.transactionPromotionProductPortionCalc(basketdetails, transactionPromotionEntryUpdated);
179
187
  });
180
188
  }
181
- console.log("basket details in refund calculation file", JSON.stringify(basketdetails));
189
+ AppLoggerService.logDebug(this.className, "addTransactionPromotion", "basket details in refund calculation file", basketdetails);
182
190
  return basketdetails;
183
191
  }
184
192
  updateProductTotalForSummary(basketDetails) {
@@ -209,7 +217,7 @@ class BasketService {
209
217
  basketDetails.quantity +
210
218
  (product.quantity -
211
219
  (product.refundedQuantity ? product.refundedQuantity : 0));
212
- console.log("e-basket:ExchangeSummaryScreen:update basketdetails total :" +
220
+ AppLoggerService.logDebug(this.className, "updateProductTotalForSummary", "update basketdetails total :" +
213
221
  basketDetails.total +
214
222
  " Product line ID : " +
215
223
  product.itemLineId +
@@ -220,19 +228,19 @@ class BasketService {
220
228
  }
221
229
  updateBasketTotalForSummary(basketDetails) {
222
230
  basketDetails.basketTotal = basketDetails.total;
223
- console.info("ebasket : basket Service : update Basket Total for transaction transactionDiscount ", JSON.stringify(basketDetails.transactionDiscount));
224
- console.info("ebasket : basket Service : update Basket Total for transaction transactionPromotion ", JSON.stringify(basketDetails.transactionPromotion));
231
+ AppLoggerService.logInfo(this.className, "updateBasketTotalForSummary", "update Basket Total for transaction transactionDiscount ", basketDetails.transactionDiscount);
232
+ AppLoggerService.logInfo(this.className, "updateBasketTotalForSummary", "update Basket Total for transaction transactionPromotion ", basketDetails.transactionPromotion);
225
233
  basketDetails = this.updateTransactionPromotion(basketDetails);
226
234
  basketDetails = this.updateTransactionDiscount(basketDetails);
227
235
  basketDetails.basketTotal = Number(basketDetails.basketTotal.toFixed(2));
228
- console.info("ebasket : basket Service : update Basket Total: basketTotal after promotion applied for basketTotal", basketDetails.basketTotal);
236
+ AppLoggerService.logInfo(this.className, "updateBasketTotalForSummary", "update Basket Total: basketTotal after promotion applied for basketTotal", basketDetails.basketTotal);
229
237
  return basketDetails;
230
238
  }
231
239
  updateTransactionDiscount(basketDetails) {
232
240
  if (basketDetails.transactionDiscount &&
233
241
  basketDetails.transactionDiscount.length > 0) {
234
242
  const discountTotal = basketDetails.transactionDiscount.reduce((n, { discountAmount }) => n + discountAmount, 0);
235
- console.log("ebasket : basket Service : discountTotal ", discountTotal);
243
+ AppLoggerService.logDebug(this.className, "updateTransactionDiscount", "discountTotal ", discountTotal);
236
244
  basketDetails.basketTotal =
237
245
  basketDetails.basketTotal - Math.abs(discountTotal);
238
246
  }
@@ -268,7 +276,7 @@ class BasketService {
268
276
  basket.quantity +
269
277
  (product.quantity -
270
278
  (product.refundedQuantity ? product.refundedQuantity : 0));
271
- console.log("e-basket:basket service:update basketdetails total :" +
279
+ AppLoggerService.logDebug(this.className, "updateBasketTotalWithoutDiscount", "e-basket:basket service:update basketdetails total :" +
272
280
  JSON.stringify(basket) +
273
281
  basket.total +
274
282
  " Product line ID : " +
@@ -280,7 +288,8 @@ class BasketService {
280
288
  return basket;
281
289
  }
282
290
  updateBasketTotalWithDiscounts(basket) {
283
- console.log("e:basket :RefundBasketScreen : this.basketDetails new values", basket, JSON.stringify(basket.basketTotal));
291
+ AppLoggerService.logDebug(this.className, "updateBasketTotalWithDiscounts", `this.basketDetails new values ${basket},
292
+ ${JSON.stringify(basket.basketTotal)}`);
284
293
  if (basket.transactionPromotion && basket.transactionPromotion.length > 0) {
285
294
  const discountTotal = basket.transactionPromotion.reduce((n, { promotionAmount }) => n + promotionAmount, 0);
286
295
  basket.basketTotal = basket.basketTotal - discountTotal;
@@ -289,7 +298,7 @@ class BasketService {
289
298
  const discountTotal = basket.transactionDiscount.reduce((n, { discountAmount }) => n + discountAmount, 0);
290
299
  basket.basketTotal = basket.basketTotal - discountTotal;
291
300
  }
292
- console.log("e:basket :RefundBasketScreen : basket new values", JSON.stringify(basket));
301
+ AppLoggerService.logDebug(this.className, "updateBasketTotalWithDiscounts", "basket new values", basket);
293
302
  return basket;
294
303
  }
295
304
  transactionDiscountAndPromotionProductortionCalculation(basket) {
@@ -301,7 +310,9 @@ class BasketService {
301
310
  basket = this.transactionPromotionProductPortionCalc(basket, promotion);
302
311
  });
303
312
  }
304
- console.log("ebasket: basket item discount protion calculation", basket, basket.products);
313
+ AppLoggerService.logDebug(this.className, "transactionDiscountAndPromotionProductortionCalculation", `basket item discount protion calculation ,
314
+ ${basket},
315
+ ${basket.products}`);
305
316
  return basket;
306
317
  }
307
318
  transactionPromotionProductPortionCalc(basket, promotion) {
@@ -317,7 +328,7 @@ class BasketService {
317
328
  total += (p.total - this.numberUtilService.trimTo2Decimal2(productContributionInTotal));
318
329
  }
319
330
  });
320
- console.log(`ebasket: trnsactionPromotion: ${JSON.stringify(promotion)}, selected products total: ${total}`);
331
+ AppLoggerService.logDebug(this.className, "transactionPromotionProductPortionCalc", `ebasket: trnsactionPromotion: ${JSON.stringify(promotion)}, selected products total: ${total}`);
321
332
  basket.products.forEach((product) => {
322
333
  product = this.validateProductItemDiscount(product);
323
334
  const productContributionInTotal = this.numberUtilService.trimTo2Decimal2(product.itemDiscounts.trnDiscountsPortion) +
@@ -345,10 +356,10 @@ class BasketService {
345
356
  total += (p.total - this.numberUtilService.trimTo2Decimal2(productContributionInTotal));
346
357
  }
347
358
  });
348
- console.log(`ebasket: trnsactionDiscount: ${JSON.stringify(discount)}, selected products total: ${total}`);
359
+ AppLoggerService.logDebug(this.className, "transactionDiscountProductPortionCalc", `ebasket: trnsactionDiscount: ${JSON.stringify(discount)}, selected products total: ${total}`);
349
360
  basket.products.forEach((product) => {
350
361
  product = this.validateProductItemDiscount(product);
351
- console.log(product.discountable, "ebasket : basket service : discountable in basket service");
362
+ AppLoggerService.logDebug(this.className, "transactionDiscountProductPortionCalc", "discountable in basket service", product.discountable);
352
363
  const productContributionInTotal = this.numberUtilService.trimTo2Decimal2(product.itemDiscounts.trnDiscountsPortion) +
353
364
  this.numberUtilService.trimTo2Decimal2(product.itemDiscounts.trnPromotionsPortion) -
354
365
  this.numberUtilService.trimTo2Decimal2(product.itemDiscounts.refundPortion);
@@ -414,7 +425,7 @@ class BasketService {
414
425
  return largestNumber + 1;
415
426
  }
416
427
  updateBasketProductDataAsPerQuantity(product, quantity) {
417
- console.log(`ebasket: updateBasketProductDataAsPerQuantity : ${quantity} product: ${JSON.stringify(product)}`);
428
+ AppLoggerService.logDebug(this.className, "updateBasketProductDataAsPerQuantity", `ebasket: updateBasketProductDataAsPerQuantity : ${quantity} product: ${JSON.stringify(product)}`);
418
429
  product.quantity = quantity;
419
430
  if (product.hasOwnProperty("lineDiscount")) {
420
431
  // && this.product.quantity !== this.productDetailForm.controls.quantity.value
@@ -432,11 +443,11 @@ class BasketService {
432
443
  else {
433
444
  product.total = product.totalLinePrice;
434
445
  }
435
- console.log(`ebasket: updateBasketProductDataAsPerQuantity : ${quantity} product: ${JSON.stringify(product)}`);
446
+ AppLoggerService.logDebug(this.className, "updateBasketProductDataAsPerQuantity", `ebasket: updateBasketProductDataAsPerQuantity : ${quantity} product: ${JSON.stringify(product)}`);
436
447
  return product;
437
448
  }
438
449
  filterProductListWithWebOrder(isWebOrder) {
439
- console.log("ebasket: filterProductListWithWebOrder hit", JSON.stringify(this.currentBasket.products));
450
+ AppLoggerService.logDebug(this.className, "filterProductListWithWebOrder", "filterProductListWithWebOrder hit", this.currentBasket.products);
440
451
  if (isWebOrder)
441
452
  return this.currentBasket.products.filter((x) => x.isWebOrder);
442
453
  else {
@@ -444,11 +455,11 @@ class BasketService {
444
455
  }
445
456
  }
446
457
  filterProductListWithDelivery() {
447
- console.log("ebasket: filterProductListWithDelivery hit", JSON.stringify(this.currentBasket.products));
458
+ AppLoggerService.logDebug(this.className, "filterProductListWithDelivery", "filterProductListWithDelivery hit", this.currentBasket.products);
448
459
  return this.currentBasket.products.filter((x) => x.deliveryMethod === DELIVERY_METHODS.DELIVERY.toString());
449
460
  }
450
461
  filterProductListWithDeliveryGroup(group, products) {
451
- console.log("ebasket: filterProductListWithDeliveryGroup hit", JSON.stringify(products));
462
+ AppLoggerService.logDebug(this.className, "filterProductListWithDeliveryGroup", "filterProductListWithDeliveryGroup hit", products);
452
463
  return products.filter((x) => x.deliveryGroup === group);
453
464
  }
454
465
  generateNewDeliveryGroupNumber(products) {
@@ -465,7 +476,7 @@ class BasketService {
465
476
  return (largestNumber + 1).toString();
466
477
  }
467
478
  getDeliveryGroupNumbers(products) {
468
- console.log("getDeliveryGroupNumbers initiating : ", JSON.stringify(products));
479
+ AppLoggerService.logDebug(this.className, "getDeliveryGroupNumbers", "getDeliveryGroupNumbers initiating : ", products);
469
480
  let uniqueAndsortedResult = [];
470
481
  if (products.length > 0) {
471
482
  let deliveryGroupArr = products.map((product) => {
@@ -478,12 +489,12 @@ class BasketService {
478
489
  return 0;
479
490
  });
480
491
  uniqueAndsortedResult = Array.from(new Set(deliveryGroupArr)).sort((a, b) => a - b);
481
- console.log("getDeliveryGroupNumbers : ", JSON.stringify(uniqueAndsortedResult));
492
+ AppLoggerService.logDebug(this.className, "getDeliveryGroupNumbers", "getDeliveryGroupNumbers : uniqueAndsortedResult", uniqueAndsortedResult);
482
493
  }
483
494
  return uniqueAndsortedResult;
484
495
  }
485
496
  updateProductsWithNewDeliveryGroupNumber(products) {
486
- console.log("updateProductsWithNewDeliveryGroupNumber initiating : ", JSON.stringify(products));
497
+ AppLoggerService.logDebug(this.className, "updateProductsWithNewDeliveryGroupNumber", "initiating : ", products);
487
498
  let newGroupNumber = this.generateNewDeliveryGroupNumber(this.currentBasket.products);
488
499
  if (products.length > 0) {
489
500
  this.currentBasket.products.forEach(cBProducts => {
@@ -507,31 +518,31 @@ class BasketService {
507
518
  time = Number(element.leadTime.value) * 24 * 7;
508
519
  estmatedTime = Math.max(estmatedTime, time);
509
520
  estimatedDays = (estmatedTime === time) ? element.leadTime.type : estimatedDays;
510
- console.log("week", estmatedTime, estimatedDays);
521
+ AppLoggerService.logDebug(this.className, "calculateEstimatedTime", `week ${estmatedTime} ${estimatedDays}`);
511
522
  }
512
523
  else if (element.leadTime.type.toLocaleLowerCase() === "days") {
513
524
  time = Number(element.leadTime.value) * 24;
514
525
  estmatedTime = Math.max(estmatedTime, time);
515
526
  estimatedDays = (estmatedTime === time) ? element.leadTime.type : estimatedDays;
516
- console.log("days", estmatedTime, estimatedDays);
527
+ AppLoggerService.logDebug(this.className, "calculateEstimatedTime", `days ${estmatedTime} ${estimatedDays}`);
517
528
  }
518
529
  else if (element.leadTime.type.toLocaleLowerCase() === "months") {
519
530
  time = Number(element.leadTime.value) * 24 * 30;
520
531
  estmatedTime = Math.max(estmatedTime, time);
521
532
  estimatedDays = (estmatedTime === time) ? element.leadTime.type : estimatedDays;
522
- console.log("months", estmatedTime, estimatedDays);
533
+ AppLoggerService.logDebug(this.className, "calculateEstimatedTime", `months ${estmatedTime} ${estimatedDays}`);
523
534
  }
524
535
  else if (element.leadTime.type.toLocaleLowerCase() === "years") {
525
536
  time = Number(element.leadTime.value) * 24 * 365;
526
537
  estmatedTime = Math.max(estmatedTime, time);
527
538
  estimatedDays = (estmatedTime === time) ? element.leadTime.type : estimatedDays;
528
- console.log("years", estmatedTime, estimatedDays);
539
+ AppLoggerService.logDebug(this.className, "calculateEstimatedTime", `years ${estmatedTime} ${estimatedDays}`);
529
540
  }
530
541
  else {
531
542
  time = Number(element.leadTime.value);
532
543
  estmatedTime = Math.max(estmatedTime, time);
533
544
  estimatedDays = (estmatedTime === time) ? element.leadTime.type : estimatedDays;
534
- console.log("hours", estmatedTime, estimatedDays);
545
+ AppLoggerService.logDebug(this.className, "calculateEstimatedTime", `hours ${estmatedTime} ${estimatedDays}`);
535
546
  }
536
547
  });
537
548
  if (estimatedDays.toLocaleLowerCase() === "days") {
@@ -553,12 +564,12 @@ class BasketService {
553
564
  return estimate;
554
565
  }
555
566
  catch (error) {
556
- console.log("error in calculateEstimatedTime", error);
567
+ AppLoggerService.logError(this.className, "calculateEstimatedTime", "error in calculateEstimatedTime", error);
557
568
  }
558
569
  return 0;
559
570
  }
560
571
  updateProductsWithDeliveryGroupNumber(oldGroup, newGroup) {
561
- console.log("updateProductsWithDeliveryGroupNumber initiating");
572
+ AppLoggerService.logDebug(this.className, "updateProductsWithDeliveryGroupNumber initiating");
562
573
  this.currentBasket.products.forEach(cBProducts => {
563
574
  if (cBProducts.deliveryGroup === oldGroup) {
564
575
  cBProducts.deliveryGroup = newGroup;
@@ -568,7 +579,7 @@ class BasketService {
568
579
  return;
569
580
  }
570
581
  getDeliveryInfo() {
571
- console.log("getDeliveryGroupInfor initiating");
582
+ AppLoggerService.logDebug(this.className, "getDeliveryInfo", "getDeliveryGroupInfor initiating");
572
583
  try {
573
584
  let groupInfo = {
574
585
  groups: []
@@ -593,7 +604,7 @@ class BasketService {
593
604
  return groupInfo;
594
605
  }
595
606
  catch (error) {
596
- console.log("error", error);
607
+ AppLoggerService.logError(this.className, "getDeliveryInfo", "error while getting delivery info", error);
597
608
  }
598
609
  }
599
610
  }
@@ -601,6 +612,7 @@ class BasketService {
601
612
  class NumberUtilService {
602
613
  constructor(cp) {
603
614
  this.cp = cp;
615
+ this.className = "NumberUtilService";
604
616
  }
605
617
  trimTo2Decimal(no) {
606
618
  //return Math.floor(no * 100) / 100;
@@ -618,7 +630,7 @@ class NumberUtilService {
618
630
  if (numValue) {
619
631
  const numb = parseFloat(numValue.toString().replace(',', ''));
620
632
  returnValue = this.cp.transform(Number(numValue).toFixed(2), currencyCode.toLocaleUpperCase(), "symbol");
621
- console.log("AppendWithCurrencySymbol :" + returnValue);
633
+ AppLoggerService.logDebug(this.className, "AppendWithCurrencySymbol", "AppendWithCurrencySymbol :", returnValue);
622
634
  }
623
635
  else {
624
636
  returnValue = this.cp.transform("0.00", currencyCode.toLocaleUpperCase(), "symbol");
@@ -642,6 +654,7 @@ class TransactionDocumentBuilder {
642
654
  constructor(transactionDoc, currencyPipe, basketService) {
643
655
  this.currencyPipe = currencyPipe;
644
656
  this.basketService = basketService;
657
+ this.className = "TransactionDocumentBuilder";
645
658
  this.numberUtilService = new NumberUtilService(currencyPipe);
646
659
  this.basketService = new BasketService(this.numberUtilService);
647
660
  this.storeInfo = JSON.parse(localStorage.getItem('storeInfo') || '{}');
@@ -688,7 +701,7 @@ class TransactionDocumentBuilder {
688
701
  .substring(1);
689
702
  this.transactionDocument.transactionRef =
690
703
  storeDetails.orgCode + storeDetails.storeId + date.toISOString() + random;
691
- console.log("ebasket: transaction ref created", this.transactionDocument.transactionRef);
704
+ AppLoggerService.logDebug(this.className, "transactionRef", "transaction ref created", this.transactionDocument.transactionRef);
692
705
  return this;
693
706
  }
694
707
  /**
@@ -796,7 +809,7 @@ class TransactionDocumentBuilder {
796
809
  * @returns basket
797
810
  */
798
811
  basket(basketDetails) {
799
- console.log("ebasket: basket details update in transaction document", JSON.stringify(basketDetails));
812
+ AppLoggerService.logDebug(this.className, "basket", "basket details update in transaction document", basketDetails);
800
813
  this.transactionDocument.subsidiaryId = basketDetails.subsidiaryId || (localStorage.getItem('subsidiaryId') || '');
801
814
  this.transactionDocument.basket.products = [];
802
815
  this.transactionDocument.basket.lineDiscount = [];
@@ -849,7 +862,7 @@ class TransactionDocumentBuilder {
849
862
  this.transactionDocument.basket.products.push(p);
850
863
  this.lineDiscount(basketDetails);
851
864
  });
852
- console.info("ebasket: transactiondocument basket details updated", JSON.stringify(this.transactionDocument.basket));
865
+ AppLoggerService.logInfo(this.className, "basket", "transactiondocument basket details updated", this.transactionDocument.basket);
853
866
  return this;
854
867
  }
855
868
  /**
@@ -857,7 +870,7 @@ class TransactionDocumentBuilder {
857
870
  * @returns currentTransactionDetails
858
871
  */
859
872
  currentTransactionDetails(basket) {
860
- console.log("ebasket: current transaction details for exchanges", basket);
873
+ AppLoggerService.logDebug(this.className, "currentTransactionDetails", "current transaction details for exchanges", basket);
861
874
  this.transactionDocument.currentTransactionDetails.products = [];
862
875
  this.transactionDocument.currentTransactionDetails.linePromotion = [];
863
876
  this.transactionDocument.currentTransactionDetails.lineDiscount = [];
@@ -882,7 +895,7 @@ class TransactionDocumentBuilder {
882
895
  this.transactionDocument.currentTransactionDetails.lineDiscount.push(product.lineDiscount);
883
896
  }
884
897
  });
885
- console.log("ebasket: current transaction details after removing old products", this.transactionDocument.currentTransactionDetails.products);
898
+ AppLoggerService.logDebug(this.className, "currentTransactionDetails", "current transaction details after removing old products", this.transactionDocument.currentTransactionDetails.products);
886
899
  if (basket.transactionDiscount && basket.transactionDiscount.length > 0) {
887
900
  this.transactionDocument.currentTransactionDetails.transactionDiscount.push(...basket.transactionDiscount);
888
901
  }
@@ -907,7 +920,7 @@ class TransactionDocumentBuilder {
907
920
  this.transactionDocument.currentTransactionDetails.basketSummary.discountTotal = 0;
908
921
  }
909
922
  }
910
- console.log("ebasket:this.transactionDocument.currentTransactionDetails", JSON.stringify(this.transactionDocument.currentTransactionDetails));
923
+ AppLoggerService.logInfo(this.className, "currentTransactionDetails", "currentTransactionDetails", this.transactionDocument.currentTransactionDetails);
911
924
  return this;
912
925
  }
913
926
  /**
@@ -935,7 +948,8 @@ class TransactionDocumentBuilder {
935
948
  taxableAmount: product.total,
936
949
  PreTax: 0
937
950
  };
938
- console.info("Product contribution : item line ID :current transaction Details", product.itemLineId, "tax line :", JSON.stringify(taxLine), JSON.stringify(basketDetails.basketTotal));
951
+ AppLoggerService.logInfo(this.className, "updateCurrentTransactionDetailsTaxBreakdown", `item line ID :current transaction Details",
952
+ ${product.itemLineId}, tax line : ${taxLine}, basketDetails.basketTotal ${basketDetails.basketTotal}`);
939
953
  //step 1
940
954
  // if Transaction Discount and/or promotion applied, find net selling price of each product as taxableamount
941
955
  //If transaction discount/promotion is applied taxable amount should be deducting transaction promotion and transaction disacount portion
@@ -963,14 +977,13 @@ class TransactionDocumentBuilder {
963
977
  else {
964
978
  this.transactionDocument.currentTransactionDetails.basketSummary.VATTotal = 0.00;
965
979
  }
966
- console.log("eBasket:after calculating tax currenttransactionDetails", this.transactionDocument.currentTransactionDetails);
980
+ AppLoggerService.logDebug(this.className, "updateCurrentTransactionDetailsTaxBreakdown", "eBasket:after calculating tax currenttransactionDetails", this.transactionDocument.currentTransactionDetails);
967
981
  return this;
968
982
  }
969
983
  updateCurrentTransactionDetailsTotalTaxSummary() {
970
- console.log("Total Tax Summery Request :", JSON.stringify(this.transactionDocument.currentTransactionDetails.taxBreakdown));
984
+ AppLoggerService.logDebug(this.className, "updateCurrentTransactionDetailsTotalTaxSummary", "Total Tax Summery Request :", this.transactionDocument.currentTransactionDetails.taxBreakdown);
971
985
  let totalTaxSummaryArray = [];
972
986
  let totalTaxSummaryGroup = [];
973
- console.log("Tax Lines for Total Tax Summery :", JSON.stringify(this.transactionDocument.currentTransactionDetails.taxBreakdown.taxLines));
974
987
  this.transactionDocument.currentTransactionDetails.taxBreakdown.taxLines.forEach((element) => {
975
988
  let TaxSummary = {
976
989
  VATCode: "",
@@ -986,7 +999,7 @@ class TransactionDocumentBuilder {
986
999
  TaxSummary.TXrateSum = this.numberUtilService.trimTo2Decimal2(TaxSummary.PreTaxSum + TaxSummary.TaxSum);
987
1000
  totalTaxSummaryArray.push(TaxSummary);
988
1001
  });
989
- console.log("Total Tax Summery Without Grouped : ", JSON.stringify(totalTaxSummaryArray));
1002
+ AppLoggerService.logDebug(this.className, "updateCurrentTransactionDetailsTotalTaxSummary", "Total Tax Summery Without Grouped : ", totalTaxSummaryArray);
990
1003
  totalTaxSummaryGroup = totalTaxSummaryArray.reduce((preparedArray, currentObj) => {
991
1004
  let ind = preparedArray.findIndex((x) => x.VAT === currentObj.VAT);
992
1005
  if (ind === -1) {
@@ -1002,7 +1015,7 @@ class TransactionDocumentBuilder {
1002
1015
  return preparedArray;
1003
1016
  }, []);
1004
1017
  // listOfTags.map(x => unique.filter(a => a.label == x.label && a.color == x.color).length > 0 ? null : unique.push(x));
1005
- console.log("Total Tax Summer Group :", JSON.stringify(totalTaxSummaryGroup));
1018
+ AppLoggerService.logDebug(this.className, "updateCurrentTransactionDetailsTotalTaxSummary", "Total Tax Summer Group :", totalTaxSummaryGroup);
1006
1019
  this.transactionDocument.currentTransactionDetails.totalTaxSummary = totalTaxSummaryGroup;
1007
1020
  return this;
1008
1021
  }
@@ -1012,10 +1025,10 @@ class TransactionDocumentBuilder {
1012
1025
  */
1013
1026
  updateCurrentTransactionDetailsDiscountTotal() {
1014
1027
  let refundTotal = this.transactionDocument.currentTransactionDetails.basketSummary.refundTotal ? this.transactionDocument.currentTransactionDetails.basketSummary.refundTotal : 0;
1015
- console.log("e-basket: transaction builder updateCurrentTransactionDetailsDiscountTotal: discountTotal", refundTotal, this.transactionDocument.currentTransactionDetails.basketSummary.basketTotal, this.transactionDocument.currentTransactionDetails.basketSummary.saleTotal);
1028
+ AppLoggerService.logDebug(this.className, "updateCurrentTransactionDetailsDiscountTotal", `refundTotal ${refundTotal}, basketTotal ${this.transactionDocument.currentTransactionDetails.basketSummary.basketTotal},saleTotal ${this.transactionDocument.currentTransactionDetails.basketSummary.saleTotal}`);
1016
1029
  const discountTotal = Math.abs(Math.abs(this.transactionDocument.currentTransactionDetails.basketSummary.saleTotal) -
1017
1030
  (Math.abs(this.transactionDocument.currentTransactionDetails.basketSummary.basketTotal) + Math.abs(refundTotal)));
1018
- console.log("e-basket: transaction builder updateCurrentTransactionDetailsDiscountTotal: discountTotal", discountTotal);
1031
+ AppLoggerService.logDebug(this.className, "updateCurrentTransactionDetailsDiscountTotal", "discountTotal", discountTotal);
1019
1032
  return Number(discountTotal.toFixed(2));
1020
1033
  }
1021
1034
  /**
@@ -1029,7 +1042,7 @@ class TransactionDocumentBuilder {
1029
1042
  if (product.refundedTotal) {
1030
1043
  totalRefund = totalRefund + product.refundedTotal;
1031
1044
  }
1032
- console.log("ebasket : transaction Service: totalRefund for Current TransactionDetails" + totalRefund);
1045
+ AppLoggerService.logDebug(this.className, "updateCurrentTransactionDetailsRefundTotal", "totalRefund for Current TransactionDetails", totalRefund);
1033
1046
  }
1034
1047
  return totalRefund;
1035
1048
  }
@@ -1053,7 +1066,7 @@ class TransactionDocumentBuilder {
1053
1066
  else {
1054
1067
  this.transactionDocument.basketSummary.VATTotal = 0.00;
1055
1068
  }
1056
- console.info("ebasket: basketsummary updated in transaction document: ", JSON.stringify(this.transactionDocument.basketSummary));
1069
+ AppLoggerService.logInfo(this.className, "basketSummary", "basketsummary updated in transaction document: ", this.transactionDocument.basketSummary);
1057
1070
  return this;
1058
1071
  }
1059
1072
  /**
@@ -1074,7 +1087,7 @@ class TransactionDocumentBuilder {
1074
1087
  return acc;
1075
1088
  }, []);
1076
1089
  }
1077
- // console.info(
1090
+ // AppLoggerService.logInfo(this.className,
1078
1091
  // "e-basket :line discount updated in transaction document",
1079
1092
  // this.transactionDocument.basket.lineDiscount
1080
1093
  // );
@@ -1103,7 +1116,7 @@ class TransactionDocumentBuilder {
1103
1116
  this.transactionDocument.basket.exchange.push(element.exchange);
1104
1117
  }
1105
1118
  }
1106
- console.log("e-basket :TransactionDocumentBuilder: this.transactionDocument.basket exchange", JSON.stringify(this.transactionDocument.basket.exchange));
1119
+ AppLoggerService.logDebug(this.className, "exchange", "this.transactionDocument.basket exchange", this.transactionDocument.basket.exchange);
1107
1120
  }
1108
1121
  return this;
1109
1122
  }
@@ -1155,7 +1168,7 @@ class TransactionDocumentBuilder {
1155
1168
  // return acc;
1156
1169
  // }, []);
1157
1170
  // }
1158
- console.log("e-basket :TransactionDocumentBuilder: this.transactionDocument.basket.transactionPromotion", JSON.stringify(this.transactionDocument.basket.transactionPromotion));
1171
+ AppLoggerService.logDebug(this.className, "transactionPromotion", "this.transactionDocument.basket.transactionPromotion", this.transactionDocument.basket.transactionPromotion);
1159
1172
  }
1160
1173
  return this;
1161
1174
  }
@@ -1163,7 +1176,7 @@ class TransactionDocumentBuilder {
1163
1176
  if (basketDetails.transactionDiscount) {
1164
1177
  this.transactionDocument.basket.transactionDiscount =
1165
1178
  basketDetails.transactionDiscount;
1166
- console.log("e-basket :TransactionDocumentBuilder: transaction Discount", JSON.stringify(this.transactionDocument.basket.transactionDiscount));
1179
+ AppLoggerService.logDebug(this.className, "transactionDiscount", "transaction Discount", this.transactionDocument.basket.transactionDiscount);
1167
1180
  }
1168
1181
  return this;
1169
1182
  }
@@ -1173,7 +1186,7 @@ class TransactionDocumentBuilder {
1173
1186
  * @returns
1174
1187
  */
1175
1188
  paymentDetails(paymentDetails) {
1176
- console.info("ebasket : payment details after transaction completed", JSON.stringify(paymentDetails));
1189
+ AppLoggerService.logInfo(this.className, "paymentDetails", "payment details after transaction completed", paymentDetails);
1177
1190
  this.transactionDocument.paymentDetails = paymentDetails;
1178
1191
  return this;
1179
1192
  }
@@ -1209,7 +1222,7 @@ class TransactionDocumentBuilder {
1209
1222
  * @returns at
1210
1223
  */
1211
1224
  giftOption(gift) {
1212
- console.log("e-basket :TransactionDocumentBuilder: this.transactionDocument.giftoption", gift);
1225
+ AppLoggerService.logDebug(this.className, "giftOption", "this.transactionDocument.giftoption", gift);
1213
1226
  if (gift) {
1214
1227
  this.transactionDocument.giftedReceipt = gift;
1215
1228
  }
@@ -1301,7 +1314,7 @@ class TransactionDocumentBuilder {
1301
1314
  * @returns basket details
1302
1315
  */
1303
1316
  getBasketDetails() {
1304
- console.info("ebasket: Getting Basket for transactionDocument", JSON.stringify(this.transactionDocument));
1317
+ AppLoggerService.logInfo(this.className, "getBasketDetails", "Getting Basket for transactionDocument", this.transactionDocument);
1305
1318
  let basket = {
1306
1319
  subsidiaryId: this.transactionDocument.subsidiaryId,
1307
1320
  transactionDiscount: this.transactionDocument.basket.transactionDiscount,
@@ -1320,7 +1333,7 @@ class TransactionDocumentBuilder {
1320
1333
  };
1321
1334
  basket.products = [];
1322
1335
  this.transactionDocument.basket.products.forEach((product, index) => {
1323
- console.log(JSON.stringify(product), "ebasket: basket detail update in basket");
1336
+ AppLoggerService.logDebug(this.className, JSON.stringify(product), "ebasket: basket detail update in basket");
1324
1337
  const p = {};
1325
1338
  p.SKU = product.SKU;
1326
1339
  p.barcode = product.barCode;
@@ -1402,7 +1415,7 @@ class TransactionDocumentBuilder {
1402
1415
  if (this.transactionDocument.type === TRANSACTION_TYPE.SALE_REFUND) {
1403
1416
  basket.quantity = this.getRefundedTotalWithQuantity(basket);
1404
1417
  }
1405
- console.info("ebasket: Basket created successfully", JSON.stringify(basket));
1418
+ AppLoggerService.logInfo(this.className, "getBasketDetails", "Basket created successfully", basket);
1406
1419
  return basket;
1407
1420
  }
1408
1421
  /**
@@ -1458,7 +1471,7 @@ class TransactionDocumentBuilder {
1458
1471
  // p.itemDiscounts = product.itemDiscounts as ItemDiscount;
1459
1472
  // }
1460
1473
  // // if(!p.itemDiscounts){
1461
- // // console.log(p.itemDiscounts);
1474
+ // // AppLoggerService.logDebug(this.className, p.itemDiscounts);
1462
1475
  // // this.basketService.transactionDiscountAndPromotionProductortionCalculation(basket);
1463
1476
  // // }
1464
1477
  // p.refundPromotionalQuantity = product.refundedPromotionalQuantity ? product.refundedPromotionalQuantity : 0;
@@ -1522,7 +1535,7 @@ class TransactionDocumentBuilder {
1522
1535
  // if (!basket.products[0].hasOwnProperty('itemDiscounts')) {
1523
1536
  // basket = this.getTransactionDiscountAndTransactionPromotionPortion(basket);
1524
1537
  // }
1525
- // console.log("ebasket : TransactionDocumentBuilder :new created refunded basket", JSON.stringify(basket))
1538
+ // AppLoggerService.logDebug(this.className, "ebasket : TransactionDocumentBuilder :new created refunded basket", JSON.stringify(basket))
1526
1539
  // basket.quantity = basket.products.reduce(
1527
1540
  // (n: any, { quantity }: any) => n + quantity,
1528
1541
  // 0
@@ -1530,11 +1543,11 @@ class TransactionDocumentBuilder {
1530
1543
  // basket.total = this.getTotalWithLineDiscountAndLinePromotionApplied(basket);
1531
1544
  // basket.basketTotal = basket.total;
1532
1545
  // basket.basketTotal = basket.basketTotal - this.getTotalDiscountWithTransactionDiscountsAndPromotions(basket);
1533
- // console.log(
1546
+ // AppLoggerService.logDebug(this.className,
1534
1547
  // "ebasket : TransactionDocumentBuilder : update Basket Total: after promotion :basketTotal",
1535
1548
  // basket.basketTotal
1536
1549
  // );
1537
- // console.log(
1550
+ // AppLoggerService.logDebug(this.className,
1538
1551
  // "e:basket :TransactionDocumentBuilder : basketDetails updated values",
1539
1552
  // JSON.stringify(basket)
1540
1553
  // );
@@ -1579,19 +1592,19 @@ class TransactionDocumentBuilder {
1579
1592
  basketDetails.transactionDiscount.length > 0) {
1580
1593
  discountTotal += basketDetails.transactionDiscount.reduce((n, { discountAmount }) => n + discountAmount, 0);
1581
1594
  }
1582
- console.log("ebasket : TransactionDocumentBuilder : Transaction discount Total:", discountTotal);
1595
+ AppLoggerService.logDebug(this.className, "getTotalDiscountWithTransactionDiscountsAndPromotions", "Transaction discount Total:", discountTotal);
1583
1596
  return discountTotal;
1584
1597
  }
1585
1598
  appendCurrencySymbol(currency, value) {
1586
1599
  // value=this.decimalpipe.transform(value,'1.2');
1587
1600
  if (value >= 0) {
1588
1601
  const returnval = currency + value;
1589
- console.log(returnval, "ebasket: add currency with value");
1602
+ AppLoggerService.logDebug(this.className, "appendCurrencySymbol", "add currency with value", returnval);
1590
1603
  return returnval;
1591
1604
  }
1592
1605
  else {
1593
1606
  const returnval = "-" + (currency + value * -1);
1594
- console.log(returnval, "-(currency+(value*-1))");
1607
+ AppLoggerService.logDebug(this.className, "appendCurrencySymbol", "returnVal", returnval);
1595
1608
  return returnval;
1596
1609
  }
1597
1610
  }
@@ -1603,7 +1616,7 @@ class TransactionDocumentBuilder {
1603
1616
  // this.transactionDocument.basket.products.forEach((product) => {
1604
1617
  // product.refundedQuantity = product.quantity;
1605
1618
  // product.refundedTotal = product.totalLinePrice * -1;
1606
- // console.log(
1619
+ // AppLoggerService.logDebug(this.className,
1607
1620
  // "ebasket: Transaction price override :",
1608
1621
  // this.transactionDocument.basket.lineDiscount
1609
1622
  // );
@@ -1612,15 +1625,15 @@ class TransactionDocumentBuilder {
1612
1625
  // this.transactionDocument.basket.linePromotion.length > 0
1613
1626
  // ) {
1614
1627
  // this.transactionDocument.basket.linePromotion.forEach((linePromotion) => {
1615
- // console.log(
1628
+ // AppLoggerService.logDebug(this.className,
1616
1629
  // "Promotion: basket linePromotion : ",
1617
1630
  // this.transactionDocument.basket.linePromotion
1618
1631
  // );
1619
- // console.log(
1632
+ // AppLoggerService.logDebug(this.className,
1620
1633
  // "linePromotion.itemLineId.toString() : ",
1621
1634
  // linePromotion.itemLineId.toString()
1622
1635
  // );
1623
- // console.log(
1636
+ // AppLoggerService.logDebug(this.className,
1624
1637
  // "condition : " +
1625
1638
  // (product.itemLineId === linePromotion.itemLineId.toString())
1626
1639
  // );
@@ -1635,15 +1648,15 @@ class TransactionDocumentBuilder {
1635
1648
  // this.transactionDocument.basket.lineDiscount.length > 0
1636
1649
  // ) {
1637
1650
  // this.transactionDocument.basket.lineDiscount.forEach((lineDiscount) => {
1638
- // console.log(
1651
+ // AppLoggerService.logDebug(this.className,
1639
1652
  // "product.itemLineId : " +
1640
1653
  // this.transactionDocument.basket.lineDiscount
1641
1654
  // );
1642
- // console.log(
1655
+ // AppLoggerService.logDebug(this.className,
1643
1656
  // "lineDiscount.itemLineId.toString() : " +
1644
1657
  // lineDiscount.itemLineId.toString()
1645
1658
  // );
1646
- // console.log(
1659
+ // AppLoggerService.logDebug(this.className,
1647
1660
  // "condition : " +
1648
1661
  // (product.itemLineId === lineDiscount.itemLineId.toString())
1649
1662
  // );
@@ -1652,10 +1665,10 @@ class TransactionDocumentBuilder {
1652
1665
  // }
1653
1666
  // });
1654
1667
  // }
1655
- // console.log("Product description :" + product.description);
1656
- // console.log("Product total :" + product.refundedTotal);
1668
+ // AppLoggerService.logDebug(this.className, "Product description :" + product.description);
1669
+ // AppLoggerService.logDebug(this.className, "Product total :" + product.refundedTotal);
1657
1670
  // // product.displayrefundedamount=this.appendCurrencySymbol(CURRENCY[this.transactionDocument.baseCurrency],product.refundedTotal);
1658
- // // console.log(product.displayrefundedamount,"displayrefundedamount");
1671
+ // // AppLoggerService.logDebug(this.className, product.displayrefundedamount,"displayrefundedamount");
1659
1672
  // product.refunded = true;
1660
1673
  // });
1661
1674
  // const baskettotal = (this.transactionDocument.basketSummary.basketTotal *= -1);
@@ -1690,7 +1703,7 @@ class TransactionDocumentBuilder {
1690
1703
  // product.quantity * Number(product.selectedPrice.toFixed(2));
1691
1704
  // }
1692
1705
  saletotal += product.total;
1693
- console.log("e-basket:update product Total:" + saletotal, JSON.stringify(product));
1706
+ AppLoggerService.logDebug(this.className, "getTotalWithLineDiscountAndLinePromotionApplied", "e-basket:update product Total:" + saletotal, product);
1694
1707
  }
1695
1708
  return saletotal;
1696
1709
  }
@@ -1714,10 +1727,10 @@ class TransactionDocumentBuilder {
1714
1727
  */
1715
1728
  updateDiscountTotal() {
1716
1729
  let refundTotal = this.transactionDocument.basketSummary.refundTotal ? this.transactionDocument.basketSummary.refundTotal : 0;
1717
- console.info("e-basket: transaction builder: refundTotal", JSON.stringify(refundTotal), JSON.stringify(this.transactionDocument.basketSummary));
1730
+ AppLoggerService.logInfo(this.className, "updateDiscountTotal", `refundTotal: ${refundTotal} this.transactionDocument.basketSummary: ${this.transactionDocument.basketSummary}`);
1718
1731
  const discountTotal = Math.abs(Math.abs(this.transactionDocument.basketSummary.saleTotal) -
1719
1732
  (Math.abs(this.transactionDocument.basketSummary.basketTotal) + Math.abs(refundTotal)));
1720
- console.log("e-basket: transaction builder: discountTotal", JSON.stringify(discountTotal));
1733
+ AppLoggerService.logDebug(this.className, "updateDiscountTotal", "discountTotal", discountTotal);
1721
1734
  return Number(discountTotal.toFixed(2));
1722
1735
  }
1723
1736
  updateReasonCode(reasonCode) {
@@ -1768,7 +1781,8 @@ class TransactionDocumentBuilder {
1768
1781
  taxableAmount: product.total,
1769
1782
  PreTax: 0
1770
1783
  };
1771
- console.info("Product contribution : item line ID :", product.itemLineId, "tax line :", JSON.stringify(taxLine));
1784
+ AppLoggerService.logInfo(this.className, "updateTaxBreakdown", `item line ID :, ${product.itemLineId},
1785
+ "tax line :", ${taxLine}`);
1772
1786
  // step 1
1773
1787
  // if Transaction Discount and/or promotion applied, find net selling price of each product as taxableamount
1774
1788
  // if (transactionDiscountTotal > 0) {
@@ -1777,7 +1791,8 @@ class TransactionDocumentBuilder {
1777
1791
  product.itemDiscounts.trnPromotionsPortion -
1778
1792
  product.itemDiscounts.refundPortion;
1779
1793
  // tp+td-rp;
1780
- console.info("Product contribution : item line ID :", product.itemLineId, "contribution :", JSON.stringify(productContributionInTotal));
1794
+ AppLoggerService.logInfo(this.className, "updateTaxBreakdown", `item line ID , ${product.itemLineId},
1795
+ "contribution :", ${productContributionInTotal}`);
1781
1796
  // calculate net selling price after applying transaction discount as per product contribution
1782
1797
  taxLine.taxableAmount -= productContributionInTotal;
1783
1798
  // }
@@ -1795,10 +1810,10 @@ class TransactionDocumentBuilder {
1795
1810
  return this;
1796
1811
  }
1797
1812
  updateTotalTaxSummary() {
1798
- console.log("Total Tax Summery Request :", JSON.stringify(this.transactionDocument.basket.taxBreakdown));
1813
+ AppLoggerService.logDebug(this.className, "updateTotalTaxSummary", "Total Tax Summery Request :", this.transactionDocument.basket.taxBreakdown);
1799
1814
  let totalTaxSummaryArray = [];
1800
1815
  let totalTaxSummaryGroup = [];
1801
- console.log("Tax Lines for Total Tax Summery :", JSON.stringify(this.transactionDocument.basket.taxBreakdown.taxLines));
1816
+ AppLoggerService.logDebug(this.className, "updateTotalTaxSummary", "Tax Lines for Total Tax Summery :", this.transactionDocument.basket.taxBreakdown.taxLines);
1802
1817
  this.transactionDocument.basket.taxBreakdown.taxLines.forEach((element) => {
1803
1818
  let TaxSummary = {
1804
1819
  VATCode: "",
@@ -1814,7 +1829,7 @@ class TransactionDocumentBuilder {
1814
1829
  TaxSummary.TXrateSum = this.numberUtilService.trimTo2Decimal2(TaxSummary.PreTaxSum + TaxSummary.TaxSum);
1815
1830
  totalTaxSummaryArray.push(TaxSummary);
1816
1831
  });
1817
- console.log("Total Tax Summery Without Grouped : ", JSON.stringify(totalTaxSummaryArray));
1832
+ AppLoggerService.logDebug(this.className, "updateTotalTaxSummary", "Total Tax Summery Without Grouped : ", totalTaxSummaryArray);
1818
1833
  totalTaxSummaryGroup = totalTaxSummaryArray.reduce((preparedArray, currentObj) => {
1819
1834
  let ind = preparedArray.findIndex((x) => x.VAT === currentObj.VAT);
1820
1835
  if (ind === -1) {
@@ -1829,7 +1844,7 @@ class TransactionDocumentBuilder {
1829
1844
  }
1830
1845
  return preparedArray;
1831
1846
  }, []);
1832
- console.log("Total Tax Summer Group :", totalTaxSummaryGroup);
1847
+ AppLoggerService.logDebug(this.className, "updateTotalTaxSummary", "Total Tax Summer Group :", totalTaxSummaryGroup);
1833
1848
  this.transactionDocument.basket.totalTaxSummary = totalTaxSummaryGroup;
1834
1849
  return this;
1835
1850
  }
@@ -1861,7 +1876,7 @@ class TransactionDocumentBuilder {
1861
1876
  if (product.refundedTotal) {
1862
1877
  totalRefund = totalRefund + product.refundedTotal;
1863
1878
  }
1864
- console.log("ebasket : transaction Service: totalRefund" + totalRefund);
1879
+ AppLoggerService.logDebug(this.className, "getRefundTotal", "totalRefund", totalRefund);
1865
1880
  }
1866
1881
  return totalRefund;
1867
1882
  }
@@ -1873,6 +1888,7 @@ class TransactionDocumentBuilder {
1873
1888
 
1874
1889
  class RJMapperBuilderClass {
1875
1890
  constructor(transactionDoc) {
1891
+ this.className = "RJMapperBuilderClass";
1876
1892
  this.itemCount = 0;
1877
1893
  this.largestNumber = 0;
1878
1894
  this.rjObject = {};
@@ -2669,7 +2685,7 @@ class RJMapperBuilderClass {
2669
2685
  return value;
2670
2686
  }
2671
2687
  catch (e) {
2672
- console.log(value, 'can not be converted in string', e);
2688
+ AppLoggerService.logError(this.className, "convertToString", 'can not be converted in string', e);
2673
2689
  }
2674
2690
  }
2675
2691
  generateDynamicStockLookUp() {
@@ -2747,6 +2763,7 @@ class RJMapperBuilderClass {
2747
2763
  class WebReturnMapperBuilderClass {
2748
2764
  constructor(document, currencyPipe) {
2749
2765
  this.currencyPipe = currencyPipe;
2766
+ this.className = "WebReturnMapperBuilderClass";
2750
2767
  this.webReturnObject = {
2751
2768
  id: '',
2752
2769
  orgCode: "",
@@ -2936,7 +2953,7 @@ class WebReturnMapperBuilderClass {
2936
2953
  transactionPromotion.subLevelType = PROMOTION_LEVEL.LINE;
2937
2954
  transactionPromotion.trigger = couponTriggerPromotions;
2938
2955
  }
2939
- console.log("e-basket: update LinePromotion With Coupon", JSON.stringify(transactionPromotion));
2956
+ AppLoggerService.logDebug(this.className, "WebReturnMapper", "update LinePromotion With Coupon", transactionPromotion);
2940
2957
  if (!this.webReturnObject.basket.transactionPromotion) {
2941
2958
  this.webReturnObject.basket.transactionPromotion = [];
2942
2959
  }
@@ -2959,7 +2976,7 @@ class WebReturnMapperBuilderClass {
2959
2976
  return product;
2960
2977
  }
2961
2978
  transactionPromotionProductPortionCalc(txDoc, promotion) {
2962
- console.log(`ebasket: transactionPromotionProductPortionCalc: trnsactionPromotion: ${JSON.stringify(promotion)}`);
2979
+ AppLoggerService.logDebug(this.className, "transactionPromotionProductPortionCalc", `trnsactionPromotion: ${JSON.stringify(promotion)}`);
2963
2980
  if (promotion.type === PROMOTION_TYPE.COUPON && promotion.subLevelType === PROMOTION_LEVEL.LINE) {
2964
2981
  txDoc.basket.products.forEach((product) => {
2965
2982
  product = this.validateProductItemDiscount(product);
@@ -3001,7 +3018,7 @@ class WebReturnMapperBuilderClass {
3001
3018
  }
3002
3019
  }
3003
3020
  catch (error) {
3004
- console.log("updateTransactionPromotionPrtionCalc => failed:", JSON.stringify(error));
3021
+ AppLoggerService.logError(this.className, "updateTransactionPromotionPrtionCalc", "updateTransactionPromotionPrtionCalc => failed:", error);
3005
3022
  }
3006
3023
  }
3007
3024
  deviceId(deviceId) {
@@ -3057,11 +3074,11 @@ class WebReturnMapperBuilderClass {
3057
3074
  }
3058
3075
  }
3059
3076
  isInStoreOrder() {
3060
- console.log("Mapper library: WebReturnMapperBuilderClass: isInStoreOrder mapping started...");
3077
+ AppLoggerService.logDebug(this.className, "isInStoreOrder", "isInStoreOrder mapping started...");
3061
3078
  if (this.document.payment && this.document.payment.method && this.document.payment.method === 'pos_order') {
3062
3079
  this.webReturnObject.isInStoreOrder = true;
3063
3080
  }
3064
- console.log("Mapper library: WebReturnMapperBuilderClass: isInStoreOrder mapping ended...");
3081
+ AppLoggerService.logDebug(this.className, "isInStoreOrder", "isInStoreOrder mapping ended...");
3065
3082
  return this;
3066
3083
  }
3067
3084
  }
@@ -3069,6 +3086,7 @@ class WebReturnMapperBuilderClass {
3069
3086
  class WebReturnSalesforceMapperBuilderClass {
3070
3087
  constructor(orderDetails, currencyPipe) {
3071
3088
  this.currencyPipe = currencyPipe;
3089
+ this.className = "WebReturnSalesforceMapperBuilderClass";
3072
3090
  this.webReturnObject = {
3073
3091
  id: '',
3074
3092
  orgCode: "",
@@ -3103,7 +3121,7 @@ class WebReturnSalesforceMapperBuilderClass {
3103
3121
  this.numberUtilService = new NumberUtilService(currencyPipe);
3104
3122
  }
3105
3123
  webReturnCommonMapper() {
3106
- console.log("Mapper library: WebReturnSalesforceMapperBuilderClass: webReturnCommonMapper started...");
3124
+ AppLoggerService.logDebug(this.className, "webReturnCommonMapper", "Mapper library: WebReturnSalesforceMapperBuilderClass: webReturnCommonMapper started...");
3107
3125
  this.webReturnObject['type'] = TRANSACTION_TYPE.WEB_RETURNS;
3108
3126
  this.webReturnObject['datetime'] = this.getUTCDateTime(this.orderDetails.last_modified);
3109
3127
  this.webReturnObject.baseCurrency = this.orderDetails.currency;
@@ -3114,13 +3132,13 @@ class WebReturnSalesforceMapperBuilderClass {
3114
3132
  this.webReturnObject.updatedAt = this.getUTCDateTime(this.orderDetails.last_modified);
3115
3133
  this.webReturnObject.transCompletedAt = this.getUTCDateTime(this.orderDetails.last_modified);
3116
3134
  this.webReturnObject['externalTransactionId'] = this.orderDetails.order_no;
3117
- console.log("Mapper library: WebReturnSalesforceMapperBuilderClass: webReturnCommonMapper ended...");
3135
+ AppLoggerService.logDebug(this.className, "webReturnCommonMapper", "webReturnCommonMapper ended...");
3118
3136
  return this;
3119
3137
  }
3120
3138
  // export(status, details) {
3121
- // console.log("Mapper library: WebReturnSalesforceMapperBuilderClass: export mapping started...");
3122
- // console.log("Mapper library: WebReturnSalesforceMapperBuilderClass: status:", status);
3123
- // console.log("Mapper library: WebReturnSalesforceMapperBuilderClass: details:", JSON.stringify(details));
3139
+ // AppLoggerService.logDebug(this.className, "Mapper library: WebReturnSalesforceMapperBuilderClass: export mapping started...");
3140
+ // AppLoggerService.logDebug(this.className, "Mapper library: WebReturnSalesforceMapperBuilderClass: status:", status);
3141
+ // AppLoggerService.logDebug(this.className, "Mapper library: WebReturnSalesforceMapperBuilderClass: details:", JSON.stringify(details));
3124
3142
  // if (status && details && details.providers && details.providers.length > 0) {
3125
3143
  // details.providers.forEach(
3126
3144
  // providerObj => {
@@ -3134,7 +3152,7 @@ class WebReturnSalesforceMapperBuilderClass {
3134
3152
  // } else {
3135
3153
  // this.webReturnObject.export = false;
3136
3154
  // }
3137
- // console.log("Mapper library: WebReturnSalesforceMapperBuilderClass: export mapping end...")
3155
+ // AppLoggerService.logDebug(this.className, "Mapper library: WebReturnSalesforceMapperBuilderClass: export mapping end...")
3138
3156
  // return this;
3139
3157
  // }
3140
3158
  getDeliveryMethod() {
@@ -3150,7 +3168,7 @@ class WebReturnSalesforceMapperBuilderClass {
3150
3168
  }
3151
3169
  }
3152
3170
  product() {
3153
- console.log("Mapper library: WebReturnSalesforceMapperBuilderClass: product mapping started...");
3171
+ AppLoggerService.logDebug(this.className, "product", "product mapping started...");
3154
3172
  this.webReturnObject.basket['products'] = [];
3155
3173
  if (this.orderDetails.product_items && this.orderDetails.product_items.length > 0) {
3156
3174
  this.orderDetails.product_items.forEach((product, index) => {
@@ -3169,11 +3187,11 @@ class WebReturnSalesforceMapperBuilderClass {
3169
3187
  }
3170
3188
  });
3171
3189
  }
3172
- console.log("Mapper library: WebReturnSalesforceMapperBuilderClass: product mapping ended...");
3190
+ AppLoggerService.logDebug(this.className, "product", "product mapping ended...");
3173
3191
  return this;
3174
3192
  }
3175
3193
  linePromotion() {
3176
- console.log("Mapper library: WebReturnSalesforceMapperBuilderClass: linePromotion mapping started...");
3194
+ AppLoggerService.logDebug(this.className, "linePromotion", "linePromotion mapping started...");
3177
3195
  this.webReturnObject.basket.linePromotion = [];
3178
3196
  let linePromotionArray = [];
3179
3197
  if (this.orderDetails.product_items && this.orderDetails.product_items.length > 0) {
@@ -3203,14 +3221,14 @@ class WebReturnSalesforceMapperBuilderClass {
3203
3221
  });
3204
3222
  }
3205
3223
  this.webReturnObject.basket.linePromotion = linePromotionArray;
3206
- console.log("Mapper library: WebReturnSalesforceMapperBuilderClass: linePromotion mapping ended...");
3224
+ AppLoggerService.logDebug(this.className, "linePromotion", "linePromotion mapping ended...");
3207
3225
  return this;
3208
3226
  }
3209
3227
  transactionPromotion() {
3210
- console.log("Mapper library: WebReturnSalesforceMapperBuilderClass: transactionPromotion mapping started...");
3228
+ AppLoggerService.logDebug(this.className, "transactionPromotion", "transactionPromotion mapping started...");
3211
3229
  let transactionPromotionArray = this.getTransactionPromotions(this.orderDetails);
3212
3230
  this.webReturnObject.basket.transactionPromotion = transactionPromotionArray;
3213
- console.log("Mapper library: WebReturnSalesforceMapperBuilderClass: transactionPromotion mapping ended...");
3231
+ AppLoggerService.logDebug(this.className, "transactionPromotion", "transactionPromotion mapping ended...");
3214
3232
  return this;
3215
3233
  }
3216
3234
  getTransactionPromotions(basket) {
@@ -3234,12 +3252,11 @@ class WebReturnSalesforceMapperBuilderClass {
3234
3252
  transactionPromotionArray.push(transactionPromotionObj);
3235
3253
  });
3236
3254
  }
3237
- console.log("Mapper library: WebReturnSalesforceMapperBuilderClass: getTransactionPromotions : ", JSON.stringify(transactionPromotionArray));
3255
+ AppLoggerService.logDebug(this.className, "getTransactionPromotions", "getTransactionPromotions : ", transactionPromotionArray);
3238
3256
  return transactionPromotionArray;
3239
3257
  }
3240
3258
  catch (error) {
3241
- console.log("Mapper library: WebReturnSalesforceMapperBuilderClass: failed:", error);
3242
- console.log("Mapper library: WebReturnSalesforceMapperBuilderClass: failed:", JSON.stringify(error));
3259
+ AppLoggerService.logError(this.className, "getTransactionPromotions", "failed:", error);
3243
3260
  throw new Error(error);
3244
3261
  }
3245
3262
  }
@@ -3279,8 +3296,7 @@ class WebReturnSalesforceMapperBuilderClass {
3279
3296
  transactionPromotion.subLevelType = PROMOTION_LEVEL.LINE;
3280
3297
  transactionPromotion.trigger = triggerPromotion;
3281
3298
  }
3282
- console.log("linePromotion mapping ended...");
3283
- console.log("e-basket: updateLinePromotionWithCoupon", JSON.stringify(transactionPromotion));
3299
+ AppLoggerService.logDebug(this.className, "updateLinePromotionWithCoupon", "transactionPromotion", transactionPromotion);
3284
3300
  if (!this.webReturnObject.basket.transactionPromotion) {
3285
3301
  this.webReturnObject.basket.transactionPromotion = [];
3286
3302
  }
@@ -3290,8 +3306,7 @@ class WebReturnSalesforceMapperBuilderClass {
3290
3306
  return this;
3291
3307
  }
3292
3308
  catch (error) {
3293
- console.log("Ebasket: Salesforce: linePromotion mapping=> failed:", error);
3294
- console.log("Ebasket: Salesforce: linePromotion mapping=> failed:", JSON.stringify(error));
3309
+ AppLoggerService.logError(this.className, "updateLinePromotionWithCoupon", "linePromotion mapping=> failed:", error);
3295
3310
  throw new Error(error);
3296
3311
  }
3297
3312
  }
@@ -3304,7 +3319,7 @@ class WebReturnSalesforceMapperBuilderClass {
3304
3319
  return this;
3305
3320
  }
3306
3321
  transactionPromotionProductPortionCalc(txDoc, promotion) {
3307
- console.log(`ebasket: transactionPromotionProductPortionCalc: trnsactionPromotion: ${JSON.stringify(promotion)}`);
3322
+ AppLoggerService.logDebug(this.className, "transactionPromotionProductPortionCalc", `trnsactionPromotion: ${JSON.stringify(promotion)}`);
3308
3323
  if (promotion.type === PROMOTION_TYPE.COUPON && promotion.subLevelType === PROMOTION_LEVEL.LINE) {
3309
3324
  txDoc.basket.products.forEach((product) => {
3310
3325
  product = this.validateProductItemDiscount(product);
@@ -3341,7 +3356,7 @@ class WebReturnSalesforceMapperBuilderClass {
3341
3356
  return product;
3342
3357
  }
3343
3358
  customer() {
3344
- console.log("Mapper library: WebReturnSalesforceMapperBuilderClass: customer mapping started...");
3359
+ AppLoggerService.logDebug(this.className, "customer", "customer mapping started...");
3345
3360
  let customerObj = {};
3346
3361
  customerObj.email = this.orderDetails.customer_info && this.orderDetails.customer_info.email ? this.orderDetails.customer_info.email : '';
3347
3362
  customerObj.firstName = this.orderDetails.billing_address && this.orderDetails.billing_address.first_name ? this.orderDetails.billing_address.first_name : '';
@@ -3377,19 +3392,19 @@ class WebReturnSalesforceMapperBuilderClass {
3377
3392
  });
3378
3393
  customerObj.shipmentDetails = shipmentDetails;
3379
3394
  this.webReturnObject.customer = customerObj;
3380
- console.log("Mapper library: WebReturnSalesforceMapperBuilderClass: customer mapping ended...");
3395
+ AppLoggerService.logDebug(this.className, "customer", "customer mapping ended...");
3381
3396
  return this;
3382
3397
  }
3383
3398
  isInStoreOrder() {
3384
- console.log("Mapper library: WebReturnSalesforceMapperBuilderClass: isInStoreOrder mapping started...");
3399
+ AppLoggerService.logDebug(this.className, "isInStoreOrder", "isInStoreOrder mapping started...");
3385
3400
  if (this.orderDetails.c_isInStoreOrder) {
3386
3401
  this.webReturnObject.isInStoreOrder = true;
3387
3402
  }
3388
- console.log("Mapper library: WebReturnSalesforceMapperBuilderClass: isInStoreOrder mapping ended...");
3403
+ AppLoggerService.logDebug(this.className, "isInStoreOrder", "isInStoreOrder mapping ended...");
3389
3404
  return this;
3390
3405
  }
3391
3406
  externalTransactionDetails() {
3392
- console.log("Mapper library: WebReturnSalesforceMapperBuilderClass: externalTransactionDetails mapping started...");
3407
+ AppLoggerService.logDebug(this.className, "externalTransactionDetails", "externalTransactionDetails mapping started...");
3393
3408
  let externalTransactionDetails = [];
3394
3409
  if (this.orderDetails.shipments && this.orderDetails.shipments.length > 0) {
3395
3410
  this.orderDetails.shipments.forEach(shipment => {
@@ -3404,11 +3419,11 @@ class WebReturnSalesforceMapperBuilderClass {
3404
3419
  });
3405
3420
  }
3406
3421
  this.webReturnObject.externalTransactionDetails = externalTransactionDetails;
3407
- console.log("Mapper library: WebReturnSalesforceMapperBuilderClass: externalTransactionDetails mapping ended...");
3422
+ AppLoggerService.logDebug(this.className, "externalTransactionDetails", "externalTransactionDetails mapping ended...");
3408
3423
  return this;
3409
3424
  }
3410
3425
  basketSummary() {
3411
- console.log("Mapper library: WebReturnSalesforceMapperBuilderClass: basketSummary mapping started...");
3426
+ AppLoggerService.logDebug(this.className, "basketSummary", "basketSummary mapping started...");
3412
3427
  let basketSummary = {};
3413
3428
  let basketSummaryWebOrder = {};
3414
3429
  const linePromotionTotal = this.webReturnObject.basket.linePromotion.map(linePromotion => linePromotion.promotionAmount).reduce((accumulator, currentValue) => accumulator + currentValue, 0);
@@ -3424,7 +3439,7 @@ class WebReturnSalesforceMapperBuilderClass {
3424
3439
  basketSummaryWebOrder.basketTotalWithShippingTotal = this.orderDetails.order_total ? this.orderDetails.order_total : 0;
3425
3440
  basketSummary.webOrder = basketSummaryWebOrder;
3426
3441
  this.webReturnObject.basketSummary = basketSummary;
3427
- console.log("Mapper library: WebReturnSalesforceMapperBuilderClass: basketSummary mapping ended...");
3442
+ AppLoggerService.logDebug(this.className, "basketSummary", "basketSummary mapping ended...");
3428
3443
  return this;
3429
3444
  }
3430
3445
  deviceId(deviceId) {
@@ -3464,7 +3479,7 @@ class WebReturnSalesforceMapperBuilderClass {
3464
3479
  return this;
3465
3480
  }
3466
3481
  build() {
3467
- console.log("Mapper library: WebReturnSalesforceMapperBuilderClass: mapping done...");
3482
+ AppLoggerService.logDebug(this.className, "build", "mapping done...");
3468
3483
  return this.webReturnObject;
3469
3484
  }
3470
3485
  getUTCDateTime(date) {