@primocaredentgroup/compensi-medici-core 0.1.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.
Files changed (38) hide show
  1. package/convex/_generated/api.ts +110 -0
  2. package/convex/_generated/component.ts +1356 -0
  3. package/convex/_generated/dataModel.ts +60 -0
  4. package/convex/_generated/server.ts +156 -0
  5. package/convex/audit/logs.ts +69 -0
  6. package/convex/calculation/commissions.ts +497 -0
  7. package/convex/calculation/deductions.ts +119 -0
  8. package/convex/calculation/engine.ts +598 -0
  9. package/convex/calculation/fixedCommissions.ts +217 -0
  10. package/convex/calculation/orchestrator.ts +314 -0
  11. package/convex/calculation/production.ts +495 -0
  12. package/convex/calculation/productionData.ts +155 -0
  13. package/convex/calculation/ruleApplications.ts +121 -0
  14. package/convex/config/categories.ts +114 -0
  15. package/convex/config/commissionPlans.ts +166 -0
  16. package/convex/config/commissionRules.ts +154 -0
  17. package/convex/config/companyMappings.ts +77 -0
  18. package/convex/config/deductionRules.ts +113 -0
  19. package/convex/config/fixedCommissionTypes.ts +79 -0
  20. package/convex/config/globalSettings.ts +79 -0
  21. package/convex/config/invisalignConfig.ts +87 -0
  22. package/convex/config/planTemplates.ts +90 -0
  23. package/convex/config/taxProfiles.ts +122 -0
  24. package/convex/config/userTaxProfiles.ts +87 -0
  25. package/convex/convex.config.ts +3 -0
  26. package/convex/documents/draftInvoices.ts +164 -0
  27. package/convex/documents/invoiceEngine.ts +468 -0
  28. package/convex/documents/invoiceGeneration.ts +611 -0
  29. package/convex/documents/statements.ts +185 -0
  30. package/convex/ledger/entries.ts +314 -0
  31. package/convex/lib/types.ts +126 -0
  32. package/convex/schema.ts +611 -0
  33. package/convex/seedHelpers.ts +41 -0
  34. package/convex/workflow/pendingCompletions.ts +148 -0
  35. package/convex/workflow/pythonWorker.ts +190 -0
  36. package/convex/workflow/runIssues.ts +364 -0
  37. package/convex/workflow/runs.ts +718 -0
  38. package/package.json +43 -0
