@bizmap/sdk 0.0.100 → 0.0.102
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/main.d.ts +77 -54
- package/dist/main.js +37 -24
- package/package.json +1 -1
package/dist/main.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as z from 'zod';
|
|
2
|
-
import { SafeOmit } from '@wavy/util';
|
|
2
|
+
import { SafeOmit, Prettify } from '@wavy/util';
|
|
3
3
|
|
|
4
4
|
declare const companyUserRoles: z.ZodEnum<{
|
|
5
5
|
doc: "doc";
|
|
@@ -956,7 +956,7 @@ declare const Reason: z.ZodObject<{
|
|
|
956
956
|
declare const Version: z.ZodInt;
|
|
957
957
|
declare const AlphaNumeric: z.ZodString;
|
|
958
958
|
|
|
959
|
-
declare const
|
|
959
|
+
declare const PriceMod: z.ZodObject<{
|
|
960
960
|
createdAt: z.ZodReadonly<z.ZodISODateTime>;
|
|
961
961
|
lastModified: z.ZodOptional<z.ZodNullable<z.ZodISODateTime>>;
|
|
962
962
|
description: z.ZodString;
|
|
@@ -969,7 +969,21 @@ declare const PriceAdjustment: z.ZodObject<{
|
|
|
969
969
|
percentage: z.ZodNumber;
|
|
970
970
|
isOptional: z.ZodBoolean;
|
|
971
971
|
}, z.core.$strip>;
|
|
972
|
-
type
|
|
972
|
+
type PriceMod = z.infer<typeof PriceMod>;
|
|
973
|
+
declare const PriceModList: z.ZodRecord<z.ZodUUID, z.ZodObject<{
|
|
974
|
+
createdAt: z.ZodReadonly<z.ZodISODateTime>;
|
|
975
|
+
lastModified: z.ZodOptional<z.ZodNullable<z.ZodISODateTime>>;
|
|
976
|
+
description: z.ZodString;
|
|
977
|
+
fixedAmount: z.ZodObject<{
|
|
978
|
+
value: z.ZodNumber;
|
|
979
|
+
currency: z.ZodEnum<{
|
|
980
|
+
JMD: "JMD";
|
|
981
|
+
}>;
|
|
982
|
+
}, z.core.$strip>;
|
|
983
|
+
percentage: z.ZodNumber;
|
|
984
|
+
isOptional: z.ZodBoolean;
|
|
985
|
+
}, z.core.$strip>>;
|
|
986
|
+
type PriceModList = z.infer<typeof PriceModList>;
|
|
973
987
|
declare const PriceTag: z.ZodObject<{
|
|
974
988
|
createdAt: z.ZodReadonly<z.ZodISODateTime>;
|
|
975
989
|
lastModified: z.ZodOptional<z.ZodNullable<z.ZodISODateTime>>;
|
|
@@ -1070,11 +1084,17 @@ declare const ClientForm: z.ZodObject<{
|
|
|
1070
1084
|
}, z.core.$strip>;
|
|
1071
1085
|
type ClientForm = z.infer<typeof ClientForm>;
|
|
1072
1086
|
|
|
1087
|
+
declare const AppointmentSeverity: z.ZodObject<{
|
|
1088
|
+
1: z.ZodLiteral<"Emergency">;
|
|
1089
|
+
2: z.ZodLiteral<"Important">;
|
|
1090
|
+
3: z.ZodLiteral<"Average">;
|
|
1091
|
+
}, z.core.$strip>;
|
|
1092
|
+
type AppointmentSeverity = z.infer<typeof AppointmentSeverity>;
|
|
1073
1093
|
declare const MiniAppointmentDetails: z.ZodObject<{
|
|
1074
1094
|
createdAt: z.ZodReadonly<z.ZodISODateTime>;
|
|
1075
1095
|
lastModified: z.ZodOptional<z.ZodNullable<z.ZodISODateTime>>;
|
|
1076
1096
|
_id: z.ZodUUID;
|
|
1077
|
-
|
|
1097
|
+
severity: z.ZodString;
|
|
1078
1098
|
src: z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>;
|
|
1079
1099
|
tkt: z.ZodReadonly<z.ZodInt>;
|
|
1080
1100
|
reason: z.ZodOptional<z.ZodObject<{
|
|
@@ -1131,6 +1151,20 @@ declare const MiniAppointmentDetails: z.ZodObject<{
|
|
|
1131
1151
|
percentage: z.ZodNumber;
|
|
1132
1152
|
isOptional: z.ZodBoolean;
|
|
1133
1153
|
}, z.core.$strip>>>>;
|
|
1154
|
+
payments: z.ZodOptional<z.ZodNullable<z.ZodArray<z.ZodObject<{
|
|
1155
|
+
createdAt: z.ZodReadonly<z.ZodISODateTime>;
|
|
1156
|
+
lastModified: z.ZodOptional<z.ZodNullable<z.ZodISODateTime>>;
|
|
1157
|
+
uid: z.ZodUUID;
|
|
1158
|
+
method: z.ZodEnum<{
|
|
1159
|
+
cash: "cash";
|
|
1160
|
+
card: "card";
|
|
1161
|
+
insurance: "insurance";
|
|
1162
|
+
}>;
|
|
1163
|
+
currency: z.ZodEnum<{
|
|
1164
|
+
JMD: "JMD";
|
|
1165
|
+
}>;
|
|
1166
|
+
amount: z.ZodNumber;
|
|
1167
|
+
}, z.core.$strip>>>>;
|
|
1134
1168
|
clientUid: z.ZodUUID;
|
|
1135
1169
|
payload: z.ZodOptional<z.ZodNullable<z.ZodObject<{
|
|
1136
1170
|
lastModified: z.ZodNullable<z.ZodNumber>;
|
|
@@ -1175,20 +1209,6 @@ declare const MiniAppointmentDetails: z.ZodObject<{
|
|
|
1175
1209
|
physAsst: "physAsst";
|
|
1176
1210
|
}>;
|
|
1177
1211
|
}, z.core.$strip>>;
|
|
1178
|
-
payments: z.ZodOptional<z.ZodNullable<z.ZodArray<z.ZodObject<{
|
|
1179
|
-
createdAt: z.ZodReadonly<z.ZodISODateTime>;
|
|
1180
|
-
lastModified: z.ZodOptional<z.ZodNullable<z.ZodISODateTime>>;
|
|
1181
|
-
uid: z.ZodUUID;
|
|
1182
|
-
method: z.ZodEnum<{
|
|
1183
|
-
cash: "cash";
|
|
1184
|
-
card: "card";
|
|
1185
|
-
insurance: "insurance";
|
|
1186
|
-
}>;
|
|
1187
|
-
currency: z.ZodEnum<{
|
|
1188
|
-
JMD: "JMD";
|
|
1189
|
-
}>;
|
|
1190
|
-
amount: z.ZodNumber;
|
|
1191
|
-
}, z.core.$strip>>>>;
|
|
1192
1212
|
lockedBy: z.ZodOptional<z.ZodUUID>;
|
|
1193
1213
|
timeline: z.ZodObject<{
|
|
1194
1214
|
scheduler: z.ZodObject<{
|
|
@@ -1288,7 +1308,7 @@ declare const AppointmentDetails: z.ZodObject<{
|
|
|
1288
1308
|
}, z.core.$strip>>>;
|
|
1289
1309
|
src: z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>;
|
|
1290
1310
|
tkt: z.ZodReadonly<z.ZodInt>;
|
|
1291
|
-
|
|
1311
|
+
severity: z.ZodString;
|
|
1292
1312
|
reason: z.ZodOptional<z.ZodObject<{
|
|
1293
1313
|
createdAt: z.ZodReadonly<z.ZodISODateTime>;
|
|
1294
1314
|
lastModified: z.ZodOptional<z.ZodNullable<z.ZodISODateTime>>;
|
|
@@ -1304,17 +1324,6 @@ declare const AppointmentDetails: z.ZodObject<{
|
|
|
1304
1324
|
item: z.ZodString;
|
|
1305
1325
|
cost: z.ZodNumber;
|
|
1306
1326
|
}, z.core.$strip>>>>;
|
|
1307
|
-
cancelled: z.ZodOptional<z.ZodObject<{
|
|
1308
|
-
doneAt: z.ZodISODateTime;
|
|
1309
|
-
reason: z.ZodObject<{
|
|
1310
|
-
value: z.ZodString;
|
|
1311
|
-
lastModified: z.ZodISODateTime;
|
|
1312
|
-
}, z.core.$strip>;
|
|
1313
|
-
doneBy: z.ZodEnum<{
|
|
1314
|
-
doc: "doc";
|
|
1315
|
-
physAsst: "physAsst";
|
|
1316
|
-
}>;
|
|
1317
|
-
}, z.core.$strip>>;
|
|
1318
1327
|
payments: z.ZodOptional<z.ZodNullable<z.ZodArray<z.ZodObject<{
|
|
1319
1328
|
createdAt: z.ZodReadonly<z.ZodISODateTime>;
|
|
1320
1329
|
lastModified: z.ZodOptional<z.ZodNullable<z.ZodISODateTime>>;
|
|
@@ -1329,6 +1338,17 @@ declare const AppointmentDetails: z.ZodObject<{
|
|
|
1329
1338
|
}>;
|
|
1330
1339
|
amount: z.ZodNumber;
|
|
1331
1340
|
}, z.core.$strip>>>>;
|
|
1341
|
+
cancelled: z.ZodOptional<z.ZodObject<{
|
|
1342
|
+
doneAt: z.ZodISODateTime;
|
|
1343
|
+
reason: z.ZodObject<{
|
|
1344
|
+
value: z.ZodString;
|
|
1345
|
+
lastModified: z.ZodISODateTime;
|
|
1346
|
+
}, z.core.$strip>;
|
|
1347
|
+
doneBy: z.ZodEnum<{
|
|
1348
|
+
doc: "doc";
|
|
1349
|
+
physAsst: "physAsst";
|
|
1350
|
+
}>;
|
|
1351
|
+
}, z.core.$strip>>;
|
|
1332
1352
|
lockedBy: z.ZodOptional<z.ZodUUID>;
|
|
1333
1353
|
timeline: z.ZodObject<{
|
|
1334
1354
|
scheduler: z.ZodObject<{
|
|
@@ -1467,7 +1487,7 @@ declare const MutableAppointmentDetails: z.ZodObject<{
|
|
|
1467
1487
|
}, z.core.$strip>>>;
|
|
1468
1488
|
src: z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>;
|
|
1469
1489
|
tkt: z.ZodReadonly<z.ZodInt>;
|
|
1470
|
-
|
|
1490
|
+
severity: z.ZodString;
|
|
1471
1491
|
reason: z.ZodOptional<z.ZodObject<{
|
|
1472
1492
|
createdAt: z.ZodReadonly<z.ZodISODateTime>;
|
|
1473
1493
|
lastModified: z.ZodOptional<z.ZodNullable<z.ZodISODateTime>>;
|
|
@@ -1483,17 +1503,6 @@ declare const MutableAppointmentDetails: z.ZodObject<{
|
|
|
1483
1503
|
item: z.ZodString;
|
|
1484
1504
|
cost: z.ZodNumber;
|
|
1485
1505
|
}, z.core.$strip>>>>;
|
|
1486
|
-
cancelled: z.ZodOptional<z.ZodObject<{
|
|
1487
|
-
doneAt: z.ZodISODateTime;
|
|
1488
|
-
reason: z.ZodObject<{
|
|
1489
|
-
value: z.ZodString;
|
|
1490
|
-
lastModified: z.ZodISODateTime;
|
|
1491
|
-
}, z.core.$strip>;
|
|
1492
|
-
doneBy: z.ZodEnum<{
|
|
1493
|
-
doc: "doc";
|
|
1494
|
-
physAsst: "physAsst";
|
|
1495
|
-
}>;
|
|
1496
|
-
}, z.core.$strip>>;
|
|
1497
1506
|
payments: z.ZodOptional<z.ZodNullable<z.ZodArray<z.ZodObject<{
|
|
1498
1507
|
createdAt: z.ZodReadonly<z.ZodISODateTime>;
|
|
1499
1508
|
lastModified: z.ZodOptional<z.ZodNullable<z.ZodISODateTime>>;
|
|
@@ -1508,6 +1517,17 @@ declare const MutableAppointmentDetails: z.ZodObject<{
|
|
|
1508
1517
|
}>;
|
|
1509
1518
|
amount: z.ZodNumber;
|
|
1510
1519
|
}, z.core.$strip>>>>;
|
|
1520
|
+
cancelled: z.ZodOptional<z.ZodObject<{
|
|
1521
|
+
doneAt: z.ZodISODateTime;
|
|
1522
|
+
reason: z.ZodObject<{
|
|
1523
|
+
value: z.ZodString;
|
|
1524
|
+
lastModified: z.ZodISODateTime;
|
|
1525
|
+
}, z.core.$strip>;
|
|
1526
|
+
doneBy: z.ZodEnum<{
|
|
1527
|
+
doc: "doc";
|
|
1528
|
+
physAsst: "physAsst";
|
|
1529
|
+
}>;
|
|
1530
|
+
}, z.core.$strip>>;
|
|
1511
1531
|
lockedBy: z.ZodOptional<z.ZodUUID>;
|
|
1512
1532
|
timeline: z.ZodObject<{
|
|
1513
1533
|
scheduler: z.ZodObject<{
|
|
@@ -1575,7 +1595,7 @@ declare const ScheduleAppointmentForm: z.ZodObject<{
|
|
|
1575
1595
|
lastModified: z.ZodOptional<z.ZodNullable<z.ZodISODateTime>>;
|
|
1576
1596
|
clientId: z.ZodUUID;
|
|
1577
1597
|
serviceProviderId: z.ZodUnion<[z.ZodUUID, z.ZodLiteral<"next">]>;
|
|
1578
|
-
category: z.
|
|
1598
|
+
category: z.ZodString;
|
|
1579
1599
|
appointmentReason: z.ZodOptional<z.ZodObject<{
|
|
1580
1600
|
createdAt: z.ZodReadonly<z.ZodISODateTime>;
|
|
1581
1601
|
lastModified: z.ZodOptional<z.ZodNullable<z.ZodISODateTime>>;
|
|
@@ -1700,7 +1720,7 @@ declare function scheduleAppointment(request: RequestParameter): Promise<{
|
|
|
1700
1720
|
_id: string;
|
|
1701
1721
|
src: string;
|
|
1702
1722
|
tkt: number;
|
|
1703
|
-
|
|
1723
|
+
severity: string;
|
|
1704
1724
|
timeline: {
|
|
1705
1725
|
scheduler: {
|
|
1706
1726
|
userUid: string;
|
|
@@ -1830,14 +1850,6 @@ declare function scheduleAppointment(request: RequestParameter): Promise<{
|
|
|
1830
1850
|
cost: number;
|
|
1831
1851
|
lastModified?: string | null | undefined;
|
|
1832
1852
|
}> | null | undefined;
|
|
1833
|
-
cancelled?: {
|
|
1834
|
-
doneAt: string;
|
|
1835
|
-
reason: {
|
|
1836
|
-
value: string;
|
|
1837
|
-
lastModified: string;
|
|
1838
|
-
};
|
|
1839
|
-
doneBy: "doc" | "physAsst";
|
|
1840
|
-
} | undefined;
|
|
1841
1853
|
payments?: {
|
|
1842
1854
|
createdAt: string;
|
|
1843
1855
|
uid: string;
|
|
@@ -1846,12 +1858,23 @@ declare function scheduleAppointment(request: RequestParameter): Promise<{
|
|
|
1846
1858
|
amount: number;
|
|
1847
1859
|
lastModified?: string | null | undefined;
|
|
1848
1860
|
}[] | null | undefined;
|
|
1861
|
+
cancelled?: {
|
|
1862
|
+
doneAt: string;
|
|
1863
|
+
reason: {
|
|
1864
|
+
value: string;
|
|
1865
|
+
lastModified: string;
|
|
1866
|
+
};
|
|
1867
|
+
doneBy: "doc" | "physAsst";
|
|
1868
|
+
} | undefined;
|
|
1849
1869
|
lockedBy?: string | undefined;
|
|
1850
1870
|
};
|
|
1851
1871
|
}>;
|
|
1852
1872
|
|
|
1853
1873
|
/** @disclaimer This doesn't handle currency conversion */
|
|
1854
|
-
declare function
|
|
1874
|
+
declare function calcBalance(components: Prettify<Partial<Pick<AppointmentDetails, "charges" | "discounts" | "additionalFees" | "prepayments" | "payments">>>, options?: {
|
|
1875
|
+
logger?: boolean;
|
|
1876
|
+
}): number;
|
|
1877
|
+
declare const calcPriceMod: (mods: PriceModList | null | undefined, subtotal: number) => number;
|
|
1855
1878
|
|
|
1856
1879
|
/**
|
|
1857
1880
|
* @param {CompanyUserRole} role The role used to filter the staff members
|
|
@@ -1914,4 +1937,4 @@ declare function createNotifId(options?: {
|
|
|
1914
1937
|
to: string;
|
|
1915
1938
|
}): string;
|
|
1916
1939
|
|
|
1917
|
-
export { type AcceptedCurrency, AlphaNumeric, AppointmentDetails, type AppointmentDistAlg, ClientForm, ClientIdentity, CompanyBilling, CompanyDetails, CompanyIdentity, CompanyInviteList, CompanyNotifications, type CompanyPartnerRole, CompanyPreferences, type CompanyServiceSelector, CompanyStaff, CompanyState, CompanyUser, type CompanyUserRole, CompanyUserSession, type CompanyUserStatus, CreateCompanyForm, CreditCurrency, type EmployeeRole, type Gender, type HealthcareProviderRole, type Industry, InviteResponse, InvoiceNo, MedicalDetails, Medicine, MiniAppointmentDetails, MiniCompanyUser, MutableAppointmentDetails, MutableCompanyBilling, MutableCompanyDetails, MutableCompanyIdentity, MutableCompanyPreferences, Notification, PaymentDetails, type PaymentMethod,
|
|
1940
|
+
export { type AcceptedCurrency, AlphaNumeric, AppointmentDetails, type AppointmentDistAlg, AppointmentSeverity, ClientForm, ClientIdentity, CompanyBilling, CompanyDetails, CompanyIdentity, CompanyInviteList, CompanyNotifications, type CompanyPartnerRole, CompanyPreferences, type CompanyServiceSelector, CompanyStaff, CompanyState, CompanyUser, type CompanyUserRole, CompanyUserSession, type CompanyUserStatus, CreateCompanyForm, CreditCurrency, type EmployeeRole, type Gender, type HealthcareProviderRole, type Industry, InviteResponse, InvoiceNo, MedicalDetails, Medicine, MiniAppointmentDetails, MiniCompanyUser, MutableAppointmentDetails, MutableCompanyBilling, MutableCompanyDetails, MutableCompanyIdentity, MutableCompanyPreferences, Notification, PaymentDetails, type PaymentMethod, PriceMod, PriceModList, PriceTag, Reason, Receipts, ScheduleAppointmentForm, StandardTime, TicketNo, type Tier, TierList, TimeLog, Timestamp, Trn, UserDetails, Version, Vitals, acceptedCurrencies, adminRoles, appointmentDistAlgs, calcBalance, calcPriceMod, companyPartnerRoles, companyServiceSelectors, companyUserRoles, companyUserStatus, createNotifId, employeeRoles, findAvailableStaff, findConflictingPartners, findNextAvailableStaff, genders, getCompatibleRoles, healthcareProviderRoles, industries, normalizeCompanyId, normalizeNidKey, parseClientName, paymentMethods, scheduleAppointment, serviceProviders, tiers, vitalKeys };
|
package/dist/main.js
CHANGED
|
@@ -104,7 +104,7 @@ var AlphaNumeric = z5.string().trim().superRefine((data, ctx) => {
|
|
|
104
104
|
});
|
|
105
105
|
|
|
106
106
|
// src/schemas/utils/billing.ts
|
|
107
|
-
var
|
|
107
|
+
var PriceMod = z6.object({
|
|
108
108
|
description: z6.string().trim().min(3, "A description must have atleast (3) characters.").max(25, "A description can't have more that (25) characters.").superRefine((data, ctx) => {
|
|
109
109
|
const invalidCharIdx = data.search(/[^a-zA-Z0-9-\.:\(\)]/);
|
|
110
110
|
if (invalidCharIdx > -1) {
|
|
@@ -119,6 +119,7 @@ var PriceAdjustment = z6.object({
|
|
|
119
119
|
isOptional: z6.boolean(),
|
|
120
120
|
...TimeLog.shape
|
|
121
121
|
});
|
|
122
|
+
var PriceModList = z6.record(z6.uuidv4(), PriceMod);
|
|
122
123
|
var PriceTag = z6.object({
|
|
123
124
|
uid: z6.uuidv4(),
|
|
124
125
|
/**The name of the item that's being priced */
|
|
@@ -178,16 +179,16 @@ var CompanyState = z7.object({
|
|
|
178
179
|
});
|
|
179
180
|
|
|
180
181
|
// src/schemas/company/components/Billing.ts
|
|
181
|
-
var
|
|
182
|
+
var createMod = (resource) => PriceModList.refine(
|
|
182
183
|
(d) => Object.values(d).length <= 100,
|
|
183
184
|
`Adding more than 100 ${resource}s is prohibited.`
|
|
184
185
|
);
|
|
185
186
|
var CompanyBilling = z8.object({
|
|
186
187
|
_id: CompanyState.shape._id,
|
|
187
|
-
additionalFees:
|
|
188
|
-
discounts:
|
|
188
|
+
additionalFees: createMod("additional fee"),
|
|
189
|
+
discounts: createMod("discount"),
|
|
189
190
|
/** Optionally deductable from bills */
|
|
190
|
-
prepayments:
|
|
191
|
+
prepayments: createMod("pre-payment"),
|
|
191
192
|
offeredServices: z8.record(z8.uuidv4(), PriceTag.omit({ uid: true })).superRefine((data, ctx) => {
|
|
192
193
|
const services = Object.entries(data);
|
|
193
194
|
if (services.length > 150) {
|
|
@@ -777,21 +778,25 @@ var MedicalDetails = z20.object({
|
|
|
777
778
|
import { sumOf as sumOf2 } from "@wavy/fn";
|
|
778
779
|
import * as z21 from "zod";
|
|
779
780
|
|
|
780
|
-
// src/functions/
|
|
781
|
+
// src/functions/calc.ts
|
|
781
782
|
import { sumOf } from "@wavy/fn";
|
|
782
|
-
function
|
|
783
|
+
function calcBalance(components, options) {
|
|
783
784
|
const subtotal = sumOf(
|
|
784
|
-
Object.values(
|
|
785
|
+
Object.values(components.charges || {})?.map((c) => c.cost)
|
|
785
786
|
);
|
|
786
|
-
const discount =
|
|
787
|
-
const additionalFees =
|
|
788
|
-
const prepayments =
|
|
789
|
-
|
|
790
|
-
|
|
787
|
+
const discount = calcPriceMod(components.discounts, subtotal);
|
|
788
|
+
const additionalFees = calcPriceMod(components.additionalFees, subtotal);
|
|
789
|
+
const prepayments = calcPriceMod(components.prepayments, subtotal);
|
|
790
|
+
const payments = sumOf(components.payments?.map((p) => p.amount) ?? []);
|
|
791
|
+
const result = subtotal + additionalFees - (discount + prepayments + payments);
|
|
792
|
+
if (options?.logger) {
|
|
793
|
+
console.log({ subtotal, discount, additionalFees, prepayments, result });
|
|
794
|
+
}
|
|
795
|
+
return result;
|
|
791
796
|
}
|
|
792
|
-
var
|
|
793
|
-
const castedAdjustments = !
|
|
794
|
-
if (!
|
|
797
|
+
var calcPriceMod = (mods, subtotal) => {
|
|
798
|
+
const castedAdjustments = !mods ? [] : Object.values(mods);
|
|
799
|
+
if (!mods || castedAdjustments.length < 1) return 0;
|
|
795
800
|
return sumOf(
|
|
796
801
|
castedAdjustments?.map(
|
|
797
802
|
(d) => (d.fixedAmount?.value || 0) + (d.percentage ? d.percentage * 0.01 * subtotal : 0)
|
|
@@ -804,11 +809,16 @@ var TimelineActivity = z21.object({
|
|
|
804
809
|
postedAt: Timestamp.nullish(),
|
|
805
810
|
userUid: CompanyUser.shape._id.nonoptional()
|
|
806
811
|
});
|
|
812
|
+
var AppointmentSeverity = z21.object({
|
|
813
|
+
1: z21.literal("Emergency"),
|
|
814
|
+
2: z21.literal("Important"),
|
|
815
|
+
3: z21.literal("Average")
|
|
816
|
+
});
|
|
807
817
|
var MiniAppointmentDetails = z21.object({
|
|
808
818
|
/** A random uid that identifies the document. */
|
|
809
819
|
_id: z21.uuidv4(),
|
|
810
820
|
// This helps to identify the urgency of the appointment
|
|
811
|
-
|
|
821
|
+
severity: z21.string().refine((data) => AppointmentSeverity.keyof().safeParse(data).success),
|
|
812
822
|
/** The company's uid */
|
|
813
823
|
src: CompanyState.shape._id,
|
|
814
824
|
/** The ticket number */
|
|
@@ -835,6 +845,7 @@ var MiniAppointmentDetails = z21.object({
|
|
|
835
845
|
/**Required to calculate the accurate grandTotal of the charges */
|
|
836
846
|
discounts: CompanyBilling.shape.discounts.nullish(),
|
|
837
847
|
prepayments: CompanyBilling.shape.prepayments.nullish(),
|
|
848
|
+
payments: z21.array(PaymentDetails).max(100).nullish(),
|
|
838
849
|
/** The client's identity */
|
|
839
850
|
clientUid: ClientIdentity.shape._id,
|
|
840
851
|
/**
|
|
@@ -852,9 +863,8 @@ var MiniAppointmentDetails = z21.object({
|
|
|
852
863
|
reason: Reason,
|
|
853
864
|
doneBy: companyUserRoles.extract(["doc", "physAsst"])
|
|
854
865
|
}).optional(),
|
|
855
|
-
|
|
866
|
+
//** Add this after consulting with company owners about payment expectations */
|
|
856
867
|
// paymentDueDate: Timestamp.nullish(),
|
|
857
|
-
payments: z21.array(PaymentDetails).max(100).nullish(),
|
|
858
868
|
// The user that is currently modifying the appointment
|
|
859
869
|
lockedBy: UserDetails.shape._id.optional(),
|
|
860
870
|
timeline: z21.object({
|
|
@@ -872,7 +882,7 @@ var MiniAppointmentDetails = z21.object({
|
|
|
872
882
|
}),
|
|
873
883
|
...TimeLog.shape
|
|
874
884
|
}).superRefine((data, ctx) => {
|
|
875
|
-
if (data.payments && data.charges && sumOf2(data.payments.map((p) => p.amount)) >=
|
|
885
|
+
if (data.payments && data.charges && sumOf2(data.payments.map((p) => p.amount)) >= calcBalance(data)) {
|
|
876
886
|
const untrackedPayment = data.payments.find(
|
|
877
887
|
(p) => !data.timeline.debtCollector?.some(
|
|
878
888
|
(d) => p.uid in d.collectedPayments
|
|
@@ -898,7 +908,7 @@ var MutableAppointmentDetails = AppointmentDetails.safeExtend(
|
|
|
898
908
|
var ScheduleAppointmentForm = z21.object({
|
|
899
909
|
clientId: ClientIdentity.shape._id,
|
|
900
910
|
serviceProviderId: CompanyUser.shape._id.or(z21.literal("next")),
|
|
901
|
-
category: AppointmentDetails.shape.
|
|
911
|
+
category: AppointmentDetails.shape.severity,
|
|
902
912
|
appointmentReason: AppointmentDetails.shape.reason,
|
|
903
913
|
charges: AppointmentDetails.shape.charges.optional(),
|
|
904
914
|
prepayments: AppointmentDetails.shape.prepayments.optional(),
|
|
@@ -1048,7 +1058,7 @@ async function scheduleAppointment(request) {
|
|
|
1048
1058
|
_id: v4(),
|
|
1049
1059
|
src: stateCopy._id,
|
|
1050
1060
|
tkt: request.state.tktNoCounter,
|
|
1051
|
-
|
|
1061
|
+
severity: request.form.category,
|
|
1052
1062
|
discounts: Object.fromEntries(
|
|
1053
1063
|
Object.entries(request.billing.discounts || {}).filter(
|
|
1054
1064
|
([_, disc]) => !disc.isOptional
|
|
@@ -1106,6 +1116,7 @@ function createNotifId(options) {
|
|
|
1106
1116
|
export {
|
|
1107
1117
|
AlphaNumeric,
|
|
1108
1118
|
AppointmentDetails,
|
|
1119
|
+
AppointmentSeverity,
|
|
1109
1120
|
ClientForm,
|
|
1110
1121
|
ClientIdentity,
|
|
1111
1122
|
CompanyBilling,
|
|
@@ -1133,7 +1144,8 @@ export {
|
|
|
1133
1144
|
MutableCompanyPreferences,
|
|
1134
1145
|
Notification,
|
|
1135
1146
|
PaymentDetails,
|
|
1136
|
-
|
|
1147
|
+
PriceMod,
|
|
1148
|
+
PriceModList,
|
|
1137
1149
|
PriceTag,
|
|
1138
1150
|
Reason,
|
|
1139
1151
|
Receipts,
|
|
@@ -1150,7 +1162,8 @@ export {
|
|
|
1150
1162
|
acceptedCurrencies,
|
|
1151
1163
|
adminRoles,
|
|
1152
1164
|
appointmentDistAlgs,
|
|
1153
|
-
|
|
1165
|
+
calcBalance,
|
|
1166
|
+
calcPriceMod,
|
|
1154
1167
|
companyPartnerRoles,
|
|
1155
1168
|
companyServiceSelectors,
|
|
1156
1169
|
companyUserRoles,
|