File

src/app/components/payments/payment-detail/payment-detail.vm.ts

Index

Properties
Methods

Constructor

constructor(statusService?: PaymentStatusService, payment?: Payment)
Parameters :
Name Type Optional
statusService PaymentStatusService Yes
payment Payment Yes

Properties

contactMethod
Type : string
daysLeft
Type : string
expirationDate
Type : Date
isExpired
Default value : false
isLoading
Default value : false
loaderHeader
Type : string
Default value : 'Canceling Payment'
message
Type : string
Default value : 'Please wait a moment while we cancel this payment.'
payment
Type : Payment
paymentDate
Type : Date

Methods

isCancelled
isCancelled()
Returns : boolean
isDone
isDone()
Returns : boolean
isHandlingError
isHandlingError()
Returns : boolean
isNotApplicable
isNotApplicable()
Returns : boolean
isPmtExpired
isPmtExpired()
Returns : boolean
isProcessing
isProcessing()
Returns : boolean
isWaiting
isWaiting()
Returns : boolean
setDaysLeft
setDaysLeft(days: number)
Parameters :
Name Type Optional
days number No
Returns : string
import { PaymentState } from '../../../enums';
import { Payment } from '../../../models';
import { PaymentStatusService } from '../../../providers';

const states = PaymentState;

export class PaymentDetailViewModel {
  payment: Payment;
  paymentDate: Date;
  contactMethod: string;
  expirationDate: Date;
  daysLeft: string;
  isLoading = false;
  isExpired = false;
  loaderHeader = 'Canceling Payment';
  message = 'Please wait a moment while we cancel this payment.';

  constructor(private statusService?: PaymentStatusService, payment?: Payment) {
    // tslint:disable-next-line:curly
    if (statusService === null || statusService === undefined) return;
    // tslint:disable-next-line:curly
    if (payment === null || payment === undefined) return;
    this.payment = payment;
    this.paymentDate = new Date(this.payment.paymentDate);
    const startDate = new Date(this.payment.paymentDate);
    this.expirationDate = new Date(this.payment.paymentDate);
    const today = new Date();
  }

  isWaiting(): boolean {
    // tslint:disable-next-line:curly
    if (this.statusService === null || this.statusService === undefined)
      return false;
    return this.statusService.getState(this.payment) === PaymentState.WAITING;
  }

  isPmtExpired(): boolean {
    // tslint:disable-next-line:curly
    if (this.statusService === null || this.statusService === undefined)
      return false;
    return this.statusService.getState(this.payment) === PaymentState.EXPIRED;
  }

  isNotApplicable(): boolean {
    // tslint:disable-next-line:curly
    if (this.statusService === null || this.statusService === undefined)
      return false;
    return (
      this.statusService.getState(this.payment) === PaymentState.NOTAPPLICABLE
    );
  }

  isProcessing(): boolean {
    // tslint:disable-next-line:curly
    if (this.statusService === null || this.statusService === undefined)
      return false;
    return (
      this.statusService.getState(this.payment) === PaymentState.PROCESSING
    );
  }

  isCancelled(): boolean {
    // tslint:disable-next-line:curly
    if (this.statusService === null || this.statusService === undefined)
      return false;
    return this.statusService.getState(this.payment) === PaymentState.CANCELLED;
  }

  isDone(): boolean {
    // tslint:disable-next-line:curly
    if (this.statusService === null || this.statusService === undefined)
      return false;
    return this.statusService.getState(this.payment) === PaymentState.DONE;
  }

  isHandlingError(): boolean {
    // tslint:disable-next-line:curly
    if (this.statusService === null || this.statusService === undefined)
      return false;
    return this.statusService.getState(this.payment) === PaymentState.ERROR;
  }

  setDaysLeft(days: number) {
    if (days === 0) {
      return (this.daysLeft = 'LESS THAN 1');
    } else if (days > 0) {
      this.daysLeft = `${days}`;
    } else {
      this.daysLeft = 'EXPIRED';
      this.isExpired = true;
    }
  }
}

results matching ""

    No results matching ""