proflores-db-model 0.1.28 → 0.1.30

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -2,7 +2,7 @@ import { ObjectLiteral } from "typeorm";
2
2
  import { Inventory } from "./Inventory";
3
3
  import { BranchImage } from "./BranchImage";
4
4
  export declare class Branch implements ObjectLiteral {
5
- idBranch: number;
5
+ idBranch?: number;
6
6
  name: string;
7
7
  address: string;
8
8
  phone: string;
@@ -14,6 +14,10 @@ const typeorm_1 = require("typeorm");
14
14
  const Inventory_1 = require("./Inventory");
15
15
  const BranchImage_1 = require("./BranchImage");
16
16
  let Branch = class Branch {
17
+ constructor() {
18
+ this.inventory = [];
19
+ this.images = [];
20
+ }
17
21
  };
18
22
  __decorate([
19
23
  (0, typeorm_1.PrimaryGeneratedColumn)("increment"),
@@ -11,7 +11,7 @@ export declare class Inventory implements ObjectLiteral {
11
11
  quantity: number;
12
12
  wholesalePrice: number;
13
13
  retailPrice: number;
14
- unitOfMeasure: UnitOfMeasure;
15
- branch: Branch;
16
- supplier: Supplier;
14
+ unitOfMeasure?: UnitOfMeasure | null;
15
+ branch?: Branch | null;
16
+ supplier?: Supplier | null;
17
17
  }
@@ -23,7 +23,7 @@ __decorate([
23
23
  __metadata("design:type", Number)
24
24
  ], Inventory.prototype, "idInventory", void 0);
25
25
  __decorate([
26
- (0, typeorm_1.ManyToOne)(() => Products_1.Product),
26
+ (0, typeorm_1.ManyToOne)(() => Products_1.Product, { nullable: false }),
27
27
  (0, typeorm_1.JoinColumn)({ name: "idProduct" }),
28
28
  __metadata("design:type", Products_1.Product)
29
29
  ], Inventory.prototype, "product", void 0);
@@ -33,31 +33,31 @@ __decorate([
33
33
  __metadata("design:type", ContainerType_1.ContainerType)
34
34
  ], Inventory.prototype, "container", void 0);
35
35
  __decorate([
36
- (0, typeorm_1.Column)("decimal", { nullable: false }),
36
+ (0, typeorm_1.Column)("decimal", { nullable: false, default: 0 }),
37
37
  __metadata("design:type", Number)
38
38
  ], Inventory.prototype, "quantity", void 0);
39
39
  __decorate([
40
- (0, typeorm_1.Column)("decimal", { nullable: false }),
40
+ (0, typeorm_1.Column)("decimal", { nullable: false, default: 0 }),
41
41
  __metadata("design:type", Number)
42
42
  ], Inventory.prototype, "wholesalePrice", void 0);
43
43
  __decorate([
44
- (0, typeorm_1.Column)("decimal", { nullable: false }),
44
+ (0, typeorm_1.Column)("decimal", { nullable: false, default: 0 }),
45
45
  __metadata("design:type", Number)
46
46
  ], Inventory.prototype, "retailPrice", void 0);
47
47
  __decorate([
48
- (0, typeorm_1.ManyToOne)(() => UnitOfMesure_1.UnitOfMeasure),
48
+ (0, typeorm_1.ManyToOne)(() => UnitOfMesure_1.UnitOfMeasure, { nullable: true }),
49
49
  (0, typeorm_1.JoinColumn)({ name: "idUnitOfMeasure" }),
50
- __metadata("design:type", UnitOfMesure_1.UnitOfMeasure)
50
+ __metadata("design:type", Object)
51
51
  ], Inventory.prototype, "unitOfMeasure", void 0);
52
52
  __decorate([
53
- (0, typeorm_1.ManyToOne)(() => Branches_1.Branch),
53
+ (0, typeorm_1.ManyToOne)(() => Branches_1.Branch, { nullable: true }),
54
54
  (0, typeorm_1.JoinColumn)({ name: "idBranch" }),
55
- __metadata("design:type", Branches_1.Branch)
55
+ __metadata("design:type", Object)
56
56
  ], Inventory.prototype, "branch", void 0);
57
57
  __decorate([
58
- (0, typeorm_1.ManyToOne)(() => Suppliers_1.Supplier),
58
+ (0, typeorm_1.ManyToOne)(() => Suppliers_1.Supplier, { nullable: true }),
59
59
  (0, typeorm_1.JoinColumn)({ name: "idSupplier" }),
60
- __metadata("design:type", Suppliers_1.Supplier)
60
+ __metadata("design:type", Object)
61
61
  ], Inventory.prototype, "supplier", void 0);
62
62
  Inventory = __decorate([
63
63
  (0, typeorm_1.Entity)("inventory")
@@ -1,6 +1,6 @@
1
1
  import { Product } from "./Products";
2
2
  export declare class ProductImage {
3
- idProductImage: number;
3
+ idProductImage?: number;
4
4
  imageUrl: string;
5
- product: Product;
5
+ product?: Product | null;
6
6
  }
@@ -23,9 +23,12 @@ __decorate([
23
23
  __metadata("design:type", String)
24
24
  ], ProductImage.prototype, "imageUrl", void 0);
25
25
  __decorate([
26
- (0, typeorm_1.ManyToOne)(() => Products_1.Product, (products) => products.images, { onDelete: "CASCADE" }),
26
+ (0, typeorm_1.ManyToOne)(() => Products_1.Product, (product) => product.images, {
27
+ onDelete: "CASCADE",
28
+ nullable: true
29
+ }),
27
30
  (0, typeorm_1.JoinColumn)({ name: "productId" }),
28
- __metadata("design:type", Products_1.Product)
31
+ __metadata("design:type", Object)
29
32
  ], ProductImage.prototype, "product", void 0);
30
33
  ProductImage = __decorate([
31
34
  (0, typeorm_1.Entity)("product_images")
@@ -3,11 +3,11 @@ import { CategoryForPlantType } from "./CategoryForPlantType";
3
3
  import { ProductImage } from "./ProductImage";
4
4
  import { Inventory } from "./Inventory";
5
5
  export declare class Product implements ObjectLiteral {
6
- idProduct: number;
6
+ idProduct?: number;
7
7
  name: string;
8
8
  secondaryName: string;
9
9
  description: string;
10
- categoryForPlantType: CategoryForPlantType;
10
+ categoryForPlantType?: CategoryForPlantType | null;
11
11
  images: ProductImage[];
12
12
  inventories: Inventory[];
13
13
  isActive: boolean;
@@ -15,6 +15,10 @@ const CategoryForPlantType_1 = require("./CategoryForPlantType");
15
15
  const ProductImage_1 = require("./ProductImage");
16
16
  const Inventory_1 = require("./Inventory");
17
17
  let Product = class Product {
18
+ constructor() {
19
+ this.images = [];
20
+ this.inventories = [];
21
+ }
18
22
  };
19
23
  __decorate([
20
24
  (0, typeorm_1.PrimaryGeneratedColumn)("increment"),
@@ -33,9 +37,9 @@ __decorate([
33
37
  __metadata("design:type", String)
34
38
  ], Product.prototype, "description", void 0);
35
39
  __decorate([
36
- (0, typeorm_1.ManyToOne)(() => CategoryForPlantType_1.CategoryForPlantType),
40
+ (0, typeorm_1.ManyToOne)(() => CategoryForPlantType_1.CategoryForPlantType, { nullable: true }),
37
41
  (0, typeorm_1.JoinColumn)({ name: "categoryForPlantTypeId" }),
38
- __metadata("design:type", CategoryForPlantType_1.CategoryForPlantType)
42
+ __metadata("design:type", Object)
39
43
  ], Product.prototype, "categoryForPlantType", void 0);
40
44
  __decorate([
41
45
  (0, typeorm_1.OneToMany)(() => ProductImage_1.ProductImage, (productImage) => productImage.product, {
@@ -1,6 +1,6 @@
1
1
  import { Supplier } from "./Suppliers";
2
2
  export declare class SupplierImage {
3
- idSupplierImage: number;
3
+ idSupplierImage?: number;
4
4
  imageUrl: string;
5
- supplier: Supplier;
5
+ supplier?: Supplier | null;
6
6
  }
@@ -23,11 +23,12 @@ __decorate([
23
23
  __metadata("design:type", String)
24
24
  ], SupplierImage.prototype, "imageUrl", void 0);
25
25
  __decorate([
26
- (0, typeorm_1.ManyToOne)(() => Suppliers_1.Supplier, (suppliers) => suppliers.images, {
26
+ (0, typeorm_1.ManyToOne)(() => Suppliers_1.Supplier, (supplier) => supplier.images, {
27
27
  onDelete: "CASCADE",
28
+ nullable: true,
28
29
  }),
29
30
  (0, typeorm_1.JoinColumn)({ name: "supplierId" }),
30
- __metadata("design:type", Suppliers_1.Supplier)
31
+ __metadata("design:type", Object)
31
32
  ], SupplierImage.prototype, "supplier", void 0);
32
33
  SupplierImage = __decorate([
33
34
  (0, typeorm_1.Entity)("supplier_images")
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "proflores-db-model",
3
- "version": "0.1.28",
3
+ "version": "0.1.30",
4
4
  "description": "Data model for managing expenses and transactions for Proflores nursery business",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -1,10 +1,11 @@
1
1
  import { Entity, PrimaryGeneratedColumn, Column, ObjectLiteral, OneToMany } from "typeorm";
2
2
  import { Inventory } from "./Inventory";
3
3
  import { BranchImage } from "./BranchImage";
4
+
4
5
  @Entity("branches")
5
6
  export class Branch implements ObjectLiteral {
6
7
  @PrimaryGeneratedColumn("increment")
7
- idBranch!: number;
8
+ idBranch?: number;
8
9
 
9
10
  @Column("varchar", { nullable: false, length: 255 })
10
11
  name!: string;
@@ -22,11 +23,10 @@ export class Branch implements ObjectLiteral {
22
23
  city!: string;
23
24
 
24
25
  @OneToMany(() => Inventory, (inventory) => inventory.branch)
25
- inventory!: Inventory[];
26
+ inventory: Inventory[] = [];
26
27
 
27
28
  @OneToMany(() => BranchImage, (branchImage) => branchImage.branch, {
28
29
  cascade: true,
29
30
  })
30
- images!: BranchImage[];
31
-
32
- }
31
+ images: BranchImage[] = [];
32
+ }
@@ -1,43 +1,44 @@
1
- import { Entity, PrimaryGeneratedColumn, Column, ObjectLiteral, ManyToOne, JoinColumn } from "typeorm";
2
- import { Product } from "./Products";
3
- import { UnitOfMeasure } from "./UnitOfMesure";
4
- import { Branch } from "./Branches";
5
- import { ContainerType } from "./ContainerType";
6
- import { Supplier } from "./Suppliers";
7
-
8
- @Entity("inventory")
9
- export class Inventory implements ObjectLiteral {
10
- @PrimaryGeneratedColumn("increment")
11
- idInventory!: number;
12
-
13
- @ManyToOne(() => Product)
14
- @JoinColumn({ name: "idProduct" })
15
- product!: Product;
16
-
17
- @ManyToOne(() => ContainerType, { nullable: false })
18
- @JoinColumn({ name: "containerId" })
19
- container!: ContainerType;
20
-
21
- @Column("decimal", { nullable: false })
22
- quantity!: number;
23
-
24
- @Column("decimal", { nullable: false })
25
- wholesalePrice!: number;
26
-
27
- @Column("decimal", { nullable: false })
28
- retailPrice!: number;
29
-
30
- @ManyToOne(() => UnitOfMeasure)
31
- @JoinColumn({ name: "idUnitOfMeasure" })
32
- unitOfMeasure!: UnitOfMeasure;
33
-
34
- @ManyToOne(() => Branch)
35
- @JoinColumn({ name: "idBranch" })
36
- branch!: Branch;
37
-
38
- @ManyToOne(() => Supplier)
39
- @JoinColumn({ name: "idSupplier" })
40
- supplier!: Supplier;
41
-
42
-
43
- }
1
+ import {
2
+ Entity, PrimaryGeneratedColumn, Column, ObjectLiteral, ManyToOne, JoinColumn
3
+ } from "typeorm";
4
+ import { Product } from "./Products";
5
+ import { UnitOfMeasure } from "./UnitOfMesure";
6
+ import { Branch } from "./Branches";
7
+ import { ContainerType } from "./ContainerType";
8
+ import { Supplier } from "./Suppliers";
9
+
10
+ @Entity("inventory")
11
+ export class Inventory implements ObjectLiteral {
12
+ @PrimaryGeneratedColumn("increment")
13
+ idInventory!: number;
14
+
15
+ @ManyToOne(() => Product, { nullable: false })
16
+ @JoinColumn({ name: "idProduct" })
17
+ product!: Product;
18
+
19
+ @ManyToOne(() => ContainerType, { nullable: false })
20
+ @JoinColumn({ name: "containerId" })
21
+ container!: ContainerType;
22
+
23
+ @Column("decimal", { nullable: false, default: 0 })
24
+ quantity!: number;
25
+
26
+ @Column("decimal", { nullable: false, default: 0 })
27
+ wholesalePrice!: number;
28
+
29
+ @Column("decimal", { nullable: false, default: 0 })
30
+ retailPrice!: number;
31
+
32
+ @ManyToOne(() => UnitOfMeasure, { nullable: true })
33
+ @JoinColumn({ name: "idUnitOfMeasure" })
34
+ unitOfMeasure?: UnitOfMeasure | null;
35
+
36
+ @ManyToOne(() => Branch, { nullable: true })
37
+ @JoinColumn({ name: "idBranch" })
38
+ branch?: Branch | null;
39
+
40
+ @ManyToOne(() => Supplier, { nullable: true })
41
+ @JoinColumn({ name: "idSupplier" })
42
+ supplier?: Supplier | null;
43
+ }
44
+
@@ -6,13 +6,16 @@ import {
6
6
  @Entity("product_images")
7
7
  export class ProductImage {
8
8
  @PrimaryGeneratedColumn("increment")
9
- idProductImage!: number;
9
+ idProductImage?: number;
10
10
 
11
11
  @Column("varchar", { nullable: false, length: 500 })
12
12
  imageUrl!: string;
13
13
 
14
- @ManyToOne(() => Product, (products) => products.images, { onDelete: "CASCADE" })
14
+ @ManyToOne(() => Product, (product) => product.images, {
15
+ onDelete: "CASCADE",
16
+ nullable: true
17
+ })
15
18
  @JoinColumn({ name: "productId" })
16
- product!: Product;
19
+ product?: Product | null;
17
20
  }
18
21
 
@@ -1,43 +1,43 @@
1
1
  import {
2
- Entity,
3
- PrimaryGeneratedColumn,
4
- Column,
5
- ObjectLiteral,
6
- ManyToOne,
7
- JoinColumn,
8
- OneToMany,
9
- } from "typeorm";
10
- import { CategoryForPlantType } from "./CategoryForPlantType";
11
- import { ProductImage } from "./ProductImage";
12
- import { Inventory } from "./Inventory";
13
-
14
-
15
- @Entity("products")
16
- export class Product implements ObjectLiteral {
17
- @PrimaryGeneratedColumn("increment")
18
- idProduct!: number;
19
-
20
- @Column("varchar", { nullable: false, length: 255 })
21
- name!: string;
22
-
23
- @Column("varchar", { nullable: false, length: 255 })
24
- secondaryName!: string;
25
-
26
- @Column("text", { nullable: false })
27
- description!: string;
28
-
29
- @ManyToOne(() => CategoryForPlantType)
30
- @JoinColumn({ name: "categoryForPlantTypeId" })
31
- categoryForPlantType!: CategoryForPlantType;
32
-
33
- @OneToMany(() => ProductImage, (productImage) => productImage.product, {
34
- cascade: true,
35
- })
36
- images!: ProductImage[];
37
-
38
- @OneToMany(() => Inventory, (inventory) => inventory.product)
39
- inventories!: Inventory[];
40
-
41
- @Column("boolean", { default: true })
42
- isActive!: boolean;
43
- }
2
+ Entity,
3
+ PrimaryGeneratedColumn,
4
+ Column,
5
+ ObjectLiteral,
6
+ ManyToOne,
7
+ JoinColumn,
8
+ OneToMany,
9
+ } from "typeorm";
10
+ import { CategoryForPlantType } from "./CategoryForPlantType";
11
+ import { ProductImage } from "./ProductImage";
12
+ import { Inventory } from "./Inventory";
13
+
14
+ @Entity("products")
15
+ export class Product implements ObjectLiteral {
16
+ @PrimaryGeneratedColumn("increment")
17
+ idProduct?: number;
18
+
19
+ @Column("varchar", { nullable: false, length: 255 })
20
+ name!: string;
21
+
22
+ @Column("varchar", { nullable: false, length: 255 })
23
+ secondaryName!: string;
24
+
25
+ @Column("text", { nullable: false })
26
+ description!: string;
27
+
28
+ @ManyToOne(() => CategoryForPlantType, { nullable: true })
29
+ @JoinColumn({ name: "categoryForPlantTypeId" })
30
+ categoryForPlantType?: CategoryForPlantType | null;
31
+
32
+ @OneToMany(() => ProductImage, (productImage) => productImage.product, {
33
+ cascade: true,
34
+ })
35
+ images: ProductImage[] = [];
36
+
37
+ @OneToMany(() => Inventory, (inventory) => inventory.product)
38
+ inventories: Inventory[] = [];
39
+
40
+ @Column("boolean", { default: true })
41
+ isActive!: boolean;
42
+ }
43
+
@@ -3,15 +3,16 @@ import { Supplier } from "./Suppliers";
3
3
 
4
4
  @Entity("supplier_images")
5
5
  export class SupplierImage {
6
- @PrimaryGeneratedColumn("increment")
7
- idSupplierImage!: number;
6
+ @PrimaryGeneratedColumn("increment")
7
+ idSupplierImage?: number;
8
8
 
9
- @Column("varchar", { nullable: false, length: 500 })
10
- imageUrl!: string;
9
+ @Column("varchar", { nullable: false, length: 500 })
10
+ imageUrl!: string;
11
11
 
12
- @ManyToOne(() => Supplier, (suppliers) => suppliers.images, {
13
- onDelete: "CASCADE",
14
- })
15
- @JoinColumn({ name: "supplierId" })
16
- supplier!: Supplier;
17
- }
12
+ @ManyToOne(() => Supplier, (supplier) => supplier.images, {
13
+ onDelete: "CASCADE",
14
+ nullable: true,
15
+ })
16
+ @JoinColumn({ name: "supplierId" })
17
+ supplier?: Supplier | null;
18
+ }