proflores-db-model 0.2.54 → 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 (41) 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 +2 -0
  13. package/dist/entities/index.js +6 -1
  14. package/dist/models/apu/Budget.d.ts +2 -0
  15. package/dist/models/apu/Budget.js +5 -0
  16. package/dist/models/production/CropActivity.d.ts +2 -0
  17. package/dist/models/production/CropActivity.js +5 -0
  18. package/dist/models/production/CropLot.d.ts +2 -0
  19. package/dist/models/production/CropLot.js +5 -0
  20. package/dist/models/production/ProductionExpenditure.d.ts +24 -0
  21. package/dist/models/production/ProductionExpenditure.js +107 -0
  22. package/dist/models/production/ProductionExpenditureDetail.d.ts +17 -0
  23. package/dist/models/production/ProductionExpenditureDetail.js +70 -0
  24. package/dist/types/ExpenditureStatus.d.ts +6 -0
  25. package/dist/types/ExpenditureStatus.js +10 -0
  26. package/dist/types/ExpenditureType.d.ts +5 -0
  27. package/dist/types/ExpenditureType.js +9 -0
  28. package/dist/types/index.d.ts +2 -0
  29. package/dist/types/index.js +6 -1
  30. package/package.json +1 -1
  31. package/src/entities/Bank/TransactionBank.ts +12 -0
  32. package/src/entities/Expenditure.ts +108 -0
  33. package/src/entities/ExpenditureDetail.ts +52 -0
  34. package/src/entities/Income.ts +1 -1
  35. package/src/entities/index.ts +4 -0
  36. package/src/models/apu/Budget.ts +4 -0
  37. package/src/models/production/CropActivity.ts +4 -0
  38. package/src/models/production/CropLot.ts +4 -0
  39. package/src/types/ExpenditureStatus.ts +6 -0
  40. package/src/types/ExpenditureType.ts +5 -0
  41. package/src/types/index.ts +5 -1
@@ -2,6 +2,8 @@ import { ObjectLiteral } from "typeorm";
2
2
  import { BankAccount } from "./BankAccount";
3
3
  import { ExpenseTransaction } from "../ExpenseTransaction";
4
4
  import { Payment } from "../Payment";
5
+ import { Income } from "../Income";
6
+ import { Expenditure } from "../Expenditure";
5
7
  export declare class TransactionBank implements ObjectLiteral {
6
8
  idTransactionBank: number;
7
9
  amount: number;
@@ -10,4 +12,6 @@ export declare class TransactionBank implements ObjectLiteral {
10
12
  bankAccount: BankAccount;
11
13
  expenseTransaction?: ExpenseTransaction;
12
14
  payment?: Payment;
15
+ income?: Income;
16
+ expenditure?: Expenditure;
13
17
  }
@@ -14,6 +14,8 @@ const typeorm_1 = require("typeorm");
14
14
  const BankAccount_1 = require("./BankAccount");
15
15
  const ExpenseTransaction_1 = require("../ExpenseTransaction");
16
16
  const Payment_1 = require("../Payment");
17
+ const Income_1 = require("../Income");
18
+ const Expenditure_1 = require("../Expenditure");
17
19
  let TransactionBank = class TransactionBank {
18
20
  };
19
21
  exports.TransactionBank = TransactionBank;
@@ -53,6 +55,18 @@ __decorate([
53
55
  }),
54
56
  __metadata("design:type", Payment_1.Payment)
55
57
  ], TransactionBank.prototype, "payment", void 0);
58
+ __decorate([
59
+ (0, typeorm_1.OneToOne)(() => Income_1.Income, (income) => income.transactionBank, {
60
+ nullable: true
61
+ }),
62
+ __metadata("design:type", Income_1.Income)
63
+ ], TransactionBank.prototype, "income", void 0);
64
+ __decorate([
65
+ (0, typeorm_1.OneToOne)(() => Expenditure_1.Expenditure, (expenditure) => expenditure.transactionBank, {
66
+ nullable: true
67
+ }),
68
+ __metadata("design:type", Expenditure_1.Expenditure)
69
+ ], TransactionBank.prototype, "expenditure", void 0);
56
70
  exports.TransactionBank = TransactionBank = __decorate([
57
71
  (0, typeorm_1.Entity)("transactions_bank")
58
72
  ], TransactionBank);
