@glissandoo/lib 1.121.0 → 1.122.0

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.
@@ -1,9 +1,10 @@
1
1
  import { EventPayoutConfig } from '../models/Evento/types';
2
+ import { EventPaymentItem } from '../models/Group/Payment/types';
2
3
  import { PayoutRuleCondition, PayoutRuleEffect } from '../types/payoutRule';
3
4
  export declare namespace EventoPayoutFbFunctionsTypes {
4
5
  interface InitializeParams {
5
6
  eventId: string;
6
- grossAmount: number;
7
+ grossAmount: number | null;
7
8
  importByMember: number | null;
8
9
  currency: string;
9
10
  fixedExpenses?: {
@@ -19,11 +20,23 @@ export declare namespace EventoPayoutFbFunctionsTypes {
19
20
  }
20
21
  interface UpdateConfigParams {
21
22
  eventId: string;
22
- grossAmount?: number;
23
+ grossAmount?: number | null;
23
24
  importByMember?: number | null;
24
25
  currency?: string;
25
26
  }
26
27
  type UpdateConfigResult = void;
28
+ interface PaymentsParams {
29
+ eventId: string;
30
+ }
31
+ interface PaymentsResult {
32
+ items: EventPaymentItem[];
33
+ }
34
+ interface MyPaymentsParams {
35
+ eventId: string;
36
+ }
37
+ interface MyPaymentsResult {
38
+ items: EventPaymentItem[];
39
+ }
27
40
  }
28
41
  export declare namespace EventoPayoutRuleFbFunctionsTypes {
29
42
  interface CreateParams {
@@ -10,6 +10,12 @@ export declare namespace GroupPaymentFbFunctionsTypes {
10
10
  totalAmount: number | null;
11
11
  currency: string;
12
12
  note?: string | null;
13
+ /**
14
+ * Marks the payment as a fixed event expense (created from the event
15
+ * payout edit drawer). When `true` and `eventId` is set, the created
16
+ * payment id is appended to the event payout's `expenses` array.
17
+ */
18
+ fixedExpense?: boolean;
13
19
  }
14
20
  interface CreateResult {
15
21
  id: string;
@@ -45,6 +45,8 @@ export declare enum FbFunctionName {
45
45
  EventoPayoutInitialize = "event-payoutInitialize",
46
46
  EventoPayoutUpdateConfig = "event-payoutUpdateConfig",
47
47
  EventoPayoutRuleSet = "event-payoutRuleSet",
48
+ EventoPayments = "event-payments",
49
+ EventoMyPayments = "event-myPayments",
48
50
  EventPublish = "event-publish",
49
51
  EventRemove = "event-remove",
50
52
  EventRepertoryDownload = "eventRepertory-download",
@@ -49,6 +49,8 @@ var FbFunctionName;
49
49
  FbFunctionName["EventoPayoutInitialize"] = "event-payoutInitialize";
50
50
  FbFunctionName["EventoPayoutUpdateConfig"] = "event-payoutUpdateConfig";
51
51
  FbFunctionName["EventoPayoutRuleSet"] = "event-payoutRuleSet";
52
+ FbFunctionName["EventoPayments"] = "event-payments";
53
+ FbFunctionName["EventoMyPayments"] = "event-myPayments";
52
54
  FbFunctionName["EventPublish"] = "event-publish";
53
55
  FbFunctionName["EventRemove"] = "event-remove";
54
56
  FbFunctionName["EventRepertoryDownload"] = "eventRepertory-download";
@@ -56,6 +56,8 @@ const regionByFunctions = {
56
56
  [index_1.FbFunctionName.EventoPayoutInitialize]: GCloudRegions.EuropeWest6,
57
57
  [index_1.FbFunctionName.EventoPayoutUpdateConfig]: GCloudRegions.EuropeWest6,
58
58
  [index_1.FbFunctionName.EventoPayoutRuleSet]: GCloudRegions.EuropeWest6,
59
+ [index_1.FbFunctionName.EventoPayments]: GCloudRegions.EuropeWest6,
60
+ [index_1.FbFunctionName.EventoMyPayments]: GCloudRegions.EuropeWest6,
59
61
  [index_1.FbFunctionName.EventPublish]: GCloudRegions.UsCentral1,
60
62
  [index_1.FbFunctionName.EventRemove]: GCloudRegions.UsCentral1,
61
63
  [index_1.FbFunctionName.EventRepertoryDownload]: GCloudRegions.EuropeWest6,
@@ -14,24 +14,30 @@ export interface EventPaymentForecastEntry {
14
14
  export interface BuildEventPaymentForecastInput {
15
15
  players: AEventPlayerBasicData[];
16
16
  payout: EventPayoutConfig | null;
17
- /** Set of player ids that already have at least one payment for this event (any status). */
18
- playerIdsWithPayment: ReadonlySet<string>;
17
+ /**
18
+ * Set of player ids that already have a real payment for this event whose id
19
+ * is NOT part of `payout.expenses`. The forecast is hidden for these players.
20
+ */
21
+ playerIdsWithNonExpensePayment: ReadonlySet<string>;
19
22
  selectionMode: EventSelectionMode | null;
20
- /** When true (event already roll-called) the forecast is no longer relevant. */
21
- isRollCalled: boolean;
23
+ /**
24
+ * Custom field values per player id, used to evaluate `custom.<field>` payout
25
+ * rules. When omitted (or a player is missing), an empty object is used.
26
+ */
27
+ customFieldsByPlayerId?: ReadonlyMap<string, Record<string, string | number | boolean | null>>;
22
28
  }
23
29
  /**
24
30
  * Computes the simulated ("forecast") payment rows shown in the event payments
25
31
  * tab for players that don't yet have a real payment.
26
32
  *
27
33
  * Exclusion rules per player:
28
- * - There is already a payment for the player on this event.
29
- * - `status === Declined`.
34
+ * - The player already has a real payment whose id is NOT in `payout.expenses`
35
+ * (`playerIdsWithNonExpensePayment`).
36
+ * - `status === Declined` or `rollcall === Declined`.
30
37
  * - When `selectionMode === Closed`, require `selected === true` (rejects
31
38
  * `false` and `null`).
32
39
  * - The payout rules engine returns `excluded` (PlayerExclude rule).
33
40
  *
34
- * Returns an empty array when no `payout` is configured for the event or when
35
- * the event has already been roll-called (`isRollCalled`).
41
+ * Returns an empty array when no `payout` is configured for the event.
36
42
  */
37
- export declare function buildEventPaymentForecast({ players, payout, playerIdsWithPayment, selectionMode, isRollCalled, }: BuildEventPaymentForecastInput): EventPaymentForecastEntry[];
43
+ export declare function buildEventPaymentForecast({ players, payout, playerIdsWithNonExpensePayment, selectionMode, customFieldsByPlayerId, }: BuildEventPaymentForecastInput): EventPaymentForecastEntry[];
@@ -9,34 +9,34 @@ const payoutRules_1 = require("./payoutRules");
9
9
  * tab for players that don't yet have a real payment.
10
10
  *
11
11
  * Exclusion rules per player:
12
- * - There is already a payment for the player on this event.
13
- * - `status === Declined`.
12
+ * - The player already has a real payment whose id is NOT in `payout.expenses`
13
+ * (`playerIdsWithNonExpensePayment`).
14
+ * - `status === Declined` or `rollcall === Declined`.
14
15
  * - When `selectionMode === Closed`, require `selected === true` (rejects
15
16
  * `false` and `null`).
16
17
  * - The payout rules engine returns `excluded` (PlayerExclude rule).
17
18
  *
18
- * Returns an empty array when no `payout` is configured for the event or when
19
- * the event has already been roll-called (`isRollCalled`).
19
+ * Returns an empty array when no `payout` is configured for the event.
20
20
  */
21
- function buildEventPaymentForecast({ players, payout, playerIdsWithPayment, selectionMode, isRollCalled, }) {
21
+ function buildEventPaymentForecast({ players, payout, playerIdsWithNonExpensePayment, selectionMode, customFieldsByPlayerId, }) {
22
22
  if (!payout)
23
23
  return [];
24
- if (isRollCalled)
25
- return [];
26
24
  const requireSelected = selectionMode === types_2.EventSelectionMode.Closed;
27
25
  const result = [];
28
26
  for (const player of players) {
29
- if (playerIdsWithPayment.has(player.id))
27
+ if (playerIdsWithNonExpensePayment.has(player.id))
30
28
  continue;
31
29
  if (player.status === types_1.EventPlayerStatus.Declined)
32
30
  continue;
31
+ if (player.rollcall === types_1.EventPlayerStatus.Declined)
32
+ continue;
33
33
  if (requireSelected && player.selected !== true)
34
34
  continue;
35
35
  const input = {
36
36
  id: player.id,
37
37
  mainInstrument: player.mainInstrument ?? '',
38
38
  isGuest: player.isGuest,
39
- customFields: {},
39
+ customFields: customFieldsByPlayerId?.get(player.id) ?? {},
40
40
  };
41
41
  const evaluation = (0, payoutRules_1.evaluateRulesForPlayer)(input, payout.rules ?? [], payout.importByMember);
42
42
  if (evaluation.excluded)
@@ -188,9 +188,21 @@ export interface EventData extends EventPromoterData {
188
188
  readonly createdOn: CreatedOn;
189
189
  }
190
190
  export interface EventPayoutConfig {
191
- grossAmount: number;
191
+ /**
192
+ * Event budget. `null` means "to be determined" (an Income payment is still
193
+ * generated, with `totalAmount: null`). `0` means no budget (no Income
194
+ * payment is generated). `> 0` is a concrete amount.
195
+ */
196
+ grossAmount: number | null;
192
197
  currency: string;
193
198
  importByMember: number | null;
194
199
  rules: EventoPayoutRuleEntry[];
195
200
  expenses: string[];
201
+ /**
202
+ * Id of the auto-generated `Income` GroupPayment that materializes the
203
+ * event budget (`grossAmount`), assigned to the group itself. `null` when
204
+ * the budget is `0` or for legacy events created before incomes were
205
+ * tracked.
206
+ */
207
+ incomeId?: string | null;
196
208
  }
@@ -94,3 +94,51 @@ export interface GroupPaymentData {
94
94
  editedBy: string | null;
95
95
  }
96
96
  export type AGroupPaymentData = GroupPaymentData;
97
+ /**
98
+ * Estados visibles en la lista unificada de pagos de un evento.
99
+ * Reutiliza los valores de `GroupPaymentStatus` y añade el sintético
100
+ * `forecast` para las filas de previsión (no persistidas en Postgres).
101
+ */
102
+ export declare enum EventPaymentStatus {
103
+ Pending = "pending",
104
+ Paid = "paid",
105
+ Cancelled = "cancelled",
106
+ Forecast = "forecast"
107
+ }
108
+ /**
109
+ * Item unificado devuelto por la callable `event-payments`.
110
+ *
111
+ * Comparte la forma de `GroupPaymentData`. Las filas reales mantienen su
112
+ * `status` persistido; las de previsión usan `status === EventPaymentStatus.Forecast`
113
+ * como discriminador y dejan en `null` los campos no aplicables
114
+ * (`createdAt`, `createdBy`, `paymentMethod`, etc.).
115
+ */
116
+ export interface EventPaymentItem {
117
+ /** Real: UUID del row. Previsión: sintético `forecast-<playerId>`. */
118
+ id: string;
119
+ groupId: string;
120
+ type: GroupPaymentType;
121
+ eventId: string | null;
122
+ playerId: string | null;
123
+ concept: string;
124
+ assignedTo: string;
125
+ totalAmount: number | null;
126
+ baseAmount: number | null;
127
+ appliedRules: AppliedRuleEntry[];
128
+ currency: string;
129
+ status: EventPaymentStatus;
130
+ /** Siempre `[]` en este resultado (history se carga on-demand). */
131
+ history: GroupPaymentHistoryItem[];
132
+ paymentMethod: GroupPaymentMethod | null;
133
+ paidAt: string | null;
134
+ paidBy: string | null;
135
+ note: string | null;
136
+ /**
137
+ * Real: fecha de creación del row. Previsión: fecha de creación del evento.
138
+ */
139
+ createdAt: string;
140
+ /** Real: userId creador. Previsión: `SYSTEM`. */
141
+ createdBy: string;
142
+ editedAt: string | null;
143
+ editedBy: string | null;
144
+ }
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.GroupPaymentHistoryAction = exports.GroupPaymentMethod = exports.GroupPaymentStatus = exports.GroupPaymentType = void 0;
3
+ exports.EventPaymentStatus = exports.GroupPaymentHistoryAction = exports.GroupPaymentMethod = exports.GroupPaymentStatus = exports.GroupPaymentType = void 0;
4
4
  var GroupPaymentType;
5
5
  (function (GroupPaymentType) {
6
6
  GroupPaymentType["Income"] = "income";
@@ -24,3 +24,15 @@ var GroupPaymentHistoryAction;
24
24
  GroupPaymentHistoryAction["Concept"] = "concept";
25
25
  GroupPaymentHistoryAction["Method"] = "method";
26
26
  })(GroupPaymentHistoryAction = exports.GroupPaymentHistoryAction || (exports.GroupPaymentHistoryAction = {}));
27
+ /**
28
+ * Estados visibles en la lista unificada de pagos de un evento.
29
+ * Reutiliza los valores de `GroupPaymentStatus` y añade el sintético
30
+ * `forecast` para las filas de previsión (no persistidas en Postgres).
31
+ */
32
+ var EventPaymentStatus;
33
+ (function (EventPaymentStatus) {
34
+ EventPaymentStatus["Pending"] = "pending";
35
+ EventPaymentStatus["Paid"] = "paid";
36
+ EventPaymentStatus["Cancelled"] = "cancelled";
37
+ EventPaymentStatus["Forecast"] = "forecast";
38
+ })(EventPaymentStatus = exports.EventPaymentStatus || (exports.EventPaymentStatus = {}));
@@ -159,31 +159,33 @@ class Group extends basic_1.default {
159
159
  return null;
160
160
  }
161
161
  get config() {
162
+ const config = this.data.config || {};
162
163
  return {
163
- [types_1.GroupConfigKey.IncludesMembersToEventsWhenJoined]: types_1.GroupConfigKey.IncludesMembersToEventsWhenJoined in this.data.config
164
- ? this.data.config[types_1.GroupConfigKey.IncludesMembersToEventsWhenJoined]
164
+ [types_1.GroupConfigKey.IncludesMembersToEventsWhenJoined]: types_1.GroupConfigKey.IncludesMembersToEventsWhenJoined in config
165
+ ? config[types_1.GroupConfigKey.IncludesMembersToEventsWhenJoined]
165
166
  : true,
166
- [types_1.GroupConfigKey.AllowEditInstruments]: types_1.GroupConfigKey.AllowEditInstruments in this.data.config
167
- ? this.data.config[types_1.GroupConfigKey.AllowEditInstruments]
167
+ [types_1.GroupConfigKey.AllowEditInstruments]: types_1.GroupConfigKey.AllowEditInstruments in config
168
+ ? config[types_1.GroupConfigKey.AllowEditInstruments]
168
169
  : true,
169
- [types_1.GroupConfigKey.ShowAttendanceToMembers]: types_1.GroupConfigKey.ShowAttendanceToMembers in this.data.config
170
- ? this.data.config[types_1.GroupConfigKey.ShowAttendanceToMembers]
170
+ [types_1.GroupConfigKey.ShowAttendanceToMembers]: types_1.GroupConfigKey.ShowAttendanceToMembers in config
171
+ ? config[types_1.GroupConfigKey.ShowAttendanceToMembers]
171
172
  : types_1.GroupConfigShowAttendanceToMembers.None,
172
- [types_1.GroupConfigKey.AllowVerifyGeoLoc]: types_1.GroupConfigKey.AllowVerifyGeoLoc in this.data.config
173
- ? this.data.config[types_1.GroupConfigKey.AllowVerifyGeoLoc]
173
+ [types_1.GroupConfigKey.AllowVerifyGeoLoc]: types_1.GroupConfigKey.AllowVerifyGeoLoc in config
174
+ ? config[types_1.GroupConfigKey.AllowVerifyGeoLoc]
174
175
  : false,
175
176
  };
176
177
  }
177
178
  get configSites() {
179
+ const configSites = this.data.configSites || {};
178
180
  return {
179
- [types_1.GroupConfigSitesKey.Active]: types_1.GroupConfigSitesKey.Active in this.data.configSites
180
- ? this.data.configSites[types_1.GroupConfigSitesKey.Active]
181
+ [types_1.GroupConfigSitesKey.Active]: types_1.GroupConfigSitesKey.Active in configSites
182
+ ? configSites[types_1.GroupConfigSitesKey.Active]
181
183
  : false,
182
- [types_1.GroupConfigSitesKey.ShowEvents]: types_1.GroupConfigSitesKey.ShowEvents in this.data.configSites
183
- ? this.data.configSites[types_1.GroupConfigSitesKey.ShowEvents]
184
+ [types_1.GroupConfigSitesKey.ShowEvents]: types_1.GroupConfigSitesKey.ShowEvents in configSites
185
+ ? configSites[types_1.GroupConfigSitesKey.ShowEvents]
184
186
  : false,
185
- [types_1.GroupConfigSitesKey.ShowMembers]: types_1.GroupConfigSitesKey.ShowMembers in this.data.configSites
186
- ? this.data.configSites[types_1.GroupConfigSitesKey.ShowMembers]
187
+ [types_1.GroupConfigSitesKey.ShowMembers]: types_1.GroupConfigSitesKey.ShowMembers in configSites
188
+ ? configSites[types_1.GroupConfigSitesKey.ShowMembers]
187
189
  : false,
188
190
  };
189
191
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@glissandoo/lib",
3
- "version": "1.121.0",
3
+ "version": "1.122.0",
4
4
  "description": "Glissandoo library js",
5
5
  "main": "./index.js",
6
6
  "types": "./index.d.ts",