parent
becc277123
commit
335d4e24da
@ -23,3 +23,14 @@ export class DonorIdsNotMatchingError extends NotAcceptableError {
|
|||||||
@IsString()
|
@IsString()
|
||||||
message = "The ids don't match! \n And if you wanted to change a donor's id: This isn't allowed!"
|
message = "The ids don't match! \n And if you wanted to change a donor's id: This isn't allowed!"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Error to throw when a donor needs a receipt, but no address is associated with them.
|
||||||
|
*/
|
||||||
|
export class DonorReceiptAddressNeededError extends NotAcceptableError {
|
||||||
|
@IsString()
|
||||||
|
name = "DonorReceiptAddressNeededError"
|
||||||
|
|
||||||
|
@IsString()
|
||||||
|
message = "An address is needed to create a receipt for a donor. \n You didn't provide one."
|
||||||
|
}
|
@ -1,4 +1,5 @@
|
|||||||
import { IsBoolean, IsOptional } from 'class-validator';
|
import { IsBoolean, IsOptional } from 'class-validator';
|
||||||
|
import { DonorReceiptAddressNeededError } from '../../errors/DonorErrors';
|
||||||
import { Donor } from '../entities/Donor';
|
import { Donor } from '../entities/Donor';
|
||||||
import { CreateParticipant } from './CreateParticipant';
|
import { CreateParticipant } from './CreateParticipant';
|
||||||
|
|
||||||
@ -25,8 +26,12 @@ export class CreateDonor extends CreateParticipant {
|
|||||||
newDonor.lastname = this.lastname;
|
newDonor.lastname = this.lastname;
|
||||||
newDonor.phone = this.phone;
|
newDonor.phone = this.phone;
|
||||||
newDonor.email = this.email;
|
newDonor.email = this.email;
|
||||||
newDonor.receiptNeeded = this.receiptNeeded;
|
|
||||||
newDonor.address = await this.getAddress();
|
newDonor.address = await this.getAddress();
|
||||||
|
newDonor.receiptNeeded = this.receiptNeeded;
|
||||||
|
|
||||||
|
if (this.receiptNeeded == true && this.email == "" && this.address == null) {
|
||||||
|
throw new DonorReceiptAddressNeededError()
|
||||||
|
}
|
||||||
|
|
||||||
return newDonor;
|
return newDonor;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user