File
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.'
|
|
Methods
isCancelled
|
isCancelled()
|
|
|
isHandlingError
|
isHandlingError()
|
|
|
isNotApplicable
|
isNotApplicable()
|
|
|
isPmtExpired
|
isPmtExpired()
|
|
|
isProcessing
|
isProcessing()
|
|
|
setDaysLeft
|
setDaysLeft(days: number)
|
|
Parameters :
Name |
Type |
Optional |
days |
number
|
No
|
|
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;
}
}
}