57 lines
1.4 KiB
TypeScript
57 lines
1.4 KiB
TypeScript
import {Entity, Column, PrimaryGeneratedColumn, ManyToOne, CreateDateColumn} from "typeorm"
|
|
import { PaymentPlanTemplate, defaultPaymentPlanTemplate } from "./paymentplantemplate.entity"
|
|
import { Application } from "./application.entity"
|
|
import { HttpException } from "../HttpError"
|
|
|
|
|
|
|
|
|
|
@Entity()
|
|
export class PaymentPlan{
|
|
|
|
@PrimaryGeneratedColumn("uuid")
|
|
id!: string
|
|
|
|
@CreateDateColumn()
|
|
startDate!:Date
|
|
|
|
@Column({nullable: true})
|
|
endDate?:Date
|
|
|
|
@Column()
|
|
customMaximum?:number
|
|
|
|
@ManyToOne(()=>PaymentPlanTemplate, {eager: true})
|
|
template!:PaymentPlanTemplate;
|
|
|
|
@ManyToOne(()=>Application, (app)=>app.paymentPlan)
|
|
application!:Promise<Application>
|
|
|
|
@Column({default:0})
|
|
countedVolume!:number
|
|
|
|
@Column({default:false})
|
|
paymentReceived!:boolean
|
|
|
|
}
|
|
|
|
export interface NewPaymentPlanBody{
|
|
customMaximum?:number,
|
|
templateName: string,
|
|
closeOpenPlans: boolean
|
|
}
|
|
export function isPaymentPlan(instance: any): instance is PaymentPlan{
|
|
return true
|
|
}
|
|
export function isNewPaymentPlanBody(instance: any): instance is NewPaymentPlanBody{
|
|
if("customMaximum" in instance && typeof instance.customMaximum != "number"){
|
|
return false
|
|
}
|
|
if(typeof instance.templateName != "string"){
|
|
return false
|
|
}
|
|
if(typeof instance.closeOpenPlans != "boolean"){
|
|
return false
|
|
}
|
|
return true;
|
|
} |