supplier-stock.entity.ts 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. import {
  2. DeepPartial,
  3. ID,
  4. Product,
  5. ProductVariant,
  6. VendureEntity,
  7. } from '@vendure/core';
  8. import { Column, Entity, OneToMany, ManyToOne } from 'typeorm';
  9. import { SupplierStockInTransit } from './supplier-stock-in-transit.entity';
  10. /**
  11. * @description This entity represents a supplier virtual stock
  12. *
  13. * @docsCategory entities
  14. */
  15. @Entity('supplier_stock')
  16. export class SupplierStock extends VendureEntity {
  17. constructor(input?: DeepPartial<SupplierStock>) {
  18. super(input);
  19. }
  20. @Column({ default: 0 })
  21. stockOnHand: number;
  22. @Column({ default: 0 })
  23. virtualStock: number;
  24. @Column({ default: 0 })
  25. inTransitsStock: number;
  26. @Column({ nullable: true })
  27. stockArea: string;
  28. @OneToMany(() => SupplierStockInTransit, (type) => type.supplierStock)
  29. stocksInTransits: SupplierStockInTransit[];
  30. @Column({ default: true })
  31. enabled: boolean;
  32. @Column({ nullable: true })
  33. link?: string;
  34. @Column({ nullable: true, type: 'simple-json' })
  35. tags?: string[];
  36. @Column({ type: 'tinytext', nullable: true })
  37. comment?: string;
  38. @ManyToOne(() => ProductVariant, { onDelete: 'CASCADE' })
  39. productVariant: ProductVariant;
  40. @Column('int')
  41. productVariantId: ID;
  42. @ManyToOne(() => Product, { onDelete: 'CASCADE' })
  43. product: Product;
  44. @Column('int', { nullable: true })
  45. productId: ID;
  46. }