proflores-db-model 0.2.33 → 0.2.35

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.
@@ -0,0 +1,14 @@
1
+ import { Budget } from '../apu';
2
+ export declare class BudgetSnapshot {
3
+ idSnapshot: number;
4
+ budget: Budget;
5
+ idBudget: number;
6
+ payload: Record<string, any>;
7
+ pdfHash?: string | null;
8
+ idPriceList?: number;
9
+ currency: string;
10
+ total: number;
11
+ createdAt: Date;
12
+ generatedBy?: string;
13
+ notes?: string;
14
+ }
@@ -0,0 +1,67 @@
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.BudgetSnapshot = void 0;
13
+ const typeorm_1 = require("typeorm");
14
+ const apu_1 = require("../apu");
15
+ let BudgetSnapshot = class BudgetSnapshot {
16
+ };
17
+ exports.BudgetSnapshot = BudgetSnapshot;
18
+ __decorate([
19
+ (0, typeorm_1.PrimaryGeneratedColumn)(),
20
+ __metadata("design:type", Number)
21
+ ], BudgetSnapshot.prototype, "idSnapshot", void 0);
22
+ __decorate([
23
+ (0, typeorm_1.ManyToOne)(() => apu_1.Budget, { onDelete: 'CASCADE' }),
24
+ (0, typeorm_1.JoinColumn)({ name: 'idBudget' }),
25
+ __metadata("design:type", apu_1.Budget)
26
+ ], BudgetSnapshot.prototype, "budget", void 0);
27
+ __decorate([
28
+ (0, typeorm_1.RelationId)((s) => s.budget),
29
+ __metadata("design:type", Number)
30
+ ], BudgetSnapshot.prototype, "idBudget", void 0);
31
+ __decorate([
32
+ (0, typeorm_1.Column)({ type: 'jsonb' }),
33
+ __metadata("design:type", Object)
34
+ ], BudgetSnapshot.prototype, "payload", void 0);
35
+ __decorate([
36
+ (0, typeorm_1.Column)({ type: 'varchar', length: 64, nullable: true }),
37
+ __metadata("design:type", Object)
38
+ ], BudgetSnapshot.prototype, "pdfHash", void 0);
39
+ __decorate([
40
+ (0, typeorm_1.Column)({ type: 'int', nullable: true }),
41
+ __metadata("design:type", Number)
42
+ ], BudgetSnapshot.prototype, "idPriceList", void 0);
43
+ __decorate([
44
+ (0, typeorm_1.Column)({ type: 'varchar', length: 10, default: 'MXN' }),
45
+ __metadata("design:type", String)
46
+ ], BudgetSnapshot.prototype, "currency", void 0);
47
+ __decorate([
48
+ (0, typeorm_1.Column)({ type: 'decimal', precision: 20, scale: 4 }),
49
+ __metadata("design:type", Number)
50
+ ], BudgetSnapshot.prototype, "total", void 0);
51
+ __decorate([
52
+ (0, typeorm_1.CreateDateColumn)({ type: 'timestamptz' }),
53
+ __metadata("design:type", Date)
54
+ ], BudgetSnapshot.prototype, "createdAt", void 0);
55
+ __decorate([
56
+ (0, typeorm_1.Column)({ type: 'varchar', length: 128, nullable: true }),
57
+ __metadata("design:type", String)
58
+ ], BudgetSnapshot.prototype, "generatedBy", void 0);
59
+ __decorate([
60
+ (0, typeorm_1.Column)({ type: 'text', nullable: true }),
61
+ __metadata("design:type", String)
62
+ ], BudgetSnapshot.prototype, "notes", void 0);
63
+ exports.BudgetSnapshot = BudgetSnapshot = __decorate([
64
+ (0, typeorm_1.Entity)('budget_snapshots'),
65
+ (0, typeorm_1.Index)(['idBudget', 'createdAt']),
66
+ (0, typeorm_1.Index)(['pdfHash'])
67
+ ], BudgetSnapshot);
@@ -10,3 +10,4 @@ export { Project } from './Project';
10
10
  export { Resource } from './Resource';
11
11
  export { ResourcePrice } from './ResourcePrice';
12
12
  export { ResourceType } from './enums/resource-type.enum';
13
+ export { BudgetSnapshot } from './budget-snapshot.entity';
@@ -1,9 +1,9 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.ResourceType = exports.ResourcePrice = exports.Resource = exports.Project = exports.PriceList = exports.Concept = exports.Company = exports.Client = exports.BudgetItem = exports.Budget = exports.ApuItem = exports.Apu = void 0;
4
- var Apu_1 = require("./Apu");
3
+ exports.BudgetSnapshot = exports.ResourceType = exports.ResourcePrice = exports.Resource = exports.Project = exports.PriceList = exports.Concept = exports.Company = exports.Client = exports.BudgetItem = exports.Budget = exports.ApuItem = exports.Apu = void 0;
4
+ var Apu_1 = require("./Apu"); //
5
5
  Object.defineProperty(exports, "Apu", { enumerable: true, get: function () { return Apu_1.Apu; } });
