digipay-utility-payment 0.0.20 → 0.0.22
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.
|
Binary file
|
|
@@ -1922,6 +1922,7 @@ class BillWorkflowComponent {
|
|
|
1922
1922
|
allWorkflowData = {};
|
|
1923
1923
|
selectedProduct = null;
|
|
1924
1924
|
PRODUCT_PRICE_TYPE = PRODUCT_PRICE_TYPE;
|
|
1925
|
+
isInitialized = false;
|
|
1925
1926
|
constructor(topupAndBillpaymentService, toasterService, fb, translationService, router, cdr, sdkState) {
|
|
1926
1927
|
this.topupAndBillpaymentService = topupAndBillpaymentService;
|
|
1927
1928
|
this.toasterService = toasterService;
|
|
@@ -1950,42 +1951,57 @@ class BillWorkflowComponent {
|
|
|
1950
1951
|
this.currentScreenIndex = index;
|
|
1951
1952
|
}
|
|
1952
1953
|
});
|
|
1954
|
+
this.topupAndBillpaymentService.workflowData.pipe(takeUntil(this.destroy$)).subscribe((data) => {
|
|
1955
|
+
if (isNotNull(data)) {
|
|
1956
|
+
this.allWorkflowData = data;
|
|
1957
|
+
}
|
|
1958
|
+
});
|
|
1953
1959
|
this.topupAndBillpaymentService.workflowScreens.pipe(takeUntil(this.destroy$)).subscribe((screens) => {
|
|
1954
1960
|
if (isNotNull(screens)) {
|
|
1955
1961
|
this.workflowScreens = screens;
|
|
1956
|
-
if (this.
|
|
1962
|
+
if (this.isInitialized &&
|
|
1963
|
+
this.workflowScreens.length > 0 &&
|
|
1964
|
+
this.currentScreenIndex < this.workflowScreens.length) {
|
|
1957
1965
|
this.loadCurrentScreen();
|
|
1958
1966
|
}
|
|
1959
1967
|
}
|
|
1960
1968
|
});
|
|
1961
|
-
this.topupAndBillpaymentService.workflowData.pipe(takeUntil(this.destroy$)).subscribe((data) => {
|
|
1962
|
-
if (isNotNull(data)) {
|
|
1963
|
-
this.allWorkflowData = data;
|
|
1964
|
-
}
|
|
1965
|
-
});
|
|
1966
1969
|
// Create form with updateOn: 'change' for real-time validation
|
|
1967
1970
|
this.detailsForm = this.fb.group({}, { updateOn: 'change' });
|
|
1968
1971
|
}
|
|
1969
1972
|
ngOnInit() {
|
|
1970
|
-
|
|
1971
|
-
|
|
1972
|
-
|
|
1973
|
-
|
|
1974
|
-
else if (this.selectedBill) {
|
|
1975
|
-
this.checkWorkflowForBill(this.selectedBill);
|
|
1973
|
+
this.syncSelectedBillFromInputs();
|
|
1974
|
+
if (this.workflowScreens.length > 0) {
|
|
1975
|
+
if (this.getSelectedBill()) {
|
|
1976
|
+
this.loadCurrentScreen();
|
|
1976
1977
|
}
|
|
1977
1978
|
}
|
|
1979
|
+
else if (this.billData) {
|
|
1980
|
+
this.checkWorkflowForBill(this.billData);
|
|
1981
|
+
}
|
|
1982
|
+
else if (this.selectedBill) {
|
|
1983
|
+
this.checkWorkflowForBill(this.selectedBill);
|
|
1984
|
+
}
|
|
1985
|
+
this.isInitialized = true;
|
|
1978
1986
|
}
|
|
1979
1987
|
ngAfterViewInit() {
|
|
1980
1988
|
// Detect changes after view initialization to prevent ExpressionChangedAfterItHasBeenCheckedError
|
|
1981
1989
|
this.cdr.detectChanges();
|
|
1982
1990
|
}
|
|
1983
1991
|
ngOnChanges(changes) {
|
|
1992
|
+
const billFromInput = changes['billData']?.currentValue ?? changes['selectedBill']?.currentValue;
|
|
1993
|
+
if (billFromInput) {
|
|
1994
|
+
this.selectedBill = billFromInput;
|
|
1995
|
+
if (this.isInitialized && this.workflowScreens.length > 0) {
|
|
1996
|
+
this.loadCurrentScreen();
|
|
1997
|
+
return;
|
|
1998
|
+
}
|
|
1999
|
+
}
|
|
1984
2000
|
if (this.workflowScreens.length === 0) {
|
|
1985
|
-
if (changes['billData']
|
|
2001
|
+
if (changes['billData']?.currentValue) {
|
|
1986
2002
|
this.checkWorkflowForBill(changes['billData'].currentValue);
|
|
1987
2003
|
}
|
|
1988
|
-
if (changes['selectedBill']
|
|
2004
|
+
else if (changes['selectedBill']?.currentValue) {
|
|
1989
2005
|
this.checkWorkflowForBill(changes['selectedBill'].currentValue);
|
|
1990
2006
|
}
|
|
1991
2007
|
}
|
|
@@ -2431,6 +2447,24 @@ class BillWorkflowComponent {
|
|
|
2431
2447
|
};
|
|
2432
2448
|
}
|
|
2433
2449
|
}
|
|
2450
|
+
if (isAmountField) {
|
|
2451
|
+
const billAmount = this.getBillAmount();
|
|
2452
|
+
if (billAmount !== null) {
|
|
2453
|
+
customValidators = {
|
|
2454
|
+
...customValidators,
|
|
2455
|
+
billAmountMax: {
|
|
2456
|
+
expression: (control) => {
|
|
2457
|
+
const enteredAmount = this.parseFormAmount(control?.value);
|
|
2458
|
+
if (enteredAmount === null) {
|
|
2459
|
+
return true;
|
|
2460
|
+
}
|
|
2461
|
+
return enteredAmount <= billAmount;
|
|
2462
|
+
},
|
|
2463
|
+
message: () => this.translationService.translate("COMMON_LABEL_AMOUNT_MUST_NOT_EXCEED_BILL_AMOUNT"),
|
|
2464
|
+
},
|
|
2465
|
+
};
|
|
2466
|
+
}
|
|
2467
|
+
}
|
|
2434
2468
|
const validations = field?.field_validation || [];
|
|
2435
2469
|
const normalizedFieldType = this.normalizeFieldType(field?.field_type);
|
|
2436
2470
|
const normalizedValidations = this.normalizeValidations(validations);
|
|
@@ -2518,6 +2552,31 @@ class BillWorkflowComponent {
|
|
|
2518
2552
|
}
|
|
2519
2553
|
return null;
|
|
2520
2554
|
}
|
|
2555
|
+
getBillAmount() {
|
|
2556
|
+
const billAmount = Number(this.getSelectedBill()?.bill_amount);
|
|
2557
|
+
if (isNaN(billAmount) || billAmount <= 0) {
|
|
2558
|
+
return null;
|
|
2559
|
+
}
|
|
2560
|
+
return billAmount;
|
|
2561
|
+
}
|
|
2562
|
+
parseFormAmount(value) {
|
|
2563
|
+
if (value === null || value === undefined || value === "") {
|
|
2564
|
+
return null;
|
|
2565
|
+
}
|
|
2566
|
+
const amount = typeof value === "number" ? value : parseFloat(String(value));
|
|
2567
|
+
return isNaN(amount) ? null : amount;
|
|
2568
|
+
}
|
|
2569
|
+
syncSelectedBillFromInputs() {
|
|
2570
|
+
if (this.billData) {
|
|
2571
|
+
this.selectedBill = this.billData;
|
|
2572
|
+
}
|
|
2573
|
+
else if (this.allWorkflowData?.selectedBill) {
|
|
2574
|
+
this.selectedBill = this.allWorkflowData.selectedBill;
|
|
2575
|
+
}
|
|
2576
|
+
}
|
|
2577
|
+
getSelectedBill() {
|
|
2578
|
+
return this.allWorkflowData?.selectedBill ?? this.billData ?? this.selectedBill ?? null;
|
|
2579
|
+
}
|
|
2521
2580
|
ngOnDestroy() {
|
|
2522
2581
|
this.destroy$.next(true);
|
|
2523
2582
|
this.destroy$.unsubscribe();
|