proflores-db-model 0.2.53 → 0.2.55

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 (44) hide show
  1. package/dist/entities/Bank/TransactionBank.d.ts +4 -0
  2. package/dist/entities/Bank/TransactionBank.js +14 -0
  3. package/dist/entities/BudgetExpenditure.d.ts +22 -0
  4. package/dist/entities/BudgetExpenditure.js +97 -0
  5. package/dist/entities/BudgetExpenditureDetail.d.ts +17 -0
  6. package/dist/entities/BudgetExpenditureDetail.js +70 -0
  7. package/dist/entities/Expenditure.d.ts +28 -0
  8. package/dist/entities/Expenditure.js +126 -0
  9. package/dist/entities/ExpenditureDetail.d.ts +17 -0
  10. package/dist/entities/ExpenditureDetail.js +70 -0
  11. package/dist/entities/Income.js +1 -1
  12. package/dist/entities/index.d.ts +26 -0
  13. package/dist/entities/index.js +65 -0
  14. package/dist/index.d.ts +1 -24
  15. package/dist/index.js +4 -49
  16. package/dist/models/apu/Budget.d.ts +2 -0
  17. package/dist/models/apu/Budget.js +5 -0
  18. package/dist/models/production/CropActivity.d.ts +2 -0
  19. package/dist/models/production/CropActivity.js +5 -0
  20. package/dist/models/production/CropLot.d.ts +2 -0
  21. package/dist/models/production/CropLot.js +5 -0
  22. package/dist/models/production/ProductionExpenditure.d.ts +24 -0
  23. package/dist/models/production/ProductionExpenditure.js +107 -0
  24. package/dist/models/production/ProductionExpenditureDetail.d.ts +17 -0
  25. package/dist/models/production/ProductionExpenditureDetail.js +70 -0
  26. package/dist/types/ExpenditureStatus.d.ts +6 -0
  27. package/dist/types/ExpenditureStatus.js +10 -0
  28. package/dist/types/ExpenditureType.d.ts +5 -0
  29. package/dist/types/ExpenditureType.js +9 -0
  30. package/dist/types/index.d.ts +2 -0
  31. package/dist/types/index.js +6 -1
  32. package/package.json +1 -1
  33. package/src/entities/Bank/TransactionBank.ts +12 -0
  34. package/src/entities/Expenditure.ts +108 -0
  35. package/src/entities/ExpenditureDetail.ts +52 -0
  36. package/src/entities/Income.ts +1 -1
  37. package/src/entities/index.ts +45 -0
  38. package/src/index.ts +5 -24
  39. package/src/models/apu/Budget.ts +4 -0
  40. package/src/models/production/CropActivity.ts +4 -0
  41. package/src/models/production/CropLot.ts +4 -0
  42. package/src/types/ExpenditureStatus.ts +6 -0
  43. package/src/types/ExpenditureType.ts +5 -0
  44. package/src/types/index.ts +5 -1
package/dist/index.js CHANGED
@@ -14,56 +14,11 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
14
  for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
