@bizmap/sdk 0.0.99 → 0.0.101

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.
Files changed (3) hide show
  1. package/dist/main.d.ts +136 -124
  2. package/dist/main.js +53 -36
  3. 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 PriceAdjustment: z.ZodObject<{
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 PriceAdjustment = z.infer<typeof PriceAdjustment>;
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>>;
@@ -1083,17 +1097,16 @@ declare const MiniAppointmentDetails: z.ZodObject<{
1083
1097
  value: z.ZodString;
1084
1098
  }, z.core.$strip>>;
1085
1099
  invoiceNo: z.ZodOptional<z.ZodString>;
1086
- charges: z.ZodArray<z.ZodObject<{
1100
+ charges: z.ZodOptional<z.ZodNullable<z.ZodRecord<z.ZodUUID, z.ZodObject<{
1087
1101
  createdAt: z.ZodReadonly<z.ZodISODateTime>;
1088
1102
  lastModified: z.ZodOptional<z.ZodNullable<z.ZodISODateTime>>;
1089
- uid: z.ZodUUID;
1090
- item: z.ZodString;
1091
- cost: z.ZodNumber;
1092
1103
  currency: z.ZodEnum<{
1093
1104
  JMD: "JMD";
1094
1105
  }>;
1095
- }, z.core.$strip>>;
1096
- additionalFees: z.ZodReadonly<z.ZodNullable<z.ZodArray<z.ZodObject<{
1106
+ item: z.ZodString;
1107
+ cost: z.ZodNumber;
1108
+ }, z.core.$strip>>>>;
1109
+ additionalFees: z.ZodOptional<z.ZodNullable<z.ZodRecord<z.ZodUUID, z.ZodObject<{
1097
1110
  createdAt: z.ZodReadonly<z.ZodISODateTime>;
1098
1111
  lastModified: z.ZodOptional<z.ZodNullable<z.ZodISODateTime>>;
1099
1112
  description: z.ZodString;
@@ -1106,7 +1119,7 @@ declare const MiniAppointmentDetails: z.ZodObject<{
1106
1119
  percentage: z.ZodNumber;
1107
1120
  isOptional: z.ZodBoolean;
1108
1121
  }, z.core.$strip>>>>;
1109
- discounts: z.ZodReadonly<z.ZodNullable<z.ZodArray<z.ZodObject<{
1122
+ discounts: z.ZodOptional<z.ZodNullable<z.ZodRecord<z.ZodUUID, z.ZodObject<{
1110
1123
  createdAt: z.ZodReadonly<z.ZodISODateTime>;
1111
1124
  lastModified: z.ZodOptional<z.ZodNullable<z.ZodISODateTime>>;
1112
1125
  description: z.ZodString;
@@ -1119,7 +1132,7 @@ declare const MiniAppointmentDetails: z.ZodObject<{
1119
1132
  percentage: z.ZodNumber;
1120
1133
  isOptional: z.ZodBoolean;
1121
1134
  }, z.core.$strip>>>>;
1122
- prepayments: z.ZodNullable<z.ZodArray<z.ZodObject<{
1135
+ prepayments: z.ZodOptional<z.ZodNullable<z.ZodRecord<z.ZodUUID, z.ZodObject<{
1123
1136
  createdAt: z.ZodReadonly<z.ZodISODateTime>;
1124
1137
  lastModified: z.ZodOptional<z.ZodNullable<z.ZodISODateTime>>;
1125
1138
  description: z.ZodString;
@@ -1131,7 +1144,21 @@ declare const MiniAppointmentDetails: z.ZodObject<{
1131
1144
  }, z.core.$strip>;
1132
1145
  percentage: z.ZodNumber;
1133
1146
  isOptional: z.ZodBoolean;
1134
- }, z.core.$strip>>>;
1147
+ }, z.core.$strip>>>>;
1148
+ payments: z.ZodOptional<z.ZodNullable<z.ZodArray<z.ZodObject<{
1149
+ createdAt: z.ZodReadonly<z.ZodISODateTime>;
1150
+ lastModified: z.ZodOptional<z.ZodNullable<z.ZodISODateTime>>;
1151
+ uid: z.ZodUUID;
1152
+ method: z.ZodEnum<{
1153
+ cash: "cash";
1154
+ card: "card";
1155
+ insurance: "insurance";
1156
+ }>;
1157
+ currency: z.ZodEnum<{
1158
+ JMD: "JMD";
1159
+ }>;
1160
+ amount: z.ZodNumber;
1161
+ }, z.core.$strip>>>>;
1135
1162
  clientUid: z.ZodUUID;
1136
1163
  payload: z.ZodOptional<z.ZodNullable<z.ZodObject<{
1137
1164
  lastModified: z.ZodNullable<z.ZodNumber>;
@@ -1176,20 +1203,6 @@ declare const MiniAppointmentDetails: z.ZodObject<{
1176
1203
  physAsst: "physAsst";
1177
1204
  }>;
1178
1205
  }, z.core.$strip>>;
1179
- payments: z.ZodOptional<z.ZodNullable<z.ZodArray<z.ZodObject<{
1180
- createdAt: z.ZodReadonly<z.ZodISODateTime>;
1181
- lastModified: z.ZodOptional<z.ZodNullable<z.ZodISODateTime>>;
1182
- uid: z.ZodUUID;
1183
- method: z.ZodEnum<{
1184
- cash: "cash";
1185
- card: "card";
1186
- insurance: "insurance";
1187
- }>;
1188
- currency: z.ZodEnum<{
1189
- JMD: "JMD";
1190
- }>;
1191
- amount: z.ZodNumber;
1192
- }, z.core.$strip>>>>;
1193
1206
  lockedBy: z.ZodOptional<z.ZodUUID>;
1194
1207
  timeline: z.ZodObject<{
1195
1208
  scheduler: z.ZodObject<{
@@ -1216,7 +1229,7 @@ declare const AppointmentDetails: z.ZodObject<{
1216
1229
  createdAt: z.ZodReadonly<z.ZodISODateTime>;
1217
1230
  lastModified: z.ZodOptional<z.ZodNullable<z.ZodISODateTime>>;
1218
1231
  _id: z.ZodUUID;
1219
- additionalFees: z.ZodReadonly<z.ZodNullable<z.ZodArray<z.ZodObject<{
1232
+ additionalFees: z.ZodOptional<z.ZodNullable<z.ZodRecord<z.ZodUUID, z.ZodObject<{
1220
1233
  createdAt: z.ZodReadonly<z.ZodISODateTime>;
1221
1234
  lastModified: z.ZodOptional<z.ZodNullable<z.ZodISODateTime>>;
1222
1235
  description: z.ZodString;
@@ -1229,7 +1242,7 @@ declare const AppointmentDetails: z.ZodObject<{
1229
1242
  percentage: z.ZodNumber;
1230
1243
  isOptional: z.ZodBoolean;
1231
1244
  }, z.core.$strip>>>>;
1232
- discounts: z.ZodReadonly<z.ZodNullable<z.ZodArray<z.ZodObject<{
1245
+ discounts: z.ZodOptional<z.ZodNullable<z.ZodRecord<z.ZodUUID, z.ZodObject<{
1233
1246
  createdAt: z.ZodReadonly<z.ZodISODateTime>;
1234
1247
  lastModified: z.ZodOptional<z.ZodNullable<z.ZodISODateTime>>;
1235
1248
  description: z.ZodString;
@@ -1242,7 +1255,7 @@ declare const AppointmentDetails: z.ZodObject<{
1242
1255
  percentage: z.ZodNumber;
1243
1256
  isOptional: z.ZodBoolean;
1244
1257
  }, z.core.$strip>>>>;
1245
- prepayments: z.ZodNullable<z.ZodArray<z.ZodObject<{
1258
+ prepayments: z.ZodOptional<z.ZodNullable<z.ZodRecord<z.ZodUUID, z.ZodObject<{
1246
1259
  createdAt: z.ZodReadonly<z.ZodISODateTime>;
1247
1260
  lastModified: z.ZodOptional<z.ZodNullable<z.ZodISODateTime>>;
1248
1261
  description: z.ZodString;
@@ -1254,7 +1267,7 @@ declare const AppointmentDetails: z.ZodObject<{
1254
1267
  }, z.core.$strip>;
1255
1268
  percentage: z.ZodNumber;
1256
1269
  isOptional: z.ZodBoolean;
1257
- }, z.core.$strip>>>;
1270
+ }, z.core.$strip>>>>;
1258
1271
  payload: z.ZodOptional<z.ZodNullable<z.ZodObject<{
1259
1272
  lastModified: z.ZodNullable<z.ZodNumber>;
1260
1273
  vitals: z.ZodRecord<z.ZodEnum<{
@@ -1296,27 +1309,15 @@ declare const AppointmentDetails: z.ZodObject<{
1296
1309
  value: z.ZodString;
1297
1310
  }, z.core.$strip>>;
1298
1311
  invoiceNo: z.ZodOptional<z.ZodString>;
1299
- charges: z.ZodArray<z.ZodObject<{
1312
+ charges: z.ZodOptional<z.ZodNullable<z.ZodRecord<z.ZodUUID, z.ZodObject<{
1300
1313
  createdAt: z.ZodReadonly<z.ZodISODateTime>;
1301
1314
  lastModified: z.ZodOptional<z.ZodNullable<z.ZodISODateTime>>;
1302
- uid: z.ZodUUID;
1303
- item: z.ZodString;
1304
- cost: z.ZodNumber;
1305
1315
  currency: z.ZodEnum<{
1306
1316
  JMD: "JMD";
1307
1317
  }>;
1308
- }, z.core.$strip>>;
1309
- cancelled: z.ZodOptional<z.ZodObject<{
1310
- doneAt: z.ZodISODateTime;
1311
- reason: z.ZodObject<{
1312
- value: z.ZodString;
1313
- lastModified: z.ZodISODateTime;
1314
- }, z.core.$strip>;
1315
- doneBy: z.ZodEnum<{
1316
- doc: "doc";
1317
- physAsst: "physAsst";
1318
- }>;
1319
- }, z.core.$strip>>;
1318
+ item: z.ZodString;
1319
+ cost: z.ZodNumber;
1320
+ }, z.core.$strip>>>>;
1320
1321
  payments: z.ZodOptional<z.ZodNullable<z.ZodArray<z.ZodObject<{
1321
1322
  createdAt: z.ZodReadonly<z.ZodISODateTime>;
1322
1323
  lastModified: z.ZodOptional<z.ZodNullable<z.ZodISODateTime>>;
@@ -1331,6 +1332,17 @@ declare const AppointmentDetails: z.ZodObject<{
1331
1332
  }>;
1332
1333
  amount: z.ZodNumber;
1333
1334
  }, z.core.$strip>>>>;
1335
+ cancelled: z.ZodOptional<z.ZodObject<{
1336
+ doneAt: z.ZodISODateTime;
1337
+ reason: z.ZodObject<{
1338
+ value: z.ZodString;
1339
+ lastModified: z.ZodISODateTime;
1340
+ }, z.core.$strip>;
1341
+ doneBy: z.ZodEnum<{
1342
+ doc: "doc";
1343
+ physAsst: "physAsst";
1344
+ }>;
1345
+ }, z.core.$strip>>;
1334
1346
  lockedBy: z.ZodOptional<z.ZodUUID>;
1335
1347
  timeline: z.ZodObject<{
1336
1348
  scheduler: z.ZodObject<{
@@ -1396,7 +1408,7 @@ declare const MutableAppointmentDetails: z.ZodObject<{
1396
1408
  createdAt: z.ZodReadonly<z.ZodISODateTime>;
1397
1409
  lastModified: z.ZodOptional<z.ZodNullable<z.ZodISODateTime>>;
1398
1410
  _id: z.ZodUUID;
1399
- additionalFees: z.ZodReadonly<z.ZodNullable<z.ZodArray<z.ZodObject<{
1411
+ additionalFees: z.ZodOptional<z.ZodNullable<z.ZodRecord<z.ZodUUID, z.ZodObject<{
1400
1412
  createdAt: z.ZodReadonly<z.ZodISODateTime>;
1401
1413
  lastModified: z.ZodOptional<z.ZodNullable<z.ZodISODateTime>>;
1402
1414
  description: z.ZodString;
@@ -1409,7 +1421,7 @@ declare const MutableAppointmentDetails: z.ZodObject<{
1409
1421
  percentage: z.ZodNumber;
1410
1422
  isOptional: z.ZodBoolean;
1411
1423
  }, z.core.$strip>>>>;
1412
- discounts: z.ZodReadonly<z.ZodNullable<z.ZodArray<z.ZodObject<{
1424
+ discounts: z.ZodOptional<z.ZodNullable<z.ZodRecord<z.ZodUUID, z.ZodObject<{
1413
1425
  createdAt: z.ZodReadonly<z.ZodISODateTime>;
1414
1426
  lastModified: z.ZodOptional<z.ZodNullable<z.ZodISODateTime>>;
1415
1427
  description: z.ZodString;
@@ -1422,7 +1434,7 @@ declare const MutableAppointmentDetails: z.ZodObject<{
1422
1434
  percentage: z.ZodNumber;
1423
1435
  isOptional: z.ZodBoolean;
1424
1436
  }, z.core.$strip>>>>;
1425
- prepayments: z.ZodNullable<z.ZodArray<z.ZodObject<{
1437
+ prepayments: z.ZodOptional<z.ZodNullable<z.ZodRecord<z.ZodUUID, z.ZodObject<{
1426
1438
  createdAt: z.ZodReadonly<z.ZodISODateTime>;
1427
1439
  lastModified: z.ZodOptional<z.ZodNullable<z.ZodISODateTime>>;
1428
1440
  description: z.ZodString;
@@ -1434,7 +1446,7 @@ declare const MutableAppointmentDetails: z.ZodObject<{
1434
1446
  }, z.core.$strip>;
1435
1447
  percentage: z.ZodNumber;
1436
1448
  isOptional: z.ZodBoolean;
1437
- }, z.core.$strip>>>;
1449
+ }, z.core.$strip>>>>;
1438
1450
  payload: z.ZodOptional<z.ZodNullable<z.ZodObject<{
1439
1451
  lastModified: z.ZodNullable<z.ZodNumber>;
1440
1452
  vitals: z.ZodRecord<z.ZodEnum<{
@@ -1476,27 +1488,15 @@ declare const MutableAppointmentDetails: z.ZodObject<{
1476
1488
  value: z.ZodString;
1477
1489
  }, z.core.$strip>>;
1478
1490
  invoiceNo: z.ZodOptional<z.ZodString>;
1479
- charges: z.ZodArray<z.ZodObject<{
1491
+ charges: z.ZodOptional<z.ZodNullable<z.ZodRecord<z.ZodUUID, z.ZodObject<{
1480
1492
  createdAt: z.ZodReadonly<z.ZodISODateTime>;
1481
1493
  lastModified: z.ZodOptional<z.ZodNullable<z.ZodISODateTime>>;
1482
- uid: z.ZodUUID;
1483
- item: z.ZodString;
1484
- cost: z.ZodNumber;
1485
1494
  currency: z.ZodEnum<{
1486
1495
  JMD: "JMD";
1487
1496
  }>;
1488
- }, z.core.$strip>>;
1489
- cancelled: z.ZodOptional<z.ZodObject<{
1490
- doneAt: z.ZodISODateTime;
1491
- reason: z.ZodObject<{
1492
- value: z.ZodString;
1493
- lastModified: z.ZodISODateTime;
1494
- }, z.core.$strip>;
1495
- doneBy: z.ZodEnum<{
1496
- doc: "doc";
1497
- physAsst: "physAsst";
1498
- }>;
1499
- }, z.core.$strip>>;
1497
+ item: z.ZodString;
1498
+ cost: z.ZodNumber;
1499
+ }, z.core.$strip>>>>;
1500
1500
  payments: z.ZodOptional<z.ZodNullable<z.ZodArray<z.ZodObject<{
1501
1501
  createdAt: z.ZodReadonly<z.ZodISODateTime>;
1502
1502
  lastModified: z.ZodOptional<z.ZodNullable<z.ZodISODateTime>>;
@@ -1511,6 +1511,17 @@ declare const MutableAppointmentDetails: z.ZodObject<{
1511
1511
  }>;
1512
1512
  amount: z.ZodNumber;
1513
1513
  }, z.core.$strip>>>>;
1514
+ cancelled: z.ZodOptional<z.ZodObject<{
1515
+ doneAt: z.ZodISODateTime;
1516
+ reason: z.ZodObject<{
1517
+ value: z.ZodString;
1518
+ lastModified: z.ZodISODateTime;
1519
+ }, z.core.$strip>;
1520
+ doneBy: z.ZodEnum<{
1521
+ doc: "doc";
1522
+ physAsst: "physAsst";
1523
+ }>;
1524
+ }, z.core.$strip>>;
1514
1525
  lockedBy: z.ZodOptional<z.ZodUUID>;
1515
1526
  timeline: z.ZodObject<{
1516
1527
  scheduler: z.ZodObject<{
@@ -1584,17 +1595,16 @@ declare const ScheduleAppointmentForm: z.ZodObject<{
1584
1595
  lastModified: z.ZodOptional<z.ZodNullable<z.ZodISODateTime>>;
1585
1596
  value: z.ZodString;
1586
1597
  }, z.core.$strip>>;
1587
- charges: z.ZodOptional<z.ZodArray<z.ZodObject<{
1598
+ charges: z.ZodOptional<z.ZodOptional<z.ZodNullable<z.ZodRecord<z.ZodUUID, z.ZodObject<{
1588
1599
  createdAt: z.ZodReadonly<z.ZodISODateTime>;
1589
1600
  lastModified: z.ZodOptional<z.ZodNullable<z.ZodISODateTime>>;
1590
- uid: z.ZodUUID;
1591
- item: z.ZodString;
1592
- cost: z.ZodNumber;
1593
1601
  currency: z.ZodEnum<{
1594
1602
  JMD: "JMD";
1595
1603
  }>;
1596
- }, z.core.$strip>>>;
1597
- prepayments: z.ZodOptional<z.ZodNullable<z.ZodArray<z.ZodObject<{
1604
+ item: z.ZodString;
1605
+ cost: z.ZodNumber;
1606
+ }, z.core.$strip>>>>>;
1607
+ prepayments: z.ZodOptional<z.ZodOptional<z.ZodNullable<z.ZodRecord<z.ZodUUID, z.ZodObject<{
1598
1608
  createdAt: z.ZodReadonly<z.ZodISODateTime>;
1599
1609
  lastModified: z.ZodOptional<z.ZodNullable<z.ZodISODateTime>>;
1600
1610
  description: z.ZodString;
@@ -1606,7 +1616,7 @@ declare const ScheduleAppointmentForm: z.ZodObject<{
1606
1616
  }, z.core.$strip>;
1607
1617
  percentage: z.ZodNumber;
1608
1618
  isOptional: z.ZodBoolean;
1609
- }, z.core.$strip>>>>;
1619
+ }, z.core.$strip>>>>>;
1610
1620
  payments: z.ZodOptional<z.ZodOptional<z.ZodNullable<z.ZodArray<z.ZodObject<{
1611
1621
  createdAt: z.ZodReadonly<z.ZodISODateTime>;
1612
1622
  lastModified: z.ZodOptional<z.ZodNullable<z.ZodISODateTime>>;
@@ -1702,50 +1712,9 @@ declare function scheduleAppointment(request: RequestParameter): Promise<{
1702
1712
  appointment: {
1703
1713
  createdAt: string;
1704
1714
  _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
1715
  src: string;
1739
1716
  tkt: number;
1740
1717
  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
1718
  timeline: {
1750
1719
  scheduler: {
1751
1720
  userUid: string;
@@ -1803,6 +1772,39 @@ declare function scheduleAppointment(request: RequestParameter): Promise<{
1803
1772
  };
1804
1773
  _hash: string;
1805
1774
  lastModified?: string | null | undefined;
1775
+ additionalFees?: Record<string, {
1776
+ createdAt: string;
1777
+ description: string;
1778
+ fixedAmount: {
1779
+ value: number;
1780
+ currency: "JMD";
1781
+ };
1782
+ percentage: number;
1783
+ isOptional: boolean;
1784
+ lastModified?: string | null | undefined;
1785
+ }> | null | undefined;
1786
+ discounts?: Record<string, {
1787
+ createdAt: string;
1788
+ description: string;
1789
+ fixedAmount: {
1790
+ value: number;
1791
+ currency: "JMD";
1792
+ };
1793
+ percentage: number;
1794
+ isOptional: boolean;
1795
+ lastModified?: string | null | undefined;
1796
+ }> | null | undefined;
1797
+ prepayments?: Record<string, {
1798
+ createdAt: string;
1799
+ description: string;
1800
+ fixedAmount: {
1801
+ value: number;
1802
+ currency: "JMD";
1803
+ };
1804
+ percentage: number;
1805
+ isOptional: boolean;
1806
+ lastModified?: string | null | undefined;
1807
+ }> | null | undefined;
1806
1808
  payload?: {
1807
1809
  lastModified: number | null;
1808
1810
  vitals: Record<"heartRate" | "respiratoryRate" | "bloodPressure" | "bloodOxygen" | "bodyTemp", {
@@ -1835,14 +1837,13 @@ declare function scheduleAppointment(request: RequestParameter): Promise<{
1835
1837
  lastModified?: string | null | undefined;
1836
1838
  } | undefined;
1837
1839
  invoiceNo?: string | undefined;
1838
- cancelled?: {
1839
- doneAt: string;
1840
- reason: {
1841
- value: string;
1842
- lastModified: string;
1843
- };
1844
- doneBy: "doc" | "physAsst";
1845
- } | undefined;
1840
+ charges?: Record<string, {
1841
+ createdAt: string;
1842
+ currency: "JMD";
1843
+ item: string;
1844
+ cost: number;
1845
+ lastModified?: string | null | undefined;
1846
+ }> | null | undefined;
1846
1847
  payments?: {
1847
1848
  createdAt: string;
1848
1849
  uid: string;
@@ -1851,12 +1852,23 @@ declare function scheduleAppointment(request: RequestParameter): Promise<{
1851
1852
  amount: number;
1852
1853
  lastModified?: string | null | undefined;
1853
1854
  }[] | null | undefined;
1855
+ cancelled?: {
1856
+ doneAt: string;
1857
+ reason: {
1858
+ value: string;
1859
+ lastModified: string;
1860
+ };
1861
+ doneBy: "doc" | "physAsst";
1862
+ } | undefined;
1854
1863
  lockedBy?: string | undefined;
1855
1864
  };
1856
1865
  }>;
1857
1866
 
1858
1867
  /** @disclaimer This doesn't handle currency conversion */
1859
- declare function calcAppointmentFee(appointment: Pick<AppointmentDetails, "charges" | "discounts" | "additionalFees" | "prepayments">): number;
1868
+ declare function calcBalance(components: Prettify<Partial<Pick<AppointmentDetails, "charges" | "discounts" | "additionalFees" | "prepayments" | "payments">>>, options?: {
1869
+ logger?: boolean;
1870
+ }): number;
1871
+ declare const calcPriceMod: (mods: PriceModList | null | undefined, subtotal: number) => number;
1860
1872
 
1861
1873
  /**
1862
1874
  * @param {CompanyUserRole} role The role used to filter the staff members
@@ -1919,4 +1931,4 @@ declare function createNotifId(options?: {
1919
1931
  to: string;
1920
1932
  }): string;
1921
1933
 
1922
- 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, PriceAdjustment, PriceTag, Reason, Receipts, ScheduleAppointmentForm, StandardTime, TicketNo, type Tier, TierList, TimeLog, Timestamp, Trn, UserDetails, Version, Vitals, acceptedCurrencies, adminRoles, appointmentDistAlgs, calcAppointmentFee, companyPartnerRoles, companyServiceSelectors, companyUserRoles, companyUserStatus, createNotifId, employeeRoles, findAvailableStaff, findConflictingPartners, findNextAvailableStaff, genders, getCompatibleRoles, healthcareProviderRoles, industries, normalizeCompanyId, normalizeNidKey, parseClientName, paymentMethods, scheduleAppointment, serviceProviders, tiers, vitalKeys };
1934
+ 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, 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 PriceAdjustment = z6.object({
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 createAdjustments = (resource) => z8.record(z8.uuidv4(), PriceAdjustment).refine(
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: createAdjustments("additional fee"),
188
- discounts: createAdjustments("discount"),
188
+ additionalFees: createMod("additional fee"),
189
+ discounts: createMod("discount"),
189
190
  /** Optionally deductable from bills */
190
- prepayments: createAdjustments("pre-payment"),
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) {
@@ -774,23 +775,30 @@ var MedicalDetails = z20.object({
774
775
  });
775
776
 
776
777
  // src/schemas/appointment/Appointment.ts
777
- import * as z21 from "zod";
778
778
  import { sumOf as sumOf2 } from "@wavy/fn";
779
+ import * as z21 from "zod";
779
780
 
780
- // src/functions/calcAppointmentFee.ts
781
+ // src/functions/calculations.ts
781
782
  import { sumOf } from "@wavy/fn";
782
- function calcAppointmentFee(appointment) {
783
- const subtotal = sumOf(appointment.charges?.map((c) => c.cost));
784
- const discount = calcAdjustment(appointment.discounts, subtotal);
785
- const additionalFees = calcAdjustment(appointment.additionalFees, subtotal);
786
- const prepayments = calcAdjustment(appointment.prepayments, subtotal);
787
- console.log({ subtotal, discount, additionalFees, prepayments });
788
- return subtotal + additionalFees - (discount + prepayments);
783
+ function calcBalance(components, options) {
784
+ const subtotal = sumOf(
785
+ Object.values(components.charges || {})?.map((c) => c.cost)
786
+ );
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;
789
796
  }
790
- var calcAdjustment = (adjustments, subtotal) => {
791
- if (!adjustments || adjustments.length < 1) return 0;
797
+ var calcPriceMod = (mods, subtotal) => {
798
+ const castedAdjustments = !mods ? [] : Object.values(mods);
799
+ if (!mods || castedAdjustments.length < 1) return 0;
792
800
  return sumOf(
793
- adjustments?.map(
801
+ castedAdjustments?.map(
794
802
  (d) => (d.fixedAmount?.value || 0) + (d.percentage ? d.percentage * 0.01 * subtotal : 0)
795
803
  )
796
804
  );
@@ -805,7 +813,6 @@ var MiniAppointmentDetails = z21.object({
805
813
  /** A random uid that identifies the document. */
806
814
  _id: z21.uuidv4(),
807
815
  // This helps to identify the urgency of the appointment
808
- // 3
809
816
  category: z21.int().min(1).max(3),
810
817
  /** The company's uid */
811
818
  src: CompanyState.shape._id,
@@ -824,12 +831,16 @@ var MiniAppointmentDetails = z21.object({
824
831
  */
825
832
  invoiceNo: InvoiceNo.optional(),
826
833
  /** The services that the client has done/will do. */
827
- charges: z21.array(PriceTag).max(20),
834
+ charges: CompanyBilling.shape.offeredServices.nullish().refine(
835
+ (d) => !d || Object.keys(d).length <= 20,
836
+ "Expected no more than (20) charges."
837
+ ),
828
838
  /**Required to calculate the accurate grandTotal of the charges */
829
- additionalFees: z21.array(PriceAdjustment).nullable().readonly(),
839
+ additionalFees: CompanyBilling.shape.additionalFees.nullish(),
830
840
  /**Required to calculate the accurate grandTotal of the charges */
831
- discounts: z21.array(PriceAdjustment).nullable().readonly(),
832
- prepayments: z21.array(PriceAdjustment).nullable(),
841
+ discounts: CompanyBilling.shape.discounts.nullish(),
842
+ prepayments: CompanyBilling.shape.prepayments.nullish(),
843
+ payments: z21.array(PaymentDetails).max(100).nullish(),
833
844
  /** The client's identity */
834
845
  clientUid: ClientIdentity.shape._id,
835
846
  /**
@@ -847,9 +858,8 @@ var MiniAppointmentDetails = z21.object({
847
858
  reason: Reason,
848
859
  doneBy: companyUserRoles.extract(["doc", "physAsst"])
849
860
  }).optional(),
850
- /** Add this after consulting with company owners about payment expectations */
861
+ //** Add this after consulting with company owners about payment expectations */
851
862
  // paymentDueDate: Timestamp.nullish(),
852
- payments: z21.array(PaymentDetails).max(100).nullish(),
853
863
  // The user that is currently modifying the appointment
854
864
  lockedBy: UserDetails.shape._id.optional(),
855
865
  timeline: z21.object({
@@ -867,7 +877,7 @@ var MiniAppointmentDetails = z21.object({
867
877
  }),
868
878
  ...TimeLog.shape
869
879
  }).superRefine((data, ctx) => {
870
- if (data.payments && data.charges && sumOf2(data.payments.map((p) => p.amount)) >= calcAppointmentFee(data)) {
880
+ if (data.payments && data.charges && sumOf2(data.payments.map((p) => p.amount)) >= calcBalance(data)) {
871
881
  const untrackedPayment = data.payments.find(
872
882
  (p) => !data.timeline.debtCollector?.some(
873
883
  (d) => p.uid in d.collectedPayments
@@ -959,6 +969,7 @@ async function scheduleAppointment(request) {
959
969
  const companyUser = request.staff?.members[request.sender._id];
960
970
  const staffDetailsCopy = CompanyStaff.parse(structuredClone(request.staff));
961
971
  const stateCopy = CompanyState.parse(structuredClone(request.state));
972
+ const castedFormCharges = Object.values(request.form?.charges || {});
962
973
  let selectedDoctor = null;
963
974
  let selectedPhysAsst = null;
964
975
  const availableDoctors = findAvailableStaff("doc", staffDetailsCopy);
@@ -996,9 +1007,9 @@ async function scheduleAppointment(request) {
996
1007
  staffDetailsCopy
997
1008
  );
998
1009
  }
999
- if (request.preferences.serviceSelector === "scheduler" && (!request.form.charges || request.form.charges.length < 1)) {
1010
+ if (request.preferences.serviceSelector === "scheduler" && (!request.form.charges || castedFormCharges.length < 1)) {
1000
1011
  throw new Error("Insufficient services selected.");
1001
- } else if (request.preferences.serviceSelector === "scheduler" && request.billing.offeredServices.deployed && request.form.charges.find(
1012
+ } else if (request.preferences.serviceSelector === "scheduler" && request.billing.offeredServices.deployed && castedFormCharges.find(
1002
1013
  (charge) => !!Object.values(request.billing.offeredServices).find(
1003
1014
  (createdCharge) => findChanges(charge, createdCharge).length > 0
1004
1015
  )
@@ -1009,7 +1020,7 @@ async function scheduleAppointment(request) {
1009
1020
  throw new Error("Insufficient payment transactions recorded.");
1010
1021
  } else if (request.preferences.enforcePaidAppointments) {
1011
1022
  const maxIterations = Math.max(
1012
- request.form.charges.length,
1023
+ castedFormCharges.length,
1013
1024
  request.form.payments.length
1014
1025
  );
1015
1026
  let totalPaid = 0;
@@ -1043,15 +1054,19 @@ async function scheduleAppointment(request) {
1043
1054
  src: stateCopy._id,
1044
1055
  tkt: request.state.tktNoCounter,
1045
1056
  category: request.form.category,
1046
- discounts: Object.values(request.billing.discounts || {}).filter(
1047
- (disc) => !disc.isOptional
1057
+ discounts: Object.fromEntries(
1058
+ Object.entries(request.billing.discounts || {}).filter(
1059
+ ([_, disc]) => !disc.isOptional
1060
+ )
1048
1061
  ),
1049
- additionalFees: Object.values(request.billing.additionalFees || {}).filter(
1050
- (fee) => !fee.isOptional
1062
+ additionalFees: Object.fromEntries(
1063
+ Object.entries(request.billing.additionalFees || {}).filter(
1064
+ ([_, fee]) => !fee.isOptional
1065
+ )
1051
1066
  ),
1052
1067
  payments: request.preferences.enforcePaidAppointments ? request.form.payments : null,
1053
- prepayments: request.preferences.enforcePaidAppointments ? request.form.prepayments || [] : null,
1054
- charges: request.preferences.serviceSelector === "scheduler" ? request.form.charges : [],
1068
+ prepayments: request.preferences.enforcePaidAppointments ? request.form?.prepayments ?? null : null,
1069
+ charges: request.preferences.serviceSelector === "scheduler" ? request.form?.charges ?? null : null,
1055
1070
  client: await request.findClient(request.form.clientId),
1056
1071
  _hash: "aa.aa.aa",
1057
1072
  lastModified: null,
@@ -1123,7 +1138,8 @@ export {
1123
1138
  MutableCompanyPreferences,
1124
1139
  Notification,
1125
1140
  PaymentDetails,
1126
- PriceAdjustment,
1141
+ PriceMod,
1142
+ PriceModList,
1127
1143
  PriceTag,
1128
1144
  Reason,
1129
1145
  Receipts,
@@ -1140,7 +1156,8 @@ export {
1140
1156
  acceptedCurrencies,
1141
1157
  adminRoles,
1142
1158
  appointmentDistAlgs,
1143
- calcAppointmentFee,
1159
+ calcBalance,
1160
+ calcPriceMod,
1144
1161
  companyPartnerRoles,
1145
1162
  companyServiceSelectors,
1146
1163
  companyUserRoles,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bizmap/sdk",
3
- "version": "0.0.99",
3
+ "version": "0.0.101",
4
4
  "main": "./dist/main.js",
5
5
  "types": "./dist/main.d.ts",
6
6
  "type": "module",