@asumano/worklip-typeorm-db 1.1.48 → 1.1.49

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.
@@ -184,4 +184,8 @@ exports.BillingInvoice = BillingInvoice = __decorate([
184
184
  }),
185
185
  (0, typeorm_1.Index)("UQ_billing_invoice_number", ["invoice_number"], { unique: true }),
186
186
  (0, typeorm_1.Index)("UQ_billing_invoice_period", ["company_subscription", "period_year", "period_month"], { unique: true })
187
+ // DOC: El webhook de Wompi concilia la factura por payment_reference; indexarlo
188
+ // evita full scan en cada evento.
189
+ ,
190
+ (0, typeorm_1.Index)("IDX_billing_invoice_payment_reference", ["payment_reference"])
187
191
  ], BillingInvoice);
@@ -4,7 +4,7 @@ export declare class BillingUsageSnapshot {
4
4
  company: Company;
5
5
  year: number;
6
6
  month: number;
7
- storage_bytes: number;
7
+ storage_bytes: string;
8
8
  whatsapp_messages: number;
9
9
  emails_sent: number;
10
10
  active_users: number;
@@ -48,8 +48,11 @@ __decorate([
48
48
  (0, typeorm_1.Column)({
49
49
  type: "bigint",
50
50
  comment: "Cuánto fue el consumo de almacenamiento (media_file) de la empresa para el mes y año.",
51
- }),
52
- __metadata("design:type", Number)
51
+ })
52
+ // DOC: MySQL/mysql2 devuelve BIGINT como string (evita pérdida de precisión con
53
+ // números > 2^53). Se tipa string; usar Number()/bytesToGb al consumirlo.
54
+ ,
55
+ __metadata("design:type", String)
53
56
  ], BillingUsageSnapshot.prototype, "storage_bytes", void 0);
