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.
Files changed (73) hide show
  1. package/dist/entities/ExpenseDetail.d.ts +6 -0
  2. package/dist/entities/ExpenseDetail.js +19 -1
  3. package/dist/entities/ExpenseTransaction.d.ts +2 -0
  4. package/dist/entities/ExpenseTransaction.js +11 -1
  5. package/dist/entities/Income.d.ts +29 -0
  6. package/dist/entities/Income.js +121 -0
  7. package/dist/entities/InventoryMovement.d.ts +2 -0
  8. package/dist/entities/InventoryMovement.js +7 -0
  9. package/dist/entities/index.d.ts +24 -0
  10. package/dist/entities/index.js +60 -0
  11. package/dist/index.d.ts +2 -23
  12. package/dist/index.js +5 -47
  13. package/dist/models/apu/Budget.d.ts +4 -0
  14. package/dist/models/apu/Budget.js +10 -0
  15. package/dist/models/production/CropActivity.d.ts +20 -0
  16. package/dist/models/production/CropActivity.js +85 -0
  17. package/dist/models/production/CropExpense.d.ts +22 -0
  18. package/dist/models/production/CropExpense.js +93 -0
  19. package/dist/models/production/CropLot.d.ts +33 -0
  20. package/dist/models/production/CropLot.js +132 -0
  21. package/dist/models/production/CropStage.d.ts +13 -0
  22. package/dist/models/production/CropStage.js +58 -0
  23. package/dist/models/production/CropStageImage.d.ts +9 -0
  24. package/dist/models/production/CropStageImage.js +44 -0
  25. package/dist/models/production/GrowthArea.d.ts +13 -0
  26. package/dist/models/production/GrowthArea.js +55 -0
  27. package/dist/models/production/Harvest.d.ts +16 -0
  28. package/dist/models/production/Harvest.js +70 -0
  29. package/dist/models/production/ProductionSeason.d.ts +11 -0
  30. package/dist/models/production/ProductionSeason.js +49 -0
  31. package/dist/models/production/index.d.ts +8 -0
  32. package/dist/models/production/index.js +20 -0
  33. package/dist/types/CropActivityType.d.ts +12 -0
  34. package/dist/types/CropActivityType.js +16 -0
  35. package/dist/types/CropLotStatus.d.ts +10 -0
  36. package/dist/types/CropLotStatus.js +14 -0
  37. package/dist/types/GrowthStage.d.ts +10 -0
  38. package/dist/types/GrowthStage.js +14 -0
  39. package/dist/types/IncomeStatus.d.ts +5 -0
  40. package/dist/types/IncomeStatus.js +9 -0
  41. package/dist/types/IncomeType.d.ts +6 -0
  42. package/dist/types/IncomeType.js +10 -0
  43. package/dist/types/MovementType.d.ts +2 -1
  44. package/dist/types/MovementType.js +1 -0
  45. package/dist/types/QualityGrade.d.ts +6 -0
  46. package/dist/types/QualityGrade.js +10 -0
  47. package/dist/types/index.d.ts +6 -0
  48. package/dist/types/index.js +15 -1
  49. package/package.json +1 -1
  50. package/src/entities/ExpenseDetail.ts +16 -1
  51. package/src/entities/ExpenseTransaction.ts +12 -2
  52. package/src/entities/Income.ts +99 -0
  53. package/src/entities/InventoryMovement.ts +7 -1
  54. package/src/entities/index.ts +41 -0
  55. package/src/index.ts +6 -23
  56. package/src/models/apu/Budget.ts +8 -0
  57. package/src/models/production/CropActivity.ts +68 -0
  58. package/src/models/production/CropExpense.ts +74 -0
  59. package/src/models/production/CropLot.ts +106 -0
  60. package/src/models/production/CropStage.ts +45 -0
  61. package/src/models/production/CropStageImage.ts +32 -0
  62. package/src/models/production/GrowthArea.ts +41 -0
  63. package/src/models/production/Harvest.ts +56 -0
  64. package/src/models/production/ProductionSeason.ts +34 -0
  65. package/src/models/production/index.ts +9 -0
  66. package/src/types/CropActivityType.ts +12 -0
  67. package/src/types/CropLotStatus.ts +10 -0
  68. package/src/types/GrowthStage.ts +10 -0
  69. package/src/types/IncomeStatus.ts +5 -0
  70. package/src/types/IncomeType.ts +6 -0
  71. package/src/types/MovementType.ts +5 -4
  72. package/src/types/QualityGrade.ts +6 -0
  73. package/src/types/index.ts +11 -1
