proflores-db-model 0.2.36 → 0.2.38

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.
@@ -11,5 +11,7 @@ export declare class Budget implements ObjectLiteral {
11
11
  vatPct: number;
12
12
  status: "DRAFT" | "SENT" | "APPROVED" | "REJECTED" | "BILLED" | string;
13
13
  notes?: string | null;
14
+ invoiceUuid?: string | null;
15
+ fiscalApiId?: string | null;
14
16
  items?: BudgetItem[];
15
17
  }
@@ -54,6 +54,14 @@ __decorate([
54
54
  (0, typeorm_1.Column)("text", { nullable: true }),
55
55
  __metadata("design:type", Object)
56
56
  ], Budget.prototype, "notes", void 0);
57
+ __decorate([
58
+ (0, typeorm_1.Column)("varchar", { length: 255, nullable: true }),
59
+ __metadata("design:type", Object)
60
+ ], Budget.prototype, "invoiceUuid", void 0);
61
+ __decorate([
62
+ (0, typeorm_1.Column)("varchar", { length: 255, nullable: true }),
63
+ __metadata("design:type", Object)
64
+ ], Budget.prototype, "fiscalApiId", void 0);
57
65
  __decorate([
58
66
  (0, typeorm_1.OneToMany)(() => BudgetItem_1.BudgetItem, (bi) => bi.budget, { cascade: true }),
59
67
  __metadata("design:type", Array)
@@ -1,4 +1,4 @@
1
- import { Budget } from '../apu';
1
+ import { Budget } from "../apu";
2
2
  export declare class BudgetSnapshot {
3
3
  idSnapshot: number;
4
4
  budget: Budget;
@@ -8,6 +8,6 @@ export declare class BudgetSnapshot {
8
8
  currency: string;
9
9
  total: number;
10
10
  createdAt: Date;
11
- generatedBy?: string;
12
- notes?: string;
11
+ generatedBy?: string | null;
12
+ notes?: string | null;
13
13
  }
@@ -10,54 +10,58 @@ var __metadata = (this && this.__metadata) || function (k, v) {
10
10
  };
11
11
  Object.defineProperty(exports, "__esModule", { value: true });
12
12
  exports.BudgetSnapshot = void 0;
13
+ // apu/entities/BudgetSnapshot.ts
13
14
  const typeorm_1 = require("typeorm");
14
15
  const apu_1 = require("../apu");
15
16
  let BudgetSnapshot = class BudgetSnapshot {
16
17
  };
17
18
  exports.BudgetSnapshot = BudgetSnapshot;
18
19
  __decorate([
19
- (0, typeorm_1.PrimaryGeneratedColumn)(),
20
+ (0, typeorm_1.PrimaryGeneratedColumn)("increment"),
20
21
  __metadata("design:type", Number)
21
22
  ], BudgetSnapshot.prototype, "idSnapshot", void 0);
22
23
  __decorate([
23
- (0, typeorm_1.ManyToOne)(() => apu_1.Budget, { onDelete: 'CASCADE' }),
24
- (0, typeorm_1.JoinColumn)({ name: 'idBudget' }),
24
+ (0, typeorm_1.ManyToOne)(() => apu_1.Budget, { nullable: false, onDelete: "CASCADE" }),
25
+ (0, typeorm_1.JoinColumn)({ name: "idBudget" }),
25
26
  __metadata("design:type", apu_1.Budget)
26
27
  ], BudgetSnapshot.prototype, "budget", void 0);
27
28
  __decorate([
28
- (0, typeorm_1.Column)({ type: 'jsonb' }),
29
+ (0, typeorm_1.Column)("jsonb"),
29
30
  __metadata("design:type", Object)
30
31
  ], BudgetSnapshot.prototype, "payload", void 0);
31
32
  __decorate([
32
- (0, typeorm_1.Column)({ nullable: true, length: 64 }),
33
+ (0, typeorm_1.Column)("varchar", { length: 64, nullable: true }),
33
34
  __metadata("design:type", Object)
34
35
  ], BudgetSnapshot.prototype, "pdfHash", void 0);
35
36
  __decorate([
36
- (0, typeorm_1.Column)({ nullable: true }),
37
+ (0, typeorm_1.Column)("int", { nullable: true }),
37
38
  __metadata("design:type", Number)
38
39
  ], BudgetSnapshot.prototype, "idPriceList", void 0);
39
40
  __decorate([
40
- (0, typeorm_1.Column)({ type: 'varchar', length: 10, default: 'MXN' }),
41
+ (0, typeorm_1.Column)("varchar", { length: 10, default: "MXN" }),
41
42
  __metadata("design:type", String)
42
43
  ], BudgetSnapshot.prototype, "currency", void 0);
43
44
  __decorate([
44
- (0, typeorm_1.Column)({ type: 'decimal', precision: 20, scale: 4 }),
45
+ (0, typeorm_1.Column)("decimal", { precision: 20, scale: 4 }),
45
46
  __metadata("design:type", Number)
46
47
  ], BudgetSnapshot.prototype, "total", void 0);
47
48
  __decorate([
48
- (0, typeorm_1.CreateDateColumn)(),
49
+ (0, typeorm_1.CreateDateColumn)({ type: "timestamptz" }),
49
50
  __metadata("design:type", Date)
50
51
  ], BudgetSnapshot.prototype, "createdAt", void 0);
51
52
  __decorate([
52
- (0, typeorm_1.Column)({ nullable: true }),
53
- __metadata("design:type", String)
53
+ (0, typeorm_1.Column)("varchar", { length: 128, nullable: true }),
54
+ __metadata("design:type", Object)
54
55
  ], BudgetSnapshot.prototype, "generatedBy", void 0);
55
56
  __decorate([
56
- (0, typeorm_1.Column)({ type: 'text', nullable: true }),
57
- __metadata("design:type", String)
57
+ (0, typeorm_1.Column)("text", { nullable: true }),
58
+ __metadata("design:type", Object)
58
59
  ], BudgetSnapshot.prototype, "notes", void 0);
59
60
  exports.BudgetSnapshot = BudgetSnapshot = __decorate([
60
- (0, typeorm_1.Entity)('budget_snapshots'),
61
- (0, typeorm_1.Index)(['idBudget', 'createdAt']),
62
- (0, typeorm_1.Index)(['pdfHash'])
61
+ (0, typeorm_1.Entity)("budget_snapshots"),
62
+ (0, typeorm_1.Index)(["budget"]) // como @Index(["apu"]) en tu ApuItem
63
+ ,
64
+ (0, typeorm_1.Index)(["createdAt"]),
65
+ (0, typeorm_1.Index)(["pdfHash"]),
66
+ (0, typeorm_1.Check)(`"total" >= 0`)
63
67
  ], BudgetSnapshot);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "proflores-db-model",
3
- "version": "0.2.36",
3
+ "version": "0.2.38",
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",
@@ -36,6 +36,12 @@ export class Budget implements ObjectLiteral {
36
36
  @Column("text", { nullable: true })
37
37
  notes?: string | null;
38
38
 
39
+ @Column("varchar", { length: 255, nullable: true })
40
+ invoiceUuid?: string | null;
41
+
42
+ @Column("varchar", { length: 255, nullable: true })
43
+ fiscalApiId?: string | null;
44
+
39
45
  @OneToMany(() => BudgetItem, (bi) => bi.budget, { cascade: true })
40
46
  items?: BudgetItem[];
41
47
  }
@@ -1,38 +1,45 @@
1
- import { Entity, Column, PrimaryGeneratedColumn, CreateDateColumn, ManyToOne, JoinColumn, Index } from 'typeorm';
2
- import { Budget } from '../apu';
3
-
4
- @Entity('budget_snapshots')
5
- @Index(['idBudget', 'createdAt'])
6
- @Index(['pdfHash'])
1
+ // apu/entities/BudgetSnapshot.ts
2
+ import {
3
+ Entity, PrimaryGeneratedColumn, Column, ManyToOne, JoinColumn,
4
+ Index, CreateDateColumn, Check,
5
+ } from "typeorm";
6
+ import { Budget } from "../apu";
7
+
8
+ @Entity("budget_snapshots")
9
+ @Index(["budget"]) // como @Index(["apu"]) en tu ApuItem
10
+ @Index(["createdAt"])
11
+ @Index(["pdfHash"])
12
+ @Check(`"total" >= 0`)
7
13
  export class BudgetSnapshot {
8
- @PrimaryGeneratedColumn()
14
+ @PrimaryGeneratedColumn("increment")
9
15
  idSnapshot!: number;
10
16
 
11
- @ManyToOne(() => Budget, { onDelete: 'CASCADE' })
12
- @JoinColumn({ name: 'idBudget' })
13
- budget!: Budget;
17
+ @ManyToOne(() => Budget, { nullable: false, onDelete: "CASCADE" })
18
+ @JoinColumn({ name: "idBudget" })
19
+ budget!: Budget; // FK real en DB: idBudget
14
20
 
15
- @Column({ type: 'jsonb' })
16
- payload!: Record<string, any>;
21
+ @Column("jsonb")
22
+ payload!: Record<string, any>; // DTO congelado
17
23
 
18
- @Column({ nullable: true, length: 64 })
24
+ // Usa 64 si guardas SHA-256 sin "0x"; si usaras "0x" cámbialo a length: 66
25
+ @Column("varchar", { length: 64, nullable: true })
19
26
  pdfHash?: string | null;
20
27
 
21
- @Column({ nullable: true })
28
+ @Column("int", { nullable: true })
22
29
  idPriceList?: number;
23
30
 
24
- @Column({ type: 'varchar', length: 10, default: 'MXN' })
31
+ @Column("varchar", { length: 10, default: "MXN" })
25
32
  currency!: string;
26
33
 
27
- @Column({ type: 'decimal', precision: 20, scale: 4 })
34
+ @Column("decimal", { precision: 20, scale: 4 })
28
35
  total!: number;
29
36
 
30
- @CreateDateColumn()
37
+ @CreateDateColumn({ type: "timestamptz" })
31
38
  createdAt!: Date;
32
39
 
33
- @Column({ nullable: true })
34
- generatedBy?: string;
40
+ @Column("varchar", { length: 128, nullable: true })
41
+ generatedBy?: string | null;
35
42
 
36
- @Column({ type: 'text', nullable: true })
37
- notes?: string;
38
- }
43
+ @Column("text", { nullable: true })
44
+ notes?: string | null;
45
+ }