@hed-hog/finance 0.0.300 → 0.0.301
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/finance.contract-activated.subscriber.d.ts +24 -0
- package/dist/finance.contract-activated.subscriber.d.ts.map +1 -0
- package/dist/finance.contract-activated.subscriber.js +519 -0
- package/dist/finance.contract-activated.subscriber.js.map +1 -0
- package/dist/finance.contract-activated.subscriber.spec.d.ts +2 -0
- package/dist/finance.contract-activated.subscriber.spec.d.ts.map +1 -0
- package/dist/finance.contract-activated.subscriber.spec.js +302 -0
- package/dist/finance.contract-activated.subscriber.spec.js.map +1 -0
- package/dist/finance.module.d.ts.map +1 -1
- package/dist/finance.module.js +6 -1
- package/dist/finance.module.js.map +1 -1
- package/hedhog/frontend/app/_components/finance-layout.tsx.ejs +108 -0
- package/hedhog/frontend/app/accounts-payable/approvals/page.tsx.ejs +91 -106
- package/hedhog/frontend/app/accounts-payable/installments/page.tsx.ejs +1306 -1145
- package/hedhog/frontend/app/accounts-receivable/collections-default/page.tsx.ejs +288 -268
- package/hedhog/frontend/app/accounts-receivable/installments/page.tsx.ejs +491 -351
- package/hedhog/frontend/app/administration/audit-logs/page.tsx.ejs +157 -173
- package/hedhog/frontend/app/administration/categories/page.tsx.ejs +44 -62
- package/hedhog/frontend/app/administration/cost-centers/page.tsx.ejs +62 -80
- package/hedhog/frontend/app/administration/period-close/page.tsx.ejs +151 -170
- package/hedhog/frontend/app/cash-and-banks/bank-accounts/page.tsx.ejs +332 -286
- package/hedhog/frontend/app/cash-and-banks/bank-reconciliation/page.tsx.ejs +204 -226
- package/hedhog/frontend/app/cash-and-banks/statements/page.tsx.ejs +122 -140
- package/hedhog/frontend/app/cash-and-banks/transfers/page.tsx.ejs +32 -49
- package/hedhog/frontend/app/planning/cash-flow-forecast/page.tsx.ejs +84 -108
- package/hedhog/frontend/app/planning/receivables-calendar/page.tsx.ejs +53 -70
- package/hedhog/frontend/app/planning/scenarios/page.tsx.ejs +98 -95
- package/hedhog/frontend/app/reports/actual-vs-forecast/page.tsx.ejs +100 -125
- package/hedhog/frontend/app/reports/aging-default/page.tsx.ejs +77 -105
- package/hedhog/frontend/app/reports/cash-position/page.tsx.ejs +99 -134
- package/hedhog/frontend/app/reports/overview-results/page.tsx.ejs +147 -182
- package/hedhog/frontend/app/reports/top-customers/page.tsx.ejs +49 -61
- package/hedhog/frontend/app/reports/top-operational-expenses/page.tsx.ejs +49 -67
- package/hedhog/frontend/messages/en.json +176 -68
- package/hedhog/frontend/messages/pt.json +176 -68
- package/package.json +7 -6
- package/src/finance.contract-activated.subscriber.spec.ts +392 -0
- package/src/finance.contract-activated.subscriber.ts +780 -0
- package/src/finance.module.ts +6 -1
|
@@ -1,28 +1,39 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
|
|
3
|
-
import {
|
|
4
|
-
CategoryFieldWithCreate,
|
|
5
|
-
CostCenterFieldWithCreate,
|
|
6
|
-
} from '@/app/(app)/(libraries)/finance/_components/finance-entity-field-with-create';
|
|
7
|
-
import {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
import {
|
|
13
|
-
import {
|
|
14
|
-
|
|
15
|
-
|
|
3
|
+
import {
|
|
4
|
+
CategoryFieldWithCreate,
|
|
5
|
+
CostCenterFieldWithCreate,
|
|
6
|
+
} from '@/app/(app)/(libraries)/finance/_components/finance-entity-field-with-create';
|
|
7
|
+
import {
|
|
8
|
+
FinancePageSection,
|
|
9
|
+
FinanceSheetBody,
|
|
10
|
+
FinanceSheetSection,
|
|
11
|
+
} from '@/app/(app)/(libraries)/finance/_components/finance-layout';
|
|
12
|
+
import { FinanceTitleActionsMenu } from '@/app/(app)/(libraries)/finance/_components/finance-title-actions-menu';
|
|
13
|
+
import { PersonFieldWithCreate } from '@/app/(app)/(libraries)/contact/person/_components/person-field-with-create';
|
|
14
|
+
import {
|
|
15
|
+
EmptyState,
|
|
16
|
+
Page,
|
|
17
|
+
PageHeader,
|
|
18
|
+
PaginationFooter,
|
|
19
|
+
SearchBar,
|
|
20
|
+
} from '@/components/entity-list';
|
|
21
|
+
import { Button } from '@/components/ui/button';
|
|
22
|
+
import { Checkbox } from '@/components/ui/checkbox';
|
|
23
|
+
import {
|
|
24
|
+
Form,
|
|
25
|
+
FormControl,
|
|
16
26
|
FormField,
|
|
17
27
|
FormItem,
|
|
18
28
|
FormLabel,
|
|
19
|
-
FormMessage,
|
|
20
|
-
} from '@/components/ui/form';
|
|
21
|
-
import { Input } from '@/components/ui/input';
|
|
22
|
-
import { InputMoney } from '@/components/ui/input-money';
|
|
23
|
-
import {
|
|
24
|
-
import {
|
|
25
|
-
import {
|
|
29
|
+
FormMessage,
|
|
30
|
+
} from '@/components/ui/form';
|
|
31
|
+
import { Input } from '@/components/ui/input';
|
|
32
|
+
import { InputMoney } from '@/components/ui/input-money';
|
|
33
|
+
import { KpiCardsGrid } from '@/components/ui/kpi-cards-grid';
|
|
34
|
+
import { Label } from '@/components/ui/label';
|
|
35
|
+
import { Money } from '@/components/ui/money';
|
|
36
|
+
import { Progress } from '@/components/ui/progress';
|
|
26
37
|
import {
|
|
27
38
|
Select,
|
|
28
39
|
SelectContent,
|
|
@@ -53,16 +64,18 @@ import {
|
|
|
53
64
|
TooltipContent,
|
|
54
65
|
TooltipTrigger,
|
|
55
66
|
} from '@/components/ui/tooltip';
|
|
56
|
-
import { useApp, useQuery } from '@hed-hog/next-app-provider';
|
|
57
|
-
import { zodResolver } from '@hookform/resolvers/zod';
|
|
58
|
-
import {
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
67
|
+
import { useApp, useQuery } from '@hed-hog/next-app-provider';
|
|
68
|
+
import { zodResolver } from '@hookform/resolvers/zod';
|
|
69
|
+
import {
|
|
70
|
+
AlertTriangle,
|
|
71
|
+
FileText,
|
|
72
|
+
Loader2,
|
|
73
|
+
Paperclip,
|
|
74
|
+
Plus,
|
|
75
|
+
Trash2,
|
|
76
|
+
Upload,
|
|
77
|
+
Wallet,
|
|
78
|
+
} from 'lucide-react';
|
|
66
79
|
import { useTranslations } from 'next-intl';
|
|
67
80
|
import Link from 'next/link';
|
|
68
81
|
import { usePathname, useRouter, useSearchParams } from 'next/navigation';
|
|
@@ -649,37 +662,44 @@ function NovoTituloSheet({
|
|
|
649
662
|
{t('newTitle.action')}
|
|
650
663
|
</Button>
|
|
651
664
|
</SheetTrigger>
|
|
652
|
-
<SheetContent className="w-full sm:max-w-lg
|
|
653
|
-
<SheetHeader>
|
|
654
|
-
<SheetTitle>{t('newTitle.title')}</SheetTitle>
|
|
655
|
-
<SheetDescription>{t('newTitle.description')}</SheetDescription>
|
|
656
|
-
</SheetHeader>
|
|
657
|
-
<Form {...form}>
|
|
658
|
-
<form
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
665
|
+
<SheetContent className="flex h-full w-full flex-col overflow-hidden p-0 sm:max-w-xl lg:max-w-4xl">
|
|
666
|
+
<SheetHeader className="border-b border-border/50 px-4 py-4 sm:px-6">
|
|
667
|
+
<SheetTitle>{t('newTitle.title')}</SheetTitle>
|
|
668
|
+
<SheetDescription>{t('newTitle.description')}</SheetDescription>
|
|
669
|
+
</SheetHeader>
|
|
670
|
+
<Form {...form}>
|
|
671
|
+
<form
|
|
672
|
+
className="flex h-full flex-col overflow-hidden"
|
|
673
|
+
onSubmit={form.handleSubmit(handleSubmit)}
|
|
674
|
+
>
|
|
675
|
+
<FinanceSheetBody>
|
|
676
|
+
<FinanceSheetSection
|
|
677
|
+
title={t('sections.main.title')}
|
|
678
|
+
description={t('sections.main.description')}
|
|
679
|
+
>
|
|
680
|
+
<div className="grid grid-cols-1 items-start gap-4 xl:grid-cols-[minmax(0,1.15fr)_minmax(0,0.85fr)]">
|
|
681
|
+
<div className="grid gap-2">
|
|
682
|
+
<FormLabel>{t('common.upload.label')}</FormLabel>
|
|
683
|
+
<Input
|
|
684
|
+
ref={fileInputRef}
|
|
685
|
+
className="hidden"
|
|
686
|
+
type="file"
|
|
687
|
+
accept=".pdf,.png,.jpg,.jpeg,.xml,.txt"
|
|
688
|
+
onChange={(event) => {
|
|
689
|
+
const file = event.target.files?.[0];
|
|
690
|
+
if (!file) {
|
|
691
|
+
return;
|
|
692
|
+
}
|
|
693
|
+
|
|
694
|
+
clearUploadedFile();
|
|
695
|
+
void uploadRelatedFile(file);
|
|
696
|
+
}}
|
|
697
|
+
disabled={
|
|
698
|
+
isUploadingFile ||
|
|
699
|
+
isExtractingFileData ||
|
|
700
|
+
form.formState.isSubmitting
|
|
701
|
+
}
|
|
702
|
+
/>
|
|
683
703
|
|
|
684
704
|
<div className="grid w-full grid-cols-2 gap-2">
|
|
685
705
|
<Tooltip>
|
|
@@ -744,12 +764,12 @@ function NovoTituloSheet({
|
|
|
744
764
|
)}
|
|
745
765
|
</div>
|
|
746
766
|
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
767
|
+
<div className="space-y-1 rounded-lg border border-dashed border-border/70 bg-muted/20 p-3">
|
|
768
|
+
{uploadedFileId && (
|
|
769
|
+
<p className="truncate text-xs text-muted-foreground">
|
|
770
|
+
{t('common.upload.selectedPrefix')} {uploadedFileName}
|
|
771
|
+
</p>
|
|
772
|
+
)}
|
|
753
773
|
|
|
754
774
|
{isUploadingFile && !isExtractingFileData && (
|
|
755
775
|
<div className="space-y-1">
|
|
@@ -779,364 +799,388 @@ function NovoTituloSheet({
|
|
|
779
799
|
</p>
|
|
780
800
|
)}
|
|
781
801
|
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
<
|
|
796
|
-
|
|
797
|
-
<
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
|
|
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
|
-
|
|
862
|
-
|
|
863
|
-
|
|
864
|
-
|
|
865
|
-
|
|
866
|
-
|
|
867
|
-
|
|
868
|
-
|
|
869
|
-
|
|
870
|
-
|
|
871
|
-
|
|
872
|
-
|
|
873
|
-
|
|
874
|
-
|
|
875
|
-
|
|
876
|
-
|
|
877
|
-
|
|
878
|
-
<
|
|
879
|
-
|
|
880
|
-
|
|
881
|
-
|
|
882
|
-
<
|
|
883
|
-
|
|
884
|
-
|
|
885
|
-
|
|
886
|
-
|
|
887
|
-
|
|
888
|
-
|
|
889
|
-
|
|
890
|
-
|
|
891
|
-
|
|
892
|
-
|
|
893
|
-
|
|
894
|
-
|
|
895
|
-
|
|
896
|
-
|
|
897
|
-
|
|
898
|
-
|
|
899
|
-
|
|
900
|
-
|
|
901
|
-
|
|
902
|
-
|
|
903
|
-
|
|
904
|
-
|
|
905
|
-
|
|
906
|
-
|
|
907
|
-
|
|
908
|
-
|
|
909
|
-
|
|
910
|
-
|
|
911
|
-
|
|
912
|
-
|
|
913
|
-
|
|
914
|
-
|
|
915
|
-
|
|
916
|
-
|
|
917
|
-
|
|
918
|
-
|
|
919
|
-
|
|
920
|
-
|
|
921
|
-
|
|
922
|
-
|
|
923
|
-
|
|
924
|
-
|
|
925
|
-
|
|
926
|
-
|
|
927
|
-
|
|
928
|
-
|
|
929
|
-
|
|
930
|
-
|
|
931
|
-
|
|
932
|
-
|
|
933
|
-
|
|
934
|
-
|
|
935
|
-
|
|
936
|
-
|
|
937
|
-
|
|
938
|
-
|
|
939
|
-
|
|
940
|
-
|
|
941
|
-
|
|
942
|
-
|
|
943
|
-
|
|
944
|
-
|
|
945
|
-
|
|
946
|
-
|
|
947
|
-
|
|
948
|
-
|
|
949
|
-
|
|
950
|
-
|
|
951
|
-
|
|
952
|
-
|
|
953
|
-
|
|
954
|
-
|
|
955
|
-
|
|
956
|
-
|
|
957
|
-
|
|
958
|
-
|
|
959
|
-
|
|
960
|
-
|
|
961
|
-
|
|
962
|
-
|
|
963
|
-
|
|
964
|
-
|
|
965
|
-
|
|
966
|
-
|
|
967
|
-
|
|
968
|
-
|
|
969
|
-
|
|
970
|
-
|
|
971
|
-
field.
|
|
972
|
-
|
|
973
|
-
|
|
974
|
-
|
|
975
|
-
|
|
976
|
-
|
|
977
|
-
|
|
978
|
-
|
|
979
|
-
|
|
980
|
-
|
|
981
|
-
|
|
982
|
-
|
|
983
|
-
|
|
984
|
-
|
|
985
|
-
|
|
986
|
-
|
|
987
|
-
|
|
988
|
-
|
|
989
|
-
|
|
990
|
-
|
|
991
|
-
|
|
992
|
-
|
|
993
|
-
|
|
994
|
-
field.
|
|
995
|
-
|
|
996
|
-
|
|
997
|
-
|
|
998
|
-
|
|
999
|
-
|
|
1000
|
-
|
|
1001
|
-
|
|
1002
|
-
|
|
1003
|
-
|
|
1004
|
-
|
|
1005
|
-
|
|
1006
|
-
|
|
1007
|
-
|
|
1008
|
-
|
|
1009
|
-
|
|
1010
|
-
|
|
1011
|
-
|
|
1012
|
-
|
|
1013
|
-
|
|
1014
|
-
|
|
1015
|
-
|
|
1016
|
-
|
|
1017
|
-
|
|
1018
|
-
|
|
1019
|
-
|
|
1020
|
-
|
|
1021
|
-
|
|
1022
|
-
|
|
1023
|
-
|
|
1024
|
-
|
|
1025
|
-
|
|
1026
|
-
|
|
1027
|
-
|
|
1028
|
-
|
|
1029
|
-
|
|
1030
|
-
|
|
1031
|
-
|
|
1032
|
-
|
|
1033
|
-
|
|
1034
|
-
|
|
1035
|
-
|
|
1036
|
-
|
|
1037
|
-
|
|
1038
|
-
|
|
1039
|
-
|
|
1040
|
-
|
|
1041
|
-
|
|
1042
|
-
|
|
1043
|
-
|
|
1044
|
-
|
|
1045
|
-
|
|
1046
|
-
|
|
1047
|
-
|
|
1048
|
-
|
|
1049
|
-
|
|
1050
|
-
|
|
1051
|
-
|
|
1052
|
-
|
|
1053
|
-
|
|
1054
|
-
|
|
1055
|
-
|
|
1056
|
-
|
|
1057
|
-
|
|
1058
|
-
|
|
1059
|
-
|
|
1060
|
-
|
|
1061
|
-
|
|
1062
|
-
|
|
1063
|
-
|
|
1064
|
-
|
|
1065
|
-
|
|
1066
|
-
|
|
1067
|
-
|
|
1068
|
-
|
|
1069
|
-
|
|
1070
|
-
|
|
1071
|
-
|
|
1072
|
-
|
|
1073
|
-
|
|
1074
|
-
|
|
1075
|
-
|
|
1076
|
-
|
|
1077
|
-
|
|
1078
|
-
|
|
1079
|
-
|
|
1080
|
-
|
|
1081
|
-
|
|
1082
|
-
|
|
1083
|
-
|
|
1084
|
-
|
|
1085
|
-
|
|
1086
|
-
|
|
1087
|
-
|
|
1088
|
-
|
|
1089
|
-
|
|
1090
|
-
|
|
1091
|
-
|
|
1092
|
-
|
|
1093
|
-
|
|
1094
|
-
|
|
1095
|
-
|
|
1096
|
-
|
|
1097
|
-
|
|
1098
|
-
|
|
1099
|
-
|
|
1100
|
-
|
|
1101
|
-
|
|
1102
|
-
|
|
1103
|
-
|
|
1104
|
-
|
|
1105
|
-
|
|
1106
|
-
|
|
1107
|
-
|
|
1108
|
-
|
|
1109
|
-
|
|
1110
|
-
|
|
1111
|
-
|
|
1112
|
-
|
|
1113
|
-
|
|
1114
|
-
)}
|
|
1115
|
-
|
|
1116
|
-
|
|
1117
|
-
|
|
1118
|
-
|
|
1119
|
-
|
|
1120
|
-
|
|
1121
|
-
|
|
1122
|
-
|
|
1123
|
-
|
|
1124
|
-
|
|
1125
|
-
|
|
1126
|
-
|
|
1127
|
-
|
|
1128
|
-
|
|
1129
|
-
|
|
1130
|
-
|
|
1131
|
-
|
|
1132
|
-
|
|
1133
|
-
|
|
1134
|
-
|
|
1135
|
-
|
|
1136
|
-
|
|
1137
|
-
|
|
1138
|
-
|
|
1139
|
-
|
|
802
|
+
{!isExtractingFileData &&
|
|
803
|
+
extractionWarnings.length > 0 && (
|
|
804
|
+
<p className="truncate text-xs text-muted-foreground">
|
|
805
|
+
{extractionWarnings[0]}
|
|
806
|
+
</p>
|
|
807
|
+
)}
|
|
808
|
+
</div>
|
|
809
|
+
</div>
|
|
810
|
+
|
|
811
|
+
<FormField
|
|
812
|
+
control={form.control}
|
|
813
|
+
name="documento"
|
|
814
|
+
render={({ field }) => (
|
|
815
|
+
<FormItem>
|
|
816
|
+
<FormLabel>{t('fields.document')}</FormLabel>
|
|
817
|
+
<FormControl>
|
|
818
|
+
<Input placeholder="NF-00000" {...field} />
|
|
819
|
+
</FormControl>
|
|
820
|
+
<FormMessage />
|
|
821
|
+
</FormItem>
|
|
822
|
+
)}
|
|
823
|
+
/>
|
|
824
|
+
</div>
|
|
825
|
+
|
|
826
|
+
<PersonFieldWithCreate
|
|
827
|
+
form={form}
|
|
828
|
+
name="fornecedorId"
|
|
829
|
+
label={t('fields.supplier')}
|
|
830
|
+
entityLabel="fornecedor"
|
|
831
|
+
selectPlaceholder={t('common.select')}
|
|
832
|
+
/>
|
|
833
|
+
|
|
834
|
+
<div className="grid gap-4 md:grid-cols-2">
|
|
835
|
+
<FormField
|
|
836
|
+
control={form.control}
|
|
837
|
+
name="competencia"
|
|
838
|
+
render={({ field }) => (
|
|
839
|
+
<FormItem>
|
|
840
|
+
<FormLabel>{t('fields.competency')}</FormLabel>
|
|
841
|
+
<FormControl>
|
|
842
|
+
<Input
|
|
843
|
+
type="month"
|
|
844
|
+
{...field}
|
|
845
|
+
value={field.value || ''}
|
|
846
|
+
/>
|
|
847
|
+
</FormControl>
|
|
848
|
+
<FormMessage />
|
|
849
|
+
</FormItem>
|
|
850
|
+
)}
|
|
851
|
+
/>
|
|
852
|
+
|
|
853
|
+
<FormField
|
|
854
|
+
control={form.control}
|
|
855
|
+
name="vencimento"
|
|
856
|
+
render={({ field }) => (
|
|
857
|
+
<FormItem>
|
|
858
|
+
<FormLabel>{t('fields.dueDate')}</FormLabel>
|
|
859
|
+
<FormControl>
|
|
860
|
+
<Input
|
|
861
|
+
type="date"
|
|
862
|
+
{...field}
|
|
863
|
+
value={field.value || ''}
|
|
864
|
+
/>
|
|
865
|
+
</FormControl>
|
|
866
|
+
<FormMessage />
|
|
867
|
+
</FormItem>
|
|
868
|
+
)}
|
|
869
|
+
/>
|
|
870
|
+
</div>
|
|
871
|
+
|
|
872
|
+
<div className="grid gap-4 md:grid-cols-2">
|
|
873
|
+
<FormField
|
|
874
|
+
control={form.control}
|
|
875
|
+
name="valor"
|
|
876
|
+
render={({ field }) => (
|
|
877
|
+
<FormItem>
|
|
878
|
+
<FormLabel>{t('fields.totalValue')}</FormLabel>
|
|
879
|
+
<FormControl>
|
|
880
|
+
<InputMoney
|
|
881
|
+
ref={field.ref}
|
|
882
|
+
name={field.name}
|
|
883
|
+
value={field.value}
|
|
884
|
+
onBlur={field.onBlur}
|
|
885
|
+
onValueChange={(value) => field.onChange(value ?? 0)}
|
|
886
|
+
placeholder="0,00"
|
|
887
|
+
/>
|
|
888
|
+
</FormControl>
|
|
889
|
+
<FormMessage />
|
|
890
|
+
</FormItem>
|
|
891
|
+
)}
|
|
892
|
+
/>
|
|
893
|
+
|
|
894
|
+
<FormField
|
|
895
|
+
control={form.control}
|
|
896
|
+
name="installmentsCount"
|
|
897
|
+
render={({ field }) => (
|
|
898
|
+
<FormItem>
|
|
899
|
+
<FormLabel>
|
|
900
|
+
{t('installmentsEditor.countLabel')}
|
|
901
|
+
</FormLabel>
|
|
902
|
+
<FormControl>
|
|
903
|
+
<Input
|
|
904
|
+
type="number"
|
|
905
|
+
min={1}
|
|
906
|
+
max={120}
|
|
907
|
+
value={field.value}
|
|
908
|
+
onChange={(event) => {
|
|
909
|
+
const nextValue = Number(event.target.value || 1);
|
|
910
|
+
field.onChange(
|
|
911
|
+
Number.isNaN(nextValue) ? 1 : nextValue
|
|
912
|
+
);
|
|
913
|
+
}}
|
|
914
|
+
/>
|
|
915
|
+
</FormControl>
|
|
916
|
+
<FormMessage />
|
|
917
|
+
</FormItem>
|
|
918
|
+
)}
|
|
919
|
+
/>
|
|
920
|
+
</div>
|
|
921
|
+
</FinanceSheetSection>
|
|
922
|
+
|
|
923
|
+
<FinanceSheetSection
|
|
924
|
+
title={t('sections.installments.title')}
|
|
925
|
+
description={t('sections.installments.description')}
|
|
926
|
+
>
|
|
927
|
+
<div className="space-y-3">
|
|
928
|
+
<div className="flex flex-col gap-3 xl:flex-row xl:items-center xl:justify-between">
|
|
929
|
+
<div className="flex items-center gap-2">
|
|
930
|
+
<Checkbox
|
|
931
|
+
id="auto-redistribute-installments-payable"
|
|
932
|
+
checked={autoRedistributeInstallments}
|
|
933
|
+
onCheckedChange={(checked) =>
|
|
934
|
+
setAutoRedistributeInstallments(checked === true)
|
|
935
|
+
}
|
|
936
|
+
/>
|
|
937
|
+
<Label
|
|
938
|
+
htmlFor="auto-redistribute-installments-payable"
|
|
939
|
+
className="text-xs text-muted-foreground"
|
|
940
|
+
>
|
|
941
|
+
{t('installmentsEditor.autoRedistributeLabel')}
|
|
942
|
+
</Label>
|
|
943
|
+
</div>
|
|
944
|
+
<Button
|
|
945
|
+
type="button"
|
|
946
|
+
variant="outline"
|
|
947
|
+
size="sm"
|
|
948
|
+
onClick={() => {
|
|
949
|
+
setIsInstallmentsEdited(false);
|
|
950
|
+
replaceInstallments(
|
|
951
|
+
buildEqualInstallments(
|
|
952
|
+
form.getValues('installmentsCount'),
|
|
953
|
+
form.getValues('valor'),
|
|
954
|
+
form.getValues('vencimento')
|
|
955
|
+
)
|
|
956
|
+
);
|
|
957
|
+
}}
|
|
958
|
+
>
|
|
959
|
+
{t('installmentsEditor.recalculate')}
|
|
960
|
+
</Button>
|
|
961
|
+
</div>
|
|
962
|
+
|
|
963
|
+
{autoRedistributeInstallments && (
|
|
964
|
+
<p className="text-xs text-muted-foreground">
|
|
965
|
+
{t('installmentsEditor.autoRedistributeHint')}
|
|
966
|
+
</p>
|
|
967
|
+
)}
|
|
968
|
+
|
|
969
|
+
<div className="space-y-2">
|
|
970
|
+
{installmentFields.map((installment, index) => (
|
|
971
|
+
<div
|
|
972
|
+
key={installment.id}
|
|
973
|
+
className="grid grid-cols-1 items-start gap-3 rounded-lg border border-border/60 bg-background p-3 sm:grid-cols-[96px_1fr_180px]"
|
|
974
|
+
>
|
|
975
|
+
<div className="flex items-center text-sm text-muted-foreground">
|
|
976
|
+
#{index + 1}
|
|
977
|
+
</div>
|
|
978
|
+
|
|
979
|
+
<FormField
|
|
980
|
+
control={form.control}
|
|
981
|
+
name={`installments.${index}.dueDate` as const}
|
|
982
|
+
render={({ field }) => (
|
|
983
|
+
<FormItem>
|
|
984
|
+
<FormLabel className="text-xs">
|
|
985
|
+
{t('installmentsEditor.dueDateLabel')}
|
|
986
|
+
</FormLabel>
|
|
987
|
+
<FormControl>
|
|
988
|
+
<Input
|
|
989
|
+
type="date"
|
|
990
|
+
{...field}
|
|
991
|
+
value={field.value || ''}
|
|
992
|
+
onChange={(event) => {
|
|
993
|
+
setIsInstallmentsEdited(true);
|
|
994
|
+
field.onChange(event);
|
|
995
|
+
}}
|
|
996
|
+
/>
|
|
997
|
+
</FormControl>
|
|
998
|
+
<FormMessage />
|
|
999
|
+
</FormItem>
|
|
1000
|
+
)}
|
|
1001
|
+
/>
|
|
1002
|
+
|
|
1003
|
+
<FormField
|
|
1004
|
+
control={form.control}
|
|
1005
|
+
name={`installments.${index}.amount` as const}
|
|
1006
|
+
render={({ field }) => (
|
|
1007
|
+
<FormItem>
|
|
1008
|
+
<FormLabel className="text-xs">
|
|
1009
|
+
{t('installmentsEditor.amountLabel')}
|
|
1010
|
+
</FormLabel>
|
|
1011
|
+
<FormControl>
|
|
1012
|
+
<InputMoney
|
|
1013
|
+
ref={field.ref}
|
|
1014
|
+
name={field.name}
|
|
1015
|
+
value={field.value}
|
|
1016
|
+
onBlur={() => {
|
|
1017
|
+
field.onBlur();
|
|
1018
|
+
|
|
1019
|
+
if (!autoRedistributeInstallments) {
|
|
1020
|
+
return;
|
|
1021
|
+
}
|
|
1022
|
+
|
|
1023
|
+
clearScheduledRedistribution(index);
|
|
1024
|
+
runInstallmentRedistribution(index);
|
|
1025
|
+
}}
|
|
1026
|
+
onValueChange={(value) => {
|
|
1027
|
+
setIsInstallmentsEdited(true);
|
|
1028
|
+
field.onChange(value ?? 0);
|
|
1029
|
+
|
|
1030
|
+
if (!autoRedistributeInstallments) {
|
|
1031
|
+
return;
|
|
1032
|
+
}
|
|
1033
|
+
|
|
1034
|
+
scheduleInstallmentRedistribution(index);
|
|
1035
|
+
}}
|
|
1036
|
+
placeholder="0,00"
|
|
1037
|
+
/>
|
|
1038
|
+
</FormControl>
|
|
1039
|
+
<FormMessage />
|
|
1040
|
+
</FormItem>
|
|
1041
|
+
)}
|
|
1042
|
+
/>
|
|
1043
|
+
</div>
|
|
1044
|
+
))}
|
|
1045
|
+
</div>
|
|
1046
|
+
|
|
1047
|
+
<p
|
|
1048
|
+
className={`text-xs ${
|
|
1049
|
+
installmentsDiffCents === 0
|
|
1050
|
+
? 'text-muted-foreground'
|
|
1051
|
+
: 'text-destructive'
|
|
1052
|
+
}`}
|
|
1053
|
+
>
|
|
1054
|
+
{t('installmentsEditor.totalPrefix', {
|
|
1055
|
+
total: installmentsTotal.toFixed(2),
|
|
1056
|
+
})}
|
|
1057
|
+
{installmentsDiffCents > 0 &&
|
|
1058
|
+
` ${t('installmentsEditor.adjustmentNeeded')}`}
|
|
1059
|
+
</p>
|
|
1060
|
+
{form.formState.errors.installments?.message && (
|
|
1061
|
+
<p className="text-xs text-destructive">
|
|
1062
|
+
{form.formState.errors.installments.message}
|
|
1063
|
+
</p>
|
|
1064
|
+
)}
|
|
1065
|
+
</div>
|
|
1066
|
+
</FinanceSheetSection>
|
|
1067
|
+
|
|
1068
|
+
<FinanceSheetSection
|
|
1069
|
+
title={t('sections.classification.title')}
|
|
1070
|
+
description={t('sections.classification.description')}
|
|
1071
|
+
>
|
|
1072
|
+
<div className="grid gap-4 xl:grid-cols-3">
|
|
1073
|
+
<CategoryFieldWithCreate
|
|
1074
|
+
form={form}
|
|
1075
|
+
name="categoriaId"
|
|
1076
|
+
label={t('fields.category')}
|
|
1077
|
+
selectPlaceholder={t('common.select')}
|
|
1078
|
+
categories={categorias}
|
|
1079
|
+
categoryKind="despesa"
|
|
1080
|
+
onCreated={onCategoriesUpdated}
|
|
1081
|
+
/>
|
|
1082
|
+
|
|
1083
|
+
<CostCenterFieldWithCreate
|
|
1084
|
+
form={form}
|
|
1085
|
+
name="centroCustoId"
|
|
1086
|
+
label={t('fields.costCenter')}
|
|
1087
|
+
selectPlaceholder={t('common.select')}
|
|
1088
|
+
costCenters={centrosCusto}
|
|
1089
|
+
onCreated={onCostCentersUpdated}
|
|
1090
|
+
/>
|
|
1091
|
+
|
|
1092
|
+
<FormField
|
|
1093
|
+
control={form.control}
|
|
1094
|
+
name="metodo"
|
|
1095
|
+
render={({ field }) => (
|
|
1096
|
+
<FormItem>
|
|
1097
|
+
<FormLabel>{t('fields.paymentMethod')}</FormLabel>
|
|
1098
|
+
<Select
|
|
1099
|
+
value={field.value}
|
|
1100
|
+
onValueChange={field.onChange}
|
|
1101
|
+
>
|
|
1102
|
+
<FormControl>
|
|
1103
|
+
<SelectTrigger className="w-full">
|
|
1104
|
+
<SelectValue placeholder={t('common.select')} />
|
|
1105
|
+
</SelectTrigger>
|
|
1106
|
+
</FormControl>
|
|
1107
|
+
<SelectContent>
|
|
1108
|
+
<SelectItem value="boleto">
|
|
1109
|
+
{t('paymentMethods.boleto')}
|
|
1110
|
+
</SelectItem>
|
|
1111
|
+
<SelectItem value="pix">PIX</SelectItem>
|
|
1112
|
+
<SelectItem value="transferencia">
|
|
1113
|
+
{t('paymentMethods.transfer')}
|
|
1114
|
+
</SelectItem>
|
|
1115
|
+
<SelectItem value="cartao">
|
|
1116
|
+
{t('paymentMethods.card')}
|
|
1117
|
+
</SelectItem>
|
|
1118
|
+
<SelectItem value="dinheiro">
|
|
1119
|
+
{t('paymentMethods.cash')}
|
|
1120
|
+
</SelectItem>
|
|
1121
|
+
<SelectItem value="cheque">
|
|
1122
|
+
{t('paymentMethods.check')}
|
|
1123
|
+
</SelectItem>
|
|
1124
|
+
</SelectContent>
|
|
1125
|
+
</Select>
|
|
1126
|
+
<FormMessage />
|
|
1127
|
+
</FormItem>
|
|
1128
|
+
)}
|
|
1129
|
+
/>
|
|
1130
|
+
</div>
|
|
1131
|
+
</FinanceSheetSection>
|
|
1132
|
+
|
|
1133
|
+
<FinanceSheetSection
|
|
1134
|
+
title={t('sections.notes.title')}
|
|
1135
|
+
description={t('sections.notes.description')}
|
|
1136
|
+
>
|
|
1137
|
+
<FormField
|
|
1138
|
+
control={form.control}
|
|
1139
|
+
name="descricao"
|
|
1140
|
+
render={({ field }) => (
|
|
1141
|
+
<FormItem>
|
|
1142
|
+
<FormLabel>{t('fields.description')}</FormLabel>
|
|
1143
|
+
<FormControl>
|
|
1144
|
+
<Textarea
|
|
1145
|
+
placeholder={t('newTitle.descriptionPlaceholder')}
|
|
1146
|
+
{...field}
|
|
1147
|
+
value={field.value || ''}
|
|
1148
|
+
/>
|
|
1149
|
+
</FormControl>
|
|
1150
|
+
<FormMessage />
|
|
1151
|
+
</FormItem>
|
|
1152
|
+
)}
|
|
1153
|
+
/>
|
|
1154
|
+
</FinanceSheetSection>
|
|
1155
|
+
</FinanceSheetBody>
|
|
1156
|
+
|
|
1157
|
+
<div className="border-t border-border/50 px-4 py-4 sm:px-6">
|
|
1158
|
+
<div className="flex flex-col-reverse gap-2 sm:flex-row sm:justify-end">
|
|
1159
|
+
<Button type="button" variant="outline" onClick={handleCancel}>
|
|
1160
|
+
{t('common.cancel')}
|
|
1161
|
+
</Button>
|
|
1162
|
+
<Button
|
|
1163
|
+
type="submit"
|
|
1164
|
+
disabled={
|
|
1165
|
+
form.formState.isSubmitting ||
|
|
1166
|
+
isUploadingFile ||
|
|
1167
|
+
isExtractingFileData
|
|
1168
|
+
}
|
|
1169
|
+
>
|
|
1170
|
+
{(isUploadingFile || isExtractingFileData) && (
|
|
1171
|
+
<Loader2 className="mr-2 h-4 w-4 animate-spin" />
|
|
1172
|
+
)}
|
|
1173
|
+
{isExtractingFileData
|
|
1174
|
+
? t('common.upload.fillingWithAi')
|
|
1175
|
+
: isUploadingFile
|
|
1176
|
+
? t('common.upload.uploadingFile')
|
|
1177
|
+
: t('common.save')}
|
|
1178
|
+
</Button>
|
|
1179
|
+
</div>
|
|
1180
|
+
</div>
|
|
1181
|
+
</form>
|
|
1182
|
+
</Form>
|
|
1183
|
+
</SheetContent>
|
|
1140
1184
|
</Sheet>
|
|
1141
1185
|
);
|
|
1142
1186
|
}
|
|
@@ -1401,9 +1445,9 @@ function EditarTituloSheet({
|
|
|
1401
1445
|
};
|
|
1402
1446
|
}, []);
|
|
1403
1447
|
|
|
1404
|
-
const handleSubmit = async (values: NewTitleFormValues) => {
|
|
1405
|
-
if (!titulo?.id) {
|
|
1406
|
-
showToastHandler?.('error', t('messages.invalidTitleForEdit'));
|
|
1448
|
+
const handleSubmit = async (values: NewTitleFormValues) => {
|
|
1449
|
+
if (!titulo?.id) {
|
|
1450
|
+
showToastHandler?.('error', t('messages.invalidTitleForEdit'));
|
|
1407
1451
|
return;
|
|
1408
1452
|
}
|
|
1409
1453
|
|
|
@@ -1440,9 +1484,13 @@ function EditarTituloSheet({
|
|
|
1440
1484
|
showToastHandler?.('success', t('messages.updateSuccess'));
|
|
1441
1485
|
onOpenChange(false);
|
|
1442
1486
|
} catch {
|
|
1443
|
-
showToastHandler?.('error', t('messages.updateError'));
|
|
1444
|
-
}
|
|
1445
|
-
};
|
|
1487
|
+
showToastHandler?.('error', t('messages.updateError'));
|
|
1488
|
+
}
|
|
1489
|
+
};
|
|
1490
|
+
|
|
1491
|
+
const handleCancel = () => {
|
|
1492
|
+
onOpenChange(false);
|
|
1493
|
+
};
|
|
1446
1494
|
|
|
1447
1495
|
const clearUploadedFile = () => {
|
|
1448
1496
|
setUploadedFileId(null);
|
|
@@ -1609,37 +1657,44 @@ function EditarTituloSheet({
|
|
|
1609
1657
|
|
|
1610
1658
|
return (
|
|
1611
1659
|
<Sheet open={open} onOpenChange={onOpenChange}>
|
|
1612
|
-
<SheetContent className="w-full sm:max-w-lg
|
|
1613
|
-
<SheetHeader>
|
|
1614
|
-
<SheetTitle>{t('table.actions.edit')}</SheetTitle>
|
|
1615
|
-
<SheetDescription>{t('editTitle.description')}</SheetDescription>
|
|
1616
|
-
</SheetHeader>
|
|
1617
|
-
<Form {...form}>
|
|
1618
|
-
<form
|
|
1619
|
-
|
|
1620
|
-
|
|
1621
|
-
|
|
1622
|
-
|
|
1623
|
-
|
|
1624
|
-
|
|
1625
|
-
|
|
1626
|
-
|
|
1627
|
-
|
|
1628
|
-
|
|
1629
|
-
|
|
1630
|
-
|
|
1631
|
-
|
|
1632
|
-
|
|
1633
|
-
|
|
1634
|
-
|
|
1635
|
-
|
|
1636
|
-
|
|
1637
|
-
|
|
1638
|
-
|
|
1639
|
-
|
|
1640
|
-
|
|
1641
|
-
|
|
1642
|
-
|
|
1660
|
+
<SheetContent className="flex h-full w-full flex-col overflow-hidden p-0 sm:max-w-xl lg:max-w-4xl">
|
|
1661
|
+
<SheetHeader className="border-b border-border/50 px-4 py-4 sm:px-6">
|
|
1662
|
+
<SheetTitle>{t('table.actions.edit')}</SheetTitle>
|
|
1663
|
+
<SheetDescription>{t('editTitle.description')}</SheetDescription>
|
|
1664
|
+
</SheetHeader>
|
|
1665
|
+
<Form {...form}>
|
|
1666
|
+
<form
|
|
1667
|
+
className="flex h-full flex-col overflow-hidden"
|
|
1668
|
+
onSubmit={form.handleSubmit(handleSubmit)}
|
|
1669
|
+
>
|
|
1670
|
+
<FinanceSheetBody>
|
|
1671
|
+
<FinanceSheetSection
|
|
1672
|
+
title={t('sections.main.title')}
|
|
1673
|
+
description={t('sections.main.description')}
|
|
1674
|
+
>
|
|
1675
|
+
<div className="grid grid-cols-1 items-start gap-4 xl:grid-cols-[minmax(0,1.15fr)_minmax(0,0.85fr)]">
|
|
1676
|
+
<div className="grid gap-2">
|
|
1677
|
+
<FormLabel>{t('common.upload.label')}</FormLabel>
|
|
1678
|
+
<Input
|
|
1679
|
+
ref={fileInputRef}
|
|
1680
|
+
className="hidden"
|
|
1681
|
+
type="file"
|
|
1682
|
+
accept=".pdf,.png,.jpg,.jpeg,.xml,.txt"
|
|
1683
|
+
onChange={(event) => {
|
|
1684
|
+
const file = event.target.files?.[0];
|
|
1685
|
+
if (!file) {
|
|
1686
|
+
return;
|
|
1687
|
+
}
|
|
1688
|
+
|
|
1689
|
+
clearUploadedFile();
|
|
1690
|
+
void uploadRelatedFile(file);
|
|
1691
|
+
}}
|
|
1692
|
+
disabled={
|
|
1693
|
+
isUploadingFile ||
|
|
1694
|
+
isExtractingFileData ||
|
|
1695
|
+
form.formState.isSubmitting
|
|
1696
|
+
}
|
|
1697
|
+
/>
|
|
1643
1698
|
|
|
1644
1699
|
<div className="grid w-full grid-cols-2 gap-2">
|
|
1645
1700
|
<Tooltip>
|
|
@@ -1704,12 +1759,12 @@ function EditarTituloSheet({
|
|
|
1704
1759
|
)}
|
|
1705
1760
|
</div>
|
|
1706
1761
|
|
|
1707
|
-
|
|
1708
|
-
|
|
1709
|
-
|
|
1710
|
-
|
|
1711
|
-
|
|
1712
|
-
|
|
1762
|
+
<div className="space-y-1 rounded-lg border border-dashed border-border/70 bg-muted/20 p-3">
|
|
1763
|
+
{(uploadedFileId || uploadedFileName) && (
|
|
1764
|
+
<p className="truncate text-xs text-muted-foreground">
|
|
1765
|
+
{t('common.upload.selectedPrefix')} {uploadedFileName}
|
|
1766
|
+
</p>
|
|
1767
|
+
)}
|
|
1713
1768
|
|
|
1714
1769
|
{isUploadingFile && !isExtractingFileData && (
|
|
1715
1770
|
<div className="space-y-1">
|
|
@@ -1739,358 +1794,387 @@ function EditarTituloSheet({
|
|
|
1739
1794
|
</p>
|
|
1740
1795
|
)}
|
|
1741
1796
|
|
|
1742
|
-
|
|
1743
|
-
|
|
1744
|
-
|
|
1745
|
-
|
|
1746
|
-
|
|
1747
|
-
|
|
1748
|
-
|
|
1749
|
-
|
|
1750
|
-
|
|
1751
|
-
|
|
1752
|
-
|
|
1753
|
-
|
|
1754
|
-
|
|
1755
|
-
<
|
|
1756
|
-
|
|
1757
|
-
<
|
|
1758
|
-
|
|
1759
|
-
|
|
1760
|
-
|
|
1761
|
-
|
|
1762
|
-
|
|
1763
|
-
|
|
1764
|
-
|
|
1765
|
-
|
|
1766
|
-
|
|
1767
|
-
|
|
1768
|
-
|
|
1769
|
-
|
|
1770
|
-
|
|
1771
|
-
|
|
1772
|
-
|
|
1773
|
-
|
|
1774
|
-
<
|
|
1775
|
-
|
|
1776
|
-
|
|
1777
|
-
|
|
1778
|
-
|
|
1779
|
-
<
|
|
1780
|
-
|
|
1781
|
-
<
|
|
1782
|
-
|
|
1783
|
-
|
|
1784
|
-
|
|
1785
|
-
|
|
1786
|
-
|
|
1787
|
-
|
|
1788
|
-
|
|
1789
|
-
|
|
1790
|
-
|
|
1791
|
-
|
|
1792
|
-
|
|
1793
|
-
|
|
1794
|
-
|
|
1795
|
-
|
|
1796
|
-
|
|
1797
|
-
<
|
|
1798
|
-
|
|
1799
|
-
<
|
|
1800
|
-
|
|
1801
|
-
|
|
1802
|
-
|
|
1803
|
-
|
|
1804
|
-
|
|
1805
|
-
|
|
1806
|
-
|
|
1807
|
-
|
|
1808
|
-
|
|
1809
|
-
|
|
1810
|
-
|
|
1811
|
-
|
|
1812
|
-
<
|
|
1813
|
-
|
|
1814
|
-
|
|
1815
|
-
|
|
1816
|
-
|
|
1817
|
-
<
|
|
1818
|
-
|
|
1819
|
-
<
|
|
1820
|
-
|
|
1821
|
-
|
|
1822
|
-
|
|
1823
|
-
|
|
1824
|
-
|
|
1825
|
-
|
|
1826
|
-
|
|
1827
|
-
|
|
1828
|
-
|
|
1829
|
-
|
|
1830
|
-
|
|
1831
|
-
|
|
1832
|
-
|
|
1833
|
-
|
|
1834
|
-
|
|
1835
|
-
|
|
1836
|
-
|
|
1837
|
-
|
|
1838
|
-
<
|
|
1839
|
-
|
|
1840
|
-
|
|
1841
|
-
|
|
1842
|
-
<
|
|
1843
|
-
|
|
1844
|
-
|
|
1845
|
-
|
|
1846
|
-
|
|
1847
|
-
|
|
1848
|
-
|
|
1849
|
-
|
|
1850
|
-
|
|
1851
|
-
|
|
1852
|
-
|
|
1853
|
-
|
|
1854
|
-
|
|
1855
|
-
|
|
1856
|
-
|
|
1857
|
-
|
|
1858
|
-
|
|
1859
|
-
|
|
1860
|
-
|
|
1861
|
-
|
|
1862
|
-
|
|
1863
|
-
|
|
1864
|
-
|
|
1865
|
-
|
|
1866
|
-
|
|
1867
|
-
|
|
1868
|
-
|
|
1869
|
-
|
|
1870
|
-
|
|
1871
|
-
|
|
1872
|
-
|
|
1873
|
-
|
|
1874
|
-
|
|
1875
|
-
|
|
1876
|
-
|
|
1877
|
-
|
|
1878
|
-
|
|
1879
|
-
|
|
1880
|
-
|
|
1881
|
-
|
|
1882
|
-
|
|
1883
|
-
|
|
1884
|
-
|
|
1885
|
-
|
|
1886
|
-
|
|
1887
|
-
|
|
1888
|
-
|
|
1889
|
-
|
|
1890
|
-
|
|
1891
|
-
|
|
1892
|
-
|
|
1893
|
-
|
|
1894
|
-
|
|
1895
|
-
|
|
1896
|
-
|
|
1897
|
-
|
|
1898
|
-
|
|
1899
|
-
|
|
1900
|
-
|
|
1901
|
-
|
|
1902
|
-
|
|
1903
|
-
|
|
1904
|
-
|
|
1905
|
-
|
|
1906
|
-
|
|
1907
|
-
>
|
|
1908
|
-
|
|
1909
|
-
|
|
1910
|
-
|
|
1911
|
-
|
|
1912
|
-
<
|
|
1913
|
-
|
|
1914
|
-
|
|
1915
|
-
|
|
1916
|
-
|
|
1917
|
-
|
|
1918
|
-
|
|
1919
|
-
|
|
1920
|
-
|
|
1921
|
-
|
|
1922
|
-
|
|
1923
|
-
|
|
1924
|
-
|
|
1925
|
-
|
|
1926
|
-
|
|
1927
|
-
|
|
1928
|
-
|
|
1929
|
-
|
|
1930
|
-
|
|
1931
|
-
|
|
1932
|
-
|
|
1933
|
-
|
|
1934
|
-
|
|
1935
|
-
|
|
1936
|
-
|
|
1937
|
-
|
|
1938
|
-
|
|
1939
|
-
|
|
1940
|
-
|
|
1941
|
-
|
|
1942
|
-
|
|
1943
|
-
|
|
1944
|
-
|
|
1945
|
-
|
|
1946
|
-
|
|
1947
|
-
|
|
1948
|
-
|
|
1949
|
-
|
|
1950
|
-
|
|
1951
|
-
|
|
1952
|
-
|
|
1953
|
-
|
|
1954
|
-
}
|
|
1955
|
-
|
|
1956
|
-
|
|
1957
|
-
|
|
1958
|
-
|
|
1959
|
-
|
|
1960
|
-
|
|
1961
|
-
|
|
1962
|
-
|
|
1963
|
-
|
|
1964
|
-
|
|
1965
|
-
|
|
1966
|
-
|
|
1967
|
-
|
|
1968
|
-
|
|
1969
|
-
|
|
1970
|
-
|
|
1971
|
-
|
|
1972
|
-
|
|
1973
|
-
|
|
1974
|
-
|
|
1975
|
-
|
|
1976
|
-
|
|
1977
|
-
|
|
1978
|
-
|
|
1979
|
-
|
|
1980
|
-
|
|
1981
|
-
|
|
1982
|
-
|
|
1983
|
-
|
|
1984
|
-
|
|
1985
|
-
|
|
1986
|
-
|
|
1987
|
-
|
|
1988
|
-
|
|
1989
|
-
|
|
1990
|
-
|
|
1991
|
-
|
|
1992
|
-
|
|
1993
|
-
|
|
1994
|
-
|
|
1995
|
-
{
|
|
1996
|
-
|
|
1997
|
-
|
|
1998
|
-
|
|
1999
|
-
|
|
2000
|
-
|
|
2001
|
-
|
|
2002
|
-
|
|
2003
|
-
|
|
2004
|
-
|
|
2005
|
-
|
|
2006
|
-
|
|
2007
|
-
|
|
2008
|
-
|
|
2009
|
-
|
|
2010
|
-
|
|
2011
|
-
|
|
2012
|
-
|
|
2013
|
-
|
|
2014
|
-
|
|
2015
|
-
|
|
2016
|
-
|
|
2017
|
-
|
|
2018
|
-
|
|
2019
|
-
|
|
2020
|
-
|
|
2021
|
-
|
|
2022
|
-
|
|
2023
|
-
|
|
2024
|
-
|
|
2025
|
-
|
|
2026
|
-
|
|
2027
|
-
|
|
2028
|
-
|
|
2029
|
-
|
|
2030
|
-
|
|
2031
|
-
|
|
2032
|
-
|
|
2033
|
-
|
|
2034
|
-
|
|
2035
|
-
|
|
2036
|
-
|
|
2037
|
-
|
|
2038
|
-
</
|
|
2039
|
-
<
|
|
2040
|
-
{
|
|
2041
|
-
|
|
2042
|
-
|
|
2043
|
-
|
|
2044
|
-
|
|
2045
|
-
|
|
2046
|
-
|
|
2047
|
-
|
|
2048
|
-
|
|
2049
|
-
|
|
2050
|
-
|
|
2051
|
-
|
|
2052
|
-
|
|
2053
|
-
|
|
2054
|
-
|
|
2055
|
-
|
|
2056
|
-
|
|
2057
|
-
|
|
2058
|
-
|
|
2059
|
-
|
|
2060
|
-
|
|
2061
|
-
|
|
2062
|
-
|
|
2063
|
-
|
|
2064
|
-
|
|
2065
|
-
|
|
2066
|
-
|
|
2067
|
-
|
|
2068
|
-
|
|
2069
|
-
|
|
2070
|
-
|
|
2071
|
-
|
|
2072
|
-
|
|
2073
|
-
|
|
2074
|
-
|
|
2075
|
-
|
|
2076
|
-
|
|
2077
|
-
|
|
2078
|
-
|
|
2079
|
-
|
|
2080
|
-
|
|
2081
|
-
|
|
2082
|
-
|
|
2083
|
-
|
|
2084
|
-
|
|
2085
|
-
|
|
2086
|
-
|
|
2087
|
-
|
|
2088
|
-
|
|
2089
|
-
|
|
2090
|
-
|
|
2091
|
-
|
|
2092
|
-
|
|
2093
|
-
|
|
1797
|
+
{!isExtractingFileData &&
|
|
1798
|
+
extractionWarnings.length > 0 && (
|
|
1799
|
+
<p className="truncate text-xs text-muted-foreground">
|
|
1800
|
+
{extractionWarnings[0]}
|
|
1801
|
+
</p>
|
|
1802
|
+
)}
|
|
1803
|
+
</div>
|
|
1804
|
+
</div>
|
|
1805
|
+
|
|
1806
|
+
<FormField
|
|
1807
|
+
control={form.control}
|
|
1808
|
+
name="documento"
|
|
1809
|
+
render={({ field }) => (
|
|
1810
|
+
<FormItem>
|
|
1811
|
+
<FormLabel>{t('fields.document')}</FormLabel>
|
|
1812
|
+
<FormControl>
|
|
1813
|
+
<Input placeholder="NF-00000" {...field} />
|
|
1814
|
+
</FormControl>
|
|
1815
|
+
<FormMessage />
|
|
1816
|
+
</FormItem>
|
|
1817
|
+
)}
|
|
1818
|
+
/>
|
|
1819
|
+
</div>
|
|
1820
|
+
|
|
1821
|
+
<PersonFieldWithCreate
|
|
1822
|
+
form={form}
|
|
1823
|
+
name="fornecedorId"
|
|
1824
|
+
label={t('fields.supplier')}
|
|
1825
|
+
entityLabel="fornecedor"
|
|
1826
|
+
selectPlaceholder={t('common.select')}
|
|
1827
|
+
/>
|
|
1828
|
+
|
|
1829
|
+
<div className="grid gap-4 md:grid-cols-2">
|
|
1830
|
+
<FormField
|
|
1831
|
+
control={form.control}
|
|
1832
|
+
name="competencia"
|
|
1833
|
+
render={({ field }) => (
|
|
1834
|
+
<FormItem>
|
|
1835
|
+
<FormLabel>{t('fields.competency')}</FormLabel>
|
|
1836
|
+
<FormControl>
|
|
1837
|
+
<Input
|
|
1838
|
+
type="month"
|
|
1839
|
+
{...field}
|
|
1840
|
+
value={field.value || ''}
|
|
1841
|
+
/>
|
|
1842
|
+
</FormControl>
|
|
1843
|
+
<FormMessage />
|
|
1844
|
+
</FormItem>
|
|
1845
|
+
)}
|
|
1846
|
+
/>
|
|
1847
|
+
|
|
1848
|
+
<FormField
|
|
1849
|
+
control={form.control}
|
|
1850
|
+
name="vencimento"
|
|
1851
|
+
render={({ field }) => (
|
|
1852
|
+
<FormItem>
|
|
1853
|
+
<FormLabel>{t('fields.dueDate')}</FormLabel>
|
|
1854
|
+
<FormControl>
|
|
1855
|
+
<Input
|
|
1856
|
+
type="date"
|
|
1857
|
+
{...field}
|
|
1858
|
+
value={field.value || ''}
|
|
1859
|
+
/>
|
|
1860
|
+
</FormControl>
|
|
1861
|
+
<FormMessage />
|
|
1862
|
+
</FormItem>
|
|
1863
|
+
)}
|
|
1864
|
+
/>
|
|
1865
|
+
</div>
|
|
1866
|
+
|
|
1867
|
+
<div className="grid gap-4 md:grid-cols-2">
|
|
1868
|
+
<FormField
|
|
1869
|
+
control={form.control}
|
|
1870
|
+
name="valor"
|
|
1871
|
+
render={({ field }) => (
|
|
1872
|
+
<FormItem>
|
|
1873
|
+
<FormLabel>{t('fields.totalValue')}</FormLabel>
|
|
1874
|
+
<FormControl>
|
|
1875
|
+
<InputMoney
|
|
1876
|
+
ref={field.ref}
|
|
1877
|
+
name={field.name}
|
|
1878
|
+
value={field.value}
|
|
1879
|
+
onBlur={field.onBlur}
|
|
1880
|
+
onValueChange={(value) => field.onChange(value ?? 0)}
|
|
1881
|
+
placeholder="0,00"
|
|
1882
|
+
/>
|
|
1883
|
+
</FormControl>
|
|
1884
|
+
<FormMessage />
|
|
1885
|
+
</FormItem>
|
|
1886
|
+
)}
|
|
1887
|
+
/>
|
|
1888
|
+
|
|
1889
|
+
<FormField
|
|
1890
|
+
control={form.control}
|
|
1891
|
+
name="installmentsCount"
|
|
1892
|
+
render={({ field }) => (
|
|
1893
|
+
<FormItem>
|
|
1894
|
+
<FormLabel>
|
|
1895
|
+
{t('installmentsEditor.countLabel')}
|
|
1896
|
+
</FormLabel>
|
|
1897
|
+
<FormControl>
|
|
1898
|
+
<Input
|
|
1899
|
+
type="number"
|
|
1900
|
+
min={1}
|
|
1901
|
+
max={120}
|
|
1902
|
+
value={field.value}
|
|
1903
|
+
onChange={(event) => {
|
|
1904
|
+
const nextValue = Number(event.target.value || 1);
|
|
1905
|
+
field.onChange(
|
|
1906
|
+
Number.isNaN(nextValue) ? 1 : nextValue
|
|
1907
|
+
);
|
|
1908
|
+
setIsInstallmentsEdited(false);
|
|
1909
|
+
}}
|
|
1910
|
+
/>
|
|
1911
|
+
</FormControl>
|
|
1912
|
+
<FormMessage />
|
|
1913
|
+
</FormItem>
|
|
1914
|
+
)}
|
|
1915
|
+
/>
|
|
1916
|
+
</div>
|
|
1917
|
+
</FinanceSheetSection>
|
|
1918
|
+
|
|
1919
|
+
<FinanceSheetSection
|
|
1920
|
+
title={t('sections.installments.title')}
|
|
1921
|
+
description={t('sections.installments.description')}
|
|
1922
|
+
>
|
|
1923
|
+
<div className="space-y-3">
|
|
1924
|
+
<div className="flex flex-col gap-3 xl:flex-row xl:items-center xl:justify-between">
|
|
1925
|
+
<div className="flex items-center gap-2">
|
|
1926
|
+
<Checkbox
|
|
1927
|
+
id="auto-redistribute-installments-edit-payable"
|
|
1928
|
+
checked={autoRedistributeInstallments}
|
|
1929
|
+
onCheckedChange={(checked) =>
|
|
1930
|
+
setAutoRedistributeInstallments(checked === true)
|
|
1931
|
+
}
|
|
1932
|
+
/>
|
|
1933
|
+
<Label
|
|
1934
|
+
htmlFor="auto-redistribute-installments-edit-payable"
|
|
1935
|
+
className="text-xs text-muted-foreground"
|
|
1936
|
+
>
|
|
1937
|
+
{t('installmentsEditor.autoRedistributeLabel')}
|
|
1938
|
+
</Label>
|
|
1939
|
+
</div>
|
|
1940
|
+
<Button
|
|
1941
|
+
type="button"
|
|
1942
|
+
variant="outline"
|
|
1943
|
+
size="sm"
|
|
1944
|
+
onClick={() => {
|
|
1945
|
+
setIsInstallmentsEdited(false);
|
|
1946
|
+
replaceInstallments(
|
|
1947
|
+
buildEqualInstallments(
|
|
1948
|
+
form.getValues('installmentsCount'),
|
|
1949
|
+
form.getValues('valor'),
|
|
1950
|
+
form.getValues('vencimento')
|
|
1951
|
+
)
|
|
1952
|
+
);
|
|
1953
|
+
}}
|
|
1954
|
+
>
|
|
1955
|
+
{t('installmentsEditor.recalculate')}
|
|
1956
|
+
</Button>
|
|
1957
|
+
</div>
|
|
1958
|
+
|
|
1959
|
+
{autoRedistributeInstallments && (
|
|
1960
|
+
<p className="text-xs text-muted-foreground">
|
|
1961
|
+
{t('installmentsEditor.autoRedistributeHint')}
|
|
1962
|
+
</p>
|
|
1963
|
+
)}
|
|
1964
|
+
|
|
1965
|
+
<div className="space-y-2">
|
|
1966
|
+
{installmentFields.map((installment, index) => (
|
|
1967
|
+
<div
|
|
1968
|
+
key={installment.id}
|
|
1969
|
+
className="grid grid-cols-1 items-start gap-3 rounded-lg border border-border/60 bg-background p-3 sm:grid-cols-[96px_1fr_180px]"
|
|
1970
|
+
>
|
|
1971
|
+
<div className="flex items-center text-sm text-muted-foreground">
|
|
1972
|
+
#{index + 1}
|
|
1973
|
+
</div>
|
|
1974
|
+
|
|
1975
|
+
<FormField
|
|
1976
|
+
control={form.control}
|
|
1977
|
+
name={`installments.${index}.dueDate` as const}
|
|
1978
|
+
render={({ field }) => (
|
|
1979
|
+
<FormItem>
|
|
1980
|
+
<FormLabel className="text-xs">
|
|
1981
|
+
{t('installmentsEditor.dueDateLabel')}
|
|
1982
|
+
</FormLabel>
|
|
1983
|
+
<FormControl>
|
|
1984
|
+
<Input
|
|
1985
|
+
type="date"
|
|
1986
|
+
{...field}
|
|
1987
|
+
value={field.value || ''}
|
|
1988
|
+
onChange={(event) => {
|
|
1989
|
+
setIsInstallmentsEdited(true);
|
|
1990
|
+
field.onChange(event);
|
|
1991
|
+
}}
|
|
1992
|
+
/>
|
|
1993
|
+
</FormControl>
|
|
1994
|
+
<FormMessage />
|
|
1995
|
+
</FormItem>
|
|
1996
|
+
)}
|
|
1997
|
+
/>
|
|
1998
|
+
|
|
1999
|
+
<FormField
|
|
2000
|
+
control={form.control}
|
|
2001
|
+
name={`installments.${index}.amount` as const}
|
|
2002
|
+
render={({ field }) => (
|
|
2003
|
+
<FormItem>
|
|
2004
|
+
<FormLabel className="text-xs">
|
|
2005
|
+
{t('installmentsEditor.amountLabel')}
|
|
2006
|
+
</FormLabel>
|
|
2007
|
+
<FormControl>
|
|
2008
|
+
<InputMoney
|
|
2009
|
+
ref={field.ref}
|
|
2010
|
+
name={field.name}
|
|
2011
|
+
value={field.value}
|
|
2012
|
+
onBlur={() => {
|
|
2013
|
+
field.onBlur();
|
|
2014
|
+
|
|
2015
|
+
if (!autoRedistributeInstallments) {
|
|
2016
|
+
return;
|
|
2017
|
+
}
|
|
2018
|
+
|
|
2019
|
+
clearScheduledRedistribution(index);
|
|
2020
|
+
runInstallmentRedistribution(index);
|
|
2021
|
+
}}
|
|
2022
|
+
onValueChange={(value) => {
|
|
2023
|
+
setIsInstallmentsEdited(true);
|
|
2024
|
+
field.onChange(value ?? 0);
|
|
2025
|
+
|
|
2026
|
+
if (!autoRedistributeInstallments) {
|
|
2027
|
+
return;
|
|
2028
|
+
}
|
|
2029
|
+
|
|
2030
|
+
scheduleInstallmentRedistribution(index);
|
|
2031
|
+
}}
|
|
2032
|
+
placeholder="0,00"
|
|
2033
|
+
/>
|
|
2034
|
+
</FormControl>
|
|
2035
|
+
<FormMessage />
|
|
2036
|
+
</FormItem>
|
|
2037
|
+
)}
|
|
2038
|
+
/>
|
|
2039
|
+
</div>
|
|
2040
|
+
))}
|
|
2041
|
+
</div>
|
|
2042
|
+
|
|
2043
|
+
<p
|
|
2044
|
+
className={`text-xs ${
|
|
2045
|
+
installmentsDiffCents === 0
|
|
2046
|
+
? 'text-muted-foreground'
|
|
2047
|
+
: 'text-destructive'
|
|
2048
|
+
}`}
|
|
2049
|
+
>
|
|
2050
|
+
{t('installmentsEditor.totalPrefix', {
|
|
2051
|
+
total: installmentsTotal.toFixed(2),
|
|
2052
|
+
})}
|
|
2053
|
+
{installmentsDiffCents > 0 &&
|
|
2054
|
+
` ${t('installmentsEditor.adjustmentNeeded')}`}
|
|
2055
|
+
</p>
|
|
2056
|
+
{form.formState.errors.installments?.message && (
|
|
2057
|
+
<p className="text-xs text-destructive">
|
|
2058
|
+
{form.formState.errors.installments.message}
|
|
2059
|
+
</p>
|
|
2060
|
+
)}
|
|
2061
|
+
</div>
|
|
2062
|
+
</FinanceSheetSection>
|
|
2063
|
+
|
|
2064
|
+
<FinanceSheetSection
|
|
2065
|
+
title={t('sections.classification.title')}
|
|
2066
|
+
description={t('sections.classification.description')}
|
|
2067
|
+
>
|
|
2068
|
+
<div className="grid gap-4 xl:grid-cols-3">
|
|
2069
|
+
<CategoryFieldWithCreate
|
|
2070
|
+
form={form}
|
|
2071
|
+
name="categoriaId"
|
|
2072
|
+
label={t('fields.category')}
|
|
2073
|
+
selectPlaceholder={t('common.select')}
|
|
2074
|
+
categories={categorias}
|
|
2075
|
+
categoryKind="despesa"
|
|
2076
|
+
onCreated={onCategoriesUpdated}
|
|
2077
|
+
/>
|
|
2078
|
+
|
|
2079
|
+
<CostCenterFieldWithCreate
|
|
2080
|
+
form={form}
|
|
2081
|
+
name="centroCustoId"
|
|
2082
|
+
label={t('fields.costCenter')}
|
|
2083
|
+
selectPlaceholder={t('common.select')}
|
|
2084
|
+
costCenters={centrosCusto}
|
|
2085
|
+
onCreated={onCostCentersUpdated}
|
|
2086
|
+
/>
|
|
2087
|
+
|
|
2088
|
+
<FormField
|
|
2089
|
+
control={form.control}
|
|
2090
|
+
name="metodo"
|
|
2091
|
+
render={({ field }) => (
|
|
2092
|
+
<FormItem>
|
|
2093
|
+
<FormLabel>{t('fields.paymentMethod')}</FormLabel>
|
|
2094
|
+
<Select
|
|
2095
|
+
value={field.value}
|
|
2096
|
+
onValueChange={field.onChange}
|
|
2097
|
+
>
|
|
2098
|
+
<FormControl>
|
|
2099
|
+
<SelectTrigger className="w-full">
|
|
2100
|
+
<SelectValue placeholder={t('common.select')} />
|
|
2101
|
+
</SelectTrigger>
|
|
2102
|
+
</FormControl>
|
|
2103
|
+
<SelectContent>
|
|
2104
|
+
<SelectItem value="boleto">
|
|
2105
|
+
{t('paymentMethods.boleto')}
|
|
2106
|
+
</SelectItem>
|
|
2107
|
+
<SelectItem value="pix">PIX</SelectItem>
|
|
2108
|
+
<SelectItem value="transferencia">
|
|
2109
|
+
{t('paymentMethods.transfer')}
|
|
2110
|
+
</SelectItem>
|
|
2111
|
+
<SelectItem value="cartao">
|
|
2112
|
+
{t('paymentMethods.card')}
|
|
2113
|
+
</SelectItem>
|
|
2114
|
+
<SelectItem value="dinheiro">
|
|
2115
|
+
{t('paymentMethods.cash')}
|
|
2116
|
+
</SelectItem>
|
|
2117
|
+
<SelectItem value="cheque">
|
|
2118
|
+
{t('paymentMethods.check')}
|
|
2119
|
+
</SelectItem>
|
|
2120
|
+
</SelectContent>
|
|
2121
|
+
</Select>
|
|
2122
|
+
<FormMessage />
|
|
2123
|
+
</FormItem>
|
|
2124
|
+
)}
|
|
2125
|
+
/>
|
|
2126
|
+
</div>
|
|
2127
|
+
</FinanceSheetSection>
|
|
2128
|
+
|
|
2129
|
+
<FinanceSheetSection
|
|
2130
|
+
title={t('sections.notes.title')}
|
|
2131
|
+
description={t('sections.notes.description')}
|
|
2132
|
+
>
|
|
2133
|
+
<FormField
|
|
2134
|
+
control={form.control}
|
|
2135
|
+
name="descricao"
|
|
2136
|
+
render={({ field }) => (
|
|
2137
|
+
<FormItem>
|
|
2138
|
+
<FormLabel>{t('fields.description')}</FormLabel>
|
|
2139
|
+
<FormControl>
|
|
2140
|
+
<Textarea
|
|
2141
|
+
placeholder={t('newTitle.descriptionPlaceholder')}
|
|
2142
|
+
{...field}
|
|
2143
|
+
value={field.value || ''}
|
|
2144
|
+
/>
|
|
2145
|
+
</FormControl>
|
|
2146
|
+
<FormMessage />
|
|
2147
|
+
</FormItem>
|
|
2148
|
+
)}
|
|
2149
|
+
/>
|
|
2150
|
+
</FinanceSheetSection>
|
|
2151
|
+
</FinanceSheetBody>
|
|
2152
|
+
|
|
2153
|
+
<div className="border-t border-border/50 px-4 py-4 sm:px-6">
|
|
2154
|
+
<div className="flex flex-col-reverse gap-2 sm:flex-row sm:justify-end">
|
|
2155
|
+
<Button type="button" variant="outline" onClick={handleCancel}>
|
|
2156
|
+
{t('common.cancel')}
|
|
2157
|
+
</Button>
|
|
2158
|
+
<Button
|
|
2159
|
+
type="submit"
|
|
2160
|
+
disabled={
|
|
2161
|
+
form.formState.isSubmitting ||
|
|
2162
|
+
isUploadingFile ||
|
|
2163
|
+
isExtractingFileData
|
|
2164
|
+
}
|
|
2165
|
+
>
|
|
2166
|
+
{(isUploadingFile || isExtractingFileData) && (
|
|
2167
|
+
<Loader2 className="mr-2 h-4 w-4 animate-spin" />
|
|
2168
|
+
)}
|
|
2169
|
+
{isExtractingFileData
|
|
2170
|
+
? t('common.upload.fillingWithAi')
|
|
2171
|
+
: isUploadingFile
|
|
2172
|
+
? t('common.upload.uploadingFile')
|
|
2173
|
+
: t('common.save')}
|
|
2174
|
+
</Button>
|
|
2175
|
+
</div>
|
|
2176
|
+
</div>
|
|
2177
|
+
</form>
|
|
2094
2178
|
</Form>
|
|
2095
2179
|
</SheetContent>
|
|
2096
2180
|
</Sheet>
|
|
@@ -2138,12 +2222,12 @@ export default function TitulosPagarPage() {
|
|
|
2138
2222
|
const centrosCusto = centrosCustoData || [];
|
|
2139
2223
|
|
|
2140
2224
|
const getPessoaById = (id?: string) => pessoas.find((p) => p.id === id);
|
|
2141
|
-
const getCategoriaById = (id?: string) => categorias.find((c) => c.id === id);
|
|
2142
|
-
|
|
2143
|
-
const [search, setSearch] = useState('');
|
|
2144
|
-
const [statusFilter, setStatusFilter] = useState<string>('');
|
|
2145
|
-
const [page, setPage] = useState(1);
|
|
2146
|
-
const pageSize = 10;
|
|
2225
|
+
const getCategoriaById = (id?: string) => categorias.find((c) => c.id === id);
|
|
2226
|
+
|
|
2227
|
+
const [search, setSearch] = useState('');
|
|
2228
|
+
const [statusFilter, setStatusFilter] = useState<string>('all');
|
|
2229
|
+
const [page, setPage] = useState(1);
|
|
2230
|
+
const pageSize = 10;
|
|
2147
2231
|
const [isNewTitleSheetOpen, setIsNewTitleSheetOpen] = useState(false);
|
|
2148
2232
|
const [editingTitleId, setEditingTitleId] = useState<string | null>(null);
|
|
2149
2233
|
const [approvingTitleId, setApprovingTitleId] = useState<string | null>(null);
|
|
@@ -2178,11 +2262,10 @@ export default function TitulosPagarPage() {
|
|
|
2178
2262
|
const normalizedStatusFilter =
|
|
2179
2263
|
statusFilter && statusFilter !== 'all' ? statusFilter : undefined;
|
|
2180
2264
|
|
|
2181
|
-
const {
|
|
2182
|
-
data: paginatedTitlesResponse,
|
|
2183
|
-
refetch: refetchTitles,
|
|
2184
|
-
|
|
2185
|
-
} = useQuery<{
|
|
2265
|
+
const {
|
|
2266
|
+
data: paginatedTitlesResponse,
|
|
2267
|
+
refetch: refetchTitles,
|
|
2268
|
+
} = useQuery<{
|
|
2186
2269
|
data: any[];
|
|
2187
2270
|
total: number;
|
|
2188
2271
|
page: number;
|
|
@@ -2222,11 +2305,76 @@ export default function TitulosPagarPage() {
|
|
|
2222
2305
|
},
|
|
2223
2306
|
placeholderData: (old) => old,
|
|
2224
2307
|
});
|
|
2225
|
-
|
|
2226
|
-
const titulosPagar = paginatedTitlesResponse?.data || [];
|
|
2227
|
-
|
|
2228
|
-
|
|
2229
|
-
|
|
2308
|
+
|
|
2309
|
+
const titulosPagar = paginatedTitlesResponse?.data || [];
|
|
2310
|
+
const visibleTitlesTotal = useMemo(
|
|
2311
|
+
() =>
|
|
2312
|
+
titulosPagar.reduce(
|
|
2313
|
+
(acc, title) => acc + Number(title?.valorTotal || 0),
|
|
2314
|
+
0
|
|
2315
|
+
),
|
|
2316
|
+
[titulosPagar]
|
|
2317
|
+
);
|
|
2318
|
+
const visiblePendingTitles = useMemo(
|
|
2319
|
+
() =>
|
|
2320
|
+
titulosPagar.filter((title) =>
|
|
2321
|
+
['aberto', 'parcial', 'vencido'].includes(String(title?.status || ''))
|
|
2322
|
+
).length,
|
|
2323
|
+
[titulosPagar]
|
|
2324
|
+
);
|
|
2325
|
+
const visibleOverdueTitles = useMemo(
|
|
2326
|
+
() =>
|
|
2327
|
+
titulosPagar.filter(
|
|
2328
|
+
(title) =>
|
|
2329
|
+
title?.status === 'vencido' ||
|
|
2330
|
+
(Array.isArray(title?.parcelas) &&
|
|
2331
|
+
title.parcelas.some((installment: any) => installment.status === 'vencido'))
|
|
2332
|
+
).length,
|
|
2333
|
+
[titulosPagar]
|
|
2334
|
+
);
|
|
2335
|
+
const summaryCards = useMemo(
|
|
2336
|
+
() => [
|
|
2337
|
+
{
|
|
2338
|
+
key: 'visible',
|
|
2339
|
+
title: t('summary.cards.visible.title'),
|
|
2340
|
+
value: titulosPagar.length,
|
|
2341
|
+
description: t('summary.cards.visible.description', {
|
|
2342
|
+
total: paginatedTitlesResponse?.total || 0,
|
|
2343
|
+
}),
|
|
2344
|
+
icon: FileText,
|
|
2345
|
+
layout: 'compact' as const,
|
|
2346
|
+
},
|
|
2347
|
+
{
|
|
2348
|
+
key: 'value',
|
|
2349
|
+
title: t('summary.cards.value.title'),
|
|
2350
|
+
value: <Money value={visibleTitlesTotal} />,
|
|
2351
|
+
description: t('summary.cards.value.description'),
|
|
2352
|
+
icon: Wallet,
|
|
2353
|
+
layout: 'compact' as const,
|
|
2354
|
+
},
|
|
2355
|
+
{
|
|
2356
|
+
key: 'attention',
|
|
2357
|
+
title: t('summary.cards.attention.title'),
|
|
2358
|
+
value: visiblePendingTitles,
|
|
2359
|
+
description: t('summary.cards.attention.description', {
|
|
2360
|
+
overdue: visibleOverdueTitles,
|
|
2361
|
+
}),
|
|
2362
|
+
icon: AlertTriangle,
|
|
2363
|
+
layout: 'compact' as const,
|
|
2364
|
+
},
|
|
2365
|
+
],
|
|
2366
|
+
[
|
|
2367
|
+
paginatedTitlesResponse?.total,
|
|
2368
|
+
t,
|
|
2369
|
+
titulosPagar.length,
|
|
2370
|
+
visibleOverdueTitles,
|
|
2371
|
+
visiblePendingTitles,
|
|
2372
|
+
visibleTitlesTotal,
|
|
2373
|
+
]
|
|
2374
|
+
);
|
|
2375
|
+
|
|
2376
|
+
useEffect(() => {
|
|
2377
|
+
const firstCandidate = settleCandidates[0];
|
|
2230
2378
|
|
|
2231
2379
|
settleTitleForm.reset({
|
|
2232
2380
|
installmentId: firstCandidate?.id || '',
|
|
@@ -2469,9 +2617,9 @@ export default function TitulosPagarPage() {
|
|
|
2469
2617
|
|
|
2470
2618
|
return (
|
|
2471
2619
|
<Page>
|
|
2472
|
-
<PageHeader
|
|
2473
|
-
title={t('header.title')}
|
|
2474
|
-
description={t('header.description')}
|
|
2620
|
+
<PageHeader
|
|
2621
|
+
title={t('header.title')}
|
|
2622
|
+
description={t('header.description')}
|
|
2475
2623
|
breadcrumbs={[
|
|
2476
2624
|
{ label: t('breadcrumbs.home'), href: '/' },
|
|
2477
2625
|
{ label: t('breadcrumbs.finance'), href: '/finance' },
|
|
@@ -2504,319 +2652,332 @@ export default function TitulosPagarPage() {
|
|
|
2504
2652
|
onCategoriesUpdated={refetchCategorias}
|
|
2505
2653
|
onCostCentersUpdated={refetchCentrosCusto}
|
|
2506
2654
|
/>
|
|
2507
|
-
</>
|
|
2508
|
-
}
|
|
2509
|
-
/>
|
|
2510
|
-
|
|
2511
|
-
<
|
|
2512
|
-
|
|
2513
|
-
|
|
2514
|
-
|
|
2515
|
-
|
|
2516
|
-
{
|
|
2517
|
-
|
|
2518
|
-
|
|
2519
|
-
|
|
2520
|
-
|
|
2521
|
-
|
|
2522
|
-
|
|
2523
|
-
|
|
2524
|
-
|
|
2525
|
-
|
|
2526
|
-
|
|
2527
|
-
|
|
2528
|
-
|
|
2529
|
-
|
|
2530
|
-
|
|
2531
|
-
|
|
2532
|
-
|
|
2533
|
-
|
|
2534
|
-
|
|
2535
|
-
|
|
2536
|
-
|
|
2537
|
-
|
|
2538
|
-
|
|
2655
|
+
</>
|
|
2656
|
+
}
|
|
2657
|
+
/>
|
|
2658
|
+
|
|
2659
|
+
<KpiCardsGrid items={summaryCards} columns={3} />
|
|
2660
|
+
|
|
2661
|
+
<div className="min-w-0">
|
|
2662
|
+
<SearchBar
|
|
2663
|
+
searchQuery={search}
|
|
2664
|
+
onSearchChange={setSearch}
|
|
2665
|
+
onSearch={() => undefined}
|
|
2666
|
+
placeholder={t('filters.searchPlaceholder')}
|
|
2667
|
+
controls={[
|
|
2668
|
+
{
|
|
2669
|
+
id: 'status',
|
|
2670
|
+
type: 'select',
|
|
2671
|
+
value: statusFilter,
|
|
2672
|
+
onChange: setStatusFilter,
|
|
2673
|
+
placeholder: t('filters.status'),
|
|
2674
|
+
options: [
|
|
2675
|
+
{ value: 'all', label: t('statuses.all') },
|
|
2676
|
+
{ value: 'rascunho', label: t('statuses.rascunho') },
|
|
2677
|
+
{ value: 'aberto', label: t('statuses.aberto') },
|
|
2678
|
+
{ value: 'parcial', label: t('statuses.parcial') },
|
|
2679
|
+
{ value: 'liquidado', label: t('statuses.liquidado') },
|
|
2680
|
+
{ value: 'vencido', label: t('statuses.vencido') },
|
|
2681
|
+
{ value: 'cancelado', label: t('statuses.cancelado') },
|
|
2682
|
+
],
|
|
2683
|
+
},
|
|
2684
|
+
]}
|
|
2685
|
+
/>
|
|
2686
|
+
</div>
|
|
2687
|
+
|
|
2688
|
+
<Sheet
|
|
2689
|
+
open={isSettleSheetOpen}
|
|
2690
|
+
onOpenChange={(open) => {
|
|
2539
2691
|
setIsSettleSheetOpen(open);
|
|
2540
2692
|
|
|
2541
2693
|
if (!open) {
|
|
2542
2694
|
setTitleToSettle(null);
|
|
2543
|
-
}
|
|
2544
|
-
}}
|
|
2545
|
-
>
|
|
2546
|
-
<SheetContent className="w-full sm:max-w-
|
|
2547
|
-
<SheetHeader>
|
|
2548
|
-
<SheetTitle>{t('settleSheet.title')}</SheetTitle>
|
|
2549
|
-
<SheetDescription>
|
|
2550
|
-
{t('settleSheet.description', {
|
|
2695
|
+
}
|
|
2696
|
+
}}
|
|
2697
|
+
>
|
|
2698
|
+
<SheetContent className="flex h-full w-full flex-col overflow-hidden p-0 sm:max-w-xl">
|
|
2699
|
+
<SheetHeader className="border-b border-border/50 px-4 py-4 sm:px-6">
|
|
2700
|
+
<SheetTitle>{t('settleSheet.title')}</SheetTitle>
|
|
2701
|
+
<SheetDescription>
|
|
2702
|
+
{t('settleSheet.description', {
|
|
2551
2703
|
document: titleToSettle?.documento || '-',
|
|
2552
2704
|
})}
|
|
2553
2705
|
</SheetDescription>
|
|
2554
2706
|
</SheetHeader>
|
|
2555
|
-
|
|
2556
|
-
<Form {...settleTitleForm}>
|
|
2557
|
-
<form
|
|
2558
|
-
className="
|
|
2559
|
-
onSubmit={settleTitleForm.handleSubmit(handleSubmitSettleTitle)}
|
|
2560
|
-
>
|
|
2561
|
-
<
|
|
2562
|
-
|
|
2563
|
-
|
|
2564
|
-
|
|
2565
|
-
|
|
2566
|
-
|
|
2567
|
-
|
|
2568
|
-
|
|
2569
|
-
|
|
2570
|
-
|
|
2571
|
-
|
|
2572
|
-
|
|
2573
|
-
|
|
2574
|
-
|
|
2575
|
-
|
|
2576
|
-
|
|
2577
|
-
|
|
2578
|
-
|
|
2579
|
-
|
|
2580
|
-
|
|
2581
|
-
|
|
2582
|
-
|
|
2583
|
-
|
|
2584
|
-
|
|
2585
|
-
|
|
2586
|
-
|
|
2587
|
-
|
|
2588
|
-
|
|
2589
|
-
|
|
2590
|
-
|
|
2591
|
-
|
|
2592
|
-
|
|
2593
|
-
|
|
2594
|
-
|
|
2595
|
-
|
|
2596
|
-
|
|
2597
|
-
|
|
2598
|
-
|
|
2599
|
-
>
|
|
2600
|
-
{
|
|
2601
|
-
|
|
2602
|
-
|
|
2603
|
-
|
|
2604
|
-
|
|
2605
|
-
|
|
2606
|
-
|
|
2607
|
-
|
|
2608
|
-
|
|
2609
|
-
|
|
2610
|
-
|
|
2611
|
-
|
|
2612
|
-
|
|
2613
|
-
|
|
2614
|
-
|
|
2615
|
-
|
|
2616
|
-
|
|
2617
|
-
|
|
2618
|
-
|
|
2619
|
-
|
|
2620
|
-
|
|
2621
|
-
|
|
2622
|
-
<
|
|
2623
|
-
|
|
2624
|
-
|
|
2625
|
-
|
|
2626
|
-
|
|
2627
|
-
|
|
2628
|
-
|
|
2629
|
-
|
|
2630
|
-
|
|
2631
|
-
|
|
2632
|
-
|
|
2633
|
-
|
|
2634
|
-
|
|
2635
|
-
|
|
2636
|
-
|
|
2637
|
-
|
|
2638
|
-
|
|
2639
|
-
|
|
2640
|
-
|
|
2641
|
-
<
|
|
2642
|
-
|
|
2643
|
-
|
|
2644
|
-
|
|
2645
|
-
|
|
2646
|
-
|
|
2647
|
-
|
|
2648
|
-
|
|
2649
|
-
|
|
2650
|
-
|
|
2651
|
-
|
|
2652
|
-
|
|
2653
|
-
|
|
2654
|
-
|
|
2655
|
-
|
|
2656
|
-
|
|
2657
|
-
|
|
2658
|
-
|
|
2707
|
+
|
|
2708
|
+
<Form {...settleTitleForm}>
|
|
2709
|
+
<form
|
|
2710
|
+
className="flex h-full flex-col overflow-hidden"
|
|
2711
|
+
onSubmit={settleTitleForm.handleSubmit(handleSubmitSettleTitle)}
|
|
2712
|
+
>
|
|
2713
|
+
<FinanceSheetBody>
|
|
2714
|
+
<FinanceSheetSection
|
|
2715
|
+
title={t('settleSheet.sections.payment.title')}
|
|
2716
|
+
description={t('settleSheet.sections.payment.description')}
|
|
2717
|
+
>
|
|
2718
|
+
<FormField
|
|
2719
|
+
control={settleTitleForm.control}
|
|
2720
|
+
name="installmentId"
|
|
2721
|
+
render={({ field }) => (
|
|
2722
|
+
<FormItem>
|
|
2723
|
+
<FormLabel>{t('settleSheet.installmentLabel')}</FormLabel>
|
|
2724
|
+
<Select
|
|
2725
|
+
value={field.value}
|
|
2726
|
+
onValueChange={(value) => {
|
|
2727
|
+
field.onChange(value);
|
|
2728
|
+
|
|
2729
|
+
const selected = settleCandidates.find(
|
|
2730
|
+
(installment: any) => installment.id === value
|
|
2731
|
+
);
|
|
2732
|
+
|
|
2733
|
+
if (selected) {
|
|
2734
|
+
settleTitleForm.setValue(
|
|
2735
|
+
'amount',
|
|
2736
|
+
Number(selected.valorAberto || 0),
|
|
2737
|
+
{ shouldValidate: true }
|
|
2738
|
+
);
|
|
2739
|
+
}
|
|
2740
|
+
}}
|
|
2741
|
+
>
|
|
2742
|
+
<FormControl>
|
|
2743
|
+
<SelectTrigger className="w-full">
|
|
2744
|
+
<SelectValue
|
|
2745
|
+
placeholder={t(
|
|
2746
|
+
'settleSheet.installmentPlaceholder'
|
|
2747
|
+
)}
|
|
2748
|
+
/>
|
|
2749
|
+
</SelectTrigger>
|
|
2750
|
+
</FormControl>
|
|
2751
|
+
<SelectContent>
|
|
2752
|
+
{settleCandidates.map((installment: any) => (
|
|
2753
|
+
<SelectItem
|
|
2754
|
+
key={installment.id}
|
|
2755
|
+
value={installment.id}
|
|
2756
|
+
>
|
|
2757
|
+
{t('settleSheet.installmentOption', {
|
|
2758
|
+
number: installment.numero,
|
|
2759
|
+
amount: new Intl.NumberFormat('pt-BR', {
|
|
2760
|
+
style: 'currency',
|
|
2761
|
+
currency: 'BRL',
|
|
2762
|
+
}).format(Number(installment.valorAberto || 0)),
|
|
2763
|
+
})}
|
|
2764
|
+
</SelectItem>
|
|
2765
|
+
))}
|
|
2766
|
+
</SelectContent>
|
|
2767
|
+
</Select>
|
|
2768
|
+
<FormMessage />
|
|
2769
|
+
</FormItem>
|
|
2770
|
+
)}
|
|
2771
|
+
/>
|
|
2772
|
+
|
|
2773
|
+
<div className="grid gap-4 sm:grid-cols-2">
|
|
2774
|
+
<FormField
|
|
2775
|
+
control={settleTitleForm.control}
|
|
2776
|
+
name="amount"
|
|
2777
|
+
render={({ field }) => (
|
|
2778
|
+
<FormItem>
|
|
2779
|
+
<FormLabel>{t('settleSheet.amountLabel')}</FormLabel>
|
|
2780
|
+
<FormControl>
|
|
2781
|
+
<InputMoney
|
|
2782
|
+
value={Number(field.value || 0)}
|
|
2783
|
+
onValueChange={(value) => {
|
|
2784
|
+
field.onChange(Number(value || 0));
|
|
2785
|
+
}}
|
|
2786
|
+
/>
|
|
2787
|
+
</FormControl>
|
|
2788
|
+
<FormMessage />
|
|
2789
|
+
</FormItem>
|
|
2790
|
+
)}
|
|
2791
|
+
/>
|
|
2792
|
+
|
|
2793
|
+
<FormField
|
|
2794
|
+
control={settleTitleForm.control}
|
|
2795
|
+
name="description"
|
|
2796
|
+
render={({ field }) => (
|
|
2797
|
+
<FormItem>
|
|
2798
|
+
<FormLabel>
|
|
2799
|
+
{t('settleSheet.descriptionLabel')}
|
|
2800
|
+
</FormLabel>
|
|
2801
|
+
<FormControl>
|
|
2802
|
+
<Input {...field} value={field.value || ''} />
|
|
2803
|
+
</FormControl>
|
|
2804
|
+
<FormMessage />
|
|
2805
|
+
</FormItem>
|
|
2806
|
+
)}
|
|
2807
|
+
/>
|
|
2808
|
+
</div>
|
|
2809
|
+
</FinanceSheetSection>
|
|
2810
|
+
</FinanceSheetBody>
|
|
2811
|
+
|
|
2812
|
+
<div className="border-t border-border/50 px-4 py-4 sm:px-6">
|
|
2813
|
+
<div className="flex flex-col-reverse gap-2 sm:flex-row sm:justify-end">
|
|
2814
|
+
<Button
|
|
2815
|
+
type="button"
|
|
2816
|
+
variant="outline"
|
|
2817
|
+
onClick={() => setIsSettleSheetOpen(false)}
|
|
2818
|
+
>
|
|
2819
|
+
{t('common.cancel')}
|
|
2820
|
+
</Button>
|
|
2821
|
+
<Button type="submit" disabled={isSettlingTitle}>
|
|
2822
|
+
{t('settleSheet.confirm')}
|
|
2823
|
+
</Button>
|
|
2824
|
+
</div>
|
|
2825
|
+
</div>
|
|
2826
|
+
</form>
|
|
2827
|
+
</Form>
|
|
2828
|
+
</SheetContent>
|
|
2659
2829
|
</Sheet>
|
|
2660
2830
|
|
|
2661
|
-
|
|
2662
|
-
|
|
2663
|
-
|
|
2664
|
-
|
|
2665
|
-
|
|
2666
|
-
|
|
2667
|
-
|
|
2668
|
-
|
|
2669
|
-
<
|
|
2670
|
-
|
|
2671
|
-
{t('table.headers.
|
|
2672
|
-
|
|
2673
|
-
|
|
2674
|
-
|
|
2675
|
-
|
|
2676
|
-
|
|
2677
|
-
|
|
2678
|
-
|
|
2679
|
-
|
|
2680
|
-
|
|
2681
|
-
|
|
2682
|
-
|
|
2683
|
-
|
|
2684
|
-
|
|
2685
|
-
|
|
2686
|
-
|
|
2687
|
-
|
|
2688
|
-
|
|
2689
|
-
|
|
2690
|
-
|
|
2691
|
-
|
|
2692
|
-
>
|
|
2693
|
-
|
|
2694
|
-
|
|
2695
|
-
|
|
2696
|
-
|
|
2697
|
-
|
|
2698
|
-
|
|
2699
|
-
|
|
2700
|
-
|
|
2701
|
-
|
|
2702
|
-
|
|
2703
|
-
|
|
2704
|
-
|
|
2705
|
-
|
|
2706
|
-
|
|
2707
|
-
|
|
2708
|
-
|
|
2709
|
-
|
|
2710
|
-
|
|
2711
|
-
|
|
2712
|
-
|
|
2713
|
-
|
|
2714
|
-
|
|
2715
|
-
|
|
2716
|
-
|
|
2717
|
-
|
|
2718
|
-
|
|
2719
|
-
|
|
2720
|
-
|
|
2721
|
-
|
|
2722
|
-
|
|
2723
|
-
|
|
2724
|
-
|
|
2725
|
-
|
|
2726
|
-
|
|
2727
|
-
|
|
2728
|
-
|
|
2729
|
-
<
|
|
2730
|
-
|
|
2731
|
-
|
|
2732
|
-
|
|
2733
|
-
|
|
2734
|
-
|
|
2735
|
-
|
|
2736
|
-
|
|
2737
|
-
|
|
2738
|
-
|
|
2739
|
-
|
|
2740
|
-
|
|
2741
|
-
|
|
2742
|
-
|
|
2743
|
-
|
|
2744
|
-
|
|
2745
|
-
|
|
2746
|
-
|
|
2747
|
-
|
|
2748
|
-
|
|
2749
|
-
|
|
2750
|
-
|
|
2751
|
-
|
|
2752
|
-
|
|
2753
|
-
|
|
2754
|
-
|
|
2755
|
-
|
|
2756
|
-
|
|
2757
|
-
|
|
2758
|
-
|
|
2759
|
-
|
|
2760
|
-
|
|
2761
|
-
|
|
2762
|
-
|
|
2763
|
-
|
|
2764
|
-
'dialogs.reverse.
|
|
2765
|
-
|
|
2766
|
-
|
|
2767
|
-
|
|
2768
|
-
|
|
2769
|
-
|
|
2770
|
-
|
|
2771
|
-
|
|
2772
|
-
|
|
2773
|
-
|
|
2774
|
-
|
|
2775
|
-
|
|
2776
|
-
|
|
2777
|
-
|
|
2778
|
-
|
|
2779
|
-
|
|
2780
|
-
|
|
2781
|
-
|
|
2782
|
-
|
|
2783
|
-
|
|
2784
|
-
|
|
2785
|
-
|
|
2786
|
-
|
|
2787
|
-
|
|
2788
|
-
|
|
2789
|
-
|
|
2790
|
-
|
|
2791
|
-
|
|
2792
|
-
|
|
2793
|
-
|
|
2794
|
-
|
|
2795
|
-
|
|
2796
|
-
|
|
2797
|
-
|
|
2798
|
-
|
|
2799
|
-
|
|
2800
|
-
|
|
2801
|
-
|
|
2802
|
-
|
|
2803
|
-
|
|
2804
|
-
|
|
2805
|
-
|
|
2806
|
-
|
|
2807
|
-
|
|
2808
|
-
|
|
2809
|
-
|
|
2810
|
-
|
|
2811
|
-
|
|
2812
|
-
|
|
2813
|
-
|
|
2814
|
-
onClick={() => setPage((current) => current + 1)}
|
|
2815
|
-
>
|
|
2816
|
-
{t('footer.next')}
|
|
2817
|
-
</Button>
|
|
2818
|
-
</div>
|
|
2819
|
-
</div>
|
|
2820
|
-
</Page>
|
|
2821
|
-
);
|
|
2822
|
-
}
|
|
2831
|
+
<FinancePageSection
|
|
2832
|
+
title={t('list.title')}
|
|
2833
|
+
description={t('list.description')}
|
|
2834
|
+
>
|
|
2835
|
+
{titulosPagar.length > 0 ? (
|
|
2836
|
+
<div className="overflow-x-auto">
|
|
2837
|
+
<Table className="min-w-[760px]">
|
|
2838
|
+
<TableHeader>
|
|
2839
|
+
<TableRow>
|
|
2840
|
+
<TableHead>{t('table.headers.document')}</TableHead>
|
|
2841
|
+
<TableHead>{t('table.headers.supplier')}</TableHead>
|
|
2842
|
+
<TableHead>{t('table.headers.competency')}</TableHead>
|
|
2843
|
+
<TableHead>{t('table.headers.dueDate')}</TableHead>
|
|
2844
|
+
<TableHead className="text-right">
|
|
2845
|
+
{t('table.headers.value')}
|
|
2846
|
+
</TableHead>
|
|
2847
|
+
<TableHead>{t('table.headers.category')}</TableHead>
|
|
2848
|
+
<TableHead>{t('table.headers.status')}</TableHead>
|
|
2849
|
+
<TableHead className="w-[50px]" />
|
|
2850
|
+
</TableRow>
|
|
2851
|
+
</TableHeader>
|
|
2852
|
+
<TableBody>
|
|
2853
|
+
{titulosPagar.map((titulo) => {
|
|
2854
|
+
const fornecedor = getPessoaById(titulo.fornecedorId);
|
|
2855
|
+
const categoria = getCategoriaById(titulo.categoriaId);
|
|
2856
|
+
const proximaParcela = titulo.parcelas.find(
|
|
2857
|
+
(p: any) => p.status === 'aberto' || p.status === 'vencido'
|
|
2858
|
+
);
|
|
2859
|
+
|
|
2860
|
+
return (
|
|
2861
|
+
<TableRow key={titulo.id} className="hover:bg-muted/30">
|
|
2862
|
+
<TableCell className="font-medium">
|
|
2863
|
+
<Link
|
|
2864
|
+
href={`/finance/accounts-payable/installments/${titulo.id}`}
|
|
2865
|
+
className="cursor-pointer hover:underline"
|
|
2866
|
+
>
|
|
2867
|
+
{titulo.documento}
|
|
2868
|
+
</Link>
|
|
2869
|
+
{titulo.anexos.length > 0 && (
|
|
2870
|
+
<Button
|
|
2871
|
+
type="button"
|
|
2872
|
+
variant="ghost"
|
|
2873
|
+
size="icon"
|
|
2874
|
+
className="ml-1 inline-flex h-5 w-5 align-middle text-muted-foreground"
|
|
2875
|
+
onClick={(event) => {
|
|
2876
|
+
event.preventDefault();
|
|
2877
|
+
event.stopPropagation();
|
|
2878
|
+
const firstAttachmentId =
|
|
2879
|
+
titulo.anexosDetalhes?.[0]?.id;
|
|
2880
|
+
void handleOpenAttachment(firstAttachmentId);
|
|
2881
|
+
}}
|
|
2882
|
+
aria-label={t('table.actions.openAttachment')}
|
|
2883
|
+
>
|
|
2884
|
+
<Paperclip className="h-3 w-3" />
|
|
2885
|
+
</Button>
|
|
2886
|
+
)}
|
|
2887
|
+
</TableCell>
|
|
2888
|
+
<TableCell>{fornecedor?.nome}</TableCell>
|
|
2889
|
+
<TableCell>{titulo.competencia}</TableCell>
|
|
2890
|
+
<TableCell>
|
|
2891
|
+
{proximaParcela
|
|
2892
|
+
? formatarData(proximaParcela.vencimento)
|
|
2893
|
+
: '-'}
|
|
2894
|
+
</TableCell>
|
|
2895
|
+
<TableCell className="text-right">
|
|
2896
|
+
<Money value={titulo.valorTotal} />
|
|
2897
|
+
</TableCell>
|
|
2898
|
+
<TableCell>{categoria?.nome}</TableCell>
|
|
2899
|
+
<TableCell>
|
|
2900
|
+
<StatusBadge status={titulo.status} />
|
|
2901
|
+
</TableCell>
|
|
2902
|
+
<TableCell>
|
|
2903
|
+
<FinanceTitleActionsMenu
|
|
2904
|
+
triggerVariant="ghost"
|
|
2905
|
+
detailHref={`/finance/accounts-payable/installments/${titulo.id}`}
|
|
2906
|
+
canEdit={canEditTitle(titulo.status)}
|
|
2907
|
+
canApprove={canApproveTitle(titulo.status)}
|
|
2908
|
+
canSettle={canSettleTitle(titulo.status)}
|
|
2909
|
+
canReverse={
|
|
2910
|
+
canReverseTitle(titulo.status) &&
|
|
2911
|
+
!!getFirstActiveSettlementId(titulo)
|
|
2912
|
+
}
|
|
2913
|
+
canCancel={canCancelTitle(titulo.status)}
|
|
2914
|
+
isApproving={approvingTitleId === titulo.id}
|
|
2915
|
+
isReversing={reversingTitleId === titulo.id}
|
|
2916
|
+
isCanceling={cancelingTitleId === titulo.id}
|
|
2917
|
+
labels={{
|
|
2918
|
+
menu: t.has('actions.title')
|
|
2919
|
+
? t('actions.title')
|
|
2920
|
+
: t('table.actions.srActions'),
|
|
2921
|
+
srActions: t('table.actions.srActions'),
|
|
2922
|
+
viewDetails: t('table.actions.viewDetails'),
|
|
2923
|
+
edit: t('table.actions.edit'),
|
|
2924
|
+
approve: t('table.actions.approve'),
|
|
2925
|
+
settle: t('table.actions.settle'),
|
|
2926
|
+
reverse: t('table.actions.reverse'),
|
|
2927
|
+
cancel: t('table.actions.cancel'),
|
|
2928
|
+
}}
|
|
2929
|
+
dialogs={{
|
|
2930
|
+
cancelTitle: t('dialogs.cancel.title'),
|
|
2931
|
+
cancelDescription: t('dialogs.cancel.description'),
|
|
2932
|
+
cancelButton: t('dialogs.cancel.cancel'),
|
|
2933
|
+
confirmCancelButton: t('dialogs.cancel.confirm'),
|
|
2934
|
+
reverseTitle: t('dialogs.reverse.title'),
|
|
2935
|
+
reverseDescription: t('dialogs.reverse.description'),
|
|
2936
|
+
reverseReasonLabel: t('dialogs.reverse.reasonLabel'),
|
|
2937
|
+
reverseReasonPlaceholder: t(
|
|
2938
|
+
'dialogs.reverse.reasonPlaceholder'
|
|
2939
|
+
),
|
|
2940
|
+
reverseButton: t('dialogs.reverse.cancel'),
|
|
2941
|
+
confirmReverseButton: t('dialogs.reverse.confirm'),
|
|
2942
|
+
}}
|
|
2943
|
+
onEdit={() => setEditingTitleId(titulo.id)}
|
|
2944
|
+
onApprove={() => void handleApproveTitle(titulo.id)}
|
|
2945
|
+
onSettle={() => handleSettleTitle(titulo)}
|
|
2946
|
+
onReverse={(reason) =>
|
|
2947
|
+
handleReverseTitle(titulo, reason)
|
|
2948
|
+
}
|
|
2949
|
+
onCancel={() => handleCancelTitle(titulo.id)}
|
|
2950
|
+
/>
|
|
2951
|
+
</TableCell>
|
|
2952
|
+
</TableRow>
|
|
2953
|
+
);
|
|
2954
|
+
})}
|
|
2955
|
+
</TableBody>
|
|
2956
|
+
</Table>
|
|
2957
|
+
</div>
|
|
2958
|
+
) : (
|
|
2959
|
+
<div className="px-4 py-8 sm:px-6">
|
|
2960
|
+
<EmptyState
|
|
2961
|
+
icon={<FileText className="h-12 w-12" />}
|
|
2962
|
+
title={t('empty.title')}
|
|
2963
|
+
description={t('empty.description')}
|
|
2964
|
+
actionLabel={t('newTitle.action')}
|
|
2965
|
+
onAction={() => setIsNewTitleSheetOpen(true)}
|
|
2966
|
+
/>
|
|
2967
|
+
</div>
|
|
2968
|
+
)}
|
|
2969
|
+
|
|
2970
|
+
<div className="border-t border-border/50 px-4 py-4 sm:px-6">
|
|
2971
|
+
<PaginationFooter
|
|
2972
|
+
currentPage={page}
|
|
2973
|
+
pageSize={pageSize}
|
|
2974
|
+
totalItems={paginatedTitlesResponse?.total || 0}
|
|
2975
|
+
onPageChange={setPage}
|
|
2976
|
+
onPageSizeChange={() => undefined}
|
|
2977
|
+
pageSizeOptions={[10]}
|
|
2978
|
+
/>
|
|
2979
|
+
</div>
|
|
2980
|
+
</FinancePageSection>
|
|
2981
|
+
</Page>
|
|
2982
|
+
);
|
|
2983
|
+
}
|