@glissandoo/lib 1.108.8 → 1.108.10

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.
@@ -139,6 +139,8 @@ export declare enum FbFunctionName {
139
139
  PartnershipPartnerEdit = "partnershipPartner-edit",
140
140
  PartnershipPartnerOnWrite = "partnershipPartner-onWrite",
141
141
  PartnershipPartnerRemove = "partnershipPartner-remove",
142
+ PartnershipPartnerRequest = "partnershipPartner-request",
143
+ PartnershipPartnerAccept = "partnershipPartner-accept",
142
144
  PartnershipPaymentCreateOneTime = "partnershipPayment-createOneTime",
143
145
  PartnershipPaymentGenerateRecurringBySubscriptions = "partnershipPayment-generateRecurringBySubscriptions",
144
146
  PartnershipPaymentEdit = "partnershipPayment-edit",
@@ -143,6 +143,8 @@ var FbFunctionName;
143
143
  FbFunctionName["PartnershipPartnerEdit"] = "partnershipPartner-edit";
144
144
  FbFunctionName["PartnershipPartnerOnWrite"] = "partnershipPartner-onWrite";
145
145
  FbFunctionName["PartnershipPartnerRemove"] = "partnershipPartner-remove";
146
+ FbFunctionName["PartnershipPartnerRequest"] = "partnershipPartner-request";
147
+ FbFunctionName["PartnershipPartnerAccept"] = "partnershipPartner-accept";
146
148
  FbFunctionName["PartnershipPaymentCreateOneTime"] = "partnershipPayment-createOneTime";
147
149
  FbFunctionName["PartnershipPaymentGenerateRecurringBySubscriptions"] = "partnershipPayment-generateRecurringBySubscriptions";
148
150
  FbFunctionName["PartnershipPaymentEdit"] = "partnershipPayment-edit";
@@ -34,5 +34,14 @@ export declare namespace PartnershipPartnerFbFunctionsTypes {
34
34
  partnerId: string;
35
35
  }
36
36
  export type RemoveResult = void;
37
+ export interface RequestParams extends CreateData {
38
+ partnershipId: string;
39
+ }
40
+ export type RequestResult = void;
41
+ export interface AcceptParams {
42
+ partnershipId: string;
43
+ partnerId: string;
44
+ }
45
+ export type AcceptResult = void;
37
46
  export {};
38
47
  }
@@ -5,6 +5,7 @@ export declare namespace PartnershipPaymentFbFunctionsTypes {
5
5
  amount: number;
6
6
  partnerId: string;
7
7
  paymentMethod: PaymentMethod;
8
+ dueDate: string;
8
9
  }
