@hmcts/ccpay-web-component 6.5.23-beta1 → 6.5.23-beta3

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,6 @@
1
1
  import * as i0 from '@angular/core';
2
2
  import { Injectable, EventEmitter, Output, Input, Inject, Component, Pipe, forwardRef, ViewChild, NgModule } from '@angular/core';
3
- import { BehaviorSubject, throwError } from 'rxjs';
3
+ import { BehaviorSubject, throwError, forkJoin } from 'rxjs';
4
4
  import * as i3 from '@angular/common';
5
5
  import { CommonModule, formatDate } from '@angular/common';
6
6
  import * as i1 from '@angular/common/http';
@@ -3790,42 +3790,32 @@ class AddRemissionComponent {
3790
3790
  const newNetAmount = this.remissionForm.controls.amount.value, remissionAmount = parseFloat((this.fee.net_amount - newNetAmount).toFixed(2)), requestBody = new AddRemissionRequest(this.ccdCaseNumber, this.fee, remissionAmount, this.remissionForm.controls.remissionCode.value, this.caseType);
3791
3791
  this.paymentViewService.postPaymentGroupWithRemissions(decodeURIComponent(this.paymentGroupRef).trim(), this.fee.id, requestBody).subscribe(response => {
3792
3792
  if (JSON.parse(response).success) {
3793
- let LDUrl = this.isTurnOff ? '&isTurnOff=Enable' : '&isTurnOff=Disable';
3794
- LDUrl += `&caseType=${this.caseType}`;
3795
- if (this.paymentLibComponent.bspaymentdcn) {
3796
- this.router.routeReuseStrategy.shouldReuseRoute = () => false;
3797
- this.router.onSameUrlNavigation = 'reload';
3798
- this.router.navigateByUrl(`/payment-history/${this.ccdCaseNumber}?view=fee-summary&selectedOption=${this.option}&paymentGroupRef=${this.paymentGroupRef}&dcn=${this.paymentLibComponent.bspaymentdcn}${LDUrl}`);
3799
- }
3800
- else {
3801
- this.redirectAfterAddigRemission(event);
3802
- }
3793
+ this.redirectAfterAddingRemission(event);
3803
3794
  }
3804
3795
  }, (error) => {
3805
3796
  this.errorMessage = error;
3806
3797
  this.isConfirmationBtnDisabled = false;
3807
3798
  });
3808
3799
  }