@@ -0,0 +1,16 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.CropActivityType = void 0;
4
+ var CropActivityType;
5
+ (function (CropActivityType) {
6
+ CropActivityType["IRRIGATION"] = "IRRIGATION";
7
+ CropActivityType["FERTILIZATION"] = "FERTILIZATION";
8
+ CropActivityType["PRUNING"] = "PRUNING";
9
+ CropActivityType["PEST_CONTROL"] = "PEST_CONTROL";
10
+ CropActivityType["DISEASE_CONTROL"] = "DISEASE_CONTROL";
11
+ CropActivityType["TRANSPLANT"] = "TRANSPLANT";
12
+ CropActivityType["WEEDING"] = "WEEDING";
13
+ CropActivityType["HARVESTING"] = "HARVESTING";
14
+ CropActivityType["QUALITY_CHECK"] = "QUALITY_CHECK";
15
+ CropActivityType["OTHER"] = "OTHER";
16
+ })(CropActivityType || (exports.CropActivityType = CropActivityType = {}));
@@ -0,0 +1,10 @@
1
+ export declare enum CropLotStatus {
2
+ PLANNED = "PLANNED",
3
+ SOWING = "SOWING",
4
+ GROWING = "GROWING",
5
+ FLOWERING = "FLOWERING",
6
+ READY_TO_HARVEST = "READY_TO_HARVEST",
7
+ HARVESTING = "HARVESTING",
8
+ COMPLETED = "COMPLETED",
9
+ CANCELLED = "CANCELLED"
10
+ }
@@ -0,0 +1,14 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.CropLotStatus = void 0;
4
+ var CropLotStatus;
5
+ (function (CropLotStatus) {
6
+ CropLotStatus["PLANNED"] = "PLANNED";
7
+ CropLotStatus["SOWING"] = "SOWING";
8
+ CropLotStatus["GROWING"] = "GROWING";
9
+ CropLotStatus["FLOWERING"] = "FLOWERING";
10
+ CropLotStatus["READY_TO_HARVEST"] = "READY_TO_HARVEST";
11
+ CropLotStatus["HARVESTING"] = "HARVESTING";
12
+ CropLotStatus["COMPLETED"] = "COMPLETED";
13
+ CropLotStatus["CANCELLED"] = "CANCELLED";
14
+ })(CropLotStatus || (exports.CropLotStatus = CropLotStatus = {}));
@@ -0,0 +1,10 @@
1
+ export declare enum GrowthStage {
2
+ SOWING = "SOWING",
3
+ GERMINATION = "GERMINATION",
4
+ SEEDLING = "SEEDLING",
5
+ VEGETATIVE = "VEGETATIVE",
6
+ FLOWERING = "FLOWERING",
7
+ FRUITING = "FRUITING",
8
+ MATURATION = "MATURATION",
9
+ HARVEST = "HARVEST"
10
+ }
@@ -0,0 +1,14 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.GrowthStage = void 0;
4
+ var GrowthStage;
5
+ (function (GrowthStage) {
6
+ GrowthStage["SOWING"] = "SOWING";
7
+ GrowthStage["GERMINATION"] = "GERMINATION";
8
+ GrowthStage["SEEDLING"] = "SEEDLING";
9
+ GrowthStage["VEGETATIVE"] = "VEGETATIVE";
10
+ GrowthStage["FLOWERING"] = "FLOWERING";
11
+ GrowthStage["FRUITING"] = "FRUITING";
12
+ GrowthStage["MATURATION"] = "MATURATION";
13
+ GrowthStage["HARVEST"] = "HARVEST";
14
+ })(GrowthStage || (exports.GrowthStage = GrowthStage = {}));
@@ -0,0 +1,5 @@
1
+ export declare enum IncomeStatus {
2
+ PENDING = "PENDING",
3
+ CONFIRMED = "CONFIRMED",
4
+ CANCELLED = "CANCELLED"
5
+ }
@@ -0,0 +1,9 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.IncomeStatus = void 0;
4
+ var IncomeStatus;
5
+ (function (IncomeStatus) {
6
+ IncomeStatus["PENDING"] = "PENDING";
7
+ IncomeStatus["CONFIRMED"] = "CONFIRMED";
8
+ IncomeStatus["CANCELLED"] = "CANCELLED";
9
+ })(IncomeStatus || (exports.IncomeStatus = IncomeStatus = {}));
@@ -0,0 +1,6 @@
1
+ export declare enum IncomeType {
2
+ BUDGET_PAYMENT = "BUDGET_PAYMENT",
3
+ SPOT_SALE = "SPOT_SALE",
4
+ HARVEST_SALE = "HARVEST_SALE",
5
+ OTHER = "OTHER"
6
+ }
@@ -0,0 +1,10 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.IncomeType = void 0;
4
+ var IncomeType;
5
+ (function (IncomeType) {
6
+ IncomeType["BUDGET_PAYMENT"] = "BUDGET_PAYMENT";
7
+ IncomeType["SPOT_SALE"] = "SPOT_SALE";
8
+ IncomeType["HARVEST_SALE"] = "HARVEST_SALE";
9
+ IncomeType["OTHER"] = "OTHER";
10
+ })(IncomeType || (exports.IncomeType = IncomeType = {}));
@@ -3,5 +3,6 @@ export declare enum MovementType {
3
3
  SALE = "SALE",
4
4
  ADJUSTMENT = "ADJUSTMENT",
5
5
  TRANSFER_IN = "TRANSFER_IN",
6
- TRANSFER_OUT = "TRANSFER_OUT"
6
+ TRANSFER_OUT = "TRANSFER_OUT",
7
+ HARVEST = "HARVEST"
7
8
  }
