@glissandoo/lib 1.118.0 → 1.119.1
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/functions/index.d.ts +2 -0
- package/functions/index.js +2 -0
- package/functions/partnershipPartner.d.ts +15 -1
- package/functions/partnershipSepaPaymentGroup.d.ts +4 -1
- package/functions/regions.js +2 -0
- package/helpers/errors.d.ts +3 -0
- package/helpers/errors.js +3 -0
- package/helpers/notifications/index.js +2 -0
- package/helpers/types.d.ts +1 -0
- package/helpers/types.js +13 -1
- package/models/Partnership/Communication/index.d.ts +13 -5
- package/models/Partnership/Communication/index.js +27 -20
- package/models/Partnership/Communication/supabase.d.ts +7 -0
- package/models/Partnership/Communication/supabase.js +24 -0
- package/models/Partnership/Communication/types.d.ts +5 -4
- package/models/Partnership/Group/index.d.ts +25 -7
- package/models/Partnership/Group/index.js +51 -13
- package/models/Partnership/Group/supabase.d.ts +13 -0
- package/models/Partnership/Group/supabase.js +25 -0
- package/models/Partnership/Group/types.d.ts +9 -3
- package/models/Partnership/Partner/index.d.ts +18 -7
- package/models/Partnership/Partner/index.js +47 -33
- package/models/Partnership/Partner/supabase.d.ts +7 -0
- package/models/Partnership/Partner/supabase.js +38 -0
- package/models/Partnership/Partner/types.d.ts +9 -8
- package/models/Partnership/Payment/index.d.ts +22 -5
- package/models/Partnership/Payment/index.js +44 -22
- package/models/Partnership/Payment/supabase.d.ts +15 -0
- package/models/Partnership/Payment/supabase.js +40 -0
- package/models/Partnership/Payment/types.d.ts +14 -6
- package/models/Partnership/Payment/types.js +1 -0
- package/models/Partnership/Plan/index.d.ts +14 -5
- package/models/Partnership/Plan/index.js +26 -18
- package/models/Partnership/Plan/supabase.d.ts +7 -0
- package/models/Partnership/Plan/supabase.js +22 -0
- package/models/Partnership/Plan/types.d.ts +5 -4
- package/models/Partnership/SepaPaymentGroup/index.d.ts +12 -4
- package/models/Partnership/SepaPaymentGroup/index.js +21 -14
- package/models/Partnership/SepaPaymentGroup/supabase.d.ts +7 -0
- package/models/Partnership/SepaPaymentGroup/supabase.js +18 -0
- package/models/Partnership/SepaPaymentGroup/types.d.ts +4 -3
- package/models/Partnership/Subscription/index.d.ts +15 -7
- package/models/Partnership/Subscription/index.js +27 -20
- package/models/Partnership/Subscription/supabase.d.ts +7 -0
- package/models/Partnership/Subscription/supabase.js +23 -0
- package/models/Partnership/Subscription/types.d.ts +7 -6
- package/models/Partnership/types.d.ts +5 -0
- package/package.json +1 -1
- package/types/supabase/generated.d.ts +487 -0
- package/types/supabase/generated.js +4 -0
- package/types/supabase/generated.ts +497 -0
|
@@ -1,13 +1,21 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
3
|
const types_1 = require("../../../helpers/types");
|
|
7
|
-
const utils_1 = require("../../../helpers/utils");
|
|
8
|
-
const lang_1 = __importDefault(require("../../Model/lang"));
|
|
9
4
|
const types_2 = require("./types");
|
|
10
|
-
|
|
5
|
+
/**
|
|
6
|
+
* Modelo plain-object para una fila de `partnership_partner`. Conserva la API
|
|
7
|
+
* de getters del antiguo modelo Firestore. `status` se deriva del estado
|
|
8
|
+
* (borrado/pendiente/activo); las fechas son ISO (string).
|
|
9
|
+
*/
|
|
10
|
+
class PartnershipPartner {
|
|
11
|
+
constructor(data) {
|
|
12
|
+
this.id = data.id;
|
|
13
|
+
this._data = data;
|
|
14
|
+
this.exists = true;
|
|
15
|
+
}
|
|
16
|
+
get data() {
|
|
17
|
+
return this._data;
|
|
18
|
+
}
|
|
11
19
|
get tinyInfo() {
|
|
12
20
|
return {
|
|
13
21
|
displayName: this.displayName,
|
|
@@ -15,66 +23,66 @@ class PartnershipPartner extends lang_1.default {
|
|
|
15
23
|
};
|
|
16
24
|
}
|
|
17
25
|
get partnershipId() {
|
|
18
|
-
return
|
|
26
|
+
return this._data.partnershipId;
|
|
19
27
|
}
|
|
20
28
|
get partnerNumber() {
|
|
21
|
-
return this.
|
|
29
|
+
return this._data.partnerNumber || 0;
|
|
22
30
|
}
|
|
23
31
|
get name() {
|
|
24
|
-
return this.
|
|
32
|
+
return this._data.name;
|
|
25
33
|
}
|
|
26
34
|
get lastname() {
|
|
27
|
-
return this.
|
|
35
|
+
return this._data.lastname;
|
|
28
36
|
}
|
|
29
37
|
get photoURL() {
|
|
30
|
-
return this.
|
|
38
|
+
return this._data.photoURL;
|
|
31
39
|
}
|
|
32
40
|
get displayName() {
|
|
33
41
|
return `${this.name} ${this.lastname}`;
|
|
34
42
|
}
|
|
35
43
|
get NIF() {
|
|
36
|
-
return this.
|
|
44
|
+
return this._data.NIF;
|
|
37
45
|
}
|
|
38
46
|
get email() {
|
|
39
|
-
return this.
|
|
47
|
+
return this._data.email;
|
|
40
48
|
}
|
|
41
49
|
get phone() {
|
|
42
|
-
return this.
|
|
50
|
+
return this._data.phone;
|
|
43
51
|
}
|
|
44
52
|
get birthdate() {
|
|
45
|
-
return this.
|
|
53
|
+
return this._data.birthDate;
|
|
46
54
|
}
|
|
47
55
|
get sepaMandate() {
|
|
48
|
-
if (!this.
|
|
56
|
+
if (!this._data.sepaMandate)
|
|
49
57
|
return null;
|
|
50
58
|
return {
|
|
51
|
-
...this.
|
|
52
|
-
holderDisplayAddress: (0, types_1.displayBasicAddress)(this.
|
|
59
|
+
...this._data.sepaMandate,
|
|
60
|
+
holderDisplayAddress: (0, types_1.displayBasicAddress)(this._data.sepaMandate.holderAddress),
|
|
53
61
|
};
|
|
54
62
|
}
|
|
55
63
|
get address() {
|
|
56
|
-
return this.
|
|
64
|
+
return this._data.address;
|
|
57
65
|
}
|
|
58
66
|
get paymentMethod() {
|
|
59
|
-
return this.
|
|
67
|
+
return this._data.paymentMethod || null;
|
|
60
68
|
}
|
|
61
69
|
get displayAddress() {
|
|
62
70
|
return (0, types_1.displayBasicAddress)(this.address);
|
|
63
71
|
}
|
|
64
72
|
get createdAt() {
|
|
65
|
-
return this.
|
|
73
|
+
return this._data.createdAt;
|
|
66
74
|
}
|
|
67
75
|
get createdBy() {
|
|
68
|
-
return this.
|
|
76
|
+
return this._data.createdBy;
|
|
69
77
|
}
|
|
70
78
|
get editedAt() {
|
|
71
|
-
return this.
|
|
79
|
+
return this._data.editedAt || null;
|
|
72
80
|
}
|
|
73
81
|
get editedBy() {
|
|
74
|
-
return this.
|
|
82
|
+
return this._data.editedBy || null;
|
|
75
83
|
}
|
|
76
84
|
get isDeleted() {
|
|
77
|
-
return this.
|
|
85
|
+
return this._data.deletedAt !== null;
|
|
78
86
|
}
|
|
79
87
|
get isActive() {
|
|
80
88
|
return this.exists && !this.isDeleted;
|
|
@@ -83,10 +91,10 @@ class PartnershipPartner extends lang_1.default {
|
|
|
83
91
|
return !this.isDeleted && this.acceptedAt === null;
|
|
84
92
|
}
|
|
85
93
|
get acceptedAt() {
|
|
86
|
-
return this.
|
|
94
|
+
return this._data.acceptedAt || null;
|
|
87
95
|
}
|
|
88
96
|
get acceptedBy() {
|
|
89
|
-
return this.
|
|
97
|
+
return this._data.acceptedBy || null;
|
|
90
98
|
}
|
|
91
99
|
get status() {
|
|
92
100
|
if (this.isDeleted)
|
|
@@ -96,22 +104,28 @@ class PartnershipPartner extends lang_1.default {
|
|
|
96
104
|
return types_2.PartnerStatus.Active;
|
|
97
105
|
}
|
|
98
106
|
get userId() {
|
|
99
|
-
return this.
|
|
107
|
+
return this._data.userId || null;
|
|
108
|
+
}
|
|
109
|
+
get payerId() {
|
|
110
|
+
return this._data.payerId || null;
|
|
111
|
+
}
|
|
112
|
+
get hasPayer() {
|
|
113
|
+
return this.payerId !== null;
|
|
100
114
|
}
|
|
101
115
|
get groupIds() {
|
|
102
|
-
return this.
|
|
116
|
+
return this._data.groupIds || [];
|
|
103
117
|
}
|
|
104
118
|
get tagIds() {
|
|
105
|
-
return this.
|
|
119
|
+
return this._data.tagIds || [];
|
|
106
120
|
}
|
|
107
121
|
get subscriptionIds() {
|
|
108
|
-
return this.
|
|
122
|
+
return this._data.subscriptionIds || [];
|
|
109
123
|
}
|
|
110
124
|
get subscriptions() {
|
|
111
|
-
return this.
|
|
125
|
+
return this._data.subscriptions || {};
|
|
112
126
|
}
|
|
113
127
|
get acceptsCommunications() {
|
|
114
|
-
return this.
|
|
128
|
+
return this._data.acceptsCommunications !== false;
|
|
115
129
|
}
|
|
116
130
|
}
|
|
117
131
|
exports.default = PartnershipPartner;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { Database } from '../../../types/supabase';
|
|
2
|
+
import { PartnershipPartnerData } from './types';
|
|
3
|
+
export type PartnershipPartnerRow = Database['public']['Tables']['partnership_partner']['Row'];
|
|
4
|
+
export type PartnershipPartnerInsert = Database['public']['Tables']['partnership_partner']['Insert'];
|
|
5
|
+
export type PartnershipPartnerUpdate = Database['public']['Tables']['partnership_partner']['Update'];
|
|
6
|
+
export declare const PARTNERSHIP_PARTNER_TABLE: "partnership_partner";
|
|
7
|
+
export declare function rowToPartnershipPartnerData(row: PartnershipPartnerRow): PartnershipPartnerData;
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.rowToPartnershipPartnerData = exports.PARTNERSHIP_PARTNER_TABLE = void 0;
|
|
4
|
+
exports.PARTNERSHIP_PARTNER_TABLE = 'partnership_partner';
|
|
5
|
+
function rowToPartnershipPartnerData(row) {
|
|
6
|
+
return {
|
|
7
|
+
id: row.id,
|
|
8
|
+
partnershipId: row.partnershipId,
|
|
9
|
+
userId: row.userId,
|
|
10
|
+
payerId: row.payerId,
|
|
11
|
+
partnerNumber: row.partnerNumber,
|
|
12
|
+
email: row.email,
|
|
13
|
+
name: row.name,
|
|
14
|
+
lastname: row.lastname,
|
|
15
|
+
photoURL: row.photoURL,
|
|
16
|
+
birthDate: row.birthDate,
|
|
17
|
+
address: row.address ?? null,
|
|
18
|
+
phone: row.phone,
|
|
19
|
+
NIF: row.NIF,
|
|
20
|
+
sepaMandate: row.sepaMandate ?? null,
|
|
21
|
+
paymentMethod: row.paymentMethod ?? null,
|
|
22
|
+
groupIds: row.groupIds ?? [],
|
|
23
|
+
tagIds: row.tagIds ?? [],
|
|
24
|
+
subscriptionIds: row.subscriptionIds ?? [],
|
|
25
|
+
subscriptions: row.subscriptions ?? {},
|
|
26
|
+
customFields: row.customFields ?? {},
|
|
27
|
+
acceptsCommunications: row.acceptsCommunications,
|
|
28
|
+
createdAt: row.createdAt,
|
|
29
|
+
createdBy: row.createdBy,
|
|
30
|
+
editedAt: row.editedBy ? row.updatedAt : null,
|
|
31
|
+
editedBy: row.editedBy,
|
|
32
|
+
acceptedAt: row.acceptedAt,
|
|
33
|
+
acceptedBy: row.acceptedBy,
|
|
34
|
+
deletedAt: row.deletedAt,
|
|
35
|
+
deletedBy: row.deletedBy,
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
exports.rowToPartnershipPartnerData = rowToPartnershipPartnerData;
|
|
@@ -1,6 +1,4 @@
|
|
|
1
|
-
import { Timestamp } from '@google-cloud/firestore';
|
|
2
1
|
import { BasicAddressData } from '../../../helpers/types';
|
|
3
|
-
import { DocumentReference } from '../../../types/firestore';
|
|
4
2
|
import { GroupPlayerCustomFieldValue } from '../../Group/Player/types';
|
|
5
3
|
import { PaymentMethod } from '../Payment/types';
|
|
6
4
|
import { PartnershipPlanBasicData } from '../Plan/types';
|
|
@@ -17,13 +15,16 @@ export interface PartnershipPartnerSepaMandate {
|
|
|
17
15
|
swiftbic: string | null;
|
|
18
16
|
}
|
|
19
17
|
export interface PartnershipPartnerData {
|
|
18
|
+
id: string;
|
|
19
|
+
partnershipId: string;
|
|
20
20
|
userId: string | null;
|
|
21
|
+
payerId: string | null;
|
|
21
22
|
partnerNumber: number;
|
|
22
23
|
email: string | null;
|
|
23
24
|
name: string;
|
|
24
25
|
lastname: string;
|
|
25
26
|
photoURL: string;
|
|
26
|
-
birthDate:
|
|
27
|
+
birthDate: string | null;
|
|
27
28
|
address: BasicAddressData | null;
|
|
28
29
|
phone: string | null;
|
|
29
30
|
NIF: string | null;
|
|
@@ -35,12 +36,12 @@ export interface PartnershipPartnerData {
|
|
|
35
36
|
subscriptions: Record<string, PartnershipPlanBasicData>;
|
|
36
37
|
customFields: Record<string, GroupPlayerCustomFieldValue>;
|
|
37
38
|
acceptsCommunications: boolean;
|
|
38
|
-
createdAt:
|
|
39
|
-
createdBy:
|
|
40
|
-
editedAt:
|
|
39
|
+
createdAt: string;
|
|
40
|
+
createdBy: string;
|
|
41
|
+
editedAt: string | null;
|
|
41
42
|
editedBy: string | null;
|
|
42
|
-
acceptedAt:
|
|
43
|
+
acceptedAt: string | null;
|
|
43
44
|
acceptedBy: string | null;
|
|
44
|
-
deletedAt:
|
|
45
|
+
deletedAt: string | null;
|
|
45
46
|
deletedBy: string | null;
|
|
46
47
|
}
|
|
@@ -1,12 +1,28 @@
|
|
|
1
|
-
import ModelWithLang from '../../Model/lang';
|
|
2
1
|
import { PartnershipPaymentData, PaymentMethod } from './types';
|
|
3
|
-
|
|
2
|
+
/**
|
|
3
|
+
* Modelo plain-object para una fila de `partnership_payment`. Sustituye al
|
|
4
|
+
* antiguo modelo Firestore conservando la API de getters que consumen las
|
|
5
|
+
* Cloud Functions y el dashboard. Construir con `new PartnershipPayment(data)`
|
|
6
|
+
* donde `data` es el registro deserializado de la BD (ver
|
|
7
|
+
* `./supabase.ts#rowToPartnershipPaymentData`).
|
|
8
|
+
*
|
|
9
|
+
* Las fechas son ISO 8601 (string).
|
|
10
|
+
*/
|
|
11
|
+
export default class PartnershipPayment {
|
|
12
|
+
id: string;
|
|
13
|
+
exists: boolean;
|
|
14
|
+
private _data;
|
|
15
|
+
constructor(data: PartnershipPaymentData);
|
|
16
|
+
get data(): PartnershipPaymentData;
|
|
4
17
|
get partnershipId(): string;
|
|
5
18
|
get title(): string;
|
|
6
19
|
get amount(): number;
|
|
7
20
|
get displayAmount(): string;
|
|
8
21
|
get subscriptionId(): string | null;
|
|
9
22
|
get partnerId(): string;
|
|
23
|
+
get payerId(): string | null;
|
|
24
|
+
/** Socio cuya cuenta/método se usa para cobrar: el pagador si existe. */
|
|
25
|
+
get billingPartnerId(): string;
|
|
10
26
|
get isRecurrent(): boolean;
|
|
11
27
|
get isOneTime(): boolean;
|
|
12
28
|
get paymentMethod(): PaymentMethod | null;
|
|
@@ -15,11 +31,12 @@ export default class PartnershipPayment extends ModelWithLang<PartnershipPayment
|
|
|
15
31
|
get statusHistory(): import("./types").PaymentStatusHistoryItem[];
|
|
16
32
|
get statusHistoryOrdered(): import("./types").PaymentStatusHistoryItem[];
|
|
17
33
|
get sepaPaymentGroupId(): string | null;
|
|
34
|
+
get sepaEndToEndId(): string | null;
|
|
18
35
|
get isLinkedToSepaPaymentGroup(): boolean;
|
|
19
|
-
get dueDate():
|
|
20
|
-
get createdAt():
|
|
36
|
+
get dueDate(): string;
|
|
37
|
+
get createdAt(): string;
|
|
21
38
|
get createdBy(): string | null;
|
|
22
|
-
get editedAt():
|
|
39
|
+
get editedAt(): string | null;
|
|
23
40
|
get editedBy(): string | null;
|
|
24
41
|
get receiptFilePath(): string | null;
|
|
25
42
|
get isActive(): boolean;
|
|
@@ -1,29 +1,48 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
const utils_1 = require("../../../helpers/utils");
|
|
7
|
-
const lang_1 = __importDefault(require("../../Model/lang"));
|
|
8
3
|
const types_1 = require("./types");
|
|
9
|
-
|
|
4
|
+
/**
|
|
5
|
+
* Modelo plain-object para una fila de `partnership_payment`. Sustituye al
|
|
6
|
+
* antiguo modelo Firestore conservando la API de getters que consumen las
|
|
7
|
+
* Cloud Functions y el dashboard. Construir con `new PartnershipPayment(data)`
|
|
8
|
+
* donde `data` es el registro deserializado de la BD (ver
|
|
9
|
+
* `./supabase.ts#rowToPartnershipPaymentData`).
|
|
10
|
+
*
|
|
11
|
+
* Las fechas son ISO 8601 (string).
|
|
12
|
+
*/
|
|
13
|
+
class PartnershipPayment {
|
|
14
|
+
constructor(data) {
|
|
15
|
+
this.id = data.id;
|
|
16
|
+
this._data = data;
|
|
17
|
+
this.exists = true;
|
|
18
|
+
}
|
|
19
|
+
get data() {
|
|
20
|
+
return this._data;
|
|
21
|
+
}
|
|
10
22
|
get partnershipId() {
|
|
11
|
-
return
|
|
23
|
+
return this._data.partnershipId;
|
|
12
24
|
}
|
|
13
25
|
get title() {
|
|
14
|
-
return this.
|
|
26
|
+
return this._data.title;
|
|
15
27
|
}
|
|
16
28
|
get amount() {
|
|
17
|
-
return this.
|
|
29
|
+
return this._data.amount;
|
|
18
30
|
}
|
|
19
31
|
get displayAmount() {
|
|
20
32
|
return `${this.amount} €`;
|
|
21
33
|
}
|
|
22
34
|
get subscriptionId() {
|
|
23
|
-
return this.
|
|
35
|
+
return this._data.subscriptionId;
|
|
24
36
|
}
|
|
25
37
|
get partnerId() {
|
|
26
|
-
return this.
|
|
38
|
+
return this._data.partnerId;
|
|
39
|
+
}
|
|
40
|
+
get payerId() {
|
|
41
|
+
return this._data.payerId || null;
|
|
42
|
+
}
|
|
43
|
+
/** Socio cuya cuenta/método se usa para cobrar: el pagador si existe. */
|
|
44
|
+
get billingPartnerId() {
|
|
45
|
+
return this.payerId || this.partnerId;
|
|
27
46
|
}
|
|
28
47
|
get isRecurrent() {
|
|
29
48
|
return this.subscriptionId !== null;
|
|
@@ -32,43 +51,46 @@ class PartnershipPayment extends lang_1.default {
|
|
|
32
51
|
return this.subscriptionId === null;
|
|
33
52
|
}
|
|
34
53
|
get paymentMethod() {
|
|
35
|
-
return this.
|
|
54
|
+
return this._data.paymentMethod;
|
|
36
55
|
}
|
|
37
56
|
get isMethodSepa() {
|
|
38
57
|
return this.paymentMethod === types_1.PaymentMethod.SEPA;
|
|
39
58
|
}
|
|
40
59
|
get status() {
|
|
41
|
-
return this.
|
|
60
|
+
return this._data.status;
|
|
42
61
|
}
|
|
43
62
|
get statusHistory() {
|
|
44
|
-
return this.
|
|
63
|
+
return this._data.statusHistory;
|
|
45
64
|
}
|
|
46
65
|
get statusHistoryOrdered() {
|
|
47
|
-
return this.statusHistory.sort((a, b) => a.changedAt.
|
|
66
|
+
return [...this.statusHistory].sort((a, b) => new Date(a.changedAt).getTime() < new Date(b.changedAt).getTime() ? 1 : -1);
|
|
48
67
|
}
|
|
49
68
|
get sepaPaymentGroupId() {
|
|
50
|
-
return this.
|
|
69
|
+
return this._data.sepaPaymentGroupId || null;
|
|
70
|
+
}
|
|
71
|
+
get sepaEndToEndId() {
|
|
72
|
+
return this._data.sepaEndToEndId || null;
|
|
51
73
|
}
|
|
52
74
|
get isLinkedToSepaPaymentGroup() {
|
|
53
75
|
return !!this.sepaPaymentGroupId;
|
|
54
76
|
}
|
|
55
77
|
get dueDate() {
|
|
56
|
-
return this.
|
|
78
|
+
return this._data.dueDate || this._data.createdAt;
|
|
57
79
|
}
|
|
58
80
|
get createdAt() {
|
|
59
|
-
return this.
|
|
81
|
+
return this._data.createdAt;
|
|
60
82
|
}
|
|
61
83
|
get createdBy() {
|
|
62
|
-
return this.
|
|
84
|
+
return this._data.createdBy || null;
|
|
63
85
|
}
|
|
64
86
|
get editedAt() {
|
|
65
|
-
return this.
|
|
87
|
+
return this._data.editedAt || null;
|
|
66
88
|
}
|
|
67
89
|
get editedBy() {
|
|
68
|
-
return this.
|
|
90
|
+
return this._data.editedBy || null;
|
|
69
91
|
}
|
|
70
92
|
get receiptFilePath() {
|
|
71
|
-
return this.
|
|
93
|
+
return this._data.receiptFilePath || null;
|
|
72
94
|
}
|
|
73
95
|
get isActive() {
|
|
74
96
|
return this.exists;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { Database } from '../../../types/supabase';
|
|
2
|
+
import { PartnershipPaymentData, PaymentStatusHistoryItem } from './types';
|
|
3
|
+
export type PartnershipPaymentRow = Database['public']['Tables']['partnership_payment']['Row'];
|
|
4
|
+
export type PartnershipPaymentInsert = Database['public']['Tables']['partnership_payment']['Insert'];
|
|
5
|
+
export type PartnershipPaymentUpdate = Database['public']['Tables']['partnership_payment']['Update'];
|
|
6
|
+
export type PartnershipPaymentHistoryRow = Database['public']['Tables']['partnership_payment_history']['Row'];
|
|
7
|
+
export type PartnershipPaymentHistoryInsert = Database['public']['Tables']['partnership_payment_history']['Insert'];
|
|
8
|
+
export declare const PARTNERSHIP_PAYMENT_TABLE: "partnership_payment";
|
|
9
|
+
export declare const PARTNERSHIP_PAYMENT_HISTORY_TABLE: "partnership_payment_history";
|
|
10
|
+
/**
|
|
11
|
+
* Convierte una fila `partnership_payment` en `PartnershipPaymentData`.
|
|
12
|
+
* `statusHistory` se hidrata desde la tabla de historial; por defecto vacío.
|
|
13
|
+
*/
|
|
14
|
+
export declare function rowToPartnershipPaymentData(row: PartnershipPaymentRow, statusHistory?: PaymentStatusHistoryItem[]): PartnershipPaymentData;
|
|
15
|
+
export declare function historyRowToStatusItem(row: PartnershipPaymentHistoryRow): PaymentStatusHistoryItem;
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.historyRowToStatusItem = exports.rowToPartnershipPaymentData = exports.PARTNERSHIP_PAYMENT_HISTORY_TABLE = exports.PARTNERSHIP_PAYMENT_TABLE = void 0;
|
|
4
|
+
exports.PARTNERSHIP_PAYMENT_TABLE = 'partnership_payment';
|
|
5
|
+
exports.PARTNERSHIP_PAYMENT_HISTORY_TABLE = 'partnership_payment_history';
|
|
6
|
+
/**
|
|
7
|
+
* Convierte una fila `partnership_payment` en `PartnershipPaymentData`.
|
|
8
|
+
* `statusHistory` se hidrata desde la tabla de historial; por defecto vacío.
|
|
9
|
+
*/
|
|
10
|
+
function rowToPartnershipPaymentData(row, statusHistory = []) {
|
|
11
|
+
return {
|
|
12
|
+
id: row.id,
|
|
13
|
+
partnershipId: row.partnershipId,
|
|
14
|
+
title: row.title,
|
|
15
|
+
amount: Number(row.amount),
|
|
16
|
+
paymentMethod: row.paymentMethod ?? null,
|
|
17
|
+
subscriptionId: row.subscriptionId,
|
|
18
|
+
partnerId: row.partnerId,
|
|
19
|
+
payerId: row.payerId,
|
|
20
|
+
status: row.status,
|
|
21
|
+
statusHistory,
|
|
22
|
+
sepaPaymentGroupId: row.sepaPaymentGroupId,
|
|
23
|
+
sepaEndToEndId: row.sepaEndToEndId,
|
|
24
|
+
dueDate: row.dueDate,
|
|
25
|
+
createdAt: row.createdAt,
|
|
26
|
+
createdBy: row.createdBy,
|
|
27
|
+
editedAt: row.editedBy ? row.updatedAt : null,
|
|
28
|
+
editedBy: row.editedBy,
|
|
29
|
+
receiptFilePath: row.receiptFilePath,
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
exports.rowToPartnershipPaymentData = rowToPartnershipPaymentData;
|
|
33
|
+
function historyRowToStatusItem(row) {
|
|
34
|
+
return {
|
|
35
|
+
status: row.status,
|
|
36
|
+
changedAt: row.changed_at,
|
|
37
|
+
changedBy: row.changed_by,
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
exports.historyRowToStatusItem = historyRowToStatusItem;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { Timestamp } from '@google-cloud/firestore';
|
|
2
1
|
export declare enum PaymentMethod {
|
|
3
2
|
Cash = "CASH",
|
|
4
3
|
Transfer = "TRANSFER",
|
|
5
|
-
SEPA = "SEPA"
|
|
4
|
+
SEPA = "SEPA",
|
|
5
|
+
Bizum = "BIZUM"
|
|
6
6
|
}
|
|
7
7
|
export declare enum PaymentStatus {
|
|
8
8
|
Pending = "pending",
|
|
@@ -10,24 +10,32 @@ export declare enum PaymentStatus {
|
|
|
10
10
|
Returned = "returned",
|
|
11
11
|
Canceled = "canceled"
|
|
12
12
|
}
|
|
13
|
+
/**
|
|
14
|
+
* Entrada de historial de estado. `changedAt` es ISO 8601 (timestamptz de
|
|
15
|
+
* Postgres). Mantiene la forma del antiguo `statusHistory` de Firestore.
|
|
16
|
+
*/
|
|
13
17
|
export interface PaymentStatusHistoryItem {
|
|
14
18
|
status: PaymentStatus;
|
|
15
|
-
changedAt:
|
|
19
|
+
changedAt: string;
|
|
16
20
|
changedBy: string;
|
|
17
21
|
}
|
|
18
22
|
export interface PartnershipPaymentData {
|
|
23
|
+
id: string;
|
|
24
|
+
partnershipId: string;
|
|
19
25
|
title: string;
|
|
20
26
|
amount: number;
|
|
21
27
|
paymentMethod: PaymentMethod | null;
|
|
22
28
|
subscriptionId: string | null;
|
|
23
29
|
partnerId: string;
|
|
30
|
+
payerId: string | null;
|
|
24
31
|
status: PaymentStatus;
|
|
25
32
|
statusHistory: PaymentStatusHistoryItem[];
|
|
26
33
|
sepaPaymentGroupId: string | null;
|
|
27
|
-
|
|
28
|
-
|
|
34
|
+
sepaEndToEndId: string | null;
|
|
35
|
+
dueDate: string;
|
|
36
|
+
createdAt: string;
|
|
29
37
|
createdBy: string | null;
|
|
30
|
-
editedAt:
|
|
38
|
+
editedAt: string | null;
|
|
31
39
|
editedBy: string | null;
|
|
32
40
|
receiptFilePath: string | null;
|
|
33
41
|
}
|
|
@@ -6,6 +6,7 @@ var PaymentMethod;
|
|
|
6
6
|
PaymentMethod["Cash"] = "CASH";
|
|
7
7
|
PaymentMethod["Transfer"] = "TRANSFER";
|
|
8
8
|
PaymentMethod["SEPA"] = "SEPA";
|
|
9
|
+
PaymentMethod["Bizum"] = "BIZUM";
|
|
9
10
|
})(PaymentMethod = exports.PaymentMethod || (exports.PaymentMethod = {}));
|
|
10
11
|
var PaymentStatus;
|
|
11
12
|
(function (PaymentStatus) {
|
|
@@ -1,6 +1,15 @@
|
|
|
1
|
-
import ModelWithLang from '../../Model/lang';
|
|
2
1
|
import { PartnershipPlanBasicData, PartnershipPlanData } from './types';
|
|
3
|
-
|
|
2
|
+
/**
|
|
3
|
+
* Modelo plain-object para una fila de `partnership_plan`. Conserva la lógica
|
|
4
|
+
* de dominio de cálculo de fechas de cobro. Las fechas persistidas son ISO
|
|
5
|
+
* (string); los métodos de cálculo operan con `Date`.
|
|
6
|
+
*/
|
|
7
|
+
export default class PartnershipPlan {
|
|
8
|
+
id: string;
|
|
9
|
+
exists: boolean;
|
|
10
|
+
private _data;
|
|
11
|
+
constructor(data: PartnershipPlanData);
|
|
12
|
+
get data(): PartnershipPlanData;
|
|
4
13
|
get basicInfo(): PartnershipPlanBasicData;
|
|
5
14
|
get partnershipId(): string;
|
|
6
15
|
private setPaymentDay;
|
|
@@ -17,11 +26,11 @@ export default class PartnershipPlan extends ModelWithLang<PartnershipPlanData>
|
|
|
17
26
|
get isPaymentDayEndOfMonth(): boolean;
|
|
18
27
|
get subscriptionsCount(): number;
|
|
19
28
|
get hasSubscriptions(): boolean;
|
|
20
|
-
get createdAt():
|
|
29
|
+
get createdAt(): string;
|
|
21
30
|
get createdBy(): string;
|
|
22
|
-
get editedAt():
|
|
31
|
+
get editedAt(): string | null;
|
|
23
32
|
get editedBy(): string | null;
|
|
24
|
-
get deletedAt():
|
|
33
|
+
get deletedAt(): string | null;
|
|
25
34
|
get deletedBy(): string | null;
|
|
26
35
|
get isDeleted(): boolean;
|
|
27
36
|
get isActive(): boolean;
|
|
@@ -5,9 +5,20 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
const date_fns_1 = require("date-fns");
|
|
7
7
|
const isNumber_1 = __importDefault(require("lodash/isNumber"));
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
8
|
+
/**
|
|
9
|
+
* Modelo plain-object para una fila de `partnership_plan`. Conserva la lógica
|
|
10
|
+
* de dominio de cálculo de fechas de cobro. Las fechas persistidas son ISO
|
|
11
|
+
* (string); los métodos de cálculo operan con `Date`.
|
|
12
|
+
*/
|
|
13
|
+
class PartnershipPlan {
|
|
14
|
+
constructor(data) {
|
|
15
|
+
this.id = data.id;
|
|
16
|
+
this._data = data;
|
|
17
|
+
this.exists = true;
|
|
18
|
+
}
|
|
19
|
+
get data() {
|
|
20
|
+
return this._data;
|
|
21
|
+
}
|
|
11
22
|
get basicInfo() {
|
|
12
23
|
return {
|
|
13
24
|
name: this.name,
|
|
@@ -16,7 +27,7 @@ class PartnershipPlan extends lang_1.default {
|
|
|
16
27
|
};
|
|
17
28
|
}
|
|
18
29
|
get partnershipId() {
|
|
19
|
-
return
|
|
30
|
+
return this._data.partnershipId;
|
|
20
31
|
}
|
|
21
32
|
setPaymentDay(date) {
|
|
22
33
|
return this.isPaymentDayEndOfMonth
|
|
@@ -43,19 +54,19 @@ class PartnershipPlan extends lang_1.default {
|
|
|
43
54
|
return newDate;
|
|
44
55
|
}
|
|
45
56
|
get name() {
|
|
46
|
-
return this.
|
|
57
|
+
return this._data.name;
|
|
47
58
|
}
|
|
48
59
|
get description() {
|
|
49
|
-
return this.
|
|
60
|
+
return this._data.description;
|
|
50
61
|
}
|
|
51
62
|
get price() {
|
|
52
|
-
return this.
|
|
63
|
+
return this._data.price;
|
|
53
64
|
}
|
|
54
65
|
get displayPrice() {
|
|
55
66
|
return `${this.price} €`;
|
|
56
67
|
}
|
|
57
68
|
get schedule() {
|
|
58
|
-
return this.
|
|
69
|
+
return this._data.schedule;
|
|
59
70
|
}
|
|
60
71
|
get isAnnuallySchedule() {
|
|
61
72
|
return this.schedule.periodInMonths === 12;
|
|
@@ -63,32 +74,29 @@ class PartnershipPlan extends lang_1.default {
|
|
|
63
74
|
get isPaymentDayEndOfMonth() {
|
|
64
75
|
return this.schedule.paymentDay === -1;
|
|
65
76
|
}
|
|
66
|
-
// get paymentMethod() {
|
|
67
|
-
// return this.data.paymentMethod;
|
|
68
|
-
// }
|
|
69
77
|
get subscriptionsCount() {
|
|
70
|
-
return this.
|
|
78
|
+
return this._data.subscriptionsCount || 0;
|
|
71
79
|
}
|
|
72
80
|
get hasSubscriptions() {
|
|
73
81
|
return this.subscriptionsCount > 0;
|
|
74
82
|
}
|
|
75
83
|
get createdAt() {
|
|
76
|
-
return this.
|
|
84
|
+
return this._data.createdAt;
|
|
77
85
|
}
|
|
78
86
|
get createdBy() {
|
|
79
|
-
return this.
|
|
87
|
+
return this._data.createdBy;
|
|
80
88
|
}
|
|
81
89
|
get editedAt() {
|
|
82
|
-
return this.
|
|
90
|
+
return this._data.editedAt || null;
|
|
83
91
|
}
|
|
84
92
|
get editedBy() {
|
|
85
|
-
return this.
|
|
93
|
+
return this._data.editedBy || null;
|
|
86
94
|
}
|
|
87
95
|
get deletedAt() {
|
|
88
|
-
return this.
|
|
96
|
+
return this._data.deletedAt || null;
|
|
89
97
|
}
|
|
90
98
|
get deletedBy() {
|
|
91
|
-
return this.
|
|
99
|
+
return this._data.deletedBy || null;
|
|
92
100
|
}
|
|
93
101
|
get isDeleted() {
|
|
94
102
|
return this.deletedAt !== null;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { Database } from '../../../types/supabase';
|
|
2
|
+
import { PartnershipPlanData } from './types';
|
|
3
|
+
export type PartnershipPlanRow = Database['public']['Tables']['partnership_plan']['Row'];
|
|
4
|
+
export type PartnershipPlanInsert = Database['public']['Tables']['partnership_plan']['Insert'];
|
|
5
|
+
export type PartnershipPlanUpdate = Database['public']['Tables']['partnership_plan']['Update'];
|
|
6
|
+
export declare const PARTNERSHIP_PLAN_TABLE: "partnership_plan";
|
|
7
|
+
export declare function rowToPartnershipPlanData(row: PartnershipPlanRow): PartnershipPlanData;
|