parent
b4c31ee9b5
commit
34dbaaafe0
@ -1,5 +1,6 @@
|
|||||||
import { IsInt, IsNotEmpty, IsPositive } from "class-validator";
|
import { IsInt, IsNotEmpty, IsPositive } from "class-validator";
|
||||||
import { Donation } from '../entities/Donation';
|
import { Donation } from '../entities/Donation';
|
||||||
|
import { DonationStatus } from '../enums/DonationStatus';
|
||||||
import { ResponseObjectType } from '../enums/ResponseObjectType';
|
import { ResponseObjectType } from '../enums/ResponseObjectType';
|
||||||
import { IResponse } from './IResponse';
|
import { IResponse } from './IResponse';
|
||||||
import { ResponseDonor } from './ResponseDonor';
|
import { ResponseDonor } from './ResponseDonor';
|
||||||
@ -15,6 +16,12 @@ export class ResponseDonation implements IResponse {
|
|||||||
*/
|
*/
|
||||||
responseType: ResponseObjectType = ResponseObjectType.DONATION;
|
responseType: ResponseObjectType = ResponseObjectType.DONATION;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The donation's payment status.
|
||||||
|
* Provides you with a quick indicator of it's payment status.
|
||||||
|
*/
|
||||||
|
status: DonationStatus;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The donation's id.
|
* The donation's id.
|
||||||
*/
|
*/
|
||||||
@ -49,5 +56,11 @@ export class ResponseDonation implements IResponse {
|
|||||||
this.donor = donation.donor.toResponse();
|
this.donor = donation.donor.toResponse();
|
||||||
this.amount = donation.amount;
|
this.amount = donation.amount;
|
||||||
this.payedAmount = donation.payedAmount;
|
this.payedAmount = donation.payedAmount;
|
||||||
|
if (this.payedAmount < this.amount) {
|
||||||
|
this.status = DonationStatus.OPEN;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
this.status = DonationStatus.PAYED;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user