15
  };
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
- exports.Income = exports.PaymentCfdi = exports.Payment = exports.InventoryImage = exports.SupplierImage = exports.BranchImage = exports.Branch = exports.InventoryMovement = exports.Inventory = exports.Product = exports.ProductImage = exports.TransactionBank = exports.BankAccount = exports.UnitOfMeasure = exports.CategoryForPlantType = exports.CategoryForCosting = exports.Supplier = exports.ContainerType = exports.InventoryItem = exports.ExpenseTransaction = exports.User = exports.ProjectOrder = exports.ExpenseType = exports.ExpenseDetail = void 0;
18
- var ExpenseDetail_1 = require("./entities/ExpenseDetail");
19
- Object.defineProperty(exports, "ExpenseDetail", { enumerable: true, get: function () { return ExpenseDetail_1.ExpenseDetail; } });
20
- var ExpenseType_1 = require("./entities/ExpenseType");
21
- Object.defineProperty(exports, "ExpenseType", { enumerable: true, get: function () { return ExpenseType_1.ExpenseType; } });
22
- var ProjectOrder_1 = require("./entities/ProjectOrder");
23
- Object.defineProperty(exports, "ProjectOrder", { enumerable: true, get: function () { return ProjectOrder_1.ProjectOrder; } });
24
- var User_1 = require("./entities/User");
25
- Object.defineProperty(exports, "User", { enumerable: true, get: function () { return User_1.User; } });
26
- var ExpenseTransaction_1 = require("./entities/ExpenseTransaction");
27
- Object.defineProperty(exports, "ExpenseTransaction", { enumerable: true, get: function () { return ExpenseTransaction_1.ExpenseTransaction; } });
28
- var InventoryItem_1 = require("./entities/InventoryItem");
29
- Object.defineProperty(exports, "InventoryItem", { enumerable: true, get: function () { return InventoryItem_1.InventoryItem; } });
30
- var ContainerType_1 = require("./entities/ContainerType");
31
- Object.defineProperty(exports, "ContainerType", { enumerable: true, get: function () { return ContainerType_1.ContainerType; } });
32
- var Suppliers_1 = require("./entities/Suppliers");
33
- Object.defineProperty(exports, "Supplier", { enumerable: true, get: function () { return Suppliers_1.Supplier; } });
34
- var CategoryForCosting_1 = require("./entities/CategoryForCosting");
35
- Object.defineProperty(exports, "CategoryForCosting", { enumerable: true, get: function () { return CategoryForCosting_1.CategoryForCosting; } });
36
- var CategoryForPlantType_1 = require("./entities/CategoryForPlantType");
37
- Object.defineProperty(exports, "CategoryForPlantType", { enumerable: true, get: function () { return CategoryForPlantType_1.CategoryForPlantType; } });
38
- var UnitOfMesure_1 = require("./entities/UnitOfMesure");
39
- Object.defineProperty(exports, "UnitOfMeasure", { enumerable: true, get: function () { return UnitOfMesure_1.UnitOfMeasure; } });
40
- var BankAccount_1 = require("./entities/Bank/BankAccount");
41
- Object.defineProperty(exports, "BankAccount", { enumerable: true, get: function () { return BankAccount_1.BankAccount; } });
42
- var TransactionBank_1 = require("./entities/Bank/TransactionBank");
43
- Object.defineProperty(exports, "TransactionBank", { enumerable: true, get: function () { return TransactionBank_1.TransactionBank; } });
44
- var ProductImage_1 = require("./entities/ProductImage");
45
- Object.defineProperty(exports, "ProductImage", { enumerable: true, get: function () { return ProductImage_1.ProductImage; } });
46
- var Products_1 = require("./entities/Products");
47
- Object.defineProperty(exports, "Product", { enumerable: true, get: function () { return Products_1.Product; } });
48
- var Inventory_1 = require("./entities/Inventory");
49
- Object.defineProperty(exports, "Inventory", { enumerable: true, get: function () { return Inventory_1.Inventory; } });
50
- var InventoryMovement_1 = require("./entities/InventoryMovement");
51
- Object.defineProperty(exports, "InventoryMovement", { enumerable: true, get: function () { return InventoryMovement_1.InventoryMovement; } });
52
- var Branches_1 = require("./entities/Branches");
53
- Object.defineProperty(exports, "Branch", { enumerable: true, get: function () { return Branches_1.Branch; } });
54
- var BranchImage_1 = require("./entities/BranchImage");
55
- Object.defineProperty(exports, "BranchImage", { enumerable: true, get: function () { return BranchImage_1.BranchImage; } });
56
- var SupplierImage_1 = require("./entities/SupplierImage");
57
- Object.defineProperty(exports, "SupplierImage", { enumerable: true, get: function () { return SupplierImage_1.SupplierImage; } });
58
- var InventoryImage_1 = require("./entities/InventoryImage");
59
- Object.defineProperty(exports, "InventoryImage", { enumerable: true, get: function () { return InventoryImage_1.InventoryImage; } });
60
- var Payment_1 = require("./entities/Payment");
61
- Object.defineProperty(exports, "Payment", { enumerable: true, get: function () { return Payment_1.Payment; } });
62
- var PaymentCfdi_1 = require("./entities/PaymentCfdi");
63
- Object.defineProperty(exports, "PaymentCfdi", { enumerable: true, get: function () { return PaymentCfdi_1.PaymentCfdi; } });
64
- var Income_1 = require("./entities/Income");
65
- Object.defineProperty(exports, "Income", { enumerable: true, get: function () { return Income_1.Income; } });
17
+ // Entities
18
+ __exportStar(require("./entities"), exports);
19
+ // Types
66
20
  __exportStar(require("./types"), exports);
21
+ // Models
67
22
  __exportStar(require("./models/technical-sheet"), exports);
68
23
  __exportStar(require("./models/apu"), exports);
69
24
  __exportStar(require("./models/production"), exports);
@@ -5,6 +5,7 @@ import { BudgetCancellationFolio } from "./BudgetCancellationFolio";
5
5
  import { Payment } from "../../entities/Payment";
6
6
  import { ExpenseTransaction } from "../../entities/ExpenseTransaction";
7
7
  import { Income } from "../../entities/Income";