@@ -0,0 +1,22 @@
1
+ import { ObjectLiteral } from "typeorm";
2
+ import { Budget } from "../models/apu/Budget";
3
+ import { TransactionBank } from "./Bank/TransactionBank";
4
+ import { ExpenditureStatus } from "../types/ExpenditureStatus";
5
+ import { BudgetExpenditureDetail } from "./BudgetExpenditureDetail";
6
+ export declare class BudgetExpenditure implements ObjectLiteral {
7
+ idBudgetExpenditure: number;
8
+ budget: Budget;
9
+ code?: string | null;
10
+ description: string;
11
+ totalAmount: number;
12
+ expenditureDate: Date;
13
+ status: ExpenditureStatus;
14
+ paymentMethod?: string | null;
15
+ invoiceUuid?: string | null;
16
+ supplierName?: string | null;
17
+ notes?: string | null;
18
+ transactionBank?: TransactionBank | null;
19
+ createdAt: Date;
20
+ updatedAt: Date;
21
+ details?: BudgetExpenditureDetail[];
22
+ }
@@ -0,0 +1,97 @@
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.BudgetExpenditure = void 0;
13
+ const typeorm_1 = require("typeorm");
14
+ const Budget_1 = require("../models/apu/Budget");
15
+ const TransactionBank_1 = require("./Bank/TransactionBank");
16
+ const ExpenditureStatus_1 = require("../types/ExpenditureStatus");
17
+ const BudgetExpenditureDetail_1 = require("./BudgetExpenditureDetail");
18
+ let BudgetExpenditure = class BudgetExpenditure {
19
+ };
20
+ exports.BudgetExpenditure = BudgetExpenditure;
21
+ __decorate([
22
+ (0, typeorm_1.PrimaryGeneratedColumn)("increment"),
23
+ __metadata("design:type", Number)
24
+ ], BudgetExpenditure.prototype, "idBudgetExpenditure", void 0);
25
+ __decorate([
26
+ (0, typeorm_1.ManyToOne)(() => Budget_1.Budget, (budget) => budget.expenditures, {
27
+ nullable: false,
28
+ onDelete: "RESTRICT",
29
+ }),
30
+ (0, typeorm_1.JoinColumn)({ name: "idBudget" }),
31
+ __metadata("design:type", Budget_1.Budget)
32
+ ], BudgetExpenditure.prototype, "budget", void 0);
33
+ __decorate([
34
+ (0, typeorm_1.Column)("varchar", { length: 64, nullable: true, unique: true }),
35
+ __metadata("design:type", Object)
36
+ ], BudgetExpenditure.prototype, "code", void 0);
37
+ __decorate([
38
+ (0, typeorm_1.Column)("varchar", { length: 255, nullable: false }),
39
+ __metadata("design:type", String)
40
+ ], BudgetExpenditure.prototype, "description", void 0);
41
+ __decorate([
42
+ (0, typeorm_1.Column)("decimal", { precision: 14, scale: 2, nullable: false }),
43
+ __metadata("design:type", Number)
44
+ ], BudgetExpenditure.prototype, "totalAmount", void 0);
45
+ __decorate([
46
+ (0, typeorm_1.Column)("date", { nullable: false }),
47
+ __metadata("design:type", Date)
48
+ ], BudgetExpenditure.prototype, "expenditureDate", void 0);
49
+ __decorate([
50
+ (0, typeorm_1.Column)({
51
+ type: "enum",
52
+ enum: ExpenditureStatus_1.ExpenditureStatus,
53
+ default: ExpenditureStatus_1.ExpenditureStatus.PENDING,
54
+ }),
55
+ __metadata("design:type", String)
56
+ ], BudgetExpenditure.prototype, "status", void 0);
57
+ __decorate([
58
+ (0, typeorm_1.Column)("varchar", { length: 32, nullable: true }),
59
+ __metadata("design:type", Object)
60
+ ], BudgetExpenditure.prototype, "paymentMethod", void 0);
61
+ __decorate([
62
+ (0, typeorm_1.Column)("varchar", { length: 255, nullable: true }),
63
+ __metadata("design:type", Object)
64
+ ], BudgetExpenditure.prototype, "invoiceUuid", void 0);
65
+ __decorate([
66
+ (0, typeorm_1.Column)("varchar", { length: 255, nullable: true }),
67
+ __metadata("design:type", Object)
68
+ ], BudgetExpenditure.prototype, "supplierName", void 0);
69
+ __decorate([
70
+ (0, typeorm_1.Column)("text", { nullable: true }),
71
+ __metadata("design:type", Object)
72
+ ], BudgetExpenditure.prototype, "notes", void 0);
73
+ __decorate([
74
+ (0, typeorm_1.OneToOne)(() => TransactionBank_1.TransactionBank, { nullable: true, cascade: true }),
75
+ (0, typeorm_1.JoinColumn)({ name: "idTransactionBank" }),
76
+ __metadata("design:type", Object)
77
+ ], BudgetExpenditure.prototype, "transactionBank", void 0);
78
+ __decorate([
79
+ (0, typeorm_1.CreateDateColumn)({ type: "timestamp" }),
80
+ __metadata("design:type", Date)
81
+ ], BudgetExpenditure.prototype, "createdAt", void 0);
82
+ __decorate([
83
+ (0, typeorm_1.UpdateDateColumn)({ type: "timestamp" }),
84
+ __metadata("design:type", Date)
85
+ ], BudgetExpenditure.prototype, "updatedAt", void 0);
86
+ __decorate([
87
+ (0, typeorm_1.OneToMany)(() => BudgetExpenditureDetail_1.BudgetExpenditureDetail, (detail) => detail.budgetExpenditure, {
88
+ cascade: true,
89
+ }),
90
+ __metadata("design:type", Array)
91
+ ], BudgetExpenditure.prototype, "details", void 0);
92
+ exports.BudgetExpenditure = BudgetExpenditure = __decorate([
93
+ (0, typeorm_1.Entity)("budget_expenditures"),
94
+ (0, typeorm_1.Index)(["budget"]),
95
+ (0, typeorm_1.Index)(["expenditureDate"]),
96
+ (0, typeorm_1.Index)(["status"])
97
+ ], BudgetExpenditure);
@@ -0,0 +1,17 @@
1
+ import { ObjectLiteral } from "typeorm";
2
+ import { BudgetExpenditure } from "./BudgetExpenditure";
3
+ import { Resource } from "../models/apu/Resource";
4
+ import { Inventory } from "./Inventory";
5
+ import { UnitOfMeasure } from "./UnitOfMesure";
6
+ export declare class BudgetExpenditureDetail implements ObjectLiteral {
7
+ idBudgetExpenditureDetail: number;
8
+ budgetExpenditure: BudgetExpenditure;
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.BudgetExpenditureDetail = void 0;
13
+ const typeorm_1 = require("typeorm");
14
+ const BudgetExpenditure_1 = require("./BudgetExpenditure");
15
+ const Resource_1 = require("../models/apu/Resource");
16
+ const Inventory_1 = require("./Inventory");
17
+ const UnitOfMesure_1 = require("./UnitOfMesure");
18
+ let BudgetExpenditureDetail = class BudgetExpenditureDetail {
19
+ };
20
+ exports.BudgetExpenditureDetail = BudgetExpenditureDetail;
21
+ __decorate([
22
+ (0, typeorm_1.PrimaryGeneratedColumn)("increment"),
23
+ __metadata("design:type", Number)
24
+ ], BudgetExpenditureDetail.prototype, "idBudgetExpenditureDetail", void 0);
25
+ __decorate([
26
+ (0, typeorm_1.ManyToOne)(() => BudgetExpenditure_1.BudgetExpenditure, (expenditure) => expenditure.details, {
27
+ nullable: false,
28
+ onDelete: "CASCADE",
29
+ }),
30
+ (0, typeorm_1.JoinColumn)({ name: "idBudgetExpenditure" }),
31
+ __metadata("design:type", BudgetExpenditure_1.BudgetExpenditure)
32
+ ], BudgetExpenditureDetail.prototype, "budgetExpenditure", void 0);
33
+ __decorate([
34
+ (0, typeorm_1.Column)("varchar", { length: 255, nullable: false }),
35
+ __metadata("design:type", String)
36
+ ], BudgetExpenditureDetail.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
+ ], BudgetExpenditureDetail.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
+ ], BudgetExpenditureDetail.prototype, "unitOfMeasure", void 0);
46
+ __decorate([
47
+ (0, typeorm_1.Column)("decimal", { precision: 14, scale: 4, nullable: false }),
48
+ __metadata("design:type", Number)
49
+ ], BudgetExpenditureDetail.prototype, "unitPrice", void 0);
50
+ __decorate([
51
+ (0, typeorm_1.Column)("decimal", { precision: 14, scale: 2, nullable: false }),
52
+ __metadata("design:type", Number)
53
+ ], BudgetExpenditureDetail.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
+ ], BudgetExpenditureDetail.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
+ ], BudgetExpenditureDetail.prototype, "inventory", void 0);
64
+ __decorate([
65
+ (0, typeorm_1.Column)("text", { nullable: true }),
66
+ __metadata("design:type", Object)
67
+ ], BudgetExpenditureDetail.prototype, "notes", void 0);
68
+ exports.BudgetExpenditureDetail = BudgetExpenditureDetail = __decorate([
69
+ (0, typeorm_1.Entity)("budget_expenditure_details")
70
+ ], BudgetExpenditureDetail);
@@ -0,0 +1,28 @@
1
+ import { ObjectLiteral } from "typeorm";
2
+ import { Budget } from "../models/apu/Budget";
3
+ import { CropLot } from "../models/production/CropLot";
4
+ import { CropActivity } from "../models/production/CropActivity";
5
+ import { TransactionBank } from "./Bank/TransactionBank";
6
+ import { ExpenditureType } from "../types/ExpenditureType";
7
+ import { ExpenditureStatus } from "../types/ExpenditureStatus";
8
+ import { ExpenditureDetail } from "./ExpenditureDetail";
9
+ export declare class Expenditure implements ObjectLiteral {
10
+ idExpenditure: number;
11
+ expenditureType: ExpenditureType;
12
+ code?: string | null;
13
+ description: string;
14
+ totalAmount: number;
15
+ expenditureDate: Date;
16
+ status: ExpenditureStatus;
17
+ budget?: Budget | null;
18
+ cropLot?: CropLot | null;
19
+ cropActivity?: CropActivity | null;
20
+ paymentMethod?: string | null;
21
+ invoiceUuid?: string | null;
22
+ supplierName?: string | null;
23
+ notes?: string | null;
24
+ transactionBank?: TransactionBank | null;
25
+ createdAt: Date;
26
+ updatedAt: Date;
27
+ details?: ExpenditureDetail[];
28
+ }
@@ -0,0 +1,126 @@
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.Expenditure = void 0;
13
+ const typeorm_1 = require("typeorm");
14
+ const Budget_1 = require("../models/apu/Budget");
15
+ const CropLot_1 = require("../models/production/CropLot");
16
+ const CropActivity_1 = require("../models/production/CropActivity");
17
+ const TransactionBank_1 = require("./Bank/TransactionBank");
18
+ const ExpenditureType_1 = require("../types/ExpenditureType");
19
+ const ExpenditureStatus_1 = require("../types/ExpenditureStatus");
20
+ const ExpenditureDetail_1 = require("./ExpenditureDetail");
21
+ let Expenditure = class Expenditure {
22
+ };
23
+ exports.Expenditure = Expenditure;
24
+ __decorate([
25
+ (0, typeorm_1.PrimaryGeneratedColumn)("increment"),
26
+ __metadata("design:type", Number)
27
+ ], Expenditure.prototype, "idExpenditure", void 0);
28
+ __decorate([
29
+ (0, typeorm_1.Column)({
30
+ type: "enum",
31
+ enum: ExpenditureType_1.ExpenditureType,
32
+ default: ExpenditureType_1.ExpenditureType.OTHER,
33
+ }),
34
+ __metadata("design:type", String)
35
+ ], Expenditure.prototype, "expenditureType", void 0);
36
+ __decorate([
37
+ (0, typeorm_1.Column)("varchar", { length: 64, nullable: true, unique: true }),
38
+ __metadata("design:type", Object)
39
+ ], Expenditure.prototype, "code", void 0);
40
+ __decorate([
41
+ (0, typeorm_1.Column)("varchar", { length: 255, nullable: false }),
42
+ __metadata("design:type", String)
43
+ ], Expenditure.prototype, "description", void 0);
44
+ __decorate([
45
+ (0, typeorm_1.Column)("decimal", { precision: 14, scale: 2, nullable: false }),
46
+ __metadata("design:type", Number)
47
+ ], Expenditure.prototype, "totalAmount", void 0);
48
+ __decorate([
49
+ (0, typeorm_1.Column)("date", { nullable: false }),
50
+ __metadata("design:type", Date)
51
+ ], Expenditure.prototype, "expenditureDate", void 0);
52
+ __decorate([
53
+ (0, typeorm_1.Column)({
54
+ type: "enum",
55
+ enum: ExpenditureStatus_1.ExpenditureStatus,
56
+ default: ExpenditureStatus_1.ExpenditureStatus.PENDING,
57
+ }),
58
+ __metadata("design:type", String)
59
+ ], Expenditure.prototype, "status", void 0);
60
+ __decorate([
61
+ (0, typeorm_1.ManyToOne)(() => Budget_1.Budget, (budget) => budget.expenditures, {
62
+ nullable: true,
63
+ onDelete: "SET NULL",
64
+ }),
65
+ (0, typeorm_1.JoinColumn)({ name: "idBudget" }),
66
+ __metadata("design:type", Object)
67
+ ], Expenditure.prototype, "budget", void 0);
68
+ __decorate([
69
+ (0, typeorm_1.ManyToOne)(() => CropLot_1.CropLot, (cropLot) => cropLot.expenditures, {
70
+ nullable: true,
71
+ onDelete: "SET NULL",
72
+ }),
73
+ (0, typeorm_1.JoinColumn)({ name: "idCropLot" }),
74
+ __metadata("design:type", Object)
75
+ ], Expenditure.prototype, "cropLot", void 0);
76
+ __decorate([
77
+ (0, typeorm_1.ManyToOne)(() => CropActivity_1.CropActivity, (activity) => activity.expenditures, {
78
+ nullable: true,
79
+ onDelete: "SET NULL",
80
+ }),
81
+ (0, typeorm_1.JoinColumn)({ name: "idCropActivity" }),
82
+ __metadata("design:type", Object)
83
+ ], Expenditure.prototype, "cropActivity", void 0);
84
+ __decorate([
85
+ (0, typeorm_1.Column)("varchar", { length: 32, nullable: true }),
86
+ __metadata("design:type", Object)
87
+ ], Expenditure.prototype, "paymentMethod", void 0);
88
+ __decorate([
89
+ (0, typeorm_1.Column)("varchar", { length: 255, nullable: true }),
90
+ __metadata("design:type", Object)
91
+ ], Expenditure.prototype, "invoiceUuid", void 0);
92
+ __decorate([
93
+ (0, typeorm_1.Column)("varchar", { length: 255, nullable: true }),
94
+ __metadata("design:type", Object)
95
+ ], Expenditure.prototype, "supplierName", void 0);
96
+ __decorate([
97
+ (0, typeorm_1.Column)("text", { nullable: true }),
98
+ __metadata("design:type", Object)
99
+ ], Expenditure.prototype, "notes", void 0);
100
+ __decorate([
101
+ (0, typeorm_1.OneToOne)(() => TransactionBank_1.TransactionBank, (tb) => tb.expenditure, { nullable: true, cascade: true }),
102
+ (0, typeorm_1.JoinColumn)({ name: "idTransactionBank" }),
103
+ __metadata("design:type", Object)
104
+ ], Expenditure.prototype, "transactionBank", void 0);
105
+ __decorate([
106
+ (0, typeorm_1.CreateDateColumn)({ type: "timestamp" }),
107
+ __metadata("design:type", Date)
108
+ ], Expenditure.prototype, "createdAt", void 0);
109
+ __decorate([
110
+ (0, typeorm_1.UpdateDateColumn)({ type: "timestamp" }),
111
+ __metadata("design:type", Date)
112
+ ], Expenditure.prototype, "updatedAt", void 0);
113
+ __decorate([
114
+ (0, typeorm_1.OneToMany)(() => ExpenditureDetail_1.ExpenditureDetail, (detail) => detail.expenditure, {
115
+ cascade: true,
116
+ }),
117
+ __metadata("design:type", Array)
118
+ ], Expenditure.prototype, "details", void 0);
119
+ exports.Expenditure = Expenditure = __decorate([
120
+ (0, typeorm_1.Entity)("expenditures"),
121
+ (0, typeorm_1.Index)(["expenditureType"]),
122
+ (0, typeorm_1.Index)(["expenditureDate"]),
123
+ (0, typeorm_1.Index)(["status"]),
124
+ (0, typeorm_1.Index)(["budget"]),
125
+ (0, typeorm_1.Index)(["cropLot"])
126
+ ], Expenditure);
@@ -0,0 +1,17 @@
1
+ import { ObjectLiteral } from "typeorm";
2
+ import { Expenditure } from "./Expenditure";
3
+ import { Resource } from "../models/apu/Resource";
4
+ import { Inventory } from "./Inventory";
5
+ import { UnitOfMeasure } from "./UnitOfMesure";
6
+ export declare class ExpenditureDetail implements ObjectLiteral {
7
+ idExpenditureDetail: number;
8
+ expenditure: Expenditure;
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.ExpenditureDetail = void 0;
13
+ const typeorm_1 = require("typeorm");
14
+ const Expenditure_1 = require("./Expenditure");
15
+ const Resource_1 = require("../models/apu/Resource");
16
+ const Inventory_1 = require("./Inventory");
17
+ const UnitOfMesure_1 = require("./UnitOfMesure");
18
+ let ExpenditureDetail = class ExpenditureDetail {
19
+ };
20
+ exports.ExpenditureDetail = ExpenditureDetail;
21
+ __decorate([
22
+ (0, typeorm_1.PrimaryGeneratedColumn)("increment"),
23
+ __metadata("design:type", Number)
24
+ ], ExpenditureDetail.prototype, "idExpenditureDetail", void 0);
25
+ __decorate([
26
+ (0, typeorm_1.ManyToOne)(() => Expenditure_1.Expenditure, (expenditure) => expenditure.details, {
27
+ nullable: false,
28
+ onDelete: "CASCADE",
29
+ }),
30
+ (0, typeorm_1.JoinColumn)({ name: "idExpenditure" }),
31
+ __metadata("design:type", Expenditure_1.Expenditure)
32
+ ], ExpenditureDetail.prototype, "expenditure", void 0);
33
+ __decorate([
34
+ (0, typeorm_1.Column)("varchar", { length: 255, nullable: false }),
35
+ __metadata("design:type", String)
36
+ ], ExpenditureDetail.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
+ ], ExpenditureDetail.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
+ ], ExpenditureDetail.prototype, "unitOfMeasure", void 0);
46
+ __decorate([
47
+ (0, typeorm_1.Column)("decimal", { precision: 14, scale: 4, nullable: false }),
48
+ __metadata("design:type", Number)
49
+ ], ExpenditureDetail.prototype, "unitPrice", void 0);
50
+ __decorate([
51
+ (0, typeorm_1.Column)("decimal", { precision: 14, scale: 2, nullable: false }),
52
+ __metadata("design:type", Number)
53
+ ], ExpenditureDetail.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
+ ], ExpenditureDetail.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
+ ], ExpenditureDetail.prototype, "inventory", void 0);
64
+ __decorate([
65
+ (0, typeorm_1.Column)("text", { nullable: true }),
66
+ __metadata("design:type", Object)
67
+ ], ExpenditureDetail.prototype, "notes", void 0);
68
+ exports.ExpenditureDetail = ExpenditureDetail = __decorate([
69
+ (0, typeorm_1.Entity)("expenditure_details")
70
+ ], ExpenditureDetail);
@@ -95,7 +95,7 @@ __decorate([
95
95
  __metadata("design:type", Object)
96
96
  ], Income.prototype, "invoiceUuid", void 0);
