@hed-hog/finance 0.0.236 → 0.0.238
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/dto/create-finance-tag.dto.d.ts +5 -0
- package/dist/dto/create-finance-tag.dto.d.ts.map +1 -0
- package/dist/dto/create-finance-tag.dto.js +29 -0
- package/dist/dto/create-finance-tag.dto.js.map +1 -0
- package/dist/dto/update-installment-tags.dto.d.ts +4 -0
- package/dist/dto/update-installment-tags.dto.d.ts.map +1 -0
- package/dist/dto/update-installment-tags.dto.js +27 -0
- package/dist/dto/update-installment-tags.dto.js.map +1 -0
- package/dist/finance-data.controller.d.ts +4 -0
- package/dist/finance-data.controller.d.ts.map +1 -1
- package/dist/finance-installments.controller.d.ts +81 -0
- package/dist/finance-installments.controller.d.ts.map +1 -1
- package/dist/finance-installments.controller.js +36 -0
- package/dist/finance-installments.controller.js.map +1 -1
- package/dist/finance.service.d.ts +86 -0
- package/dist/finance.service.d.ts.map +1 -1
- package/dist/finance.service.js +185 -2
- package/dist/finance.service.js.map +1 -1
- package/hedhog/data/route.yaml +27 -0
- package/hedhog/frontend/app/_components/person-field-with-create.tsx.ejs +627 -0
- package/hedhog/frontend/app/_lib/use-finance-data.ts.ejs +2 -0
- package/hedhog/frontend/app/accounts-payable/installments/[id]/page.tsx.ejs +249 -78
- package/hedhog/frontend/app/accounts-payable/installments/page.tsx.ejs +903 -883
- package/hedhog/frontend/app/accounts-receivable/installments/[id]/page.tsx.ejs +202 -20
- package/hedhog/frontend/app/accounts-receivable/installments/page.tsx.ejs +877 -861
- package/hedhog/frontend/app/administration/categories/page.tsx.ejs +108 -25
- package/hedhog/frontend/app/administration/cost-centers/page.tsx.ejs +15 -8
- package/hedhog/frontend/messages/en.json +38 -0
- package/hedhog/frontend/messages/pt.json +38 -0
- package/package.json +5 -5
- package/src/dto/create-finance-tag.dto.ts +15 -0
- package/src/dto/update-installment-tags.dto.ts +12 -0
- package/src/finance-installments.controller.ts +43 -9
- package/src/finance.service.ts +255 -12
|
@@ -1,861 +1,877 @@
|
|
|
1
|
-
'use client';
|
|
2
|
-
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
import {
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
import {
|
|
24
|
-
import {
|
|
25
|
-
import {
|
|
26
|
-
import {
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
import {
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
import {
|
|
52
|
-
import {
|
|
53
|
-
import {
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
import
|
|
65
|
-
import
|
|
66
|
-
import {
|
|
67
|
-
import {
|
|
68
|
-
import {
|
|
69
|
-
import {
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
categorias,
|
|
88
|
-
centrosCusto,
|
|
89
|
-
t,
|
|
90
|
-
onCreated,
|
|
91
|
-
}: {
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
})
|
|
98
|
-
const
|
|
99
|
-
const [
|
|
100
|
-
const [
|
|
101
|
-
const [
|
|
102
|
-
const [
|
|
103
|
-
const [
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
>(
|
|
107
|
-
const [
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
const
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
formData.append('
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
);
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
'
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
'
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
<
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
<
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
<
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
extractionConfidence
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
<
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
<
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
<
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
)
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
}
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
const
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
?.
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
{ label: t('breadcrumbs.
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
{ value: '
|
|
733
|
-
{ value: '
|
|
734
|
-
{ value: '
|
|
735
|
-
{ value: '
|
|
736
|
-
{ value: '
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
<TableHead>{t('table.headers.
|
|
750
|
-
<TableHead>{t('table.headers.
|
|
751
|
-
<TableHead>{t('table.headers.
|
|
752
|
-
<TableHead
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
<TableHead>{t('table.headers.
|
|
757
|
-
<TableHead
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
const
|
|
764
|
-
|
|
765
|
-
canalBadge.
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
</TableCell>
|
|
801
|
-
<TableCell>
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
|
|
816
|
-
|
|
817
|
-
|
|
818
|
-
|
|
819
|
-
|
|
820
|
-
<
|
|
821
|
-
<
|
|
822
|
-
|
|
823
|
-
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
|
|
827
|
-
|
|
828
|
-
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
|
|
835
|
-
|
|
836
|
-
|
|
837
|
-
|
|
838
|
-
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
|
|
846
|
-
|
|
847
|
-
|
|
848
|
-
|
|
849
|
-
|
|
850
|
-
|
|
851
|
-
|
|
852
|
-
|
|
853
|
-
|
|
854
|
-
|
|
855
|
-
|
|
856
|
-
|
|
857
|
-
|
|
858
|
-
|
|
859
|
-
|
|
860
|
-
|
|
861
|
-
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
3
|
+
import { PersonFieldWithCreate } from '@/app/(app)/(libraries)/finance/_components/person-field-with-create';
|
|
4
|
+
import { Page, PageHeader } from '@/components/entity-list';
|
|
5
|
+
import { Badge } from '@/components/ui/badge';
|
|
6
|
+
import { Button } from '@/components/ui/button';
|
|
7
|
+
import {
|
|
8
|
+
DropdownMenu,
|
|
9
|
+
DropdownMenuContent,
|
|
10
|
+
DropdownMenuItem,
|
|
11
|
+
DropdownMenuSeparator,
|
|
12
|
+
DropdownMenuTrigger,
|
|
13
|
+
} from '@/components/ui/dropdown-menu';
|
|
14
|
+
import { FilterBar } from '@/components/ui/filter-bar';
|
|
15
|
+
import {
|
|
16
|
+
Form,
|
|
17
|
+
FormControl,
|
|
18
|
+
FormField,
|
|
19
|
+
FormItem,
|
|
20
|
+
FormLabel,
|
|
21
|
+
FormMessage,
|
|
22
|
+
} from '@/components/ui/form';
|
|
23
|
+
import { Input } from '@/components/ui/input';
|
|
24
|
+
import { InputMoney } from '@/components/ui/input-money';
|
|
25
|
+
import { Money } from '@/components/ui/money';
|
|
26
|
+
import { Progress } from '@/components/ui/progress';
|
|
27
|
+
import {
|
|
28
|
+
Select,
|
|
29
|
+
SelectContent,
|
|
30
|
+
SelectItem,
|
|
31
|
+
SelectTrigger,
|
|
32
|
+
SelectValue,
|
|
33
|
+
} from '@/components/ui/select';
|
|
34
|
+
import {
|
|
35
|
+
Sheet,
|
|
36
|
+
SheetContent,
|
|
37
|
+
SheetDescription,
|
|
38
|
+
SheetHeader,
|
|
39
|
+
SheetTitle,
|
|
40
|
+
SheetTrigger,
|
|
41
|
+
} from '@/components/ui/sheet';
|
|
42
|
+
import { StatusBadge } from '@/components/ui/status-badge';
|
|
43
|
+
import {
|
|
44
|
+
Table,
|
|
45
|
+
TableBody,
|
|
46
|
+
TableCell,
|
|
47
|
+
TableHead,
|
|
48
|
+
TableHeader,
|
|
49
|
+
TableRow,
|
|
50
|
+
} from '@/components/ui/table';
|
|
51
|
+
import { Textarea } from '@/components/ui/textarea';
|
|
52
|
+
import { useApp } from '@hed-hog/next-app-provider';
|
|
53
|
+
import { zodResolver } from '@hookform/resolvers/zod';
|
|
54
|
+
import {
|
|
55
|
+
Download,
|
|
56
|
+
Edit,
|
|
57
|
+
Eye,
|
|
58
|
+
Loader2,
|
|
59
|
+
MoreHorizontal,
|
|
60
|
+
Paperclip,
|
|
61
|
+
Plus,
|
|
62
|
+
Send,
|
|
63
|
+
} from 'lucide-react';
|
|
64
|
+
import { useTranslations } from 'next-intl';
|
|
65
|
+
import Link from 'next/link';
|
|
66
|
+
import { useState } from 'react';
|
|
67
|
+
import { useForm } from 'react-hook-form';
|
|
68
|
+
import { z } from 'zod';
|
|
69
|
+
import { formatarData } from '../../_lib/formatters';
|
|
70
|
+
import { useFinanceData } from '../../_lib/use-finance-data';
|
|
71
|
+
|
|
72
|
+
const newTitleFormSchema = z.object({
|
|
73
|
+
documento: z.string().trim().min(1, 'Documento é obrigatório'),
|
|
74
|
+
clienteId: z.string().min(1, 'Cliente é obrigatório'),
|
|
75
|
+
competencia: z.string().optional(),
|
|
76
|
+
vencimento: z.string().min(1, 'Vencimento é obrigatório'),
|
|
77
|
+
valor: z.number().min(0.01, 'Valor deve ser maior que zero'),
|
|
78
|
+
categoriaId: z.string().optional(),
|
|
79
|
+
centroCustoId: z.string().optional(),
|
|
80
|
+
canal: z.string().optional(),
|
|
81
|
+
descricao: z.string().optional(),
|
|
82
|
+
});
|
|
83
|
+
|
|
84
|
+
type NewTitleFormValues = z.infer<typeof newTitleFormSchema>;
|
|
85
|
+
|
|
86
|
+
function NovoTituloSheet({
|
|
87
|
+
categorias,
|
|
88
|
+
centrosCusto,
|
|
89
|
+
t,
|
|
90
|
+
onCreated,
|
|
91
|
+
}: {
|
|
92
|
+
categorias: any[];
|
|
93
|
+
centrosCusto: any[];
|
|
94
|
+
t: ReturnType<typeof useTranslations>;
|
|
95
|
+
onCreated: () => Promise<any> | void;
|
|
96
|
+
}) {
|
|
97
|
+
const { request, showToastHandler } = useApp();
|
|
98
|
+
const [open, setOpen] = useState(false);
|
|
99
|
+
const [uploadedFileId, setUploadedFileId] = useState<number | null>(null);
|
|
100
|
+
const [uploadedFileName, setUploadedFileName] = useState('');
|
|
101
|
+
const [isUploadingFile, setIsUploadingFile] = useState(false);
|
|
102
|
+
const [isExtractingFileData, setIsExtractingFileData] = useState(false);
|
|
103
|
+
const [extractionConfidence, setExtractionConfidence] = useState<
|
|
104
|
+
number | null
|
|
105
|
+
>(null);
|
|
106
|
+
const [extractionWarnings, setExtractionWarnings] = useState<string[]>([]);
|
|
107
|
+
const [uploadProgress, setUploadProgress] = useState(0);
|
|
108
|
+
|
|
109
|
+
const normalizeFilenameForDisplay = (filename: string) => {
|
|
110
|
+
if (!filename) {
|
|
111
|
+
return filename;
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
if (!/Ã.|Â.|â[\u0080-\u00BF]/.test(filename)) {
|
|
115
|
+
return filename;
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
try {
|
|
119
|
+
const bytes = Uint8Array.from(filename, (char) => char.charCodeAt(0));
|
|
120
|
+
const decoded = new TextDecoder('utf-8').decode(bytes);
|
|
121
|
+
return /Ã.|Â.|â[\u0080-\u00BF]/.test(decoded) ? filename : decoded;
|
|
122
|
+
} catch {
|
|
123
|
+
return filename;
|
|
124
|
+
}
|
|
125
|
+
};
|
|
126
|
+
|
|
127
|
+
const form = useForm<NewTitleFormValues>({
|
|
128
|
+
resolver: zodResolver(newTitleFormSchema),
|
|
129
|
+
defaultValues: {
|
|
130
|
+
documento: '',
|
|
131
|
+
clienteId: '',
|
|
132
|
+
competencia: '',
|
|
133
|
+
vencimento: '',
|
|
134
|
+
valor: 0,
|
|
135
|
+
categoriaId: '',
|
|
136
|
+
centroCustoId: '',
|
|
137
|
+
canal: '',
|
|
138
|
+
descricao: '',
|
|
139
|
+
},
|
|
140
|
+
});
|
|
141
|
+
|
|
142
|
+
const handleSubmit = async (values: NewTitleFormValues) => {
|
|
143
|
+
try {
|
|
144
|
+
await request({
|
|
145
|
+
url: '/finance/accounts-receivable/installments',
|
|
146
|
+
method: 'POST',
|
|
147
|
+
data: {
|
|
148
|
+
document_number: values.documento,
|
|
149
|
+
person_id: Number(values.clienteId),
|
|
150
|
+
competence_date: values.competencia
|
|
151
|
+
? `${values.competencia}-01`
|
|
152
|
+
: undefined,
|
|
153
|
+
due_date: values.vencimento,
|
|
154
|
+
total_amount: values.valor,
|
|
155
|
+
finance_category_id: values.categoriaId
|
|
156
|
+
? Number(values.categoriaId)
|
|
157
|
+
: undefined,
|
|
158
|
+
cost_center_id: values.centroCustoId
|
|
159
|
+
? Number(values.centroCustoId)
|
|
160
|
+
: undefined,
|
|
161
|
+
payment_channel: values.canal || undefined,
|
|
162
|
+
description: values.descricao?.trim() || undefined,
|
|
163
|
+
attachment_file_ids: uploadedFileId ? [uploadedFileId] : undefined,
|
|
164
|
+
},
|
|
165
|
+
});
|
|
166
|
+
|
|
167
|
+
await onCreated();
|
|
168
|
+
form.reset();
|
|
169
|
+
setUploadedFileId(null);
|
|
170
|
+
setUploadedFileName('');
|
|
171
|
+
setExtractionConfidence(null);
|
|
172
|
+
setExtractionWarnings([]);
|
|
173
|
+
setOpen(false);
|
|
174
|
+
showToastHandler?.('success', 'Título criado com sucesso');
|
|
175
|
+
} catch {
|
|
176
|
+
showToastHandler?.('error', 'Erro ao criar título');
|
|
177
|
+
}
|
|
178
|
+
};
|
|
179
|
+
|
|
180
|
+
const handleCancel = () => {
|
|
181
|
+
form.reset();
|
|
182
|
+
setUploadedFileId(null);
|
|
183
|
+
setUploadedFileName('');
|
|
184
|
+
setExtractionConfidence(null);
|
|
185
|
+
setExtractionWarnings([]);
|
|
186
|
+
setUploadProgress(0);
|
|
187
|
+
setOpen(false);
|
|
188
|
+
};
|
|
189
|
+
|
|
190
|
+
const uploadRelatedFile = async (file: File) => {
|
|
191
|
+
setIsUploadingFile(true);
|
|
192
|
+
setUploadProgress(0);
|
|
193
|
+
|
|
194
|
+
try {
|
|
195
|
+
const formData = new FormData();
|
|
196
|
+
formData.append('file', file);
|
|
197
|
+
formData.append('destination', 'finance/titles');
|
|
198
|
+
|
|
199
|
+
const { data } = await request<{ id: number; filename: string }>({
|
|
200
|
+
url: '/file',
|
|
201
|
+
method: 'POST',
|
|
202
|
+
data: formData,
|
|
203
|
+
headers: {
|
|
204
|
+
'Content-Type': 'multipart/form-data',
|
|
205
|
+
},
|
|
206
|
+
onUploadProgress: (event) => {
|
|
207
|
+
if (!event.total) {
|
|
208
|
+
return;
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
const progress = Math.round((event.loaded * 100) / event.total);
|
|
212
|
+
setUploadProgress(progress);
|
|
213
|
+
},
|
|
214
|
+
});
|
|
215
|
+
|
|
216
|
+
if (!data?.id) {
|
|
217
|
+
throw new Error('Arquivo inválido');
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
setUploadedFileId(data.id);
|
|
221
|
+
setUploadedFileName(
|
|
222
|
+
normalizeFilenameForDisplay(data.filename || file.name)
|
|
223
|
+
);
|
|
224
|
+
setUploadProgress(100);
|
|
225
|
+
showToastHandler?.('success', 'Arquivo relacionado com sucesso');
|
|
226
|
+
|
|
227
|
+
setIsExtractingFileData(true);
|
|
228
|
+
try {
|
|
229
|
+
const extraction = await request<{
|
|
230
|
+
documento?: string | null;
|
|
231
|
+
clienteId?: string;
|
|
232
|
+
competencia?: string;
|
|
233
|
+
vencimento?: string;
|
|
234
|
+
valor?: number | null;
|
|
235
|
+
categoriaId?: string;
|
|
236
|
+
centroCustoId?: string;
|
|
237
|
+
canal?: string;
|
|
238
|
+
descricao?: string | null;
|
|
239
|
+
confidence?: number | null;
|
|
240
|
+
confidenceLevel?: 'low' | 'high' | null;
|
|
241
|
+
warnings?: string[];
|
|
242
|
+
}>({
|
|
243
|
+
url: '/finance/accounts-receivable/installments/extract-from-file',
|
|
244
|
+
method: 'POST',
|
|
245
|
+
data: {
|
|
246
|
+
file_id: data.id,
|
|
247
|
+
},
|
|
248
|
+
});
|
|
249
|
+
|
|
250
|
+
const extracted = extraction.data || {};
|
|
251
|
+
setExtractionConfidence(
|
|
252
|
+
typeof extracted.confidence === 'number' ? extracted.confidence : null
|
|
253
|
+
);
|
|
254
|
+
setExtractionWarnings(
|
|
255
|
+
Array.isArray(extracted.warnings)
|
|
256
|
+
? extracted.warnings.filter(Boolean)
|
|
257
|
+
: []
|
|
258
|
+
);
|
|
259
|
+
|
|
260
|
+
if (extracted.documento) {
|
|
261
|
+
form.setValue('documento', extracted.documento, {
|
|
262
|
+
shouldValidate: true,
|
|
263
|
+
});
|
|
264
|
+
}
|
|
265
|
+
|
|
266
|
+
if (extracted.clienteId) {
|
|
267
|
+
form.setValue('clienteId', extracted.clienteId, {
|
|
268
|
+
shouldValidate: true,
|
|
269
|
+
});
|
|
270
|
+
}
|
|
271
|
+
|
|
272
|
+
if (extracted.competencia) {
|
|
273
|
+
form.setValue('competencia', extracted.competencia, {
|
|
274
|
+
shouldValidate: true,
|
|
275
|
+
});
|
|
276
|
+
}
|
|
277
|
+
|
|
278
|
+
if (extracted.vencimento) {
|
|
279
|
+
form.setValue('vencimento', extracted.vencimento, {
|
|
280
|
+
shouldValidate: true,
|
|
281
|
+
});
|
|
282
|
+
}
|
|
283
|
+
|
|
284
|
+
if (typeof extracted.valor === 'number' && extracted.valor > 0) {
|
|
285
|
+
form.setValue('valor', extracted.valor, {
|
|
286
|
+
shouldValidate: true,
|
|
287
|
+
});
|
|
288
|
+
}
|
|
289
|
+
|
|
290
|
+
if (extracted.categoriaId) {
|
|
291
|
+
form.setValue('categoriaId', extracted.categoriaId, {
|
|
292
|
+
shouldValidate: true,
|
|
293
|
+
});
|
|
294
|
+
}
|
|
295
|
+
|
|
296
|
+
if (extracted.centroCustoId) {
|
|
297
|
+
form.setValue('centroCustoId', extracted.centroCustoId, {
|
|
298
|
+
shouldValidate: true,
|
|
299
|
+
});
|
|
300
|
+
}
|
|
301
|
+
|
|
302
|
+
if (extracted.canal) {
|
|
303
|
+
form.setValue('canal', extracted.canal, {
|
|
304
|
+
shouldValidate: true,
|
|
305
|
+
});
|
|
306
|
+
}
|
|
307
|
+
|
|
308
|
+
if (extracted.descricao) {
|
|
309
|
+
form.setValue('descricao', extracted.descricao, {
|
|
310
|
+
shouldValidate: true,
|
|
311
|
+
});
|
|
312
|
+
}
|
|
313
|
+
|
|
314
|
+
showToastHandler?.(
|
|
315
|
+
'success',
|
|
316
|
+
'Dados da fatura extraídos e preenchidos automaticamente'
|
|
317
|
+
);
|
|
318
|
+
} catch {
|
|
319
|
+
setExtractionConfidence(null);
|
|
320
|
+
setExtractionWarnings([]);
|
|
321
|
+
showToastHandler?.(
|
|
322
|
+
'error',
|
|
323
|
+
'Não foi possível extrair os dados automaticamente'
|
|
324
|
+
);
|
|
325
|
+
} finally {
|
|
326
|
+
setIsExtractingFileData(false);
|
|
327
|
+
}
|
|
328
|
+
} catch {
|
|
329
|
+
setUploadedFileId(null);
|
|
330
|
+
setUploadedFileName('');
|
|
331
|
+
setExtractionConfidence(null);
|
|
332
|
+
setExtractionWarnings([]);
|
|
333
|
+
setUploadProgress(0);
|
|
334
|
+
showToastHandler?.('error', 'Não foi possível enviar o arquivo');
|
|
335
|
+
} finally {
|
|
336
|
+
setIsUploadingFile(false);
|
|
337
|
+
}
|
|
338
|
+
};
|
|
339
|
+
|
|
340
|
+
return (
|
|
341
|
+
<Sheet open={open} onOpenChange={setOpen}>
|
|
342
|
+
<SheetTrigger asChild>
|
|
343
|
+
<Button>
|
|
344
|
+
<Plus className="mr-2 h-4 w-4" />
|
|
345
|
+
{t('newTitle.action')}
|
|
346
|
+
</Button>
|
|
347
|
+
</SheetTrigger>
|
|
348
|
+
<SheetContent className="w-full sm:max-w-lg overflow-y-auto">
|
|
349
|
+
<SheetHeader>
|
|
350
|
+
<SheetTitle>{t('newTitle.title')}</SheetTitle>
|
|
351
|
+
<SheetDescription>{t('newTitle.description')}</SheetDescription>
|
|
352
|
+
</SheetHeader>
|
|
353
|
+
<Form {...form}>
|
|
354
|
+
<form className="px-4" onSubmit={form.handleSubmit(handleSubmit)}>
|
|
355
|
+
<div className="grid gap-4">
|
|
356
|
+
<div className="grid gap-2">
|
|
357
|
+
<FormLabel>Arquivo da fatura (opcional)</FormLabel>
|
|
358
|
+
<div className="flex flex-col gap-2 sm:flex-row sm:items-center">
|
|
359
|
+
<Input
|
|
360
|
+
type="file"
|
|
361
|
+
accept=".pdf,.png,.jpg,.jpeg,.xml,.txt"
|
|
362
|
+
onChange={(event) => {
|
|
363
|
+
const file = event.target.files?.[0];
|
|
364
|
+
if (!file) {
|
|
365
|
+
return;
|
|
366
|
+
}
|
|
367
|
+
|
|
368
|
+
setUploadedFileId(null);
|
|
369
|
+
setUploadedFileName('');
|
|
370
|
+
setExtractionConfidence(null);
|
|
371
|
+
setExtractionWarnings([]);
|
|
372
|
+
setUploadProgress(0);
|
|
373
|
+
void uploadRelatedFile(file);
|
|
374
|
+
}}
|
|
375
|
+
disabled={
|
|
376
|
+
isUploadingFile ||
|
|
377
|
+
isExtractingFileData ||
|
|
378
|
+
form.formState.isSubmitting
|
|
379
|
+
}
|
|
380
|
+
/>
|
|
381
|
+
</div>
|
|
382
|
+
{isUploadingFile && (
|
|
383
|
+
<div className="space-y-1">
|
|
384
|
+
<Progress value={uploadProgress} className="h-2" />
|
|
385
|
+
<p className="text-xs text-muted-foreground">
|
|
386
|
+
Upload em andamento: {uploadProgress}%
|
|
387
|
+
</p>
|
|
388
|
+
</div>
|
|
389
|
+
)}
|
|
390
|
+
{uploadedFileId && (
|
|
391
|
+
<p className="text-xs text-muted-foreground">
|
|
392
|
+
Arquivo relacionado: {uploadedFileName}
|
|
393
|
+
</p>
|
|
394
|
+
)}
|
|
395
|
+
{isExtractingFileData && (
|
|
396
|
+
<div className="rounded-md border border-primary/30 bg-primary/5 p-3">
|
|
397
|
+
<div className="flex items-center gap-2 text-sm font-medium text-primary">
|
|
398
|
+
<Loader2 className="h-4 w-4 animate-spin" />
|
|
399
|
+
Analisando documento com IA
|
|
400
|
+
</div>
|
|
401
|
+
<p className="mt-1 text-xs text-muted-foreground">
|
|
402
|
+
Os campos serão preenchidos automaticamente em instantes.
|
|
403
|
+
Revise os dados antes de salvar.
|
|
404
|
+
</p>
|
|
405
|
+
</div>
|
|
406
|
+
)}
|
|
407
|
+
{!isExtractingFileData &&
|
|
408
|
+
extractionConfidence !== null &&
|
|
409
|
+
extractionConfidence < 70 && (
|
|
410
|
+
<div className="rounded-md border border-destructive/30 bg-destructive/5 p-3">
|
|
411
|
+
<div className="text-sm font-medium text-destructive">
|
|
412
|
+
Confiança da extração:{' '}
|
|
413
|
+
{Math.round(extractionConfidence)}%
|
|
414
|
+
</div>
|
|
415
|
+
<p className="mt-1 text-xs text-muted-foreground">
|
|
416
|
+
Revise principalmente valor e vencimento antes de
|
|
417
|
+
salvar.
|
|
418
|
+
</p>
|
|
419
|
+
{extractionWarnings.length > 0 && (
|
|
420
|
+
<p className="mt-1 text-xs text-muted-foreground">
|
|
421
|
+
{extractionWarnings[0]}
|
|
422
|
+
</p>
|
|
423
|
+
)}
|
|
424
|
+
</div>
|
|
425
|
+
)}
|
|
426
|
+
</div>
|
|
427
|
+
|
|
428
|
+
<FormField
|
|
429
|
+
control={form.control}
|
|
430
|
+
name="documento"
|
|
431
|
+
render={({ field }) => (
|
|
432
|
+
<FormItem>
|
|
433
|
+
<FormLabel>{t('fields.document')}</FormLabel>
|
|
434
|
+
<FormControl>
|
|
435
|
+
<Input placeholder="FAT-00000" {...field} />
|
|
436
|
+
</FormControl>
|
|
437
|
+
<FormMessage />
|
|
438
|
+
</FormItem>
|
|
439
|
+
)}
|
|
440
|
+
/>
|
|
441
|
+
|
|
442
|
+
<PersonFieldWithCreate
|
|
443
|
+
form={form}
|
|
444
|
+
name="clienteId"
|
|
445
|
+
label={t('fields.client')}
|
|
446
|
+
entityLabel="cliente"
|
|
447
|
+
selectPlaceholder={t('common.select')}
|
|
448
|
+
/>
|
|
449
|
+
|
|
450
|
+
<div className="grid grid-cols-2 gap-4">
|
|
451
|
+
<FormField
|
|
452
|
+
control={form.control}
|
|
453
|
+
name="competencia"
|
|
454
|
+
render={({ field }) => (
|
|
455
|
+
<FormItem>
|
|
456
|
+
<FormLabel>{t('fields.competency')}</FormLabel>
|
|
457
|
+
<FormControl>
|
|
458
|
+
<Input
|
|
459
|
+
type="month"
|
|
460
|
+
{...field}
|
|
461
|
+
value={field.value || ''}
|
|
462
|
+
/>
|
|
463
|
+
</FormControl>
|
|
464
|
+
<FormMessage />
|
|
465
|
+
</FormItem>
|
|
466
|
+
)}
|
|
467
|
+
/>
|
|
468
|
+
|
|
469
|
+
<FormField
|
|
470
|
+
control={form.control}
|
|
471
|
+
name="vencimento"
|
|
472
|
+
render={({ field }) => (
|
|
473
|
+
<FormItem>
|
|
474
|
+
<FormLabel>{t('fields.dueDate')}</FormLabel>
|
|
475
|
+
<FormControl>
|
|
476
|
+
<Input
|
|
477
|
+
type="date"
|
|
478
|
+
{...field}
|
|
479
|
+
value={field.value || ''}
|
|
480
|
+
/>
|
|
481
|
+
</FormControl>
|
|
482
|
+
<FormMessage />
|
|
483
|
+
</FormItem>
|
|
484
|
+
)}
|
|
485
|
+
/>
|
|
486
|
+
</div>
|
|
487
|
+
|
|
488
|
+
<FormField
|
|
489
|
+
control={form.control}
|
|
490
|
+
name="valor"
|
|
491
|
+
render={({ field }) => (
|
|
492
|
+
<FormItem>
|
|
493
|
+
<FormLabel>{t('fields.totalValue')}</FormLabel>
|
|
494
|
+
<FormControl>
|
|
495
|
+
<InputMoney
|
|
496
|
+
ref={field.ref}
|
|
497
|
+
name={field.name}
|
|
498
|
+
value={field.value}
|
|
499
|
+
onBlur={field.onBlur}
|
|
500
|
+
onValueChange={(value) => field.onChange(value ?? 0)}
|
|
501
|
+
placeholder="0,00"
|
|
502
|
+
/>
|
|
503
|
+
</FormControl>
|
|
504
|
+
<FormMessage />
|
|
505
|
+
</FormItem>
|
|
506
|
+
)}
|
|
507
|
+
/>
|
|
508
|
+
|
|
509
|
+
<FormField
|
|
510
|
+
control={form.control}
|
|
511
|
+
name="categoriaId"
|
|
512
|
+
render={({ field }) => (
|
|
513
|
+
<FormItem>
|
|
514
|
+
<FormLabel>{t('fields.category')}</FormLabel>
|
|
515
|
+
<Select value={field.value} onValueChange={field.onChange}>
|
|
516
|
+
<FormControl>
|
|
517
|
+
<SelectTrigger>
|
|
518
|
+
<SelectValue placeholder={t('common.select')} />
|
|
519
|
+
</SelectTrigger>
|
|
520
|
+
</FormControl>
|
|
521
|
+
<SelectContent>
|
|
522
|
+
{categorias
|
|
523
|
+
.filter((c) => c.natureza === 'receita')
|
|
524
|
+
.map((c) => (
|
|
525
|
+
<SelectItem key={c.id} value={String(c.id)}>
|
|
526
|
+
{c.codigo} - {c.nome}
|
|
527
|
+
</SelectItem>
|
|
528
|
+
))}
|
|
529
|
+
</SelectContent>
|
|
530
|
+
</Select>
|
|
531
|
+
<FormMessage />
|
|
532
|
+
</FormItem>
|
|
533
|
+
)}
|
|
534
|
+
/>
|
|
535
|
+
|
|
536
|
+
<FormField
|
|
537
|
+
control={form.control}
|
|
538
|
+
name="centroCustoId"
|
|
539
|
+
render={({ field }) => (
|
|
540
|
+
<FormItem>
|
|
541
|
+
<FormLabel>{t('fields.costCenter')}</FormLabel>
|
|
542
|
+
<Select value={field.value} onValueChange={field.onChange}>
|
|
543
|
+
<FormControl>
|
|
544
|
+
<SelectTrigger>
|
|
545
|
+
<SelectValue placeholder={t('common.select')} />
|
|
546
|
+
</SelectTrigger>
|
|
547
|
+
</FormControl>
|
|
548
|
+
<SelectContent>
|
|
549
|
+
{centrosCusto.map((c) => (
|
|
550
|
+
<SelectItem key={c.id} value={String(c.id)}>
|
|
551
|
+
{c.codigo} - {c.nome}
|
|
552
|
+
</SelectItem>
|
|
553
|
+
))}
|
|
554
|
+
</SelectContent>
|
|
555
|
+
</Select>
|
|
556
|
+
<FormMessage />
|
|
557
|
+
</FormItem>
|
|
558
|
+
)}
|
|
559
|
+
/>
|
|
560
|
+
|
|
561
|
+
<FormField
|
|
562
|
+
control={form.control}
|
|
563
|
+
name="canal"
|
|
564
|
+
render={({ field }) => (
|
|
565
|
+
<FormItem>
|
|
566
|
+
<FormLabel>{t('fields.channel')}</FormLabel>
|
|
567
|
+
<Select value={field.value} onValueChange={field.onChange}>
|
|
568
|
+
<FormControl>
|
|
569
|
+
<SelectTrigger>
|
|
570
|
+
<SelectValue placeholder={t('common.select')} />
|
|
571
|
+
</SelectTrigger>
|
|
572
|
+
</FormControl>
|
|
573
|
+
<SelectContent>
|
|
574
|
+
<SelectItem value="boleto">
|
|
575
|
+
{t('channels.boleto')}
|
|
576
|
+
</SelectItem>
|
|
577
|
+
<SelectItem value="pix">PIX</SelectItem>
|
|
578
|
+
<SelectItem value="cartao">
|
|
579
|
+
{t('channels.card')}
|
|
580
|
+
</SelectItem>
|
|
581
|
+
<SelectItem value="transferencia">
|
|
582
|
+
{t('channels.transfer')}
|
|
583
|
+
</SelectItem>
|
|
584
|
+
</SelectContent>
|
|
585
|
+
</Select>
|
|
586
|
+
<FormMessage />
|
|
587
|
+
</FormItem>
|
|
588
|
+
)}
|
|
589
|
+
/>
|
|
590
|
+
|
|
591
|
+
<FormField
|
|
592
|
+
control={form.control}
|
|
593
|
+
name="descricao"
|
|
594
|
+
render={({ field }) => (
|
|
595
|
+
<FormItem>
|
|
596
|
+
<FormLabel>{t('fields.description')}</FormLabel>
|
|
597
|
+
<FormControl>
|
|
598
|
+
<Textarea
|
|
599
|
+
placeholder={t('newTitle.descriptionPlaceholder')}
|
|
600
|
+
{...field}
|
|
601
|
+
value={field.value || ''}
|
|
602
|
+
/>
|
|
603
|
+
</FormControl>
|
|
604
|
+
<FormMessage />
|
|
605
|
+
</FormItem>
|
|
606
|
+
)}
|
|
607
|
+
/>
|
|
608
|
+
</div>
|
|
609
|
+
|
|
610
|
+
<div className="flex justify-end gap-2 pt-4">
|
|
611
|
+
<Button type="button" variant="outline" onClick={handleCancel}>
|
|
612
|
+
{t('common.cancel')}
|
|
613
|
+
</Button>
|
|
614
|
+
<Button
|
|
615
|
+
type="submit"
|
|
616
|
+
disabled={
|
|
617
|
+
form.formState.isSubmitting ||
|
|
618
|
+
isUploadingFile ||
|
|
619
|
+
isExtractingFileData
|
|
620
|
+
}
|
|
621
|
+
>
|
|
622
|
+
{(isUploadingFile || isExtractingFileData) && (
|
|
623
|
+
<Loader2 className="mr-2 h-4 w-4 animate-spin" />
|
|
624
|
+
)}
|
|
625
|
+
{isExtractingFileData
|
|
626
|
+
? 'Preenchendo com IA...'
|
|
627
|
+
: isUploadingFile
|
|
628
|
+
? 'Enviando arquivo...'
|
|
629
|
+
: t('common.save')}
|
|
630
|
+
</Button>
|
|
631
|
+
</div>
|
|
632
|
+
</form>
|
|
633
|
+
</Form>
|
|
634
|
+
</SheetContent>
|
|
635
|
+
</Sheet>
|
|
636
|
+
);
|
|
637
|
+
}
|
|
638
|
+
|
|
639
|
+
export default function TitulosReceberPage() {
|
|
640
|
+
const t = useTranslations('finance.ReceivableInstallmentsPage');
|
|
641
|
+
const { request, showToastHandler } = useApp();
|
|
642
|
+
const { data, refetch } = useFinanceData();
|
|
643
|
+
const { titulosReceber, pessoas, categorias, centrosCusto } = data;
|
|
644
|
+
|
|
645
|
+
const getPessoaById = (id?: string) => pessoas.find((p) => p.id === id);
|
|
646
|
+
|
|
647
|
+
const [search, setSearch] = useState('');
|
|
648
|
+
const [statusFilter, setStatusFilter] = useState<string>('');
|
|
649
|
+
|
|
650
|
+
const canalBadge = {
|
|
651
|
+
boleto: {
|
|
652
|
+
label: t('channels.boleto'),
|
|
653
|
+
className: 'bg-blue-100 text-blue-700',
|
|
654
|
+
},
|
|
655
|
+
pix: { label: 'PIX', className: 'bg-green-100 text-green-700' },
|
|
656
|
+
cartao: {
|
|
657
|
+
label: t('channels.card'),
|
|
658
|
+
className: 'bg-purple-100 text-purple-700',
|
|
659
|
+
},
|
|
660
|
+
transferencia: {
|
|
661
|
+
label: t('channels.transfer'),
|
|
662
|
+
className: 'bg-orange-100 text-orange-700',
|
|
663
|
+
},
|
|
664
|
+
};
|
|
665
|
+
|
|
666
|
+
const filteredTitulos = titulosReceber.filter((titulo) => {
|
|
667
|
+
const matchesSearch =
|
|
668
|
+
titulo.documento.toLowerCase().includes(search.toLowerCase()) ||
|
|
669
|
+
getPessoaById(titulo.clienteId)
|
|
670
|
+
?.nome.toLowerCase()
|
|
671
|
+
.includes(search.toLowerCase());
|
|
672
|
+
|
|
673
|
+
const matchesStatus = !statusFilter || titulo.status === statusFilter;
|
|
674
|
+
|
|
675
|
+
return matchesSearch && matchesStatus;
|
|
676
|
+
});
|
|
677
|
+
|
|
678
|
+
const handleOpenAttachment = async (fileId?: string) => {
|
|
679
|
+
if (!fileId) {
|
|
680
|
+
return;
|
|
681
|
+
}
|
|
682
|
+
|
|
683
|
+
try {
|
|
684
|
+
const response = await request<{ url?: string }>({
|
|
685
|
+
url: `/file/open/${fileId}`,
|
|
686
|
+
method: 'PUT',
|
|
687
|
+
});
|
|
688
|
+
|
|
689
|
+
const url = response?.data?.url;
|
|
690
|
+
if (!url) {
|
|
691
|
+
showToastHandler?.('error', 'Não foi possível abrir o anexo');
|
|
692
|
+
return;
|
|
693
|
+
}
|
|
694
|
+
|
|
695
|
+
window.open(url, '_blank', 'noopener,noreferrer');
|
|
696
|
+
} catch {
|
|
697
|
+
showToastHandler?.('error', 'Não foi possível abrir o anexo');
|
|
698
|
+
}
|
|
699
|
+
};
|
|
700
|
+
|
|
701
|
+
return (
|
|
702
|
+
<Page>
|
|
703
|
+
<PageHeader
|
|
704
|
+
title={t('header.title')}
|
|
705
|
+
description={t('header.description')}
|
|
706
|
+
breadcrumbs={[
|
|
707
|
+
{ label: t('breadcrumbs.home'), href: '/' },
|
|
708
|
+
{ label: t('breadcrumbs.finance'), href: '/finance' },
|
|
709
|
+
{ label: t('breadcrumbs.current') },
|
|
710
|
+
]}
|
|
711
|
+
actions={
|
|
712
|
+
<NovoTituloSheet
|
|
713
|
+
categorias={categorias}
|
|
714
|
+
centrosCusto={centrosCusto}
|
|
715
|
+
t={t}
|
|
716
|
+
onCreated={refetch}
|
|
717
|
+
/>
|
|
718
|
+
}
|
|
719
|
+
/>
|
|
720
|
+
|
|
721
|
+
<FilterBar
|
|
722
|
+
searchPlaceholder={t('filters.searchPlaceholder')}
|
|
723
|
+
searchValue={search}
|
|
724
|
+
onSearchChange={setSearch}
|
|
725
|
+
filters={[
|
|
726
|
+
{
|
|
727
|
+
id: 'status',
|
|
728
|
+
label: t('filters.status'),
|
|
729
|
+
value: statusFilter,
|
|
730
|
+
onChange: setStatusFilter,
|
|
731
|
+
options: [
|
|
732
|
+
{ value: 'all', label: t('statuses.all') },
|
|
733
|
+
{ value: 'aberto', label: t('statuses.aberto') },
|
|
734
|
+
{ value: 'parcial', label: t('statuses.parcial') },
|
|
735
|
+
{ value: 'liquidado', label: t('statuses.liquidado') },
|
|
736
|
+
{ value: 'vencido', label: t('statuses.vencido') },
|
|
737
|
+
{ value: 'cancelado', label: t('statuses.cancelado') },
|
|
738
|
+
],
|
|
739
|
+
},
|
|
740
|
+
]}
|
|
741
|
+
activeFilters={statusFilter && statusFilter !== 'all' ? 1 : 0}
|
|
742
|
+
onClearFilters={() => setStatusFilter('')}
|
|
743
|
+
/>
|
|
744
|
+
|
|
745
|
+
<div className="rounded-md border">
|
|
746
|
+
<Table>
|
|
747
|
+
<TableHeader>
|
|
748
|
+
<TableRow>
|
|
749
|
+
<TableHead>{t('table.headers.document')}</TableHead>
|
|
750
|
+
<TableHead>{t('table.headers.client')}</TableHead>
|
|
751
|
+
<TableHead>{t('table.headers.competency')}</TableHead>
|
|
752
|
+
<TableHead>{t('table.headers.dueDate')}</TableHead>
|
|
753
|
+
<TableHead className="text-right">
|
|
754
|
+
{t('table.headers.value')}
|
|
755
|
+
</TableHead>
|
|
756
|
+
<TableHead>{t('table.headers.channel')}</TableHead>
|
|
757
|
+
<TableHead>{t('table.headers.status')}</TableHead>
|
|
758
|
+
<TableHead className="w-[50px]" />
|
|
759
|
+
</TableRow>
|
|
760
|
+
</TableHeader>
|
|
761
|
+
<TableBody>
|
|
762
|
+
{filteredTitulos.map((titulo) => {
|
|
763
|
+
const cliente = getPessoaById(titulo.clienteId);
|
|
764
|
+
const canal =
|
|
765
|
+
canalBadge[titulo.canal as keyof typeof canalBadge] ||
|
|
766
|
+
canalBadge.transferencia;
|
|
767
|
+
const proximaParcela = titulo.parcelas.find(
|
|
768
|
+
(p: any) => p.status === 'aberto' || p.status === 'vencido'
|
|
769
|
+
);
|
|
770
|
+
|
|
771
|
+
return (
|
|
772
|
+
<TableRow key={titulo.id}>
|
|
773
|
+
<TableCell className="font-medium">
|
|
774
|
+
<Link
|
|
775
|
+
href={`/finance/accounts-receivable/installments/${titulo.id}`}
|
|
776
|
+
className="hover:underline"
|
|
777
|
+
>
|
|
778
|
+
{titulo.documento}
|
|
779
|
+
</Link>
|
|
780
|
+
{titulo.anexos.length > 0 && (
|
|
781
|
+
<Button
|
|
782
|
+
type="button"
|
|
783
|
+
variant="ghost"
|
|
784
|
+
size="icon"
|
|
785
|
+
className="ml-1 inline-flex h-5 w-5 align-middle text-muted-foreground"
|
|
786
|
+
onClick={(event) => {
|
|
787
|
+
event.preventDefault();
|
|
788
|
+
event.stopPropagation();
|
|
789
|
+
const firstAttachmentId =
|
|
790
|
+
titulo.anexosDetalhes?.[0]?.id;
|
|
791
|
+
void handleOpenAttachment(firstAttachmentId);
|
|
792
|
+
}}
|
|
793
|
+
aria-label="Abrir anexo"
|
|
794
|
+
>
|
|
795
|
+
<Paperclip className="h-3 w-3" />
|
|
796
|
+
</Button>
|
|
797
|
+
)}
|
|
798
|
+
</TableCell>
|
|
799
|
+
<TableCell>{cliente?.nome}</TableCell>
|
|
800
|
+
<TableCell>{titulo.competencia}</TableCell>
|
|
801
|
+
<TableCell>
|
|
802
|
+
{proximaParcela
|
|
803
|
+
? formatarData(proximaParcela.vencimento)
|
|
804
|
+
: '-'}
|
|
805
|
+
</TableCell>
|
|
806
|
+
<TableCell className="text-right">
|
|
807
|
+
<Money value={titulo.valorTotal} />
|
|
808
|
+
</TableCell>
|
|
809
|
+
<TableCell>
|
|
810
|
+
<Badge className={canal.className} variant="outline">
|
|
811
|
+
{canal.label}
|
|
812
|
+
</Badge>
|
|
813
|
+
</TableCell>
|
|
814
|
+
<TableCell>
|
|
815
|
+
<StatusBadge status={titulo.status} />
|
|
816
|
+
</TableCell>
|
|
817
|
+
<TableCell>
|
|
818
|
+
<DropdownMenu>
|
|
819
|
+
<DropdownMenuTrigger asChild>
|
|
820
|
+
<Button variant="ghost" size="icon">
|
|
821
|
+
<MoreHorizontal className="h-4 w-4" />
|
|
822
|
+
<span className="sr-only">
|
|
823
|
+
{t('table.actions.srActions')}
|
|
824
|
+
</span>
|
|
825
|
+
</Button>
|
|
826
|
+
</DropdownMenuTrigger>
|
|
827
|
+
<DropdownMenuContent align="end">
|
|
828
|
+
<DropdownMenuItem asChild>
|
|
829
|
+
<Link
|
|
830
|
+
href={`/finance/accounts-receivable/installments/${titulo.id}`}
|
|
831
|
+
>
|
|
832
|
+
<Eye className="mr-2 h-4 w-4" />
|
|
833
|
+
{t('table.actions.viewDetails')}
|
|
834
|
+
</Link>
|
|
835
|
+
</DropdownMenuItem>
|
|
836
|
+
<DropdownMenuItem>
|
|
837
|
+
<Edit className="mr-2 h-4 w-4" />
|
|
838
|
+
{t('table.actions.edit')}
|
|
839
|
+
</DropdownMenuItem>
|
|
840
|
+
<DropdownMenuSeparator />
|
|
841
|
+
<DropdownMenuItem>
|
|
842
|
+
<Download className="mr-2 h-4 w-4" />
|
|
843
|
+
{t('table.actions.registerReceipt')}
|
|
844
|
+
</DropdownMenuItem>
|
|
845
|
+
<DropdownMenuItem>
|
|
846
|
+
<Send className="mr-2 h-4 w-4" />
|
|
847
|
+
{t('table.actions.sendCollection')}
|
|
848
|
+
</DropdownMenuItem>
|
|
849
|
+
</DropdownMenuContent>
|
|
850
|
+
</DropdownMenu>
|
|
851
|
+
</TableCell>
|
|
852
|
+
</TableRow>
|
|
853
|
+
);
|
|
854
|
+
})}
|
|
855
|
+
</TableBody>
|
|
856
|
+
</Table>
|
|
857
|
+
</div>
|
|
858
|
+
|
|
859
|
+
<div className="flex items-center justify-between">
|
|
860
|
+
<p className="text-sm text-muted-foreground">
|
|
861
|
+
{t('footer.showing', {
|
|
862
|
+
filtered: filteredTitulos.length,
|
|
863
|
+
total: titulosReceber.length,
|
|
864
|
+
})}
|
|
865
|
+
</p>
|
|
866
|
+
<div className="flex items-center gap-2">
|
|
867
|
+
<Button variant="outline" size="sm" disabled>
|
|
868
|
+
{t('footer.previous')}
|
|
869
|
+
</Button>
|
|
870
|
+
<Button variant="outline" size="sm" disabled>
|
|
871
|
+
{t('footer.next')}
|
|
872
|
+
</Button>
|
|
873
|
+
</div>
|
|
874
|
+
</div>
|
|
875
|
+
</Page>
|
|
876
|
+
);
|
|
877
|
+
}
|