8
+ import { Expenditure } from "../../entities/Expenditure";
8
9
  export declare class Budget implements ObjectLiteral {
9
10
  idBudget: number;
10
11
  project: Project;
@@ -23,4 +24,5 @@ export declare class Budget implements ObjectLiteral {
23
24
  payments?: Payment[];
24
25
  expenses?: ExpenseTransaction[];
25
26
  incomes?: Income[];
27
+ expenditures?: Expenditure[];
26
28
  }
@@ -18,6 +18,7 @@ const BudgetCancellationFolio_1 = require("./BudgetCancellationFolio");
18
18
  const Payment_1 = require("../../entities/Payment");
19
19
  const ExpenseTransaction_1 = require("../../entities/ExpenseTransaction");
20
20
  const Income_1 = require("../../entities/Income");
21
+ const Expenditure_1 = require("../../entities/Expenditure");
21
22
  let Budget = class Budget {
22
23
  };
23
24
  exports.Budget = Budget;
@@ -90,6 +91,10 @@ __decorate([
90
91
  (0, typeorm_1.OneToMany)(() => Income_1.Income, (income) => income.budget),
91
92
  __metadata("design:type", Array)
92
93
  ], Budget.prototype, "incomes", void 0);
94
+ __decorate([
95
+ (0, typeorm_1.OneToMany)(() => Expenditure_1.Expenditure, (expenditure) => expenditure.budget),
96
+ __metadata("design:type", Array)
97
+ ], Budget.prototype, "expenditures", void 0);
93
98
  exports.Budget = Budget = __decorate([
94
99
  (0, typeorm_1.Entity)("budgets"),
95
100
  (0, typeorm_1.Index)(["project"])
@@ -3,6 +3,7 @@ import { CropLot } from "./CropLot";
3
3
  import { CropActivityType } from "../../types/CropActivityType";
4
4
  import { UnitOfMeasure } from "../../entities/UnitOfMesure";
5
5
  import { CropExpense } from "./CropExpense";
6
+ import { Expenditure } from "../../entities/Expenditure";
6
7
  export declare class CropActivity implements ObjectLiteral {
7
8
  idCropActivity: number;
8
9
  cropLot: CropLot;
@@ -17,4 +18,5 @@ export declare class CropActivity implements ObjectLiteral {
17
18
  createdAt: Date;
18
19
  updatedAt: Date;
19
20
  expenses?: CropExpense[];
21
+ expenditures?: Expenditure[];
20
22
  }
@@ -15,6 +15,7 @@ const CropLot_1 = require("./CropLot");
15
15
  const CropActivityType_1 = require("../../types/CropActivityType");
16
16
  const UnitOfMesure_1 = require("../../entities/UnitOfMesure");
17
17
  const CropExpense_1 = require("./CropExpense");
18
+ const Expenditure_1 = require("../../entities/Expenditure");
18
19
  let CropActivity = class CropActivity {
19
20
  };
20
21
  exports.CropActivity = CropActivity;
@@ -78,6 +79,10 @@ __decorate([
78
79
  (0, typeorm_1.OneToMany)(() => CropExpense_1.CropExpense, (expense) => expense.cropActivity, { cascade: true }),
79
80
  __metadata("design:type", Array)
80
81
  ], CropActivity.prototype, "expenses", void 0);
82
+ __decorate([
83
+ (0, typeorm_1.OneToMany)(() => Expenditure_1.Expenditure, (expenditure) => expenditure.cropActivity),
84
+ __metadata("design:type", Array)
85
+ ], CropActivity.prototype, "expenditures", void 0);
81
86
  exports.CropActivity = CropActivity = __decorate([
82
87
  (0, typeorm_1.Entity)("crop_activities"),
83
88
  (0, typeorm_1.Index)(["cropLot", "activityDate"]),
@@ -7,6 +7,7 @@ import { CropStage } from "./CropStage";
7
7
  import { CropActivity } from "./CropActivity";
8
8
  import { CropExpense } from "./CropExpense";
9
9
  import { Harvest } from "./Harvest";
10
+ import { Expenditure } from "../../entities/Expenditure";
10
11
  export declare class CropLot implements ObjectLiteral {
11
12
  idCropLot: number;
12
13
  code: string;
@@ -30,4 +31,5 @@ export declare class CropLot implements ObjectLiteral {
30
31
  activities?: CropActivity[];
31
32
  expenses?: CropExpense[];
32
33
  harvests?: Harvest[];
34
+ expenditures?: Expenditure[];
33
35
  }
@@ -19,6 +19,7 @@ const CropStage_1 = require("./CropStage");
19
19
  const CropActivity_1 = require("./CropActivity");
20
20
  const CropExpense_1 = require("./CropExpense");
21
21
  const Harvest_1 = require("./Harvest");
22
+ const Expenditure_1 = require("../../entities/Expenditure");
22
23
  let CropLot = class CropLot {
23
24
  };
24
25
  exports.CropLot = CropLot;
@@ -123,6 +124,10 @@ __decorate([
123
124
  (0, typeorm_1.OneToMany)(() => Harvest_1.Harvest, (harvest) => harvest.cropLot, { cascade: true }),
124
125
  __metadata("design:type", Array)
125
126
  ], CropLot.prototype, "harvests", void 0);
127
+ __decorate([
128
+ (0, typeorm_1.OneToMany)(() => Expenditure_1.Expenditure, (expenditure) => expenditure.cropLot),
129
+ __metadata("design:type", Array)
130
+ ], CropLot.prototype, "expenditures", void 0);
126
131
  exports.CropLot = CropLot = __decorate([
127
132
  (0, typeorm_1.Entity)("crop_lots"),
128
133
  (0, typeorm_1.Index)(["code"], { unique: true }),
@@ -0,0 +1,24 @@
1
+ import { ObjectLiteral } from "typeorm";
2
+ import { CropLot } from "./CropLot";
3
+ import { CropActivity } from "./CropActivity";
4
+ import { TransactionBank } from "../../entities/Bank/TransactionBank";
5
+ import { ExpenditureStatus } from "../../types/ExpenditureStatus";
6
+ import { ProductionExpenditureDetail } from "./ProductionExpenditureDetail";
7
+ export declare class ProductionExpenditure implements ObjectLiteral {
8
+ idProductionExpenditure: number;
9
+ cropLot: CropLot;
10
+ cropActivity?: CropActivity | null;
11
+ code?: string | null;
12
+ description: string;
13
+ totalAmount: number;
14
+ expenditureDate: Date;
15
+ status: ExpenditureStatus;
16
+ paymentMethod?: string | null;
17
+ invoiceUuid?: string | null;
18
+ supplierName?: string | null;
19
+ notes?: string | null;
20
+ transactionBank?: TransactionBank | null;
21
+ createdAt: Date;
22
+ updatedAt: Date;
23
+ details?: ProductionExpenditureDetail[];
24
+ }
@@ -0,0 +1,107 @@
1
+ "use strict";
2
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
3
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
5
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
6
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
7
+ };
8
+ var __metadata = (this && this.__metadata) || function (k, v) {
9
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
10
+ };
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.ProductionExpenditure = void 0;
13
+ const typeorm_1 = require("typeorm");
14
+ const CropLot_1 = require("./CropLot");
15
+ const CropActivity_1 = require("./CropActivity");
16
+ const TransactionBank_1 = require("../../entities/Bank/TransactionBank");
17
+ const ExpenditureStatus_1 = require("../../types/ExpenditureStatus");
18
+ const ProductionExpenditureDetail_1 = require("./ProductionExpenditureDetail");
19
+ let ProductionExpenditure = class ProductionExpenditure {
20
+ };
21
+ exports.ProductionExpenditure = ProductionExpenditure;
22
+ __decorate([
23
+ (0, typeorm_1.PrimaryGeneratedColumn)("increment"),
24
+ __metadata("design:type", Number)
25
+ ], ProductionExpenditure.prototype, "idProductionExpenditure", void 0);
26
+ __decorate([
27
+ (0, typeorm_1.ManyToOne)(() => CropLot_1.CropLot, (cropLot) => cropLot.expenditures, {
28
+ nullable: false,
29
+ onDelete: "RESTRICT",
30
+ }),
31
+ (0, typeorm_1.JoinColumn)({ name: "idCropLot" }),
32
+ __metadata("design:type", CropLot_1.CropLot)
33
+ ], ProductionExpenditure.prototype, "cropLot", void 0);
34
+ __decorate([
35
+ (0, typeorm_1.ManyToOne)(() => CropActivity_1.CropActivity, (activity) => activity.expenditures, {
36
+ nullable: true,
37
+ onDelete: "SET NULL",
38
+ }),
39
+ (0, typeorm_1.JoinColumn)({ name: "idCropActivity" }),
40
+ __metadata("design:type", Object)
41
+ ], ProductionExpenditure.prototype, "cropActivity", void 0);
42
+ __decorate([
43
+ (0, typeorm_1.Column)("varchar", { length: 64, nullable: true, unique: true }),
44
+ __metadata("design:type", Object)
45
+ ], ProductionExpenditure.prototype, "code", void 0);
46
+ __decorate([
47
+ (0, typeorm_1.Column)("varchar", { length: 255, nullable: false }),
48
+ __metadata("design:type", String)
49
+ ], ProductionExpenditure.prototype, "description", void 0);
50
+ __decorate([
51
+ (0, typeorm_1.Column)("decimal", { precision: 14, scale: 2, nullable: false }),
52
+ __metadata("design:type", Number)
53
+ ], ProductionExpenditure.prototype, "totalAmount", void 0);
54
+ __decorate([
55
+ (0, typeorm_1.Column)("date", { nullable: false }),
56
+ __metadata("design:type", Date)
57
+ ], ProductionExpenditure.prototype, "expenditureDate", void 0);
58
+ __decorate([
59
+ (0, typeorm_1.Column)({
60
+ type: "enum",
61
+ enum: ExpenditureStatus_1.ExpenditureStatus,
62
+ default: ExpenditureStatus_1.ExpenditureStatus.PENDING,
63
+ }),
64
+ __metadata("design:type", String)
65
+ ], ProductionExpenditure.prototype, "status", void 0);
66
+ __decorate([
67
+ (0, typeorm_1.Column)("varchar", { length: 32, nullable: true }),
68
+ __metadata("design:type", Object)
69
+ ], ProductionExpenditure.prototype, "paymentMethod", void 0);
70
+ __decorate([
71
+ (0, typeorm_1.Column)("varchar", { length: 255, nullable: true }),
72
+ __metadata("design:type", Object)
73
+ ], ProductionExpenditure.prototype, "invoiceUuid", void 0);
74
+ __decorate([
75
+ (0, typeorm_1.Column)("varchar", { length: 255, nullable: true }),
76
+ __metadata("design:type", Object)
77
+ ], ProductionExpenditure.prototype, "supplierName", void 0);
78
+ __decorate([
79
+ (0, typeorm_1.Column)("text", { nullable: true }),
80
+ __metadata("design:type", Object)
81
+ ], ProductionExpenditure.prototype, "notes", void 0);
82
+ __decorate([
83
+ (0, typeorm_1.OneToOne)(() => TransactionBank_1.TransactionBank, { nullable: true, cascade: true }),
84
+ (0, typeorm_1.JoinColumn)({ name: "idTransactionBank" }),
85
+ __metadata("design:type", Object)
86
+ ], ProductionExpenditure.prototype, "transactionBank", void 0);
87
+ __decorate([
88
+ (0, typeorm_1.CreateDateColumn)({ type: "timestamp" }),
89
+ __metadata("design:type", Date)
90
+ ], ProductionExpenditure.prototype, "createdAt", void 0);
91
+ __decorate([
92
+ (0, typeorm_1.UpdateDateColumn)({ type: "timestamp" }),
93
+ __metadata("design:type", Date)
94
+ ], ProductionExpenditure.prototype, "updatedAt", void 0);
95
+ __decorate([
96
+ (0, typeorm_1.OneToMany)(() => ProductionExpenditureDetail_1.ProductionExpenditureDetail, (detail) => detail.productionExpenditure, {
97
+ cascade: true,
98
+ }),
99
+ __metadata("design:type", Array)
100
+ ], ProductionExpenditure.prototype, "details", void 0);
101
+ exports.ProductionExpenditure = ProductionExpenditure = __decorate([
102
+ (0, typeorm_1.Entity)("production_expenditures"),
103
+ (0, typeorm_1.Index)(["cropLot"]),
104
+ (0, typeorm_1.Index)(["cropActivity"]),
105
+ (0, typeorm_1.Index)(["expenditureDate"]),
106
+ (0, typeorm_1.Index)(["status"])
107
+ ], ProductionExpenditure);
@@ -0,0 +1,17 @@
1
+ import { ObjectLiteral } from "typeorm";
2
+ import { ProductionExpenditure } from "./ProductionExpenditure";
3
+ import { Resource } from "../apu/Resource";
4
+ import { Inventory } from "../../entities/Inventory";
5
+ import { UnitOfMeasure } from "../../entities/UnitOfMesure";
6
+ export declare class ProductionExpenditureDetail implements ObjectLiteral {
7
+ idProductionExpenditureDetail: number;
8
+ productionExpenditure: ProductionExpenditure;
9
+ concept: string;
10
+ quantity: number;
11
+ unitOfMeasure?: UnitOfMeasure | null;
12
+ unitPrice: number;
13
+ subtotal: number;
14
+ resource?: Resource | null;
15
+ inventory?: Inventory | null;
16
+ notes?: string | null;
17
+ }
@@ -0,0 +1,70 @@
1
+ "use strict";
2
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
3
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
5
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
6
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
7
+ };
8
+ var __metadata = (this && this.__metadata) || function (k, v) {
9
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
10
+ };
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.ProductionExpenditureDetail = void 0;
13
+ const typeorm_1 = require("typeorm");
14
+ const ProductionExpenditure_1 = require("./ProductionExpenditure");
15
+ const Resource_1 = require("../apu/Resource");
16
+ const Inventory_1 = require("../../entities/Inventory");
17
+ const UnitOfMesure_1 = require("../../entities/UnitOfMesure");
18
+ let ProductionExpenditureDetail = class ProductionExpenditureDetail {
19
+ };
20
+ exports.ProductionExpenditureDetail = ProductionExpenditureDetail;
21
+ __decorate([
22
+ (0, typeorm_1.PrimaryGeneratedColumn)("increment"),
23
+ __metadata("design:type", Number)
24
+ ], ProductionExpenditureDetail.prototype, "idProductionExpenditureDetail", void 0);
25
+ __decorate([
26
+ (0, typeorm_1.ManyToOne)(() => ProductionExpenditure_1.ProductionExpenditure, (expenditure) => expenditure.details, {
27
+ nullable: false,
28
+ onDelete: "CASCADE",
29
+ }),
30
+ (0, typeorm_1.JoinColumn)({ name: "idProductionExpenditure" }),
31
+ __metadata("design:type", ProductionExpenditure_1.ProductionExpenditure)
32
+ ], ProductionExpenditureDetail.prototype, "productionExpenditure", void 0);
33
+ __decorate([
34
+ (0, typeorm_1.Column)("varchar", { length: 255, nullable: false }),
35
+ __metadata("design:type", String)
36
+ ], ProductionExpenditureDetail.prototype, "concept", void 0);
37
+ __decorate([
38
+ (0, typeorm_1.Column)("decimal", { precision: 12, scale: 4, nullable: false, default: 1 }),
39
+ __metadata("design:type", Number)
40
+ ], ProductionExpenditureDetail.prototype, "quantity", void 0);
41
+ __decorate([
42
+ (0, typeorm_1.ManyToOne)(() => UnitOfMesure_1.UnitOfMeasure, { nullable: true, onDelete: "SET NULL" }),
43
+ (0, typeorm_1.JoinColumn)({ name: "idUnitOfMeasure" }),
44
+ __metadata("design:type", Object)
45
+ ], ProductionExpenditureDetail.prototype, "unitOfMeasure", void 0);
46
+ __decorate([
47
+ (0, typeorm_1.Column)("decimal", { precision: 14, scale: 4, nullable: false }),
48
+ __metadata("design:type", Number)
49
+ ], ProductionExpenditureDetail.prototype, "unitPrice", void 0);
50
+ __decorate([
51
+ (0, typeorm_1.Column)("decimal", { precision: 14, scale: 2, nullable: false }),
52
+ __metadata("design:type", Number)
53
+ ], ProductionExpenditureDetail.prototype, "subtotal", void 0);
54
+ __decorate([
55
+ (0, typeorm_1.ManyToOne)(() => Resource_1.Resource, { nullable: true, onDelete: "SET NULL" }),
56
+ (0, typeorm_1.JoinColumn)({ name: "idResource" }),
57
+ __metadata("design:type", Object)
58
+ ], ProductionExpenditureDetail.prototype, "resource", void 0);
59
+ __decorate([
60
+ (0, typeorm_1.ManyToOne)(() => Inventory_1.Inventory, { nullable: true, onDelete: "SET NULL" }),
61
+ (0, typeorm_1.JoinColumn)({ name: "idInventory" }),
62
+ __metadata("design:type", Object)
63
+ ], ProductionExpenditureDetail.prototype, "inventory", void 0);
64
+ __decorate([
65
+ (0, typeorm_1.Column)("text", { nullable: true }),
66
+ __metadata("design:type", Object)
67
+ ], ProductionExpenditureDetail.prototype, "notes", void 0);
68
+ exports.ProductionExpenditureDetail = ProductionExpenditureDetail = __decorate([
69
+ (0, typeorm_1.Entity)("production_expenditure_details")
70
+ ], ProductionExpenditureDetail);
@@ -0,0 +1,6 @@
1
+ export declare enum ExpenditureStatus {
2
+ PENDING = "PENDING",
3
+ APPROVED = "APPROVED",
4
+ PAID = "PAID",
5
+ CANCELLED = "CANCELLED"
6
+ }
@@ -0,0 +1,10 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ExpenditureStatus = void 0;
4
+ var ExpenditureStatus;
5
+ (function (ExpenditureStatus) {
6
+ ExpenditureStatus["PENDING"] = "PENDING";
7
+ ExpenditureStatus["APPROVED"] = "APPROVED";
8
+ ExpenditureStatus["PAID"] = "PAID";
9
+ ExpenditureStatus["CANCELLED"] = "CANCELLED";
10
+ })(ExpenditureStatus || (exports.ExpenditureStatus = ExpenditureStatus = {}));
@@ -0,0 +1,5 @@
1
+ export declare enum ExpenditureType {
2
+ BUDGET_EXPENSE = "BUDGET_EXPENSE",
3
+ PRODUCTION_EXPENSE = "PRODUCTION_EXPENSE",
4
+ OTHER = "OTHER"
5
+ }
@@ -0,0 +1,9 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ExpenditureType = void 0;
4
+ var ExpenditureType;
5
+ (function (ExpenditureType) {
6
+ ExpenditureType["BUDGET_EXPENSE"] = "BUDGET_EXPENSE";
7
+ ExpenditureType["PRODUCTION_EXPENSE"] = "PRODUCTION_EXPENSE";
8
+ ExpenditureType["OTHER"] = "OTHER";
9
+ })(ExpenditureType || (exports.ExpenditureType = ExpenditureType = {}));
@@ -9,3 +9,5 @@ export { CropActivityType } from "./CropActivityType";
9
9
  export { QualityGrade } from "./QualityGrade";
10
10
  export { IncomeType } from "./IncomeType";
11
11
  export { IncomeStatus } from "./IncomeStatus";
12
+ export { ExpenditureType } from "./ExpenditureType";
13
+ export { ExpenditureStatus } from "./ExpenditureStatus";
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.IncomeStatus = exports.IncomeType = exports.QualityGrade = exports.CropActivityType = exports.GrowthStage = exports.CropLotStatus = exports.MovementType = void 0;
3
+ exports.ExpenditureStatus = exports.ExpenditureType = 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
6
  // Production enums
@@ -17,3 +17,8 @@ var IncomeType_1 = require("./IncomeType");
17
17
  Object.defineProperty(exports, "IncomeType", { enumerable: true, get: function () { return IncomeType_1.IncomeType; } });
18
18
  var IncomeStatus_1 = require("./IncomeStatus");
19
19
  Object.defineProperty(exports, "IncomeStatus", { enumerable: true, get: function () { return IncomeStatus_1.IncomeStatus; } });
20
+ // Expenditure enums
21
+ var ExpenditureType_1 = require("./ExpenditureType");
22
+ Object.defineProperty(exports, "ExpenditureType", { enumerable: true, get: function () { return ExpenditureType_1.ExpenditureType; } });
23
+ var ExpenditureStatus_1 = require("./ExpenditureStatus");
24
+ Object.defineProperty(exports, "ExpenditureStatus", { enumerable: true, get: function () { return ExpenditureStatus_1.ExpenditureStatus; } });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "proflores-db-model",
3
- "version": "0.2.53",
3
+ "version": "0.2.55",
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",
@@ -10,6 +10,8 @@ import {
10
10
  import { BankAccount } from "./BankAccount";
11
11
  import { ExpenseTransaction } from "../ExpenseTransaction";
12
12
  import { Payment } from "../Payment";
13
+ import { Income } from "../Income";
14
+ import { Expenditure } from "../Expenditure";
13
15
 
14
16
  @Entity("transactions_bank")
15
17
  export class TransactionBank implements ObjectLiteral {
@@ -40,5 +42,15 @@ import {
40
42
  nullable: true
41
43
  })
42
44
  payment?: Payment;
45
+
46
+ @OneToOne(() => Income, (income) => income.transactionBank, {
47
+ nullable: true
48
+ })
49
+ income?: Income;
50
+
51
+ @OneToOne(() => Expenditure, (expenditure) => expenditure.transactionBank, {
52
+ nullable: true
53
+ })
54
+ expenditure?: Expenditure;
43
55
  }
44
56
 
@@ -0,0 +1,108 @@
1
+ import {
2
+ Entity,
3
+ PrimaryGeneratedColumn,
4
+ Column,
5
+ ManyToOne,
6
+ OneToMany,
7
+ OneToOne,
8
+ JoinColumn,
9
+ ObjectLiteral,
10
+ Index,
11
+ CreateDateColumn,
12
+ UpdateDateColumn,
13
+ } from "typeorm";
14
+ import { Budget } from "../models/apu/Budget";
15
+ import { CropLot } from "../models/production/CropLot";
16
+ import { CropActivity } from "../models/production/CropActivity";
17
+ import { TransactionBank } from "./Bank/TransactionBank";
18
+ import { ExpenditureType } from "../types/ExpenditureType";
19
+ import { ExpenditureStatus } from "../types/ExpenditureStatus";
20
+ import { ExpenditureDetail } from "./ExpenditureDetail";
21
+
22
+ @Entity("expenditures")
23
+ @Index(["expenditureType"])
24
+ @Index(["expenditureDate"])
25
+ @Index(["status"])
26
+ @Index(["budget"])
27
+ @Index(["cropLot"])
28
+ export class Expenditure implements ObjectLiteral {
29
+ @PrimaryGeneratedColumn("increment")
30
+ idExpenditure!: number;
31
+
32
+ @Column({
33
+ type: "enum",
34
+ enum: ExpenditureType,
35
+ default: ExpenditureType.OTHER,
36
+ })
37
+ expenditureType!: ExpenditureType;
38
+
39
+ @Column("varchar", { length: 64, nullable: true, unique: true })
40
+ code?: string | null;
41
+
42
+ @Column("varchar", { length: 255, nullable: false })
43
+ description!: string;
44
+
45
+ @Column("decimal", { precision: 14, scale: 2, nullable: false })
46
+ totalAmount!: number;
47
+
48
+ @Column("date", { nullable: false })
49
+ expenditureDate!: Date;
50
+
51
+ @Column({
52
+ type: "enum",
53
+ enum: ExpenditureStatus,
54
+ default: ExpenditureStatus.PENDING,
55
+ })
56
+ status!: ExpenditureStatus;
57
+
58
+ // Relación con Budget (para BUDGET_EXPENSE)
59
+ @ManyToOne(() => Budget, (budget) => budget.expenditures, {
60
+ nullable: true,
61
+ onDelete: "SET NULL",
62
+ })
63
+ @JoinColumn({ name: "idBudget" })
64
+ budget?: Budget | null;
65
+
66
+ // Relación con CropLot (para PRODUCTION_EXPENSE)
67
+ @ManyToOne(() => CropLot, (cropLot) => cropLot.expenditures, {
68
+ nullable: true,
69
+ onDelete: "SET NULL",
70
+ })
71
+ @JoinColumn({ name: "idCropLot" })
72
+ cropLot?: CropLot | null;
73
+
74
+ // Relación con CropActivity (opcional, para gastos de actividad específica)
75
+ @ManyToOne(() => CropActivity, (activity) => activity.expenditures, {
76
+ nullable: true,
77
+ onDelete: "SET NULL",
78
+ })
79
+ @JoinColumn({ name: "idCropActivity" })
80
+ cropActivity?: CropActivity | null;
81
+
82
+ @Column("varchar", { length: 32, nullable: true })
83
+ paymentMethod?: string | null;
84
+
85
+ @Column("varchar", { length: 255, nullable: true })
86
+ invoiceUuid?: string | null;
87
+
88
+ @Column("varchar", { length: 255, nullable: true })
89
+ supplierName?: string | null;
90
+
91
+ @Column("text", { nullable: true })
92
+ notes?: string | null;
93
+
94
+ @OneToOne(() => TransactionBank, (tb) => tb.expenditure, { nullable: true, cascade: true })
95
+ @JoinColumn({ name: "idTransactionBank" })
96
+ transactionBank?: TransactionBank | null;
97
+
98
+ @CreateDateColumn({ type: "timestamp" })
99
+ createdAt!: Date;
100
+
101
+ @UpdateDateColumn({ type: "timestamp" })
102
+ updatedAt!: Date;
103
+
104
+ @OneToMany(() => ExpenditureDetail, (detail) => detail.expenditure, {
105
+ cascade: true,
106
+ })
107
+ details?: ExpenditureDetail[];
108
+ }
@@ -0,0 +1,52 @@
1
+ import {
2
+ Entity,
3
+ PrimaryGeneratedColumn,
4
+ Column,
5
+ ManyToOne,
6
+ JoinColumn,
7
+ ObjectLiteral,
8
+ } from "typeorm";
9
+ import { Expenditure } from "./Expenditure";
10
+ import { Resource } from "../models/apu/Resource";
11
+ import { Inventory } from "./Inventory";
12
+ import { UnitOfMeasure } from "./UnitOfMesure";
13
+
14
+ @Entity("expenditure_details")
15
+ export class ExpenditureDetail implements ObjectLiteral {
16
+ @PrimaryGeneratedColumn("increment")
17
+ idExpenditureDetail!: number;
18
+
19
+ @ManyToOne(() => Expenditure, (expenditure) => expenditure.details, {
20
+ nullable: false,
21
+ onDelete: "CASCADE",
22
+ })
23
+ @JoinColumn({ name: "idExpenditure" })
24
+ expenditure!: Expenditure;
25
+
26
+ @Column("varchar", { length: 255, nullable: false })
27
+ concept!: string;
28
+
29
+ @Column("decimal", { precision: 12, scale: 4, nullable: false, default: 1 })
30
+ quantity!: number;
31
+
32
+ @ManyToOne(() => UnitOfMeasure, { nullable: true, onDelete: "SET NULL" })
33
+ @JoinColumn({ name: "idUnitOfMeasure" })
34
+ unitOfMeasure?: UnitOfMeasure | null;
35
+
36
+ @Column("decimal", { precision: 14, scale: 4, nullable: false })
37
+ unitPrice!: number;
38
+
39
+ @Column("decimal", { precision: 14, scale: 2, nullable: false })
40
+ subtotal!: number;
41
+
42
+ @ManyToOne(() => Resource, { nullable: true, onDelete: "SET NULL" })
43
+ @JoinColumn({ name: "idResource" })
44
+ resource?: Resource | null;
45
+
46
+ @ManyToOne(() => Inventory, { nullable: true, onDelete: "SET NULL" })
47
+ @JoinColumn({ name: "idInventory" })
48
+ inventory?: Inventory | null;
49
+
50
+ @Column("text", { nullable: true })
51
+ notes?: string | null;
52
+ }
@@ -84,7 +84,7 @@ export class Income implements ObjectLiteral {
84
84
  @Column("varchar", { length: 255, nullable: true })
85
85
  invoiceUuid?: string | null;
86
86
 
87
- @OneToOne(() => TransactionBank, { nullable: true, cascade: true })
87
+ @OneToOne(() => TransactionBank, (tb) => tb.income, { nullable: true, cascade: true })
88
88
  @JoinColumn({ name: "idTransactionBank" })
89
89
  transactionBank?: TransactionBank | null;
90
90