@@ -8,4 +8,5 @@ var MovementType;
8
8
  MovementType["ADJUSTMENT"] = "ADJUSTMENT";
9
9
  MovementType["TRANSFER_IN"] = "TRANSFER_IN";
10
10
  MovementType["TRANSFER_OUT"] = "TRANSFER_OUT";
11
+ MovementType["HARVEST"] = "HARVEST";
11
12
  })(MovementType || (exports.MovementType = MovementType = {}));
@@ -0,0 +1,6 @@
1
+ export declare enum QualityGrade {
2
+ PREMIUM = "PREMIUM",
3
+ STANDARD = "STANDARD",
4
+ ECONOMY = "ECONOMY",
5
+ REJECTED = "REJECTED"
6
+ }
@@ -0,0 +1,10 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.QualityGrade = void 0;
4
+ var QualityGrade;
5
+ (function (QualityGrade) {
6
+ QualityGrade["PREMIUM"] = "PREMIUM";
7
+ QualityGrade["STANDARD"] = "STANDARD";
8
+ QualityGrade["ECONOMY"] = "ECONOMY";
9
+ QualityGrade["REJECTED"] = "REJECTED";
10
+ })(QualityGrade || (exports.QualityGrade = QualityGrade = {}));
@@ -3,3 +3,9 @@ export { ExpenseDetailType } from "./ExpenseDetailType";
3
3
  export { ExpenseTypeType } from "./ExpenseTypeType";
4
4
  export { ProjectOrderType } from "./ProjectOrderType";
5
5
  export { MovementType } from "./MovementType";
