@iveri/contracts 0.48.0 → 0.49.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.
- package/dist/api/clinic/clinic-course.type.d.ts +68 -0
- package/dist/api/clinic/clinic-course.type.js +1 -0
- package/dist/api/clinic/clinic-payment-method.enum.d.ts +13 -0
- package/dist/api/clinic/clinic-payment-method.enum.js +14 -0
- package/dist/api/clinic/clinic-payment.type.d.ts +112 -0
- package/dist/api/clinic/clinic-payment.type.js +1 -0
- package/dist/api/clinic/clinic-profile.type.d.ts +3 -0
- package/dist/api/clinic/index.d.ts +3 -0
- package/dist/api/clinic/index.js +3 -0
- package/dist/enum/user-permission.enum.d.ts +7 -1
- package/dist/enum/user-permission.enum.js +6 -0
- package/package.json +1 -1
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import type { IsoDateTime } from '../../type/iso-date-time.type.js';
|
|
2
|
+
import type { Nullable } from '../../type/nil.type.js';
|
|
3
|
+
import type { UUID } from '../../type/uuid.type.js';
|
|
4
|
+
import type { ClinicPaymentMethod } from './clinic-payment-method.enum.js';
|
|
5
|
+
import type { ClinicResourceStatus } from './clinic-resource-status.enum.js';
|
|
6
|
+
import type { LocalizedText } from './localized-text.type.js';
|
|
7
|
+
/** A prepaid package the clinic offers: so many sessions of one option at one price. */
|
|
8
|
+
export interface ClinicCoursePlan {
|
|
9
|
+
id: UUID;
|
|
10
|
+
treatmentId: UUID;
|
|
11
|
+
optionId: UUID;
|
|
12
|
+
name: LocalizedText;
|
|
13
|
+
sessionCount: number;
|
|
14
|
+
priceMinor: number;
|
|
15
|
+
currency: string;
|
|
16
|
+
/** How long a sold course lasts, or `null` when it does not run out. */
|
|
17
|
+
validityDays: Nullable<number>;
|
|
18
|
+
status: ClinicResourceStatus;
|
|
19
|
+
createdAt: IsoDateTime;
|
|
20
|
+
updatedAt: IsoDateTime;
|
|
21
|
+
}
|
|
22
|
+
export interface CreateClinicCoursePlanRequest {
|
|
23
|
+
optionId: UUID;
|
|
24
|
+
name: LocalizedText;
|
|
25
|
+
sessionCount: number;
|
|
26
|
+
priceMinor: number;
|
|
27
|
+
validityDays?: Nullable<number>;
|
|
28
|
+
}
|
|
29
|
+
export interface UpdateClinicCoursePlanRequest {
|
|
30
|
+
name?: LocalizedText;
|
|
31
|
+
sessionCount?: number;
|
|
32
|
+
priceMinor?: number;
|
|
33
|
+
validityDays?: Nullable<number>;
|
|
34
|
+
status?: ClinicResourceStatus;
|
|
35
|
+
}
|
|
36
|
+
/** A course a client has bought, holding what was agreed then. A later change to the plan does not touch it. */
|
|
37
|
+
export interface ClinicCourse {
|
|
38
|
+
id: UUID;
|
|
39
|
+
clientId: UUID;
|
|
40
|
+
planId: UUID;
|
|
41
|
+
treatmentId: UUID;
|
|
42
|
+
optionId: UUID;
|
|
43
|
+
name: LocalizedText;
|
|
44
|
+
sessionsTotal: number;
|
|
45
|
+
sessionsUsed: number;
|
|
46
|
+
priceMinor: number;
|
|
47
|
+
currency: string;
|
|
48
|
+
expiresAt: Nullable<IsoDateTime>;
|
|
49
|
+
/** Set when the course was refunded, after which its remaining sessions are gone. */
|
|
50
|
+
closedAt: Nullable<IsoDateTime>;
|
|
51
|
+
createdAt: IsoDateTime;
|
|
52
|
+
}
|
|
53
|
+
export interface SellClinicCourseRequest {
|
|
54
|
+
planId: UUID;
|
|
55
|
+
locationId: UUID;
|
|
56
|
+
method: ClinicPaymentMethod;
|
|
57
|
+
note?: Nullable<string>;
|
|
58
|
+
}
|
|
59
|
+
/** A client's own view of a course they bought. */
|
|
60
|
+
export interface MyClinicCourse {
|
|
61
|
+
id: UUID;
|
|
62
|
+
treatmentId: UUID;
|
|
63
|
+
name: LocalizedText;
|
|
64
|
+
sessionsTotal: number;
|
|
65
|
+
sessionsUsed: number;
|
|
66
|
+
expiresAt: Nullable<IsoDateTime>;
|
|
67
|
+
isClosed: boolean;
|
|
68
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* How a visit was paid for. The first three are money the clinic received.
|
|
3
|
+
*
|
|
4
|
+
* `course` and `bonus` settle a visit without any money changing hands that day, so a day's takings
|
|
5
|
+
* keep them apart: the money for a course came in on the day it was sold.
|
|
6
|
+
*/
|
|
7
|
+
export declare enum ClinicPaymentMethod {
|
|
8
|
+
CASH = "cash",
|
|
9
|
+
CARD = "card",
|
|
10
|
+
TRANSFER = "transfer",
|
|
11
|
+
COURSE = "course",
|
|
12
|
+
BONUS = "bonus"
|
|
13
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* How a visit was paid for. The first three are money the clinic received.
|
|
3
|
+
*
|
|
4
|
+
* `course` and `bonus` settle a visit without any money changing hands that day, so a day's takings
|
|
5
|
+
* keep them apart: the money for a course came in on the day it was sold.
|
|
6
|
+
*/
|
|
7
|
+
export var ClinicPaymentMethod;
|
|
8
|
+
(function (ClinicPaymentMethod) {
|
|
9
|
+
ClinicPaymentMethod["CASH"] = "cash";
|
|
10
|
+
ClinicPaymentMethod["CARD"] = "card";
|
|
11
|
+
ClinicPaymentMethod["TRANSFER"] = "transfer";
|
|
12
|
+
ClinicPaymentMethod["COURSE"] = "course";
|
|
13
|
+
ClinicPaymentMethod["BONUS"] = "bonus";
|
|
14
|
+
})(ClinicPaymentMethod || (ClinicPaymentMethod = {}));
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
import type { IsoDateTime } from '../../type/iso-date-time.type.js';
|
|
2
|
+
import type { Nullable } from '../../type/nil.type.js';
|
|
3
|
+
import type { UUID } from '../../type/uuid.type.js';
|
|
4
|
+
import type { ClinicAppointmentStatus } from './clinic-appointment-status.enum.js';
|
|
5
|
+
import type { ClinicCourse, MyClinicCourse } from './clinic-course.type.js';
|
|
6
|
+
import type { ClinicPaymentMethod } from './clinic-payment-method.enum.js';
|
|
7
|
+
import type { LocalizedText } from './localized-text.type.js';
|
|
8
|
+
/** One line in the clinic's ledger. It is never edited: money given back is a new line pointing at it. */
|
|
9
|
+
export interface ClinicPayment {
|
|
10
|
+
id: UUID;
|
|
11
|
+
locationId: UUID;
|
|
12
|
+
clientId: UUID;
|
|
13
|
+
clientName: string;
|
|
14
|
+
/** The visit this was for, or `null` when it paid for a course. */
|
|
15
|
+
appointmentId: Nullable<UUID>;
|
|
16
|
+
/** The course this sold or used, or `null` when no course was involved. */
|
|
17
|
+
courseId: Nullable<UUID>;
|
|
18
|
+
method: ClinicPaymentMethod;
|
|
19
|
+
/** Negative for a refund. */
|
|
20
|
+
amountMinor: number;
|
|
21
|
+
currency: string;
|
|
22
|
+
refundsPaymentId: Nullable<UUID>;
|
|
23
|
+
/** Why money was given back. Only a refund has one. */
|
|
24
|
+
reason: Nullable<string>;
|
|
25
|
+
note: Nullable<string>;
|
|
26
|
+
/** How much of this can still be given back. Always zero on a refund. */
|
|
27
|
+
refundableMinor: number;
|
|
28
|
+
recordedByName: Nullable<string>;
|
|
29
|
+
createdAt: IsoDateTime;
|
|
30
|
+
}
|
|
31
|
+
export interface RecordClinicPaymentRequest {
|
|
32
|
+
method: ClinicPaymentMethod;
|
|
33
|
+
/** Required except for a course, whose session is worth what its line on the visit costs. */
|
|
34
|
+
amountMinor?: number;
|
|
35
|
+
/** Required for a course. */
|
|
36
|
+
courseId?: UUID;
|
|
37
|
+
note?: Nullable<string>;
|
|
38
|
+
}
|
|
39
|
+
export interface RefundClinicPaymentRequest {
|
|
40
|
+
/** Omitted to give back everything left. A course session or bonus is always given back whole. */
|
|
41
|
+
amountMinor?: number;
|
|
42
|
+
reason: string;
|
|
43
|
+
}
|
|
44
|
+
export interface ClinicBonusBalance {
|
|
45
|
+
currency: string;
|
|
46
|
+
amountMinor: number;
|
|
47
|
+
}
|
|
48
|
+
/** What reception needs at the desk for one visit. */
|
|
49
|
+
export interface ClinicVisitPayments {
|
|
50
|
+
appointmentId: UUID;
|
|
51
|
+
clientId: UUID;
|
|
52
|
+
clientName: string;
|
|
53
|
+
locationId: UUID;
|
|
54
|
+
treatmentName: LocalizedText;
|
|
55
|
+
status: ClinicAppointmentStatus;
|
|
56
|
+
currency: string;
|
|
57
|
+
totalMinor: number;
|
|
58
|
+
paidMinor: number;
|
|
59
|
+
dueMinor: number;
|
|
60
|
+
payments: ClinicPayment[];
|
|
61
|
+
/** This client's bonus in the visit's currency. */
|
|
62
|
+
bonusBalanceMinor: number;
|
|
63
|
+
/** This client's courses that can pay for a line of this visit. */
|
|
64
|
+
usableCourses: ClinicCourse[];
|
|
65
|
+
}
|
|
66
|
+
/** How much has been paid towards one visit. */
|
|
67
|
+
export interface ClinicVisitBalance {
|
|
68
|
+
appointmentId: UUID;
|
|
69
|
+
paidMinor: number;
|
|
70
|
+
}
|
|
71
|
+
export interface ClinicClientAccount {
|
|
72
|
+
clientId: UUID;
|
|
73
|
+
clientName: string;
|
|
74
|
+
bonusBalances: ClinicBonusBalance[];
|
|
75
|
+
courses: ClinicCourse[];
|
|
76
|
+
/** The newest payments, whatever they were for. */
|
|
77
|
+
payments: ClinicPayment[];
|
|
78
|
+
}
|
|
79
|
+
/** One currency's day. The three money figures are net of refunds, so cash is what the drawer should hold. */
|
|
80
|
+
export interface ClinicTakingsLine {
|
|
81
|
+
currency: string;
|
|
82
|
+
cashMinor: number;
|
|
83
|
+
cardMinor: number;
|
|
84
|
+
transferMinor: number;
|
|
85
|
+
netMinor: number;
|
|
86
|
+
refundedMinor: number;
|
|
87
|
+
courseRedeemedMinor: number;
|
|
88
|
+
bonusSpentMinor: number;
|
|
89
|
+
}
|
|
90
|
+
/** A visit that finished with money still owing. */
|
|
91
|
+
export interface ClinicUnsettledVisit {
|
|
92
|
+
appointmentId: UUID;
|
|
93
|
+
clientName: string;
|
|
94
|
+
treatmentName: LocalizedText;
|
|
95
|
+
currency: string;
|
|
96
|
+
totalMinor: number;
|
|
97
|
+
paidMinor: number;
|
|
98
|
+
dueMinor: number;
|
|
99
|
+
}
|
|
100
|
+
export interface ClinicDailyTakings {
|
|
101
|
+
locationId: UUID;
|
|
102
|
+
/** The branch's own calendar day, `YYYY-MM-DD`. */
|
|
103
|
+
date: string;
|
|
104
|
+
lines: ClinicTakingsLine[];
|
|
105
|
+
payments: ClinicPayment[];
|
|
106
|
+
unsettled: ClinicUnsettledVisit[];
|
|
107
|
+
}
|
|
108
|
+
/** What a client holds at this clinic. */
|
|
109
|
+
export interface MyClinicWallet {
|
|
110
|
+
bonusBalances: ClinicBonusBalance[];
|
|
111
|
+
courses: MyClinicCourse[];
|
|
112
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -19,6 +19,8 @@ export interface ClinicProfile {
|
|
|
19
19
|
clientCancelCutoffHours: number;
|
|
20
20
|
/** How far ahead a client can book. */
|
|
21
21
|
bookingHorizonDays: number;
|
|
22
|
+
/** The share of money paid that comes back as bonus. Zero means the clinic runs no bonus programme. */
|
|
23
|
+
bonusEarnPercent: number;
|
|
22
24
|
createdAt: IsoDateTime;
|
|
23
25
|
updatedAt: IsoDateTime;
|
|
24
26
|
}
|
|
@@ -32,4 +34,5 @@ export interface SaveClinicProfileRequest {
|
|
|
32
34
|
isPublished: boolean;
|
|
33
35
|
clientCancelCutoffHours: number;
|
|
34
36
|
bookingHorizonDays: number;
|
|
37
|
+
bonusEarnPercent?: number;
|
|
35
38
|
}
|
|
@@ -2,6 +2,7 @@ export * from './clinic-appointment-status.enum.js';
|
|
|
2
2
|
export * from './clinic-appointment.type.js';
|
|
3
3
|
export * from './clinic-client.type.js';
|
|
4
4
|
export * from './clinic-consent-form.type.js';
|
|
5
|
+
export * from './clinic-course.type.js';
|
|
5
6
|
export * from './clinic-device.type.js';
|
|
6
7
|
export * from './clinic-lead-kind.enum.js';
|
|
7
8
|
export * from './clinic-lead-status.enum.js';
|
|
@@ -14,6 +15,8 @@ export * from './clinic-gallery.type.js';
|
|
|
14
15
|
export * from './clinic-media.type.js';
|
|
15
16
|
export * from './clinic-newsletter-channel.enum.js';
|
|
16
17
|
export * from './clinic-newsletter.type.js';
|
|
18
|
+
export * from './clinic-payment-method.enum.js';
|
|
19
|
+
export * from './clinic-payment.type.js';
|
|
17
20
|
export * from './clinic-profile.type.js';
|
|
18
21
|
export * from './clinic-promotion.type.js';
|
|
19
22
|
export * from './clinic-public.type.js';
|
package/dist/api/clinic/index.js
CHANGED
|
@@ -2,6 +2,7 @@ export * from './clinic-appointment-status.enum.js';
|
|
|
2
2
|
export * from './clinic-appointment.type.js';
|
|
3
3
|
export * from './clinic-client.type.js';
|
|
4
4
|
export * from './clinic-consent-form.type.js';
|
|
5
|
+
export * from './clinic-course.type.js';
|
|
5
6
|
export * from './clinic-device.type.js';
|
|
6
7
|
export * from './clinic-lead-kind.enum.js';
|
|
7
8
|
export * from './clinic-lead-status.enum.js';
|
|
@@ -14,6 +15,8 @@ export * from './clinic-gallery.type.js';
|
|
|
14
15
|
export * from './clinic-media.type.js';
|
|
15
16
|
export * from './clinic-newsletter-channel.enum.js';
|
|
16
17
|
export * from './clinic-newsletter.type.js';
|
|
18
|
+
export * from './clinic-payment-method.enum.js';
|
|
19
|
+
export * from './clinic-payment.type.js';
|
|
17
20
|
export * from './clinic-profile.type.js';
|
|
18
21
|
export * from './clinic-promotion.type.js';
|
|
19
22
|
export * from './clinic-public.type.js';
|
|
@@ -456,7 +456,13 @@ export declare enum UserPermission {
|
|
|
456
456
|
/** Add to a client's clinical record: screening answers, signed consent and the treatment log. */
|
|
457
457
|
CLINIC_RECORD_MANAGE = "clinic:record:manage",
|
|
458
458
|
/** See who has read a client's clinical record, which reading the record does not show. */
|
|
459
|
-
CLINIC_RECORD_AUDIT = "clinic:record:audit"
|
|
459
|
+
CLINIC_RECORD_AUDIT = "clinic:record:audit",
|
|
460
|
+
/** See what has been paid, each client's balance and the day's takings. */
|
|
461
|
+
CLINIC_PAYMENT_READ = "clinic:payment:read",
|
|
462
|
+
/** Record money taken at the desk and sell prepaid courses. */
|
|
463
|
+
CLINIC_PAYMENT_RECORD = "clinic:payment:record",
|
|
464
|
+
/** Give money back. Its own permission, because reception taking money does not imply returning it. */
|
|
465
|
+
CLINIC_PAYMENT_REFUND = "clinic:payment:refund"
|
|
460
466
|
}
|
|
461
467
|
/**
|
|
462
468
|
* Every member, for seeding the owner role and validating custom-role input.
|
|
@@ -519,6 +519,12 @@ export var UserPermission;
|
|
|
519
519
|
UserPermission["CLINIC_RECORD_MANAGE"] = "clinic:record:manage";
|
|
520
520
|
/** See who has read a client's clinical record, which reading the record does not show. */
|
|
521
521
|
UserPermission["CLINIC_RECORD_AUDIT"] = "clinic:record:audit";
|
|
522
|
+
/** See what has been paid, each client's balance and the day's takings. */
|
|
523
|
+
UserPermission["CLINIC_PAYMENT_READ"] = "clinic:payment:read";
|
|
524
|
+
/** Record money taken at the desk and sell prepaid courses. */
|
|
525
|
+
UserPermission["CLINIC_PAYMENT_RECORD"] = "clinic:payment:record";
|
|
526
|
+
/** Give money back. Its own permission, because reception taking money does not imply returning it. */
|
|
527
|
+
UserPermission["CLINIC_PAYMENT_REFUND"] = "clinic:payment:refund";
|
|
522
528
|
})(UserPermission || (UserPermission = {}));
|
|
523
529
|
/**
|
|
524
530
|
* Every member, for seeding the owner role and validating custom-role input.
|