97
97
  __decorate([
98
- (0, typeorm_1.OneToOne)(() => TransactionBank_1.TransactionBank, { nullable: true, cascade: true }),
98
+ (0, typeorm_1.OneToOne)(() => TransactionBank_1.TransactionBank, (tb) => tb.income, { nullable: true, cascade: true }),
99
99
  (0, typeorm_1.JoinColumn)({ name: "idTransactionBank" }),
100
100
  __metadata("design:type", Object)
101
101
  ], Income.prototype, "transactionBank", void 0);
@@ -19,6 +19,8 @@ export { ExpenseType } from "./ExpenseType";
19
19
  export { Payment } from "./Payment";
20
20
  export { PaymentCfdi } from "./PaymentCfdi";
21
21
  export { Income } from "./Income";
22
+ export { Expenditure } from "./Expenditure";
23
+ export { ExpenditureDetail } from "./ExpenditureDetail";
22
24
  export { ProjectOrder } from "./ProjectOrder";
23
25
  export { UnitOfMeasure } from "./UnitOfMesure";
24
26
  export { User } from "./User";
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.User = exports.UnitOfMeasure = exports.ProjectOrder = exports.Income = exports.PaymentCfdi = exports.Payment = exports.ExpenseType = exports.ExpenseTransaction = exports.ExpenseDetail = exports.SupplierImage = exports.Supplier = exports.ContainerType = exports.InventoryMovement = exports.InventoryImage = exports.InventoryItem = exports.Inventory = exports.ProductImage = exports.Product = exports.BranchImage = exports.Branch = exports.CategoryForPlantType = exports.CategoryForCosting = exports.TransactionBank = exports.BankAccount = void 0;
3
+ exports.User = exports.UnitOfMeasure = exports.ProjectOrder = exports.ExpenditureDetail = exports.Expenditure = exports.Income = exports.PaymentCfdi = exports.Payment = exports.ExpenseType = exports.ExpenseTransaction = exports.ExpenseDetail = exports.SupplierImage = exports.Supplier = exports.ContainerType = exports.InventoryMovement = exports.InventoryImage = exports.InventoryItem = exports.Inventory = exports.ProductImage = exports.Product = exports.BranchImage = exports.Branch = exports.CategoryForPlantType = exports.CategoryForCosting = exports.TransactionBank = exports.BankAccount = void 0;
4
4
  // Bank