6
+ export { CropLotStatus } from "./CropLotStatus";
7
+ export { GrowthStage } from "./GrowthStage";
8
+ export { CropActivityType } from "./CropActivityType";
9
+ export { QualityGrade } from "./QualityGrade";
10
+ export { IncomeType } from "./IncomeType";
11
+ export { IncomeStatus } from "./IncomeStatus";
@@ -1,5 +1,19 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.MovementType = void 0;
3
+ exports.IncomeStatus = exports.IncomeType = exports.QualityGrade = exports.CropActivityType = exports.GrowthStage = exports.CropLotStatus = exports.MovementType = void 0;
4
4
  var MovementType_1 = require("./MovementType");
5
5
  Object.defineProperty(exports, "MovementType", { enumerable: true, get: function () { return MovementType_1.MovementType; } });
6
+ // Production enums
7
+ var CropLotStatus_1 = require("./CropLotStatus");
8
+ Object.defineProperty(exports, "CropLotStatus", { enumerable: true, get: function () { return CropLotStatus_1.CropLotStatus; } });
9
+ var GrowthStage_1 = require("./GrowthStage");
10
+ Object.defineProperty(exports, "GrowthStage", { enumerable: true, get: function () { return GrowthStage_1.GrowthStage; } });
11
+ var CropActivityType_1 = require("./CropActivityType");
12
+ Object.defineProperty(exports, "CropActivityType", { enumerable: true, get: function () { return CropActivityType_1.CropActivityType; } });
13
+ var QualityGrade_1 = require("./QualityGrade");
14
+ Object.defineProperty(exports, "QualityGrade", { enumerable: true, get: function () { return QualityGrade_1.QualityGrade; } });
15
+ // Income enums
16
+ var IncomeType_1 = require("./IncomeType");
17
+ Object.defineProperty(exports, "IncomeType", { enumerable: true, get: function () { return IncomeType_1.IncomeType; } });
18
+ var IncomeStatus_1 = require("./IncomeStatus");
19
+ Object.defineProperty(exports, "IncomeStatus", { enumerable: true, get: function () { return IncomeStatus_1.IncomeStatus; } });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "proflores-db-model",
3
- "version": "0.2.52",
3
+ "version": "0.2.54",
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",
@@ -9,6 +9,9 @@ import {
9
9
  import { ExpenseTransaction } from "./ExpenseTransaction";
10
10
  import { Inventory } from "./Inventory";
11
11
  import { ProjectOrder } from "./ProjectOrder";
12
+ import { Budget } from "../models/apu/Budget";
13
+ import { CropLot } from "../models/production/CropLot";
14
+ import { CropActivity } from "../models/production/CropActivity";
12
15
 
13
16
  @Entity()
14
17
  export class ExpenseDetail implements ObjectLiteral {
@@ -44,7 +47,19 @@ export class ExpenseDetail implements ObjectLiteral {
44
47
  @Column("boolean", { default: true })
45
48
  isActive!: boolean;
46
49
 
47
- @ManyToOne(() => ProjectOrder, { nullable: false })
50
+ @ManyToOne(() => ProjectOrder, { nullable: true })
48
51
  @JoinColumn({ name: "projectId" })
49
52
  projectOrder?: ProjectOrder;
53
+
54
+ @ManyToOne(() => Budget, { nullable: true, onDelete: "SET NULL" })
55
+ @JoinColumn({ name: "idBudget" })
56
+ budget?: Budget | null;
57
+
58
+ @ManyToOne(() => CropLot, { nullable: true, onDelete: "SET NULL" })
59
+ @JoinColumn({ name: "idCropLot" })
60
+ cropLot?: CropLot | null;
61
+
62
+ @ManyToOne(() => CropActivity, { nullable: true, onDelete: "SET NULL" })
63
+ @JoinColumn({ name: "idCropActivity" })
64
+ cropActivity?: CropActivity | null;
50
65
  }
@@ -7,13 +7,16 @@ import {
7
7
  JoinColumn,
8
8
  OneToMany,
9
9
  ObjectLiteral,
10
- OneToOne
10
+ OneToOne,
11
+ Index,
11
12
  } from "typeorm";
12
13
  import { ExpenseType } from "./ExpenseType";
13
14
  import { ExpenseDetail } from "./ExpenseDetail";
14
15
  import { TransactionBank } from "./Bank/TransactionBank";
16
+ import { Budget } from "../models/apu/Budget";
15
17
 
16
18
  @Entity()
19
+ @Index(["budget"])
17
20
  export class ExpenseTransaction implements ObjectLiteral {
18
21
  @PrimaryGeneratedColumn("increment")
19
22
  expenseTransactionId!: number;
@@ -46,7 +49,14 @@ export class ExpenseTransaction implements ObjectLiteral {
46
49
  expenseDetails?: ExpenseDetail[];
47
50
 
48
51
  @OneToOne(() => TransactionBank, (transactionBank) => transactionBank.expenseTransaction, {
49
- nullable: true,
52
+ nullable: true,
50
53
  })
51
54
  transactionBank?: TransactionBank;
55
+
56
+ @ManyToOne(() => Budget, (budget) => budget.expenses, {
57
+ nullable: true,
58
+ onDelete: "SET NULL",
59
+ })
60
+ @JoinColumn({ name: "idBudget" })
61
+ budget?: Budget | null;
52
62
  }
@@ -0,0 +1,99 @@
1
+ import {
2
+ Entity,
3
+ PrimaryGeneratedColumn,
4
+ Column,
5
+ ManyToOne,
6
+ OneToOne,
7
+ JoinColumn,
8
+ ObjectLiteral,
9
+ Index,
10
+ CreateDateColumn,
11
+ UpdateDateColumn,
12
+ } from "typeorm";
13
+ import { Budget } from "../models/apu/Budget";
14
+ import { Payment } from "./Payment";
15
+ import { CropLot } from "../models/production/CropLot";
16
+ import { Client } from "../models/apu/Client";
17
+ import { Inventory } from "./Inventory";
18
+ import { TransactionBank } from "./Bank/TransactionBank";
19
+ import { IncomeType } from "../types/IncomeType";
20
+ import { IncomeStatus } from "../types/IncomeStatus";
21
+
22
+ @Entity("incomes")
23
+ @Index(["incomeDate"])
24
+ @Index(["incomeType"])
25
+ @Index(["status"])
26
+ @Index(["budget"])
27
+ @Index(["cropLot"])
28
+ export class Income implements ObjectLiteral {
29
+ @PrimaryGeneratedColumn("increment")
30
+ idIncome!: number;
31
+
32
+ @Column({
33
+ type: "enum",
34
+ enum: IncomeType,
35
+ default: IncomeType.OTHER,
36
+ })
37
+ incomeType!: IncomeType;
38
+
39
+ @Column("decimal", { precision: 14, scale: 2, nullable: false })
40
+ amount!: number;
41
+
42
+ @Column("date", { nullable: false })
43
+ incomeDate!: Date;
44
+
45
+ @Column("text", { nullable: true })
46
+ description?: string | null;
47
+
48
+ @Column({
49
+ type: "enum",
50
+ enum: IncomeStatus,
51
+ default: IncomeStatus.PENDING,
52
+ })
53
+ status!: IncomeStatus;
54
+
55
+ @ManyToOne(() => Budget, (budget) => budget.incomes, {
56
+ nullable: true,
57
+ onDelete: "SET NULL",
58
+ })
59
+ @JoinColumn({ name: "idBudget" })
60
+ budget?: Budget | null;
61
+
62
+ @ManyToOne(() => Payment, { nullable: true, onDelete: "SET NULL" })
63
+ @JoinColumn({ name: "idPayment" })
64
+ payment?: Payment | null;
65
+
66
+ @ManyToOne(() => CropLot, { nullable: true, onDelete: "SET NULL" })
67
+ @JoinColumn({ name: "idCropLot" })
68
+ cropLot?: CropLot | null;
69
+
70
+ @ManyToOne(() => Client, { nullable: true, onDelete: "SET NULL" })
71
+ @JoinColumn({ name: "idClient" })
72
+ client?: Client | null;
73
+
74
+ @ManyToOne(() => Inventory, { nullable: true, onDelete: "SET NULL" })
75
+ @JoinColumn({ name: "idInventory" })
76
+ inventory?: Inventory | null;
77
+
78
+ @Column("decimal", { precision: 12, scale: 4, nullable: true })
79
+ quantity?: number | null;
80
+
81
+ @Column("decimal", { precision: 14, scale: 4, nullable: true })
82
+ unitPrice?: number | null;
83
+
84
+ @Column("varchar", { length: 255, nullable: true })
85
+ invoiceUuid?: string | null;
86
+
87
+ @OneToOne(() => TransactionBank, { nullable: true, cascade: true })
88
+ @JoinColumn({ name: "idTransactionBank" })
89
+ transactionBank?: TransactionBank | null;
90
+
91
+ @Column("text", { nullable: true })
92
+ notes?: string | null;
93
+
94
+ @CreateDateColumn({ type: "timestamp" })
95
+ createdAt!: Date;
96
+
97
+ @UpdateDateColumn({ type: "timestamp" })
98
+ updatedAt!: Date;
99
+ }
@@ -3,6 +3,7 @@ import {
3
3
  PrimaryGeneratedColumn,
4
4
  Column,
5
5
  ManyToOne,
6
+ OneToOne,
6
7
  JoinColumn,
7
8
  CreateDateColumn,
8
9
  UpdateDateColumn,
@@ -10,6 +11,7 @@ import {
10
11
  } from "typeorm";
11
12
  import { Inventory } from "./Inventory";
12
13
  import { MovementType } from "../types/MovementType";
14
+ import { Harvest } from "../models/production/Harvest";
13
15
  @Entity("inventory_movement")
14
16
  export class InventoryMovement implements ObjectLiteral {
15
17
  @PrimaryGeneratedColumn("increment")
@@ -47,6 +49,10 @@ import {
47
49
 
48
50
  @Column("varchar", { length: 50, nullable: true })
49
51
  referenceModule?: string;
50
-
52
+
53
+ @OneToOne(() => Harvest, (harvest) => harvest.inventoryMovement, {
54
+ nullable: true,
55
+ })
56
+ harvest?: Harvest | null;
51
57
  }
52
58
 
@@ -0,0 +1,41 @@
1
+ // Bank
2
+ export { BankAccount } from "./Bank/BankAccount";
3
+ export { TransactionBank } from "./Bank/TransactionBank";
4
+
5
+ // Categories
6
+ export { CategoryForCosting } from "./CategoryForCosting";
7
+ export { CategoryForPlantType } from "./CategoryForPlantType";
8
+
9
+ // Branches
10
+ export { Branch } from "./Branches";
11
+ export { BranchImage } from "./BranchImage";
12
+
13
+ // Products & Inventory
14
+ export { Product } from "./Products";
15
+ export { ProductImage } from "./ProductImage";
16
+ export { Inventory } from "./Inventory";
17
+ export { InventoryItem } from "./InventoryItem";
18
+ export { InventoryImage } from "./InventoryImage";
19
+ export { InventoryMovement } from "./InventoryMovement";
20
+ export { ContainerType } from "./ContainerType";
21
+
22
+ // Suppliers
23
+ export { Supplier } from "./Suppliers";
24
+ export { SupplierImage } from "./SupplierImage";
25
+
26
+ // Expenses
27
+ export { ExpenseDetail } from "./ExpenseDetail";
28
+ export { ExpenseTransaction } from "./ExpenseTransaction";
29
+ export { ExpenseType } from "./ExpenseType";
30
+
31
+ // Payments
32
+ export { Payment } from "./Payment";
33
+ export { PaymentCfdi } from "./PaymentCfdi";
34
+
35
+ // Income
36
+ export { Income } from "./Income";
37
+
38
+ // Others
39
+ export { ProjectOrder } from "./ProjectOrder";
40
+ export { UnitOfMeasure } from "./UnitOfMesure";
41
+ export { User } from "./User";
package/src/index.ts CHANGED
@@ -1,27 +1,10 @@
1
- export { ExpenseDetail } from "./entities/ExpenseDetail";
2
- export { ExpenseType } from "./entities/ExpenseType";
3
- export { ProjectOrder } from "./entities/ProjectOrder";
4
- export { User } from "./entities/User";
5
- export { ExpenseTransaction } from "./entities/ExpenseTransaction";
6
- export { InventoryItem } from "./entities/InventoryItem";
7
- export { ContainerType } from "./entities/ContainerType";
8
- export { Supplier } from "./entities/Suppliers";
9
- export { CategoryForCosting } from "./entities/CategoryForCosting";
10
- export { CategoryForPlantType } from "./entities/CategoryForPlantType";
11
- export { UnitOfMeasure } from "./entities/UnitOfMesure";
12
- export { BankAccount } from "./entities/Bank/BankAccount";
13
- export { TransactionBank } from "./entities/Bank/TransactionBank";
14
- export { ProductImage } from "./entities/ProductImage";
15
- export { Product } from "./entities/Products";
16
- export { Inventory } from "./entities/Inventory";
17
- export { InventoryMovement } from "./entities/InventoryMovement";
18
- export { Branch } from "./entities/Branches";
19
- export { BranchImage } from "./entities/BranchImage";
20
- export { SupplierImage } from "./entities/SupplierImage";
21
- export { InventoryImage } from "./entities/InventoryImage";
22
- export { Payment } from "./entities/Payment";
23
- export { PaymentCfdi } from "./entities/PaymentCfdi";
1
+ // Entities
2
+ export * from "./entities";
24
3
 
4
+ // Types
25
5
  export * from "./types";
6
+
7
+ // Models
26
8
  export * from "./models/technical-sheet";
27
9
  export * from "./models/apu";
10
+ export * from "./models/production";
@@ -6,6 +6,8 @@ import { Project } from "./Project";
6
6
  import { BudgetItem } from "./BudgetItem";
7
7
  import { BudgetCancellationFolio } from "./BudgetCancellationFolio";
8
8
  import { Payment } from "../../entities/Payment";
9
+ import { ExpenseTransaction } from "../../entities/ExpenseTransaction";
10
+ import { Income } from "../../entities/Income";
9
11
 
10
12
  @Entity("budgets")
11
13
  @Index(["project"])
@@ -55,4 +57,10 @@ export class Budget implements ObjectLiteral {
55
57
 
56
58
  @OneToMany(() => Payment, (payment) => payment.budget)
57
59
  payments?: Payment[];
60
+
61
+ @OneToMany(() => ExpenseTransaction, (expense) => expense.budget)
62
+ expenses?: ExpenseTransaction[];
63
+
64
+ @OneToMany(() => Income, (income) => income.budget)
65
+ incomes?: Income[];
58
66
  }
@@ -0,0 +1,68 @@
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 { CropLot } from "./CropLot";
14
+ import { CropActivityType } from "../../types/CropActivityType";
15
+ import { UnitOfMeasure } from "../../entities/UnitOfMesure";
16
+ import { CropExpense } from "./CropExpense";
17
+
18
+ @Entity("crop_activities")
19
+ @Index(["cropLot", "activityDate"])
20
+ @Index(["activityType"])
21
+ export class CropActivity implements ObjectLiteral {
22
+ @PrimaryGeneratedColumn("increment")
23
+ idCropActivity!: number;
24
+
25
+ @ManyToOne(() => CropLot, (cropLot) => cropLot.activities, {
26
+ nullable: false,
27
+ onDelete: "CASCADE",
28
+ })
29
+ @JoinColumn({ name: "idCropLot" })
30
+ cropLot!: CropLot;
31
+
32
+ @Column({
33
+ type: "enum",
34
+ enum: CropActivityType,
35
+ })
36
+ activityType!: CropActivityType;
37
+
38
+ @Column("text", { nullable: false })
39
+ description!: string;
40
+
41
+ @Column("date", { nullable: false })
42
+ activityDate!: Date;
43
+
44
+ @Column("decimal", { precision: 12, scale: 4, nullable: true })
45
+ quantity?: number | null;
46
+
47
+ @ManyToOne(() => UnitOfMeasure, { nullable: true, onDelete: "SET NULL" })
48
+ @JoinColumn({ name: "idUnitOfMeasure" })
49
+ unitOfMeasure?: UnitOfMeasure | null;
50
+
51
+ @Column("decimal", { precision: 8, scale: 2, nullable: true })
52
+ laborHours?: number | null;
53
+
54
+ @Column("text", { nullable: true })
55
+ notes?: string | null;
56
+
57
+ @Column("varchar", { length: 255, nullable: true })
58
+ performedBy?: string | null;
59
+
60
+ @CreateDateColumn({ type: "timestamp" })
61
+ createdAt!: Date;
62
+
63
+ @UpdateDateColumn({ type: "timestamp" })
64
+ updatedAt!: Date;
65
+
66
+ @OneToMany(() => CropExpense, (expense) => expense.cropActivity, { cascade: true })
67
+ expenses?: CropExpense[];
68
+ }
@@ -0,0 +1,74 @@
1
+ import {
2
+ Entity,
3
+ PrimaryGeneratedColumn,
4
+ Column,
5
+ ManyToOne,
6
+ JoinColumn,
7
+ ObjectLiteral,
8
+ Index,
9
+ CreateDateColumn,
10
+ UpdateDateColumn,
11
+ } from "typeorm";
12
+ import { CropLot } from "./CropLot";
13
+ import { CropActivity } from "./CropActivity";
14
+ import { ExpenseType } from "../../entities/ExpenseType";
15
+ import { Resource } from "../apu/Resource";
16
+ import { Inventory } from "../../entities/Inventory";
17
+
18
+ @Entity("crop_expenses")
19
+ @Index(["cropLot", "expenseDate"])
20
+ @Index(["cropActivity"])
21
+ export class CropExpense implements ObjectLiteral {
22
+ @PrimaryGeneratedColumn("increment")
23
+ idCropExpense!: number;
24
+
25
+ @ManyToOne(() => CropLot, (cropLot) => cropLot.expenses, {
26
+ nullable: false,
27
+ onDelete: "CASCADE",
28
+ })
29
+ @JoinColumn({ name: "idCropLot" })
30
+ cropLot!: CropLot;
31
+
32
+ @ManyToOne(() => CropActivity, (activity) => activity.expenses, {
33
+ nullable: true,
34
+ onDelete: "SET NULL",
35
+ })
36
+ @JoinColumn({ name: "idCropActivity" })
37
+ cropActivity?: CropActivity | null;
38
+
39
+ @ManyToOne(() => ExpenseType, { nullable: true, onDelete: "SET NULL" })
40
+ @JoinColumn({ name: "idExpenseType" })
41
+ expenseType?: ExpenseType | null;
42
+
43
+ @Column("varchar", { length: 255, nullable: false })
44
+ concept!: string;
45
+
46
+ @Column("decimal", { precision: 14, scale: 2, nullable: false })
47
+ amount!: number;
48
+
49
+ @Column("decimal", { precision: 12, scale: 4, nullable: false, default: 1 })
50
+ quantity!: number;
51
+
52
+ @Column("decimal", { precision: 14, scale: 4, nullable: false })
53
+ unitPrice!: number;
54
+
55
+ @Column("date", { nullable: false })
56
+ expenseDate!: Date;
57
+
58
+ @ManyToOne(() => Resource, { nullable: true, onDelete: "SET NULL" })
59
+ @JoinColumn({ name: "idResource" })
60
+ resource?: Resource | null;
61
+
62
+ @ManyToOne(() => Inventory, { nullable: true, onDelete: "SET NULL" })
63
+ @JoinColumn({ name: "idInventory" })
64
+ inventory?: Inventory | null;
65
+
66
+ @Column("text", { nullable: true })
67
+ notes?: string | null;
68
+
69
+ @CreateDateColumn({ type: "timestamp" })
70
+ createdAt!: Date;
71
+
72
+ @UpdateDateColumn({ type: "timestamp" })
73
+ updatedAt!: Date;
74
+ }