@hmcts/ccpay-web-component 6.2.3-beta5 → 6.2.3-beta7

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.
@@ -2138,7 +2138,7 @@ class CaseTransactionsComponent {
2138
2138
  this.calculateOrderFeesAmounts();
2139
2139
  this.calculateRefundAmount();
2140
2140
  this.calculateAmountDueTo();
2141
- this.calculateOverpayment();
2141
+ this.calculateOverpaymentBasedOnRemission();
2142
2142
  this.validateAmountDueTo();
2143
2143
  this.calculateOverpaymentBaseOnAcceptedRefund();
2144
2144
  if (this.isFromServiceRequestPage) {
@@ -2166,7 +2166,7 @@ class CaseTransactionsComponent {
2166
2166
  this.calculateAmounts();
2167
2167
  this.calculateOrderFeesAmounts();
2168
2168
  this.calculateAmountDueTo();
2169
- this.calculateOverpayment();
2169
+ this.calculateOverpaymentBasedOnRemission();
2170
2170
  this.validateAmountDueTo();
2171
2171
  this.calculateOverpaymentBaseOnAcceptedRefund();
2172
2172
  this.totalRefundAmount = this.calculateRefundAmount();
@@ -2256,7 +2256,7 @@ class CaseTransactionsComponent {
2256
2256
  paymentGroup.fees.forEach(fee => {
2257
2257
  this.orderFeesTotal = this.orderFeesTotal + fee.calculated_amount;
2258
2258
  this.overPaymentAmount = this.overPaymentAmount + fee.over_payment;
2259
- this.paymentLibComponent.balanceToBePaid = this.overPaymentAmount;
2259
+ this.paymentLibComponent.overPaymentAmount = this.overPaymentAmount;
2260
2260
  });
2261
2261
  }
2262
2262
  if (paymentGroup.remissions) {
@@ -2269,7 +2269,7 @@ class CaseTransactionsComponent {
2269
2269
  paymentGroup.payments.forEach(payment => {
2270
2270
  if (isFeeOverPaymentExist) {
2271
2271
  this.overPaymentAmount = this.overPaymentAmount + payment.over_payment;
2272
- this.paymentLibComponent.balanceToBePaid = this.overPaymentAmount;
2272
+ this.paymentLibComponent.overPaymentAmount = this.overPaymentAmount;
2273
2273
  }
2274
2274
  if (payment.status.toUpperCase() === 'SUCCESS') {
2275
2275
  this.orderTotalPayments = this.orderTotalPayments + payment.amount;
@@ -2456,12 +2456,13 @@ class CaseTransactionsComponent {
2456
2456
  });
2457
2457
  return result;
2458
2458
  }
2459
- calculateOverpayment() {
2459
+ calculateOverpaymentBasedOnRemission() {
2460
+ // This sept is done to calculate a possible over payment due to remissions on fees.
2460
2461
  if (this.isThereRemissions()) {
2461
2462
  let newValue = this.totalPayments - (this.orderFeesTotal - this.totalRemissions);
2462
2463
  if (newValue > 0) {
2463
2464
  this.overPaymentAmount = newValue;
2464
- this.paymentLibComponent.balanceToBePaid = this.overPaymentAmount;
2465
+ this.paymentLibComponent.overPaymentAmount = this.overPaymentAmount;
2465
2466
  }
2466
2467
  }
2467
2468
  }
@@ -2480,6 +2481,7 @@ class CaseTransactionsComponent {
2480
2481
  }
2481
2482
  }
2482
2483
  calculateOverpaymentBaseOnAcceptedRefund() {
2484
+ // This sept is done to re calculate the final over payments values based on accepted refunds.
2483
2485
  this.paymentGroups.forEach(paymentGroup => {
2484
2486
  if (paymentGroup.refunds != null && paymentGroup.refunds.length > 0) {
2485
2487
  this.paymentLibComponent.refunds = paymentGroup.refunds;
@@ -2493,7 +2495,7 @@ class CaseTransactionsComponent {
2493
2495
  this.overPaymentAmount = newValue;
2494
2496
  }
2495
2497
  }
2496
- this.paymentLibComponent.balanceToBePaid = this.overPaymentAmount;
2498
+ this.paymentLibComponent.overPaymentAmount = this.overPaymentAmount;
2497
2499
  });
2498
2500
  }
2499
2501
  });
@@ -2666,7 +2668,7 @@ class CaseTransactionsComponent {
2666
2668
  this.paymentLibComponent.paymentReference = paymentGroup.paymentReference;
2667
2669
  this.paymentLibComponent.viewName = 'payment-view';
2668
2670
  this.paymentLibComponent.paymentGroup = this.paymentGroup;
2669
- this.paymentLibComponent.balanceToBePaid = this.overPaymentAmount;
2671
+ this.paymentLibComponent.overPaymentAmount = this.overPaymentAmount;
2670
2672
  }
2671
2673
  goToPayementView(paymentGroupReference, paymentReference, paymentMethod) {
2672
2674
  this.goToPaymentViewComponent({ paymentGroupReference, paymentReference, paymentMethod });
@@ -3047,25 +3049,25 @@ class ServiceRequestComponent {
3047
3049
  if (this.chkIsIssueRefundBtnEnable(payment)) {
3048
3050
  this.paymentViewService.getApportionPaymentDetails(payment.reference).subscribe(paymentGroup => {
3049
3051
  paymentGroup.payments = paymentGroup.payments.filter(paymentGroupObj => paymentGroupObj['reference'].includes(payment.reference));
3050
- // No refund and no over payment
3052
+ // No refund and no over payment --> showIssueRefundPage()
3051
3053
  if (!this.isAnyRefundsForThisCase() && this.getBalanceToBePaid() == 0) {
3052
3054
  this.showIssueRefundPage(paymentGroup, payment);
3053
3055
  return;
3054
3056
  }
3055
- // No refund and over payment
3057
+ // No refund and over payment --> showOverPayment()
3056
3058
  if (!this.isAnyRefundsForThisCase() && this.getBalanceToBePaid() > 0) {
3057
3059
  this.showOverPayment(paymentGroup, payment);
3058
3060
  return;
3059
3061
  }
3060
- // Refunds means and No over payment --> refunds accepted.
3062
+ // Refunds > 0 and overPayment == 0 ---> refunds accepted. showIssueRefundPage()
3061
3063
  if (this.isAnyRefundsForThisCase() && this.getBalanceToBePaid() == 0) {
3062
3064
  this.showIssueRefundPage(paymentGroup, payment);
3063
3065
  return;
3064
3066
  }
3065
- // Refunds means and No over payment --> refunds in process or Rejected.
3067
+ // Refunds > 0 and overPayment > 0 --> refunds in process or Rejected.
3066
3068
  if (this.isAnyRefundsForThisCase() && this.getBalanceToBePaid() > 0) {
3067
- let refund = this.getRefundByFeeID(paymentGroup.fees.at(0).id.toString());
3068
- if (refund.refund_status.name === 'Rejected') {
3069
+ // rejected by fee refunds === refunds by fee it means that refund for the current fee is rejected.
3070
+ if (this.isTheCurrentRefundRejectedForTheFee(paymentGroup.fees.at(0).id.toString())) {
3069
3071
  this.showOverPayment(paymentGroup, payment);
3070
3072
  return;
3071
3073
  }
@@ -3077,6 +3079,15 @@ class ServiceRequestComponent {
3077
3079
  }
3078
3080
  }
3079
3081
  }
3082
+ isTheCurrentRefundRejectedForTheFee(feeCode) {
3083
+ let refundsByFee = this.paymentLibComponent.refunds.filter(refund => refund.fee_ids === feeCode);
3084
+ let refundsByFeeAndRejected = this.paymentLibComponent.refunds.filter(refund => refund.refund_status.name === 'Rejected');
3085
+ // Refunds > 0 and overPayment --> refunds in process or Rejected.
3086
+ if (refundsByFee.length === refundsByFeeAndRejected.length) {
3087
+ return true;
3088
+ }
3089
+ return false;
3090
+ }
3080
3091
  isAnyRefundsForThisCase() {
3081
3092
  return (this.paymentLibComponent.refunds != null) && (this.paymentLibComponent.refunds.length > 0);
3082
3093
  }
@@ -3101,15 +3112,7 @@ class ServiceRequestComponent {
3101
3112
  this.isFromServiceRequestPage = false;
3102
3113
  }
3103
3114
  getBalanceToBePaid() {
3104
- return this.paymentLibComponent.balanceToBePaid;
3105
- }
3106
- getRefundByFeeID(feeCode) {
3107
- for (const refund of this.paymentLibComponent.refunds) {
3108
- if (refund.fee_ids === feeCode) {
3109
- return refund;
3110
- }
3111
- }
3112
- return null;
3115
+ return this.paymentLibComponent.overPaymentAmount;
3113
3116
  }
3114
3117
  goToPayementView(paymentGroupReference, paymentReference, paymentMethod) {
3115
3118
  this.goToPaymentViewComponent({ paymentGroupReference, paymentReference, paymentMethod });
@@ -3158,12 +3161,21 @@ class ServiceRequestComponent {
3158
3161
  }
3159
3162
  chkIsAddRemissionBtnEnable(fee) {
3160
3163
  if (fee !== null && fee !== undefined) {
3161
- return fee.add_remission && fee.remission_enable;
3164
+ return fee.add_remission && fee.remission_enable && this.isTheCurrentRefundInProcessForThisFee(fee);
3162
3165
  }
3163
3166
  else {
3164
3167
  return false;
3165
3168
  }
3166
3169
  }
3170
+ // This method is going to check if the current refund has been rejected.
3171
+ // If this is the case the button should be disable.
3172
+ isTheCurrentRefundInProcessForThisFee(fee) {
3173
+ // No refunds
3174
+ if (this.paymentLibComponent.refunds == null || this.paymentLibComponent.refunds.length === 0) {
3175
+ return false;
3176
+ }
3177
+ return !this.isTheCurrentRefundRejectedForTheFee(fee.id.toString());
3178
+ }
3167
3179
  resetOrderData() {
3168
3180
  this.OrderslistService.setOrderRef(null);
3169
3181
  this.OrderslistService.setorderCCDEvent(null);
@@ -3252,7 +3264,7 @@ class ServiceRequestComponent {
3252
3264
  this.paymentGroupList.fees.forEach(fee => {
3253
3265
  feesOverPayment += fee.over_payment;
3254
3266
  });
3255
- return feesOverPayment > 0 ? feesOverPayment : this.paymentLibComponent.balanceToBePaid;
3267
+ return feesOverPayment > 0 ? feesOverPayment : this.paymentLibComponent.overPaymentAmount;
3256
3268
  }
3257
3269
  getTemplateInstructionType(payment) {
3258
3270
  if (payment == undefined || payment == null) {
@@ -4410,7 +4422,7 @@ class AddRemissionComponent {
4410
4422
  return remission.overall_balance.toString();
4411
4423
  }
4412
4424
  else {
4413
- return this.paymentLibComponent.balanceToBePaid.toString();
4425
+ return this.paymentLibComponent.overPaymentAmount.toString();
4414
4426
  }
4415
4427
  }
4416
4428
  return "undefined";
@@ -4707,7 +4719,7 @@ class PaymentViewComponent {
4707
4719
  this.paymentGroup.fees.forEach(fee => {
4708
4720
  feesOverPayment += fee.over_payment;
4709
4721
  });
4710
- return feesOverPayment > 0 ? feesOverPayment : this.paymentLibComponent.balanceToBePaid;
4722
+ return feesOverPayment > 0 ? feesOverPayment : this.paymentLibComponent.overPaymentAmount;
4711
4723
  }
4712
4724
  goToServiceRequestPage() {
4713
4725
  this.paymentLibComponent.viewName = 'case-transactions';
@@ -4815,25 +4827,25 @@ class PaymentViewComponent {
4815
4827
  issueRefund(paymentgrp) {
4816
4828
  if (paymentgrp !== null && paymentgrp !== undefined) {
4817
4829
  if (this.chkIsIssueRefundBtnEnable(paymentgrp.payments[0])) {
4818
- // No refund and no over payment
4830
+ // No refund and no over payment --> showIssueRefundPage()
4819
4831
  if (!this.isAnyRefundsForThisCase() && this.getBalanceToBePaid() == 0) {
4820
4832
  this.showIssueRefundPage(paymentgrp);
4821
4833
  return;
4822
4834
  }
4823
- // No refund and over payment
4835
+ // No refund and over payment --> showOverPayment()
4824
4836
  if (!this.isAnyRefundsForThisCase() && this.getBalanceToBePaid() > 0) {
4825
4837
  this.showOverPayment();
4826
4838
  return;
4827
4839
  }
4828
- // Refunds means and No over payment --> refunds accepted.
4840
+ // Refunds > 0 and overPayment == 0 ---> refunds accepted. showIssueRefundPage(s)
4829
4841
  if (this.isAnyRefundsForThisCase() && this.getBalanceToBePaid() == 0) {
4830
4842
  this.showIssueRefundPage(paymentgrp);
4831
4843
  return;
4832
4844
  }
4833
- // Refunds means and No over payment --> refunds in process or Rejected.
4845
+ // Refunds > 0 and overPayment > 0 --> refunds in process or Rejected.
4834
4846
  if (this.isAnyRefundsForThisCase() && this.getBalanceToBePaid() > 0) {
4835
- let refund = this.getRefundByFeeID(this.paymentFees.at(0).id.toString());
4836
- if (refund.refund_status.name === 'Rejected') {
4847
+ // rejected by fee refunds === refunds by fee it means that refund for the current fee is rejected.
4848
+ if (this.isTheCurrentRefundRejectedForTheFee(this.paymentFees.at(0).id.toString())) {
4837
4849
  this.showOverPayment();
4838
4850
  return;
4839
4851
  }
@@ -4844,6 +4856,15 @@ class PaymentViewComponent {
4844
4856
  }
4845
4857
  }
4846
4858
  }
4859
+ isTheCurrentRefundRejectedForTheFee(feeCode) {
4860
+ let refundsByFee = this.paymentLibComponent.refunds.filter(refund => refund.fee_ids === feeCode);
4861
+ let refundsByFeeAndRejected = this.paymentLibComponent.refunds.filter(refund => refund.refund_status.name === 'Rejected');
4862
+ // Refunds > 0 and overPayment --> refunds in process or Rejected.
4863
+ if (refundsByFee.length === refundsByFeeAndRejected.length) {
4864
+ return true;
4865
+ }
4866
+ return false;
4867
+ }
4847
4868
  isAnyRefundsForThisCase() {
4848
4869
  return (this.paymentLibComponent.refunds != null) && (this.paymentLibComponent.refunds.length > 0);
4849
4870
  }
@@ -4859,15 +4880,7 @@ class PaymentViewComponent {
4859
4880
  this.isFromServiceRequestPage = false;
4860
4881
  }
4861
4882
  getBalanceToBePaid() {
4862
- return this.paymentLibComponent.balanceToBePaid;
4863
- }
4864
- getRefundByFeeID(feeCode) {
4865
- for (const refund of this.paymentLibComponent.refunds) {
4866
- if (refund.fee_ids === feeCode) {
4867
- return refund;
4868
- }
4869
- }
4870
- return null;
4883
+ return this.paymentLibComponent.overPaymentAmount;
4871
4884
  }
4872
4885
  getRemissionByFeeCode(feeCode, remissions) {
4873
4886
  if (remissions && remissions.length > 0) {
@@ -4908,12 +4921,21 @@ class PaymentViewComponent {
4908
4921
  }
4909
4922
  chkIsAddRemissionBtnEnable(fee) {
4910
4923
  if (fee !== null && fee !== undefined) {
4911
- return fee.add_remission && fee.remission_enable;
4924
+ return fee.add_remission && fee.remission_enable && this.isTheCurrentRefundInProcessForThisFee(fee);
4912
4925
  }
4913
4926
  else {
4914
4927
  return false;
4915
4928
  }
4916
4929
  }
4930
+ // This method is going to check if the current refund has been rejected.
4931
+ // If this is the case the button should be disable.
4932
+ isTheCurrentRefundInProcessForThisFee(fee) {
4933
+ // No refunds
4934
+ if (this.paymentLibComponent.refunds == null || this.paymentLibComponent.refunds.length === 0) {
4935
+ return false;
4936
+ }
4937
+ return !this.isTheCurrentRefundRejectedForTheFee(fee.id.toString());
4938
+ }
4917
4939
  selectPymentOption(paymentType) {
4918
4940
  this.paymentType = paymentType;
4919
4941
  this.isContinueBtnDisabled = false;
@@ -7579,7 +7601,7 @@ class PaymentLibComponent {
7579
7601
  orderTotalPayments = 0.00;
7580
7602
  orderPendingPayments = 0.00;
7581
7603
  paymentGroup;
7582
- balanceToBePaid = 0.00;
7604
+ overPaymentAmount = 0.00;
7583
7605
  refunds;
7584
7606
  constructor(paymentLibService, cd, OrderslistService) {
7585
7607
  this.paymentLibService = paymentLibService;