@pmcretail/mapper-library 0.0.43 → 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.
- package/bundles/pmcretail-mapper-library.umd.js +4165 -0
- package/bundles/pmcretail-mapper-library.umd.js.map +1 -0
- package/esm2015/lib/RJ-mapper.class.js +877 -0
- package/esm2015/lib/TransactionDocumentBuilder.js +1244 -0
- package/esm2015/lib/WebReturn-mapper.class.js +326 -0
- package/esm2015/lib/WebReturnSalesforceMapper.class.js +409 -0
- package/esm2015/lib/basket.service.js +527 -0
- package/esm2015/lib/mapper-library.component.js +26 -0
- package/esm2015/lib/mapper-library.module.js +21 -0
- package/esm2015/lib/number-util.service.js +42 -0
- package/{fesm2022/pmcretail-mapper-library.mjs → fesm2015/pmcretail-mapper-library.js} +173 -154
- package/fesm2015/pmcretail-mapper-library.js.map +1 -0
- package/lib/RJ-mapper.class.d.ts +1 -0
- package/lib/RJ-mapper.class.d.ts.map +1 -1
- package/lib/TransactionDocumentBuilder.d.ts +1 -0
- package/lib/TransactionDocumentBuilder.d.ts.map +1 -1
- package/lib/WebReturn-mapper.class.d.ts +1 -0
- package/lib/WebReturn-mapper.class.d.ts.map +1 -1
- package/lib/WebReturnSalesforceMapper.class.d.ts +1 -0
- package/lib/WebReturnSalesforceMapper.class.d.ts.map +1 -1
- package/lib/basket.service.d.ts +1 -0
- package/lib/basket.service.d.ts.map +1 -1
- package/lib/mapper-library.component.d.ts +1 -1
- package/lib/number-util.service.d.ts +1 -0
- package/lib/number-util.service.d.ts.map +1 -1
- package/package.json +9 -16
- package/esm2022/lib/RJ-mapper.class.mjs +0 -875
- package/esm2022/lib/TransactionDocumentBuilder.mjs +0 -1240
- package/esm2022/lib/WebReturn-mapper.class.mjs +0 -324
- package/esm2022/lib/WebReturnSalesforceMapper.class.mjs +0 -410
- package/esm2022/lib/basket.service.mjs +0 -516
- package/esm2022/lib/mapper-library.component.mjs +0 -22
- package/esm2022/lib/mapper-library.module.mjs +0 -21
- package/esm2022/lib/number-util.service.mjs +0 -40
- package/fesm2022/pmcretail-mapper-library.mjs.map +0 -1
- /package/{esm2022/lib/mapper-library.model.mjs → esm2015/lib/mapper-library.model.js} +0 -0
- /package/{esm2022/pmcretail-mapper-library.mjs → esm2015/pmcretail-mapper-library.js} +0 -0
- /package/{esm2022/public-api.mjs → esm2015/public-api.js} +0 -0
- /package/{index.d.ts → pmcretail-mapper-library.d.ts} +0 -0
|
@@ -1,34 +1,39 @@
|
|
|
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 {
|
|
7
8
|
constructor() { }
|
|
8
9
|
ngOnInit() {
|
|
9
10
|
}
|
|
10
|
-
|
|
11
|
-
|
|
11
|
+
}
|
|
12
|
+
MapperLibraryComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: MapperLibraryComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
13
|
+
MapperLibraryComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "12.2.17", type: MapperLibraryComponent, selector: "lib-mapper-library", ngImport: i0, template: `
|
|
12
14
|
<p>
|
|
13
15
|
mapper-library works!
|
|
14
16
|
</p>
|
|
15
|
-
`, isInline: true });
|
|
16
|
-
|
|
17
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.4", ngImport: i0, type: MapperLibraryComponent, decorators: [{
|
|
17
|
+
`, isInline: true });
|
|
18
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: MapperLibraryComponent, decorators: [{
|
|
18
19
|
type: Component,
|
|
19
|
-
args: [{
|
|
20
|
+
args: [{
|
|
21
|
+
selector: 'lib-mapper-library',
|
|
22
|
+
template: `
|
|
20
23
|
<p>
|
|
21
24
|
mapper-library works!
|
|
22
25
|
</p>
|
|
23
|
-
|
|
24
|
-
|
|
26
|
+
`,
|
|
27
|
+
styles: []
|
|
28
|
+
}]
|
|
29
|
+
}], ctorParameters: function () { return []; } });
|
|
25
30
|
|
|
26
31
|
class MapperLibraryModule {
|
|
27
|
-
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.2.4", ngImport: i0, type: MapperLibraryModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule }); }
|
|
28
|
-
static { this.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "18.2.4", ngImport: i0, type: MapperLibraryModule, declarations: [MapperLibraryComponent], exports: [MapperLibraryComponent] }); }
|
|
29
|
-
static { this.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "18.2.4", ngImport: i0, type: MapperLibraryModule }); }
|
|
30
32
|
}
|
|
31
|
-
i0.ɵɵ
|
|
33
|
+
MapperLibraryModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: MapperLibraryModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
|
|
34
|
+
MapperLibraryModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: MapperLibraryModule, declarations: [MapperLibraryComponent], exports: [MapperLibraryComponent] });
|
|
35
|
+
MapperLibraryModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: MapperLibraryModule, imports: [[]] });
|
|
36
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: MapperLibraryModule, decorators: [{
|
|
32
37
|
type: NgModule,
|
|
33
38
|
args: [{
|
|
34
39
|
declarations: [
|
|
@@ -81,12 +86,6 @@ var PROMOTION_TYPE;
|
|
|
81
86
|
})(PROMOTION_TYPE || (PROMOTION_TYPE = {}));
|
|
82
87
|
|
|
83
88
|
class BasketService {
|
|
84
|
-
get isMixedBasketSales() {
|
|
85
|
-
return this._isMixedBasketSales;
|
|
86
|
-
}
|
|
87
|
-
set isMixedBasketSales(v) {
|
|
88
|
-
this._isMixedBasketSales = v;
|
|
89
|
-
}
|
|
90
89
|
constructor(numberUtilService) {
|
|
91
90
|
this.numberUtilService = numberUtilService;
|
|
92
91
|
this.currentBasket = {
|
|
@@ -105,6 +104,13 @@ class BasketService {
|
|
|
105
104
|
this.peerSync = this.peerSource.asObservable();
|
|
106
105
|
this.scanSource = new BehaviorSubject(false);
|
|
107
106
|
this.scanner = this.scanSource.asObservable();
|
|
107
|
+
this.className = "BasketService";
|
|
108
|
+
}
|
|
109
|
+
get isMixedBasketSales() {
|
|
110
|
+
return this._isMixedBasketSales;
|
|
111
|
+
}
|
|
112
|
+
set isMixedBasketSales(v) {
|
|
113
|
+
this._isMixedBasketSales = v;
|
|
108
114
|
}
|
|
109
115
|
updateBasket(basket) {
|
|
110
116
|
this.currentBasket = basket;
|
|
@@ -125,7 +131,9 @@ class BasketService {
|
|
|
125
131
|
this.numberUtilService.trimTo2Decimal(basketDetails.total) +
|
|
126
132
|
this.numberUtilService.trimTo2Decimal(p.total);
|
|
127
133
|
}
|
|
128
|
-
|
|
134
|
+
AppLoggerService.logDebug(this.className, "updateBasketTotal", `basketDetails updated values for transaction id
|
|
135
|
+
${basketDetails.transactionId}, basketDetails
|
|
136
|
+
${JSON.stringify(basketDetails)}`);
|
|
129
137
|
basketDetails.basketTotal = basketDetails.total;
|
|
130
138
|
basketState.updateBasket(basketDetails);
|
|
131
139
|
}
|
|
@@ -135,7 +143,9 @@ class BasketService {
|
|
|
135
143
|
* @returns basketDetails
|
|
136
144
|
*/
|
|
137
145
|
addlinePromotion(promotionList, basketDetails) {
|
|
138
|
-
|
|
146
|
+
AppLoggerService.logDebug(this.className, "addlinePromotion", `promotionList ${JSON.stringify(promotionList)} and
|
|
147
|
+
basketDetails
|
|
148
|
+
${JSON.stringify(basketDetails)} for linePromotions`);
|
|
139
149
|
if (promotionList &&
|
|
140
150
|
promotionList.result &&
|
|
141
151
|
promotionList.result.linePromotions &&
|
|
@@ -157,7 +167,9 @@ class BasketService {
|
|
|
157
167
|
* @returns basketDetails
|
|
158
168
|
*/
|
|
159
169
|
addTransactionPromotion(promotionList, basketdetails) {
|
|
160
|
-
|
|
170
|
+
AppLoggerService.logDebug(this.className, "addTransactionPromotion", `promotionList ${JSON.stringify(promotionList)} and
|
|
171
|
+
basketDetails
|
|
172
|
+
${JSON.stringify(basketdetails)} for transactionPromotions ${JSON.stringify(basketdetails.transactionPromotion)}`);
|
|
161
173
|
if (promotionList &&
|
|
162
174
|
promotionList.result &&
|
|
163
175
|
promotionList.result.transactionPromotion &&
|
|
@@ -174,7 +186,7 @@ class BasketService {
|
|
|
174
186
|
basketdetails = this.transactionPromotionProductPortionCalc(basketdetails, transactionPromotionEntryUpdated);
|
|
175
187
|
});
|
|
176
188
|
}
|
|
177
|
-
|
|
189
|
+
AppLoggerService.logDebug(this.className, "addTransactionPromotion", "basket details in refund calculation file", basketdetails);
|
|
178
190
|
return basketdetails;
|
|
179
191
|
}
|
|
180
192
|
updateProductTotalForSummary(basketDetails) {
|
|
@@ -205,7 +217,7 @@ class BasketService {
|
|
|
205
217
|
basketDetails.quantity +
|
|
206
218
|
(product.quantity -
|
|
207
219
|
(product.refundedQuantity ? product.refundedQuantity : 0));
|
|
208
|
-
|
|
220
|
+
AppLoggerService.logDebug(this.className, "updateProductTotalForSummary", "update basketdetails total :" +
|
|
209
221
|
basketDetails.total +
|
|
210
222
|
" Product line ID : " +
|
|
211
223
|
product.itemLineId +
|
|
@@ -216,19 +228,19 @@ class BasketService {
|
|
|
216
228
|
}
|
|
217
229
|
updateBasketTotalForSummary(basketDetails) {
|
|
218
230
|
basketDetails.basketTotal = basketDetails.total;
|
|
219
|
-
|
|
220
|
-
|
|
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);
|
|
221
233
|
basketDetails = this.updateTransactionPromotion(basketDetails);
|
|
222
234
|
basketDetails = this.updateTransactionDiscount(basketDetails);
|
|
223
235
|
basketDetails.basketTotal = Number(basketDetails.basketTotal.toFixed(2));
|
|
224
|
-
|
|
236
|
+
AppLoggerService.logInfo(this.className, "updateBasketTotalForSummary", "update Basket Total: basketTotal after promotion applied for basketTotal", basketDetails.basketTotal);
|
|
225
237
|
return basketDetails;
|
|
226
238
|
}
|
|
227
239
|
updateTransactionDiscount(basketDetails) {
|
|
228
240
|
if (basketDetails.transactionDiscount &&
|
|
229
241
|
basketDetails.transactionDiscount.length > 0) {
|
|
230
242
|
const discountTotal = basketDetails.transactionDiscount.reduce((n, { discountAmount }) => n + discountAmount, 0);
|
|
231
|
-
|
|
243
|
+
AppLoggerService.logDebug(this.className, "updateTransactionDiscount", "discountTotal ", discountTotal);
|
|
232
244
|
basketDetails.basketTotal =
|
|
233
245
|
basketDetails.basketTotal - Math.abs(discountTotal);
|
|
234
246
|
}
|
|
@@ -264,7 +276,7 @@ class BasketService {
|
|
|
264
276
|
basket.quantity +
|
|
265
277
|
(product.quantity -
|
|
266
278
|
(product.refundedQuantity ? product.refundedQuantity : 0));
|
|
267
|
-
|
|
279
|
+
AppLoggerService.logDebug(this.className, "updateBasketTotalWithoutDiscount", "e-basket:basket service:update basketdetails total :" +
|
|
268
280
|
JSON.stringify(basket) +
|
|
269
281
|
basket.total +
|
|
270
282
|
" Product line ID : " +
|
|
@@ -276,7 +288,8 @@ class BasketService {
|
|
|
276
288
|
return basket;
|
|
277
289
|
}
|
|
278
290
|
updateBasketTotalWithDiscounts(basket) {
|
|
279
|
-
|
|
291
|
+
AppLoggerService.logDebug(this.className, "updateBasketTotalWithDiscounts", `this.basketDetails new values ${basket},
|
|
292
|
+
${JSON.stringify(basket.basketTotal)}`);
|
|
280
293
|
if (basket.transactionPromotion && basket.transactionPromotion.length > 0) {
|
|
281
294
|
const discountTotal = basket.transactionPromotion.reduce((n, { promotionAmount }) => n + promotionAmount, 0);
|
|
282
295
|
basket.basketTotal = basket.basketTotal - discountTotal;
|
|
@@ -285,7 +298,7 @@ class BasketService {
|
|
|
285
298
|
const discountTotal = basket.transactionDiscount.reduce((n, { discountAmount }) => n + discountAmount, 0);
|
|
286
299
|
basket.basketTotal = basket.basketTotal - discountTotal;
|
|
287
300
|
}
|
|
288
|
-
|
|
301
|
+
AppLoggerService.logDebug(this.className, "updateBasketTotalWithDiscounts", "basket new values", basket);
|
|
289
302
|
return basket;
|
|
290
303
|
}
|
|
291
304
|
transactionDiscountAndPromotionProductortionCalculation(basket) {
|
|
@@ -297,7 +310,9 @@ class BasketService {
|
|
|
297
310
|
basket = this.transactionPromotionProductPortionCalc(basket, promotion);
|
|
298
311
|
});
|
|
299
312
|
}
|
|
300
|
-
|
|
313
|
+
AppLoggerService.logDebug(this.className, "transactionDiscountAndPromotionProductortionCalculation", `basket item discount protion calculation ,
|
|
314
|
+
${basket},
|
|
315
|
+
${basket.products}`);
|
|
301
316
|
return basket;
|
|
302
317
|
}
|
|
303
318
|
transactionPromotionProductPortionCalc(basket, promotion) {
|
|
@@ -313,7 +328,7 @@ class BasketService {
|
|
|
313
328
|
total += (p.total - this.numberUtilService.trimTo2Decimal2(productContributionInTotal));
|
|
314
329
|
}
|
|
315
330
|
});
|
|
316
|
-
|
|
331
|
+
AppLoggerService.logDebug(this.className, "transactionPromotionProductPortionCalc", `ebasket: trnsactionPromotion: ${JSON.stringify(promotion)}, selected products total: ${total}`);
|
|
317
332
|
basket.products.forEach((product) => {
|
|
318
333
|
product = this.validateProductItemDiscount(product);
|
|
319
334
|
const productContributionInTotal = this.numberUtilService.trimTo2Decimal2(product.itemDiscounts.trnDiscountsPortion) +
|
|
@@ -341,10 +356,10 @@ class BasketService {
|
|
|
341
356
|
total += (p.total - this.numberUtilService.trimTo2Decimal2(productContributionInTotal));
|
|
342
357
|
}
|
|
343
358
|
});
|
|
344
|
-
|
|
359
|
+
AppLoggerService.logDebug(this.className, "transactionDiscountProductPortionCalc", `ebasket: trnsactionDiscount: ${JSON.stringify(discount)}, selected products total: ${total}`);
|
|
345
360
|
basket.products.forEach((product) => {
|
|
346
361
|
product = this.validateProductItemDiscount(product);
|
|
347
|
-
|
|
362
|
+
AppLoggerService.logDebug(this.className, "transactionDiscountProductPortionCalc", "discountable in basket service", product.discountable);
|
|
348
363
|
const productContributionInTotal = this.numberUtilService.trimTo2Decimal2(product.itemDiscounts.trnDiscountsPortion) +
|
|
349
364
|
this.numberUtilService.trimTo2Decimal2(product.itemDiscounts.trnPromotionsPortion) -
|
|
350
365
|
this.numberUtilService.trimTo2Decimal2(product.itemDiscounts.refundPortion);
|
|
@@ -410,7 +425,7 @@ class BasketService {
|
|
|
410
425
|
return largestNumber + 1;
|
|
411
426
|
}
|
|
412
427
|
updateBasketProductDataAsPerQuantity(product, quantity) {
|
|
413
|
-
|
|
428
|
+
AppLoggerService.logDebug(this.className, "updateBasketProductDataAsPerQuantity", `ebasket: updateBasketProductDataAsPerQuantity : ${quantity} product: ${JSON.stringify(product)}`);
|
|
414
429
|
product.quantity = quantity;
|
|
415
430
|
if (product.hasOwnProperty("lineDiscount")) {
|
|
416
431
|
// && this.product.quantity !== this.productDetailForm.controls.quantity.value
|
|
@@ -428,11 +443,11 @@ class BasketService {
|
|
|
428
443
|
else {
|
|
429
444
|
product.total = product.totalLinePrice;
|
|
430
445
|
}
|
|
431
|
-
|
|
446
|
+
AppLoggerService.logDebug(this.className, "updateBasketProductDataAsPerQuantity", `ebasket: updateBasketProductDataAsPerQuantity : ${quantity} product: ${JSON.stringify(product)}`);
|
|
432
447
|
return product;
|
|
433
448
|
}
|
|
434
449
|
filterProductListWithWebOrder(isWebOrder) {
|
|
435
|
-
|
|
450
|
+
AppLoggerService.logDebug(this.className, "filterProductListWithWebOrder", "filterProductListWithWebOrder hit", this.currentBasket.products);
|
|
436
451
|
if (isWebOrder)
|
|
437
452
|
return this.currentBasket.products.filter((x) => x.isWebOrder);
|
|
438
453
|
else {
|
|
@@ -440,11 +455,11 @@ class BasketService {
|
|
|
440
455
|
}
|
|
441
456
|
}
|
|
442
457
|
filterProductListWithDelivery() {
|
|
443
|
-
|
|
458
|
+
AppLoggerService.logDebug(this.className, "filterProductListWithDelivery", "filterProductListWithDelivery hit", this.currentBasket.products);
|
|
444
459
|
return this.currentBasket.products.filter((x) => x.deliveryMethod === DELIVERY_METHODS.DELIVERY.toString());
|
|
445
460
|
}
|
|
446
461
|
filterProductListWithDeliveryGroup(group, products) {
|
|
447
|
-
|
|
462
|
+
AppLoggerService.logDebug(this.className, "filterProductListWithDeliveryGroup", "filterProductListWithDeliveryGroup hit", products);
|
|
448
463
|
return products.filter((x) => x.deliveryGroup === group);
|
|
449
464
|
}
|
|
450
465
|
generateNewDeliveryGroupNumber(products) {
|
|
@@ -461,7 +476,7 @@ class BasketService {
|
|
|
461
476
|
return (largestNumber + 1).toString();
|
|
462
477
|
}
|
|
463
478
|
getDeliveryGroupNumbers(products) {
|
|
464
|
-
|
|
479
|
+
AppLoggerService.logDebug(this.className, "getDeliveryGroupNumbers", "getDeliveryGroupNumbers initiating : ", products);
|
|
465
480
|
let uniqueAndsortedResult = [];
|
|
466
481
|
if (products.length > 0) {
|
|
467
482
|
let deliveryGroupArr = products.map((product) => {
|
|
@@ -474,12 +489,12 @@ class BasketService {
|
|
|
474
489
|
return 0;
|
|
475
490
|
});
|
|
476
491
|
uniqueAndsortedResult = Array.from(new Set(deliveryGroupArr)).sort((a, b) => a - b);
|
|
477
|
-
|
|
492
|
+
AppLoggerService.logDebug(this.className, "getDeliveryGroupNumbers", "getDeliveryGroupNumbers : uniqueAndsortedResult", uniqueAndsortedResult);
|
|
478
493
|
}
|
|
479
494
|
return uniqueAndsortedResult;
|
|
480
495
|
}
|
|
481
496
|
updateProductsWithNewDeliveryGroupNumber(products) {
|
|
482
|
-
|
|
497
|
+
AppLoggerService.logDebug(this.className, "updateProductsWithNewDeliveryGroupNumber", "initiating : ", products);
|
|
483
498
|
let newGroupNumber = this.generateNewDeliveryGroupNumber(this.currentBasket.products);
|
|
484
499
|
if (products.length > 0) {
|
|
485
500
|
this.currentBasket.products.forEach(cBProducts => {
|
|
@@ -503,31 +518,31 @@ class BasketService {
|
|
|
503
518
|
time = Number(element.leadTime.value) * 24 * 7;
|
|
504
519
|
estmatedTime = Math.max(estmatedTime, time);
|
|
505
520
|
estimatedDays = (estmatedTime === time) ? element.leadTime.type : estimatedDays;
|
|
506
|
-
|
|
521
|
+
AppLoggerService.logDebug(this.className, "calculateEstimatedTime", `week ${estmatedTime} ${estimatedDays}`);
|
|
507
522
|
}
|
|
508
523
|
else if (element.leadTime.type.toLocaleLowerCase() === "days") {
|
|
509
524
|
time = Number(element.leadTime.value) * 24;
|
|
510
525
|
estmatedTime = Math.max(estmatedTime, time);
|
|
511
526
|
estimatedDays = (estmatedTime === time) ? element.leadTime.type : estimatedDays;
|
|
512
|
-
|
|
527
|
+
AppLoggerService.logDebug(this.className, "calculateEstimatedTime", `days ${estmatedTime} ${estimatedDays}`);
|
|
513
528
|
}
|
|
514
529
|
else if (element.leadTime.type.toLocaleLowerCase() === "months") {
|
|
515
530
|
time = Number(element.leadTime.value) * 24 * 30;
|
|
516
531
|
estmatedTime = Math.max(estmatedTime, time);
|
|
517
532
|
estimatedDays = (estmatedTime === time) ? element.leadTime.type : estimatedDays;
|
|
518
|
-
|
|
533
|
+
AppLoggerService.logDebug(this.className, "calculateEstimatedTime", `months ${estmatedTime} ${estimatedDays}`);
|
|
519
534
|
}
|
|
520
535
|
else if (element.leadTime.type.toLocaleLowerCase() === "years") {
|
|
521
536
|
time = Number(element.leadTime.value) * 24 * 365;
|
|
522
537
|
estmatedTime = Math.max(estmatedTime, time);
|
|
523
538
|
estimatedDays = (estmatedTime === time) ? element.leadTime.type : estimatedDays;
|
|
524
|
-
|
|
539
|
+
AppLoggerService.logDebug(this.className, "calculateEstimatedTime", `years ${estmatedTime} ${estimatedDays}`);
|
|
525
540
|
}
|
|
526
541
|
else {
|
|
527
542
|
time = Number(element.leadTime.value);
|
|
528
543
|
estmatedTime = Math.max(estmatedTime, time);
|
|
529
544
|
estimatedDays = (estmatedTime === time) ? element.leadTime.type : estimatedDays;
|
|
530
|
-
|
|
545
|
+
AppLoggerService.logDebug(this.className, "calculateEstimatedTime", `hours ${estmatedTime} ${estimatedDays}`);
|
|
531
546
|
}
|
|
532
547
|
});
|
|
533
548
|
if (estimatedDays.toLocaleLowerCase() === "days") {
|
|
@@ -549,12 +564,12 @@ class BasketService {
|
|
|
549
564
|
return estimate;
|
|
550
565
|
}
|
|
551
566
|
catch (error) {
|
|
552
|
-
|
|
567
|
+
AppLoggerService.logError(this.className, "calculateEstimatedTime", "error in calculateEstimatedTime", error);
|
|
553
568
|
}
|
|
554
569
|
return 0;
|
|
555
570
|
}
|
|
556
571
|
updateProductsWithDeliveryGroupNumber(oldGroup, newGroup) {
|
|
557
|
-
|
|
572
|
+
AppLoggerService.logDebug(this.className, "updateProductsWithDeliveryGroupNumber initiating");
|
|
558
573
|
this.currentBasket.products.forEach(cBProducts => {
|
|
559
574
|
if (cBProducts.deliveryGroup === oldGroup) {
|
|
560
575
|
cBProducts.deliveryGroup = newGroup;
|
|
@@ -564,7 +579,7 @@ class BasketService {
|
|
|
564
579
|
return;
|
|
565
580
|
}
|
|
566
581
|
getDeliveryInfo() {
|
|
567
|
-
|
|
582
|
+
AppLoggerService.logDebug(this.className, "getDeliveryInfo", "getDeliveryGroupInfor initiating");
|
|
568
583
|
try {
|
|
569
584
|
let groupInfo = {
|
|
570
585
|
groups: []
|
|
@@ -589,7 +604,7 @@ class BasketService {
|
|
|
589
604
|
return groupInfo;
|
|
590
605
|
}
|
|
591
606
|
catch (error) {
|
|
592
|
-
|
|
607
|
+
AppLoggerService.logError(this.className, "getDeliveryInfo", "error while getting delivery info", error);
|
|
593
608
|
}
|
|
594
609
|
}
|
|
595
610
|
}
|
|
@@ -597,6 +612,7 @@ class BasketService {
|
|
|
597
612
|
class NumberUtilService {
|
|
598
613
|
constructor(cp) {
|
|
599
614
|
this.cp = cp;
|
|
615
|
+
this.className = "NumberUtilService";
|
|
600
616
|
}
|
|
601
617
|
trimTo2Decimal(no) {
|
|
602
618
|
//return Math.floor(no * 100) / 100;
|
|
@@ -614,22 +630,22 @@ class NumberUtilService {
|
|
|
614
630
|
if (numValue) {
|
|
615
631
|
const numb = parseFloat(numValue.toString().replace(',', ''));
|
|
616
632
|
returnValue = this.cp.transform(Number(numValue).toFixed(2), currencyCode.toLocaleUpperCase(), "symbol");
|
|
617
|
-
|
|
633
|
+
AppLoggerService.logDebug(this.className, "AppendWithCurrencySymbol", "AppendWithCurrencySymbol :", returnValue);
|
|
618
634
|
}
|
|
619
635
|
else {
|
|
620
636
|
returnValue = this.cp.transform("0.00", currencyCode.toLocaleUpperCase(), "symbol");
|
|
621
637
|
}
|
|
622
638
|
return returnValue;
|
|
623
639
|
}
|
|
624
|
-
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.2.4", ngImport: i0, type: NumberUtilService, deps: [{ token: i1.CurrencyPipe }], target: i0.ɵɵFactoryTarget.Injectable }); }
|
|
625
|
-
static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "18.2.4", ngImport: i0, type: NumberUtilService, providedIn: "root" }); }
|
|
626
640
|
}
|
|
627
|
-
i0.ɵɵ
|
|
641
|
+
NumberUtilService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: NumberUtilService, deps: [{ token: i1.CurrencyPipe }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
642
|
+
NumberUtilService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: NumberUtilService, providedIn: "root" });
|
|
643
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: NumberUtilService, decorators: [{
|
|
628
644
|
type: Injectable,
|
|
629
645
|
args: [{
|
|
630
646
|
providedIn: "root",
|
|
631
647
|
}]
|
|
632
|
-
}], ctorParameters: ()
|
|
648
|
+
}], ctorParameters: function () { return [{ type: i1.CurrencyPipe }]; } });
|
|
633
649
|
|
|
634
650
|
/**
|
|
635
651
|
* Transaction document builder
|
|
@@ -638,6 +654,7 @@ class TransactionDocumentBuilder {
|
|
|
638
654
|
constructor(transactionDoc, currencyPipe, basketService) {
|
|
639
655
|
this.currencyPipe = currencyPipe;
|
|
640
656
|
this.basketService = basketService;
|
|
657
|
+
this.className = "TransactionDocumentBuilder";
|
|
641
658
|
this.numberUtilService = new NumberUtilService(currencyPipe);
|
|
642
659
|
this.basketService = new BasketService(this.numberUtilService);
|
|
643
660
|
this.storeInfo = JSON.parse(localStorage.getItem('storeInfo') || '{}');
|
|
@@ -684,7 +701,7 @@ class TransactionDocumentBuilder {
|
|
|
684
701
|
.substring(1);
|
|
685
702
|
this.transactionDocument.transactionRef =
|
|
686
703
|
storeDetails.orgCode + storeDetails.storeId + date.toISOString() + random;
|
|
687
|
-
|
|
704
|
+
AppLoggerService.logDebug(this.className, "transactionRef", "transaction ref created", this.transactionDocument.transactionRef);
|
|
688
705
|
return this;
|
|
689
706
|
}
|
|
690
707
|
/**
|
|
@@ -792,7 +809,7 @@ class TransactionDocumentBuilder {
|
|
|
792
809
|
* @returns basket
|
|
793
810
|
*/
|
|
794
811
|
basket(basketDetails) {
|
|
795
|
-
|
|
812
|
+
AppLoggerService.logDebug(this.className, "basket", "basket details update in transaction document", basketDetails);
|
|
796
813
|
this.transactionDocument.subsidiaryId = basketDetails.subsidiaryId || (localStorage.getItem('subsidiaryId') || '');
|
|
797
814
|
this.transactionDocument.basket.products = [];
|
|
798
815
|
this.transactionDocument.basket.lineDiscount = [];
|
|
@@ -845,7 +862,7 @@ class TransactionDocumentBuilder {
|
|
|
845
862
|
this.transactionDocument.basket.products.push(p);
|
|
846
863
|
this.lineDiscount(basketDetails);
|
|
847
864
|
});
|
|
848
|
-
|
|
865
|
+
AppLoggerService.logInfo(this.className, "basket", "transactiondocument basket details updated", this.transactionDocument.basket);
|
|
849
866
|
return this;
|
|
850
867
|
}
|
|
851
868
|
/**
|
|
@@ -853,7 +870,7 @@ class TransactionDocumentBuilder {
|
|
|
853
870
|
* @returns currentTransactionDetails
|
|
854
871
|
*/
|
|
855
872
|
currentTransactionDetails(basket) {
|
|
856
|
-
|
|
873
|
+
AppLoggerService.logDebug(this.className, "currentTransactionDetails", "current transaction details for exchanges", basket);
|
|
857
874
|
this.transactionDocument.currentTransactionDetails.products = [];
|
|
858
875
|
this.transactionDocument.currentTransactionDetails.linePromotion = [];
|
|
859
876
|
this.transactionDocument.currentTransactionDetails.lineDiscount = [];
|
|
@@ -878,7 +895,7 @@ class TransactionDocumentBuilder {
|
|
|
878
895
|
this.transactionDocument.currentTransactionDetails.lineDiscount.push(product.lineDiscount);
|
|
879
896
|
}
|
|
880
897
|
});
|
|
881
|
-
|
|
898
|
+
AppLoggerService.logDebug(this.className, "currentTransactionDetails", "current transaction details after removing old products", this.transactionDocument.currentTransactionDetails.products);
|
|
882
899
|
if (basket.transactionDiscount && basket.transactionDiscount.length > 0) {
|
|
883
900
|
this.transactionDocument.currentTransactionDetails.transactionDiscount.push(...basket.transactionDiscount);
|
|
884
901
|
}
|
|
@@ -903,7 +920,7 @@ class TransactionDocumentBuilder {
|
|
|
903
920
|
this.transactionDocument.currentTransactionDetails.basketSummary.discountTotal = 0;
|
|
904
921
|
}
|
|
905
922
|
}
|
|
906
|
-
|
|
923
|
+
AppLoggerService.logInfo(this.className, "currentTransactionDetails", "currentTransactionDetails", this.transactionDocument.currentTransactionDetails);
|
|
907
924
|
return this;
|
|
908
925
|
}
|
|
909
926
|
/**
|
|
@@ -931,7 +948,8 @@ class TransactionDocumentBuilder {
|
|
|
931
948
|
taxableAmount: product.total,
|
|
932
949
|
PreTax: 0
|
|
933
950
|
};
|
|
934
|
-
|
|
951
|
+
AppLoggerService.logInfo(this.className, "updateCurrentTransactionDetailsTaxBreakdown", `item line ID :current transaction Details",
|
|
952
|
+
${product.itemLineId}, tax line : ${taxLine}, basketDetails.basketTotal ${basketDetails.basketTotal}`);
|
|
935
953
|
//step 1
|
|
936
954
|
// if Transaction Discount and/or promotion applied, find net selling price of each product as taxableamount
|
|
937
955
|
//If transaction discount/promotion is applied taxable amount should be deducting transaction promotion and transaction disacount portion
|
|
@@ -959,14 +977,13 @@ class TransactionDocumentBuilder {
|
|
|
959
977
|
else {
|
|
960
978
|
this.transactionDocument.currentTransactionDetails.basketSummary.VATTotal = 0.00;
|
|
961
979
|
}
|
|
962
|
-
|
|
980
|
+
AppLoggerService.logDebug(this.className, "updateCurrentTransactionDetailsTaxBreakdown", "eBasket:after calculating tax currenttransactionDetails", this.transactionDocument.currentTransactionDetails);
|
|
963
981
|
return this;
|
|
964
982
|
}
|
|
965
983
|
updateCurrentTransactionDetailsTotalTaxSummary() {
|
|
966
|
-
|
|
984
|
+
AppLoggerService.logDebug(this.className, "updateCurrentTransactionDetailsTotalTaxSummary", "Total Tax Summery Request :", this.transactionDocument.currentTransactionDetails.taxBreakdown);
|
|
967
985
|
let totalTaxSummaryArray = [];
|
|
968
986
|
let totalTaxSummaryGroup = [];
|
|
969
|
-
console.log("Tax Lines for Total Tax Summery :", JSON.stringify(this.transactionDocument.currentTransactionDetails.taxBreakdown.taxLines));
|
|
970
987
|
this.transactionDocument.currentTransactionDetails.taxBreakdown.taxLines.forEach((element) => {
|
|
971
988
|
let TaxSummary = {
|
|
972
989
|
VATCode: "",
|
|
@@ -982,7 +999,7 @@ class TransactionDocumentBuilder {
|
|
|
982
999
|
TaxSummary.TXrateSum = this.numberUtilService.trimTo2Decimal2(TaxSummary.PreTaxSum + TaxSummary.TaxSum);
|
|
983
1000
|
totalTaxSummaryArray.push(TaxSummary);
|
|
984
1001
|
});
|
|
985
|
-
|
|
1002
|
+
AppLoggerService.logDebug(this.className, "updateCurrentTransactionDetailsTotalTaxSummary", "Total Tax Summery Without Grouped : ", totalTaxSummaryArray);
|
|
986
1003
|
totalTaxSummaryGroup = totalTaxSummaryArray.reduce((preparedArray, currentObj) => {
|
|
987
1004
|
let ind = preparedArray.findIndex((x) => x.VAT === currentObj.VAT);
|
|
988
1005
|
if (ind === -1) {
|
|
@@ -998,7 +1015,7 @@ class TransactionDocumentBuilder {
|
|
|
998
1015
|
return preparedArray;
|
|
999
1016
|
}, []);
|
|
1000
1017
|
// listOfTags.map(x => unique.filter(a => a.label == x.label && a.color == x.color).length > 0 ? null : unique.push(x));
|
|
1001
|
-
|
|
1018
|
+
AppLoggerService.logDebug(this.className, "updateCurrentTransactionDetailsTotalTaxSummary", "Total Tax Summer Group :", totalTaxSummaryGroup);
|
|
1002
1019
|
this.transactionDocument.currentTransactionDetails.totalTaxSummary = totalTaxSummaryGroup;
|
|
1003
1020
|
return this;
|
|
1004
1021
|
}
|
|
@@ -1008,10 +1025,10 @@ class TransactionDocumentBuilder {
|
|
|
1008
1025
|
*/
|
|
1009
1026
|
updateCurrentTransactionDetailsDiscountTotal() {
|
|
1010
1027
|
let refundTotal = this.transactionDocument.currentTransactionDetails.basketSummary.refundTotal ? this.transactionDocument.currentTransactionDetails.basketSummary.refundTotal : 0;
|
|
1011
|
-
|
|
1028
|
+
AppLoggerService.logDebug(this.className, "updateCurrentTransactionDetailsDiscountTotal", `refundTotal ${refundTotal}, basketTotal ${this.transactionDocument.currentTransactionDetails.basketSummary.basketTotal},saleTotal ${this.transactionDocument.currentTransactionDetails.basketSummary.saleTotal}`);
|
|
1012
1029
|
const discountTotal = Math.abs(Math.abs(this.transactionDocument.currentTransactionDetails.basketSummary.saleTotal) -
|
|
1013
1030
|
(Math.abs(this.transactionDocument.currentTransactionDetails.basketSummary.basketTotal) + Math.abs(refundTotal)));
|
|
1014
|
-
|
|
1031
|
+
AppLoggerService.logDebug(this.className, "updateCurrentTransactionDetailsDiscountTotal", "discountTotal", discountTotal);
|
|
1015
1032
|
return Number(discountTotal.toFixed(2));
|
|
1016
1033
|
}
|
|
1017
1034
|
/**
|
|
@@ -1025,7 +1042,7 @@ class TransactionDocumentBuilder {
|
|
|
1025
1042
|
if (product.refundedTotal) {
|
|
1026
1043
|
totalRefund = totalRefund + product.refundedTotal;
|
|
1027
1044
|
}
|
|
1028
|
-
|
|
1045
|
+
AppLoggerService.logDebug(this.className, "updateCurrentTransactionDetailsRefundTotal", "totalRefund for Current TransactionDetails", totalRefund);
|
|
1029
1046
|
}
|
|
1030
1047
|
return totalRefund;
|
|
1031
1048
|
}
|
|
@@ -1049,7 +1066,7 @@ class TransactionDocumentBuilder {
|
|
|
1049
1066
|
else {
|
|
1050
1067
|
this.transactionDocument.basketSummary.VATTotal = 0.00;
|
|
1051
1068
|
}
|
|
1052
|
-
|
|
1069
|
+
AppLoggerService.logInfo(this.className, "basketSummary", "basketsummary updated in transaction document: ", this.transactionDocument.basketSummary);
|
|
1053
1070
|
return this;
|
|
1054
1071
|
}
|
|
1055
1072
|
/**
|
|
@@ -1070,7 +1087,7 @@ class TransactionDocumentBuilder {
|
|
|
1070
1087
|
return acc;
|
|
1071
1088
|
}, []);
|
|
1072
1089
|
}
|
|
1073
|
-
//
|
|
1090
|
+
// AppLoggerService.logInfo(this.className,
|
|
1074
1091
|
// "e-basket :line discount updated in transaction document",
|
|
1075
1092
|
// this.transactionDocument.basket.lineDiscount
|
|
1076
1093
|
// );
|
|
@@ -1099,7 +1116,7 @@ class TransactionDocumentBuilder {
|
|
|
1099
1116
|
this.transactionDocument.basket.exchange.push(element.exchange);
|
|
1100
1117
|
}
|
|
1101
1118
|
}
|
|
1102
|
-
|
|
1119
|
+
AppLoggerService.logDebug(this.className, "exchange", "this.transactionDocument.basket exchange", this.transactionDocument.basket.exchange);
|
|
1103
1120
|
}
|
|
1104
1121
|
return this;
|
|
1105
1122
|
}
|
|
@@ -1151,7 +1168,7 @@ class TransactionDocumentBuilder {
|
|
|
1151
1168
|
// return acc;
|
|
1152
1169
|
// }, []);
|
|
1153
1170
|
// }
|
|
1154
|
-
|
|
1171
|
+
AppLoggerService.logDebug(this.className, "transactionPromotion", "this.transactionDocument.basket.transactionPromotion", this.transactionDocument.basket.transactionPromotion);
|
|
1155
1172
|
}
|
|
1156
1173
|
return this;
|
|
1157
1174
|
}
|
|
@@ -1159,7 +1176,7 @@ class TransactionDocumentBuilder {
|
|
|
1159
1176
|
if (basketDetails.transactionDiscount) {
|
|
1160
1177
|
this.transactionDocument.basket.transactionDiscount =
|
|
1161
1178
|
basketDetails.transactionDiscount;
|
|
1162
|
-
|
|
1179
|
+
AppLoggerService.logDebug(this.className, "transactionDiscount", "transaction Discount", this.transactionDocument.basket.transactionDiscount);
|
|
1163
1180
|
}
|
|
1164
1181
|
return this;
|
|
1165
1182
|
}
|
|
@@ -1169,7 +1186,7 @@ class TransactionDocumentBuilder {
|
|
|
1169
1186
|
* @returns
|
|
1170
1187
|
*/
|
|
1171
1188
|
paymentDetails(paymentDetails) {
|
|
1172
|
-
|
|
1189
|
+
AppLoggerService.logInfo(this.className, "paymentDetails", "payment details after transaction completed", paymentDetails);
|
|
1173
1190
|
this.transactionDocument.paymentDetails = paymentDetails;
|
|
1174
1191
|
return this;
|
|
1175
1192
|
}
|
|
@@ -1205,7 +1222,7 @@ class TransactionDocumentBuilder {
|
|
|
1205
1222
|
* @returns at
|
|
1206
1223
|
*/
|
|
1207
1224
|
giftOption(gift) {
|
|
1208
|
-
|
|
1225
|
+
AppLoggerService.logDebug(this.className, "giftOption", "this.transactionDocument.giftoption", gift);
|
|
1209
1226
|
if (gift) {
|
|
1210
1227
|
this.transactionDocument.giftedReceipt = gift;
|
|
1211
1228
|
}
|
|
@@ -1297,7 +1314,7 @@ class TransactionDocumentBuilder {
|
|
|
1297
1314
|
* @returns basket details
|
|
1298
1315
|
*/
|
|
1299
1316
|
getBasketDetails() {
|
|
1300
|
-
|
|
1317
|
+
AppLoggerService.logInfo(this.className, "getBasketDetails", "Getting Basket for transactionDocument", this.transactionDocument);
|
|
1301
1318
|
let basket = {
|
|
1302
1319
|
subsidiaryId: this.transactionDocument.subsidiaryId,
|
|
1303
1320
|
transactionDiscount: this.transactionDocument.basket.transactionDiscount,
|
|
@@ -1316,7 +1333,7 @@ class TransactionDocumentBuilder {
|
|
|
1316
1333
|
};
|
|
1317
1334
|
basket.products = [];
|
|
1318
1335
|
this.transactionDocument.basket.products.forEach((product, index) => {
|
|
1319
|
-
|
|
1336
|
+
AppLoggerService.logDebug(this.className, JSON.stringify(product), "ebasket: basket detail update in basket");
|
|
1320
1337
|
const p = {};
|
|
1321
1338
|
p.SKU = product.SKU;
|
|
1322
1339
|
p.barcode = product.barCode;
|
|
@@ -1398,7 +1415,7 @@ class TransactionDocumentBuilder {
|
|
|
1398
1415
|
if (this.transactionDocument.type === TRANSACTION_TYPE.SALE_REFUND) {
|
|
1399
1416
|
basket.quantity = this.getRefundedTotalWithQuantity(basket);
|
|
1400
1417
|
}
|
|
1401
|
-
|
|
1418
|
+
AppLoggerService.logInfo(this.className, "getBasketDetails", "Basket created successfully", basket);
|
|
1402
1419
|
return basket;
|
|
1403
1420
|
}
|
|
1404
1421
|
/**
|
|
@@ -1454,7 +1471,7 @@ class TransactionDocumentBuilder {
|
|
|
1454
1471
|
// p.itemDiscounts = product.itemDiscounts as ItemDiscount;
|
|
1455
1472
|
// }
|
|
1456
1473
|
// // if(!p.itemDiscounts){
|
|
1457
|
-
// //
|
|
1474
|
+
// // AppLoggerService.logDebug(this.className, p.itemDiscounts);
|
|
1458
1475
|
// // this.basketService.transactionDiscountAndPromotionProductortionCalculation(basket);
|
|
1459
1476
|
// // }
|
|
1460
1477
|
// p.refundPromotionalQuantity = product.refundedPromotionalQuantity ? product.refundedPromotionalQuantity : 0;
|
|
@@ -1518,7 +1535,7 @@ class TransactionDocumentBuilder {
|
|
|
1518
1535
|
// if (!basket.products[0].hasOwnProperty('itemDiscounts')) {
|
|
1519
1536
|
// basket = this.getTransactionDiscountAndTransactionPromotionPortion(basket);
|
|
1520
1537
|
// }
|
|
1521
|
-
//
|
|
1538
|
+
// AppLoggerService.logDebug(this.className, "ebasket : TransactionDocumentBuilder :new created refunded basket", JSON.stringify(basket))
|
|
1522
1539
|
// basket.quantity = basket.products.reduce(
|
|
1523
1540
|
// (n: any, { quantity }: any) => n + quantity,
|
|
1524
1541
|
// 0
|
|
@@ -1526,11 +1543,11 @@ class TransactionDocumentBuilder {
|
|
|
1526
1543
|
// basket.total = this.getTotalWithLineDiscountAndLinePromotionApplied(basket);
|
|
1527
1544
|
// basket.basketTotal = basket.total;
|
|
1528
1545
|
// basket.basketTotal = basket.basketTotal - this.getTotalDiscountWithTransactionDiscountsAndPromotions(basket);
|
|
1529
|
-
//
|
|
1546
|
+
// AppLoggerService.logDebug(this.className,
|
|
1530
1547
|
// "ebasket : TransactionDocumentBuilder : update Basket Total: after promotion :basketTotal",
|
|
1531
1548
|
// basket.basketTotal
|
|
1532
1549
|
// );
|
|
1533
|
-
//
|
|
1550
|
+
// AppLoggerService.logDebug(this.className,
|
|
1534
1551
|
// "e:basket :TransactionDocumentBuilder : basketDetails updated values",
|
|
1535
1552
|
// JSON.stringify(basket)
|
|
1536
1553
|
// );
|
|
@@ -1575,19 +1592,19 @@ class TransactionDocumentBuilder {
|
|
|
1575
1592
|
basketDetails.transactionDiscount.length > 0) {
|
|
1576
1593
|
discountTotal += basketDetails.transactionDiscount.reduce((n, { discountAmount }) => n + discountAmount, 0);
|
|
1577
1594
|
}
|
|
1578
|
-
|
|
1595
|
+
AppLoggerService.logDebug(this.className, "getTotalDiscountWithTransactionDiscountsAndPromotions", "Transaction discount Total:", discountTotal);
|
|
1579
1596
|
return discountTotal;
|
|
1580
1597
|
}
|
|
1581
1598
|
appendCurrencySymbol(currency, value) {
|
|
1582
1599
|
// value=this.decimalpipe.transform(value,'1.2');
|
|
1583
1600
|
if (value >= 0) {
|
|
1584
1601
|
const returnval = currency + value;
|
|
1585
|
-
|
|
1602
|
+
AppLoggerService.logDebug(this.className, "appendCurrencySymbol", "add currency with value", returnval);
|
|
1586
1603
|
return returnval;
|
|
1587
1604
|
}
|
|
1588
1605
|
else {
|
|
1589
1606
|
const returnval = "-" + (currency + value * -1);
|
|
1590
|
-
|
|
1607
|
+
AppLoggerService.logDebug(this.className, "appendCurrencySymbol", "returnVal", returnval);
|
|
1591
1608
|
return returnval;
|
|
1592
1609
|
}
|
|
1593
1610
|
}
|
|
@@ -1599,7 +1616,7 @@ class TransactionDocumentBuilder {
|
|
|
1599
1616
|
// this.transactionDocument.basket.products.forEach((product) => {
|
|
1600
1617
|
// product.refundedQuantity = product.quantity;
|
|
1601
1618
|
// product.refundedTotal = product.totalLinePrice * -1;
|
|
1602
|
-
//
|
|
1619
|
+
// AppLoggerService.logDebug(this.className,
|
|
1603
1620
|
// "ebasket: Transaction price override :",
|
|
1604
1621
|
// this.transactionDocument.basket.lineDiscount
|
|
1605
1622
|
// );
|
|
@@ -1608,15 +1625,15 @@ class TransactionDocumentBuilder {
|
|
|
1608
1625
|
// this.transactionDocument.basket.linePromotion.length > 0
|
|
1609
1626
|
// ) {
|
|
1610
1627
|
// this.transactionDocument.basket.linePromotion.forEach((linePromotion) => {
|
|
1611
|
-
//
|
|
1628
|
+
// AppLoggerService.logDebug(this.className,
|
|
1612
1629
|
// "Promotion: basket linePromotion : ",
|
|
1613
1630
|
// this.transactionDocument.basket.linePromotion
|
|
1614
1631
|
// );
|
|
1615
|
-
//
|
|
1632
|
+
// AppLoggerService.logDebug(this.className,
|
|
1616
1633
|
// "linePromotion.itemLineId.toString() : ",
|
|
1617
1634
|
// linePromotion.itemLineId.toString()
|
|
1618
1635
|
// );
|
|
1619
|
-
//
|
|
1636
|
+
// AppLoggerService.logDebug(this.className,
|
|
1620
1637
|
// "condition : " +
|
|
1621
1638
|
// (product.itemLineId === linePromotion.itemLineId.toString())
|
|
1622
1639
|
// );
|
|
@@ -1631,15 +1648,15 @@ class TransactionDocumentBuilder {
|
|
|
1631
1648
|
// this.transactionDocument.basket.lineDiscount.length > 0
|
|
1632
1649
|
// ) {
|
|
1633
1650
|
// this.transactionDocument.basket.lineDiscount.forEach((lineDiscount) => {
|
|
1634
|
-
//
|
|
1651
|
+
// AppLoggerService.logDebug(this.className,
|
|
1635
1652
|
// "product.itemLineId : " +
|
|
1636
1653
|
// this.transactionDocument.basket.lineDiscount
|
|
1637
1654
|
// );
|
|
1638
|
-
//
|
|
1655
|
+
// AppLoggerService.logDebug(this.className,
|
|
1639
1656
|
// "lineDiscount.itemLineId.toString() : " +
|
|
1640
1657
|
// lineDiscount.itemLineId.toString()
|
|
1641
1658
|
// );
|
|
1642
|
-
//
|
|
1659
|
+
// AppLoggerService.logDebug(this.className,
|
|
1643
1660
|
// "condition : " +
|
|
1644
1661
|
// (product.itemLineId === lineDiscount.itemLineId.toString())
|
|
1645
1662
|
// );
|
|
@@ -1648,10 +1665,10 @@ class TransactionDocumentBuilder {
|
|
|
1648
1665
|
// }
|
|
1649
1666
|
// });
|
|
1650
1667
|
// }
|
|
1651
|
-
//
|
|
1652
|
-
//
|
|
1668
|
+
// AppLoggerService.logDebug(this.className, "Product description :" + product.description);
|
|
1669
|
+
// AppLoggerService.logDebug(this.className, "Product total :" + product.refundedTotal);
|
|
1653
1670
|
// // product.displayrefundedamount=this.appendCurrencySymbol(CURRENCY[this.transactionDocument.baseCurrency],product.refundedTotal);
|
|
1654
|
-
// //
|
|
1671
|
+
// // AppLoggerService.logDebug(this.className, product.displayrefundedamount,"displayrefundedamount");
|
|
1655
1672
|
// product.refunded = true;
|
|
1656
1673
|
// });
|
|
1657
1674
|
// const baskettotal = (this.transactionDocument.basketSummary.basketTotal *= -1);
|
|
@@ -1686,7 +1703,7 @@ class TransactionDocumentBuilder {
|
|
|
1686
1703
|
// product.quantity * Number(product.selectedPrice.toFixed(2));
|
|
1687
1704
|
// }
|
|
1688
1705
|
saletotal += product.total;
|
|
1689
|
-
|
|
1706
|
+
AppLoggerService.logDebug(this.className, "getTotalWithLineDiscountAndLinePromotionApplied", "e-basket:update product Total:" + saletotal, product);
|
|
1690
1707
|
}
|
|
1691
1708
|
return saletotal;
|
|
1692
1709
|
}
|
|
@@ -1710,10 +1727,10 @@ class TransactionDocumentBuilder {
|
|
|
1710
1727
|
*/
|
|
1711
1728
|
updateDiscountTotal() {
|
|
1712
1729
|
let refundTotal = this.transactionDocument.basketSummary.refundTotal ? this.transactionDocument.basketSummary.refundTotal : 0;
|
|
1713
|
-
|
|
1730
|
+
AppLoggerService.logInfo(this.className, "updateDiscountTotal", `refundTotal: ${refundTotal} this.transactionDocument.basketSummary: ${this.transactionDocument.basketSummary}`);
|
|
1714
1731
|
const discountTotal = Math.abs(Math.abs(this.transactionDocument.basketSummary.saleTotal) -
|
|
1715
1732
|
(Math.abs(this.transactionDocument.basketSummary.basketTotal) + Math.abs(refundTotal)));
|
|
1716
|
-
|
|
1733
|
+
AppLoggerService.logDebug(this.className, "updateDiscountTotal", "discountTotal", discountTotal);
|
|
1717
1734
|
return Number(discountTotal.toFixed(2));
|
|
1718
1735
|
}
|
|
1719
1736
|
updateReasonCode(reasonCode) {
|
|
@@ -1764,7 +1781,8 @@ class TransactionDocumentBuilder {
|
|
|
1764
1781
|
taxableAmount: product.total,
|
|
1765
1782
|
PreTax: 0
|
|
1766
1783
|
};
|
|
1767
|
-
|
|
1784
|
+
AppLoggerService.logInfo(this.className, "updateTaxBreakdown", `item line ID :, ${product.itemLineId},
|
|
1785
|
+
"tax line :", ${taxLine}`);
|
|
1768
1786
|
// step 1
|
|
1769
1787
|
// if Transaction Discount and/or promotion applied, find net selling price of each product as taxableamount
|
|
1770
1788
|
// if (transactionDiscountTotal > 0) {
|
|
@@ -1773,7 +1791,8 @@ class TransactionDocumentBuilder {
|
|
|
1773
1791
|
product.itemDiscounts.trnPromotionsPortion -
|
|
1774
1792
|
product.itemDiscounts.refundPortion;
|
|
1775
1793
|
// tp+td-rp;
|
|
1776
|
-
|
|
1794
|
+
AppLoggerService.logInfo(this.className, "updateTaxBreakdown", `item line ID , ${product.itemLineId},
|
|
1795
|
+
"contribution :", ${productContributionInTotal}`);
|
|
1777
1796
|
// calculate net selling price after applying transaction discount as per product contribution
|
|
1778
1797
|
taxLine.taxableAmount -= productContributionInTotal;
|
|
1779
1798
|
// }
|
|
@@ -1791,10 +1810,10 @@ class TransactionDocumentBuilder {
|
|
|
1791
1810
|
return this;
|
|
1792
1811
|
}
|
|
1793
1812
|
updateTotalTaxSummary() {
|
|
1794
|
-
|
|
1813
|
+
AppLoggerService.logDebug(this.className, "updateTotalTaxSummary", "Total Tax Summery Request :", this.transactionDocument.basket.taxBreakdown);
|
|
1795
1814
|
let totalTaxSummaryArray = [];
|
|
1796
1815
|
let totalTaxSummaryGroup = [];
|
|
1797
|
-
|
|
1816
|
+
AppLoggerService.logDebug(this.className, "updateTotalTaxSummary", "Tax Lines for Total Tax Summery :", this.transactionDocument.basket.taxBreakdown.taxLines);
|
|
1798
1817
|
this.transactionDocument.basket.taxBreakdown.taxLines.forEach((element) => {
|
|
1799
1818
|
let TaxSummary = {
|
|
1800
1819
|
VATCode: "",
|
|
@@ -1810,7 +1829,7 @@ class TransactionDocumentBuilder {
|
|
|
1810
1829
|
TaxSummary.TXrateSum = this.numberUtilService.trimTo2Decimal2(TaxSummary.PreTaxSum + TaxSummary.TaxSum);
|
|
1811
1830
|
totalTaxSummaryArray.push(TaxSummary);
|
|
1812
1831
|
});
|
|
1813
|
-
|
|
1832
|
+
AppLoggerService.logDebug(this.className, "updateTotalTaxSummary", "Total Tax Summery Without Grouped : ", totalTaxSummaryArray);
|
|
1814
1833
|
totalTaxSummaryGroup = totalTaxSummaryArray.reduce((preparedArray, currentObj) => {
|
|
1815
1834
|
let ind = preparedArray.findIndex((x) => x.VAT === currentObj.VAT);
|
|
1816
1835
|
if (ind === -1) {
|
|
@@ -1825,7 +1844,7 @@ class TransactionDocumentBuilder {
|
|
|
1825
1844
|
}
|
|
1826
1845
|
return preparedArray;
|
|
1827
1846
|
}, []);
|
|
1828
|
-
|
|
1847
|
+
AppLoggerService.logDebug(this.className, "updateTotalTaxSummary", "Total Tax Summer Group :", totalTaxSummaryGroup);
|
|
1829
1848
|
this.transactionDocument.basket.totalTaxSummary = totalTaxSummaryGroup;
|
|
1830
1849
|
return this;
|
|
1831
1850
|
}
|
|
@@ -1857,7 +1876,7 @@ class TransactionDocumentBuilder {
|
|
|
1857
1876
|
if (product.refundedTotal) {
|
|
1858
1877
|
totalRefund = totalRefund + product.refundedTotal;
|
|
1859
1878
|
}
|
|
1860
|
-
|
|
1879
|
+
AppLoggerService.logDebug(this.className, "getRefundTotal", "totalRefund", totalRefund);
|
|
1861
1880
|
}
|
|
1862
1881
|
return totalRefund;
|
|
1863
1882
|
}
|
|
@@ -1869,6 +1888,7 @@ class TransactionDocumentBuilder {
|
|
|
1869
1888
|
|
|
1870
1889
|
class RJMapperBuilderClass {
|
|
1871
1890
|
constructor(transactionDoc) {
|
|
1891
|
+
this.className = "RJMapperBuilderClass";
|
|
1872
1892
|
this.itemCount = 0;
|
|
1873
1893
|
this.largestNumber = 0;
|
|
1874
1894
|
this.rjObject = {};
|
|
@@ -1995,7 +2015,7 @@ class RJMapperBuilderClass {
|
|
|
1995
2015
|
"OriginalTransactionNumber": 0,
|
|
1996
2016
|
"OriginalCashierNumber": 0
|
|
1997
2017
|
};
|
|
1998
|
-
data['Return'] = {
|
|
2018
|
+
data['Return'] = Object.assign(Object.assign({}, data['Return']), obj);
|
|
1999
2019
|
this.rjObject['ProductReturn'].push(data);
|
|
2000
2020
|
this.getModifierItem(element.lineDiscount, element.itemLineId);
|
|
2001
2021
|
});
|
|
@@ -2015,7 +2035,7 @@ class RJMapperBuilderClass {
|
|
|
2015
2035
|
"OriginalTransactionNumber": 0,
|
|
2016
2036
|
"OriginalCashierNumber": 0
|
|
2017
2037
|
};
|
|
2018
|
-
returnProduct['Return'] = {
|
|
2038
|
+
returnProduct['Return'] = Object.assign(Object.assign({}, returnProduct['Return']), obj);
|
|
2019
2039
|
this.rjObject['ProductReturn'].push(returnProduct);
|
|
2020
2040
|
}
|
|
2021
2041
|
else {
|
|
@@ -2182,8 +2202,8 @@ class RJMapperBuilderClass {
|
|
|
2182
2202
|
TenderAmount: this.convertToString(-1 * this.removeDecimal((Math.round(element.amount)))),
|
|
2183
2203
|
CurrencyID: this.transactionDocument.baseCurrency,
|
|
2184
2204
|
CurrencyDescription: this.transactionDocument.baseCurrency,
|
|
2185
|
-
GiftVoucherSalesAllowed: '',
|
|
2186
|
-
AllowRechargeableVoucherSales: '',
|
|
2205
|
+
GiftVoucherSalesAllowed: '',
|
|
2206
|
+
AllowRechargeableVoucherSales: '',
|
|
2187
2207
|
GiftVoucherID: ''
|
|
2188
2208
|
};
|
|
2189
2209
|
this.rjObject[element.externalTenderKey].push(obj);
|
|
@@ -2191,7 +2211,7 @@ class RJMapperBuilderClass {
|
|
|
2191
2211
|
else {
|
|
2192
2212
|
let obj1 = {
|
|
2193
2213
|
XMLSchemaVersion: "1",
|
|
2194
|
-
LineNumber: this.generateLineNumber(),
|
|
2214
|
+
LineNumber: this.generateLineNumber(),
|
|
2195
2215
|
NetValue: this.convertToString(-1 * this.removeDecimal(Math.round(element.amount))),
|
|
2196
2216
|
EffectiveNetValue: this.convertToString(-1 * this.removeDecimal(Math.round(element.amount))),
|
|
2197
2217
|
Description: this.getDescription(element),
|
|
@@ -2227,8 +2247,8 @@ class RJMapperBuilderClass {
|
|
|
2227
2247
|
TenderAmount: JSON.stringify(-1 * this.removeDecimal((Math.round(element.amount)))),
|
|
2228
2248
|
CurrencyID: this.transactionDocument.baseCurrency,
|
|
2229
2249
|
CurrencyDescription: this.transactionDocument.baseCurrency,
|
|
2230
|
-
GiftVoucherSalesAllowed: '',
|
|
2231
|
-
AllowRechargeableVoucherSales: '',
|
|
2250
|
+
GiftVoucherSalesAllowed: '',
|
|
2251
|
+
AllowRechargeableVoucherSales: '',
|
|
2232
2252
|
GiftVoucherID: ''
|
|
2233
2253
|
};
|
|
2234
2254
|
this.rjObject['CashTender'].push(obj);
|
|
@@ -2534,12 +2554,12 @@ class RJMapperBuilderClass {
|
|
|
2534
2554
|
SalespersonID: this.transactionDocument.userName,
|
|
2535
2555
|
SalespersonName: this.salesPersonName,
|
|
2536
2556
|
TaxCode: this.transactionDocument.basket['taxBreakdown']['taxLines'].find((item) => item.itemLineId == element['itemLineId']).VATCode,
|
|
2537
|
-
TaxModifiable: "1",
|
|
2557
|
+
TaxModifiable: "1",
|
|
2538
2558
|
OriginalTaxAmount: this.convertToString((this.removeDecimal(this.getOriginalTax(element, taxTotal.VAT)).toFixed(2))),
|
|
2539
2559
|
TaxAmount: this.convertToString(this.removeDecimal(taxTotal.taxLineTotal)),
|
|
2540
|
-
OriginalTaxAmountSet: "1",
|
|
2560
|
+
OriginalTaxAmountSet: "1",
|
|
2541
2561
|
ProductID: element.SKU,
|
|
2542
|
-
HandKeyed: "1",
|
|
2562
|
+
HandKeyed: "1",
|
|
2543
2563
|
CustomerDetails: "",
|
|
2544
2564
|
Perishable: this.getMMGROUPID(element.attributes),
|
|
2545
2565
|
MMGroupID: this.getMMGROUPID(element.attributes)
|
|
@@ -2665,7 +2685,7 @@ class RJMapperBuilderClass {
|
|
|
2665
2685
|
return value;
|
|
2666
2686
|
}
|
|
2667
2687
|
catch (e) {
|
|
2668
|
-
|
|
2688
|
+
AppLoggerService.logError(this.className, "convertToString", 'can not be converted in string', e);
|
|
2669
2689
|
}
|
|
2670
2690
|
}
|
|
2671
2691
|
generateDynamicStockLookUp() {
|
|
@@ -2743,6 +2763,7 @@ class RJMapperBuilderClass {
|
|
|
2743
2763
|
class WebReturnMapperBuilderClass {
|
|
2744
2764
|
constructor(document, currencyPipe) {
|
|
2745
2765
|
this.currencyPipe = currencyPipe;
|
|
2766
|
+
this.className = "WebReturnMapperBuilderClass";
|
|
2746
2767
|
this.webReturnObject = {
|
|
2747
2768
|
id: '',
|
|
2748
2769
|
orgCode: "",
|
|
@@ -2932,7 +2953,7 @@ class WebReturnMapperBuilderClass {
|
|
|
2932
2953
|
transactionPromotion.subLevelType = PROMOTION_LEVEL.LINE;
|
|
2933
2954
|
transactionPromotion.trigger = couponTriggerPromotions;
|
|
2934
2955
|
}
|
|
2935
|
-
|
|
2956
|
+
AppLoggerService.logDebug(this.className, "WebReturnMapper", "update LinePromotion With Coupon", transactionPromotion);
|
|
2936
2957
|
if (!this.webReturnObject.basket.transactionPromotion) {
|
|
2937
2958
|
this.webReturnObject.basket.transactionPromotion = [];
|
|
2938
2959
|
}
|
|
@@ -2955,7 +2976,7 @@ class WebReturnMapperBuilderClass {
|
|
|
2955
2976
|
return product;
|
|
2956
2977
|
}
|
|
2957
2978
|
transactionPromotionProductPortionCalc(txDoc, promotion) {
|
|
2958
|
-
|
|
2979
|
+
AppLoggerService.logDebug(this.className, "transactionPromotionProductPortionCalc", `trnsactionPromotion: ${JSON.stringify(promotion)}`);
|
|
2959
2980
|
if (promotion.type === PROMOTION_TYPE.COUPON && promotion.subLevelType === PROMOTION_LEVEL.LINE) {
|
|
2960
2981
|
txDoc.basket.products.forEach((product) => {
|
|
2961
2982
|
product = this.validateProductItemDiscount(product);
|
|
@@ -2997,7 +3018,7 @@ class WebReturnMapperBuilderClass {
|
|
|
2997
3018
|
}
|
|
2998
3019
|
}
|
|
2999
3020
|
catch (error) {
|
|
3000
|
-
|
|
3021
|
+
AppLoggerService.logError(this.className, "updateTransactionPromotionPrtionCalc", "updateTransactionPromotionPrtionCalc => failed:", error);
|
|
3001
3022
|
}
|
|
3002
3023
|
}
|
|
3003
3024
|
deviceId(deviceId) {
|
|
@@ -3053,11 +3074,11 @@ class WebReturnMapperBuilderClass {
|
|
|
3053
3074
|
}
|
|
3054
3075
|
}
|
|
3055
3076
|
isInStoreOrder() {
|
|
3056
|
-
|
|
3077
|
+
AppLoggerService.logDebug(this.className, "isInStoreOrder", "isInStoreOrder mapping started...");
|
|
3057
3078
|
if (this.document.payment && this.document.payment.method && this.document.payment.method === 'pos_order') {
|
|
3058
3079
|
this.webReturnObject.isInStoreOrder = true;
|
|
3059
3080
|
}
|
|
3060
|
-
|
|
3081
|
+
AppLoggerService.logDebug(this.className, "isInStoreOrder", "isInStoreOrder mapping ended...");
|
|
3061
3082
|
return this;
|
|
3062
3083
|
}
|
|
3063
3084
|
}
|
|
@@ -3065,6 +3086,7 @@ class WebReturnMapperBuilderClass {
|
|
|
3065
3086
|
class WebReturnSalesforceMapperBuilderClass {
|
|
3066
3087
|
constructor(orderDetails, currencyPipe) {
|
|
3067
3088
|
this.currencyPipe = currencyPipe;
|
|
3089
|
+
this.className = "WebReturnSalesforceMapperBuilderClass";
|
|
3068
3090
|
this.webReturnObject = {
|
|
3069
3091
|
id: '',
|
|
3070
3092
|
orgCode: "",
|
|
@@ -3099,7 +3121,7 @@ class WebReturnSalesforceMapperBuilderClass {
|
|
|
3099
3121
|
this.numberUtilService = new NumberUtilService(currencyPipe);
|
|
3100
3122
|
}
|
|
3101
3123
|
webReturnCommonMapper() {
|
|
3102
|
-
|
|
3124
|
+
AppLoggerService.logDebug(this.className, "webReturnCommonMapper", "Mapper library: WebReturnSalesforceMapperBuilderClass: webReturnCommonMapper started...");
|
|
3103
3125
|
this.webReturnObject['type'] = TRANSACTION_TYPE.WEB_RETURNS;
|
|
3104
3126
|
this.webReturnObject['datetime'] = this.getUTCDateTime(this.orderDetails.last_modified);
|
|
3105
3127
|
this.webReturnObject.baseCurrency = this.orderDetails.currency;
|
|
@@ -3110,13 +3132,13 @@ class WebReturnSalesforceMapperBuilderClass {
|
|
|
3110
3132
|
this.webReturnObject.updatedAt = this.getUTCDateTime(this.orderDetails.last_modified);
|
|
3111
3133
|
this.webReturnObject.transCompletedAt = this.getUTCDateTime(this.orderDetails.last_modified);
|
|
3112
3134
|
this.webReturnObject['externalTransactionId'] = this.orderDetails.order_no;
|
|
3113
|
-
|
|
3135
|
+
AppLoggerService.logDebug(this.className, "webReturnCommonMapper", "webReturnCommonMapper ended...");
|
|
3114
3136
|
return this;
|
|
3115
3137
|
}
|
|
3116
3138
|
// export(status, details) {
|
|
3117
|
-
//
|
|
3118
|
-
//
|
|
3119
|
-
//
|
|
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));
|
|
3120
3142
|
// if (status && details && details.providers && details.providers.length > 0) {
|
|
3121
3143
|
// details.providers.forEach(
|
|
3122
3144
|
// providerObj => {
|
|
@@ -3130,7 +3152,7 @@ class WebReturnSalesforceMapperBuilderClass {
|
|
|
3130
3152
|
// } else {
|
|
3131
3153
|
// this.webReturnObject.export = false;
|
|
3132
3154
|
// }
|
|
3133
|
-
//
|
|
3155
|
+
// AppLoggerService.logDebug(this.className, "Mapper library: WebReturnSalesforceMapperBuilderClass: export mapping end...")
|
|
3134
3156
|
// return this;
|
|
3135
3157
|
// }
|
|
3136
3158
|
getDeliveryMethod() {
|
|
@@ -3146,7 +3168,7 @@ class WebReturnSalesforceMapperBuilderClass {
|
|
|
3146
3168
|
}
|
|
3147
3169
|
}
|
|
3148
3170
|
product() {
|
|
3149
|
-
|
|
3171
|
+
AppLoggerService.logDebug(this.className, "product", "product mapping started...");
|
|
3150
3172
|
this.webReturnObject.basket['products'] = [];
|
|
3151
3173
|
if (this.orderDetails.product_items && this.orderDetails.product_items.length > 0) {
|
|
3152
3174
|
this.orderDetails.product_items.forEach((product, index) => {
|
|
@@ -3165,11 +3187,11 @@ class WebReturnSalesforceMapperBuilderClass {
|
|
|
3165
3187
|
}
|
|
3166
3188
|
});
|
|
3167
3189
|
}
|
|
3168
|
-
|
|
3190
|
+
AppLoggerService.logDebug(this.className, "product", "product mapping ended...");
|
|
3169
3191
|
return this;
|
|
3170
3192
|
}
|
|
3171
3193
|
linePromotion() {
|
|
3172
|
-
|
|
3194
|
+
AppLoggerService.logDebug(this.className, "linePromotion", "linePromotion mapping started...");
|
|
3173
3195
|
this.webReturnObject.basket.linePromotion = [];
|
|
3174
3196
|
let linePromotionArray = [];
|
|
3175
3197
|
if (this.orderDetails.product_items && this.orderDetails.product_items.length > 0) {
|
|
@@ -3199,14 +3221,14 @@ class WebReturnSalesforceMapperBuilderClass {
|
|
|
3199
3221
|
});
|
|
3200
3222
|
}
|
|
3201
3223
|
this.webReturnObject.basket.linePromotion = linePromotionArray;
|
|
3202
|
-
|
|
3224
|
+
AppLoggerService.logDebug(this.className, "linePromotion", "linePromotion mapping ended...");
|
|
3203
3225
|
return this;
|
|
3204
3226
|
}
|
|
3205
3227
|
transactionPromotion() {
|
|
3206
|
-
|
|
3228
|
+
AppLoggerService.logDebug(this.className, "transactionPromotion", "transactionPromotion mapping started...");
|
|
3207
3229
|
let transactionPromotionArray = this.getTransactionPromotions(this.orderDetails);
|
|
3208
3230
|
this.webReturnObject.basket.transactionPromotion = transactionPromotionArray;
|
|
3209
|
-
|
|
3231
|
+
AppLoggerService.logDebug(this.className, "transactionPromotion", "transactionPromotion mapping ended...");
|
|
3210
3232
|
return this;
|
|
3211
3233
|
}
|
|
3212
3234
|
getTransactionPromotions(basket) {
|
|
@@ -3230,12 +3252,11 @@ class WebReturnSalesforceMapperBuilderClass {
|
|
|
3230
3252
|
transactionPromotionArray.push(transactionPromotionObj);
|
|
3231
3253
|
});
|
|
3232
3254
|
}
|
|
3233
|
-
|
|
3255
|
+
AppLoggerService.logDebug(this.className, "getTransactionPromotions", "getTransactionPromotions : ", transactionPromotionArray);
|
|
3234
3256
|
return transactionPromotionArray;
|
|
3235
3257
|
}
|
|
3236
3258
|
catch (error) {
|
|
3237
|
-
|
|
3238
|
-
console.log("Mapper library: WebReturnSalesforceMapperBuilderClass: failed:", JSON.stringify(error));
|
|
3259
|
+
AppLoggerService.logError(this.className, "getTransactionPromotions", "failed:", error);
|
|
3239
3260
|
throw new Error(error);
|
|
3240
3261
|
}
|
|
3241
3262
|
}
|
|
@@ -3275,8 +3296,7 @@ class WebReturnSalesforceMapperBuilderClass {
|
|
|
3275
3296
|
transactionPromotion.subLevelType = PROMOTION_LEVEL.LINE;
|
|
3276
3297
|
transactionPromotion.trigger = triggerPromotion;
|
|
3277
3298
|
}
|
|
3278
|
-
|
|
3279
|
-
console.log("e-basket: updateLinePromotionWithCoupon", JSON.stringify(transactionPromotion));
|
|
3299
|
+
AppLoggerService.logDebug(this.className, "updateLinePromotionWithCoupon", "transactionPromotion", transactionPromotion);
|
|
3280
3300
|
if (!this.webReturnObject.basket.transactionPromotion) {
|
|
3281
3301
|
this.webReturnObject.basket.transactionPromotion = [];
|
|
3282
3302
|
}
|
|
@@ -3286,8 +3306,7 @@ class WebReturnSalesforceMapperBuilderClass {
|
|
|
3286
3306
|
return this;
|
|
3287
3307
|
}
|
|
3288
3308
|
catch (error) {
|
|
3289
|
-
|
|
3290
|
-
console.log("Ebasket: Salesforce: linePromotion mapping=> failed:", JSON.stringify(error));
|
|
3309
|
+
AppLoggerService.logError(this.className, "updateLinePromotionWithCoupon", "linePromotion mapping=> failed:", error);
|
|
3291
3310
|
throw new Error(error);
|
|
3292
3311
|
}
|
|
3293
3312
|
}
|
|
@@ -3300,7 +3319,7 @@ class WebReturnSalesforceMapperBuilderClass {
|
|
|
3300
3319
|
return this;
|
|
3301
3320
|
}
|
|
3302
3321
|
transactionPromotionProductPortionCalc(txDoc, promotion) {
|
|
3303
|
-
|
|
3322
|
+
AppLoggerService.logDebug(this.className, "transactionPromotionProductPortionCalc", `trnsactionPromotion: ${JSON.stringify(promotion)}`);
|
|
3304
3323
|
if (promotion.type === PROMOTION_TYPE.COUPON && promotion.subLevelType === PROMOTION_LEVEL.LINE) {
|
|
3305
3324
|
txDoc.basket.products.forEach((product) => {
|
|
3306
3325
|
product = this.validateProductItemDiscount(product);
|
|
@@ -3337,7 +3356,7 @@ class WebReturnSalesforceMapperBuilderClass {
|
|
|
3337
3356
|
return product;
|
|
3338
3357
|
}
|
|
3339
3358
|
customer() {
|
|
3340
|
-
|
|
3359
|
+
AppLoggerService.logDebug(this.className, "customer", "customer mapping started...");
|
|
3341
3360
|
let customerObj = {};
|
|
3342
3361
|
customerObj.email = this.orderDetails.customer_info && this.orderDetails.customer_info.email ? this.orderDetails.customer_info.email : '';
|
|
3343
3362
|
customerObj.firstName = this.orderDetails.billing_address && this.orderDetails.billing_address.first_name ? this.orderDetails.billing_address.first_name : '';
|
|
@@ -3373,19 +3392,19 @@ class WebReturnSalesforceMapperBuilderClass {
|
|
|
3373
3392
|
});
|
|
3374
3393
|
customerObj.shipmentDetails = shipmentDetails;
|
|
3375
3394
|
this.webReturnObject.customer = customerObj;
|
|
3376
|
-
|
|
3395
|
+
AppLoggerService.logDebug(this.className, "customer", "customer mapping ended...");
|
|
3377
3396
|
return this;
|
|
3378
3397
|
}
|
|
3379
3398
|
isInStoreOrder() {
|
|
3380
|
-
|
|
3399
|
+
AppLoggerService.logDebug(this.className, "isInStoreOrder", "isInStoreOrder mapping started...");
|
|
3381
3400
|
if (this.orderDetails.c_isInStoreOrder) {
|
|
3382
3401
|
this.webReturnObject.isInStoreOrder = true;
|
|
3383
3402
|
}
|
|
3384
|
-
|
|
3403
|
+
AppLoggerService.logDebug(this.className, "isInStoreOrder", "isInStoreOrder mapping ended...");
|
|
3385
3404
|
return this;
|
|
3386
3405
|
}
|
|
3387
3406
|
externalTransactionDetails() {
|
|
3388
|
-
|
|
3407
|
+
AppLoggerService.logDebug(this.className, "externalTransactionDetails", "externalTransactionDetails mapping started...");
|
|
3389
3408
|
let externalTransactionDetails = [];
|
|
3390
3409
|
if (this.orderDetails.shipments && this.orderDetails.shipments.length > 0) {
|
|
3391
3410
|
this.orderDetails.shipments.forEach(shipment => {
|
|
@@ -3400,11 +3419,11 @@ class WebReturnSalesforceMapperBuilderClass {
|
|
|
3400
3419
|
});
|
|
3401
3420
|
}
|
|
3402
3421
|
this.webReturnObject.externalTransactionDetails = externalTransactionDetails;
|
|
3403
|
-
|
|
3422
|
+
AppLoggerService.logDebug(this.className, "externalTransactionDetails", "externalTransactionDetails mapping ended...");
|
|
3404
3423
|
return this;
|
|
3405
3424
|
}
|
|
3406
3425
|
basketSummary() {
|
|
3407
|
-
|
|
3426
|
+
AppLoggerService.logDebug(this.className, "basketSummary", "basketSummary mapping started...");
|
|
3408
3427
|
let basketSummary = {};
|
|
3409
3428
|
let basketSummaryWebOrder = {};
|
|
3410
3429
|
const linePromotionTotal = this.webReturnObject.basket.linePromotion.map(linePromotion => linePromotion.promotionAmount).reduce((accumulator, currentValue) => accumulator + currentValue, 0);
|
|
@@ -3420,7 +3439,7 @@ class WebReturnSalesforceMapperBuilderClass {
|
|
|
3420
3439
|
basketSummaryWebOrder.basketTotalWithShippingTotal = this.orderDetails.order_total ? this.orderDetails.order_total : 0;
|
|
3421
3440
|
basketSummary.webOrder = basketSummaryWebOrder;
|
|
3422
3441
|
this.webReturnObject.basketSummary = basketSummary;
|
|
3423
|
-
|
|
3442
|
+
AppLoggerService.logDebug(this.className, "basketSummary", "basketSummary mapping ended...");
|
|
3424
3443
|
return this;
|
|
3425
3444
|
}
|
|
3426
3445
|
deviceId(deviceId) {
|
|
@@ -3460,7 +3479,7 @@ class WebReturnSalesforceMapperBuilderClass {
|
|
|
3460
3479
|
return this;
|
|
3461
3480
|
}
|
|
3462
3481
|
build() {
|
|
3463
|
-
|
|
3482
|
+
AppLoggerService.logDebug(this.className, "build", "mapping done...");
|
|
3464
3483
|
return this.webReturnObject;
|
|
3465
3484
|
}
|
|
3466
3485
|
getUTCDateTime(date) {
|
|
@@ -3479,4 +3498,4 @@ class WebReturnSalesforceMapperBuilderClass {
|
|
|
3479
3498
|
*/
|
|
3480
3499
|
|
|
3481
3500
|
export { MapperLibraryComponent, MapperLibraryModule, RJMapperBuilderClass, WebReturnMapperBuilderClass, WebReturnSalesforceMapperBuilderClass };
|
|
3482
|
-
//# sourceMappingURL=pmcretail-mapper-library.
|
|
3501
|
+
//# sourceMappingURL=pmcretail-mapper-library.js.map
|