3809
- redirectAfterAddigRemission(event) {
3800
+ redirectAfterAddingRemission(event) {
3810
3801
  const value = this.remissionForm.controls.amount.value;
3811
3802
  //if the from is empty or 0 it means full remission.
3812
3803
  if (["0", "", null].includes(value)) {
3813
3804
  this.gotoCasetransationPage();
3814
3805
  }
3815
3806
  else {
3816
- this.redirectToSummaryPage(event, this.orderRef);
3807
+ this.redirectToSummaryPage(event);
3817
3808
  }
3818
3809
  }
3819
- redirectToSummaryPage(event, orderef) {
3820
- if (true) {
3810
+ redirectToSummaryPage(event) {
3811
+ if (event && typeof event.preventDefault === 'function') {
3821
3812
  event.preventDefault();
3822
- this.paymentLibComponent.bspaymentdcn = null;
3823
- this.paymentLibComponent.paymentGroupReference = this.paymentGroupRef;
3824
- this.paymentLibComponent.isTurnOff = this.isTurnOff;
3825
- this.paymentLibComponent.viewName = 'fee-summary';
3826
- this.confirmRemissionEvent.emit();
3827
- this.remissionAdded.emit();
3828
3813
  }
3814
+ this.paymentLibComponent.paymentGroupReference = this.paymentGroupRef;
3815
+ this.paymentLibComponent.isTurnOff = this.isTurnOff;
3816
+ this.paymentLibComponent.viewName = 'fee-summary';
3817
+ this.confirmRemissionEvent.emit();
3818
+ this.remissionAdded.emit();
3829
3819
  }
3830
3820
  returnToFeeScreen() {
3831
3821
  this.viewStatus = 'main';
@@ -4742,25 +4732,51 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.18", ngImpo
4742
4732
 
4743
4733
  class StatusHistoryComponent {
4744
4734
  statusHistoryService;
4735
+ paymentViewService;
4745
4736
  paymentLibComponent;
4746
4737
  isTakePayment;
4747
4738
  pageTitle = 'Payment status history';
4748
4739
  statuses;
4740
+ isDisplayFailureReasonColumn = false;
4741
+ isDisplayReasons = [];
4749
4742
  errorMessage;
4750
- constructor(statusHistoryService, paymentLibComponent) {
4743
+ constructor(statusHistoryService, paymentViewService, paymentLibComponent) {
4751
4744
  this.statusHistoryService = statusHistoryService;
4745
+ this.paymentViewService = paymentViewService;
4752
4746
  this.paymentLibComponent = paymentLibComponent;
4753
4747
  }
4754
4748
  ngOnInit() {
4755
- this.statusHistoryService.getPaymentStatusesByReference(this.paymentLibComponent.paymentReference, this.paymentLibComponent.paymentMethod).subscribe(statuses => this.statuses = statuses, (error) => this.errorMessage = error.replace(/"/g, ""));
4749
+ forkJoin({
4750
+ paymentGroup: this.paymentViewService.getApportionPaymentDetails(this.paymentLibComponent.paymentReference),
4751
+ statuses: this.statusHistoryService.getPaymentStatusesByReference(this.paymentLibComponent.paymentReference, this.paymentLibComponent.paymentMethod)
4752
+ }).subscribe(({ paymentGroup, statuses }) => {
4753
+ this.statuses = statuses;
4754
+ const firstPayment = paymentGroup &&
4755
+ paymentGroup.payments &&
4756
+ paymentGroup.payments.length > 0 ? paymentGroup.payments[0] : null;
4757
+ if (firstPayment &&
4758
+ (firstPayment.channel.toLowerCase() === 'telephony' || firstPayment.channel.toLowerCase() === 'online') &&
4759
+ (firstPayment.method.toLowerCase() === 'card')) {
4760
+ this.isDisplayReasons = this.statuses.status_histories.map(statusHistory => statusHistory.status.toLowerCase() === 'failed' ||
4761
+ statusHistory.status.toLowerCase() === 'declined' ||
4762
+ statusHistory.status.toLowerCase() === 'cancelled' ||
4763
+ statusHistory.status.toLowerCase() === 'timed out' ||
4764
+ statusHistory.status.toLowerCase() === 'error');
4765
+ this.isDisplayFailureReasonColumn = this.isDisplayReasons.some(isDisplayReason => isDisplayReason);
4766
+ }
4767
+ else {
4768
+ this.isDisplayReasons = [];
4769
+ this.isDisplayFailureReasonColumn = false;
4770
+ }
4771
+ }, (error) => this.errorMessage = error.replace(/"/g, ""));
4756
4772
  }
4757
- static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.18", ngImport: i0, type: StatusHistoryComponent, deps: [{ token: StatusHistoryService }, { token: 'PAYMENT_LIB' }], target: i0.ɵɵFactoryTarget.Component });
4758
- static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "20.3.18", type: StatusHistoryComponent, isStandalone: true, selector: "ccpay-payment-statuses", inputs: { isTakePayment: "isTakePayment" }, ngImport: i0, template: "<div class=\"column\">\n <h2 class=\"heading-medium\">{{ pageTitle }}</h2>\n</div>\n\n\n<div class=\"error-summary\" role=\"group\" aria-labelledby=\"failure-error-summary-heading\" tabindex=\"-1\" *ngIf=\"errorMessage\">\n <h2 class=\"heading-medium error-summary-heading\" id=\"failure-error-summary-heading\">\n Payment status history could not be retrieved\n </h2>\n <div class=\"govuk-error-summary__body\">\n {{ errorMessage }}\n </div>\n</div>\n\n<div *ngIf=\"!errorMessage && statuses\">\n <table>\n <thead>\n <tr>\n <th>Status</th>\n <th *ngIf=\"isTakePayment\">Amount</th>\n <th>Date and time</th>\n </tr>\n </thead> \n <tbody>\n <tr *ngFor=\"let status of statuses.status_histories\">\n <td>{{ status.status }}</td>\n <td *ngIf=\"isTakePayment\">\u00A3{{ statuses.amount | number:'.2' }}</td>\n <td>{{ status.date_created | date:'dd MMMM yyyy HH:mm:ss'}}</td>\n </tr>\n </tbody>\n </table>\n</div>\n", styles: [""], dependencies: [{ kind: "ngmodule", type: CommonModule }, { kind: "directive", type: i3.NgForOf, selector: "[ngFor][ngForOf]", inputs: ["ngForOf", "ngForTrackBy", "ngForTemplate"] }, { kind: "directive", type: i3.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { kind: "pipe", type: i3.DecimalPipe, name: "number" }, { kind: "pipe", type: i3.DatePipe, name: "date" }] });
4773
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.18", ngImport: i0, type: StatusHistoryComponent, deps: [{ token: StatusHistoryService }, { token: PaymentViewService }, { token: 'PAYMENT_LIB' }], target: i0.ɵɵFactoryTarget.Component });
4774
+ static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "20.3.18", type: StatusHistoryComponent, isStandalone: true, selector: "ccpay-payment-statuses", inputs: { isTakePayment: "isTakePayment" }, ngImport: i0, template: "<div class=\"column\">\n <h2 class=\"heading-medium\">{{ pageTitle }}</h2>\n</div>\n\n\n<div class=\"error-summary\" role=\"group\" aria-labelledby=\"failure-error-summary-heading\" tabindex=\"-1\" *ngIf=\"errorMessage\">\n <h2 class=\"heading-medium error-summary-heading\" id=\"failure-error-summary-heading\">\n Payment status history could not be retrieved\n </h2>\n <div class=\"govuk-error-summary__body\">\n {{ errorMessage }}\n </div>\n</div>\n\n<div *ngIf=\"!errorMessage && statuses\">\n <table>\n <thead>\n <tr>\n <th>Status</th>\n <th *ngIf=\"isDisplayFailureReasonColumn\">Failure reason</th>\n <th *ngIf=\"isTakePayment\">Amount</th>\n <th>Date and time</th>\n </tr>\n </thead>\n <tbody>\n <tr *ngFor=\"let status of statuses.status_histories; let i = index\">\n <td>{{ status.status }}</td>\n <td *ngIf=\"isDisplayFailureReasonColumn\">{{ isDisplayReasons[i] ? status.error_message : '' }}</td>\n <td *ngIf=\"isTakePayment\">\u00A3{{ statuses.amount | number:'.2' }}</td>\n <td>{{ status.date_created | date:'dd MMMM yyyy HH:mm:ss'}}</td>\n </tr>\n </tbody>\n </table>\n</div>\n", styles: [""], dependencies: [{ kind: "ngmodule", type: CommonModule }, { kind: "directive", type: i3.NgForOf, selector: "[ngFor][ngForOf]", inputs: ["ngForOf", "ngForTrackBy", "ngForTemplate"] }, { kind: "directive", type: i3.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { kind: "pipe", type: i3.DecimalPipe, name: "number" }, { kind: "pipe", type: i3.DatePipe, name: "date" }] });
4759
4775
  }
4760
4776
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.18", ngImport: i0, type: StatusHistoryComponent, decorators: [{
4761
4777
  type: Component,
4762
- args: [{ selector: 'ccpay-payment-statuses', imports: [CommonModule], standalone: true, template: "<div class=\"column\">\n <h2 class=\"heading-medium\">{{ pageTitle }}</h2>\n</div>\n\n\n<div class=\"error-summary\" role=\"group\" aria-labelledby=\"failure-error-summary-heading\" tabindex=\"-1\" *ngIf=\"errorMessage\">\n <h2 class=\"heading-medium error-summary-heading\" id=\"failure-error-summary-heading\">\n Payment status history could not be retrieved\n </h2>\n <div class=\"govuk-error-summary__body\">\n {{ errorMessage }}\n </div>\n</div>\n\n<div *ngIf=\"!errorMessage && statuses\">\n <table>\n <thead>\n <tr>\n <th>Status</th>\n <th *ngIf=\"isTakePayment\">Amount</th>\n <th>Date and time</th>\n </tr>\n </thead> \n <tbody>\n <tr *ngFor=\"let status of statuses.status_histories\">\n <td>{{ status.status }}</td>\n <td *ngIf=\"isTakePayment\">\u00A3{{ statuses.amount | number:'.2' }}</td>\n <td>{{ status.date_created | date:'dd MMMM yyyy HH:mm:ss'}}</td>\n </tr>\n </tbody>\n </table>\n</div>\n" }]
4763
- }], ctorParameters: () => [{ type: StatusHistoryService }, { type: undefined, decorators: [{
4778
+ args: [{ selector: 'ccpay-payment-statuses', imports: [CommonModule], standalone: true, template: "<div class=\"column\">\n <h2 class=\"heading-medium\">{{ pageTitle }}</h2>\n</div>\n\n\n<div class=\"error-summary\" role=\"group\" aria-labelledby=\"failure-error-summary-heading\" tabindex=\"-1\" *ngIf=\"errorMessage\">\n <h2 class=\"heading-medium error-summary-heading\" id=\"failure-error-summary-heading\">\n Payment status history could not be retrieved\n </h2>\n <div class=\"govuk-error-summary__body\">\n {{ errorMessage }}\n </div>\n</div>\n\n<div *ngIf=\"!errorMessage && statuses\">\n <table>\n <thead>\n <tr>\n <th>Status</th>\n <th *ngIf=\"isDisplayFailureReasonColumn\">Failure reason</th>\n <th *ngIf=\"isTakePayment\">Amount</th>\n <th>Date and time</th>\n </tr>\n </thead>\n <tbody>\n <tr *ngFor=\"let status of statuses.status_histories; let i = index\">\n <td>{{ status.status }}</td>\n <td *ngIf=\"isDisplayFailureReasonColumn\">{{ isDisplayReasons[i] ? status.error_message : '' }}</td>\n <td *ngIf=\"isTakePayment\">\u00A3{{ statuses.amount | number:'.2' }}</td>\n <td>{{ status.date_created | date:'dd MMMM yyyy HH:mm:ss'}}</td>\n </tr>\n </tbody>\n </table>\n</div>\n" }]
4779
+ }], ctorParameters: () => [{ type: StatusHistoryService }, { type: PaymentViewService }, { type: undefined, decorators: [{
4764
4780
  type: Inject,
4765
4781
  args: ['PAYMENT_LIB']
4766
4782
  }] }], propDecorators: { isTakePayment: [{