proflores-db-model 0.2.32 → 0.2.34
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.
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/dist/models/apu/Apu.d.ts +14 -0
- package/dist/models/apu/Apu.js +62 -0
- package/dist/models/apu/ApuItem.d.ts +12 -0
- package/dist/models/apu/ApuItem.js +55 -0
- package/dist/models/apu/Budget.d.ts +15 -0
- package/dist/models/apu/Budget.js +64 -0
- package/dist/models/apu/BudgetItem.d.ts +14 -0
- package/dist/models/apu/BudgetItem.js +59 -0
- package/dist/models/apu/Client.d.ts +15 -0
- package/dist/models/apu/Client.js +68 -0
- package/dist/models/apu/Company.d.ts +16 -0
- package/dist/models/apu/Company.js +72 -0
- package/dist/models/apu/Concept.d.ts +15 -0
- package/dist/models/apu/Concept.js +61 -0
- package/dist/models/apu/PriceList.d.ts +12 -0
- package/dist/models/apu/PriceList.js +54 -0
- package/dist/models/apu/Project.d.ts +19 -0
- package/dist/models/apu/Project.js +82 -0
- package/dist/models/apu/Resource.d.ts +16 -0
- package/dist/models/apu/Resource.js +66 -0
- package/dist/models/apu/ResourcePrice.d.ts +13 -0
- package/dist/models/apu/ResourcePrice.js +56 -0
- package/dist/models/apu/budget-snapshot.entity.d.ts +14 -0
- package/dist/models/apu/budget-snapshot.entity.js +67 -0
- package/dist/models/apu/enums/resource-type.enum.d.ts +9 -0
- package/dist/models/apu/enums/resource-type.enum.js +13 -0
- package/dist/models/apu/index.d.ts +13 -0
- package/dist/models/apu/index.js +29 -0
- package/package.json +1 -1
- package/src/index.ts +2 -1
- package/src/models/apu/Apu.ts +40 -0
- package/src/models/apu/ApuItem.ts +35 -0
- package/src/models/apu/Budget.ts +41 -0
- package/src/models/apu/BudgetItem.ts +38 -0
- package/src/models/apu/Client.ts +41 -0
- package/src/models/apu/Company.ts +44 -0
- package/src/models/apu/Concept.ts +39 -0
- package/src/models/apu/PriceList.ts +34 -0
- package/src/models/apu/Project.ts +55 -0
- package/src/models/apu/Resource.ts +44 -0
- package/src/models/apu/ResourcePrice.ts +35 -0
- package/src/models/apu/budget-snapshot.entity.ts +41 -0
- package/src/models/apu/enums/resource-type.enum.ts +9 -0
- package/src/models/apu/index.ts +13 -0
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
// apu/entities/Concept.ts
|
|
2
|
+
import {
|
|
3
|
+
Entity, PrimaryGeneratedColumn, Column, ObjectLiteral, ManyToOne, OneToMany, JoinColumn, Index,
|
|
4
|
+
} from "typeorm";
|
|
5
|
+
import { UnitOfMeasure } from "../../entities/UnitOfMesure"; // <-- ajusta tu ruta real
|
|
6
|
+
import { Apu } from "./Apu";
|
|
7
|
+
import { BudgetItem } from "./BudgetItem";
|
|
8
|
+
|
|
9
|
+
@Entity("concepts")
|
|
10
|
+
@Index(["code"], { unique: true })
|
|
11
|
+
export class Concept implements ObjectLiteral {
|
|
12
|
+
@PrimaryGeneratedColumn("increment")
|
|
13
|
+
idConcept!: number;
|
|
14
|
+
|
|
15
|
+
@Column("varchar", { length: 64, nullable: true, unique: true })
|
|
16
|
+
code?: string | null; // clave del concepto (PU-XXXX)
|
|
17
|
+
|
|
18
|
+
@Column("varchar", { length: 255 })
|
|
19
|
+
title!: string;
|
|
20
|
+
|
|
21
|
+
@Column("text", { nullable: true })
|
|
22
|
+
description?: string | null;
|
|
23
|
+
|
|
24
|
+
@ManyToOne(() => UnitOfMeasure, { nullable: false })
|
|
25
|
+
@JoinColumn({ name: "idUnitOfMeasure" })
|
|
26
|
+
unit!: UnitOfMeasure;
|
|
27
|
+
|
|
28
|
+
@Column("varchar", { length: 64, nullable: true })
|
|
29
|
+
category?: string | null;
|
|
30
|
+
|
|
31
|
+
@Column({ type: "boolean", default: true })
|
|
32
|
+
isActive!: boolean;
|
|
33
|
+
|
|
34
|
+
@OneToMany(() => Apu, (a) => a.concept, { cascade: true })
|
|
35
|
+
apus?: Apu[];
|
|
36
|
+
|
|
37
|
+
@OneToMany(() => BudgetItem, (bi) => bi.concept)
|
|
38
|
+
budgetItems?: BudgetItem[];
|
|
39
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
// apu/entities/PriceList.ts
|
|
2
|
+
import {
|
|
3
|
+
Entity, PrimaryGeneratedColumn, Column, ObjectLiteral, OneToMany,
|
|
4
|
+
Index,
|
|
5
|
+
} from "typeorm";
|
|
6
|
+
import { ResourcePrice } from "./ResourcePrice";
|
|
7
|
+
|
|
8
|
+
@Entity("price_lists")
|
|
9
|
+
export class PriceList implements ObjectLiteral {
|
|
10
|
+
@PrimaryGeneratedColumn("increment")
|
|
11
|
+
idPriceList!: number;
|
|
12
|
+
|
|
13
|
+
@Column("varchar", { length: 255 })
|
|
14
|
+
name!: string;
|
|
15
|
+
|
|
16
|
+
@Column("varchar", { length: 64, nullable: true })
|
|
17
|
+
region?: string | null;
|
|
18
|
+
|
|
19
|
+
@Column("varchar", { length: 3, default: "MXN" })
|
|
20
|
+
currency!: string;
|
|
21
|
+
|
|
22
|
+
@Column("date")
|
|
23
|
+
validFrom!: string;
|
|
24
|
+
|
|
25
|
+
@Column("date", { nullable: true })
|
|
26
|
+
validTo?: string | null;
|
|
27
|
+
|
|
28
|
+
@Index()
|
|
29
|
+
@Column({ type: "boolean", default: false })
|
|
30
|
+
isDefault!: boolean;
|
|
31
|
+
|
|
32
|
+
@OneToMany(() => ResourcePrice, (rp) => rp.priceList)
|
|
33
|
+
resourcePrices?: ResourcePrice[];
|
|
34
|
+
}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
// apu/entities/Project.ts
|
|
2
|
+
import {
|
|
3
|
+
Entity, PrimaryGeneratedColumn, Column, ObjectLiteral, ManyToOne, JoinColumn, Index,
|
|
4
|
+
} from "typeorm";
|
|
5
|
+
import { Company } from "./Company";
|
|
6
|
+
import { Client } from "./Client";
|
|
7
|
+
|
|
8
|
+
@Entity("projects")
|
|
9
|
+
@Index(["company"])
|
|
10
|
+
@Index(["client"])
|
|
11
|
+
export class Project implements ObjectLiteral {
|
|
12
|
+
@PrimaryGeneratedColumn("increment")
|
|
13
|
+
idProject!: number;
|
|
14
|
+
|
|
15
|
+
@ManyToOne(() => Company, { nullable: false, onDelete: "RESTRICT" })
|
|
16
|
+
@JoinColumn({ name: "idCompany" })
|
|
17
|
+
company!: Company;
|
|
18
|
+
|
|
19
|
+
@ManyToOne(() => Client, { nullable: true, onDelete: "SET NULL" })
|
|
20
|
+
@JoinColumn({ name: "idClient" })
|
|
21
|
+
client?: Client | null;
|
|
22
|
+
|
|
23
|
+
@Column("varchar", { length: 64, nullable: true, unique: true })
|
|
24
|
+
code?: string | null;
|
|
25
|
+
|
|
26
|
+
@Column("varchar", { length: 255 })
|
|
27
|
+
name!: string;
|
|
28
|
+
|
|
29
|
+
@Column("text", { nullable: true })
|
|
30
|
+
description?: string | null;
|
|
31
|
+
|
|
32
|
+
@Column("varchar", { length: 255, nullable: true })
|
|
33
|
+
siteAddress?: string | null;
|
|
34
|
+
|
|
35
|
+
@Column("varchar", { length: 128, nullable: true })
|
|
36
|
+
city?: string | null;
|
|
37
|
+
|
|
38
|
+
@Column("varchar", { length: 128, nullable: true })
|
|
39
|
+
state?: string | null;
|
|
40
|
+
|
|
41
|
+
@Column("varchar", { length: 128, nullable: true })
|
|
42
|
+
country?: string | null;
|
|
43
|
+
|
|
44
|
+
@Column("varchar", { length: 16, nullable: true })
|
|
45
|
+
postalCode?: string | null;
|
|
46
|
+
|
|
47
|
+
@Column("varchar", { length: 64, nullable: true })
|
|
48
|
+
region?: string | null;
|
|
49
|
+
|
|
50
|
+
@Column("date", { nullable: true })
|
|
51
|
+
startDate?: string | null;
|
|
52
|
+
|
|
53
|
+
@Column("date", { nullable: true })
|
|
54
|
+
endDate?: string | null;
|
|
55
|
+
}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
// apu/entities/Resource.ts
|
|
2
|
+
import {
|
|
3
|
+
Entity, PrimaryGeneratedColumn, Column, ObjectLiteral, ManyToOne, OneToMany, JoinColumn, Index,
|
|
4
|
+
} from "typeorm";
|
|
5
|
+
import { ResourceType } from "./enums/resource-type.enum";
|
|
6
|
+
import { UnitOfMeasure } from "../../entities/UnitOfMesure";
|
|
7
|
+
import { ResourcePrice } from "./ResourcePrice";
|
|
8
|
+
import { ApuItem } from "./ApuItem";
|
|
9
|
+
|
|
10
|
+
@Entity("resources")
|
|
11
|
+
@Index(["type"])
|
|
12
|
+
export class Resource implements ObjectLiteral {
|
|
13
|
+
@PrimaryGeneratedColumn("increment")
|
|
14
|
+
idResource!: number;
|
|
15
|
+
|
|
16
|
+
@Column("varchar", { length: 64, nullable: true, unique: true })
|
|
17
|
+
code?: string | null;
|
|
18
|
+
|
|
19
|
+
@Column("varchar", { length: 255 })
|
|
20
|
+
name!: string;
|
|
21
|
+
|
|
22
|
+
@Column({
|
|
23
|
+
type: "enum",
|
|
24
|
+
enum: ResourceType,
|
|
25
|
+
enumName: "resource_type",
|
|
26
|
+
})
|
|
27
|
+
type!: ResourceType;
|
|
28
|
+
|
|
29
|
+
@ManyToOne(() => UnitOfMeasure, { nullable: false })
|
|
30
|
+
@JoinColumn({ name: "idUnitOfMeasure" })
|
|
31
|
+
unit!: UnitOfMeasure;
|
|
32
|
+
|
|
33
|
+
@Column("varchar", { length: 64, nullable: true })
|
|
34
|
+
satClave?: string | null;
|
|
35
|
+
|
|
36
|
+
@Column("text", { nullable: true })
|
|
37
|
+
notes?: string | null;
|
|
38
|
+
|
|
39
|
+
@OneToMany(() => ResourcePrice, (rp) => rp.resource)
|
|
40
|
+
prices?: ResourcePrice[];
|
|
41
|
+
|
|
42
|
+
@OneToMany(() => ApuItem, (ai) => ai.resource)
|
|
43
|
+
apuItems?: ApuItem[];
|
|
44
|
+
}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
// apu/entities/ResourcePrice.ts
|
|
2
|
+
import {
|
|
3
|
+
Entity, PrimaryGeneratedColumn, Column, ObjectLiteral, ManyToOne, JoinColumn, Index, Unique,
|
|
4
|
+
} from "typeorm";
|
|
5
|
+
import { Resource } from "./Resource";
|
|
6
|
+
import { PriceList } from "./PriceList";
|
|
7
|
+
import { Supplier } from "../../entities/Suppliers";
|
|
8
|
+
|
|
9
|
+
@Entity("resource_prices")
|
|
10
|
+
@Unique("uq_resource_price_effective", ["resource", "priceList", "effectiveFrom"])
|
|
11
|
+
@Index(["resource", "priceList", "effectiveFrom"])
|
|
12
|
+
export class ResourcePrice implements ObjectLiteral {
|
|
13
|
+
@PrimaryGeneratedColumn("increment")
|
|
14
|
+
idResourcePrice!: number;
|
|
15
|
+
|
|
16
|
+
@ManyToOne(() => Resource, { nullable: false, onDelete: "CASCADE" })
|
|
17
|
+
@JoinColumn({ name: "idResource" })
|
|
18
|
+
resource!: Resource;
|
|
19
|
+
|
|
20
|
+
@ManyToOne(() => PriceList, { nullable: false, onDelete: "CASCADE" })
|
|
21
|
+
@JoinColumn({ name: "idPriceList" })
|
|
22
|
+
priceList!: PriceList;
|
|
23
|
+
|
|
24
|
+
@ManyToOne(() => Supplier, { nullable: true })
|
|
25
|
+
@JoinColumn({ name: "idSupplier" })
|
|
26
|
+
supplier?: Supplier | null;
|
|
27
|
+
|
|
28
|
+
@Column("decimal", { precision: 14, scale: 4 })
|
|
29
|
+
unitCost!: number;
|
|
30
|
+
@Column("date")
|
|
31
|
+
effectiveFrom!: string;
|
|
32
|
+
|
|
33
|
+
@Column("date", { nullable: true })
|
|
34
|
+
effectiveTo?: string | null;
|
|
35
|
+
}
|
|
@@ -0,0 +1,41 @@
|
|
|
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'])
|
|
7
|
+
export class BudgetSnapshot {
|
|
8
|
+
@PrimaryGeneratedColumn()
|
|
9
|
+
idSnapshot!: number;
|
|
10
|
+
|
|
11
|
+
@Column()
|
|
12
|
+
idBudget!: number;
|
|
13
|
+
|
|
14
|
+
@ManyToOne(() => Budget, { onDelete: 'CASCADE' })
|
|
15
|
+
@JoinColumn({ name: 'idBudget' })
|
|
16
|
+
budget!: Budget;
|
|
17
|
+
|
|
18
|
+
@Column({ type: 'jsonb' })
|
|
19
|
+
payload!: Record<string, any>;
|
|
20
|
+
|
|
21
|
+
@Column({ nullable: true, length: 64 })
|
|
22
|
+
pdfHash?: string | null;
|
|
23
|
+
|
|
24
|
+
@Column({ nullable: true })
|
|
25
|
+
idPriceList?: number;
|
|
26
|
+
|
|
27
|
+
@Column({ type: 'varchar', length: 10, default: 'MXN' })
|
|
28
|
+
currency!: string;
|
|
29
|
+
|
|
30
|
+
@Column({ type: 'decimal', precision: 20, scale: 4 })
|
|
31
|
+
total!: number;
|
|
32
|
+
|
|
33
|
+
@CreateDateColumn()
|
|
34
|
+
createdAt!: Date;
|
|
35
|
+
|
|
36
|
+
@Column({ nullable: true })
|
|
37
|
+
generatedBy?: string;
|
|
38
|
+
|
|
39
|
+
@Column({ type: 'text', nullable: true })
|
|
40
|
+
notes?: string;
|
|
41
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export { Apu } from './Apu'; //
|
|
2
|
+
export { ApuItem } from './ApuItem'; //
|
|
3
|
+
export { Budget } from './Budget';
|
|
4
|
+
export { BudgetItem } from './BudgetItem';
|
|
5
|
+
export { Client } from './Client';
|
|
6
|
+
export { Company } from './Company';
|
|
7
|
+
export { Concept } from './Concept';
|
|
8
|
+
export { PriceList } from './PriceList'; //
|
|
9
|
+
export { Project } from './Project';
|
|
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'
|