9
10
  interface CreateOneTimeParams extends CreateOneTimeData {
10
11
  partnershipId: string;
@@ -18,6 +19,7 @@ export declare namespace PartnershipPaymentFbFunctionsTypes {
18
19
  amount?: number;
19
20
  paymentMethod?: PaymentMethod;
20
21
  status?: PaymentStatus;
22
+ dueDate?: string;
21
23
  }
22
24
  type EditResult = void;
23
25
  type RemoveParams = {
@@ -148,6 +148,8 @@ const regionByFunctions = {
148
148
  [index_1.FbFunctionName.PartnershipPartnerEdit]: GCloudRegions.EuropeWest6,
149
149
  [index_1.FbFunctionName.PartnershipPartnerOnWrite]: GCloudRegions.EuropeWest6,
150
150
  [index_1.FbFunctionName.PartnershipPartnerRemove]: GCloudRegions.EuropeWest6,
151
+ [index_1.FbFunctionName.PartnershipPartnerRequest]: GCloudRegions.EuropeWest6,
152
+ [index_1.FbFunctionName.PartnershipPartnerAccept]: GCloudRegions.EuropeWest6,
151
153
  [index_1.FbFunctionName.PartnershipPaymentCreateOneTime]: GCloudRegions.EuropeWest6,
152
154
  [index_1.FbFunctionName.PartnershipPaymentGenerateRecurringBySubscriptions]: GCloudRegions.EuropeWest6,
153
155
  [index_1.FbFunctionName.PartnershipPaymentEdit]: GCloudRegions.EuropeWest6,
@@ -29,12 +29,14 @@ const replaceKeysVarsString = (text, meta) => {
29
29
  exports.replaceKeysVarsString = replaceKeysVarsString;
30
30
  function replaceKeysVarsInNodes(nodes, meta) {
31
31
  return nodes.map((node) => {
32
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
32
33
  const newNode = { ...node };
33
34
  for (const key in newNode) {
34
35
  if (typeof newNode[key] === 'string') {
35
36
  newNode[key] = (0, exports.replaceKeysVarsString)(newNode[key], meta);
36
37
  }
37
38
  else if (Array.isArray(newNode[key])) {
39
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
38
40
  newNode[key] = replaceKeysVarsInNodes(newNode[key], meta);
39
41
  }
40
42
  }
@@ -1,5 +1,5 @@
1
1
  import ModelWithLang from '../../Model/lang';
2
- import { PartnershipPartnerData } from './types';
2
+ import { PartnershipPartnerData, PartnerStatus } from './types';
3
3
  export default class PartnershipPartner extends ModelWithLang<PartnershipPartnerData> {
4
4
  get tinyInfo(): {
5
5
  displayName: string;
@@ -11,7 +11,7 @@ export default class PartnershipPartner extends ModelWithLang<PartnershipPartner
11
11
  get photoURL(): string;
12
12
  get displayName(): string;
13
13
  get NIF(): string | null;
14
- get email(): string | null;
14
+ get email(): string;
15
15
  get phone(): string | null;
16
16
  get birthdate(): FirebaseFirestore.Timestamp | null;
17
17
  get sepaMandate(): {
@@ -30,6 +30,10 @@ export default class PartnershipPartner extends ModelWithLang<PartnershipPartner
30
30
  get editedBy(): string | null;
31
31
  get isDeleted(): boolean;
32
32
  get isActive(): boolean;
33
+ get isPending(): boolean;
34
+ get acceptedAt(): FirebaseFirestore.Timestamp | null;
35
+ get acceptedBy(): string | null;
36
+ get status(): PartnerStatus;
33
37
  get userId(): string | null;
34
38
  get groupIds(): string[];
35
39
  get subscriptionIds(): string[];
@@ -6,6 +6,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
6
6
  const types_1 = require("../../../helpers/types");
7
7
  const utils_1 = require("../../../helpers/utils");
8
8
  const lang_1 = __importDefault(require("../../Model/lang"));
9
+ const types_2 = require("./types");
9
10
  class PartnershipPartner extends lang_1.default {
10
11
  get tinyInfo() {
11
12
  return {
@@ -26,7 +27,7 @@ class PartnershipPartner extends lang_1.default {
26
27
  return this.data.photoURL;
27
28
  }
28
29
  get displayName() {
29
- return this.data.displayName;
30
+ return `${this.name} ${this.lastname}`;
30
31
  }
31
32
  get NIF() {
32
33
  return this.data.NIF;
@@ -72,6 +73,22 @@ class PartnershipPartner extends lang_1.default {
72
73
  get isActive() {
73
74
  return this.exists && !this.isDeleted;
74
75
  }
76
+ get isPending() {
77
+ return !this.isDeleted && this.acceptedAt === null;
78
+ }
79
+ get acceptedAt() {
80
+ return this.data.acceptedAt || null;
81
+ }
82
+ get acceptedBy() {
83
+ return this.data.acceptedBy || null;
84
+ }
85
+ get status() {
86
+ if (this.isDeleted)
87
+ return types_2.PartnerStatus.Inactive;
88
+ if (this.isPending)
89
+ return types_2.PartnerStatus.Pending;
90
+ return types_2.PartnerStatus.Active;
91
+ }
75
92
  get userId() {
76
93
  return this.data.userId || null;
77
94
  }
@@ -1,8 +1,13 @@
1
1
  import { Timestamp } from '@google-cloud/firestore';
2
2
  import { BasicAddressData } from '../../../helpers/types';
3
3
  import { DocumentReference } from '../../../types/firestore';
4
- import { UserExtendedData } from '../../User/types';
4
+ import { GroupPlayerCustomFieldValue } from '../../Group/Player/types';
5
5
  import { PartnershipPlanBasicData } from '../Plan/types';
6
+ export declare enum PartnerStatus {
7
+ Active = "active",
8
+ Pending = "pending",
9
+ Inactive = "inactive"
10
+ }
6
11
  export interface PartnershipPartnerSepaMandate {
7
12
  mandateId: string;
8
13
  iban: string;
@@ -10,19 +15,27 @@ export interface PartnershipPartnerSepaMandate {
10
15
  holderAddress: BasicAddressData;
11
16
  swiftbic: string | null;
12
17
  }
13
- export interface PartnershipPartnerData extends UserExtendedData {
18
+ export interface PartnershipPartnerData {
19
+ userId: string | null;
20
+ email: string;
21
+ name: string;
22
+ lastname: string;
23
+ photoURL: string;
24
+ birthDate: Timestamp | null;
14
25
  address: BasicAddressData | null;
15
26
  phone: string | null;
16
27
  NIF: string | null;
17
28
  sepaMandate: PartnershipPartnerSepaMandate | null;
18
- userId: string | null;
19
29
  groupIds: string[];
20
30
  subscriptionIds: string[];
21
31
  subscriptions: Record<string, PartnershipPlanBasicData>;
32
+ customFields: Record<string, GroupPlayerCustomFieldValue>;
22
33
  createdAt: Timestamp;
23
34
  createdBy: DocumentReference;
24
35
  editedAt: Timestamp | null;
25
36
  editedBy: string | null;
37
+ acceptedAt: Timestamp | null;
38
+ acceptedBy: string | null;
26
39
  deletedAt: Timestamp | null;
27
40
  deletedBy: string | null;
28
41
  }
@@ -1,2 +1,9 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.PartnerStatus = void 0;
4
+ var PartnerStatus;
5
+ (function (PartnerStatus) {
6
+ PartnerStatus["Active"] = "active";
7
+ PartnerStatus["Pending"] = "pending";
8
+ PartnerStatus["Inactive"] = "inactive";
9
+ })(PartnerStatus = exports.PartnerStatus || (exports.PartnerStatus = {}));
@@ -16,6 +16,7 @@ export default class PartnershipPayment extends ModelWithLang<PartnershipPayment
16
16
  get statusHistoryOrdered(): import("./types").PaymentStatusHistoryItem[];
17
17
  get sepaPaymentGroupId(): string | null;
18
18
  get isLinkedToSepaPaymentGroup(): boolean;
19
+ get dueDate(): FirebaseFirestore.Timestamp;
19
20
  get createdAt(): FirebaseFirestore.Timestamp;
20
21
  get createdBy(): string | null;
21
22
  get editedAt(): FirebaseFirestore.Timestamp | null;
@@ -52,6 +52,9 @@ class PartnershipPayment extends lang_1.default {
52
52
  get isLinkedToSepaPaymentGroup() {
53
53
  return !!this.sepaPaymentGroupId;
54
54
  }
55
+ get dueDate() {
56
+ return this.data.dueDate || this.data.createdAt;
57
+ }
55
58
  get createdAt() {
56
59
  return this.data.createdAt;
57
60
  }
@@ -23,6 +23,7 @@ export interface PartnershipPaymentData {
23
23
  status: PaymentStatus;
24
24
  statusHistory: PaymentStatusHistoryItem[];
25
25
  sepaPaymentGroupId: string | null;
26
+ dueDate: Timestamp;
26
27
  createdAt: Timestamp;
27
28
  createdBy: string | null;
28
29
  editedAt: Timestamp | null;
@@ -24,7 +24,7 @@ class PartnershipPlan extends lang_1.default {
24
24
  : (0, date_fns_1.setDate)(date, this.schedule.paymentDay);
25
25
  }
26
26
  setPaymentMonth(date) {
27
- return (0, isNumber_1.default)(this.schedule.paymentMonth) && this.isAnnuallySchedule
27
+ return (0, isNumber_1.default)(this.schedule.paymentMonth) && this.schedule.periodInMonths > 1
28
28
  ? (0, date_fns_1.setMonth)(date, this.schedule.paymentMonth)
29
29
  : date;
30
30
  }
@@ -36,8 +36,11 @@ class PartnershipPlan extends lang_1.default {
36
36
  return this.setPaymentDate(newDate);
37
37
  }
38
38
  getFirstPaymentDate() {
39
- const newDate = this.setPaymentDate(new Date());
40
- return (0, date_fns_1.isPast)(newDate) ? (0, date_fns_1.addMonths)(newDate, this.isAnnuallySchedule ? 12 : 1) : newDate;
39
+ let newDate = this.setPaymentDate(new Date());
40
+ if ((0, date_fns_1.isPast)(newDate)) {
41
+ newDate = this.getNextPaymentDate(newDate);
42
+ }
43
+ return newDate;
41
44
  }
42
45
  get name() {
43
46
  return this.data.name;
@@ -1,6 +1,6 @@
1
1
  import { AdminItemStatus } from '../../helpers/types';
2
2
  import PartnershipBasic from './basic';
3
- import { PartnershipData } from './types';
3
+ import { APartnershipCustomField, PartnershipData } from './types';
4
4
  export default class Partnership extends PartnershipBasic<PartnershipData> {
5
5
  get description(): string | null;
6
6
  get admins(): string[];
@@ -26,4 +26,6 @@ export default class Partnership extends PartnershipBasic<PartnershipData> {
26
26
  get deletedBy(): string | null;
27
27
  get isDeleted(): boolean;
28
28
  get isActive(): boolean;
29
+ get customFields(): Record<string, import("../Group/types").GroupCustomField>;
30
+ get customFieldsList(): APartnershipCustomField[];
29
31
  }
@@ -64,5 +64,16 @@ class Partnership extends basic_1.default {
64
64
  get isActive() {
65
65
  return this.exists && !this.deletedAt;
66
66
  }
67
+ get customFields() {
68
+ return this.data.customFields || {};
69
+ }
70
+ get customFieldsList() {
71
+ return Object.entries(this.customFields)
72
+ .map(([id, field]) => ({
73
+ id,
74
+ ...field,
75
+ }))
76
+ .sort((a, b) => a.order - b.order);
77
+ }
67
78
  }
68
79
  exports.default = Partnership;
@@ -1,5 +1,8 @@
1
1
  import { DocumentReference, Timestamp } from '@google-cloud/firestore';
2
2
  import { AdminItem, BasicAddressData } from '../../helpers/types';
3
+ import { AGroupCustomField, GroupCustomField } from '../Group/types';
4
+ export type PartnershipCustomField = GroupCustomField;
5
+ export type APartnershipCustomField = AGroupCustomField;
3
6
  export declare enum PartnershipRoles {
4
7
  Admin = "admin"
5
8
  }
@@ -31,6 +34,7 @@ export interface PartnershipData extends PartnershipBasicData {
31
34
  administrators: string[];
32
35
  administratorsList: AdminItem[];
33
36
  federationIds: string[];
37
+ customFields: Record<string, PartnershipCustomField>;
34
38
  createdAt: Timestamp;
35
39
  createdBy: DocumentReference;
36
40
  editedAt: Timestamp | null;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@glissandoo/lib",
3
- "version": "1.108.8",
3
+ "version": "1.108.10",
4
4
  "description": "Glissandoo library js",
5
5
  "main": "./index.js",
6
6
  "types": "./index.d.ts",