@hed-hog/finance 0.0.239 → 0.0.244
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/README.md +1 -22
- package/dist/finance-installments.controller.d.ts +132 -0
- package/dist/finance-installments.controller.d.ts.map +1 -1
- package/dist/finance-installments.controller.js +52 -0
- package/dist/finance-installments.controller.js.map +1 -1
- package/dist/finance-statements.controller.d.ts +8 -0
- package/dist/finance-statements.controller.d.ts.map +1 -1
- package/dist/finance-statements.controller.js +40 -0
- package/dist/finance-statements.controller.js.map +1 -1
- package/dist/finance.module.d.ts.map +1 -1
- package/dist/finance.module.js +1 -0
- package/dist/finance.module.js.map +1 -1
- package/dist/finance.service.d.ts +160 -2
- package/dist/finance.service.d.ts.map +1 -1
- package/dist/finance.service.js +626 -8
- package/dist/finance.service.js.map +1 -1
- package/hedhog/data/route.yaml +54 -0
- package/hedhog/frontend/app/accounts-payable/installments/[id]/page.tsx.ejs +80 -4
- package/hedhog/frontend/app/accounts-payable/installments/page.tsx.ejs +736 -13
- package/hedhog/frontend/app/accounts-receivable/installments/[id]/page.tsx.ejs +1 -1
- package/hedhog/frontend/app/accounts-receivable/installments/page.tsx.ejs +1 -3
- package/hedhog/frontend/app/cash-and-banks/statements/page.tsx.ejs +212 -60
- package/hedhog/frontend/messages/en.json +1 -0
- package/hedhog/frontend/messages/pt.json +1 -0
- package/hedhog/query/constraints.sql +86 -0
- package/hedhog/table/bank_account.yaml +0 -8
- package/hedhog/table/financial_title.yaml +1 -9
- package/hedhog/table/settlement.yaml +0 -8
- package/package.json +6 -6
- package/src/finance-installments.controller.ts +70 -10
- package/src/finance-statements.controller.ts +61 -2
- package/src/finance.module.ts +2 -1
- package/src/finance.service.ts +868 -12
- package/hedhog/table/branch.yaml +0 -18
|
@@ -78,7 +78,7 @@ import {
|
|
|
78
78
|
} from 'lucide-react';
|
|
79
79
|
import { useTranslations } from 'next-intl';
|
|
80
80
|
import Link from 'next/link';
|
|
81
|
-
import { useParams } from 'next/navigation';
|
|
81
|
+
import { useParams, useRouter } from 'next/navigation';
|
|
82
82
|
import { useEffect, useState } from 'react';
|
|
83
83
|
import { useForm } from 'react-hook-form';
|
|
84
84
|
import { z } from 'zod';
|
|
@@ -96,6 +96,7 @@ type SettleFormValues = z.infer<typeof settleSchema>;
|
|
|
96
96
|
export default function TituloDetalhePage() {
|
|
97
97
|
const t = useTranslations('finance.PayableInstallmentDetailPage');
|
|
98
98
|
const { request, showToastHandler } = useApp();
|
|
99
|
+
const router = useRouter();
|
|
99
100
|
const params = useParams<{ id: string }>();
|
|
100
101
|
const id = params?.id;
|
|
101
102
|
const { data, refetch } = useFinanceData();
|
|
@@ -132,7 +133,9 @@ export default function TituloDetalhePage() {
|
|
|
132
133
|
const [isCreatingTag, setIsCreatingTag] = useState(false);
|
|
133
134
|
const [isApproving, setIsApproving] = useState(false);
|
|
134
135
|
const [isSettling, setIsSettling] = useState(false);
|
|
136
|
+
const [isCanceling, setIsCanceling] = useState(false);
|
|
135
137
|
const [isSettleDialogOpen, setIsSettleDialogOpen] = useState(false);
|
|
138
|
+
const [isCancelDialogOpen, setIsCancelDialogOpen] = useState(false);
|
|
136
139
|
const [reversingSettlementId, setReversingSettlementId] = useState<
|
|
137
140
|
string | null
|
|
138
141
|
>(null);
|
|
@@ -358,7 +361,9 @@ export default function TituloDetalhePage() {
|
|
|
358
361
|
};
|
|
359
362
|
|
|
360
363
|
const canApprove = titulo.status === 'rascunho';
|
|
361
|
-
const
|
|
364
|
+
const canEdit = titulo.status === 'rascunho';
|
|
365
|
+
const canSettle = ['aberto', 'parcial', 'vencido'].includes(titulo.status);
|
|
366
|
+
const canCancel = !['cancelado', 'liquidado'].includes(titulo.status);
|
|
362
367
|
|
|
363
368
|
const getErrorMessage = (error: any, fallback: string) => {
|
|
364
369
|
const message = error?.response?.data?.message;
|
|
@@ -453,6 +458,32 @@ export default function TituloDetalhePage() {
|
|
|
453
458
|
}
|
|
454
459
|
};
|
|
455
460
|
|
|
461
|
+
const handleCancel = async () => {
|
|
462
|
+
if (!canCancel || isCanceling) {
|
|
463
|
+
return;
|
|
464
|
+
}
|
|
465
|
+
|
|
466
|
+
setIsCanceling(true);
|
|
467
|
+
try {
|
|
468
|
+
await request({
|
|
469
|
+
url: `/finance/accounts-payable/installments/${titulo.id}/cancel`,
|
|
470
|
+
method: 'PATCH',
|
|
471
|
+
data: {},
|
|
472
|
+
});
|
|
473
|
+
|
|
474
|
+
await refetch();
|
|
475
|
+
setIsCancelDialogOpen(false);
|
|
476
|
+
showToastHandler?.('success', 'Título cancelado com sucesso');
|
|
477
|
+
} catch (error) {
|
|
478
|
+
showToastHandler?.(
|
|
479
|
+
'error',
|
|
480
|
+
getErrorMessage(error, 'Não foi possível cancelar o título')
|
|
481
|
+
);
|
|
482
|
+
} finally {
|
|
483
|
+
setIsCanceling(false);
|
|
484
|
+
}
|
|
485
|
+
};
|
|
486
|
+
|
|
456
487
|
return (
|
|
457
488
|
<Page>
|
|
458
489
|
<PageHeader
|
|
@@ -477,7 +508,14 @@ export default function TituloDetalhePage() {
|
|
|
477
508
|
</Button>
|
|
478
509
|
</DropdownMenuTrigger>
|
|
479
510
|
<DropdownMenuContent align="end">
|
|
480
|
-
<DropdownMenuItem
|
|
511
|
+
<DropdownMenuItem
|
|
512
|
+
disabled={!canEdit}
|
|
513
|
+
onClick={() =>
|
|
514
|
+
router.push(
|
|
515
|
+
`/finance/accounts-payable/installments?editId=${titulo.id}`
|
|
516
|
+
)
|
|
517
|
+
}
|
|
518
|
+
>
|
|
481
519
|
<Edit className="mr-2 h-4 w-4" />
|
|
482
520
|
{t('actions.edit')}
|
|
483
521
|
</DropdownMenuItem>
|
|
@@ -500,13 +538,43 @@ export default function TituloDetalhePage() {
|
|
|
500
538
|
{t('actions.reverse')}
|
|
501
539
|
</DropdownMenuItem>
|
|
502
540
|
<DropdownMenuSeparator />
|
|
503
|
-
<DropdownMenuItem
|
|
541
|
+
<DropdownMenuItem
|
|
542
|
+
className="text-destructive"
|
|
543
|
+
disabled={!canCancel || isCanceling}
|
|
544
|
+
onClick={() => setIsCancelDialogOpen(true)}
|
|
545
|
+
>
|
|
504
546
|
<XCircle className="mr-2 h-4 w-4" />
|
|
505
547
|
{t('actions.cancel')}
|
|
506
548
|
</DropdownMenuItem>
|
|
507
549
|
</DropdownMenuContent>
|
|
508
550
|
</DropdownMenu>
|
|
509
551
|
|
|
552
|
+
<AlertDialog
|
|
553
|
+
open={isCancelDialogOpen}
|
|
554
|
+
onOpenChange={setIsCancelDialogOpen}
|
|
555
|
+
>
|
|
556
|
+
<AlertDialogContent>
|
|
557
|
+
<AlertDialogHeader>
|
|
558
|
+
<AlertDialogTitle>Confirmar cancelamento</AlertDialogTitle>
|
|
559
|
+
<AlertDialogDescription>
|
|
560
|
+
Essa ação altera o título para cancelado e não remove os
|
|
561
|
+
registros de auditoria.
|
|
562
|
+
</AlertDialogDescription>
|
|
563
|
+
</AlertDialogHeader>
|
|
564
|
+
<AlertDialogFooter>
|
|
565
|
+
<AlertDialogCancel disabled={isCanceling}>
|
|
566
|
+
Cancelar
|
|
567
|
+
</AlertDialogCancel>
|
|
568
|
+
<AlertDialogAction
|
|
569
|
+
disabled={isCanceling}
|
|
570
|
+
onClick={() => void handleCancel()}
|
|
571
|
+
>
|
|
572
|
+
Confirmar cancelamento
|
|
573
|
+
</AlertDialogAction>
|
|
574
|
+
</AlertDialogFooter>
|
|
575
|
+
</AlertDialogContent>
|
|
576
|
+
</AlertDialog>
|
|
577
|
+
|
|
510
578
|
<Dialog
|
|
511
579
|
open={isSettleDialogOpen}
|
|
512
580
|
onOpenChange={setIsSettleDialogOpen}
|
|
@@ -665,6 +733,14 @@ export default function TituloDetalhePage() {
|
|
|
665
733
|
<Money value={titulo.valorTotal} />
|
|
666
734
|
</dd>
|
|
667
735
|
</div>
|
|
736
|
+
<div>
|
|
737
|
+
<dt className="text-sm font-medium text-muted-foreground">
|
|
738
|
+
{t('documentData.status')}
|
|
739
|
+
</dt>
|
|
740
|
+
<dd className="mt-1">
|
|
741
|
+
<StatusBadge status={titulo.status} />
|
|
742
|
+
</dd>
|
|
743
|
+
</div>
|
|
668
744
|
<div>
|
|
669
745
|
<dt className="text-sm font-medium text-muted-foreground">
|
|
670
746
|
{t('documentData.category')}
|