parent
02bb634257
commit
6c53701a59
@ -43,7 +43,7 @@ export class DistanceDonation extends Donation {
|
|||||||
/**
|
/**
|
||||||
* Turns this entity into it's response class.
|
* Turns this entity into it's response class.
|
||||||
*/
|
*/
|
||||||
public toResponse() {
|
public toResponse(): DistanceDonation {
|
||||||
return new Error("NotImplemented");
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -3,6 +3,7 @@ import {
|
|||||||
IsNotEmpty
|
IsNotEmpty
|
||||||
} from "class-validator";
|
} from "class-validator";
|
||||||
import { Entity, ManyToOne, PrimaryGeneratedColumn, TableInheritance } from "typeorm";
|
import { Entity, ManyToOne, PrimaryGeneratedColumn, TableInheritance } from "typeorm";
|
||||||
|
import { ResponseDonation } from '../responses/ResponseDonation';
|
||||||
import { Donor } from './Donor';
|
import { Donor } from './Donor';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -31,12 +32,13 @@ export abstract class Donation {
|
|||||||
* The donation's amount in cents (or whatever your currency's smallest unit is.).
|
* The donation's amount in cents (or whatever your currency's smallest unit is.).
|
||||||
* The exact implementation may differ for each type of donation.
|
* The exact implementation may differ for each type of donation.
|
||||||
*/
|
*/
|
||||||
abstract amount: number;
|
public abstract get amount(): number;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Turns this entity into it's response class.
|
* Turns this entity into it's response class.
|
||||||
*/
|
*/
|
||||||
public toResponse() {
|
public toResponse(): ResponseDonation {
|
||||||
return new Error("NotImplemented");
|
return new ResponseDonation(this);
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -1,5 +1,6 @@
|
|||||||
import { IsInt, IsPositive } from "class-validator";
|
import { IsInt, IsPositive } from "class-validator";
|
||||||
import { ChildEntity, Column } from "typeorm";
|
import { ChildEntity, Column } from "typeorm";
|
||||||
|
import { ResponseDonation } from '../responses/ResponseDonation';
|
||||||
import { Donation } from "./Donation";
|
import { Donation } from "./Donation";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -11,16 +12,33 @@ export class FixedDonation extends Donation {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* The donation's amount in cents (or whatever your currency's smallest unit is.).
|
* The donation's amount in cents (or whatever your currency's smallest unit is.).
|
||||||
|
* This is the "real" value used by fixed donations.
|
||||||
*/
|
*/
|
||||||
@Column()
|
@Column()
|
||||||
@IsInt()
|
@IsInt()
|
||||||
@IsPositive()
|
@IsPositive()
|
||||||
amount: number;
|
private _amount: number;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The donation's amount in cents (or whatever your currency's smallest unit is.).
|
||||||
|
*/
|
||||||
|
@IsInt()
|
||||||
|
@IsPositive()
|
||||||
|
public get amount(): number {
|
||||||
|
return this._amount;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The donation's amount in cents (or whatever your currency's smallest unit is.).
|
||||||
|
*/
|
||||||
|
public set amount(value: number) {
|
||||||
|
this._amount = value;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Turns this entity into it's response class.
|
* Turns this entity into it's response class.
|
||||||
*/
|
*/
|
||||||
public toResponse() {
|
public toResponse(): ResponseDonation {
|
||||||
return new Error("NotImplemented");
|
return new ResponseDonation(this);
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -3,9 +3,9 @@ import { Donation } from '../entities/Donation';
|
|||||||
import { ResponseDonor } from './ResponseDonor';
|
import { ResponseDonor } from './ResponseDonor';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Defines the donation response interface.
|
* Defines the donation response.
|
||||||
*/
|
*/
|
||||||
export abstract class IResponseDonation {
|
export class ResponseDonation {
|
||||||
/**
|
/**
|
||||||
* The donation's id.
|
* The donation's id.
|
||||||
*/
|
*/
|
||||||
@ -26,7 +26,7 @@ export abstract class IResponseDonation {
|
|||||||
amount: number;
|
amount: number;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a IResponseDonation object from a scan.
|
* Creates a ResponseDonation object from a scan.
|
||||||
* @param donation The donation the response shall be build for.
|
* @param donation The donation the response shall be build for.
|
||||||
*/
|
*/
|
||||||
public constructor(donation: Donation) {
|
public constructor(donation: Donation) {
|
Loading…
x
Reference in New Issue
Block a user