@bizmap/sdk 0.0.99 → 0.0.100
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 +70 -75
- package/dist/main.js +28 -18
- package/package.json +1 -1
package/dist/main.d.ts
CHANGED
|
@@ -1083,17 +1083,16 @@ declare const MiniAppointmentDetails: z.ZodObject<{
|
|
|
1083
1083
|
value: z.ZodString;
|
|
1084
1084
|
}, z.core.$strip>>;
|
|
1085
1085
|
invoiceNo: z.ZodOptional<z.ZodString>;
|
|
1086
|
-
charges: z.
|
|
1086
|
+
charges: z.ZodOptional<z.ZodNullable<z.ZodRecord<z.ZodUUID, z.ZodObject<{
|
|
1087
1087
|
createdAt: z.ZodReadonly<z.ZodISODateTime>;
|
|
1088
1088
|
lastModified: z.ZodOptional<z.ZodNullable<z.ZodISODateTime>>;
|
|
1089
|
-
uid: z.ZodUUID;
|
|
1090
|
-
item: z.ZodString;
|
|
1091
|
-
cost: z.ZodNumber;
|
|
1092
1089
|
currency: z.ZodEnum<{
|
|
1093
1090
|
JMD: "JMD";
|
|
1094
1091
|
}>;
|
|
1095
|
-
|
|
1096
|
-
|
|
1092
|
+
item: z.ZodString;
|
|
1093
|
+
cost: z.ZodNumber;
|
|
1094
|
+
}, z.core.$strip>>>>;
|
|
1095
|
+
additionalFees: z.ZodOptional<z.ZodNullable<z.ZodRecord<z.ZodUUID, z.ZodObject<{
|
|
1097
1096
|
createdAt: z.ZodReadonly<z.ZodISODateTime>;
|
|
1098
1097
|
lastModified: z.ZodOptional<z.ZodNullable<z.ZodISODateTime>>;
|
|
1099
1098
|
description: z.ZodString;
|
|
@@ -1106,7 +1105,7 @@ declare const MiniAppointmentDetails: z.ZodObject<{
|
|
|
1106
1105
|
percentage: z.ZodNumber;
|
|
1107
1106
|
isOptional: z.ZodBoolean;
|
|
1108
1107
|
}, z.core.$strip>>>>;
|
|
1109
|
-
discounts: z.
|
|
1108
|
+
discounts: z.ZodOptional<z.ZodNullable<z.ZodRecord<z.ZodUUID, z.ZodObject<{
|
|
1110
1109
|
createdAt: z.ZodReadonly<z.ZodISODateTime>;
|
|
1111
1110
|
lastModified: z.ZodOptional<z.ZodNullable<z.ZodISODateTime>>;
|
|
1112
1111
|
description: z.ZodString;
|
|
@@ -1119,7 +1118,7 @@ declare const MiniAppointmentDetails: z.ZodObject<{
|
|
|
1119
1118
|
percentage: z.ZodNumber;
|
|
1120
1119
|
isOptional: z.ZodBoolean;
|
|
1121
1120
|
}, z.core.$strip>>>>;
|
|
1122
|
-
prepayments: z.ZodNullable<z.
|
|
1121
|
+
prepayments: z.ZodOptional<z.ZodNullable<z.ZodRecord<z.ZodUUID, z.ZodObject<{
|
|
1123
1122
|
createdAt: z.ZodReadonly<z.ZodISODateTime>;
|
|
1124
1123
|
lastModified: z.ZodOptional<z.ZodNullable<z.ZodISODateTime>>;
|
|
1125
1124
|
description: z.ZodString;
|
|
@@ -1131,7 +1130,7 @@ declare const MiniAppointmentDetails: z.ZodObject<{
|
|
|
1131
1130
|
}, z.core.$strip>;
|
|
1132
1131
|
percentage: z.ZodNumber;
|
|
1133
1132
|
isOptional: z.ZodBoolean;
|
|
1134
|
-
}, z.core.$strip
|
|
1133
|
+
}, z.core.$strip>>>>;
|
|
1135
1134
|
clientUid: z.ZodUUID;
|
|
1136
1135
|
payload: z.ZodOptional<z.ZodNullable<z.ZodObject<{
|
|
1137
1136
|
lastModified: z.ZodNullable<z.ZodNumber>;
|
|
@@ -1216,7 +1215,7 @@ declare const AppointmentDetails: z.ZodObject<{
|
|
|
1216
1215
|
createdAt: z.ZodReadonly<z.ZodISODateTime>;
|
|
1217
1216
|
lastModified: z.ZodOptional<z.ZodNullable<z.ZodISODateTime>>;
|
|
1218
1217
|
_id: z.ZodUUID;
|
|
1219
|
-
additionalFees: z.
|
|
1218
|
+
additionalFees: z.ZodOptional<z.ZodNullable<z.ZodRecord<z.ZodUUID, z.ZodObject<{
|
|
1220
1219
|
createdAt: z.ZodReadonly<z.ZodISODateTime>;
|
|
1221
1220
|
lastModified: z.ZodOptional<z.ZodNullable<z.ZodISODateTime>>;
|
|
1222
1221
|
description: z.ZodString;
|
|
@@ -1229,7 +1228,7 @@ declare const AppointmentDetails: z.ZodObject<{
|
|
|
1229
1228
|
percentage: z.ZodNumber;
|
|
1230
1229
|
isOptional: z.ZodBoolean;
|
|
1231
1230
|
}, z.core.$strip>>>>;
|
|
1232
|
-
discounts: z.
|
|
1231
|
+
discounts: z.ZodOptional<z.ZodNullable<z.ZodRecord<z.ZodUUID, z.ZodObject<{
|
|
1233
1232
|
createdAt: z.ZodReadonly<z.ZodISODateTime>;
|
|
1234
1233
|
lastModified: z.ZodOptional<z.ZodNullable<z.ZodISODateTime>>;
|
|
1235
1234
|
description: z.ZodString;
|
|
@@ -1242,7 +1241,7 @@ declare const AppointmentDetails: z.ZodObject<{
|
|
|
1242
1241
|
percentage: z.ZodNumber;
|
|
1243
1242
|
isOptional: z.ZodBoolean;
|
|
1244
1243
|
}, z.core.$strip>>>>;
|
|
1245
|
-
prepayments: z.ZodNullable<z.
|
|
1244
|
+
prepayments: z.ZodOptional<z.ZodNullable<z.ZodRecord<z.ZodUUID, z.ZodObject<{
|
|
1246
1245
|
createdAt: z.ZodReadonly<z.ZodISODateTime>;
|
|
1247
1246
|
lastModified: z.ZodOptional<z.ZodNullable<z.ZodISODateTime>>;
|
|
1248
1247
|
description: z.ZodString;
|
|
@@ -1254,7 +1253,7 @@ declare const AppointmentDetails: z.ZodObject<{
|
|
|
1254
1253
|
}, z.core.$strip>;
|
|
1255
1254
|
percentage: z.ZodNumber;
|
|
1256
1255
|
isOptional: z.ZodBoolean;
|
|
1257
|
-
}, z.core.$strip
|
|
1256
|
+
}, z.core.$strip>>>>;
|
|
1258
1257
|
payload: z.ZodOptional<z.ZodNullable<z.ZodObject<{
|
|
1259
1258
|
lastModified: z.ZodNullable<z.ZodNumber>;
|
|
1260
1259
|
vitals: z.ZodRecord<z.ZodEnum<{
|
|
@@ -1296,16 +1295,15 @@ declare const AppointmentDetails: z.ZodObject<{
|
|
|
1296
1295
|
value: z.ZodString;
|
|
1297
1296
|
}, z.core.$strip>>;
|
|
1298
1297
|
invoiceNo: z.ZodOptional<z.ZodString>;
|
|
1299
|
-
charges: z.
|
|
1298
|
+
charges: z.ZodOptional<z.ZodNullable<z.ZodRecord<z.ZodUUID, z.ZodObject<{
|
|
1300
1299
|
createdAt: z.ZodReadonly<z.ZodISODateTime>;
|
|
1301
1300
|
lastModified: z.ZodOptional<z.ZodNullable<z.ZodISODateTime>>;
|
|
1302
|
-
uid: z.ZodUUID;
|
|
1303
|
-
item: z.ZodString;
|
|
1304
|
-
cost: z.ZodNumber;
|
|
1305
1301
|
currency: z.ZodEnum<{
|
|
1306
1302
|
JMD: "JMD";
|
|
1307
1303
|
}>;
|
|
1308
|
-
|
|
1304
|
+
item: z.ZodString;
|
|
1305
|
+
cost: z.ZodNumber;
|
|
1306
|
+
}, z.core.$strip>>>>;
|
|
1309
1307
|
cancelled: z.ZodOptional<z.ZodObject<{
|
|
1310
1308
|
doneAt: z.ZodISODateTime;
|
|
1311
1309
|
reason: z.ZodObject<{
|
|
@@ -1396,7 +1394,7 @@ declare const MutableAppointmentDetails: z.ZodObject<{
|
|
|
1396
1394
|
createdAt: z.ZodReadonly<z.ZodISODateTime>;
|
|
1397
1395
|
lastModified: z.ZodOptional<z.ZodNullable<z.ZodISODateTime>>;
|
|
1398
1396
|
_id: z.ZodUUID;
|
|
1399
|
-
additionalFees: z.
|
|
1397
|
+
additionalFees: z.ZodOptional<z.ZodNullable<z.ZodRecord<z.ZodUUID, z.ZodObject<{
|
|
1400
1398
|
createdAt: z.ZodReadonly<z.ZodISODateTime>;
|
|
1401
1399
|
lastModified: z.ZodOptional<z.ZodNullable<z.ZodISODateTime>>;
|
|
1402
1400
|
description: z.ZodString;
|
|
@@ -1409,7 +1407,7 @@ declare const MutableAppointmentDetails: z.ZodObject<{
|
|
|
1409
1407
|
percentage: z.ZodNumber;
|
|
1410
1408
|
isOptional: z.ZodBoolean;
|
|
1411
1409
|
}, z.core.$strip>>>>;
|
|
1412
|
-
discounts: z.
|
|
1410
|
+
discounts: z.ZodOptional<z.ZodNullable<z.ZodRecord<z.ZodUUID, z.ZodObject<{
|
|
1413
1411
|
createdAt: z.ZodReadonly<z.ZodISODateTime>;
|
|
1414
1412
|
lastModified: z.ZodOptional<z.ZodNullable<z.ZodISODateTime>>;
|
|
1415
1413
|
description: z.ZodString;
|
|
@@ -1422,7 +1420,7 @@ declare const MutableAppointmentDetails: z.ZodObject<{
|
|
|
1422
1420
|
percentage: z.ZodNumber;
|
|
1423
1421
|
isOptional: z.ZodBoolean;
|
|
1424
1422
|
}, z.core.$strip>>>>;
|
|
1425
|
-
prepayments: z.ZodNullable<z.
|
|
1423
|
+
prepayments: z.ZodOptional<z.ZodNullable<z.ZodRecord<z.ZodUUID, z.ZodObject<{
|
|
1426
1424
|
createdAt: z.ZodReadonly<z.ZodISODateTime>;
|
|
1427
1425
|
lastModified: z.ZodOptional<z.ZodNullable<z.ZodISODateTime>>;
|
|
1428
1426
|
description: z.ZodString;
|
|
@@ -1434,7 +1432,7 @@ declare const MutableAppointmentDetails: z.ZodObject<{
|
|
|
1434
1432
|
}, z.core.$strip>;
|
|
1435
1433
|
percentage: z.ZodNumber;
|
|
1436
1434
|
isOptional: z.ZodBoolean;
|
|
1437
|
-
}, z.core.$strip
|
|
1435
|
+
}, z.core.$strip>>>>;
|
|
1438
1436
|
payload: z.ZodOptional<z.ZodNullable<z.ZodObject<{
|
|
1439
1437
|
lastModified: z.ZodNullable<z.ZodNumber>;
|
|
1440
1438
|
vitals: z.ZodRecord<z.ZodEnum<{
|
|
@@ -1476,16 +1474,15 @@ declare const MutableAppointmentDetails: z.ZodObject<{
|
|
|
1476
1474
|
value: z.ZodString;
|
|
1477
1475
|
}, z.core.$strip>>;
|
|
1478
1476
|
invoiceNo: z.ZodOptional<z.ZodString>;
|
|
1479
|
-
charges: z.
|
|
1477
|
+
charges: z.ZodOptional<z.ZodNullable<z.ZodRecord<z.ZodUUID, z.ZodObject<{
|
|
1480
1478
|
createdAt: z.ZodReadonly<z.ZodISODateTime>;
|
|
1481
1479
|
lastModified: z.ZodOptional<z.ZodNullable<z.ZodISODateTime>>;
|
|
1482
|
-
uid: z.ZodUUID;
|
|
1483
|
-
item: z.ZodString;
|
|
1484
|
-
cost: z.ZodNumber;
|
|
1485
1480
|
currency: z.ZodEnum<{
|
|
1486
1481
|
JMD: "JMD";
|
|
1487
1482
|
}>;
|
|
1488
|
-
|
|
1483
|
+
item: z.ZodString;
|
|
1484
|
+
cost: z.ZodNumber;
|
|
1485
|
+
}, z.core.$strip>>>>;
|
|
1489
1486
|
cancelled: z.ZodOptional<z.ZodObject<{
|
|
1490
1487
|
doneAt: z.ZodISODateTime;
|
|
1491
1488
|
reason: z.ZodObject<{
|
|
@@ -1584,17 +1581,16 @@ declare const ScheduleAppointmentForm: z.ZodObject<{
|
|
|
1584
1581
|
lastModified: z.ZodOptional<z.ZodNullable<z.ZodISODateTime>>;
|
|
1585
1582
|
value: z.ZodString;
|
|
1586
1583
|
}, z.core.$strip>>;
|
|
1587
|
-
charges: z.ZodOptional<z.
|
|
1584
|
+
charges: z.ZodOptional<z.ZodOptional<z.ZodNullable<z.ZodRecord<z.ZodUUID, z.ZodObject<{
|
|
1588
1585
|
createdAt: z.ZodReadonly<z.ZodISODateTime>;
|
|
1589
1586
|
lastModified: z.ZodOptional<z.ZodNullable<z.ZodISODateTime>>;
|
|
1590
|
-
uid: z.ZodUUID;
|
|
1591
|
-
item: z.ZodString;
|
|
1592
|
-
cost: z.ZodNumber;
|
|
1593
1587
|
currency: z.ZodEnum<{
|
|
1594
1588
|
JMD: "JMD";
|
|
1595
1589
|
}>;
|
|
1596
|
-
|
|
1597
|
-
|
|
1590
|
+
item: z.ZodString;
|
|
1591
|
+
cost: z.ZodNumber;
|
|
1592
|
+
}, z.core.$strip>>>>>;
|
|
1593
|
+
prepayments: z.ZodOptional<z.ZodOptional<z.ZodNullable<z.ZodRecord<z.ZodUUID, z.ZodObject<{
|
|
1598
1594
|
createdAt: z.ZodReadonly<z.ZodISODateTime>;
|
|
1599
1595
|
lastModified: z.ZodOptional<z.ZodNullable<z.ZodISODateTime>>;
|
|
1600
1596
|
description: z.ZodString;
|
|
@@ -1606,7 +1602,7 @@ declare const ScheduleAppointmentForm: z.ZodObject<{
|
|
|
1606
1602
|
}, z.core.$strip>;
|
|
1607
1603
|
percentage: z.ZodNumber;
|
|
1608
1604
|
isOptional: z.ZodBoolean;
|
|
1609
|
-
}, z.core.$strip
|
|
1605
|
+
}, z.core.$strip>>>>>;
|
|
1610
1606
|
payments: z.ZodOptional<z.ZodOptional<z.ZodNullable<z.ZodArray<z.ZodObject<{
|
|
1611
1607
|
createdAt: z.ZodReadonly<z.ZodISODateTime>;
|
|
1612
1608
|
lastModified: z.ZodOptional<z.ZodNullable<z.ZodISODateTime>>;
|
|
@@ -1702,50 +1698,9 @@ declare function scheduleAppointment(request: RequestParameter): Promise<{
|
|
|
1702
1698
|
appointment: {
|
|
1703
1699
|
createdAt: string;
|
|
1704
1700
|
_id: string;
|
|
1705
|
-
additionalFees: readonly {
|
|
1706
|
-
createdAt: string;
|
|
1707
|
-
description: string;
|
|
1708
|
-
fixedAmount: {
|
|
1709
|
-
value: number;
|
|
1710
|
-
currency: "JMD";
|
|
1711
|
-
};
|
|
1712
|
-
percentage: number;
|
|
1713
|
-
isOptional: boolean;
|
|
1714
|
-
lastModified?: string | null | undefined;
|
|
1715
|
-
}[] | null;
|
|
1716
|
-
discounts: readonly {
|
|
1717
|
-
createdAt: string;
|
|
1718
|
-
description: string;
|
|
1719
|
-
fixedAmount: {
|
|
1720
|
-
value: number;
|
|
1721
|
-
currency: "JMD";
|
|
1722
|
-
};
|
|
1723
|
-
percentage: number;
|
|
1724
|
-
isOptional: boolean;
|
|
1725
|
-
lastModified?: string | null | undefined;
|
|
1726
|
-
}[] | null;
|
|
1727
|
-
prepayments: {
|
|
1728
|
-
createdAt: string;
|
|
1729
|
-
description: string;
|
|
1730
|
-
fixedAmount: {
|
|
1731
|
-
value: number;
|
|
1732
|
-
currency: "JMD";
|
|
1733
|
-
};
|
|
1734
|
-
percentage: number;
|
|
1735
|
-
isOptional: boolean;
|
|
1736
|
-
lastModified?: string | null | undefined;
|
|
1737
|
-
}[] | null;
|
|
1738
1701
|
src: string;
|
|
1739
1702
|
tkt: number;
|
|
1740
1703
|
category: number;
|
|
1741
|
-
charges: {
|
|
1742
|
-
createdAt: string;
|
|
1743
|
-
uid: string;
|
|
1744
|
-
item: string;
|
|
1745
|
-
cost: number;
|
|
1746
|
-
currency: "JMD";
|
|
1747
|
-
lastModified?: string | null | undefined;
|
|
1748
|
-
}[];
|
|
1749
1704
|
timeline: {
|
|
1750
1705
|
scheduler: {
|
|
1751
1706
|
userUid: string;
|
|
@@ -1803,6 +1758,39 @@ declare function scheduleAppointment(request: RequestParameter): Promise<{
|
|
|
1803
1758
|
};
|
|
1804
1759
|
_hash: string;
|
|
1805
1760
|
lastModified?: string | null | undefined;
|
|
1761
|
+
additionalFees?: Record<string, {
|
|
1762
|
+
createdAt: string;
|
|
1763
|
+
description: string;
|
|
1764
|
+
fixedAmount: {
|
|
1765
|
+
value: number;
|
|
1766
|
+
currency: "JMD";
|
|
1767
|
+
};
|
|
1768
|
+
percentage: number;
|
|
1769
|
+
isOptional: boolean;
|
|
1770
|
+
lastModified?: string | null | undefined;
|
|
1771
|
+
}> | null | undefined;
|
|
1772
|
+
discounts?: Record<string, {
|
|
1773
|
+
createdAt: string;
|
|
1774
|
+
description: string;
|
|
1775
|
+
fixedAmount: {
|
|
1776
|
+
value: number;
|
|
1777
|
+
currency: "JMD";
|
|
1778
|
+
};
|
|
1779
|
+
percentage: number;
|
|
1780
|
+
isOptional: boolean;
|
|
1781
|
+
lastModified?: string | null | undefined;
|
|
1782
|
+
}> | null | undefined;
|
|
1783
|
+
prepayments?: Record<string, {
|
|
1784
|
+
createdAt: string;
|
|
1785
|
+
description: string;
|
|
1786
|
+
fixedAmount: {
|
|
1787
|
+
value: number;
|
|
1788
|
+
currency: "JMD";
|
|
1789
|
+
};
|
|
1790
|
+
percentage: number;
|
|
1791
|
+
isOptional: boolean;
|
|
1792
|
+
lastModified?: string | null | undefined;
|
|
1793
|
+
}> | null | undefined;
|
|
1806
1794
|
payload?: {
|
|
1807
1795
|
lastModified: number | null;
|
|
1808
1796
|
vitals: Record<"heartRate" | "respiratoryRate" | "bloodPressure" | "bloodOxygen" | "bodyTemp", {
|
|
@@ -1835,6 +1823,13 @@ declare function scheduleAppointment(request: RequestParameter): Promise<{
|
|
|
1835
1823
|
lastModified?: string | null | undefined;
|
|
1836
1824
|
} | undefined;
|
|
1837
1825
|
invoiceNo?: string | undefined;
|
|
1826
|
+
charges?: Record<string, {
|
|
1827
|
+
createdAt: string;
|
|
1828
|
+
currency: "JMD";
|
|
1829
|
+
item: string;
|
|
1830
|
+
cost: number;
|
|
1831
|
+
lastModified?: string | null | undefined;
|
|
1832
|
+
}> | null | undefined;
|
|
1838
1833
|
cancelled?: {
|
|
1839
1834
|
doneAt: string;
|
|
1840
1835
|
reason: {
|
package/dist/main.js
CHANGED
|
@@ -774,13 +774,15 @@ var MedicalDetails = z20.object({
|
|
|
774
774
|
});
|
|
775
775
|
|
|
776
776
|
// src/schemas/appointment/Appointment.ts
|
|
777
|
-
import * as z21 from "zod";
|
|
778
777
|
import { sumOf as sumOf2 } from "@wavy/fn";
|
|
778
|
+
import * as z21 from "zod";
|
|
779
779
|
|
|
780
780
|
// src/functions/calcAppointmentFee.ts
|
|
781
781
|
import { sumOf } from "@wavy/fn";
|
|
782
782
|
function calcAppointmentFee(appointment) {
|
|
783
|
-
const subtotal = sumOf(
|
|
783
|
+
const subtotal = sumOf(
|
|
784
|
+
Object.values(appointment.charges || {})?.map((c) => c.cost)
|
|
785
|
+
);
|
|
784
786
|
const discount = calcAdjustment(appointment.discounts, subtotal);
|
|
785
787
|
const additionalFees = calcAdjustment(appointment.additionalFees, subtotal);
|
|
786
788
|
const prepayments = calcAdjustment(appointment.prepayments, subtotal);
|
|
@@ -788,9 +790,10 @@ function calcAppointmentFee(appointment) {
|
|
|
788
790
|
return subtotal + additionalFees - (discount + prepayments);
|
|
789
791
|
}
|
|
790
792
|
var calcAdjustment = (adjustments, subtotal) => {
|
|
791
|
-
|
|
793
|
+
const castedAdjustments = !adjustments ? [] : Object.values(adjustments);
|
|
794
|
+
if (!adjustments || castedAdjustments.length < 1) return 0;
|
|
792
795
|
return sumOf(
|
|
793
|
-
|
|
796
|
+
castedAdjustments?.map(
|
|
794
797
|
(d) => (d.fixedAmount?.value || 0) + (d.percentage ? d.percentage * 0.01 * subtotal : 0)
|
|
795
798
|
)
|
|
796
799
|
);
|
|
@@ -805,7 +808,6 @@ var MiniAppointmentDetails = z21.object({
|
|
|
805
808
|
/** A random uid that identifies the document. */
|
|
806
809
|
_id: z21.uuidv4(),
|
|
807
810
|
// This helps to identify the urgency of the appointment
|
|
808
|
-
// 3
|
|
809
811
|
category: z21.int().min(1).max(3),
|
|
810
812
|
/** The company's uid */
|
|
811
813
|
src: CompanyState.shape._id,
|
|
@@ -824,12 +826,15 @@ var MiniAppointmentDetails = z21.object({
|
|
|
824
826
|
*/
|
|
825
827
|
invoiceNo: InvoiceNo.optional(),
|
|
826
828
|
/** The services that the client has done/will do. */
|
|
827
|
-
charges:
|
|
829
|
+
charges: CompanyBilling.shape.offeredServices.nullish().refine(
|
|
830
|
+
(d) => !d || Object.keys(d).length <= 20,
|
|
831
|
+
"Expected no more than (20) charges."
|
|
832
|
+
),
|
|
828
833
|
/**Required to calculate the accurate grandTotal of the charges */
|
|
829
|
-
additionalFees:
|
|
834
|
+
additionalFees: CompanyBilling.shape.additionalFees.nullish(),
|
|
830
835
|
/**Required to calculate the accurate grandTotal of the charges */
|
|
831
|
-
discounts:
|
|
832
|
-
prepayments:
|
|
836
|
+
discounts: CompanyBilling.shape.discounts.nullish(),
|
|
837
|
+
prepayments: CompanyBilling.shape.prepayments.nullish(),
|
|
833
838
|
/** The client's identity */
|
|
834
839
|
clientUid: ClientIdentity.shape._id,
|
|
835
840
|
/**
|
|
@@ -959,6 +964,7 @@ async function scheduleAppointment(request) {
|
|
|
959
964
|
const companyUser = request.staff?.members[request.sender._id];
|
|
960
965
|
const staffDetailsCopy = CompanyStaff.parse(structuredClone(request.staff));
|
|
961
966
|
const stateCopy = CompanyState.parse(structuredClone(request.state));
|
|
967
|
+
const castedFormCharges = Object.values(request.form?.charges || {});
|
|
962
968
|
let selectedDoctor = null;
|
|
963
969
|
let selectedPhysAsst = null;
|
|
964
970
|
const availableDoctors = findAvailableStaff("doc", staffDetailsCopy);
|
|
@@ -996,9 +1002,9 @@ async function scheduleAppointment(request) {
|
|
|
996
1002
|
staffDetailsCopy
|
|
997
1003
|
);
|
|
998
1004
|
}
|
|
999
|
-
if (request.preferences.serviceSelector === "scheduler" && (!request.form.charges ||
|
|
1005
|
+
if (request.preferences.serviceSelector === "scheduler" && (!request.form.charges || castedFormCharges.length < 1)) {
|
|
1000
1006
|
throw new Error("Insufficient services selected.");
|
|
1001
|
-
} else if (request.preferences.serviceSelector === "scheduler" && request.billing.offeredServices.deployed &&
|
|
1007
|
+
} else if (request.preferences.serviceSelector === "scheduler" && request.billing.offeredServices.deployed && castedFormCharges.find(
|
|
1002
1008
|
(charge) => !!Object.values(request.billing.offeredServices).find(
|
|
1003
1009
|
(createdCharge) => findChanges(charge, createdCharge).length > 0
|
|
1004
1010
|
)
|
|
@@ -1009,7 +1015,7 @@ async function scheduleAppointment(request) {
|
|
|
1009
1015
|
throw new Error("Insufficient payment transactions recorded.");
|
|
1010
1016
|
} else if (request.preferences.enforcePaidAppointments) {
|
|
1011
1017
|
const maxIterations = Math.max(
|
|
1012
|
-
|
|
1018
|
+
castedFormCharges.length,
|
|
1013
1019
|
request.form.payments.length
|
|
1014
1020
|
);
|
|
1015
1021
|
let totalPaid = 0;
|
|
@@ -1043,15 +1049,19 @@ async function scheduleAppointment(request) {
|
|
|
1043
1049
|
src: stateCopy._id,
|
|
1044
1050
|
tkt: request.state.tktNoCounter,
|
|
1045
1051
|
category: request.form.category,
|
|
1046
|
-
discounts: Object.
|
|
1047
|
-
(
|
|
1052
|
+
discounts: Object.fromEntries(
|
|
1053
|
+
Object.entries(request.billing.discounts || {}).filter(
|
|
1054
|
+
([_, disc]) => !disc.isOptional
|
|
1055
|
+
)
|
|
1048
1056
|
),
|
|
1049
|
-
additionalFees: Object.
|
|
1050
|
-
(
|
|
1057
|
+
additionalFees: Object.fromEntries(
|
|
1058
|
+
Object.entries(request.billing.additionalFees || {}).filter(
|
|
1059
|
+
([_, fee]) => !fee.isOptional
|
|
1060
|
+
)
|
|
1051
1061
|
),
|
|
1052
1062
|
payments: request.preferences.enforcePaidAppointments ? request.form.payments : null,
|
|
1053
|
-
prepayments: request.preferences.enforcePaidAppointments ? request.form
|
|
1054
|
-
charges: request.preferences.serviceSelector === "scheduler" ? request.form
|
|
1063
|
+
prepayments: request.preferences.enforcePaidAppointments ? request.form?.prepayments ?? null : null,
|
|
1064
|
+
charges: request.preferences.serviceSelector === "scheduler" ? request.form?.charges ?? null : null,
|
|
1055
1065
|
client: await request.findClient(request.form.clientId),
|
|
1056
1066
|
_hash: "aa.aa.aa",
|
|
1057
1067
|
lastModified: null,
|