6
- var ApuItem_1 = require("./ApuItem");
6
+ var ApuItem_1 = require("./ApuItem"); //
7
7
  Object.defineProperty(exports, "ApuItem", { enumerable: true, get: function () { return ApuItem_1.ApuItem; } });
8
8
  var Budget_1 = require("./Budget");
9
9
  Object.defineProperty(exports, "Budget", { enumerable: true, get: function () { return Budget_1.Budget; } });
@@ -15,13 +15,15 @@ var Company_1 = require("./Company");
15
15
  Object.defineProperty(exports, "Company", { enumerable: true, get: function () { return Company_1.Company; } });
16
16
  var Concept_1 = require("./Concept");
17
17
  Object.defineProperty(exports, "Concept", { enumerable: true, get: function () { return Concept_1.Concept; } });
18
- var PriceList_1 = require("./PriceList");
18
+ var PriceList_1 = require("./PriceList"); //
19
19
  Object.defineProperty(exports, "PriceList", { enumerable: true, get: function () { return PriceList_1.PriceList; } });
20
20
  var Project_1 = require("./Project");
21
21
  Object.defineProperty(exports, "Project", { enumerable: true, get: function () { return Project_1.Project; } });
22
- var Resource_1 = require("./Resource");
22
+ var Resource_1 = require("./Resource"); //
23
23
  Object.defineProperty(exports, "Resource", { enumerable: true, get: function () { return Resource_1.Resource; } });
24
- var ResourcePrice_1 = require("./ResourcePrice");
24
+ var ResourcePrice_1 = require("./ResourcePrice"); //
25
25
  Object.defineProperty(exports, "ResourcePrice", { enumerable: true, get: function () { return ResourcePrice_1.ResourcePrice; } });
26
26
  var resource_type_enum_1 = require("./enums/resource-type.enum");
27
27
  Object.defineProperty(exports, "ResourceType", { enumerable: true, get: function () { return resource_type_enum_1.ResourceType; } });
28
+ var budget_snapshot_entity_1 = require("./budget-snapshot.entity");
29
+ Object.defineProperty(exports, "BudgetSnapshot", { enumerable: true, get: function () { return budget_snapshot_entity_1.BudgetSnapshot; } });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "proflores-db-model",
3
- "version": "0.2.33",
3
+ "version": "0.2.35",
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",
@@ -0,0 +1,43 @@
1
+ import { Entity, Column, PrimaryGeneratedColumn, CreateDateColumn, ManyToOne, JoinColumn, Index, RelationId } from 'typeorm';
2
+ import { Budget } from '../apu';
3
+
4
+ @Entity('budget_snapshots')
5
+ @Index(['idBudget', 'createdAt'])
6
+ @Index(['pdfHash'])
7
+ export class BudgetSnapshot {
8
+ @PrimaryGeneratedColumn()
9
+ idSnapshot!: number;
10
+
11
+ @ManyToOne(() => Budget, { onDelete: 'CASCADE' })
12
+ @JoinColumn({ name: 'idBudget' })
13
+ budget!: Budget;
14
+
15
+ @RelationId((s: BudgetSnapshot) => s.budget)
16
+ idBudget!: number;
17
+
18
+ @Column({ type: 'jsonb' })
19
+ payload!: Record<string, any>;
20
+
21
+ // Si vas a guardar el hash con prefijo 0x, usa length: 66; si no, 64 está bien
22
+ @Column({ type: 'varchar', length: 64, nullable: true })
23
+ pdfHash?: string | null;
24
+
25
+ @Column({ type: 'int', nullable: true })
26
+ idPriceList?: number;
27
+
28
+ @Column({ type: 'varchar', length: 10, default: 'MXN' })
29
+ currency!: string;
30
+
31
+ @Column({ type: 'decimal', precision: 20, scale: 4 })
32
+ total!: number;
33
+
34
+ // Especifica el tipo para evitar diferencias entre drivers
35
+ @CreateDateColumn({ type: 'timestamptz' })
36
+ createdAt!: Date;
37
+
38
+ @Column({ type: 'varchar', length: 128, nullable: true })
39
+ generatedBy?: string;
40
+
41
+ @Column({ type: 'text', nullable: true })
42
+ notes?: string;
43
+ }
@@ -1,12 +1,13 @@
1
- export { Apu } from './Apu';
2
- export { ApuItem } from './ApuItem';
1
+ export { Apu } from './Apu'; //
2
+ export { ApuItem } from './ApuItem'; //
3
3
  export { Budget } from './Budget';
4
4
  export { BudgetItem } from './BudgetItem';
5
5
  export { Client } from './Client';
6
6
  export { Company } from './Company';
7
7
  export { Concept } from './Concept';
8
- export { PriceList } from './PriceList';
8
+ export { PriceList } from './PriceList'; //
9
9
  export { Project } from './Project';
10
- export { Resource } from './Resource';
11
- export { ResourcePrice } from './ResourcePrice';
12
- export { ResourceType } from './enums/resource-type.enum';
10
+ export { Resource } from './Resource'; //
11
+ export { ResourcePrice } from './ResourcePrice'; //
12
+ export { ResourceType } from './enums/resource-type.enum';
13
+ export { BudgetSnapshot } from './budget-snapshot.entity'