@asumano/worklip-typeorm-db 1.1.86 → 1.1.88

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.
@@ -13,6 +13,7 @@ export declare class BillingInvoice {
13
13
  discount: number;
14
14
  tax: number;
15
15
  total: number;
16
+ currency: string;
16
17
  status: number;
17
18
  due_date: Date;
18
19
  paid_date: Date | null;
@@ -114,6 +114,15 @@ __decorate([
114
114
  }),
115
115
  __metadata("design:type", Number)
116
116
  ], BillingInvoice.prototype, "total", void 0);
117
+ __decorate([
118
+ (0, typeorm_1.Column)({
119
+ length: 10,
120
+ type: "varchar",
121
+ default: "COP",
122
+ comment: "Moneda de la factura (ISO 4217).",
123
+ }),
124
+ __metadata("design:type", String)
125
+ ], BillingInvoice.prototype, "currency", void 0);
117
126
  __decorate([
118
127
  (0, typeorm_1.Column)({
119
128
  default: 1,
@@ -13,6 +13,7 @@ export declare class CompanySubscription {
13
13
  end_date: string | null;
14
14
  billing_day: number;
15
15
  price_monthly: number;
16
+ currency: string;
16
17
  status: number;
17
18
  created: Date;
18
19
  updated: Date | null;
@@ -95,6 +95,15 @@ __decorate([
95
95
  }),
96
96
  __metadata("design:type", Number)
97
97
  ], CompanySubscription.prototype, "price_monthly", void 0);
98
+ __decorate([
99
+ (0, typeorm_1.Column)({
100
+ length: 10,
101
+ type: "varchar",
102
+ default: "COP",
103
+ comment: "Moneda en la que se cobra la suscripción (ISO 4217).",
104
+ }),
105
+ __metadata("design:type", String)
106
+ ], CompanySubscription.prototype, "currency", void 0);
98
107
  __decorate([
99
108
  (0, typeorm_1.Column)({
100
109
  default: 1,
@@ -1,4 +1,4 @@
1
- import { Company, CompanyDiscount } from "../entities.views.routes";
1
+ import { Company, CompanyDiscount, Country } from "../entities.views.routes";
2
2
  export declare class DiscountCode {
3
3
  id: number;
4
4
  code: string;
@@ -6,6 +6,7 @@ export declare class DiscountCode {
6
6
  description: string | null;
7
7
  type: number;
8
8
  value: number;
9
+ country: Country;
9
10
  applies_to_plan: number;
10
11
  applies_to_addons: number;
11
12
  applies_to_features: number;
@@ -17,6 +17,7 @@ const entities_views_routes_1 = require("../entities.views.routes");
17
17
  // El código dice QUÉ descuenta (porcentaje o monto), SOBRE QUÉ (plan, complementos,
18
18
  // funcionalidades, o varias), CUÁNTO dura una vez canjeado, hasta cuándo se puede canjear y
19
19
  // quién lo puede canjear. El canje en sí vive en `company_discount`.
20
+ // DOC: El código es único POR PAÍS: el mismo PRO puede existir en dos catálogos.
20
21
  let DiscountCode = class DiscountCode {
21
22
  };
22
23
  exports.DiscountCode = DiscountCode;
@@ -31,7 +32,6 @@ __decorate([
31
32
  (0, typeorm_1.Column)({
32
33
  length: 30,
33
34
  type: "varchar",
34
- unique: true,
35
35
  comment: "Código que escribe la empresa (ej: WELCOME20). Se guarda en mayúsculas.",
36
36
  }),
37
37
  __metadata("design:type", String)
@@ -70,6 +70,11 @@ __decorate([
70
70
  }),
71
71
  __metadata("design:type", Number)
72
72
  ], DiscountCode.prototype, "value", void 0);
73
+ __decorate([
74
+ (0, typeorm_1.ManyToOne)(() => entities_views_routes_1.Country, { onDelete: "RESTRICT", onUpdate: "NO ACTION" }),
75
+ (0, typeorm_1.JoinColumn)({ name: "country" }),
76
+ __metadata("design:type", entities_views_routes_1.Country)
77
+ ], DiscountCode.prototype, "country", void 0);
73
78
  __decorate([
74
79
  (0, typeorm_1.Column)({
75
80
  default: 1,
@@ -196,6 +201,7 @@ __decorate([
196
201
  __metadata("design:type", Array)
197
202
  ], DiscountCode.prototype, "redemptions", void 0);
198
203
  exports.DiscountCode = DiscountCode = __decorate([
204
+ (0, typeorm_1.Index)("UQ_discount_code_country_code", ["country", "code"], { unique: true }),
199
205
  (0, typeorm_1.Entity)({
200
206
  comment: "Catálogo de códigos de descuento.",
201
207
  name: "discount_code",
@@ -1,4 +1,4 @@
1
- import { AssociatePermission, AssociateSection, CompanyFeature, SubscriptionPlan } from "../entities.views.routes";
1
+ import { AssociatePermission, AssociateSection, CompanyFeature, Country, PlanFeature } from "../entities.views.routes";
2
2
  export declare class Feature {
3
3
  id: number;
4
4
  code: string;
@@ -7,10 +7,11 @@ export declare class Feature {
7
7
  icon: string;
8
8
  scope: number;
9
9
  monthly_price: number;
10
+ country: Country;
10
11
  status: number;
11
12
  created: Date;
12
13
  updated: Date | null;
13
- plans: SubscriptionPlan[];
14
+ plan_features: PlanFeature[];
14
15
  company_features: CompanyFeature[];
15
16
  sections: AssociateSection[];
16
17
  permissions: AssociatePermission[];
@@ -20,6 +20,7 @@ const entities_views_routes_1 = require("../entities.views.routes");
20
20
  // Mezclarlas en la misma tabla se descartó a propósito: los complementos alimentan las
21
21
  // Alertas de consumo ("cómprame otro paquete al llegar al 80%"), y eso no significa nada
22
22
  // para algo booleano.
23
+ // DOC: El código es único POR PAÍS: el mismo PRO puede existir en dos catálogos.
23
24
  let Feature = class Feature {
24
25
  };
25
26
  exports.Feature = Feature;
@@ -34,7 +35,6 @@ __decorate([
34
35
  (0, typeorm_1.Column)({
35
36
  length: 30,
36
37
  type: "varchar",
37
- unique: true,
38
38
  comment: "Código único de la funcionalidad (ej: WORK_BOARD).",
39
39
  }),
40
40
  __metadata("design:type", String)
@@ -81,6 +81,11 @@ __decorate([
81
81
  }),
82
82
  __metadata("design:type", Number)
83
83
  ], Feature.prototype, "monthly_price", void 0);
84
+ __decorate([
85
+ (0, typeorm_1.ManyToOne)(() => entities_views_routes_1.Country, { onDelete: "RESTRICT", onUpdate: "NO ACTION" }),
86
+ (0, typeorm_1.JoinColumn)({ name: "country" }),
87
+ __metadata("design:type", entities_views_routes_1.Country)
88
+ ], Feature.prototype, "country", void 0);
84
89
  __decorate([
85
90
  (0, typeorm_1.Column)({
86
91
  default: 1,
@@ -109,9 +114,9 @@ __decorate([
109
114
  __metadata("design:type", Object)
110
115
  ], Feature.prototype, "updated", void 0);
111
116
  __decorate([
112
- (0, typeorm_1.ManyToMany)(() => entities_views_routes_1.SubscriptionPlan, (plan) => plan.features),
117
+ (0, typeorm_1.OneToMany)(() => entities_views_routes_1.PlanFeature, (planFeature) => planFeature.feature),
113
118
  __metadata("design:type", Array)
114
- ], Feature.prototype, "plans", void 0);
119
+ ], Feature.prototype, "plan_features", void 0);
115
120
  __decorate([
116
121
  (0, typeorm_1.OneToMany)(() => entities_views_routes_1.CompanyFeature, (companyFeature) => companyFeature.feature),
117
122
  __metadata("design:type", Array)
@@ -125,6 +130,7 @@ __decorate([
125
130
  __metadata("design:type", Array)
126
131
  ], Feature.prototype, "permissions", void 0);
127
132
  exports.Feature = Feature = __decorate([
133
+ (0, typeorm_1.Index)("UQ_feature_country_code", ["country", "code"], { unique: true }),
128
134
  (0, typeorm_1.Entity)({
129
135
  comment: "Catálogo de funcionalidades que se pueden contratar aparte del plan.",
130
136
  name: "feature",
@@ -0,0 +1,27 @@
1
+ import { Feature, SubscriptionPlan } from "../entities.views.routes";
2
+ /**
3
+ * DOC: Funcionalidades que un plan trae INCLUIDAS, sin cobrarse aparte.
4
+ *
5
+ * Era una tabla puente sin columnas propias (una `@ManyToMany`). Pasó a entidad explícita para
6
+ * poder llevar `seats`: sin ella, incluir en el plan una funcionalidad POR TALLER la regalaba
7
+ * en todos los talleres de la empresa, incluidos los que se compran después como complemento.
8
+ */
9
+ export declare class PlanFeature {
10
+ subscription_plan_id: number;
11
+ feature_id: number;
12
+ subscription_plan: SubscriptionPlan;
13
+ feature: Feature;
14
+ /**
15
+ * DOC: A cuántos TALLERES alcanza lo que el plan incluye. NULL = sin tope.
16
+ *
17
+ * NULL es el valor de todas las filas anteriores a esta columna, y significa lo que hacían
18
+ * entonces: la funcionalidad vale en toda la empresa. Así la migración no le cambia el
19
+ * comportamiento a ningún plan ya vendido.
20
+ *
21
+ * Con un número, el plan cubre como mucho esos talleres: los cupos se colocan uno por taller
22
+ * (`company_feature` con `origin = 3`) y, agotados, el resto hay que comprarlo.
23
+ *
24
+ * ⚠️ Solo significa algo en el alcance POR TALLER. En uno de empresa no hay nada que contar.
25
+ */
26
+ seats: number | null;
27
+ }
@@ -0,0 +1,63 @@
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.PlanFeature = void 0;
13
+ const typeorm_1 = require("typeorm");
14
+ const entities_views_routes_1 = require("../entities.views.routes");
15
+ /**
16
+ * DOC: Funcionalidades que un plan trae INCLUIDAS, sin cobrarse aparte.
17
+ *
18
+ * Era una tabla puente sin columnas propias (una `@ManyToMany`). Pasó a entidad explícita para
19
+ * poder llevar `seats`: sin ella, incluir en el plan una funcionalidad POR TALLER la regalaba
20
+ * en todos los talleres de la empresa, incluidos los que se compran después como complemento.
21
+ */
22
+ let PlanFeature = class PlanFeature {
23
+ };
24
+ exports.PlanFeature = PlanFeature;
25
+ __decorate([
26
+ (0, typeorm_1.PrimaryColumn)({ type: "int", name: "subscription_plan" }),
27
+ __metadata("design:type", Number)
28
+ ], PlanFeature.prototype, "subscription_plan_id", void 0);
29
+ __decorate([
30
+ (0, typeorm_1.PrimaryColumn)({ type: "int", name: "feature" }),
31
+ __metadata("design:type", Number)
32
+ ], PlanFeature.prototype, "feature_id", void 0);
33
+ __decorate([
34
+ (0, typeorm_1.ManyToOne)(() => entities_views_routes_1.SubscriptionPlan, (plan) => plan.plan_features, {
35
+ onDelete: "CASCADE",
36
+ onUpdate: "NO ACTION",
37
+ }),
38
+ (0, typeorm_1.JoinColumn)({ name: "subscription_plan" }),
39
+ __metadata("design:type", entities_views_routes_1.SubscriptionPlan)
40
+ ], PlanFeature.prototype, "subscription_plan", void 0);
41
+ __decorate([
42
+ (0, typeorm_1.ManyToOne)(() => entities_views_routes_1.Feature, (feature) => feature.plan_features, {
43
+ onDelete: "CASCADE",
44
+ onUpdate: "NO ACTION",
45
+ }),
46
+ (0, typeorm_1.JoinColumn)({ name: "feature" }),
47
+ __metadata("design:type", entities_views_routes_1.Feature)
48
+ ], PlanFeature.prototype, "feature", void 0);
49
+ __decorate([
50
+ (0, typeorm_1.Column)({
51
+ type: "int",
52
+ nullable: true,
53
+ default: null,
54
+ comment: "A cuántos talleres alcanza la funcionalidad incluida. NULL significa que no tiene tope.",
55
+ }),
56
+ __metadata("design:type", Object)
57
+ ], PlanFeature.prototype, "seats", void 0);
58
+ exports.PlanFeature = PlanFeature = __decorate([
59
+ (0, typeorm_1.Entity)({
60
+ comment: "Funcionalidades incluidas en un plan.",
61
+ name: "plan_feature",
62
+ })
63
+ ], PlanFeature);
@@ -1,3 +1,4 @@
1
+ import { Country } from "./Country";
1
2
  import { UsageAlert } from "./UsageAlert";
2
3
  import { SubscriptionAddon } from "./SubscriptionAddon";
3
4
  export declare class SubscriptionAddonTemplate {
@@ -8,6 +9,7 @@ export declare class SubscriptionAddonTemplate {
8
9
  addon_type: number;
9
10
  quantity: number;
10
11
  monthly_price: number;
12
+ country: Country;
11
13
  status: number;
12
14
  created: Date;
13
15
  updated: Date | null;
@@ -11,8 +11,10 @@ var __metadata = (this && this.__metadata) || function (k, v) {
11
11
  Object.defineProperty(exports, "__esModule", { value: true });
12
12
  exports.SubscriptionAddonTemplate = void 0;
13
13
  const typeorm_1 = require("typeorm");
14
+ const Country_1 = require("./Country");
14
15
  const UsageAlert_1 = require("./UsageAlert");
15
16
  const SubscriptionAddon_1 = require("./SubscriptionAddon");
17
+ // DOC: El código es único POR PAÍS: el mismo PRO puede existir en dos catálogos.
16
18
  let SubscriptionAddonTemplate = class SubscriptionAddonTemplate {
17
19
  };
18
20
  exports.SubscriptionAddonTemplate = SubscriptionAddonTemplate;
@@ -27,7 +29,6 @@ __decorate([
27
29
  (0, typeorm_1.Column)({
28
30
  length: 20,
29
31
  type: "varchar",
30
- unique: true,
31
32
  comment: "Código único del paquete.",
32
33
  }),
33
34
  __metadata("design:type", String)
@@ -70,6 +71,11 @@ __decorate([
70
71
  }),
71
72
  __metadata("design:type", Number)
72
73
  ], SubscriptionAddonTemplate.prototype, "monthly_price", void 0);
74
+ __decorate([
75
+ (0, typeorm_1.ManyToOne)(() => Country_1.Country, { onDelete: "RESTRICT", onUpdate: "NO ACTION" }),
76
+ (0, typeorm_1.JoinColumn)({ name: "country" }),
77
+ __metadata("design:type", Country_1.Country)
78
+ ], SubscriptionAddonTemplate.prototype, "country", void 0);
73
79
  __decorate([
74
80
  (0, typeorm_1.Column)({
75
81
  default: 1,
@@ -106,6 +112,7 @@ __decorate([
106
112
  __metadata("design:type", Array)
107
113
  ], SubscriptionAddonTemplate.prototype, "subscription_addons", void 0);
108
114
  exports.SubscriptionAddonTemplate = SubscriptionAddonTemplate = __decorate([
115
+ (0, typeorm_1.Index)("UQ_subscription_addon_template_country_code", ["country", "code"], { unique: true }),
109
116
  (0, typeorm_1.Entity)({
110
117
  comment: "Catálogo de paquetes adicionales que pueden ser adquiridos por las empresas.",
111
118
  name: "subscription_addon_template",
@@ -1,12 +1,14 @@
1
1
  import { Company } from "./Company";
2
+ import { Country } from "./Country";
2
3
  import { CompanySubscription } from "./CompanySubscription";
3
- import { Feature } from "./Feature";
4
+ import { PlanFeature } from "./PlanFeature";
4
5
  export declare class SubscriptionPlan {
5
6
  id: number;
6
7
  code: string;
7
8
  name: string;
8
9
  description: string | null;
9
10
  price_monthly: number;
11
+ country: Country;
10
12
  included_storage_gb: number;
11
13
  included_whatsapp_messages: number;
12
14
  included_emails: number;
@@ -32,5 +34,5 @@ export declare class SubscriptionPlan {
32
34
  created: Date;
33
35
  updated: Date | null;
34
36
  companySubscriptions: CompanySubscription[];
35
- features: Feature[];
37
+ plan_features: PlanFeature[];
36
38
  }
@@ -12,8 +12,10 @@ Object.defineProperty(exports, "__esModule", { value: true });
12
12
  exports.SubscriptionPlan = void 0;
13
13
  const typeorm_1 = require("typeorm");
14
14
  const Company_1 = require("./Company");
15
+ const Country_1 = require("./Country");
15
16
  const CompanySubscription_1 = require("./CompanySubscription");
16
- const Feature_1 = require("./Feature");
17
+ const PlanFeature_1 = require("./PlanFeature");
18
+ // DOC: El código es único POR PAÍS: el mismo PRO puede existir en dos catálogos.
17
19
  let SubscriptionPlan = class SubscriptionPlan {
18
20
  };
19
21
  exports.SubscriptionPlan = SubscriptionPlan;
@@ -28,7 +30,6 @@ __decorate([
28
30
  (0, typeorm_1.Column)({
29
31
  length: 15,
30
32
  type: "varchar",
31
- unique: true,
32
33
  comment: "Código único del plan.",
33
34
  }),
34
35
  __metadata("design:type", String)
@@ -51,10 +52,15 @@ __decorate([
51
52
  type: "decimal",
52
53
  precision: 14,
53
54
  scale: 2,
54
- comment: "Precio del plan.",
55
+ comment: "Precio del plan, en la moneda del país.",
55
56
  }),
56
57
  __metadata("design:type", Number)
57
58
  ], SubscriptionPlan.prototype, "price_monthly", void 0);
59
+ __decorate([
60
+ (0, typeorm_1.ManyToOne)(() => Country_1.Country, { onDelete: "RESTRICT", onUpdate: "NO ACTION" }),
61
+ (0, typeorm_1.JoinColumn)({ name: "country" }),
62
+ __metadata("design:type", Country_1.Country)
63
+ ], SubscriptionPlan.prototype, "country", void 0);
58
64
  __decorate([
59
65
  (0, typeorm_1.Column)({
60
66
  default: 0,
@@ -157,20 +163,10 @@ __decorate([
157
163
  __metadata("design:type", Array)
158
164
  ], SubscriptionPlan.prototype, "companySubscriptions", void 0);
159
165
  __decorate([
160
- (0, typeorm_1.ManyToMany)(() => Feature_1.Feature, (feature) => feature.plans),
161
- (0, typeorm_1.JoinTable)({
162
- name: "plan_feature",
163
- joinColumn: {
164
- name: "subscription_plan",
165
- referencedColumnName: "id",
166
- },
167
- inverseJoinColumn: {
168
- name: "feature",
169
- referencedColumnName: "id",
170
- },
171
- }),
166
+ (0, typeorm_1.OneToMany)(() => PlanFeature_1.PlanFeature, (planFeature) => planFeature.subscription_plan),
172
167
  __metadata("design:type", Array)
173
- ], SubscriptionPlan.prototype, "features", void 0);
168
+ ], SubscriptionPlan.prototype, "plan_features", void 0);
174
169
  exports.SubscriptionPlan = SubscriptionPlan = __decorate([
170
+ (0, typeorm_1.Index)("UQ_subscription_plan_country_code", ["country", "code"], { unique: true }),
175
171
  (0, typeorm_1.Entity)({ comment: "Planes que tiene el software.", name: "subscription_plan" })
176
172
  ], SubscriptionPlan);
@@ -52,6 +52,7 @@ export { SubscriptionAddonTemplate } from "./entities/SubscriptionAddonTemplate"
52
52
  export { UsageAlert } from "./entities/UsageAlert";
53
53
  export { Feature } from "./entities/Feature";
54
54
  export { CompanyFeature } from "./entities/CompanyFeature";
55
+ export { PlanFeature } from "./entities/PlanFeature";
55
56
  export { DiscountCode } from "./entities/DiscountCode";
56
57
  export { CompanyDiscount } from "./entities/CompanyDiscount";
57
58
  export { WorkboardStatus } from "./entities/WorkboardStatus";
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.PaymentTransaction = exports.BillingInvoice = exports.EmailSuppression = exports.EmailLog = exports.WhatsappLog = exports.ServiceOrderApproval = exports.MediaFile = exports.BillingUsageSnapshot = exports.PaymentMethod = exports.SubscriptionAddon = exports.CompanySubscription = exports.SubscriptionPlan = exports.CountryHoliday = exports.CompanyVehicleType = exports.BrandVehicleType = exports.CompanyBrand = exports.VehicleType = exports.MasterSection = exports.MasterPermission = exports.MasterRole = exports.MasterPlatform = exports.MasterPasswordReset = exports.AssociatePasswordReset = exports.AssociateSection = exports.AssociatePermission = exports.AssociateRole = exports.AssociatePlatform = exports.Reminder = exports.ServiceOrderHistory = exports.ServiceOrder = exports.TemplateSection = exports.SectionItem = exports.Section = exports.Template = exports.Workshop = exports.GlobalTemplateSection = exports.GlobalSectionItem = exports.GlobalSection = exports.GlobalTemplate = exports.AssociateSession = exports.MasterSession = exports.Associate = exports.Client = exports.Master = exports.Vehicle = exports.Brand = exports.Company = exports.City = exports.Region = exports.Country = void 0;
4
- exports.GlobalSectionItems = exports.GlobalSections = exports.GlobalTemplates = exports.SubscriptionAddonTemplates = exports.SubscriptionPlans = exports.Masters = exports.Companies = exports.WorkshopsByAssociate = exports.Workshops = exports.SectionItems = exports.Sections = exports.Templates = exports.Reminders = exports.Vehicles = exports.Clients = exports.ServicesOrder = exports.Associates = exports.WorkboardEvent = exports.ServiceOrderStage = exports.WorkboardStatus = exports.CompanyDiscount = exports.DiscountCode = exports.CompanyFeature = exports.Feature = exports.UsageAlert = exports.SubscriptionAddonTemplate = void 0;
4
+ exports.GlobalSectionItems = exports.GlobalSections = exports.GlobalTemplates = exports.SubscriptionAddonTemplates = exports.SubscriptionPlans = exports.Masters = exports.Companies = exports.WorkshopsByAssociate = exports.Workshops = exports.SectionItems = exports.Sections = exports.Templates = exports.Reminders = exports.Vehicles = exports.Clients = exports.ServicesOrder = exports.Associates = exports.WorkboardEvent = exports.ServiceOrderStage = exports.WorkboardStatus = exports.CompanyDiscount = exports.DiscountCode = exports.PlanFeature = exports.CompanyFeature = exports.Feature = exports.UsageAlert = exports.SubscriptionAddonTemplate = void 0;
5
5
  var Country_1 = require("./entities/Country");
6
6
  Object.defineProperty(exports, "Country", { enumerable: true, get: function () { return Country_1.Country; } });
7
7
  var Region_1 = require("./entities/Region");
@@ -113,6 +113,8 @@ var Feature_1 = require("./entities/Feature");
113
113
  Object.defineProperty(exports, "Feature", { enumerable: true, get: function () { return Feature_1.Feature; } });
114
114
  var CompanyFeature_1 = require("./entities/CompanyFeature");
115
115
  Object.defineProperty(exports, "CompanyFeature", { enumerable: true, get: function () { return CompanyFeature_1.CompanyFeature; } });
116
+ var PlanFeature_1 = require("./entities/PlanFeature");
117
+ Object.defineProperty(exports, "PlanFeature", { enumerable: true, get: function () { return PlanFeature_1.PlanFeature; } });
116
118
  // DOC: Codigos de descuento. Ver `discount.rules.ts` para el calculo, que es compartido.
117
119
  var DiscountCode_1 = require("./entities/DiscountCode");
118
120
  Object.defineProperty(exports, "DiscountCode", { enumerable: true, get: function () { return DiscountCode_1.DiscountCode; } });
@@ -12,8 +12,14 @@ export declare const FEATURE_SCOPE_LABEL: Record<number, string>;
12
12
  * vender y el panel al regalar una funcionalidad. Sin ella se podría guardar un chatbot
13
13
  * "de empresa" con taller, o un tablero "por taller" sin ninguno, y en los dos casos la
14
14
  * resolución devolvería algo que nadie quiso vender.
15
+ *
16
+ * ⚠️ `allowUnassigned` abre una excepción: POR TALLER sin taller = licencia sin colocar (ver
17
+ * `isUnassignedSeat`). Va como opción y no por defecto para que una compra a la que le falte
18
+ * el taller no se guarde en silencio sin dar acceso a nadie.
15
19
  */
16
- export declare const isValidFeatureGrant: (scope: number, workshop: number | null | undefined) => boolean;
20
+ export declare const isValidFeatureGrant: (scope: number, workshop: number | null | undefined, options?: {
21
+ allowUnassigned?: boolean;
22
+ }) => boolean;
17
23
  /**
18
24
  * DOC: ¿Esta concesión sigue viva en una fecha dada?
19
25
  *
@@ -26,3 +32,34 @@ export declare const isValidFeatureGrant: (scope: number, workshop: number | nul
26
32
  export declare const isFeatureGrantAliveAt: (grant: {
27
33
  end_date?: Date | string | null;
28
34
  }, at: Date) => boolean;
35
+ export declare const FEATURE_ORIGIN: {
36
+ readonly PURCHASED: 1;
37
+ readonly COURTESY: 2;
38
+ readonly PLAN: 3;
39
+ };
40
+ export type TFeatureOrigin = (typeof FEATURE_ORIGIN)[keyof typeof FEATURE_ORIGIN];
41
+ /**
42
+ * DOC: ¿Es una LICENCIA SIN COLOCAR? Alcance POR TALLER con `workshop = NULL`.
43
+ *
44
+ * Se representa sin columna nueva porque esa combinación era INVÁLIDA hasta hoy, así que el
45
+ * significado estaba libre.
46
+ *
47
+ * ⚠️ NO aplica al alcance AMBAS: ahí `workshop = NULL` ya significa «toda la empresa» y es
48
+ * legítimo. Tampoco hace falta — con AMBAS siempre se puede conceder a toda la empresa.
49
+ */
50
+ export declare const isUnassignedSeat: (scope: number, workshop: number | null | undefined) => boolean;
51
+ /**
52
+ * DOC: ¿Esta concesión DA ACCESO en algún lado?
53
+ *
54
+ * ⚠️ No es lo mismo que «existe la fila»: una licencia sin colocar existe, puede estar
55
+ * cobrándose, y no da acceso hasta que se le asigne un taller. Si la consulta de concesiones
56
+ * no trajera el `scope`, esa fila caería en el balde de «toda la empresa».
57
+ */
58
+ export declare const isFeatureGrantPlaced: (scope: number, workshop: number | null | undefined) => boolean;
59
+ /**
60
+ * DOC: ¿El plan tiene TOPE de talleres para esta funcionalidad (`plan_feature.seats`)?
61
+ *
62
+ * NULL = sin tope, que es lo que hacían todas las filas anteriores a la columna: la migración
63
+ * no le cambia el comportamiento a ningún plan ya vendido.
64
+ */
65
+ export declare const planSeatsAreLimited: (seats: number | null | undefined) => seats is number;
@@ -3,7 +3,7 @@
3
3
  // necesitan los tres: el panel para ofrecer el formulario correcto al crear la funcionalidad,
4
4
  // el portal para pedir (o no) un taller al comprarla, y el API para validar la concesión.
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.isFeatureGrantAliveAt = exports.isValidFeatureGrant = exports.FEATURE_SCOPE_LABEL = exports.FEATURE_SCOPE = void 0;
6
+ exports.planSeatsAreLimited = exports.isFeatureGrantPlaced = exports.isUnassignedSeat = exports.FEATURE_ORIGIN = exports.isFeatureGrantAliveAt = exports.isValidFeatureGrant = exports.FEATURE_SCOPE_LABEL = exports.FEATURE_SCOPE = void 0;
7
7
  exports.FEATURE_SCOPE = {
8
8
  // DOC: Se contrata una vez para toda la empresa. La concesión va con `workshop = NULL`.
9
9
  COMPANY: 1,
@@ -26,9 +26,15 @@ exports.FEATURE_SCOPE_LABEL = {
26
26
  * vender y el panel al regalar una funcionalidad. Sin ella se podría guardar un chatbot
27
27
  * "de empresa" con taller, o un tablero "por taller" sin ninguno, y en los dos casos la
28
28
  * resolución devolvería algo que nadie quiso vender.
29
+ *
30
+ * ⚠️ `allowUnassigned` abre una excepción: POR TALLER sin taller = licencia sin colocar (ver
31
+ * `isUnassignedSeat`). Va como opción y no por defecto para que una compra a la que le falte
32
+ * el taller no se guarde en silencio sin dar acceso a nadie.
29
33
  */
30
- const isValidFeatureGrant = (scope, workshop) => {
34
+ const isValidFeatureGrant = (scope, workshop, options) => {
31
35
  const hasWorkshop = workshop !== null && workshop !== undefined;
36
+ if (options?.allowUnassigned && (0, exports.isUnassignedSeat)(scope, workshop))
37
+ return true;
32
38
  if (Number(scope) === exports.FEATURE_SCOPE.COMPANY)
33
39
  return !hasWorkshop;
34
40
  if (Number(scope) === exports.FEATURE_SCOPE.WORKSHOP)
@@ -49,3 +55,42 @@ exports.isValidFeatureGrant = isValidFeatureGrant;
49
55
  */
50
56
  const isFeatureGrantAliveAt = (grant, at) => !grant.end_date || new Date(grant.end_date) > at;
51
57
  exports.isFeatureGrantAliveAt = isFeatureGrantAliveAt;
58
+ // DOC: De dónde salió una concesión (`company_feature.origin`), y es lo que decide si se cobra.
59
+ exports.FEATURE_ORIGIN = {
60
+ // DOC: Comprada suelta. Es la única que el job de facturación suma.
61
+ PURCHASED: 1,
62
+ // DOC: Cortesía o prueba. No se factura.
63
+ COURTESY: 2,
64
+ // DOC: Ocupa un CUPO del plan (`plan_feature.seats`). No se factura —ya está en el precio
65
+ // del plan—; la fila existe solo para saber en qué taller se colocó el cupo.
66
+ PLAN: 3,
67
+ };
68
+ /**
69
+ * DOC: ¿Es una LICENCIA SIN COLOCAR? Alcance POR TALLER con `workshop = NULL`.
70
+ *
71
+ * Se representa sin columna nueva porque esa combinación era INVÁLIDA hasta hoy, así que el
72
+ * significado estaba libre.
73
+ *
74
+ * ⚠️ NO aplica al alcance AMBAS: ahí `workshop = NULL` ya significa «toda la empresa» y es
75
+ * legítimo. Tampoco hace falta — con AMBAS siempre se puede conceder a toda la empresa.
76
+ */
77
+ const isUnassignedSeat = (scope, workshop) => Number(scope) === exports.FEATURE_SCOPE.WORKSHOP &&
78
+ (workshop === null || workshop === undefined);
79
+ exports.isUnassignedSeat = isUnassignedSeat;
80
+ /**
81
+ * DOC: ¿Esta concesión DA ACCESO en algún lado?
82
+ *
83
+ * ⚠️ No es lo mismo que «existe la fila»: una licencia sin colocar existe, puede estar
84
+ * cobrándose, y no da acceso hasta que se le asigne un taller. Si la consulta de concesiones
85
+ * no trajera el `scope`, esa fila caería en el balde de «toda la empresa».
86
+ */
87
+ const isFeatureGrantPlaced = (scope, workshop) => !(0, exports.isUnassignedSeat)(scope, workshop);
88
+ exports.isFeatureGrantPlaced = isFeatureGrantPlaced;
89
+ /**
90
+ * DOC: ¿El plan tiene TOPE de talleres para esta funcionalidad (`plan_feature.seats`)?
91
+ *
92
+ * NULL = sin tope, que es lo que hacían todas las filas anteriores a la columna: la migración
93
+ * no le cambia el comportamiento a ningún plan ya vendido.
94
+ */
95
+ const planSeatsAreLimited = (seats) => seats !== null && seats !== undefined && Number(seats) >= 0;
96
+ exports.planSeatsAreLimited = planSeatsAreLimited;
@@ -6,6 +6,10 @@ export declare class SubscriptionAddonTemplates {
6
6
  addon_type: number;
7
7
  quantity: number;
8
8
  monthly_price: number;
9
+ country: number;
10
+ country_name: string;
11
+ country_currency: string;
12
+ country_locale: string | null;
9
13
  status: number;
10
14
  created: Date;
11
15
  updated: Date | null;
@@ -42,6 +42,22 @@ __decorate([
42
42
  (0, typeorm_1.ViewColumn)(),
43
43
  __metadata("design:type", Number)
44
44
  ], SubscriptionAddonTemplates.prototype, "monthly_price", void 0);
45
+ __decorate([
46
+ (0, typeorm_1.ViewColumn)(),
47
+ __metadata("design:type", Number)
48
+ ], SubscriptionAddonTemplates.prototype, "country", void 0);
49
+ __decorate([
50
+ (0, typeorm_1.ViewColumn)(),
51
+ __metadata("design:type", String)
52
+ ], SubscriptionAddonTemplates.prototype, "country_name", void 0);
53
+ __decorate([
54
+ (0, typeorm_1.ViewColumn)(),
55
+ __metadata("design:type", String)
56
+ ], SubscriptionAddonTemplates.prototype, "country_currency", void 0);
57
+ __decorate([
58
+ (0, typeorm_1.ViewColumn)(),
59
+ __metadata("design:type", Object)
60
+ ], SubscriptionAddonTemplates.prototype, "country_locale", void 0);
45
61
  __decorate([
46
62
  (0, typeorm_1.ViewColumn)(),
47
63
  __metadata("design:type", Number)
@@ -14,6 +14,10 @@ export declare class SubscriptionPlans {
14
14
  is_custom: number;
15
15
  company: number | null;
16
16
  company_name: string | null;
17
+ country: number;
18
+ country_name: string;
19
+ country_currency: string;
20
+ country_locale: string | null;
17
21
  status: number;
18
22
  created: Date;
19
23
  updated: Date | null;
@@ -74,6 +74,22 @@ __decorate([
74
74
  (0, typeorm_1.ViewColumn)(),
75
75
  __metadata("design:type", Object)
76
76
  ], SubscriptionPlans.prototype, "company_name", void 0);
77
+ __decorate([
78
+ (0, typeorm_1.ViewColumn)(),
79
+ __metadata("design:type", Number)
80
+ ], SubscriptionPlans.prototype, "country", void 0);
81
+ __decorate([
82
+ (0, typeorm_1.ViewColumn)(),
83
+ __metadata("design:type", String)
84
+ ], SubscriptionPlans.prototype, "country_name", void 0);
85
+ __decorate([
86
+ (0, typeorm_1.ViewColumn)(),
87
+ __metadata("design:type", String)
88
+ ], SubscriptionPlans.prototype, "country_currency", void 0);
89
+ __decorate([
90
+ (0, typeorm_1.ViewColumn)(),
91
+ __metadata("design:type", Object)
92
+ ], SubscriptionPlans.prototype, "country_locale", void 0);
77
93
  __decorate([
78
94
  (0, typeorm_1.ViewColumn)(),
79
95
  __metadata("design:type", Number)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@asumano/worklip-typeorm-db",
3
- "version": "1.1.86",
3
+ "version": "1.1.88",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },