@hed-hog/finance 0.0.256 → 0.0.260
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-bank-statement-adjustment.dto.d.ts +8 -0
- package/dist/dto/create-bank-statement-adjustment.dto.d.ts.map +1 -0
- package/dist/dto/create-bank-statement-adjustment.dto.js +50 -0
- package/dist/dto/create-bank-statement-adjustment.dto.js.map +1 -0
- package/dist/dto/create-transfer.dto.d.ts +8 -0
- package/dist/dto/create-transfer.dto.d.ts.map +1 -0
- package/dist/dto/create-transfer.dto.js +52 -0
- package/dist/dto/create-transfer.dto.js.map +1 -0
- package/dist/dto/register-collection-agreement.dto.d.ts +7 -0
- package/dist/dto/register-collection-agreement.dto.d.ts.map +1 -0
- package/dist/dto/register-collection-agreement.dto.js +37 -0
- package/dist/dto/register-collection-agreement.dto.js.map +1 -0
- package/dist/dto/send-collection.dto.d.ts +5 -0
- package/dist/dto/send-collection.dto.d.ts.map +1 -0
- package/dist/dto/send-collection.dto.js +29 -0
- package/dist/dto/send-collection.dto.js.map +1 -0
- package/dist/dto/settle-installment.dto.d.ts +1 -0
- package/dist/dto/settle-installment.dto.d.ts.map +1 -1
- package/dist/dto/settle-installment.dto.js +6 -0
- package/dist/dto/settle-installment.dto.js.map +1 -1
- package/dist/finance-collections.controller.d.ts +35 -0
- package/dist/finance-collections.controller.d.ts.map +1 -0
- package/dist/finance-collections.controller.js +65 -0
- package/dist/finance-collections.controller.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 +44 -0
- package/dist/finance-installments.controller.d.ts.map +1 -1
- package/dist/finance-statements.controller.d.ts +16 -2
- package/dist/finance-statements.controller.d.ts.map +1 -1
- package/dist/finance-statements.controller.js +34 -6
- package/dist/finance-statements.controller.js.map +1 -1
- package/dist/finance-transfers.controller.d.ts +23 -0
- package/dist/finance-transfers.controller.d.ts.map +1 -0
- package/dist/finance-transfers.controller.js +56 -0
- package/dist/finance-transfers.controller.js.map +1 -0
- package/dist/finance.module.d.ts.map +1 -1
- package/dist/finance.module.js +4 -0
- package/dist/finance.module.js.map +1 -1
- package/dist/finance.service.d.ts +115 -2
- package/dist/finance.service.d.ts.map +1 -1
- package/dist/finance.service.js +632 -8
- package/dist/finance.service.js.map +1 -1
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -0
- package/dist/index.js.map +1 -1
- package/hedhog/data/route.yaml +63 -0
- package/hedhog/frontend/app/accounts-receivable/collections-default/page.tsx.ejs +643 -440
- package/hedhog/frontend/app/cash-and-banks/bank-reconciliation/page.tsx.ejs +825 -477
- package/hedhog/frontend/app/cash-and-banks/statements/page.tsx.ejs +367 -43
- package/hedhog/frontend/app/cash-and-banks/transfers/page.tsx.ejs +315 -75
- package/package.json +6 -6
- package/src/dto/create-bank-statement-adjustment.dto.ts +38 -0
- package/src/dto/create-transfer.dto.ts +46 -0
- package/src/dto/register-collection-agreement.dto.ts +27 -0
- package/src/dto/send-collection.dto.ts +14 -0
- package/src/dto/settle-installment.dto.ts +5 -0
- package/src/finance-collections.controller.ts +34 -0
- package/src/finance-statements.controller.ts +29 -1
- package/src/finance-transfers.controller.ts +26 -0
- package/src/finance.module.ts +4 -0
- package/src/finance.service.ts +775 -5
- package/src/index.ts +2 -0
|
@@ -1,477 +1,825 @@
|
|
|
1
|
-
'use client';
|
|
2
|
-
|
|
3
|
-
import { Page, PageHeader } from '@/components/entity-list';
|
|
4
|
-
import { Badge } from '@/components/ui/badge';
|
|
5
|
-
import { Button } from '@/components/ui/button';
|
|
6
|
-
import {
|
|
7
|
-
Card,
|
|
8
|
-
CardContent,
|
|
9
|
-
CardDescription,
|
|
10
|
-
CardHeader,
|
|
11
|
-
CardTitle,
|
|
12
|
-
} from '@/components/ui/card';
|
|
13
|
-
import { Checkbox } from '@/components/ui/checkbox';
|
|
14
|
-
import {
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
} from '@/components/ui/
|
|
23
|
-
import {
|
|
24
|
-
import {
|
|
25
|
-
import {
|
|
26
|
-
import {
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
import {
|
|
41
|
-
import {
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
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
|
-
const
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
3
|
+
import { Page, PageHeader } from '@/components/entity-list';
|
|
4
|
+
import { Badge } from '@/components/ui/badge';
|
|
5
|
+
import { Button } from '@/components/ui/button';
|
|
6
|
+
import {
|
|
7
|
+
Card,
|
|
8
|
+
CardContent,
|
|
9
|
+
CardDescription,
|
|
10
|
+
CardHeader,
|
|
11
|
+
CardTitle,
|
|
12
|
+
} from '@/components/ui/card';
|
|
13
|
+
import { Checkbox } from '@/components/ui/checkbox';
|
|
14
|
+
import {
|
|
15
|
+
Form,
|
|
16
|
+
FormControl,
|
|
17
|
+
FormField,
|
|
18
|
+
FormItem,
|
|
19
|
+
FormLabel,
|
|
20
|
+
FormMessage,
|
|
21
|
+
} from '@/components/ui/form';
|
|
22
|
+
import { Input } from '@/components/ui/input';
|
|
23
|
+
import { InputMoney } from '@/components/ui/input-money';
|
|
24
|
+
import { Money } from '@/components/ui/money';
|
|
25
|
+
import { Progress } from '@/components/ui/progress';
|
|
26
|
+
import {
|
|
27
|
+
Select,
|
|
28
|
+
SelectContent,
|
|
29
|
+
SelectItem,
|
|
30
|
+
SelectTrigger,
|
|
31
|
+
SelectValue,
|
|
32
|
+
} from '@/components/ui/select';
|
|
33
|
+
import {
|
|
34
|
+
Sheet,
|
|
35
|
+
SheetContent,
|
|
36
|
+
SheetDescription,
|
|
37
|
+
SheetHeader,
|
|
38
|
+
SheetTitle,
|
|
39
|
+
} from '@/components/ui/sheet';
|
|
40
|
+
import { StatusBadge } from '@/components/ui/status-badge';
|
|
41
|
+
import { useApp, useQuery } from '@hed-hog/next-app-provider';
|
|
42
|
+
import { zodResolver } from '@hookform/resolvers/zod';
|
|
43
|
+
import { Check, DollarSign, Link2, RefreshCw } from 'lucide-react';
|
|
44
|
+
import { useTranslations } from 'next-intl';
|
|
45
|
+
import { usePathname, useRouter, useSearchParams } from 'next/navigation';
|
|
46
|
+
import { useEffect, useMemo, useState } from 'react';
|
|
47
|
+
import { useForm } from 'react-hook-form';
|
|
48
|
+
import { z } from 'zod';
|
|
49
|
+
import { formatarData, formatarMoeda } from '../../_lib/formatters';
|
|
50
|
+
|
|
51
|
+
type BankAccount = {
|
|
52
|
+
id: string;
|
|
53
|
+
banco: string;
|
|
54
|
+
descricao: string;
|
|
55
|
+
};
|
|
56
|
+
|
|
57
|
+
type Statement = {
|
|
58
|
+
id: string;
|
|
59
|
+
contaBancariaId: string;
|
|
60
|
+
data: string;
|
|
61
|
+
descricao: string;
|
|
62
|
+
valor: number;
|
|
63
|
+
tipo: 'entrada' | 'saida';
|
|
64
|
+
statusConciliacao:
|
|
65
|
+
| 'importado'
|
|
66
|
+
| 'pendente'
|
|
67
|
+
| 'conciliado'
|
|
68
|
+
| 'estornado'
|
|
69
|
+
| 'ajustado';
|
|
70
|
+
};
|
|
71
|
+
|
|
72
|
+
type Installment = {
|
|
73
|
+
id: string;
|
|
74
|
+
vencimento: string;
|
|
75
|
+
valor: number;
|
|
76
|
+
status: string;
|
|
77
|
+
};
|
|
78
|
+
|
|
79
|
+
type FinancialTitle = {
|
|
80
|
+
id: string;
|
|
81
|
+
documento: string;
|
|
82
|
+
fornecedor?: string;
|
|
83
|
+
cliente?: string;
|
|
84
|
+
parcelas: Installment[];
|
|
85
|
+
};
|
|
86
|
+
|
|
87
|
+
type PaginatedResponse<T> = {
|
|
88
|
+
data: T[];
|
|
89
|
+
};
|
|
90
|
+
|
|
91
|
+
type OpenTitleItem = {
|
|
92
|
+
id: string;
|
|
93
|
+
tipo: 'pagar' | 'receber';
|
|
94
|
+
titleId: string;
|
|
95
|
+
installmentId: string;
|
|
96
|
+
documento: string;
|
|
97
|
+
pessoa: string;
|
|
98
|
+
vencimento: string;
|
|
99
|
+
valor: number;
|
|
100
|
+
};
|
|
101
|
+
|
|
102
|
+
type BankReconciliationSummary = {
|
|
103
|
+
discrepancies: number;
|
|
104
|
+
difference: number;
|
|
105
|
+
};
|
|
106
|
+
|
|
107
|
+
const ajusteSchema = z.object({
|
|
108
|
+
type: z.string().trim().min(1),
|
|
109
|
+
value: z.number().min(0.01),
|
|
110
|
+
description: z.string().optional(),
|
|
111
|
+
});
|
|
112
|
+
|
|
113
|
+
type AjusteFormValues = z.infer<typeof ajusteSchema>;
|
|
114
|
+
|
|
115
|
+
function CriarAjusteSheet({
|
|
116
|
+
t,
|
|
117
|
+
contaFilter,
|
|
118
|
+
onCreated,
|
|
119
|
+
}: {
|
|
120
|
+
t: ReturnType<typeof useTranslations>;
|
|
121
|
+
contaFilter: string;
|
|
122
|
+
onCreated: () => Promise<void> | void;
|
|
123
|
+
}) {
|
|
124
|
+
const { request, showToastHandler } = useApp();
|
|
125
|
+
const [open, setOpen] = useState(false);
|
|
126
|
+
|
|
127
|
+
const form = useForm<AjusteFormValues>({
|
|
128
|
+
resolver: zodResolver(ajusteSchema),
|
|
129
|
+
defaultValues: {
|
|
130
|
+
type: '',
|
|
131
|
+
value: 0,
|
|
132
|
+
description: '',
|
|
133
|
+
},
|
|
134
|
+
});
|
|
135
|
+
|
|
136
|
+
useEffect(() => {
|
|
137
|
+
if (!open) {
|
|
138
|
+
return;
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
form.reset({
|
|
142
|
+
type: '',
|
|
143
|
+
value: 0,
|
|
144
|
+
description: '',
|
|
145
|
+
});
|
|
146
|
+
}, [form, open]);
|
|
147
|
+
|
|
148
|
+
const handleSubmit = async (values: AjusteFormValues) => {
|
|
149
|
+
if (!contaFilter) {
|
|
150
|
+
showToastHandler?.('error', 'Selecione uma conta bancária');
|
|
151
|
+
return;
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
try {
|
|
155
|
+
await request({
|
|
156
|
+
url: '/finance/statements/adjustments',
|
|
157
|
+
method: 'POST',
|
|
158
|
+
data: {
|
|
159
|
+
bank_account_id: Number(contaFilter),
|
|
160
|
+
amount: values.value,
|
|
161
|
+
type: values.type,
|
|
162
|
+
description: values.description?.trim() || undefined,
|
|
163
|
+
},
|
|
164
|
+
});
|
|
165
|
+
|
|
166
|
+
await onCreated();
|
|
167
|
+
showToastHandler?.('success', 'Ajuste criado com sucesso');
|
|
168
|
+
setOpen(false);
|
|
169
|
+
} catch {
|
|
170
|
+
showToastHandler?.('error', 'Não foi possível criar o ajuste');
|
|
171
|
+
}
|
|
172
|
+
};
|
|
173
|
+
|
|
174
|
+
return (
|
|
175
|
+
<Sheet open={open} onOpenChange={setOpen}>
|
|
176
|
+
<Button variant="outline" size="sm" onClick={() => setOpen(true)}>
|
|
177
|
+
<DollarSign className="mr-2 h-4 w-4" />
|
|
178
|
+
{t('adjustment.action')}
|
|
179
|
+
</Button>
|
|
180
|
+
|
|
181
|
+
<SheetContent className="w-full sm:max-w-lg overflow-y-auto">
|
|
182
|
+
<SheetHeader>
|
|
183
|
+
<SheetTitle>{t('adjustment.title')}</SheetTitle>
|
|
184
|
+
<SheetDescription>{t('adjustment.description')}</SheetDescription>
|
|
185
|
+
</SheetHeader>
|
|
186
|
+
|
|
187
|
+
<Form {...form}>
|
|
188
|
+
<form
|
|
189
|
+
className="space-y-4 px-4"
|
|
190
|
+
onSubmit={form.handleSubmit(handleSubmit)}
|
|
191
|
+
>
|
|
192
|
+
<FormField
|
|
193
|
+
control={form.control}
|
|
194
|
+
name="type"
|
|
195
|
+
render={({ field }) => (
|
|
196
|
+
<FormItem>
|
|
197
|
+
<FormLabel>{t('adjustment.type')}</FormLabel>
|
|
198
|
+
<Select value={field.value} onValueChange={field.onChange}>
|
|
199
|
+
<FormControl>
|
|
200
|
+
<SelectTrigger>
|
|
201
|
+
<SelectValue placeholder={t('common.select')} />
|
|
202
|
+
</SelectTrigger>
|
|
203
|
+
</FormControl>
|
|
204
|
+
<SelectContent>
|
|
205
|
+
<SelectItem value="tarifa">
|
|
206
|
+
{t('adjustment.types.bankFee')}
|
|
207
|
+
</SelectItem>
|
|
208
|
+
<SelectItem value="juros">
|
|
209
|
+
{t('adjustment.types.interest')}
|
|
210
|
+
</SelectItem>
|
|
211
|
+
<SelectItem value="diferenca">
|
|
212
|
+
{t('adjustment.types.valueDifference')}
|
|
213
|
+
</SelectItem>
|
|
214
|
+
<SelectItem value="outro">
|
|
215
|
+
{t('adjustment.types.other')}
|
|
216
|
+
</SelectItem>
|
|
217
|
+
</SelectContent>
|
|
218
|
+
</Select>
|
|
219
|
+
<FormMessage />
|
|
220
|
+
</FormItem>
|
|
221
|
+
)}
|
|
222
|
+
/>
|
|
223
|
+
|
|
224
|
+
<FormField
|
|
225
|
+
control={form.control}
|
|
226
|
+
name="value"
|
|
227
|
+
render={({ field }) => (
|
|
228
|
+
<FormItem>
|
|
229
|
+
<FormLabel>{t('adjustment.value')}</FormLabel>
|
|
230
|
+
<FormControl>
|
|
231
|
+
<InputMoney
|
|
232
|
+
ref={field.ref}
|
|
233
|
+
name={field.name}
|
|
234
|
+
value={field.value}
|
|
235
|
+
onBlur={field.onBlur}
|
|
236
|
+
onValueChange={(value) => field.onChange(value ?? 0)}
|
|
237
|
+
placeholder="0,00"
|
|
238
|
+
/>
|
|
239
|
+
</FormControl>
|
|
240
|
+
<FormMessage />
|
|
241
|
+
</FormItem>
|
|
242
|
+
)}
|
|
243
|
+
/>
|
|
244
|
+
|
|
245
|
+
<FormField
|
|
246
|
+
control={form.control}
|
|
247
|
+
name="description"
|
|
248
|
+
render={({ field }) => (
|
|
249
|
+
<FormItem>
|
|
250
|
+
<FormLabel>{t('adjustment.details')}</FormLabel>
|
|
251
|
+
<FormControl>
|
|
252
|
+
<Input
|
|
253
|
+
placeholder={t('adjustment.detailsPlaceholder')}
|
|
254
|
+
{...field}
|
|
255
|
+
value={field.value || ''}
|
|
256
|
+
/>
|
|
257
|
+
</FormControl>
|
|
258
|
+
<FormMessage />
|
|
259
|
+
</FormItem>
|
|
260
|
+
)}
|
|
261
|
+
/>
|
|
262
|
+
|
|
263
|
+
<div className="flex justify-end gap-2 pt-4">
|
|
264
|
+
<Button
|
|
265
|
+
type="button"
|
|
266
|
+
variant="outline"
|
|
267
|
+
onClick={() => setOpen(false)}
|
|
268
|
+
>
|
|
269
|
+
{t('common.cancel')}
|
|
270
|
+
</Button>
|
|
271
|
+
<Button type="submit" disabled={form.formState.isSubmitting}>
|
|
272
|
+
{t('adjustment.submit')}
|
|
273
|
+
</Button>
|
|
274
|
+
</div>
|
|
275
|
+
</form>
|
|
276
|
+
</Form>
|
|
277
|
+
</SheetContent>
|
|
278
|
+
</Sheet>
|
|
279
|
+
);
|
|
280
|
+
}
|
|
281
|
+
|
|
282
|
+
export default function ConciliacaoPage() {
|
|
283
|
+
const t = useTranslations('finance.BankReconciliationPage');
|
|
284
|
+
const { request, showToastHandler } = useApp();
|
|
285
|
+
const pathname = usePathname();
|
|
286
|
+
const router = useRouter();
|
|
287
|
+
const searchParams = useSearchParams();
|
|
288
|
+
const bankAccountIdFromUrl = searchParams.get('bank_account_id');
|
|
289
|
+
|
|
290
|
+
const [contaFilter, setContaFilter] = useState<string>('');
|
|
291
|
+
const [selectedExtrato, setSelectedExtrato] = useState<string | null>(null);
|
|
292
|
+
const [selectedTitulo, setSelectedTitulo] = useState<string | null>(null);
|
|
293
|
+
|
|
294
|
+
const { data: contasBancarias = [] } = useQuery<BankAccount[]>({
|
|
295
|
+
queryKey: ['finance-bank-accounts'],
|
|
296
|
+
queryFn: async () => {
|
|
297
|
+
const response = await request({
|
|
298
|
+
url: '/finance/bank-accounts',
|
|
299
|
+
method: 'GET',
|
|
300
|
+
});
|
|
301
|
+
|
|
302
|
+
return (response?.data || []) as BankAccount[];
|
|
303
|
+
},
|
|
304
|
+
});
|
|
305
|
+
|
|
306
|
+
useEffect(() => {
|
|
307
|
+
const firstAccount = contasBancarias[0];
|
|
308
|
+
|
|
309
|
+
if (!firstAccount) {
|
|
310
|
+
return;
|
|
311
|
+
}
|
|
312
|
+
|
|
313
|
+
const hasAccountFromUrl =
|
|
314
|
+
!!bankAccountIdFromUrl &&
|
|
315
|
+
contasBancarias.some((account) => account.id === bankAccountIdFromUrl);
|
|
316
|
+
|
|
317
|
+
const nextAccountId = hasAccountFromUrl
|
|
318
|
+
? (bankAccountIdFromUrl as string)
|
|
319
|
+
: firstAccount.id;
|
|
320
|
+
|
|
321
|
+
if (contaFilter !== nextAccountId) {
|
|
322
|
+
setContaFilter(nextAccountId);
|
|
323
|
+
}
|
|
324
|
+
|
|
325
|
+
if (bankAccountIdFromUrl !== nextAccountId) {
|
|
326
|
+
const params = new URLSearchParams(searchParams.toString());
|
|
327
|
+
params.set('bank_account_id', nextAccountId);
|
|
328
|
+
router.replace(`${pathname}?${params.toString()}`);
|
|
329
|
+
}
|
|
330
|
+
}, [
|
|
331
|
+
bankAccountIdFromUrl,
|
|
332
|
+
contaFilter,
|
|
333
|
+
contasBancarias,
|
|
334
|
+
pathname,
|
|
335
|
+
router,
|
|
336
|
+
searchParams,
|
|
337
|
+
]);
|
|
338
|
+
|
|
339
|
+
const { data: extratos = [], refetch: refetchExtratos } = useQuery<
|
|
340
|
+
Statement[]
|
|
341
|
+
>({
|
|
342
|
+
queryKey: ['finance-statements', contaFilter],
|
|
343
|
+
queryFn: async () => {
|
|
344
|
+
if (!contaFilter) {
|
|
345
|
+
return [];
|
|
346
|
+
}
|
|
347
|
+
|
|
348
|
+
const response = await request({
|
|
349
|
+
url: `/finance/statements?bank_account_id=${contaFilter}`,
|
|
350
|
+
method: 'GET',
|
|
351
|
+
});
|
|
352
|
+
|
|
353
|
+
return (response?.data || []) as Statement[];
|
|
354
|
+
},
|
|
355
|
+
});
|
|
356
|
+
|
|
357
|
+
const { data: reconciliationSummary } = useQuery<BankReconciliationSummary>({
|
|
358
|
+
queryKey: ['finance-bank-reconciliation-summary', contaFilter],
|
|
359
|
+
queryFn: async () => {
|
|
360
|
+
if (!contaFilter) {
|
|
361
|
+
return {
|
|
362
|
+
discrepancies: 0,
|
|
363
|
+
difference: 0,
|
|
364
|
+
};
|
|
365
|
+
}
|
|
366
|
+
|
|
367
|
+
const response = await request<BankReconciliationSummary>({
|
|
368
|
+
url: `/finance/bank-reconciliation/summary?bank_account_id=${contaFilter}`,
|
|
369
|
+
method: 'GET',
|
|
370
|
+
});
|
|
371
|
+
|
|
372
|
+
return (
|
|
373
|
+
(response?.data as BankReconciliationSummary) || {
|
|
374
|
+
discrepancies: 0,
|
|
375
|
+
difference: 0,
|
|
376
|
+
}
|
|
377
|
+
);
|
|
378
|
+
},
|
|
379
|
+
});
|
|
380
|
+
|
|
381
|
+
const { data: titulosPagar = [], refetch: refetchTitulosPagar } = useQuery<
|
|
382
|
+
FinancialTitle[]
|
|
383
|
+
>({
|
|
384
|
+
queryKey: ['finance-payable-titles-open'],
|
|
385
|
+
queryFn: async () => {
|
|
386
|
+
const response = await request<PaginatedResponse<FinancialTitle>>({
|
|
387
|
+
url: '/finance/accounts-payable/installments?page=1&pageSize=200',
|
|
388
|
+
method: 'GET',
|
|
389
|
+
});
|
|
390
|
+
|
|
391
|
+
const payload = response?.data as PaginatedResponse<FinancialTitle>;
|
|
392
|
+
return Array.isArray(payload?.data) ? payload.data : [];
|
|
393
|
+
},
|
|
394
|
+
});
|
|
395
|
+
|
|
396
|
+
const { data: titulosReceber = [], refetch: refetchTitulosReceber } =
|
|
397
|
+
useQuery<FinancialTitle[]>({
|
|
398
|
+
queryKey: ['finance-receivable-titles-open'],
|
|
399
|
+
queryFn: async () => {
|
|
400
|
+
const response = await request<PaginatedResponse<FinancialTitle>>({
|
|
401
|
+
url: '/finance/accounts-receivable/installments?page=1&pageSize=200',
|
|
402
|
+
method: 'GET',
|
|
403
|
+
});
|
|
404
|
+
|
|
405
|
+
const payload = response?.data as PaginatedResponse<FinancialTitle>;
|
|
406
|
+
return Array.isArray(payload?.data) ? payload.data : [];
|
|
407
|
+
},
|
|
408
|
+
});
|
|
409
|
+
|
|
410
|
+
const extratosPendentes = extratos.filter(
|
|
411
|
+
(e) =>
|
|
412
|
+
e.statusConciliacao === 'pendente' || e.statusConciliacao === 'importado'
|
|
413
|
+
);
|
|
414
|
+
|
|
415
|
+
const extratosFiltered = extratosPendentes.filter(
|
|
416
|
+
(e) => e.contaBancariaId === contaFilter
|
|
417
|
+
);
|
|
418
|
+
|
|
419
|
+
const titulosAbertos = useMemo<OpenTitleItem[]>(() => {
|
|
420
|
+
const payables: OpenTitleItem[] = titulosPagar.flatMap((titulo) =>
|
|
421
|
+
(titulo.parcelas || [])
|
|
422
|
+
.filter(
|
|
423
|
+
(parcela) =>
|
|
424
|
+
parcela.status === 'aberto' || parcela.status === 'vencido'
|
|
425
|
+
)
|
|
426
|
+
.map((parcela) => ({
|
|
427
|
+
id: `pagar-${titulo.id}-${parcela.id}`,
|
|
428
|
+
tipo: 'pagar' as const,
|
|
429
|
+
titleId: titulo.id,
|
|
430
|
+
installmentId: parcela.id,
|
|
431
|
+
documento: titulo.documento,
|
|
432
|
+
pessoa: titulo.fornecedor || '',
|
|
433
|
+
vencimento: parcela.vencimento,
|
|
434
|
+
valor: parcela.valor,
|
|
435
|
+
}))
|
|
436
|
+
);
|
|
437
|
+
|
|
438
|
+
const receivables: OpenTitleItem[] = titulosReceber.flatMap((titulo) =>
|
|
439
|
+
(titulo.parcelas || [])
|
|
440
|
+
.filter(
|
|
441
|
+
(parcela) =>
|
|
442
|
+
parcela.status === 'aberto' || parcela.status === 'vencido'
|
|
443
|
+
)
|
|
444
|
+
.map((parcela) => ({
|
|
445
|
+
id: `receber-${titulo.id}-${parcela.id}`,
|
|
446
|
+
tipo: 'receber' as const,
|
|
447
|
+
titleId: titulo.id,
|
|
448
|
+
installmentId: parcela.id,
|
|
449
|
+
documento: titulo.documento,
|
|
450
|
+
pessoa: titulo.cliente || '',
|
|
451
|
+
vencimento: parcela.vencimento,
|
|
452
|
+
valor: parcela.valor,
|
|
453
|
+
}))
|
|
454
|
+
);
|
|
455
|
+
|
|
456
|
+
return [...payables, ...receivables];
|
|
457
|
+
}, [titulosPagar, titulosReceber]);
|
|
458
|
+
|
|
459
|
+
const selectedExtratoItem = extratosFiltered.find(
|
|
460
|
+
(extrato) => extrato.id === selectedExtrato
|
|
461
|
+
);
|
|
462
|
+
const selectedTituloItem = titulosAbertos.find(
|
|
463
|
+
(titulo) => titulo.id === selectedTitulo
|
|
464
|
+
);
|
|
465
|
+
|
|
466
|
+
const titulosCompativeis = useMemo(() => {
|
|
467
|
+
if (!selectedExtratoItem) {
|
|
468
|
+
return titulosAbertos;
|
|
469
|
+
}
|
|
470
|
+
|
|
471
|
+
return titulosAbertos.filter((titulo) =>
|
|
472
|
+
selectedExtratoItem.tipo === 'saida'
|
|
473
|
+
? titulo.tipo === 'pagar'
|
|
474
|
+
: titulo.tipo === 'receber'
|
|
475
|
+
);
|
|
476
|
+
}, [selectedExtratoItem, titulosAbertos]);
|
|
477
|
+
|
|
478
|
+
const totalConciliado = extratos.filter(
|
|
479
|
+
(e) =>
|
|
480
|
+
e.contaBancariaId === contaFilter && e.statusConciliacao === 'conciliado'
|
|
481
|
+
).length;
|
|
482
|
+
const totalExtratoConta = extratos.filter(
|
|
483
|
+
(e) => e.contaBancariaId === contaFilter
|
|
484
|
+
).length;
|
|
485
|
+
const percentualConciliado =
|
|
486
|
+
totalExtratoConta > 0
|
|
487
|
+
? Math.round((totalConciliado / totalExtratoConta) * 100)
|
|
488
|
+
: 0;
|
|
489
|
+
|
|
490
|
+
const handleRefreshData = async () => {
|
|
491
|
+
await Promise.all([
|
|
492
|
+
refetchExtratos(),
|
|
493
|
+
refetchTitulosPagar(),
|
|
494
|
+
refetchTitulosReceber(),
|
|
495
|
+
]);
|
|
496
|
+
};
|
|
497
|
+
|
|
498
|
+
const handleReconcile = async () => {
|
|
499
|
+
if (!selectedExtratoItem || !selectedTituloItem || !contaFilter) {
|
|
500
|
+
return;
|
|
501
|
+
}
|
|
502
|
+
|
|
503
|
+
const endpointBase =
|
|
504
|
+
selectedTituloItem.tipo === 'pagar'
|
|
505
|
+
? '/finance/accounts-payable/installments'
|
|
506
|
+
: '/finance/accounts-receivable/installments';
|
|
507
|
+
|
|
508
|
+
try {
|
|
509
|
+
await request({
|
|
510
|
+
url: `${endpointBase}/${selectedTituloItem.titleId}/settlements`,
|
|
511
|
+
method: 'POST',
|
|
512
|
+
data: {
|
|
513
|
+
installment_id: Number(selectedTituloItem.installmentId),
|
|
514
|
+
amount: Math.abs(selectedExtratoItem.valor),
|
|
515
|
+
settled_at: selectedExtratoItem.data,
|
|
516
|
+
bank_account_id: Number(contaFilter),
|
|
517
|
+
payment_channel: 'transferencia',
|
|
518
|
+
description: selectedExtratoItem.descricao,
|
|
519
|
+
bank_statement_line_id: Number(selectedExtratoItem.id),
|
|
520
|
+
},
|
|
521
|
+
});
|
|
522
|
+
|
|
523
|
+
setSelectedExtrato(null);
|
|
524
|
+
setSelectedTitulo(null);
|
|
525
|
+
await handleRefreshData();
|
|
526
|
+
showToastHandler?.('success', 'Conciliação realizada com sucesso');
|
|
527
|
+
} catch {
|
|
528
|
+
showToastHandler?.('error', 'Não foi possível conciliar os registros');
|
|
529
|
+
}
|
|
530
|
+
};
|
|
531
|
+
|
|
532
|
+
return (
|
|
533
|
+
<Page>
|
|
534
|
+
<PageHeader
|
|
535
|
+
title={t('header.title')}
|
|
536
|
+
description={t('header.description')}
|
|
537
|
+
breadcrumbs={[
|
|
538
|
+
{ label: t('breadcrumbs.home'), href: '/' },
|
|
539
|
+
{ label: t('breadcrumbs.finance'), href: '/finance' },
|
|
540
|
+
{ label: t('breadcrumbs.current') },
|
|
541
|
+
]}
|
|
542
|
+
/>
|
|
543
|
+
|
|
544
|
+
<div className="flex flex-col gap-4 sm:flex-row sm:items-center sm:justify-between">
|
|
545
|
+
<Select
|
|
546
|
+
value={contaFilter}
|
|
547
|
+
onValueChange={(value) => {
|
|
548
|
+
setContaFilter(value);
|
|
549
|
+
setSelectedExtrato(null);
|
|
550
|
+
setSelectedTitulo(null);
|
|
551
|
+
|
|
552
|
+
const params = new URLSearchParams(searchParams.toString());
|
|
553
|
+
params.set('bank_account_id', value);
|
|
554
|
+
router.replace(`${pathname}?${params.toString()}`);
|
|
555
|
+
}}
|
|
556
|
+
>
|
|
557
|
+
<SelectTrigger className="w-full sm:w-[280px]">
|
|
558
|
+
<SelectValue placeholder={t('filters.selectAccount')} />
|
|
559
|
+
</SelectTrigger>
|
|
560
|
+
<SelectContent>
|
|
561
|
+
{contasBancarias.map((conta) => (
|
|
562
|
+
<SelectItem key={conta.id} value={conta.id}>
|
|
563
|
+
{conta.banco} - {conta.descricao}
|
|
564
|
+
</SelectItem>
|
|
565
|
+
))}
|
|
566
|
+
</SelectContent>
|
|
567
|
+
</Select>
|
|
568
|
+
|
|
569
|
+
<div className="flex gap-2">
|
|
570
|
+
<CriarAjusteSheet
|
|
571
|
+
t={t}
|
|
572
|
+
contaFilter={contaFilter}
|
|
573
|
+
onCreated={handleRefreshData}
|
|
574
|
+
/>
|
|
575
|
+
<Button
|
|
576
|
+
disabled={!selectedExtratoItem || !selectedTituloItem}
|
|
577
|
+
onClick={() => void handleReconcile()}
|
|
578
|
+
>
|
|
579
|
+
<Link2 className="mr-2 h-4 w-4" />
|
|
580
|
+
{t('actions.reconcileSelected')}
|
|
581
|
+
</Button>
|
|
582
|
+
</div>
|
|
583
|
+
</div>
|
|
584
|
+
|
|
585
|
+
<div className="grid gap-4 md:grid-cols-4">
|
|
586
|
+
<Card>
|
|
587
|
+
<CardHeader className="pb-2">
|
|
588
|
+
<CardTitle className="text-sm font-medium">
|
|
589
|
+
{t('cards.reconciled')}
|
|
590
|
+
</CardTitle>
|
|
591
|
+
</CardHeader>
|
|
592
|
+
<CardContent>
|
|
593
|
+
<div className="text-2xl font-bold">{percentualConciliado}%</div>
|
|
594
|
+
<Progress value={percentualConciliado} className="mt-2" />
|
|
595
|
+
</CardContent>
|
|
596
|
+
</Card>
|
|
597
|
+
|
|
598
|
+
<Card>
|
|
599
|
+
<CardHeader className="pb-2">
|
|
600
|
+
<CardTitle className="text-sm font-medium">
|
|
601
|
+
{t('cards.pending')}
|
|
602
|
+
</CardTitle>
|
|
603
|
+
</CardHeader>
|
|
604
|
+
<CardContent>
|
|
605
|
+
<div className="text-2xl font-bold">{extratosFiltered.length}</div>
|
|
606
|
+
<p className="text-xs text-muted-foreground">
|
|
607
|
+
{t('cards.transactions')}
|
|
608
|
+
</p>
|
|
609
|
+
</CardContent>
|
|
610
|
+
</Card>
|
|
611
|
+
|
|
612
|
+
<Card>
|
|
613
|
+
<CardHeader className="pb-2">
|
|
614
|
+
<CardTitle className="text-sm font-medium">
|
|
615
|
+
{t('cards.discrepancies')}
|
|
616
|
+
</CardTitle>
|
|
617
|
+
</CardHeader>
|
|
618
|
+
<CardContent>
|
|
619
|
+
<div className="text-2xl font-bold text-orange-600">
|
|
620
|
+
{reconciliationSummary?.discrepancies || 0}
|
|
621
|
+
</div>
|
|
622
|
+
<p className="text-xs text-muted-foreground">
|
|
623
|
+
{t('cards.toResolve')}
|
|
624
|
+
</p>
|
|
625
|
+
</CardContent>
|
|
626
|
+
</Card>
|
|
627
|
+
|
|
628
|
+
<Card>
|
|
629
|
+
<CardHeader className="pb-2">
|
|
630
|
+
<CardTitle className="text-sm font-medium">
|
|
631
|
+
{t('cards.difference')}
|
|
632
|
+
</CardTitle>
|
|
633
|
+
</CardHeader>
|
|
634
|
+
<CardContent>
|
|
635
|
+
<div className="text-2xl font-bold">
|
|
636
|
+
<Money value={reconciliationSummary?.difference || 0} />
|
|
637
|
+
</div>
|
|
638
|
+
<p className="text-xs text-muted-foreground">
|
|
639
|
+
{t('cards.notReconciled')}
|
|
640
|
+
</p>
|
|
641
|
+
</CardContent>
|
|
642
|
+
</Card>
|
|
643
|
+
</div>
|
|
644
|
+
|
|
645
|
+
<div className="grid gap-6 lg:grid-cols-2">
|
|
646
|
+
<Card>
|
|
647
|
+
<CardHeader>
|
|
648
|
+
<CardTitle className="flex items-center gap-2">
|
|
649
|
+
<RefreshCw className="h-4 w-4" />
|
|
650
|
+
{t('statement.title')}
|
|
651
|
+
</CardTitle>
|
|
652
|
+
<CardDescription>{t('statement.description')}</CardDescription>
|
|
653
|
+
</CardHeader>
|
|
654
|
+
<CardContent>
|
|
655
|
+
<div className="space-y-2">
|
|
656
|
+
{extratosFiltered.length > 0 ? (
|
|
657
|
+
extratosFiltered.map((extrato) => (
|
|
658
|
+
<div
|
|
659
|
+
key={extrato.id}
|
|
660
|
+
className={`flex cursor-pointer items-center gap-3 rounded-lg border p-3 transition-colors ${
|
|
661
|
+
selectedExtrato === extrato.id
|
|
662
|
+
? 'border-primary bg-primary/5'
|
|
663
|
+
: 'hover:bg-muted/50'
|
|
664
|
+
}`}
|
|
665
|
+
onClick={() =>
|
|
666
|
+
setSelectedExtrato(
|
|
667
|
+
selectedExtrato === extrato.id ? null : extrato.id
|
|
668
|
+
)
|
|
669
|
+
}
|
|
670
|
+
>
|
|
671
|
+
<Checkbox
|
|
672
|
+
checked={selectedExtrato === extrato.id}
|
|
673
|
+
onCheckedChange={() =>
|
|
674
|
+
setSelectedExtrato(
|
|
675
|
+
selectedExtrato === extrato.id ? null : extrato.id
|
|
676
|
+
)
|
|
677
|
+
}
|
|
678
|
+
/>
|
|
679
|
+
<div className="flex-1">
|
|
680
|
+
<div className="flex items-center justify-between">
|
|
681
|
+
<span className="text-sm font-medium">
|
|
682
|
+
{extrato.descricao}
|
|
683
|
+
</span>
|
|
684
|
+
<span
|
|
685
|
+
className={`font-semibold ${
|
|
686
|
+
extrato.tipo === 'entrada'
|
|
687
|
+
? 'text-green-600'
|
|
688
|
+
: 'text-red-600'
|
|
689
|
+
}`}
|
|
690
|
+
>
|
|
691
|
+
{extrato.tipo === 'saida' && '-'}
|
|
692
|
+
{formatarMoeda(Math.abs(extrato.valor))}
|
|
693
|
+
</span>
|
|
694
|
+
</div>
|
|
695
|
+
<div className="flex items-center gap-2 text-xs text-muted-foreground">
|
|
696
|
+
<span>{formatarData(extrato.data)}</span>
|
|
697
|
+
<StatusBadge
|
|
698
|
+
status={extrato.statusConciliacao}
|
|
699
|
+
type="conciliacao"
|
|
700
|
+
/>
|
|
701
|
+
</div>
|
|
702
|
+
</div>
|
|
703
|
+
</div>
|
|
704
|
+
))
|
|
705
|
+
) : (
|
|
706
|
+
<div className="flex flex-col items-center justify-center py-8 text-center">
|
|
707
|
+
<Check className="h-12 w-12 text-green-500" />
|
|
708
|
+
<p className="mt-2 font-medium">
|
|
709
|
+
{t('statement.emptyTitle')}
|
|
710
|
+
</p>
|
|
711
|
+
<p className="text-sm text-muted-foreground">
|
|
712
|
+
{t('statement.emptyDescription')}
|
|
713
|
+
</p>
|
|
714
|
+
</div>
|
|
715
|
+
)}
|
|
716
|
+
</div>
|
|
717
|
+
</CardContent>
|
|
718
|
+
</Card>
|
|
719
|
+
|
|
720
|
+
<Card>
|
|
721
|
+
<CardHeader>
|
|
722
|
+
<CardTitle className="flex items-center gap-2">
|
|
723
|
+
<DollarSign className="h-4 w-4" />
|
|
724
|
+
{t('openTitles.title')}
|
|
725
|
+
</CardTitle>
|
|
726
|
+
<CardDescription>{t('openTitles.description')}</CardDescription>
|
|
727
|
+
</CardHeader>
|
|
728
|
+
<CardContent>
|
|
729
|
+
<div className="max-h-[400px] space-y-2 overflow-y-auto">
|
|
730
|
+
{titulosCompativeis.map((titulo) => (
|
|
731
|
+
<div
|
|
732
|
+
key={titulo.id}
|
|
733
|
+
className={`flex cursor-pointer items-center gap-3 rounded-lg border p-3 transition-colors ${
|
|
734
|
+
selectedTitulo === titulo.id
|
|
735
|
+
? 'border-primary bg-primary/5'
|
|
736
|
+
: 'hover:bg-muted/50'
|
|
737
|
+
}`}
|
|
738
|
+
onClick={() =>
|
|
739
|
+
setSelectedTitulo(
|
|
740
|
+
selectedTitulo === titulo.id ? null : titulo.id
|
|
741
|
+
)
|
|
742
|
+
}
|
|
743
|
+
>
|
|
744
|
+
<Checkbox
|
|
745
|
+
checked={selectedTitulo === titulo.id}
|
|
746
|
+
onCheckedChange={() =>
|
|
747
|
+
setSelectedTitulo(
|
|
748
|
+
selectedTitulo === titulo.id ? null : titulo.id
|
|
749
|
+
)
|
|
750
|
+
}
|
|
751
|
+
/>
|
|
752
|
+
<div className="flex-1">
|
|
753
|
+
<div className="flex items-center justify-between">
|
|
754
|
+
<div className="flex items-center gap-2">
|
|
755
|
+
<span className="text-sm font-medium">
|
|
756
|
+
{titulo.documento}
|
|
757
|
+
</span>
|
|
758
|
+
<Badge
|
|
759
|
+
variant="outline"
|
|
760
|
+
className={
|
|
761
|
+
titulo.tipo === 'pagar'
|
|
762
|
+
? 'border-red-200 text-red-700'
|
|
763
|
+
: 'border-green-200 text-green-700'
|
|
764
|
+
}
|
|
765
|
+
>
|
|
766
|
+
{titulo.tipo === 'pagar'
|
|
767
|
+
? t('openTitles.pay')
|
|
768
|
+
: t('openTitles.receive')}
|
|
769
|
+
</Badge>
|
|
770
|
+
</div>
|
|
771
|
+
<span className="font-semibold">
|
|
772
|
+
{formatarMoeda(titulo.valor)}
|
|
773
|
+
</span>
|
|
774
|
+
</div>
|
|
775
|
+
<div className="text-xs text-muted-foreground">
|
|
776
|
+
{t('openTitles.personDue', {
|
|
777
|
+
person: titulo.pessoa,
|
|
778
|
+
dueDate: formatarData(titulo.vencimento),
|
|
779
|
+
})}
|
|
780
|
+
</div>
|
|
781
|
+
</div>
|
|
782
|
+
</div>
|
|
783
|
+
))}
|
|
784
|
+
</div>
|
|
785
|
+
</CardContent>
|
|
786
|
+
</Card>
|
|
787
|
+
</div>
|
|
788
|
+
|
|
789
|
+
{selectedExtratoItem && selectedTituloItem && (
|
|
790
|
+
<Card className="border-primary">
|
|
791
|
+
<CardHeader>
|
|
792
|
+
<CardTitle className="flex items-center gap-2 text-primary">
|
|
793
|
+
<Link2 className="h-4 w-4" />
|
|
794
|
+
{t('ready.title')}
|
|
795
|
+
</CardTitle>
|
|
796
|
+
</CardHeader>
|
|
797
|
+
<CardContent>
|
|
798
|
+
<div className="flex items-center justify-between">
|
|
799
|
+
<div>
|
|
800
|
+
<p className="text-sm text-muted-foreground">
|
|
801
|
+
{t('ready.description')}
|
|
802
|
+
</p>
|
|
803
|
+
</div>
|
|
804
|
+
<div className="flex gap-2">
|
|
805
|
+
<Button
|
|
806
|
+
variant="outline"
|
|
807
|
+
onClick={() => {
|
|
808
|
+
setSelectedExtrato(null);
|
|
809
|
+
setSelectedTitulo(null);
|
|
810
|
+
}}
|
|
811
|
+
>
|
|
812
|
+
{t('common.cancel')}
|
|
813
|
+
</Button>
|
|
814
|
+
<Button onClick={() => void handleReconcile()}>
|
|
815
|
+
<Check className="mr-2 h-4 w-4" />
|
|
816
|
+
{t('actions.reconcile')}
|
|
817
|
+
</Button>
|
|
818
|
+
</div>
|
|
819
|
+
</div>
|
|
820
|
+
</CardContent>
|
|
821
|
+
</Card>
|
|
822
|
+
)}
|
|
823
|
+
</Page>
|
|
824
|
+
);
|
|
825
|
+
}
|