proflores-db-model 0.2.52 → 0.2.54
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.
- package/dist/entities/ExpenseDetail.d.ts +6 -0
- package/dist/entities/ExpenseDetail.js +19 -1
- package/dist/entities/ExpenseTransaction.d.ts +2 -0
- package/dist/entities/ExpenseTransaction.js +11 -1
- package/dist/entities/Income.d.ts +29 -0
- package/dist/entities/Income.js +121 -0
- package/dist/entities/InventoryMovement.d.ts +2 -0
- package/dist/entities/InventoryMovement.js +7 -0
- package/dist/entities/index.d.ts +24 -0
- package/dist/entities/index.js +60 -0
- package/dist/index.d.ts +2 -23
- package/dist/index.js +5 -47
- package/dist/models/apu/Budget.d.ts +4 -0
- package/dist/models/apu/Budget.js +10 -0
- package/dist/models/production/CropActivity.d.ts +20 -0
- package/dist/models/production/CropActivity.js +85 -0
- package/dist/models/production/CropExpense.d.ts +22 -0
- package/dist/models/production/CropExpense.js +93 -0
- package/dist/models/production/CropLot.d.ts +33 -0
- package/dist/models/production/CropLot.js +132 -0
- package/dist/models/production/CropStage.d.ts +13 -0
- package/dist/models/production/CropStage.js +58 -0
- package/dist/models/production/CropStageImage.d.ts +9 -0
- package/dist/models/production/CropStageImage.js +44 -0
- package/dist/models/production/GrowthArea.d.ts +13 -0
- package/dist/models/production/GrowthArea.js +55 -0
- package/dist/models/production/Harvest.d.ts +16 -0
- package/dist/models/production/Harvest.js +70 -0
- package/dist/models/production/ProductionSeason.d.ts +11 -0
- package/dist/models/production/ProductionSeason.js +49 -0
- package/dist/models/production/index.d.ts +8 -0
- package/dist/models/production/index.js +20 -0
- package/dist/types/CropActivityType.d.ts +12 -0
- package/dist/types/CropActivityType.js +16 -0
- package/dist/types/CropLotStatus.d.ts +10 -0
- package/dist/types/CropLotStatus.js +14 -0
- package/dist/types/GrowthStage.d.ts +10 -0
- package/dist/types/GrowthStage.js +14 -0
- package/dist/types/IncomeStatus.d.ts +5 -0
- package/dist/types/IncomeStatus.js +9 -0
- package/dist/types/IncomeType.d.ts +6 -0
- package/dist/types/IncomeType.js +10 -0
- package/dist/types/MovementType.d.ts +2 -1
- package/dist/types/MovementType.js +1 -0
- package/dist/types/QualityGrade.d.ts +6 -0
- package/dist/types/QualityGrade.js +10 -0
- package/dist/types/index.d.ts +6 -0
- package/dist/types/index.js +15 -1
- package/package.json +1 -1
- package/src/entities/ExpenseDetail.ts +16 -1
- package/src/entities/ExpenseTransaction.ts +12 -2
- package/src/entities/Income.ts +99 -0
- package/src/entities/InventoryMovement.ts +7 -1
- package/src/entities/index.ts +41 -0
- package/src/index.ts +6 -23
- package/src/models/apu/Budget.ts +8 -0
- package/src/models/production/CropActivity.ts +68 -0
- package/src/models/production/CropExpense.ts +74 -0
- package/src/models/production/CropLot.ts +106 -0
- package/src/models/production/CropStage.ts +45 -0
- package/src/models/production/CropStageImage.ts +32 -0
- package/src/models/production/GrowthArea.ts +41 -0
- package/src/models/production/Harvest.ts +56 -0
- package/src/models/production/ProductionSeason.ts +34 -0
- package/src/models/production/index.ts +9 -0
- package/src/types/CropActivityType.ts +12 -0
- package/src/types/CropLotStatus.ts +10 -0
- package/src/types/GrowthStage.ts +10 -0
- package/src/types/IncomeStatus.ts +5 -0
- package/src/types/IncomeType.ts +6 -0
- package/src/types/MovementType.ts +5 -4
- package/src/types/QualityGrade.ts +6 -0
- package/src/types/index.ts +11 -1
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
import {
|
|
2
|
+
Entity,
|
|
3
|
+
PrimaryGeneratedColumn,
|
|
4
|
+
Column,
|
|
5
|
+
ManyToOne,
|
|
6
|
+
OneToMany,
|
|
7
|
+
JoinColumn,
|
|
8
|
+
ObjectLiteral,
|
|
9
|
+
Index,
|
|
10
|
+
CreateDateColumn,
|
|
11
|
+
UpdateDateColumn,
|
|
12
|
+
} from "typeorm";
|
|
13
|
+
import { GrowthArea } from "./GrowthArea";
|
|
14
|
+
import { ProductionSeason } from "./ProductionSeason";
|
|
15
|
+
import { PlantTechnicalSheet } from "../technical-sheet/PlantTechnicalSheet";
|
|
16
|
+
import { CropLotStatus } from "../../types/CropLotStatus";
|
|
17
|
+
import { CropStage } from "./CropStage";
|
|
18
|
+
import { CropActivity } from "./CropActivity";
|
|
19
|
+
import { CropExpense } from "./CropExpense";
|
|
20
|
+
import { Harvest } from "./Harvest";
|
|
21
|
+
|
|
22
|
+
@Entity("crop_lots")
|
|
23
|
+
@Index(["code"], { unique: true })
|
|
24
|
+
@Index(["growthArea"])
|
|
25
|
+
@Index(["season"])
|
|
26
|
+
@Index(["status"])
|
|
27
|
+
export class CropLot implements ObjectLiteral {
|
|
28
|
+
@PrimaryGeneratedColumn("increment")
|
|
29
|
+
idCropLot!: number;
|
|
30
|
+
|
|
31
|
+
@Column("varchar", { length: 64, nullable: false, unique: true })
|
|
32
|
+
code!: string;
|
|
33
|
+
|
|
34
|
+
@Column("varchar", { length: 255, nullable: false })
|
|
35
|
+
name!: string;
|
|
36
|
+
|
|
37
|
+
@ManyToOne(() => GrowthArea, (area) => area.cropLots, {
|
|
38
|
+
nullable: false,
|
|
39
|
+
onDelete: "RESTRICT",
|
|
40
|
+
})
|
|
41
|
+
@JoinColumn({ name: "idGrowthArea" })
|
|
42
|
+
growthArea!: GrowthArea;
|
|
43
|
+
|
|
44
|
+
@ManyToOne(() => ProductionSeason, (season) => season.cropLots, {
|
|
45
|
+
nullable: false,
|
|
46
|
+
onDelete: "RESTRICT",
|
|
47
|
+
})
|
|
48
|
+
@JoinColumn({ name: "idSeason" })
|
|
49
|
+
season!: ProductionSeason;
|
|
50
|
+
|
|
51
|
+
@ManyToOne(() => PlantTechnicalSheet, { nullable: true, onDelete: "SET NULL" })
|
|
52
|
+
@JoinColumn({ name: "idPlantTechnicalSheet" })
|
|
53
|
+
plantTechnicalSheet?: PlantTechnicalSheet | null;
|
|
54
|
+
|
|
55
|
+
@Column("decimal", { precision: 12, scale: 2, nullable: false, default: 0 })
|
|
56
|
+
quantity!: number;
|
|
57
|
+
|
|
58
|
+
@Column("decimal", { precision: 12, scale: 2, nullable: true })
|
|
59
|
+
expectedYield?: number | null;
|
|
60
|
+
|
|
61
|
+
@Column("decimal", { precision: 12, scale: 2, nullable: true })
|
|
62
|
+
actualYield?: number | null;
|
|
63
|
+
|
|
64
|
+
@Column("decimal", { precision: 14, scale: 4, nullable: true })
|
|
65
|
+
unitCost?: number | null;
|
|
66
|
+
|
|
67
|
+
@Column("decimal", { precision: 14, scale: 2, nullable: true })
|
|
68
|
+
totalCost?: number | null;
|
|
69
|
+
|
|
70
|
+
@Column({
|
|
71
|
+
type: "enum",
|
|
72
|
+
enum: CropLotStatus,
|
|
73
|
+
default: CropLotStatus.PLANNED,
|
|
74
|
+
})
|
|
75
|
+
status!: CropLotStatus;
|
|
76
|
+
|
|
77
|
+
@Column("date", { nullable: false })
|
|
78
|
+
sowingDate!: Date;
|
|
79
|
+
|
|
80
|
+
@Column("date", { nullable: true })
|
|
81
|
+
expectedHarvestDate?: Date | null;
|
|
82
|
+
|
|
83
|
+
@Column("date", { nullable: true })
|
|
84
|
+
actualHarvestDate?: Date | null;
|
|
85
|
+
|
|
86
|
+
@Column("text", { nullable: true })
|
|
87
|
+
notes?: string | null;
|
|
88
|
+
|
|
89
|
+
@CreateDateColumn({ type: "timestamp" })
|
|
90
|
+
createdAt!: Date;
|
|
91
|
+
|
|
92
|
+
@UpdateDateColumn({ type: "timestamp" })
|
|
93
|
+
updatedAt!: Date;
|
|
94
|
+
|
|
95
|
+
@OneToMany(() => CropStage, (stage) => stage.cropLot, { cascade: true })
|
|
96
|
+
stages?: CropStage[];
|
|
97
|
+
|
|
98
|
+
@OneToMany(() => CropActivity, (activity) => activity.cropLot, { cascade: true })
|
|
99
|
+
activities?: CropActivity[];
|
|
100
|
+
|
|
101
|
+
@OneToMany(() => CropExpense, (expense) => expense.cropLot, { cascade: true })
|
|
102
|
+
expenses?: CropExpense[];
|
|
103
|
+
|
|
104
|
+
@OneToMany(() => Harvest, (harvest) => harvest.cropLot, { cascade: true })
|
|
105
|
+
harvests?: Harvest[];
|
|
106
|
+
}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import {
|
|
2
|
+
Entity,
|
|
3
|
+
PrimaryGeneratedColumn,
|
|
4
|
+
Column,
|
|
5
|
+
ManyToOne,
|
|
6
|
+
OneToMany,
|
|
7
|
+
JoinColumn,
|
|
8
|
+
ObjectLiteral,
|
|
9
|
+
Index,
|
|
10
|
+
} from "typeorm";
|
|
11
|
+
import { CropLot } from "./CropLot";
|
|
12
|
+
import { GrowthStage } from "../../types/GrowthStage";
|
|
13
|
+
import { CropStageImage } from "./CropStageImage";
|
|
14
|
+
|
|
15
|
+
@Entity("crop_stages")
|
|
16
|
+
@Index(["cropLot", "stage"])
|
|
17
|
+
export class CropStage implements ObjectLiteral {
|
|
18
|
+
@PrimaryGeneratedColumn("increment")
|
|
19
|
+
idCropStage!: number;
|
|
20
|
+
|
|
21
|
+
@ManyToOne(() => CropLot, (cropLot) => cropLot.stages, {
|
|
22
|
+
nullable: false,
|
|
23
|
+
onDelete: "CASCADE",
|
|
24
|
+
})
|
|
25
|
+
@JoinColumn({ name: "idCropLot" })
|
|
26
|
+
cropLot!: CropLot;
|
|
27
|
+
|
|
28
|
+
@Column({
|
|
29
|
+
type: "enum",
|
|
30
|
+
enum: GrowthStage,
|
|
31
|
+
})
|
|
32
|
+
stage!: GrowthStage;
|
|
33
|
+
|
|
34
|
+
@Column("date", { nullable: false })
|
|
35
|
+
startDate!: Date;
|
|
36
|
+
|
|
37
|
+
@Column("date", { nullable: true })
|
|
38
|
+
endDate?: Date | null;
|
|
39
|
+
|
|
40
|
+
@Column("text", { nullable: true })
|
|
41
|
+
notes?: string | null;
|
|
42
|
+
|
|
43
|
+
@OneToMany(() => CropStageImage, (image) => image.cropStage, { cascade: true })
|
|
44
|
+
images?: CropStageImage[];
|
|
45
|
+
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import {
|
|
2
|
+
Entity,
|
|
3
|
+
PrimaryGeneratedColumn,
|
|
4
|
+
Column,
|
|
5
|
+
ManyToOne,
|
|
6
|
+
JoinColumn,
|
|
7
|
+
ObjectLiteral,
|
|
8
|
+
CreateDateColumn,
|
|
9
|
+
} from "typeorm";
|
|
10
|
+
import { CropStage } from "./CropStage";
|
|
11
|
+
|
|
12
|
+
@Entity("crop_stage_images")
|
|
13
|
+
export class CropStageImage implements ObjectLiteral {
|
|
14
|
+
@PrimaryGeneratedColumn("increment")
|
|
15
|
+
idCropStageImage!: number;
|
|
16
|
+
|
|
17
|
+
@ManyToOne(() => CropStage, (stage) => stage.images, {
|
|
18
|
+
nullable: false,
|
|
19
|
+
onDelete: "CASCADE",
|
|
20
|
+
})
|
|
21
|
+
@JoinColumn({ name: "idCropStage" })
|
|
22
|
+
cropStage!: CropStage;
|
|
23
|
+
|
|
24
|
+
@Column("varchar", { length: 512, nullable: false })
|
|
25
|
+
imageUrl!: string;
|
|
26
|
+
|
|
27
|
+
@Column("varchar", { length: 255, nullable: true })
|
|
28
|
+
caption?: string | null;
|
|
29
|
+
|
|
30
|
+
@CreateDateColumn({ type: "timestamp" })
|
|
31
|
+
createdAt!: Date;
|
|
32
|
+
}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import {
|
|
2
|
+
Entity,
|
|
3
|
+
PrimaryGeneratedColumn,
|
|
4
|
+
Column,
|
|
5
|
+
ManyToOne,
|
|
6
|
+
OneToMany,
|
|
7
|
+
JoinColumn,
|
|
8
|
+
ObjectLiteral,
|
|
9
|
+
Index,
|
|
10
|
+
} from "typeorm";
|
|
11
|
+
import { Branch } from "../../entities/Branches";
|
|
12
|
+
import { CropLot } from "./CropLot";
|
|
13
|
+
|
|
14
|
+
@Entity("growth_areas")
|
|
15
|
+
@Index(["code"], { unique: true })
|
|
16
|
+
export class GrowthArea implements ObjectLiteral {
|
|
17
|
+
@PrimaryGeneratedColumn("increment")
|
|
18
|
+
idGrowthArea!: number;
|
|
19
|
+
|
|
20
|
+
@Column("varchar", { length: 255, nullable: false })
|
|
21
|
+
name!: string;
|
|
22
|
+
|
|
23
|
+
@Column("varchar", { length: 64, nullable: false, unique: true })
|
|
24
|
+
code!: string;
|
|
25
|
+
|
|
26
|
+
@Column("text", { nullable: true })
|
|
27
|
+
description?: string | null;
|
|
28
|
+
|
|
29
|
+
@Column("decimal", { precision: 10, scale: 2, nullable: true })
|
|
30
|
+
capacity?: number | null;
|
|
31
|
+
|
|
32
|
+
@ManyToOne(() => Branch, { nullable: true, onDelete: "SET NULL" })
|
|
33
|
+
@JoinColumn({ name: "idBranch" })
|
|
34
|
+
branch?: Branch | null;
|
|
35
|
+
|
|
36
|
+
@Column("boolean", { default: true })
|
|
37
|
+
isActive!: boolean;
|
|
38
|
+
|
|
39
|
+
@OneToMany(() => CropLot, (cropLot) => cropLot.growthArea)
|
|
40
|
+
cropLots?: CropLot[];
|
|
41
|
+
}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import {
|
|
2
|
+
Entity,
|
|
3
|
+
PrimaryGeneratedColumn,
|
|
4
|
+
Column,
|
|
5
|
+
ManyToOne,
|
|
6
|
+
OneToOne,
|
|
7
|
+
JoinColumn,
|
|
8
|
+
ObjectLiteral,
|
|
9
|
+
Index,
|
|
10
|
+
CreateDateColumn,
|
|
11
|
+
} from "typeorm";
|
|
12
|
+
import { CropLot } from "./CropLot";
|
|
13
|
+
import { UnitOfMeasure } from "../../entities/UnitOfMesure";
|
|
14
|
+
import { QualityGrade } from "../../types/QualityGrade";
|
|
15
|
+
import { InventoryMovement } from "../../entities/InventoryMovement";
|
|
16
|
+
|
|
17
|
+
@Entity("harvests")
|
|
18
|
+
@Index(["cropLot", "harvestDate"])
|
|
19
|
+
export class Harvest implements ObjectLiteral {
|
|
20
|
+
@PrimaryGeneratedColumn("increment")
|
|
21
|
+
idHarvest!: number;
|
|
22
|
+
|
|
23
|
+
@ManyToOne(() => CropLot, (cropLot) => cropLot.harvests, {
|
|
24
|
+
nullable: false,
|
|
25
|
+
onDelete: "CASCADE",
|
|
26
|
+
})
|
|
27
|
+
@JoinColumn({ name: "idCropLot" })
|
|
28
|
+
cropLot!: CropLot;
|
|
29
|
+
|
|
30
|
+
@Column("date", { nullable: false })
|
|
31
|
+
harvestDate!: Date;
|
|
32
|
+
|
|
33
|
+
@Column("decimal", { precision: 12, scale: 2, nullable: false })
|
|
34
|
+
quantity!: number;
|
|
35
|
+
|
|
36
|
+
@ManyToOne(() => UnitOfMeasure, { nullable: true, onDelete: "SET NULL" })
|
|
37
|
+
@JoinColumn({ name: "idUnitOfMeasure" })
|
|
38
|
+
unitOfMeasure?: UnitOfMeasure | null;
|
|
39
|
+
|
|
40
|
+
@Column({
|
|
41
|
+
type: "enum",
|
|
42
|
+
enum: QualityGrade,
|
|
43
|
+
nullable: true,
|
|
44
|
+
})
|
|
45
|
+
qualityGrade?: QualityGrade | null;
|
|
46
|
+
|
|
47
|
+
@Column("text", { nullable: true })
|
|
48
|
+
notes?: string | null;
|
|
49
|
+
|
|
50
|
+
@CreateDateColumn({ type: "timestamp" })
|
|
51
|
+
createdAt!: Date;
|
|
52
|
+
|
|
53
|
+
@OneToOne(() => InventoryMovement, { nullable: true, cascade: true })
|
|
54
|
+
@JoinColumn({ name: "idInventoryMovement" })
|
|
55
|
+
inventoryMovement?: InventoryMovement | null;
|
|
56
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import {
|
|
2
|
+
Entity,
|
|
3
|
+
PrimaryGeneratedColumn,
|
|
4
|
+
Column,
|
|
5
|
+
OneToMany,
|
|
6
|
+
ObjectLiteral,
|
|
7
|
+
Index,
|
|
8
|
+
} from "typeorm";
|
|
9
|
+
import { CropLot } from "./CropLot";
|
|
10
|
+
|
|
11
|
+
@Entity("production_seasons")
|
|
12
|
+
@Index(["code"], { unique: true })
|
|
13
|
+
export class ProductionSeason implements ObjectLiteral {
|
|
14
|
+
@PrimaryGeneratedColumn("increment")
|
|
15
|
+
idSeason!: number;
|
|
16
|
+
|
|
17
|
+
@Column("varchar", { length: 255, nullable: false })
|
|
18
|
+
name!: string;
|
|
19
|
+
|
|
20
|
+
@Column("varchar", { length: 64, nullable: false, unique: true })
|
|
21
|
+
code!: string;
|
|
22
|
+
|
|
23
|
+
@Column("date", { nullable: false })
|
|
24
|
+
startDate!: Date;
|
|
25
|
+
|
|
26
|
+
@Column("date", { nullable: true })
|
|
27
|
+
endDate?: Date | null;
|
|
28
|
+
|
|
29
|
+
@Column("boolean", { default: true })
|
|
30
|
+
isActive!: boolean;
|
|
31
|
+
|
|
32
|
+
@OneToMany(() => CropLot, (cropLot) => cropLot.season)
|
|
33
|
+
cropLots?: CropLot[];
|
|
34
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
// Production entities
|
|
2
|
+
export { GrowthArea } from "./GrowthArea";
|
|
3
|
+
export { ProductionSeason } from "./ProductionSeason";
|
|
4
|
+
export { CropLot } from "./CropLot";
|
|
5
|
+
export { CropStage } from "./CropStage";
|
|
6
|
+
export { CropStageImage } from "./CropStageImage";
|
|
7
|
+
export { CropActivity } from "./CropActivity";
|
|
8
|
+
export { CropExpense } from "./CropExpense";
|
|
9
|
+
export { Harvest } from "./Harvest";
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export enum CropActivityType {
|
|
2
|
+
IRRIGATION = "IRRIGATION",
|
|
3
|
+
FERTILIZATION = "FERTILIZATION",
|
|
4
|
+
PRUNING = "PRUNING",
|
|
5
|
+
PEST_CONTROL = "PEST_CONTROL",
|
|
6
|
+
DISEASE_CONTROL = "DISEASE_CONTROL",
|
|
7
|
+
TRANSPLANT = "TRANSPLANT",
|
|
8
|
+
WEEDING = "WEEDING",
|
|
9
|
+
HARVESTING = "HARVESTING",
|
|
10
|
+
QUALITY_CHECK = "QUALITY_CHECK",
|
|
11
|
+
OTHER = "OTHER",
|
|
12
|
+
}
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
export enum MovementType {
|
|
2
|
-
PURCHASE = "PURCHASE",
|
|
3
|
-
SALE = "SALE",
|
|
2
|
+
PURCHASE = "PURCHASE",
|
|
3
|
+
SALE = "SALE",
|
|
4
4
|
ADJUSTMENT = "ADJUSTMENT",
|
|
5
|
-
TRANSFER_IN = "TRANSFER_IN",
|
|
6
|
-
TRANSFER_OUT = "TRANSFER_OUT",
|
|
5
|
+
TRANSFER_IN = "TRANSFER_IN",
|
|
6
|
+
TRANSFER_OUT = "TRANSFER_OUT",
|
|
7
|
+
HARVEST = "HARVEST",
|
|
7
8
|
}
|
package/src/types/index.ts
CHANGED
|
@@ -2,4 +2,14 @@ export { ExpenseTransactionType } from "./ExpenseTransactionType";
|
|
|
2
2
|
export { ExpenseDetailType } from "./ExpenseDetailType";
|
|
3
3
|
export { ExpenseTypeType } from "./ExpenseTypeType";
|
|
4
4
|
export { ProjectOrderType } from "./ProjectOrderType";
|
|
5
|
-
export { MovementType } from "./MovementType";
|
|
5
|
+
export { MovementType } from "./MovementType";
|
|
6
|
+
|
|
7
|
+
// Production enums
|
|
8
|
+
export { CropLotStatus } from "./CropLotStatus";
|
|
9
|
+
export { GrowthStage } from "./GrowthStage";
|
|
10
|
+
export { CropActivityType } from "./CropActivityType";
|
|
11
|
+
export { QualityGrade } from "./QualityGrade";
|
|
12
|
+
|
|
13
|
+
// Income enums
|
|
14
|
+
export { IncomeType } from "./IncomeType";
|
|
15
|
+
export { IncomeStatus } from "./IncomeStatus";
|