54
57
  __decorate([
55
58
  (0, typeorm_1.Column)({
@@ -2,7 +2,7 @@ import { Vehicle } from "./Vehicle";
2
2
  import { Client } from "./Client";
3
3
  import { Associate } from "./Associate";
4
4
  import { Workshop } from "./Workshop";
5
- import { BillingInvoice, BillingUsageSnapshot, CompanyBrand, Country, EmailLog, MediaFile, PaymentMethod, UsageAlert, WhatsappLog } from "..";
5
+ import { BillingInvoice, BillingUsageSnapshot, CompanyBrand, CompanySubscription, Country, EmailLog, MediaFile, PaymentMethod, UsageAlert, WhatsappLog } from "..";
6
6
  export declare class Company {
7
7
  id: number;
8
8
  country: Country;
@@ -22,4 +22,5 @@ export declare class Company {
22
22
  email_logs: EmailLog[];
23
23
  billing_invoices: BillingInvoice[];
24
24
  usage_alerts: UsageAlert[];
25
+ company_subscriptions: CompanySubscription[];
25
26
  }
@@ -113,6 +113,10 @@ __decorate([
113
113
  (0, typeorm_1.OneToMany)(() => __1.UsageAlert, (usageAlert) => usageAlert.company),
114
114
  __metadata("design:type", Array)
115
115
  ], Company.prototype, "usage_alerts", void 0);
116
+ __decorate([
117
+ (0, typeorm_1.OneToMany)(() => __1.CompanySubscription, (companySubscription) => companySubscription.company),
118
+ __metadata("design:type", Array)
119
+ ], Company.prototype, "company_subscriptions", void 0);
116
120
  exports.Company = Company = __decorate([
117
121
  (0, typeorm_1.Entity)({ comment: "Empresas registradas en la plataforma." })
118
122
  ], Company);
@@ -26,7 +26,7 @@ __decorate([
26
26
  __metadata("design:type", Number)
27
27
  ], CompanySubscription.prototype, "id", void 0);
28
28
  __decorate([
29
- (0, typeorm_1.ManyToOne)(() => Company_1.Company, (company) => company.associates, {
29
+ (0, typeorm_1.ManyToOne)(() => Company_1.Company, (company) => company.company_subscriptions, {
30
30
  onDelete: "CASCADE",
31
31
  onUpdate: "NO ACTION",
32
32
  }),
@@ -99,7 +99,7 @@ __decorate([
99
99
  default: 1,
100
100
  type: "int",
101
101
  width: 1,
102
- comment: "Estado del plan de la empresa:\r\n1: Activo.\r\n2: Suspendido.\r\n3: Cancelado.\r\n4: Expirado.\r\n5: Trial ().\r\n6: Pendiente de pago (elegido pero aún sin pagar la primera factura).",
102
+ comment: "Estado del plan de la empresa:\r\n1: Activo.\r\n2: Suspendido.\r\n3: Cancelado.\r\n4: Expirado.\r\n5: Trial (período de prueba).\r\n6: Pendiente de pago (elegido pero aún sin pagar la primera factura).",
103
103
  }),
104
104
  __metadata("design:type", Number)
105
105
  ], CompanySubscription.prototype, "status", void 0);
@@ -132,4 +132,8 @@ __decorate([
132
132
  exports.CompanySubscription = CompanySubscription = __decorate([
133
133
  (0, typeorm_1.Entity)({ comment: "Plan de la empresa.", name: "company_subscription" }),
134
134
  (0, typeorm_1.Index)("IDX_company_subscription_company", ["company"])
135
+ // DOC: El job mensual busca las suscripciones a cobrar por billing_day + status;
136
+ // indexarlo evita recorrer toda la tabla cada día.
137
+ ,
138
+ (0, typeorm_1.Index)("IDX_company_subscription_billing", ["billing_day", "status"])
135
139
  ], CompanySubscription);
@@ -12,4 +12,5 @@ export declare class PaymentTransaction {
12
12
  error_message: string | null;
13
13
  transaction_date: Date;
14
14
  created: Date;
15
+ updated: Date | null;
15
16
  }
@@ -110,6 +110,16 @@ __decorate([
110
110
  }),
111
111
  __metadata("design:type", Date)
112
112
  ], PaymentTransaction.prototype, "created", void 0);
113
+ __decorate([
114
+ (0, typeorm_1.Column)({
115
+ type: "datetime",
116
+ default: null,
117
+ nullable: true,
118
+ comment: "Fecha de la última actualización del registro.",
119
+ onUpdate: "CURRENT_TIMESTAMP",
120
+ }),
121
+ __metadata("design:type", Object)
122
+ ], PaymentTransaction.prototype, "updated", void 0);
113
123
  exports.PaymentTransaction = PaymentTransaction = __decorate([
114
124
  (0, typeorm_1.Entity)({
115
125
  comment: "Registro histórico de todos los intentos de cobro realizados.",
@@ -4,7 +4,7 @@ export declare class SubscriptionAddonTemplate {
4
4
  id: number;
5
5
  code: string;
6
6
  name: string;
7
- description: any | null;
7
+ description: string;
8
8
  addon_type: number;
9
9
  quantity: number;
10
10
  monthly_price: number;
@@ -45,7 +45,7 @@ __decorate([
45
45
  type: "text",
46
46
  comment: "Descripción del paquete.",
47
47
  }),
48
- __metadata("design:type", Object)
48
+ __metadata("design:type", String)
49
49
  ], SubscriptionAddonTemplate.prototype, "description", void 0);
50
50
  __decorate([
51
51
  (0, typeorm_1.Column)({
@@ -14,5 +14,6 @@ export declare class SubscriptionPlan {
14
14
  is_custom: number;
15
15
  status: number;
16
16
  created: Date;
17
+ updated: Date | null;
17
18
  companySubscriptions: CompanySubscription[];
18
19
  }
@@ -127,6 +127,16 @@ __decorate([
127
127
  }),
128
128
  __metadata("design:type", Date)
129
129
  ], SubscriptionPlan.prototype, "created", void 0);
130
+ __decorate([
131
+ (0, typeorm_1.Column)({
132
+ type: "datetime",
133
+ default: null,
134
+ nullable: true,
135
+ comment: "Fecha de la última actualización del registro.",
136
+ onUpdate: "CURRENT_TIMESTAMP",
137
+ }),
138
+ __metadata("design:type", Object)
139
+ ], SubscriptionPlan.prototype, "updated", void 0);
130
140
  __decorate([
131
141
  (0, typeorm_1.OneToMany)(() => CompanySubscription_1.CompanySubscription, (companySubscription) => companySubscription.subscription_plan),
132
142
  __metadata("design:type", Array)
@@ -6,7 +6,7 @@ export declare class UsageAlert {
6
6
  resource_type: number;
7
7
  threshold_percent: number;
8
8
  action_type: number;
9
- subscription_addon_template: SubscriptionAddonTemplate;
9
+ subscription_addon_template: SubscriptionAddonTemplate | null;
10
10
  notification_email: string | null;
11
11
  last_triggered_at: Date | null;
12
12
  max_autopurchases: number | null;
@@ -56,9 +56,10 @@ __decorate([
56
56
  (0, typeorm_1.ManyToOne)(() => SubscriptionAddonTemplate_1.SubscriptionAddonTemplate, (subscriptionAddonTemplate) => subscriptionAddonTemplate.usage_alerts, {
57
57
  onDelete: "SET NULL",
58
58
  onUpdate: "NO ACTION",
59
+ nullable: true,
59
60
  }),
60
61
  (0, typeorm_1.JoinColumn)({ name: "subscription_addon_template" }),
61
- __metadata("design:type", SubscriptionAddonTemplate_1.SubscriptionAddonTemplate)
62
+ __metadata("design:type", Object)
62
63
  ], UsageAlert.prototype, "subscription_addon_template", void 0);
63
64
  __decorate([
64
65
  (0, typeorm_1.Column)({
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@asumano/worklip-typeorm-db",
3
- "version": "1.1.48",
3
+ "version": "1.1.49",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },