diff --git a/src/models/actions/create/CreateDistanceDonation.ts b/src/models/actions/create/CreateDistanceDonation.ts index 99db308..133e71b 100644 --- a/src/models/actions/create/CreateDistanceDonation.ts +++ b/src/models/actions/create/CreateDistanceDonation.ts @@ -33,7 +33,7 @@ export class CreateDistanceDonation extends CreateDonation { let newDonation = new DistanceDonation; newDonation.amountPerDistance = this.amountPerDistance; - newDonation.payedAmount = this.payedAmount; + newDonation.paidAmount = this.paidAmount; newDonation.donor = await this.getDonor(); newDonation.runner = await this.getRunner(); diff --git a/src/models/actions/create/CreateDonation.ts b/src/models/actions/create/CreateDonation.ts index 9cf0870..e70455e 100644 --- a/src/models/actions/create/CreateDonation.ts +++ b/src/models/actions/create/CreateDonation.ts @@ -17,11 +17,11 @@ export abstract class CreateDonation { donor: number; /** - * The donation's payed amount in the smalles unit of your currency (default: euro cent). + * The donation's paid amount in the smalles unit of your currency (default: euro cent). */ @IsInt() @IsOptional() - payedAmount?: number; + paidAmount?: number; /** * Creates a new Donation entity from this. diff --git a/src/models/actions/create/CreateFixedDonation.ts b/src/models/actions/create/CreateFixedDonation.ts index cc1af3c..bfdca9f 100644 --- a/src/models/actions/create/CreateFixedDonation.ts +++ b/src/models/actions/create/CreateFixedDonation.ts @@ -21,7 +21,7 @@ export class CreateFixedDonation extends CreateDonation { let newDonation = new FixedDonation; newDonation.amount = this.amount; - newDonation.payedAmount = this.payedAmount; + newDonation.paidAmount = this.paidAmount; newDonation.donor = await this.getDonor(); return newDonation; diff --git a/src/models/actions/update/UpdateDistanceDonation.ts b/src/models/actions/update/UpdateDistanceDonation.ts index ebcd7e7..c9a66ce 100644 --- a/src/models/actions/update/UpdateDistanceDonation.ts +++ b/src/models/actions/update/UpdateDistanceDonation.ts @@ -32,7 +32,7 @@ export class UpdateDistanceDonation extends UpdateDonation { */ public async update(donation: DistanceDonation): Promise { donation.amountPerDistance = this.amountPerDistance; - donation.payedAmount = this.payedAmount; + donation.paidAmount = this.paidAmount; donation.donor = await this.getDonor(); donation.runner = await this.getRunner(); diff --git a/src/models/actions/update/UpdateDonation.ts b/src/models/actions/update/UpdateDonation.ts index b08e4e9..3acf2b9 100644 --- a/src/models/actions/update/UpdateDonation.ts +++ b/src/models/actions/update/UpdateDonation.ts @@ -24,11 +24,11 @@ export abstract class UpdateDonation { donor: number; /** - * The donation's payed amount in the smalles unit of your currency (default: euro cent). + * The donation's paid amount in the smalles unit of your currency (default: euro cent). */ @IsInt() @IsOptional() - payedAmount?: number; + paidAmount?: number; /** * Creates a new Donation entity from this. diff --git a/src/models/actions/update/UpdateFixedDonation.ts b/src/models/actions/update/UpdateFixedDonation.ts index 19919dd..9e0401f 100644 --- a/src/models/actions/update/UpdateFixedDonation.ts +++ b/src/models/actions/update/UpdateFixedDonation.ts @@ -20,7 +20,7 @@ export class UpdateFixedDonation extends UpdateDonation { */ public async update(donation: FixedDonation): Promise { donation.amount = this.amount; - donation.payedAmount = this.payedAmount; + donation.paidAmount = this.paidAmount; donation.donor = await this.getDonor(); return donation; diff --git a/src/models/entities/Donation.ts b/src/models/entities/Donation.ts index ef66b65..f693d01 100644 --- a/src/models/entities/Donation.ts +++ b/src/models/entities/Donation.ts @@ -35,12 +35,12 @@ export abstract class Donation { public abstract get amount(): number; /** - * The donation's payed amount in cents (or whatever your currency's smallest unit is.). - * Used to mark donations as payed. + * The donation's paid amount in cents (or whatever your currency's smallest unit is.). + * Used to mark donations as paid. */ @Column({ nullable: true }) @IsInt() - payedAmount: number; + paidAmount: number; /** * Turns this entity into it's response class. diff --git a/src/models/entities/Donor.ts b/src/models/entities/Donor.ts index 2692e81..4d42769 100644 --- a/src/models/entities/Donor.ts +++ b/src/models/entities/Donor.ts @@ -34,12 +34,12 @@ export class Donor extends Participant { } /** - * Returns the total payed donations of a donor based on his linked donations. + * Returns the total paid donations of a donor based on his linked donations. */ @IsInt() - public get payedDonationAmount(): number { + public get paidDonationAmount(): number { if (!this.donations) { return 0; } - return this.donations.reduce((sum, current) => sum + current.payedAmount, 0); + return this.donations.reduce((sum, current) => sum + current.paidAmount, 0); } /** diff --git a/src/models/enums/DonationStatus.ts b/src/models/enums/DonationStatus.ts index 5b2658f..0f2323f 100644 --- a/src/models/enums/DonationStatus.ts +++ b/src/models/enums/DonationStatus.ts @@ -3,5 +3,5 @@ */ export enum DonationStatus { OPEN = 'OPEN', - PAYED = 'PAYED' + PAID = 'PAID' } \ No newline at end of file diff --git a/src/models/responses/ResponseDonation.ts b/src/models/responses/ResponseDonation.ts index 0703e24..e917e96 100644 --- a/src/models/responses/ResponseDonation.ts +++ b/src/models/responses/ResponseDonation.ts @@ -42,10 +42,10 @@ export class ResponseDonation implements IResponse { amount: number; /** - * The donation's payed amount in the smalles unit of your currency (default: euro cent). + * The donation's paid amount in the smalles unit of your currency (default: euro cent). */ @IsInt() - payedAmount: number; + paidAmount: number; /** * Creates a ResponseDonation object from a scan. @@ -55,12 +55,12 @@ export class ResponseDonation implements IResponse { this.id = donation.id; this.donor = donation.donor.toResponse(); this.amount = donation.amount; - this.payedAmount = donation.payedAmount || 0; - if (this.payedAmount < this.amount) { + this.paidAmount = donation.paidAmount || 0; + if (this.paidAmount < this.amount) { this.status = DonationStatus.OPEN; } else { - this.status = DonationStatus.PAYED; + this.status = DonationStatus.PAID; } } } diff --git a/src/models/responses/ResponseDonor.ts b/src/models/responses/ResponseDonor.ts index d3d2c84..07f12dc 100644 --- a/src/models/responses/ResponseDonor.ts +++ b/src/models/responses/ResponseDonor.ts @@ -29,10 +29,10 @@ export class ResponseDonor extends ResponseParticipant implements IResponse { donationAmount: number; /** - * Returns the total payed donations of a donor based on his linked donations. + * Returns the total paid donations of a donor based on his linked donations. */ @IsInt() - payedDonationAmount: number; + paidDonationAmount: number; /** * Creates a ResponseRunner object from a runner. @@ -42,5 +42,6 @@ export class ResponseDonor extends ResponseParticipant implements IResponse { super(donor); this.receiptNeeded = donor.receiptNeeded; this.donationAmount = donor.donationAmount; + this.paidDonationAmount = donor.paidDonationAmount; } } diff --git a/src/tests/donations/donations_add.spec.ts b/src/tests/donations/donations_add.spec.ts index 3080854..1f9bfc2 100644 --- a/src/tests/donations/donations_add.spec.ts +++ b/src/tests/donations/donations_add.spec.ts @@ -181,7 +181,7 @@ describe('POST /api/donations/fixed successfully', () => { expect(res.data).toEqual({ "donor": added_donor, "amount": 1000, - "payedAmount": 0, + "paidAmount": 0, "status": "OPEN", "responseType": "DONATION" }); @@ -190,7 +190,7 @@ describe('POST /api/donations/fixed successfully', () => { const res = await axios.post(base + '/api/donations/fixed', { "donor": added_donor.id, "amount": 1000, - "payedAmount": 1000 + "paidAmount": 1000 }, axios_config); delete res.data.id; expect(res.status).toEqual(200); @@ -198,8 +198,8 @@ describe('POST /api/donations/fixed successfully', () => { expect(res.data).toEqual({ "donor": added_donor, "amount": 1000, - "payedAmount": 1000, - "status": "PAYED", + "paidAmount": 1000, + "status": "PAID", "responseType": "DONATION" }); }); @@ -252,8 +252,8 @@ describe('POST /api/donations/distance successfully', () => { "amountPerDistance": 100, "runner": added_runner, "amount": 0, - "payedAmount": 0, - "status": "PAYED", + "paidAmount": 0, + "status": "PAID", "responseType": "DISTANCEDONATION" }) }); @@ -262,7 +262,7 @@ describe('POST /api/donations/distance successfully', () => { "runner": added_runner.id, "amountPerDistance": 100, "donor": added_donor.id, - "payedAmount": 1000 + "paidAmount": 1000 }, axios_config); delete res.data.id; expect(res.status).toEqual(200); @@ -272,8 +272,8 @@ describe('POST /api/donations/distance successfully', () => { "amountPerDistance": 100, "runner": added_runner, "amount": 0, - "payedAmount": 1000, - "status": "PAYED", + "paidAmount": 1000, + "status": "PAID", "responseType": "DISTANCEDONATION" }) }); diff --git a/src/tests/donations/donations_update.spec.ts b/src/tests/donations/donations_update.spec.ts index 6331e19..c7f4fc7 100644 --- a/src/tests/donations/donations_update.spec.ts +++ b/src/tests/donations/donations_update.spec.ts @@ -213,16 +213,16 @@ describe('adding + updating fixed donation valid', () => { expect(res.headers['content-type']).toContain("application/json"); expect(res.data.amount).toEqual(42); }); - it('updating payedAmount should return 200', async () => { + it('updating paidAmount should return 200', async () => { const res = await axios.put(base + '/api/donations/fixed/' + added_donation.id, { "id": added_donation.id, "donor": added_donor.id, "amount": 42, - "payedAmount": 10 + "paidAmount": 10 }, axios_config); expect(res.status).toEqual(200); expect(res.headers['content-type']).toContain("application/json"); - expect(res.data.payedAmount).toEqual(10); + expect(res.data.paidAmount).toEqual(10); }); it('updating donor should return 200', async () => { const res = await axios.put(base + '/api/donations/fixed/' + added_donation.id, { @@ -328,18 +328,18 @@ describe('adding + updating distance donation valid', () => { expect(res.headers['content-type']).toContain("application/json"); expect(res.data.amountPerDistance).toEqual(69); }); - it('updating payedAmount should return 200', async () => { + it('updating paidAmount should return 200', async () => { const res = await axios.put(base + '/api/donations/distance/' + added_donation.id, { "id": added_donation.id, "runner": added_runner.id, "amountPerDistance": 69, "donor": added_donor.id, - "payedAmount": 10 + "paidAmount": 10 }, axios_config); delete res.data.donor.donationAmount; expect(res.status).toEqual(200); expect(res.headers['content-type']).toContain("application/json"); - expect(res.data.payedAmount).toEqual(10); + expect(res.data.paidAmount).toEqual(10); }); it('updating runner should return 200', async () => { const res = await axios.put(base + '/api/donations/distance/' + added_donation.id, {