5
5
  var BankAccount_1 = require("./Bank/BankAccount");
6
6
  Object.defineProperty(exports, "BankAccount", { enumerable: true, get: function () { return BankAccount_1.BankAccount; } });
@@ -51,6 +51,11 @@ Object.defineProperty(exports, "PaymentCfdi", { enumerable: true, get: function
51
51
  // Income
52
52
  var Income_1 = require("./Income");
53
53
  Object.defineProperty(exports, "Income", { enumerable: true, get: function () { return Income_1.Income; } });
54
+ // Expenditures
55
+ var Expenditure_1 = require("./Expenditure");
56
+ Object.defineProperty(exports, "Expenditure", { enumerable: true, get: function () { return Expenditure_1.Expenditure; } });
57
+ var ExpenditureDetail_1 = require("./ExpenditureDetail");
58
+ Object.defineProperty(exports, "ExpenditureDetail", { enumerable: true, get: function () { return ExpenditureDetail_1.ExpenditureDetail; } });
54
59
  // Others
55
60
  var ProjectOrder_1 = require("./ProjectOrder");
56
61
  Object.defineProperty(exports, "ProjectOrder", { enumerable: true, get: function () { return ProjectOrder_1.ProjectOrder; } });
@@ -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.54",
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
 
@@ -35,6 +35,10 @@ export { PaymentCfdi } from "./PaymentCfdi";
35
35
  // Income
36
36
  export { Income } from "./Income";
37
37
 
38
+ // Expenditures
39
+ export { Expenditure } from "./Expenditure";
40
+ export { ExpenditureDetail } from "./ExpenditureDetail";
41
+
38
42
  // Others
39
43
  export { ProjectOrder } from "./ProjectOrder";
40
44
  export { UnitOfMeasure } from "./UnitOfMesure";
@@ -8,6 +8,7 @@ import { BudgetCancellationFolio } from "./BudgetCancellationFolio";
8
8
  import { Payment } from "../../entities/Payment";
9
9
  import { ExpenseTransaction } from "../../entities/ExpenseTransaction";
10
10
  import { Income } from "../../entities/Income";
11
+ import { Expenditure } from "../../entities/Expenditure";
11
12
 
12
13
  @Entity("budgets")
13
14
  @Index(["project"])
@@ -63,4 +64,7 @@ export class Budget implements ObjectLiteral {
63
64
 
64
65
  @OneToMany(() => Income, (income) => income.budget)
65
66
  incomes?: Income[];
67
+
68
+ @OneToMany(() => Expenditure, (expenditure) => expenditure.budget)
69
+ expenditures?: Expenditure[];
66
70
  }
@@ -14,6 +14,7 @@ import { CropLot } from "./CropLot";
14
14
  import { CropActivityType } from "../../types/CropActivityType";
15
15
  import { UnitOfMeasure } from "../../entities/UnitOfMesure";
16
16
  import { CropExpense } from "./CropExpense";
17
+ import { Expenditure } from "../../entities/Expenditure";
17
18
 
18
19
  @Entity("crop_activities")
19
20
  @Index(["cropLot", "activityDate"])
@@ -65,4 +66,7 @@ export class CropActivity implements ObjectLiteral {
65
66
 
66
67
  @OneToMany(() => CropExpense, (expense) => expense.cropActivity, { cascade: true })
67
68
  expenses?: CropExpense[];
69
+
70
+ @OneToMany(() => Expenditure, (expenditure) => expenditure.cropActivity)
71
+ expenditures?: Expenditure[];
68
72
  }
@@ -18,6 +18,7 @@ import { CropStage } from "./CropStage";
18
18
  import { CropActivity } from "./CropActivity";
19
19
  import { CropExpense } from "./CropExpense";
20
20
  import { Harvest } from "./Harvest";
21
+ import { Expenditure } from "../../entities/Expenditure";
21
22
 
22
23
  @Entity("crop_lots")
23
24
  @Index(["code"], { unique: true })
@@ -103,4 +104,7 @@ export class CropLot implements ObjectLiteral {
103
104
 
104
105
  @OneToMany(() => Harvest, (harvest) => harvest.cropLot, { cascade: true })
105
106
  harvests?: Harvest[];
107
+
108
+ @OneToMany(() => Expenditure, (expenditure) => expenditure.cropLot)
109
+ expenditures?: Expenditure[];
106
110
  }
@@ -0,0 +1,6 @@
1
+ export enum ExpenditureStatus {
2
+ PENDING = "PENDING",
3
+ APPROVED = "APPROVED",
4
+ PAID = "PAID",
5
+ CANCELLED = "CANCELLED",
6
+ }
@@ -0,0 +1,5 @@
1
+ export enum ExpenditureType {
2
+ BUDGET_EXPENSE = "BUDGET_EXPENSE",
3
+ PRODUCTION_EXPENSE = "PRODUCTION_EXPENSE",
4
+ OTHER = "OTHER",
5
+ }
@@ -12,4 +12,8 @@ export { QualityGrade } from "./QualityGrade";
12
12
 
13
13
  // Income enums
14
14
  export { IncomeType } from "./IncomeType";
15
- export { IncomeStatus } from "./IncomeStatus";
15
+ export { IncomeStatus } from "./IncomeStatus";
16
+
17
+ // Expenditure enums
18
+ export { ExpenditureType } from "./ExpenditureType";
19
+ export { ExpenditureStatus } from "./ExpenditureStatus";