@@ -0,0 +1,1356 @@
1
+ /* eslint-disable */
2
+ /**
3
+ * Generated `ComponentApi` utility.
4
+ *
5
+ * THIS CODE IS AUTOMATICALLY GENERATED.
6
+ *
7
+ * To regenerate, run `npx convex dev`.
8
+ * @module
9
+ */
10
+
11
+ import type { FunctionReference } from "convex/server";
12
+
13
+ /**
14
+ * A utility for referencing a Convex component's exposed API.
15
+ *
16
+ * Useful when expecting a parameter like `components.myComponent`.
17
+ * Usage:
18
+ * ```ts
19
+ * async function myFunction(ctx: QueryCtx, component: ComponentApi) {
20
+ * return ctx.runQuery(component.someFile.someQuery, { ...args });
21
+ * }
22
+ * ```
23
+ */
24
+ export type ComponentApi<Name extends string | undefined = string | undefined> =
25
+ {
26
+ audit: {
27
+ logs: {
28
+ listByAction: FunctionReference<
29
+ "query",
30
+ "internal",
31
+ { action: string },
32
+ any,
33
+ Name
34
+ >;
35
+ listByEntity: FunctionReference<
36
+ "query",
37
+ "internal",
38
+ { entityId: string; entityType: string },
39
+ any,
40
+ Name
41
+ >;
42
+ listByUser: FunctionReference<
43
+ "query",
44
+ "internal",
45
+ { userId: string },
46
+ any,
47
+ Name
48
+ >;
49
+ write: FunctionReference<
50
+ "mutation",
51
+ "internal",
52
+ {
53
+ action: string;
54
+ entityId: string;
55
+ entityType: string;
56
+ payload?: any;
57
+ userId: string;
58
+ },
59
+ any,
60
+ Name
61
+ >;
62
+ };
63
+ };
64
+ calculation: {
65
+ commissions: {
66
+ clearCommissionEntries: FunctionReference<
67
+ "mutation",
68
+ "internal",
69
+ { runId: string; userId: string },
70
+ any,
71
+ Name
72
+ >;
73
+ getCommissionsForSourceEntry: FunctionReference<
74
+ "query",
75
+ "internal",
76
+ { sourceLedgerEntryId: string },
77
+ any,
78
+ Name
79
+ >;
80
+ getCommissionSummary: FunctionReference<
81
+ "query",
82
+ "internal",
83
+ { runId: string },
84
+ any,
85
+ Name
86
+ >;
87
+ getCommissionSummaryByUser: FunctionReference<
88
+ "query",
89
+ "internal",
90
+ { runId: string; userId: string },
91
+ any,
92
+ Name
93
+ >;
94
+ listCommissionEntries: FunctionReference<
95
+ "query",
96
+ "internal",
97
+ { runId: string },
98
+ any,
99
+ Name
100
+ >;
101
+ listCommissionEntriesByUser: FunctionReference<
102
+ "query",
103
+ "internal",
104
+ { runId: string; userId: string },
105
+ any,
106
+ Name
107
+ >;
108
+ listUnmatchedProductionEntries: FunctionReference<
109
+ "query",
110
+ "internal",
111
+ { runId: string },
112
+ any,
113
+ Name
114
+ >;
115
+ refreshCommissions: FunctionReference<
116
+ "mutation",
117
+ "internal",
118
+ { runId: string; userId: string },
119
+ any,
120
+ Name
121
+ >;
122
+ };
123
+ orchestrator: {
124
+ executeFullCalculation: FunctionReference<
125
+ "action",
126
+ "internal",
127
+ {
128
+ fixedCommissionRules?: Array<{
129
+ amount: number;
130
+ behavior: string;
131
+ clinicId: string;
132
+ multipliedByWdays: boolean;
133
+ typeId: string;
134
+ userId: string;
135
+ }>;
136
+ ignoreAllRulesUserIds?: Array<string>;
137
+ runId: string;
138
+ userId: string;
139
+ workingDays?: Array<{
140
+ clinicId: string;
141
+ days: number;
142
+ userId: string;
143
+ }>;
144
+ },
145
+ any,
146
+ Name
147
+ >;
148
+ fetchAndIngestProduction: FunctionReference<
149
+ "action",
150
+ "internal",
151
+ { runId: string; userId: string },
152
+ any,
153
+ Name
154
+ >;
155
+ };
156
+ production: {
157
+ clearProductionEntries: FunctionReference<
158
+ "mutation",
159
+ "internal",
160
+ { runId: string; userId: string },
161
+ any,
162
+ Name
163
+ >;
164
+ getProductionByUserSummary: FunctionReference<
165
+ "query",
166
+ "internal",
167
+ { runId: string },
168
+ any,
169
+ Name
170
+ >;
171
+ getProductionSummary: FunctionReference<
172
+ "query",
173
+ "internal",
174
+ { runId: string },
175
+ any,
176
+ Name
177
+ >;
178
+ getProductionSummaryByUser: FunctionReference<
179
+ "query",
180
+ "internal",
181
+ { runId: string; userId: string },
182
+ any,
183
+ Name
184
+ >;
185
+ ingestProductionData: FunctionReference<
186
+ "mutation",
187
+ "internal",
188
+ {
189
+ runId: string;
190
+ sourceRecords: Array<{
191
+ amount: number;
192
+ carePlanRowId: string;
193
+ category?: string;
194
+ clinicId: string;
195
+ conventionId?: string;
196
+ isStorno: boolean;
197
+ metadata?: any;
198
+ originalCarePlanRowId?: string;
199
+ performedAt: number;
200
+ period: string;
201
+ subcategory?: string;
202
+ userId: string;
203
+ }>;
204
+ userId: string;
205
+ },
206
+ any,
207
+ Name
208
+ >;
209
+ listProductionEntries: FunctionReference<
210
+ "query",
211
+ "internal",
212
+ { runId: string },
213
+ any,
214
+ Name
215
+ >;
216
+ listProductionEntriesByUser: FunctionReference<
217
+ "query",
218
+ "internal",
219
+ { runId: string; userId: string },
220
+ any,
221
+ Name
222
+ >;
223
+ refreshProduction: FunctionReference<
224
+ "mutation",
225
+ "internal",
226
+ {
227
+ runId: string;
228
+ sourceRecords: Array<{
229
+ amount: number;
230
+ carePlanRowId: string;
231
+ category?: string;
232
+ clinicId: string;
233
+ conventionId?: string;
234
+ isStorno: boolean;
235
+ metadata?: any;
236
+ originalCarePlanRowId?: string;
237
+ performedAt: number;
238
+ period: string;
239
+ subcategory?: string;
240
+ userId: string;
241
+ }>;
242
+ userId: string;
243
+ },
244
+ any,
245
+ Name
246
+ >;
247
+ };
248
+ ruleApplications: {
249
+ create: FunctionReference<
250
+ "mutation",
251
+ "internal",
252
+ {
253
+ explanationLabel: string;
254
+ formulaInput: any;
255
+ formulaOutput: any;
256
+ formulaSnapshot: any;
257
+ generatedLedgerEntryId: string;
258
+ matchedConditions: any;
259
+ planId: string;
260
+ resultAmount: number;
261
+ ruleId: string;
262
+ runId: string;
263
+ sourceLedgerEntryId: string;
264
+ },
265
+ any,
266
+ Name
267
+ >;
268
+ deleteByRun: FunctionReference<
269
+ "mutation",
270
+ "internal",
271
+ { runId: string },
272
+ any,
273
+ Name
274
+ >;
275
+ listByGeneratedEntry: FunctionReference<
276
+ "query",
277
+ "internal",
278
+ { generatedLedgerEntryId: string },
279
+ any,
280
+ Name
281
+ >;
282
+ listByRun: FunctionReference<
283
+ "query",
284
+ "internal",
285
+ { runId: string },
286
+ any,
287
+ Name
288
+ >;
289
+ listByRunAndRule: FunctionReference<
290
+ "query",
291
+ "internal",
292
+ { ruleId: string; runId: string },
293
+ any,
294
+ Name
295
+ >;
296
+ listBySourceEntry: FunctionReference<
297
+ "query",
298
+ "internal",
299
+ { sourceLedgerEntryId: string },
300
+ any,
301
+ Name
302
+ >;
303
+ };
304
+ };
305
+ config: {
306
+ categories: {
307
+ createAdjustmentCategory: FunctionReference<
308
+ "mutation",
309
+ "internal",
310
+ {
311
+ code: string;
312
+ description?: string;
313
+ label: string;
314
+ sortOrder: number;
315
+ },
316
+ any,
317
+ Name
318
+ >;
319
+ createReimbursementCategory: FunctionReference<
320
+ "mutation",
321
+ "internal",
322
+ {
323
+ code: string;
324
+ description?: string;
325
+ label: string;
326
+ sortOrder: number;
327
+ },
328
+ any,
329
+ Name
330
+ >;
331
+ listAdjustmentCategories: FunctionReference<
332
+ "query",
333
+ "internal",
334
+ { activeOnly?: boolean },
335
+ any,
336
+ Name
337
+ >;
338
+ listReimbursementCategories: FunctionReference<
339
+ "query",
340
+ "internal",
341
+ { activeOnly?: boolean },
342
+ any,
343
+ Name
344
+ >;
345
+ updateAdjustmentCategory: FunctionReference<
346
+ "mutation",
347
+ "internal",
348
+ {
349
+ categoryId: string;
350
+ description?: string;
351
+ isActive?: boolean;
352
+ label?: string;
353
+ sortOrder?: number;
354
+ },
355
+ any,
356
+ Name
357
+ >;
358
+ updateReimbursementCategory: FunctionReference<
359
+ "mutation",
360
+ "internal",
361
+ {
362
+ categoryId: string;
363
+ description?: string;
364
+ isActive?: boolean;
365
+ label?: string;
366
+ sortOrder?: number;
367
+ },
368
+ any,
369
+ Name
370
+ >;
371
+ };
372
+ commissionPlans: {
373
+ changeStatus: FunctionReference<
374
+ "mutation",
375
+ "internal",
376
+ {
377
+ newStatus: "draft" | "active" | "archived";
378
+ planId: string;
379
+ updatedBy: string;
380
+ },
381
+ any,
382
+ Name
383
+ >;
384
+ create: FunctionReference<
385
+ "mutation",
386
+ "internal",
387
+ {
388
+ code: string;
389
+ createdBy: string;
390
+ description?: string;
391
+ effectiveFrom: number;
392
+ effectiveTo?: number;
393
+ name: string;
394
+ notes?: string;
395
+ templateId?: string;
396
+ userId: string;
397
+ },
398
+ any,
399
+ Name
400
+ >;
401
+ get: FunctionReference<
402
+ "query",
403
+ "internal",
404
+ { planId: string },
405
+ any,
406
+ Name
407
+ >;
408
+ listActive: FunctionReference<"query", "internal", any, any, Name>;
409
+ listAll: FunctionReference<"query", "internal", any, any, Name>;
410
+ listByUser: FunctionReference<
411
+ "query",
412
+ "internal",
413
+ { status?: "draft" | "active" | "archived"; userId: string },
414
+ any,
415
+ Name
416
+ >;
417
+ update: FunctionReference<
418
+ "mutation",
419
+ "internal",
420
+ {
421
+ description?: string;
422
+ effectiveFrom?: number;
423
+ effectiveTo?: number;
424
+ name?: string;
425
+ notes?: string;
426
+ planId: string;
427
+ updatedBy: string;
428
+ },
429
+ any,
430
+ Name
431
+ >;
432
+ };
433
+ commissionRules: {
434
+ create: FunctionReference<
435
+ "mutation",
436
+ "internal",
437
+ {
438
+ conditions: any;
439
+ createdBy: string;
440
+ explanationLabel: string;
441
+ formula: any;
442
+ name: string;
443
+ outputType: "commission" | "fixed" | "bonus";
444
+ planId: string;
445
+ priority: number;
446
+ ruleType: "percentage" | "fixed" | "token" | "combined";
447
+ validFrom?: number;
448
+ validTo?: number;
449
+ },
450
+ any,
451
+ Name
452
+ >;
453
+ listByPlan: FunctionReference<
454
+ "query",
455
+ "internal",
456
+ { activeOnly?: boolean; planId: string },
457
+ any,
458
+ Name
459
+ >;
460
+ remove: FunctionReference<
461
+ "mutation",
462
+ "internal",
463
+ { ruleId: string; userId: string },
464
+ any,
465
+ Name
466
+ >;
467
+ setActive: FunctionReference<
468
+ "mutation",
469
+ "internal",
470
+ { isActive: boolean; ruleId: string; updatedBy: string },
471
+ any,
472
+ Name
473
+ >;
474
+ update: FunctionReference<
475
+ "mutation",
476
+ "internal",
477
+ {
478
+ conditions?: any;
479
+ explanationLabel?: string;
480
+ formula?: any;
481
+ name?: string;
482
+ outputType?: "commission" | "fixed" | "bonus";
483
+ priority?: number;
484
+ ruleId: string;
485
+ ruleType?: "percentage" | "fixed" | "token" | "combined";
486
+ updatedBy: string;
487
+ validFrom?: number;
488
+ validTo?: number;
489
+ },
490
+ any,
491
+ Name
492
+ >;
493
+ };
494
+ companyMappings: {
495
+ create: FunctionReference<
496
+ "mutation",
497
+ "internal",
498
+ {
499
+ category: "DS" | "Est" | "Est_forfettari";
500
+ fromCompanyId: string;
501
+ toCompanyId: string;
502
+ },
503
+ any,
504
+ Name
505
+ >;
506
+ get: FunctionReference<
507
+ "query",
508
+ "internal",
509
+ { mappingId: string },
510
+ any,
511
+ Name
512
+ >;
513
+ getByFromCompany: FunctionReference<
514
+ "query",
515
+ "internal",
516
+ { fromCompanyId: string },
517
+ any,
518
+ Name
519
+ >;
520
+ listAll: FunctionReference<"query", "internal", any, any, Name>;
521
+ listByCategory: FunctionReference<
522
+ "query",
523
+ "internal",
524
+ { category: "DS" | "Est" | "Est_forfettari" },
525
+ any,
526
+ Name
527
+ >;
528
+ update: FunctionReference<
529
+ "mutation",
530
+ "internal",
531
+ {
532
+ category?: "DS" | "Est" | "Est_forfettari";
533
+ isActive?: boolean;
534
+ mappingId: string;
535
+ toCompanyId?: string;
536
+ },
537
+ any,
538
+ Name
539
+ >;
540
+ };
541
+ deductionRules: {
542
+ create: FunctionReference<
543
+ "mutation",
544
+ "internal",
545
+ {
546
+ code: string;
547
+ conditions: {
548
+ carePlanTypeIds?: Array<number>;
549
+ companyIds?: Array<string>;
550
+ conventionNameContains?: string;
551
+ isInsurance?: boolean;
552
+ isSinistro?: boolean;
553
+ percentageAboveThreshold?: boolean;
554
+ percentageThreshold?: number;
555
+ serviceCategoryNames?: Array<string>;
556
+ };
557
+ createdBy: string;
558
+ deductionPercent: number;
559
+ description?: string;
560
+ label: string;
561
+ priority: number;
562
+ },
563
+ any,
564
+ Name
565
+ >;
566
+ get: FunctionReference<
567
+ "query",
568
+ "internal",
569
+ { ruleId: string },
570
+ any,
571
+ Name
572
+ >;
573
+ getByCode: FunctionReference<
574
+ "query",
575
+ "internal",
576
+ { code: string },
577
+ any,
578
+ Name
579
+ >;
580
+ listActive: FunctionReference<"query", "internal", any, any, Name>;
581
+ listAll: FunctionReference<"query", "internal", any, any, Name>;
582
+ update: FunctionReference<
583
+ "mutation",
584
+ "internal",
585
+ {
586
+ conditions?: {
587
+ carePlanTypeIds?: Array<number>;
588
+ companyIds?: Array<string>;
589
+ conventionNameContains?: string;
590
+ isInsurance?: boolean;
591
+ isSinistro?: boolean;
592
+ percentageAboveThreshold?: boolean;
593
+ percentageThreshold?: number;
594
+ serviceCategoryNames?: Array<string>;
595
+ };
596
+ deductionPercent?: number;
597
+ description?: string;
598
+ isActive?: boolean;
599
+ label?: string;
600
+ priority?: number;
601
+ ruleId: string;
602
+ updatedBy: string;
603
+ },
604
+ any,
605
+ Name
606
+ >;
607
+ };
608
+ fixedCommissionTypes: {
609
+ create: FunctionReference<
610
+ "mutation",
611
+ "internal",
612
+ {
613
+ behavior:
614
+ | "minimum_guaranteed"
615
+ | "additive"
616
+ | "substitutive"
617
+ | "substitutive_no_wdays";
618
+ code: string;
619
+ description?: string;
620
+ multipliedByWdays: boolean;
621
+ name: string;
622
+ },
623
+ any,
624
+ Name
625
+ >;
626
+ get: FunctionReference<
627
+ "query",
628
+ "internal",
629
+ { typeId: string },
630
+ any,
631
+ Name
632
+ >;
633
+ getByCode: FunctionReference<
634
+ "query",
635
+ "internal",
636
+ { code: string },
637
+ any,
638
+ Name
639
+ >;
640
+ listActive: FunctionReference<"query", "internal", any, any, Name>;
641
+ listAll: FunctionReference<"query", "internal", any, any, Name>;
642
+ update: FunctionReference<
643
+ "mutation",
644
+ "internal",
645
+ {
646
+ behavior?:
647
+ | "minimum_guaranteed"
648
+ | "additive"
649
+ | "substitutive"
650
+ | "substitutive_no_wdays";
651
+ description?: string;
652
+ isActive?: boolean;
653
+ multipliedByWdays?: boolean;
654
+ name?: string;
655
+ typeId: string;
656
+ },
657
+ any,
658
+ Name
659
+ >;
660
+ };
661
+ globalSettings: {
662
+ get: FunctionReference<"query", "internal", { key: string }, any, Name>;
663
+ getNumber: FunctionReference<
664
+ "query",
665
+ "internal",
666
+ { defaultValue: number; key: string },
667
+ any,
668
+ Name
669
+ >;
670
+ listAll: FunctionReference<"query", "internal", any, any, Name>;
671
+ remove: FunctionReference<
672
+ "mutation",
673
+ "internal",
674
+ { key: string },
675
+ any,
676
+ Name
677
+ >;
678
+ set: FunctionReference<
679
+ "mutation",
680
+ "internal",
681
+ {
682
+ description?: string;
683
+ key: string;
684
+ updatedBy: string;
685
+ value: string;
686
+ },
687
+ any,
688
+ Name
689
+ >;
690
+ };
691
+ invisalignConfig: {
692
+ addMinUser: FunctionReference<
693
+ "mutation",
694
+ "internal",
695
+ { userId: string },
696
+ any,
697
+ Name
698
+ >;
699
+ listActive: FunctionReference<"query", "internal", any, any, Name>;
700
+ listAll: FunctionReference<"query", "internal", any, any, Name>;
701
+ listMinUsers: FunctionReference<"query", "internal", any, any, Name>;
702
+ removeMinUser: FunctionReference<
703
+ "mutation",
704
+ "internal",
705
+ { userId: string },
706
+ any,
707
+ Name
708
+ >;
709
+ upsert: FunctionReference<
710
+ "mutation",
711
+ "internal",
712
+ {
713
+ firstPhaseMin: number;
714
+ firstPhasePercentage: number;
715
+ listRowId: string;
716
+ otherPhasesMin: number;
717
+ otherPhasesPercentage: number;
718
+ },
719
+ any,
720
+ Name
721
+ >;
722
+ };
723
+ planTemplates: {
724
+ create: FunctionReference<
725
+ "mutation",
726
+ "internal",
727
+ {
728
+ code: string;
729
+ createdBy: string;
730
+ defaultRules?: any;
731
+ description?: string;
732
+ name: string;
733
+ },
734
+ any,
735
+ Name
736
+ >;
737
+ get: FunctionReference<
738
+ "query",
739
+ "internal",
740
+ { templateId: string },
741
+ any,
742
+ Name
743
+ >;
744
+ listActive: FunctionReference<"query", "internal", any, any, Name>;
745
+ update: FunctionReference<
746
+ "mutation",
747
+ "internal",
748
+ {
749
+ defaultRules?: any;
750
+ description?: string;
751
+ isActive?: boolean;
752
+ name?: string;
753
+ templateId: string;
754
+ updatedBy: string;
755
+ },
756
+ any,
757
+ Name
758
+ >;
759
+ };
760
+ taxProfiles: {
761
+ create: FunctionReference<
762
+ "mutation",
763
+ "internal",
764
+ {
765
+ additionalRules?: any;
766
+ code: string;
767
+ contributionRatePercent: number;
768
+ contributionText?: string;
769
+ contributionWithholding: boolean;
770
+ createdBy: string;
771
+ description?: string;
772
+ footerText?: string;
773
+ is104: boolean;
774
+ isBolloCompreso: boolean;
775
+ name: string;
776
+ stampDutyAmount: number;
777
+ stampDutyEnabled: boolean;
778
+ stampDutyThreshold: number;
779
+ vatRatePercent: number;
780
+ withholdingOnPercent: number;
781
+ withholdingRatePercent: number;
782
+ },
783
+ any,
784
+ Name
785
+ >;
786
+ get: FunctionReference<
787
+ "query",
788
+ "internal",
789
+ { profileId: string },
790
+ any,
791
+ Name
792
+ >;
793
+ getByCode: FunctionReference<
794
+ "query",
795
+ "internal",
796
+ { code: string },
797
+ any,
798
+ Name
799
+ >;
800
+ listActive: FunctionReference<"query", "internal", any, any, Name>;
801
+ listAll: FunctionReference<"query", "internal", any, any, Name>;
802
+ update: FunctionReference<
803
+ "mutation",
804
+ "internal",
805
+ {
806
+ additionalRules?: any;
807
+ contributionRatePercent?: number;
808
+ contributionText?: string;
809
+ contributionWithholding?: boolean;
810
+ description?: string;
811
+ footerText?: string;
812
+ is104?: boolean;
813
+ isActive?: boolean;
814
+ isBolloCompreso?: boolean;
815
+ name?: string;
816
+ profileId: string;
817
+ stampDutyAmount?: number;
818
+ stampDutyEnabled?: boolean;
819
+ stampDutyThreshold?: number;
820
+ updatedBy: string;
821
+ vatRatePercent?: number;
822
+ withholdingOnPercent?: number;
823
+ withholdingRatePercent?: number;
824
+ },
825
+ any,
826
+ Name
827
+ >;
828
+ };
829
+ userTaxProfiles: {
830
+ assign: FunctionReference<
831
+ "mutation",
832
+ "internal",
833
+ {
834
+ createdBy: string;
835
+ effectiveFrom: number;
836
+ effectiveTo?: number;
837
+ notes?: string;
838
+ taxProfileId: string;
839
+ userId: string;
840
+ },
841
+ any,
842
+ Name
843
+ >;
844
+ getEffective: FunctionReference<
845
+ "query",
846
+ "internal",
847
+ { atDate: number; userId: string },
848
+ any,
849
+ Name
850
+ >;
851
+ listByUser: FunctionReference<
852
+ "query",
853
+ "internal",
854
+ { userId: string },
855
+ any,
856
+ Name
857
+ >;
858
+ };
859
+ };
860
+ documents: {
861
+ draftInvoices: {
862
+ create: FunctionReference<
863
+ "mutation",
864
+ "internal",
865
+ {
866
+ clinicId: string;
867
+ contributionAmount: number;
868
+ createdBy: string;
869
+ isAutoGenerated: boolean;
870
+ lineItemCount: number;
871
+ netToPay: number;
872
+ notes?: string;
873
+ period: string;
874
+ runId: string;
875
+ stampDutyAmount: number;
876
+ subtotal: number;
877
+ taxProfileId?: string;
878
+ taxProfileSnapshot?: any;
879
+ total: number;
880
+ userId: string;
881
+ vatAmount: number;
882
+ withholdingAmount: number;
883
+ },
884
+ any,
885
+ Name
886
+ >;
887
+ get: FunctionReference<
888
+ "query",
889
+ "internal",
890
+ { invoiceId: string },
891
+ any,
892
+ Name
893
+ >;
894
+ listByPeriodAndUser: FunctionReference<
895
+ "query",
896
+ "internal",
897
+ { period: string; userId: string },
898
+ any,
899
+ Name
900
+ >;
901
+ listByRun: FunctionReference<
902
+ "query",
903
+ "internal",
904
+ { runId: string },
905
+ any,
906
+ Name
907
+ >;
908
+ listByRunAndUser: FunctionReference<
909
+ "query",
910
+ "internal",
911
+ { runId: string; userId: string },
912
+ any,
913
+ Name
914
+ >;
915
+ updateStatus: FunctionReference<
916
+ "mutation",
917
+ "internal",
918
+ {
919
+ invoiceId: string;
920
+ newStatus: "draft" | "ready" | "sent" | "cancelled";
921
+ userId: string;
922
+ },
923
+ any,
924
+ Name
925
+ >;
926
+ };
927
+ invoiceGeneration: {
928
+ clearAutoGeneratedInvoices: FunctionReference<
929
+ "mutation",
930
+ "internal",
931
+ { runId: string; userId: string },
932
+ any,
933
+ Name
934
+ >;
935
+ getInvoiceSummaryByUser: FunctionReference<
936
+ "query",
937
+ "internal",
938
+ { runId: string; userId: string },
939
+ any,
940
+ Name
941
+ >;
942
+ getTotalNetToPay: FunctionReference<
943
+ "query",
944
+ "internal",
945
+ { runId: string },
946
+ any,
947
+ Name
948
+ >;
949
+ listFiscalAnomalies: FunctionReference<
950
+ "query",
951
+ "internal",
952
+ { runId: string },
953
+ any,
954
+ Name
955
+ >;
956
+ listUsersWithoutTaxProfile: FunctionReference<
957
+ "query",
958
+ "internal",
959
+ { runId: string },
960
+ any,
961
+ Name
962
+ >;
963
+ refreshDraftInvoices: FunctionReference<
964
+ "mutation",
965
+ "internal",
966
+ { runId: string; userId: string },
967
+ any,
968
+ Name
969
+ >;
970
+ };
971
+ statements: {
972
+ getByRunAndUser: FunctionReference<
973
+ "query",
974
+ "internal",
975
+ { runId: string; userId: string },
976
+ any,
977
+ Name
978
+ >;
979
+ getSummaryByRun: FunctionReference<
980
+ "query",
981
+ "internal",
982
+ { runId: string },
983
+ any,
984
+ Name
985
+ >;
986
+ };
987
+ };
988
+ ledger: {
989
+ entries: {
990
+ create: FunctionReference<
991
+ "mutation",
992
+ "internal",
993
+ {
994
+ amount: number;
995
+ clinicId: string;
996
+ createdBy: string;
997
+ description: string;
998
+ effectiveDate: number;
999
+ isManual: boolean;
1000
+ metadata?: any;
1001
+ period: string;
1002
+ planId?: string;
1003
+ quantity?: number;
1004
+ ruleId?: string;
1005
+ runId: string;
1006
+ sourceId?: string;
1007
+ sourceType: "care_plan_row" | "storno" | "manual" | "system";
1008
+ type:
1009
+ | "production"
1010
+ | "storno"
1011
+ | "commission"
1012
+ | "fixed"
1013
+ | "bonus"
1014
+ | "reimbursement"
1015
+ | "adjustment";
1016
+ unitAmount?: number;
1017
+ userId: string;
1018
+ },
1019
+ any,
1020
+ Name
1021
+ >;
1022
+ createBatch: FunctionReference<
1023
+ "mutation",
1024
+ "internal",
1025
+ {
1026
+ entries: Array<{
1027
+ amount: number;
1028
+ clinicId: string;
1029
+ createdBy: string;
1030
+ description: string;
1031
+ effectiveDate: number;
1032
+ isManual: boolean;
1033
+ metadata?: any;
1034
+ period: string;
1035
+ planId?: string;
1036
+ quantity?: number;
1037
+ ruleId?: string;
1038
+ runId: string;
1039
+ sourceId?: string;
1040
+ sourceType: "care_plan_row" | "storno" | "manual" | "system";
1041
+ type:
1042
+ | "production"
1043
+ | "storno"
1044
+ | "commission"
1045
+ | "fixed"
1046
+ | "bonus"
1047
+ | "reimbursement"
1048
+ | "adjustment";
1049
+ unitAmount?: number;
1050
+ userId: string;
1051
+ }>;
1052
+ },
1053
+ any,
1054
+ Name
1055
+ >;
1056
+ deleteCalculatedByRun: FunctionReference<
1057
+ "mutation",
1058
+ "internal",
1059
+ { runId: string; userId: string },
1060
+ any,
1061
+ Name
1062
+ >;
1063
+ listByPeriodAndUser: FunctionReference<
1064
+ "query",
1065
+ "internal",
1066
+ { period: string; userId: string },
1067
+ any,
1068
+ Name
1069
+ >;
1070
+ listByRun: FunctionReference<
1071
+ "query",
1072
+ "internal",
1073
+ { runId: string },
1074
+ any,
1075
+ Name
1076
+ >;
1077
+ listByRunAndType: FunctionReference<
1078
+ "query",
1079
+ "internal",
1080
+ {
1081
+ runId: string;
1082
+ type:
1083
+ | "production"
1084
+ | "storno"
1085
+ | "commission"
1086
+ | "fixed"
1087
+ | "bonus"
1088
+ | "reimbursement"
1089
+ | "adjustment";
1090
+ },
1091
+ any,
1092
+ Name
1093
+ >;
1094
+ listByRunAndUser: FunctionReference<
1095
+ "query",
1096
+ "internal",
1097
+ { runId: string; userId: string },
1098
+ any,
1099
+ Name
1100
+ >;
1101
+ listByRunUserClinic: FunctionReference<
1102
+ "query",
1103
+ "internal",
1104
+ { clinicId: string; runId: string; userId: string },
1105
+ any,
1106
+ Name
1107
+ >;
1108
+ remove: FunctionReference<
1109
+ "mutation",
1110
+ "internal",
1111
+ { entryId: string; userId: string },
1112
+ any,
1113
+ Name
1114
+ >;
1115
+ update: FunctionReference<
1116
+ "mutation",
1117
+ "internal",
1118
+ {
1119
+ amount?: number;
1120
+ description?: string;
1121
+ entryId: string;
1122
+ metadata?: any;
1123
+ userId: string;
1124
+ },
1125
+ any,
1126
+ Name
1127
+ >;
1128
+ };
1129
+ };
1130
+ seedHelpers: {
1131
+ clearAll: FunctionReference<"mutation", "internal", {}, any, Name>;
1132
+ };
1133
+ workflow: {
1134
+ pendingCompletions: {
1135
+ getPendingSummary: FunctionReference<
1136
+ "query",
1137
+ "internal",
1138
+ {},
1139
+ any,
1140
+ Name
1141
+ >;
1142
+ listPendingByPeriod: FunctionReference<
1143
+ "query",
1144
+ "internal",
1145
+ { period: string },
1146
+ any,
1147
+ Name
1148
+ >;
1149
+ markAsProcessed: FunctionReference<
1150
+ "mutation",
1151
+ "internal",
1152
+ { period: string; runId: string },
1153
+ any,
1154
+ Name
1155
+ >;
1156
+ recordCompletion: FunctionReference<
1157
+ "mutation",
1158
+ "internal",
1159
+ {
1160
+ amount: number;
1161
+ carePlanId: string;
1162
+ carePlanRowId: string;
1163
+ clinicId: string;
1164
+ companyId?: string;
1165
+ completedAt: number;
1166
+ completedBy: string;
1167
+ period: string;
1168
+ serviceDescription?: string;
1169
+ userId: string;
1170
+ },
1171
+ any,
1172
+ Name
1173
+ >;
1174
+ };
1175
+ pythonWorker: {
1176
+ testConnection: FunctionReference<
1177
+ "action",
1178
+ "internal",
1179
+ { runId: string; workerUrl?: string },
1180
+ any,
1181
+ Name
1182
+ >;
1183
+ triggerCalculation: FunctionReference<
1184
+ "action",
1185
+ "internal",
1186
+ {
1187
+ runId: string;
1188
+ userId: string;
1189
+ userIds?: Array<string>;
1190
+ workerUrl?: string;
1191
+ },
1192
+ any,
1193
+ Name
1194
+ >;
1195
+ };
1196
+ runIssues: {
1197
+ collectIssues: FunctionReference<
1198
+ "mutation",
1199
+ "internal",
1200
+ { runId: string; userId: string },
1201
+ any,
1202
+ Name
1203
+ >;
1204
+ getSummary: FunctionReference<
1205
+ "query",
1206
+ "internal",
1207
+ { runId: string },
1208
+ any,
1209
+ Name
1210
+ >;
1211
+ listByRun: FunctionReference<
1212
+ "query",
1213
+ "internal",
1214
+ { runId: string },
1215
+ any,
1216
+ Name
1217
+ >;
1218
+ listByRunAndType: FunctionReference<
1219
+ "query",
1220
+ "internal",
1221
+ {
1222
+ issueType:
1223
+ | "no_active_plan"
1224
+ | "no_matching_rule"
1225
+ | "no_tax_profile"
1226
+ | "multiple_tax_profiles"
1227
+ | "inactive_tax_profile"
1228
+ | "fiscal_anomaly"
1229
+ | "missing_invoices";
1230
+ runId: string;
1231
+ },
1232
+ any,
1233
+ Name
1234
+ >;
1235
+ listErrorsByRun: FunctionReference<
1236
+ "query",
1237
+ "internal",
1238
+ { runId: string },
1239
+ any,
1240
+ Name
1241
+ >;
1242
+ };
1243
+ runs: {
1244
+ checkReadiness: FunctionReference<
1245
+ "query",
1246
+ "internal",
1247
+ { runId: string },
1248
+ any,
1249
+ Name
1250
+ >;
1251
+ closeRun: FunctionReference<
1252
+ "mutation",
1253
+ "internal",
1254
+ { force?: boolean; runId: string; userId: string },
1255
+ any,
1256
+ Name
1257
+ >;
1258
+ compareRuns: FunctionReference<
1259
+ "query",
1260
+ "internal",
1261
+ { runIdA: string; runIdB: string },
1262
+ any,
1263
+ Name
1264
+ >;
1265
+ createRun: FunctionReference<
1266
+ "mutation",
1267
+ "internal",
1268
+ {
1269
+ calculationMode?: "manual" | "scheduled" | "reopen";
1270
+ isShadowRun?: boolean;
1271
+ notes?: string;
1272
+ period: string;
1273
+ scopePayload?: any;
1274
+ scopeType?: "global" | "users" | "clinics" | "user_clinic_pairs";
1275
+ triggeredBy: string;
1276
+ },
1277
+ any,
1278
+ Name
1279
+ >;
1280
+ get: FunctionReference<
1281
+ "query",
1282
+ "internal",
1283
+ { runId: string },
1284
+ any,
1285
+ Name
1286
+ >;
1287
+ getRunSnapshot: FunctionReference<
1288
+ "query",
1289
+ "internal",
1290
+ { runId: string },
1291
+ any,
1292
+ Name
1293
+ >;
1294
+ getVersionHistory: FunctionReference<
1295
+ "query",
1296
+ "internal",
1297
+ { period: string },
1298
+ any,
1299
+ Name
1300
+ >;
1301
+ listByPeriod: FunctionReference<
1302
+ "query",
1303
+ "internal",
1304
+ { period: string },
1305
+ any,
1306
+ Name
1307
+ >;
1308
+ listByStatus: FunctionReference<
1309
+ "query",
1310
+ "internal",
1311
+ {
1312
+ status:
1313
+ | "draft"
1314
+ | "calculated"
1315
+ | "reviewing"
1316
+ | "approved"
1317
+ | "closed";
1318
+ },
1319
+ any,
1320
+ Name
1321
+ >;
1322
+ listClosed: FunctionReference<"query", "internal", {}, any, Name>;
1323
+ listShadowByPeriod: FunctionReference<
1324
+ "query",
1325
+ "internal",
1326
+ { period: string },
1327
+ any,
1328
+ Name
1329
+ >;
1330
+ reopenRun: FunctionReference<
1331
+ "mutation",
1332
+ "internal",
1333
+ { notes?: string; runId: string; userId: string },
1334
+ any,
1335
+ Name
1336
+ >;
1337
+ updateStatus: FunctionReference<
1338
+ "mutation",
1339
+ "internal",
1340
+ {
1341
+ newStatus:
1342
+ | "draft"
1343
+ | "calculated"
1344
+ | "reviewing"
1345
+ | "approved"
1346
+ | "closed";
1347
+ notes?: string;
1348
+ runId: string;
1349
+ userId: string;
1350
+ },
1351
+ any,
1352
+ Name
1353
+ >;
1354
+ };
1355
+ };
1356
+ };