File size: 1,205 Bytes
7b1861f
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
import {
  BaseEntity,
  Column,
  CreateDateColumn,
  Entity,
  JoinColumn,
  ManyToOne,
  PrimaryGeneratedColumn,
  Relation,
} from 'typeorm';
import { BranchEntity } from './branch.entity.js';
import { UserEntity } from './user.entity.js';

@Entity('receipts')
export class ReceiptEntity extends BaseEntity {
  @PrimaryGeneratedColumn()
  id: number;

  @Column()
  branch_id: string;

  @ManyToOne(() => BranchEntity, (a) => a.receipts)
  @JoinColumn({ name: 'branch_id' })
  branch: Relation<BranchEntity>;

  @Column({ default: 0 })
  income: number;

  @Column({ default: 0 })
  spend: number;

  @Column({ nullable: true })
  description: string;

  @Column({ default: 0 })
  type: number;

  @Column({ default: 0 })
  sub_type: number;

  @Column({ nullable: true })
  sender_id: string;

  @Column({ nullable: true })
  receiver_id: string;

  @ManyToOne(() => UserEntity, (a) => a.out_receipts)
  @JoinColumn({ name: 'sender_id' })
  sender: Relation<UserEntity>;

  @ManyToOne(() => UserEntity, (a) => a.in_receipts)
  @JoinColumn({ name: 'receiver_id' })
  receiver: Relation<UserEntity>;

  @CreateDateColumn()
  created_at: Date;
}