@asumano/worklip-typeorm-db 1.1.86 → 1.1.87
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/entities/Feature.d.ts +2 -2
- package/dist/entities/Feature.js +2 -2
- package/dist/entities/PlanFeature.d.ts +27 -0
- package/dist/entities/PlanFeature.js +63 -0
- package/dist/entities/SubscriptionPlan.d.ts +2 -2
- package/dist/entities/SubscriptionPlan.js +3 -14
- package/dist/entities.index.d.ts +1 -0
- package/dist/entities.index.js +3 -1
- package/dist/feature.scope.d.ts +38 -1
- package/dist/feature.scope.js +47 -2
- package/package.json +1 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { AssociatePermission, AssociateSection, CompanyFeature,
|
|
1
|
+
import { AssociatePermission, AssociateSection, CompanyFeature, PlanFeature } from "../entities.views.routes";
|
|
2
2
|
export declare class Feature {
|
|
3
3
|
id: number;
|
|
4
4
|
code: string;
|
|
@@ -10,7 +10,7 @@ export declare class Feature {
|
|
|
10
10
|
status: number;
|
|
11
11
|
created: Date;
|
|
12
12
|
updated: Date | null;
|
|
13
|
-
|
|
13
|
+
plan_features: PlanFeature[];
|
|
14
14
|
company_features: CompanyFeature[];
|
|
15
15
|
sections: AssociateSection[];
|
|
16
16
|
permissions: AssociatePermission[];
|
package/dist/entities/Feature.js
CHANGED
|
@@ -109,9 +109,9 @@ __decorate([
|
|
|
109
109
|
__metadata("design:type", Object)
|
|
110
110
|
], Feature.prototype, "updated", void 0);
|
|
111
111
|
__decorate([
|
|
112
|
-
(0, typeorm_1.
|
|
112
|
+
(0, typeorm_1.OneToMany)(() => entities_views_routes_1.PlanFeature, (planFeature) => planFeature.feature),
|
|
113
113
|
__metadata("design:type", Array)
|
|
114
|
-
], Feature.prototype, "
|
|
114
|
+
], Feature.prototype, "plan_features", void 0);
|
|
115
115
|
__decorate([
|
|
116
116
|
(0, typeorm_1.OneToMany)(() => entities_views_routes_1.CompanyFeature, (companyFeature) => companyFeature.feature),
|
|
117
117
|
__metadata("design:type", Array)
|
|
@@ -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,6 +1,6 @@
|
|
|
1
1
|
import { Company } from "./Company";
|
|
2
2
|
import { CompanySubscription } from "./CompanySubscription";
|
|
3
|
-
import {
|
|
3
|
+
import { PlanFeature } from "./PlanFeature";
|
|
4
4
|
export declare class SubscriptionPlan {
|
|
5
5
|
id: number;
|
|
6
6
|
code: string;
|
|
@@ -32,5 +32,5 @@ export declare class SubscriptionPlan {
|
|
|
32
32
|
created: Date;
|
|
33
33
|
updated: Date | null;
|
|
34
34
|
companySubscriptions: CompanySubscription[];
|
|
35
|
-
|
|
35
|
+
plan_features: PlanFeature[];
|
|
36
36
|
}
|
|
@@ -13,7 +13,7 @@ exports.SubscriptionPlan = void 0;
|
|
|
13
13
|
const typeorm_1 = require("typeorm");
|
|
14
14
|
const Company_1 = require("./Company");
|
|
15
15
|
const CompanySubscription_1 = require("./CompanySubscription");
|
|
16
|
-
const
|
|
16
|
+
const PlanFeature_1 = require("./PlanFeature");
|
|
17
17
|
let SubscriptionPlan = class SubscriptionPlan {
|
|
18
18
|
};
|
|
19
19
|
exports.SubscriptionPlan = SubscriptionPlan;
|
|
@@ -157,20 +157,9 @@ __decorate([
|
|
|
157
157
|
__metadata("design:type", Array)
|
|
158
158
|
], SubscriptionPlan.prototype, "companySubscriptions", void 0);
|
|
159
159
|
__decorate([
|
|
160
|
-
(0, typeorm_1.
|
|
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
|
-
}),
|
|
160
|
+
(0, typeorm_1.OneToMany)(() => PlanFeature_1.PlanFeature, (planFeature) => planFeature.subscription_plan),
|
|
172
161
|
__metadata("design:type", Array)
|
|
173
|
-
], SubscriptionPlan.prototype, "
|
|
162
|
+
], SubscriptionPlan.prototype, "plan_features", void 0);
|
|
174
163
|
exports.SubscriptionPlan = SubscriptionPlan = __decorate([
|
|
175
164
|
(0, typeorm_1.Entity)({ comment: "Planes que tiene el software.", name: "subscription_plan" })
|
|
176
165
|
], SubscriptionPlan);
|
package/dist/entities.index.d.ts
CHANGED
|
@@ -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";
|
package/dist/entities.index.js
CHANGED
|
@@ -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; } });
|
package/dist/feature.scope.d.ts
CHANGED
|
@@ -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
|
|
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;
|
package/dist/feature.scope.js
CHANGED
|
@@ -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;
|