Fixed spelling
All checks were successful
continuous-integration/drone/pr Build is passing

ref #193
This commit is contained in:
Nicolai Ort 2021-04-14 18:54:02 +02:00
parent 8ae4b85827
commit da266a8dd6
13 changed files with 38 additions and 37 deletions

View File

@ -33,7 +33,7 @@ export class CreateDistanceDonation extends CreateDonation {
let newDonation = new DistanceDonation; let newDonation = new DistanceDonation;
newDonation.amountPerDistance = this.amountPerDistance; newDonation.amountPerDistance = this.amountPerDistance;
newDonation.payedAmount = this.payedAmount; newDonation.paidAmount = this.paidAmount;
newDonation.donor = await this.getDonor(); newDonation.donor = await this.getDonor();
newDonation.runner = await this.getRunner(); newDonation.runner = await this.getRunner();

View File

@ -17,11 +17,11 @@ export abstract class CreateDonation {
donor: number; 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() @IsInt()
@IsOptional() @IsOptional()
payedAmount?: number; paidAmount?: number;
/** /**
* Creates a new Donation entity from this. * Creates a new Donation entity from this.

View File

@ -21,7 +21,7 @@ export class CreateFixedDonation extends CreateDonation {
let newDonation = new FixedDonation; let newDonation = new FixedDonation;
newDonation.amount = this.amount; newDonation.amount = this.amount;
newDonation.payedAmount = this.payedAmount; newDonation.paidAmount = this.paidAmount;
newDonation.donor = await this.getDonor(); newDonation.donor = await this.getDonor();
return newDonation; return newDonation;

View File

@ -32,7 +32,7 @@ export class UpdateDistanceDonation extends UpdateDonation {
*/ */
public async update(donation: DistanceDonation): Promise<DistanceDonation> { public async update(donation: DistanceDonation): Promise<DistanceDonation> {
donation.amountPerDistance = this.amountPerDistance; donation.amountPerDistance = this.amountPerDistance;
donation.payedAmount = this.payedAmount; donation.paidAmount = this.paidAmount;
donation.donor = await this.getDonor(); donation.donor = await this.getDonor();
donation.runner = await this.getRunner(); donation.runner = await this.getRunner();

View File

@ -24,11 +24,11 @@ export abstract class UpdateDonation {
donor: number; 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() @IsInt()
@IsOptional() @IsOptional()
payedAmount?: number; paidAmount?: number;
/** /**
* Creates a new Donation entity from this. * Creates a new Donation entity from this.

View File

@ -20,7 +20,7 @@ export class UpdateFixedDonation extends UpdateDonation {
*/ */
public async update(donation: FixedDonation): Promise<FixedDonation> { public async update(donation: FixedDonation): Promise<FixedDonation> {
donation.amount = this.amount; donation.amount = this.amount;
donation.payedAmount = this.payedAmount; donation.paidAmount = this.paidAmount;
donation.donor = await this.getDonor(); donation.donor = await this.getDonor();
return donation; return donation;

View File

@ -35,12 +35,12 @@ export abstract class Donation {
public abstract get amount(): number; public abstract get amount(): number;
/** /**
* The donation's payed amount in cents (or whatever your currency's smallest unit is.). * The donation's paid amount in cents (or whatever your currency's smallest unit is.).
* Used to mark donations as payed. * Used to mark donations as paid.
*/ */
@Column({ nullable: true }) @Column({ nullable: true })
@IsInt() @IsInt()
payedAmount: number; paidAmount: number;
/** /**
* Turns this entity into it's response class. * Turns this entity into it's response class.

View File

@ -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() @IsInt()
public get payedDonationAmount(): number { public get paidDonationAmount(): number {
if (!this.donations) { return 0; } 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);
} }
/** /**

View File

@ -3,5 +3,5 @@
*/ */
export enum DonationStatus { export enum DonationStatus {
OPEN = 'OPEN', OPEN = 'OPEN',
PAYED = 'PAYED' PAID = 'PAID'
} }

View File

@ -42,10 +42,10 @@ export class ResponseDonation implements IResponse {
amount: number; 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() @IsInt()
payedAmount: number; paidAmount: number;
/** /**
* Creates a ResponseDonation object from a scan. * Creates a ResponseDonation object from a scan.
@ -55,12 +55,12 @@ export class ResponseDonation implements IResponse {
this.id = donation.id; this.id = donation.id;
this.donor = donation.donor.toResponse(); this.donor = donation.donor.toResponse();
this.amount = donation.amount; this.amount = donation.amount;
this.payedAmount = donation.payedAmount || 0; this.paidAmount = donation.paidAmount || 0;
if (this.payedAmount < this.amount) { if (this.paidAmount < this.amount) {
this.status = DonationStatus.OPEN; this.status = DonationStatus.OPEN;
} }
else { else {
this.status = DonationStatus.PAYED; this.status = DonationStatus.PAID;
} }
} }
} }

View File

@ -29,10 +29,10 @@ export class ResponseDonor extends ResponseParticipant implements IResponse {
donationAmount: number; 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() @IsInt()
payedDonationAmount: number; paidDonationAmount: number;
/** /**
* Creates a ResponseRunner object from a runner. * Creates a ResponseRunner object from a runner.
@ -42,5 +42,6 @@ export class ResponseDonor extends ResponseParticipant implements IResponse {
super(donor); super(donor);
this.receiptNeeded = donor.receiptNeeded; this.receiptNeeded = donor.receiptNeeded;
this.donationAmount = donor.donationAmount; this.donationAmount = donor.donationAmount;
this.paidDonationAmount = donor.paidDonationAmount;
} }
} }

View File

@ -181,7 +181,7 @@ describe('POST /api/donations/fixed successfully', () => {
expect(res.data).toEqual({ expect(res.data).toEqual({
"donor": added_donor, "donor": added_donor,
"amount": 1000, "amount": 1000,
"payedAmount": 0, "paidAmount": 0,
"status": "OPEN", "status": "OPEN",
"responseType": "DONATION" "responseType": "DONATION"
}); });
@ -190,7 +190,7 @@ describe('POST /api/donations/fixed successfully', () => {
const res = await axios.post(base + '/api/donations/fixed', { const res = await axios.post(base + '/api/donations/fixed', {
"donor": added_donor.id, "donor": added_donor.id,
"amount": 1000, "amount": 1000,
"payedAmount": 1000 "paidAmount": 1000
}, axios_config); }, axios_config);
delete res.data.id; delete res.data.id;
expect(res.status).toEqual(200); expect(res.status).toEqual(200);
@ -198,8 +198,8 @@ describe('POST /api/donations/fixed successfully', () => {
expect(res.data).toEqual({ expect(res.data).toEqual({
"donor": added_donor, "donor": added_donor,
"amount": 1000, "amount": 1000,
"payedAmount": 1000, "paidAmount": 1000,
"status": "PAYED", "status": "PAID",
"responseType": "DONATION" "responseType": "DONATION"
}); });
}); });
@ -252,8 +252,8 @@ describe('POST /api/donations/distance successfully', () => {
"amountPerDistance": 100, "amountPerDistance": 100,
"runner": added_runner, "runner": added_runner,
"amount": 0, "amount": 0,
"payedAmount": 0, "paidAmount": 0,
"status": "PAYED", "status": "PAID",
"responseType": "DISTANCEDONATION" "responseType": "DISTANCEDONATION"
}) })
}); });
@ -262,7 +262,7 @@ describe('POST /api/donations/distance successfully', () => {
"runner": added_runner.id, "runner": added_runner.id,
"amountPerDistance": 100, "amountPerDistance": 100,
"donor": added_donor.id, "donor": added_donor.id,
"payedAmount": 1000 "paidAmount": 1000
}, axios_config); }, axios_config);
delete res.data.id; delete res.data.id;
expect(res.status).toEqual(200); expect(res.status).toEqual(200);
@ -272,8 +272,8 @@ describe('POST /api/donations/distance successfully', () => {
"amountPerDistance": 100, "amountPerDistance": 100,
"runner": added_runner, "runner": added_runner,
"amount": 0, "amount": 0,
"payedAmount": 1000, "paidAmount": 1000,
"status": "PAYED", "status": "PAID",
"responseType": "DISTANCEDONATION" "responseType": "DISTANCEDONATION"
}) })
}); });

View File

@ -213,16 +213,16 @@ describe('adding + updating fixed donation valid', () => {
expect(res.headers['content-type']).toContain("application/json"); expect(res.headers['content-type']).toContain("application/json");
expect(res.data.amount).toEqual(42); 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, { const res = await axios.put(base + '/api/donations/fixed/' + added_donation.id, {
"id": added_donation.id, "id": added_donation.id,
"donor": added_donor.id, "donor": added_donor.id,
"amount": 42, "amount": 42,
"payedAmount": 10 "paidAmount": 10
}, axios_config); }, axios_config);
expect(res.status).toEqual(200); expect(res.status).toEqual(200);
expect(res.headers['content-type']).toContain("application/json"); 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 () => { it('updating donor should return 200', async () => {
const res = await axios.put(base + '/api/donations/fixed/' + added_donation.id, { 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.headers['content-type']).toContain("application/json");
expect(res.data.amountPerDistance).toEqual(69); 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, { const res = await axios.put(base + '/api/donations/distance/' + added_donation.id, {
"id": added_donation.id, "id": added_donation.id,
"runner": added_runner.id, "runner": added_runner.id,
"amountPerDistance": 69, "amountPerDistance": 69,
"donor": added_donor.id, "donor": added_donor.id,
"payedAmount": 10 "paidAmount": 10
}, axios_config); }, axios_config);
delete res.data.donor.donationAmount; delete res.data.donor.donationAmount;
expect(res.status).toEqual(200); expect(res.status).toEqual(200);
expect(res.headers['content-type']).toContain("application/json"); 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 () => { it('updating runner should return 200', async () => {
const res = await axios.put(base + '/api/donations/distance/' + added_donation.id, { const res = await axios.put(base + '/api/donations/distance/' + added_donation.id, {