mirror of
https://github.com/felipegcoutinho/openmonetis.git
synced 2026-07-09 03:16:01 +00:00
chore: prepara versao 2.7.7
This commit is contained in:
22
CHANGELOG.md
22
CHANGELOG.md
@@ -5,6 +5,28 @@ Todas as mudanças notáveis deste projeto serão documentadas neste arquivo.
|
|||||||
O formato é baseado em [Keep a Changelog](https://keepachangelog.com/pt-BR/1.1.0/),
|
O formato é baseado em [Keep a Changelog](https://keepachangelog.com/pt-BR/1.1.0/),
|
||||||
e este projeto adere ao [Versionamento Semântico](https://semver.org/lang/pt-BR/).
|
e este projeto adere ao [Versionamento Semântico](https://semver.org/lang/pt-BR/).
|
||||||
|
|
||||||
|
## [2.7.7] - 2026-06-20
|
||||||
|
|
||||||
|
Esta versão faz ajustes pontuais de leitura nos resumos financeiros e no dashboard, reforçando a identidade visual de cartões e contas e deixando as listas dos widgets mais consistentes sem alterar a estrutura de navegação das páginas.
|
||||||
|
|
||||||
|
### Alterado
|
||||||
|
- Cartões e contas: os cabeçalhos dos resumos agora destacam melhor o logo, o nome da entidade e o período exibido.
|
||||||
|
- Dashboard: as listas dos widgets agora compartilham padrões de altura, espaçamento, alinhamento e truncamento para melhorar a leitura de valores, status e metadados.
|
||||||
|
|
||||||
|
## [2.7.6] - 2026-06-20
|
||||||
|
|
||||||
|
Esta versão melhora dois fluxos importantes: a importação de planilhas fica mais esperta ao reconhecer categorias já informadas no arquivo, e lançamentos avulsos podem ser reorganizados como parcelamentos ou recorrências sem precisar recriá-los manualmente.
|
||||||
|
|
||||||
|
As funcionalidades desta versão foram desenvolvidas originalmente por Yuri Argolo (`yurnasg`) e adaptadas para integração ao projeto principal.
|
||||||
|
|
||||||
|
### Adicionado
|
||||||
|
- Importação: planilhas XLS/XLSX agora aceitam a coluna `Categoria` no template e tentam mapear automaticamente o valor para uma categoria existente compatível com o tipo do lançamento.
|
||||||
|
- Lançamentos: lançamentos à vista agora podem ser convertidos em recorrentes diretamente pelo menu de ações.
|
||||||
|
- Lançamentos: lançamentos à vista de cartão de crédito agora podem ser convertidos em uma série parcelada informando o total de parcelas.
|
||||||
|
|
||||||
|
### Alterado
|
||||||
|
- Lançamentos: conversões para séries respeitam faturas pagas e limite disponível do cartão antes de criar novos movimentos.
|
||||||
|
|
||||||
## [2.7.5] - 2026-06-13
|
## [2.7.5] - 2026-06-13
|
||||||
|
|
||||||
Esta versão faz um polimento pontual no dashboard, deixando os widgets mais explicativos, consistentes e confiáveis quando há listas maiores ou informações complementares para revisar.
|
Esta versão faz um polimento pontual no dashboard, deixando os widgets mais explicativos, consistentes e confiáveis quando há listas maiores ou informações complementares para revisar.
|
||||||
|
|||||||
@@ -10,7 +10,7 @@
|
|||||||
|
|
||||||
> **Não há versão online hospedada.** Você precisa clonar o repositório e rodar localmente ou no seu próprio servidor.
|
> **Não há versão online hospedada.** Você precisa clonar o repositório e rodar localmente ou no seu próprio servidor.
|
||||||
|
|
||||||
[](CHANGELOG.md)
|
[](CHANGELOG.md)
|
||||||
[](https://nextjs.org/)
|
[](https://nextjs.org/)
|
||||||
[](https://www.typescriptlang.org/)
|
[](https://www.typescriptlang.org/)
|
||||||
[](https://www.postgresql.org/)
|
[](https://www.postgresql.org/)
|
||||||
@@ -65,11 +65,11 @@ A ideia é simples: ter um lugar onde consigo ver todas as minhas contas, cartõ
|
|||||||
|
|
||||||
### Funcionalidades
|
### Funcionalidades
|
||||||
|
|
||||||
💰 **Contas e transações** — Contas bancárias, cartões, dinheiro. Receitas, despesas, rendimentos e transferências. Categorização, divisão de lançamentos entre várias pessoas, filtros combináveis com intervalo de datas, extratos detalhados e importação de extratos OFX e XLS/XLSX com detecção automática de categoria.
|
💰 **Contas e transações** — Contas bancárias, cartões, dinheiro. Receitas, despesas, rendimentos e transferências. Categorização, divisão de lançamentos entre várias pessoas, filtros combináveis com intervalo de datas, extratos detalhados com identificação visual clara da conta e importação de extratos OFX e XLS/XLSX com detecção automática de categoria.
|
||||||
|
|
||||||
📊 **Dashboard e relatórios** — Widgets personalizáveis, métricas com atalhos para lançamentos, gráficos de evolução, comparativos por categoria, tendências, uso de cartões, top estabelecimentos e navegação direta entre meses pelo seletor de período. Exportação em PDF e Excel.
|
📊 **Dashboard e relatórios** — Widgets personalizáveis com listas consistentes, métricas com atalhos para lançamentos, gráficos de evolução, comparativos por categoria, tendências, uso de cartões, top estabelecimentos e navegação direta entre meses pelo seletor de período. Exportação em PDF e Excel.
|
||||||
|
|
||||||
💳 **Faturas de cartão** — Acompanhe faturas por período, controle limites e vencimentos.
|
💳 **Faturas de cartão** — Acompanhe faturas por período, controle limites e vencimentos com identificação visual mais clara do cartão.
|
||||||
|
|
||||||
🎯 **Orçamentos** — Defina limites por categoria e acompanhe o progresso.
|
🎯 **Orçamentos** — Defina limites por categoria e acompanhe o progresso.
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "openmonetis",
|
"name": "openmonetis",
|
||||||
"version": "2.7.5",
|
"version": "2.7.7",
|
||||||
"private": true,
|
"private": true,
|
||||||
"packageManager": "pnpm@11.1.3",
|
"packageManager": "pnpm@11.1.3",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
"use client";
|
"use client";
|
||||||
|
|
||||||
import { RiInformationLine } from "@remixicon/react";
|
import { RiBankLine, RiInformationLine } from "@remixicon/react";
|
||||||
import Image from "next/image";
|
import Image from "next/image";
|
||||||
import type { ReactNode } from "react";
|
import type { ReactNode } from "react";
|
||||||
import MoneyValues from "@/shared/components/money-values";
|
import MoneyValues from "@/shared/components/money-values";
|
||||||
@@ -52,28 +52,32 @@ export function AccountStatementCard({
|
|||||||
const resultado = totalIncomes - totalExpenses;
|
const resultado = totalIncomes - totalExpenses;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Card className="gap-0 py-0">
|
<Card className="gap-0 py-0 space-y-2">
|
||||||
<CardContent className="px-4 py-4 sm:px-5 sm:py-5">
|
<CardContent className="px-4 py-4 sm:px-5 sm:py-5">
|
||||||
<div className="flex flex-col gap-4">
|
<div className="flex flex-col gap-4">
|
||||||
{/* Linha 1 — identidade */}
|
{/* Linha 1 — identidade */}
|
||||||
<div className="flex items-center justify-between gap-3">
|
<div className="flex flex-col gap-4 sm:flex-row sm:items-start sm:justify-between">
|
||||||
<div className="flex min-w-0 items-center gap-3">
|
<div className="flex min-w-0 items-start gap-3">
|
||||||
{logoPath ? (
|
{logoPath ? (
|
||||||
<div className="flex size-12 shrink-0 items-center justify-center overflow-hidden rounded-full">
|
<div className="flex size-12 shrink-0 items-center justify-center overflow-hidden rounded-full">
|
||||||
<Image
|
<Image
|
||||||
src={logoPath}
|
src={logoPath}
|
||||||
alt={`Logo ${accountName}`}
|
alt={`Logo ${accountName}`}
|
||||||
width={42}
|
width={48}
|
||||||
height={42}
|
height={48}
|
||||||
className="h-full w-full object-contain"
|
className="h-full w-full object-contain"
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
) : null}
|
) : (
|
||||||
<div className="min-w-0">
|
<span className="flex size-12 shrink-0 items-center justify-center rounded-full border bg-card text-primary">
|
||||||
<h2 className="truncate text-sm font-semibold text-foreground">
|
<RiBankLine className="size-5" aria-hidden />
|
||||||
|
</span>
|
||||||
|
)}
|
||||||
|
<div className="min-w-0 space-y-1">
|
||||||
|
<h2 className="truncate text-xl font-semibold text-foreground sm:text-2xl">
|
||||||
{accountName}
|
{accountName}
|
||||||
</h2>
|
</h2>
|
||||||
<p className="text-xs text-muted-foreground">
|
<p className="text-sm leading-relaxed text-muted-foreground">
|
||||||
Extrato de {periodLabel}
|
Extrato de {periodLabel}
|
||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ import {
|
|||||||
isIncomeBill,
|
isIncomeBill,
|
||||||
} from "@/features/dashboard/bills/bills-helpers";
|
} from "@/features/dashboard/bills/bills-helpers";
|
||||||
import type { DashboardBill } from "@/features/dashboard/bills/bills-queries";
|
import type { DashboardBill } from "@/features/dashboard/bills/bills-queries";
|
||||||
|
import { dashboardWidgetListStyles as styles } from "@/features/dashboard/components/dashboard-widget-list-styles";
|
||||||
import { EstablishmentLogo } from "@/shared/components/entity-avatar";
|
import { EstablishmentLogo } from "@/shared/components/entity-avatar";
|
||||||
import MoneyValues from "@/shared/components/money-values";
|
import MoneyValues from "@/shared/components/money-values";
|
||||||
import { Button } from "@/shared/components/ui/button";
|
import { Button } from "@/shared/components/ui/button";
|
||||||
@@ -47,18 +48,15 @@ export function BillListItem({ bill, period, onPay }: BillListItemProps) {
|
|||||||
const href = buildTransactionsHref(bill.name, period);
|
const href = buildTransactionsHref(bill.name, period);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<li className="flex items-center justify-between transition-all duration-300 py-1.5">
|
<li className={styles.row}>
|
||||||
<div className="flex min-w-0 flex-1 items-center gap-2 py-0.5">
|
<div className={styles.main}>
|
||||||
<EstablishmentLogo name={bill.name} size={37} />
|
<EstablishmentLogo name={bill.name} size={37} />
|
||||||
|
|
||||||
<div className="min-w-0">
|
<div className={styles.textStack}>
|
||||||
<Link
|
<Link href={href} className={styles.titleLink}>
|
||||||
href={href}
|
|
||||||
className="inline-flex max-w-full items-center gap-1 text-sm font-medium text-foreground underline-offset-2 hover:text-primary hover:underline"
|
|
||||||
>
|
|
||||||
<span className="truncate">{bill.name}</span>
|
<span className="truncate">{bill.name}</span>
|
||||||
</Link>
|
</Link>
|
||||||
<div className="flex flex-wrap items-center gap-2 text-xs text-muted-foreground">
|
<div className={styles.meta}>
|
||||||
{statusLabel ? (
|
{statusLabel ? (
|
||||||
statusTooltipLabel ? (
|
statusTooltipLabel ? (
|
||||||
<Tooltip>
|
<Tooltip>
|
||||||
@@ -92,10 +90,10 @@ export function BillListItem({ bill, period, onPay }: BillListItemProps) {
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div className="flex shrink-0 flex-col items-end">
|
<div className={styles.trailing}>
|
||||||
<MoneyValues className="font-medium" amount={bill.amount} />
|
<MoneyValues className={styles.trailingValue} amount={bill.amount} />
|
||||||
{bill.isSettled ? (
|
{bill.isSettled ? (
|
||||||
<span className="flex h-7 items-center gap-0.5 text-xs font-medium text-success">
|
<span className={`${styles.trailingMeta} text-success`}>
|
||||||
<RiCheckboxCircleFill className="size-3.5" />{" "}
|
<RiCheckboxCircleFill className="size-3.5" />{" "}
|
||||||
{income ? "Recebido" : "Pago"}
|
{income ? "Recebido" : "Pago"}
|
||||||
</span>
|
</span>
|
||||||
@@ -104,7 +102,7 @@ export function BillListItem({ bill, period, onPay }: BillListItemProps) {
|
|||||||
type="button"
|
type="button"
|
||||||
size="sm"
|
size="sm"
|
||||||
variant="link"
|
variant="link"
|
||||||
className="-mr-1.5 h-7 px-1.5 py-0"
|
className={styles.actionButton}
|
||||||
onClick={() => onPay(bill.id)}
|
onClick={() => onPay(bill.id)}
|
||||||
>
|
>
|
||||||
{overdue ? (
|
{overdue ? (
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
import Link from "next/link";
|
import Link from "next/link";
|
||||||
import type { DashboardCategoryBreakdownItem } from "@/features/dashboard/categories/category-breakdown-helpers";
|
import type { DashboardCategoryBreakdownItem } from "@/features/dashboard/categories/category-breakdown-helpers";
|
||||||
|
import { dashboardWidgetListStyles as styles } from "@/features/dashboard/components/dashboard-widget-list-styles";
|
||||||
import { PercentageChangeIndicator } from "@/features/dashboard/components/percentage-change-indicator";
|
import { PercentageChangeIndicator } from "@/features/dashboard/components/percentage-change-indicator";
|
||||||
import { CategoryIconBadge } from "@/shared/components/entity-avatar";
|
import { CategoryIconBadge } from "@/shared/components/entity-avatar";
|
||||||
import MoneyValues from "@/shared/components/money-values";
|
import MoneyValues from "@/shared/components/money-values";
|
||||||
@@ -45,25 +46,23 @@ export function CategoryBreakdownListItem({
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<div>
|
<div>
|
||||||
<div className="flex items-center justify-between gap-2 transition-all duration-300 py-1.5">
|
<div className={styles.row}>
|
||||||
<span className="w-3 shrink-0 text-left text-xs font-medium text-muted-foreground">
|
<span className={styles.rank}>{position}</span>
|
||||||
{position}
|
<div className={styles.main}>
|
||||||
</span>
|
|
||||||
<div className="flex min-w-0 flex-1 items-center gap-2">
|
|
||||||
<CategoryIconBadge
|
<CategoryIconBadge
|
||||||
icon={category.categoryIcon}
|
icon={category.categoryIcon}
|
||||||
name={category.categoryName}
|
name={category.categoryName}
|
||||||
/>
|
/>
|
||||||
<div className="min-w-0 flex-1">
|
<div className={styles.textStack}>
|
||||||
<div className="flex items-center gap-2">
|
<div className="flex items-center gap-2">
|
||||||
<Link
|
<Link
|
||||||
href={`/categories/${category.categoryId}?periodo=${periodParam}`}
|
href={`/categories/${category.categoryId}?periodo=${periodParam}`}
|
||||||
className="flex max-w-full items-center gap-1 text-sm font-medium text-foreground underline-offset-2 hover:text-primary hover:underline"
|
className={styles.titleLink}
|
||||||
>
|
>
|
||||||
<span className="truncate">{category.categoryName}</span>
|
<span className="truncate">{category.categoryName}</span>
|
||||||
</Link>
|
</Link>
|
||||||
</div>
|
</div>
|
||||||
<div className="flex flex-wrap items-center gap-x-1 text-xs text-muted-foreground">
|
<div className={styles.meta}>
|
||||||
<span>
|
<span>
|
||||||
{formatPercentage(
|
{formatPercentage(
|
||||||
category.percentageOfTotal,
|
category.percentageOfTotal,
|
||||||
@@ -97,13 +96,13 @@ export function CategoryBreakdownListItem({
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div className="flex shrink-0 flex-col items-end gap-0.5">
|
<div className={styles.trailing}>
|
||||||
<MoneyValues
|
<MoneyValues
|
||||||
className="text-foreground font-medium"
|
className={styles.trailingValue}
|
||||||
amount={category.currentAmount}
|
amount={category.currentAmount}
|
||||||
/>
|
/>
|
||||||
{category.percentageChange !== null ? (
|
{category.percentageChange !== null ? (
|
||||||
<span className="flex items-center gap-1 text-xs text-muted-foreground">
|
<span className={`${styles.trailingMeta} text-muted-foreground`}>
|
||||||
<PercentageChangeIndicator
|
<PercentageChangeIndicator
|
||||||
value={category.percentageChange}
|
value={category.percentageChange}
|
||||||
label={formatPercentage(
|
label={formatPercentage(
|
||||||
|
|||||||
@@ -0,0 +1,15 @@
|
|||||||
|
export const dashboardWidgetListStyles = {
|
||||||
|
row: "flex min-h-[3.25rem] items-center justify-between gap-2 py-1.5 transition-all duration-300",
|
||||||
|
main: "flex min-w-0 flex-1 items-center gap-2",
|
||||||
|
textStack: "min-w-0 flex-1 space-y-0.5",
|
||||||
|
title: "truncate text-sm font-medium leading-5 text-foreground",
|
||||||
|
titleLink:
|
||||||
|
"inline-flex max-w-full items-center gap-1 text-sm font-medium leading-5 text-foreground underline-offset-2 hover:text-primary hover:underline",
|
||||||
|
meta: "flex min-h-4 flex-wrap items-center gap-x-2 gap-y-0.5 text-xs leading-4 text-muted-foreground",
|
||||||
|
rank: "w-3 shrink-0 text-left text-xs font-medium leading-4 text-muted-foreground",
|
||||||
|
trailing:
|
||||||
|
"flex min-w-[5.75rem] shrink-0 flex-col items-end gap-0.5 text-right",
|
||||||
|
trailingValue: "font-medium leading-5",
|
||||||
|
trailingMeta: "flex h-5 items-center gap-0.5 text-xs font-medium leading-4",
|
||||||
|
actionButton: "-mr-1 h-5 px-1 py-0 text-xs leading-4",
|
||||||
|
};
|
||||||
@@ -1,5 +1,6 @@
|
|||||||
import { RiPencilLine } from "@remixicon/react";
|
import { RiPencilLine } from "@remixicon/react";
|
||||||
import Link from "next/link";
|
import Link from "next/link";
|
||||||
|
import { dashboardWidgetListStyles as styles } from "@/features/dashboard/components/dashboard-widget-list-styles";
|
||||||
import {
|
import {
|
||||||
clampGoalProgress,
|
clampGoalProgress,
|
||||||
formatGoalProgressPercentage,
|
formatGoalProgressPercentage,
|
||||||
@@ -30,7 +31,7 @@ export function GoalProgressItem({ item, onEdit }: GoalProgressItemProps) {
|
|||||||
const usedPercentageLabel = formatGoalProgressPercentage(item.usedPercentage);
|
const usedPercentageLabel = formatGoalProgressPercentage(item.usedPercentage);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<li className="group py-2 transition-all duration-300">
|
<li className="group py-1.5 transition-all duration-300">
|
||||||
<div className="flex items-start justify-between gap-3">
|
<div className="flex items-start justify-between gap-3">
|
||||||
<div className="flex min-w-0 flex-1 items-start gap-2">
|
<div className="flex min-w-0 flex-1 items-start gap-2">
|
||||||
<CategoryIconBadge
|
<CategoryIconBadge
|
||||||
@@ -42,16 +43,14 @@ export function GoalProgressItem({ item, onEdit }: GoalProgressItemProps) {
|
|||||||
{item.categoryId ? (
|
{item.categoryId ? (
|
||||||
<Link
|
<Link
|
||||||
href={`/categories/${item.categoryId}?periodo=${formatPeriodForUrl(item.period)}`}
|
href={`/categories/${item.categoryId}?periodo=${formatPeriodForUrl(item.period)}`}
|
||||||
className="block truncate text-sm font-medium text-foreground underline-offset-2 hover:text-primary hover:underline"
|
className={`${styles.title} block underline-offset-2 hover:text-primary hover:underline`}
|
||||||
>
|
>
|
||||||
{item.categoryName}
|
{item.categoryName}
|
||||||
</Link>
|
</Link>
|
||||||
) : (
|
) : (
|
||||||
<p className="truncate text-sm font-medium text-foreground">
|
<p className={styles.title}>{item.categoryName}</p>
|
||||||
{item.categoryName}
|
|
||||||
</p>
|
|
||||||
)}
|
)}
|
||||||
<p className="mt-0.5 text-xs text-muted-foreground">
|
<p className="mt-0.5 text-xs leading-4 text-muted-foreground">
|
||||||
<MoneyValues className="font-medium" amount={item.spentAmount} />{" "}
|
<MoneyValues className="font-medium" amount={item.spentAmount} />{" "}
|
||||||
de{" "}
|
de{" "}
|
||||||
<MoneyValues className="font-medium" amount={item.budgetAmount} />
|
<MoneyValues className="font-medium" amount={item.budgetAmount} />
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
import { RiCheckboxCircleFill, RiGroupLine } from "@remixicon/react";
|
import { RiCheckboxCircleFill, RiGroupLine } from "@remixicon/react";
|
||||||
import Link from "next/link";
|
import Link from "next/link";
|
||||||
|
import { dashboardWidgetListStyles as styles } from "@/features/dashboard/components/dashboard-widget-list-styles";
|
||||||
import { PercentageChangeIndicator } from "@/features/dashboard/components/percentage-change-indicator";
|
import { PercentageChangeIndicator } from "@/features/dashboard/components/percentage-change-indicator";
|
||||||
import {
|
import {
|
||||||
buildInvoiceDetailsHref,
|
buildInvoiceDetailsHref,
|
||||||
@@ -62,18 +63,14 @@ export function InvoiceListItem({ invoice, onPay }: InvoiceListItemProps) {
|
|||||||
: null;
|
: null;
|
||||||
|
|
||||||
const linkNode = (
|
const linkNode = (
|
||||||
<Link
|
<Link prefetch href={detailHref} className={styles.titleLink}>
|
||||||
prefetch
|
|
||||||
href={detailHref}
|
|
||||||
className="inline-flex max-w-full items-center gap-1 text-sm font-medium text-foreground underline-offset-2 hover:text-primary hover:underline"
|
|
||||||
>
|
|
||||||
<span className="truncate">{invoice.cardName}</span>
|
<span className="truncate">{invoice.cardName}</span>
|
||||||
</Link>
|
</Link>
|
||||||
);
|
);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<li className="flex items-center justify-between transition-all duration-300 py-1.5">
|
<li className={styles.row}>
|
||||||
<div className="flex min-w-0 flex-1 items-center gap-2 py-1">
|
<div className={styles.main}>
|
||||||
<InvoiceLogo
|
<InvoiceLogo
|
||||||
cardName={invoice.cardName}
|
cardName={invoice.cardName}
|
||||||
logo={invoice.logo}
|
logo={invoice.logo}
|
||||||
@@ -81,7 +78,7 @@ export function InvoiceListItem({ invoice, onPay }: InvoiceListItemProps) {
|
|||||||
containerClassName="size-9.5"
|
containerClassName="size-9.5"
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<div className="min-w-0">
|
<div className={styles.textStack}>
|
||||||
<div className="flex max-w-full items-center gap-1">
|
<div className="flex max-w-full items-center gap-1">
|
||||||
{hasBreakdown ? (
|
{hasBreakdown ? (
|
||||||
<HoverCard openDelay={150}>
|
<HoverCard openDelay={150}>
|
||||||
@@ -155,7 +152,7 @@ export function InvoiceListItem({ invoice, onPay }: InvoiceListItemProps) {
|
|||||||
) : null}
|
) : null}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div className="flex flex-wrap items-center gap-2 text-xs text-muted-foreground">
|
<div className={styles.meta}>
|
||||||
{!isPaid ? (
|
{!isPaid ? (
|
||||||
dueTooltipLabel ? (
|
dueTooltipLabel ? (
|
||||||
<Tooltip>
|
<Tooltip>
|
||||||
@@ -204,13 +201,13 @@ export function InvoiceListItem({ invoice, onPay }: InvoiceListItemProps) {
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div className="flex shrink-0 flex-col items-end">
|
<div className={styles.trailing}>
|
||||||
<MoneyValues
|
<MoneyValues
|
||||||
className="font-medium"
|
className={styles.trailingValue}
|
||||||
amount={Math.abs(invoice.totalAmount)}
|
amount={Math.abs(invoice.totalAmount)}
|
||||||
/>
|
/>
|
||||||
{isPaid ? (
|
{isPaid ? (
|
||||||
<span className="flex h-7 items-center gap-0.5 text-xs font-medium text-success">
|
<span className={`${styles.trailingMeta} text-success`}>
|
||||||
<RiCheckboxCircleFill className="size-3.5" /> Pago
|
<RiCheckboxCircleFill className="size-3.5" /> Pago
|
||||||
</span>
|
</span>
|
||||||
) : (
|
) : (
|
||||||
@@ -218,7 +215,7 @@ export function InvoiceListItem({ invoice, onPay }: InvoiceListItemProps) {
|
|||||||
type="button"
|
type="button"
|
||||||
size="sm"
|
size="sm"
|
||||||
variant="link"
|
variant="link"
|
||||||
className="-mr-1.5 h-7 px-1.5 py-0"
|
className={styles.actionButton}
|
||||||
onClick={() => onPay(invoice.id)}
|
onClick={() => onPay(invoice.id)}
|
||||||
>
|
>
|
||||||
{isOverdue ? (
|
{isOverdue ? (
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ import {
|
|||||||
RiFileList2Line,
|
RiFileList2Line,
|
||||||
RiPencilLine,
|
RiPencilLine,
|
||||||
} from "@remixicon/react";
|
} from "@remixicon/react";
|
||||||
|
import { dashboardWidgetListStyles as styles } from "@/features/dashboard/components/dashboard-widget-list-styles";
|
||||||
import type { Note } from "@/features/notes/components/types";
|
import type { Note } from "@/features/notes/components/types";
|
||||||
import {
|
import {
|
||||||
buildNoteDisplayTitle,
|
buildNoteDisplayTitle,
|
||||||
@@ -33,18 +34,16 @@ export function NoteListItem({
|
|||||||
const isTask = note.type === "tarefa";
|
const isTask = note.type === "tarefa";
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<li className="group flex items-center justify-between gap-2 py-1.5 transition-all duration-300">
|
<li className={`group ${styles.row}`}>
|
||||||
<div className="min-w-0 flex-1">
|
<div className={styles.textStack}>
|
||||||
<p className="truncate text-sm font-medium text-foreground">
|
<p className={styles.title}>{displayTitle}</p>
|
||||||
{displayTitle}
|
<div className={styles.meta}>
|
||||||
</p>
|
|
||||||
<div className="mt-1 flex min-w-0 items-center gap-2">
|
|
||||||
{isTask ? (
|
{isTask ? (
|
||||||
<Badge variant="outline" className="h-5 px-1.5 text-xs">
|
<Badge variant="outline" className="h-5 px-1.5 text-xs">
|
||||||
{getNoteTasksSummary(note)}
|
{getNoteTasksSummary(note)}
|
||||||
</Badge>
|
</Badge>
|
||||||
) : null}
|
) : null}
|
||||||
<p className="truncate text-xs text-muted-foreground">
|
<p className="truncate">
|
||||||
<span className="inline-flex items-center gap-1">
|
<span className="inline-flex items-center gap-1">
|
||||||
<RiCalendarLine className="size-3.5 shrink-0" />
|
<RiCalendarLine className="size-3.5 shrink-0" />
|
||||||
{createdAtLabel}
|
{createdAtLabel}
|
||||||
@@ -53,7 +52,7 @@ export function NoteListItem({
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div className="flex shrink-0 items-center gap-0.5">
|
<div className="flex min-w-[4.5rem] shrink-0 items-center justify-end gap-0.5">
|
||||||
<Tooltip>
|
<Tooltip>
|
||||||
<TooltipTrigger asChild>
|
<TooltipTrigger asChild>
|
||||||
<Button
|
<Button
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
import Link from "next/link";
|
import Link from "next/link";
|
||||||
import type { ReactNode } from "react";
|
import type { ReactNode } from "react";
|
||||||
|
import { dashboardWidgetListStyles as styles } from "@/features/dashboard/components/dashboard-widget-list-styles";
|
||||||
import {
|
import {
|
||||||
formatPaymentBreakdownPercentage,
|
formatPaymentBreakdownPercentage,
|
||||||
formatPaymentBreakdownTransactionsLabel,
|
formatPaymentBreakdownTransactionsLabel,
|
||||||
@@ -31,10 +32,8 @@ export function PaymentBreakdownListItem({
|
|||||||
position,
|
position,
|
||||||
}: PaymentBreakdownListItemProps) {
|
}: PaymentBreakdownListItemProps) {
|
||||||
return (
|
return (
|
||||||
<div className="flex items-center gap-2 transition-all duration-300 py-1">
|
<div className={styles.row}>
|
||||||
<span className="w-3 shrink-0 text-left text-xs font-medium text-muted-foreground">
|
<span className={styles.rank}>{position}</span>
|
||||||
{position}
|
|
||||||
</span>
|
|
||||||
<div
|
<div
|
||||||
className="flex size-9.5 shrink-0 items-center justify-center rounded-full"
|
className="flex size-9.5 shrink-0 items-center justify-center rounded-full"
|
||||||
style={{
|
style={{
|
||||||
@@ -45,26 +44,26 @@ export function PaymentBreakdownListItem({
|
|||||||
{item.icon}
|
{item.icon}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div className="min-w-0 flex-1">
|
<div className={styles.textStack}>
|
||||||
<div className="flex items-center justify-between">
|
<div className="flex items-center justify-between gap-2">
|
||||||
{item.href ? (
|
{item.href ? (
|
||||||
<Link
|
<Link href={item.href} className={styles.titleLink}>
|
||||||
href={item.href}
|
|
||||||
className="inline-flex items-center gap-1 text-sm font-medium text-foreground underline-offset-2 hover:text-primary hover:underline"
|
|
||||||
>
|
|
||||||
<span className="truncate">{item.title}</span>
|
<span className="truncate">{item.title}</span>
|
||||||
</Link>
|
</Link>
|
||||||
) : (
|
) : (
|
||||||
<p className="text-sm font-medium text-foreground">{item.title}</p>
|
<p className={styles.title}>{item.title}</p>
|
||||||
)}
|
)}
|
||||||
<MoneyValues className="shrink-0 font-medium" amount={item.amount} />
|
<MoneyValues
|
||||||
|
className={`shrink-0 ${styles.trailingValue}`}
|
||||||
|
amount={item.amount}
|
||||||
|
/>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div className="flex items-center justify-between text-xs text-muted-foreground">
|
<div className={styles.meta}>
|
||||||
<span>
|
<span>
|
||||||
{formatPaymentBreakdownTransactionsLabel(item.transactions)}
|
{formatPaymentBreakdownTransactionsLabel(item.transactions)}
|
||||||
</span>
|
</span>
|
||||||
<span>
|
<span className="ml-auto">
|
||||||
{formatPaymentBreakdownPercentage(item.percentage)} do total
|
{formatPaymentBreakdownPercentage(item.percentage)} do total
|
||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ import {
|
|||||||
import { useState } from "react";
|
import { useState } from "react";
|
||||||
import { AttachmentPreview } from "@/features/attachments/components/attachment-preview";
|
import { AttachmentPreview } from "@/features/attachments/components/attachment-preview";
|
||||||
import type { AttachmentForPeriod } from "@/features/attachments/queries";
|
import type { AttachmentForPeriod } from "@/features/attachments/queries";
|
||||||
|
import { dashboardWidgetListStyles as styles } from "@/features/dashboard/components/dashboard-widget-list-styles";
|
||||||
import {
|
import {
|
||||||
Tooltip,
|
Tooltip,
|
||||||
TooltipContent,
|
TooltipContent,
|
||||||
@@ -77,7 +78,7 @@ export function AttachmentsWidget({ snapshot }: AttachmentsWidgetProps) {
|
|||||||
<button
|
<button
|
||||||
type="button"
|
type="button"
|
||||||
onClick={() => setSelectedIndex(index)}
|
onClick={() => setSelectedIndex(index)}
|
||||||
className="flex w-full items-center gap-2 py-2 text-left"
|
className={`${styles.row} w-full text-left`}
|
||||||
>
|
>
|
||||||
<div className="shrink-0">
|
<div className="shrink-0">
|
||||||
{isPdf && <RiFilePdf2Line className="size-6 text-red-500" />}
|
{isPdf && <RiFilePdf2Line className="size-6 text-red-500" />}
|
||||||
@@ -86,10 +87,10 @@ export function AttachmentsWidget({ snapshot }: AttachmentsWidgetProps) {
|
|||||||
<RiFileLine className="size-6 text-muted-foreground" />
|
<RiFileLine className="size-6 text-muted-foreground" />
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
<div className="min-w-0 flex-1">
|
<div className={styles.textStack}>
|
||||||
<Tooltip>
|
<Tooltip>
|
||||||
<TooltipTrigger asChild>
|
<TooltipTrigger asChild>
|
||||||
<span className="block truncate text-sm font-medium text-foreground hover:underline">
|
<span className={`${styles.title} block hover:underline`}>
|
||||||
{attachment.fileName}
|
{attachment.fileName}
|
||||||
</span>
|
</span>
|
||||||
</TooltipTrigger>
|
</TooltipTrigger>
|
||||||
@@ -97,18 +98,18 @@ export function AttachmentsWidget({ snapshot }: AttachmentsWidgetProps) {
|
|||||||
{attachment.fileName}
|
{attachment.fileName}
|
||||||
</TooltipContent>
|
</TooltipContent>
|
||||||
</Tooltip>
|
</Tooltip>
|
||||||
<span className="block truncate text-xs text-muted-foreground">
|
<span className={`${styles.meta} block truncate`}>
|
||||||
{attachment.transactionName}
|
{attachment.transactionName}
|
||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
<div className="shrink-0 text-right">
|
<div className={styles.trailing}>
|
||||||
<span className="block text-xs text-muted-foreground">
|
<span className="block text-xs leading-4 text-muted-foreground">
|
||||||
{formatDateOnly(attachment.purchaseDate, {
|
{formatDateOnly(attachment.purchaseDate, {
|
||||||
day: "2-digit",
|
day: "2-digit",
|
||||||
month: "2-digit",
|
month: "2-digit",
|
||||||
}) ?? "—"}
|
}) ?? "—"}
|
||||||
</span>
|
</span>
|
||||||
<span className="block text-xs text-muted-foreground/60">
|
<span className="block text-xs leading-4 text-muted-foreground/60">
|
||||||
{formatBytes(attachment.fileSize)}
|
{formatBytes(attachment.fileSize)}
|
||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ import {
|
|||||||
RiLineChartLine,
|
RiLineChartLine,
|
||||||
} from "@remixicon/react";
|
} from "@remixicon/react";
|
||||||
import type { DashboardCategoryBreakdownItem } from "@/features/dashboard/categories/category-breakdown-helpers";
|
import type { DashboardCategoryBreakdownItem } from "@/features/dashboard/categories/category-breakdown-helpers";
|
||||||
|
import { dashboardWidgetListStyles as styles } from "@/features/dashboard/components/dashboard-widget-list-styles";
|
||||||
import { PercentageChangeIndicator } from "@/features/dashboard/components/percentage-change-indicator";
|
import { PercentageChangeIndicator } from "@/features/dashboard/components/percentage-change-indicator";
|
||||||
import { CategoryIconBadge } from "@/shared/components/entity-avatar";
|
import { CategoryIconBadge } from "@/shared/components/entity-avatar";
|
||||||
import MoneyValues from "@/shared/components/money-values";
|
import MoneyValues from "@/shared/components/money-values";
|
||||||
@@ -45,17 +46,15 @@ export function CategoryTrendsWidget({
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<li key={category.categoryId}>
|
<li key={category.categoryId}>
|
||||||
<div className="-mx-2 flex items-center gap-3 rounded-md p-2">
|
<div className={styles.row}>
|
||||||
<CategoryIconBadge
|
<CategoryIconBadge
|
||||||
icon={category.categoryIcon}
|
icon={category.categoryIcon}
|
||||||
name={category.categoryName}
|
name={category.categoryName}
|
||||||
size="md"
|
size="md"
|
||||||
/>
|
/>
|
||||||
<div className="min-w-0 flex-1">
|
<div className={styles.textStack}>
|
||||||
<p className="truncate text-sm font-medium text-foreground">
|
<p className={styles.title}>{category.categoryName}</p>
|
||||||
{category.categoryName}
|
<p className={styles.meta}>
|
||||||
</p>
|
|
||||||
<p className="flex items-center gap-1.5 text-xs text-muted-foreground">
|
|
||||||
<span
|
<span
|
||||||
className="inline-flex items-center gap-1"
|
className="inline-flex items-center gap-1"
|
||||||
title="Mês anterior"
|
title="Mês anterior"
|
||||||
@@ -81,7 +80,9 @@ export function CategoryTrendsWidget({
|
|||||||
</span>
|
</span>
|
||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
<span className="flex shrink-0 items-center gap-1 text-xs text-muted-foreground">
|
<span
|
||||||
|
className={`${styles.trailingMeta} min-w-[5.75rem] justify-end text-muted-foreground`}
|
||||||
|
>
|
||||||
<PercentageChangeIndicator
|
<PercentageChangeIndicator
|
||||||
value={change}
|
value={change}
|
||||||
label={formatPercentage(change, {
|
label={formatPercentage(change, {
|
||||||
|
|||||||
@@ -10,6 +10,7 @@ import Link from "next/link";
|
|||||||
import { useRouter } from "next/navigation";
|
import { useRouter } from "next/navigation";
|
||||||
import { useMemo, useState } from "react";
|
import { useMemo, useState } from "react";
|
||||||
import { toast } from "sonner";
|
import { toast } from "sonner";
|
||||||
|
import { dashboardWidgetListStyles as styles } from "@/features/dashboard/components/dashboard-widget-list-styles";
|
||||||
import type { DashboardInboxSnapshot } from "@/features/dashboard/lib/inbox-snapshot-queries";
|
import type { DashboardInboxSnapshot } from "@/features/dashboard/lib/inbox-snapshot-queries";
|
||||||
import type { DashboardWidgetQuickActionOptions } from "@/features/dashboard/widget-registry/widget-config";
|
import type { DashboardWidgetQuickActionOptions } from "@/features/dashboard/widget-registry/widget-config";
|
||||||
import {
|
import {
|
||||||
@@ -201,8 +202,8 @@ export function InboxWidget({
|
|||||||
const displayLogo = logoSrc ?? DEFAULT_INBOX_APP_LOGO;
|
const displayLogo = logoSrc ?? DEFAULT_INBOX_APP_LOGO;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div key={item.id} className="flex items-center justify-between py-2">
|
<div key={item.id} className={styles.row}>
|
||||||
<div className="flex min-w-0 flex-1 items-center gap-2">
|
<div className={styles.main}>
|
||||||
<Image
|
<Image
|
||||||
src={displayLogo}
|
src={displayLogo}
|
||||||
alt={item.sourceAppName ?? ""}
|
alt={item.sourceAppName ?? ""}
|
||||||
@@ -212,11 +213,9 @@ export function InboxWidget({
|
|||||||
unoptimized
|
unoptimized
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<div className="min-w-0">
|
<div className={styles.textStack}>
|
||||||
<p className="truncate text-sm font-medium text-foreground">
|
<p className={styles.title}>{displayName}</p>
|
||||||
{displayName}
|
<div className={styles.meta}>
|
||||||
</p>
|
|
||||||
<div className="flex min-w-0 items-center gap-2 text-xs text-muted-foreground">
|
|
||||||
{item.sourceAppName && (
|
{item.sourceAppName && (
|
||||||
<span className="truncate">{item.sourceAppName}</span>
|
<span className="truncate">{item.sourceAppName}</span>
|
||||||
)}
|
)}
|
||||||
@@ -227,9 +226,9 @@ export function InboxWidget({
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div className="ml-2 flex shrink-0 items-center gap-1">
|
<div className="ml-2 flex min-w-[7.5rem] shrink-0 items-center justify-end gap-1">
|
||||||
{amount !== null && (
|
{amount !== null && (
|
||||||
<MoneyValues className="font-medium" amount={amount} />
|
<MoneyValues className={styles.trailingValue} amount={amount} />
|
||||||
)}
|
)}
|
||||||
{amount === null && (
|
{amount === null && (
|
||||||
<span className="max-w-20 text-right text-xs leading-tight text-muted-foreground">
|
<span className="max-w-20 text-right text-xs leading-tight text-muted-foreground">
|
||||||
|
|||||||
@@ -10,6 +10,7 @@ import Image from "next/image";
|
|||||||
import Link from "next/link";
|
import Link from "next/link";
|
||||||
import { useTransition } from "react";
|
import { useTransition } from "react";
|
||||||
import { toast } from "sonner";
|
import { toast } from "sonner";
|
||||||
|
import { dashboardWidgetListStyles as styles } from "@/features/dashboard/components/dashboard-widget-list-styles";
|
||||||
import type { DashboardAccount } from "@/features/dashboard/lib/accounts-queries";
|
import type { DashboardAccount } from "@/features/dashboard/lib/accounts-queries";
|
||||||
import { updateMyAccountsWidgetPreference } from "@/features/dashboard/widget-registry/widget-actions";
|
import { updateMyAccountsWidgetPreference } from "@/features/dashboard/widget-registry/widget-actions";
|
||||||
import MoneyValues from "@/shared/components/money-values";
|
import MoneyValues from "@/shared/components/money-values";
|
||||||
@@ -139,11 +140,8 @@ export function MyAccountsWidget({
|
|||||||
const logoSrc = resolveLogoSrc(account.logo);
|
const logoSrc = resolveLogoSrc(account.logo);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<li
|
<li key={account.id} className={styles.row}>
|
||||||
key={account.id}
|
<div className={styles.main}>
|
||||||
className="flex items-center justify-between py-1.5 transition-all duration-300"
|
|
||||||
>
|
|
||||||
<div className="flex min-w-0 flex-1 items-center gap-2 py-1">
|
|
||||||
<div className="relative flex size-9.5 shrink-0 items-center justify-center overflow-hidden rounded-full">
|
<div className="relative flex size-9.5 shrink-0 items-center justify-center overflow-hidden rounded-full">
|
||||||
{logoSrc ? (
|
{logoSrc ? (
|
||||||
<Image
|
<Image
|
||||||
@@ -161,18 +159,18 @@ export function MyAccountsWidget({
|
|||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div className="min-w-0">
|
<div className={styles.textStack}>
|
||||||
<Link
|
<Link
|
||||||
prefetch
|
prefetch
|
||||||
href={`/accounts/${
|
href={`/accounts/${
|
||||||
account.id
|
account.id
|
||||||
}/statement?periodo=${formatPeriodForUrl(period)}`}
|
}/statement?periodo=${formatPeriodForUrl(period)}`}
|
||||||
className="inline-flex max-w-full items-center gap-1 text-sm font-medium text-foreground underline-offset-2 hover:text-primary hover:underline"
|
className={styles.titleLink}
|
||||||
>
|
>
|
||||||
<span className="truncate">{account.name}</span>
|
<span className="truncate">{account.name}</span>
|
||||||
</Link>
|
</Link>
|
||||||
|
|
||||||
<div className="flex flex-wrap items-center gap-2 text-xs text-muted-foreground">
|
<div className={styles.meta}>
|
||||||
<span className="truncate">{account.accountType}</span>
|
<span className="truncate">{account.accountType}</span>
|
||||||
{account.excludeFromBalance ? (
|
{account.excludeFromBalance ? (
|
||||||
<Tooltip>
|
<Tooltip>
|
||||||
@@ -195,10 +193,10 @@ export function MyAccountsWidget({
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div className="flex flex-col items-end gap-0.5 text-right">
|
<div className={styles.trailing}>
|
||||||
<MoneyValues
|
<MoneyValues
|
||||||
className={cn(
|
className={cn(
|
||||||
"font-medium",
|
styles.trailingValue,
|
||||||
account.balance < 0 && "text-destructive",
|
account.balance < 0 && "text-destructive",
|
||||||
)}
|
)}
|
||||||
amount={account.balance}
|
amount={account.balance}
|
||||||
|
|||||||
@@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
import { RiGroupLine, RiVerifiedBadgeFill } from "@remixicon/react";
|
import { RiGroupLine, RiVerifiedBadgeFill } from "@remixicon/react";
|
||||||
import Link from "next/link";
|
import Link from "next/link";
|
||||||
|
import { dashboardWidgetListStyles as styles } from "@/features/dashboard/components/dashboard-widget-list-styles";
|
||||||
import { PercentageChangeIndicator } from "@/features/dashboard/components/percentage-change-indicator";
|
import { PercentageChangeIndicator } from "@/features/dashboard/components/percentage-change-indicator";
|
||||||
import type { DashboardPagador } from "@/features/dashboard/lib/payers-queries";
|
import type { DashboardPagador } from "@/features/dashboard/lib/payers-queries";
|
||||||
import MoneyValues from "@/shared/components/money-values";
|
import MoneyValues from "@/shared/components/money-values";
|
||||||
@@ -44,14 +45,9 @@ export function PayersWidget({ payers }: PayersWidgetProps) {
|
|||||||
: null;
|
: null;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div
|
<div key={payer.id} className={styles.row}>
|
||||||
key={payer.id}
|
<span className={styles.rank}>{index + 1}</span>
|
||||||
className="flex items-center justify-between gap-2 transition-all duration-300 py-1.5"
|
<div className={styles.main}>
|
||||||
>
|
|
||||||
<span className="w-3 shrink-0 text-left text-xs font-medium text-muted-foreground">
|
|
||||||
{index + 1}
|
|
||||||
</span>
|
|
||||||
<div className="flex min-w-0 flex-1 items-center gap-2 py-1">
|
|
||||||
<Avatar className="size-9.5 shrink-0">
|
<Avatar className="size-9.5 shrink-0">
|
||||||
<AvatarImage
|
<AvatarImage
|
||||||
src={getAvatarSrc(payer.avatarUrl)}
|
src={getAvatarSrc(payer.avatarUrl)}
|
||||||
@@ -60,11 +56,11 @@ export function PayersWidget({ payers }: PayersWidgetProps) {
|
|||||||
<AvatarFallback>{initials}</AvatarFallback>
|
<AvatarFallback>{initials}</AvatarFallback>
|
||||||
</Avatar>
|
</Avatar>
|
||||||
|
|
||||||
<div className="min-w-0">
|
<div className={styles.textStack}>
|
||||||
<Link
|
<Link
|
||||||
prefetch
|
prefetch
|
||||||
href={`/payers/${payer.id}`}
|
href={`/payers/${payer.id}`}
|
||||||
className="inline-flex max-w-full items-center gap-1 text-sm text-foreground underline-offset-2 hover:text-primary hover:underline"
|
className={styles.titleLink}
|
||||||
>
|
>
|
||||||
<span className="truncate font-medium">{payer.name}</span>
|
<span className="truncate font-medium">{payer.name}</span>
|
||||||
{payer.isAdmin && (
|
{payer.isAdmin && (
|
||||||
@@ -84,18 +80,18 @@ export function PayersWidget({ payers }: PayersWidgetProps) {
|
|||||||
</Tooltip>
|
</Tooltip>
|
||||||
)}
|
)}
|
||||||
</Link>
|
</Link>
|
||||||
<p className="truncate text-xs text-muted-foreground">
|
<p className={styles.meta}>Despesas no período</p>
|
||||||
Despesas no período
|
|
||||||
</p>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div className="flex shrink-0 flex-col items-end">
|
<div className={styles.trailing}>
|
||||||
<MoneyValues
|
<MoneyValues
|
||||||
className="font-medium"
|
className={styles.trailingValue}
|
||||||
amount={payer.totalExpenses}
|
amount={payer.totalExpenses}
|
||||||
/>
|
/>
|
||||||
<div className="flex items-center gap-1 text-xs text-muted-foreground">
|
<div
|
||||||
|
className={`${styles.trailingMeta} text-muted-foreground`}
|
||||||
|
>
|
||||||
<PercentageChangeIndicator value={percentageChange} />
|
<PercentageChangeIndicator value={percentageChange} />
|
||||||
{percentageChange !== null ? (
|
{percentageChange !== null ? (
|
||||||
<span>vs. mês ant.</span>
|
<span>vs. mês ant.</span>
|
||||||
|
|||||||
@@ -3,6 +3,7 @@
|
|||||||
import { RiFileList2Line, RiStore3Line } from "@remixicon/react";
|
import { RiFileList2Line, RiStore3Line } from "@remixicon/react";
|
||||||
import { useEffect, useMemo, useRef, useState } from "react";
|
import { useEffect, useMemo, useRef, useState } from "react";
|
||||||
import type { PurchasesByCategoryData } from "@/features/dashboard/categories/purchases-by-category-queries";
|
import type { PurchasesByCategoryData } from "@/features/dashboard/categories/purchases-by-category-queries";
|
||||||
|
import { dashboardWidgetListStyles as styles } from "@/features/dashboard/components/dashboard-widget-list-styles";
|
||||||
import { EstablishmentLogo } from "@/shared/components/entity-avatar";
|
import { EstablishmentLogo } from "@/shared/components/entity-avatar";
|
||||||
import MoneyValues from "@/shared/components/money-values";
|
import MoneyValues from "@/shared/components/money-values";
|
||||||
import {
|
import {
|
||||||
@@ -162,26 +163,21 @@ export function PurchasesByCategoryWidget({
|
|||||||
<div className="flex flex-col">
|
<div className="flex flex-col">
|
||||||
{currentTransactions.map((transaction) => {
|
{currentTransactions.map((transaction) => {
|
||||||
return (
|
return (
|
||||||
<div
|
<div key={transaction.id} className={styles.row}>
|
||||||
key={transaction.id}
|
<div className={styles.main}>
|
||||||
className="flex items-center justify-between gap-2 transition-all duration-300 py-1.5"
|
|
||||||
>
|
|
||||||
<div className="flex min-w-0 flex-1 items-center gap-2">
|
|
||||||
<EstablishmentLogo name={transaction.name} size={37} />
|
<EstablishmentLogo name={transaction.name} size={37} />
|
||||||
|
|
||||||
<div className="min-w-0">
|
<div className={styles.textStack}>
|
||||||
<p className="truncate text-sm font-medium text-foreground">
|
<p className={styles.title}>{transaction.name}</p>
|
||||||
{transaction.name}
|
<p className={styles.meta}>
|
||||||
</p>
|
|
||||||
<p className="text-xs text-muted-foreground">
|
|
||||||
{formatTransactionDate(transaction.purchaseDate)}
|
{formatTransactionDate(transaction.purchaseDate)}
|
||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div className="shrink-0 text-foreground">
|
<div className={styles.trailing}>
|
||||||
<MoneyValues
|
<MoneyValues
|
||||||
className="font-medium"
|
className={styles.trailingValue}
|
||||||
amount={transaction.amount}
|
amount={transaction.amount}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
import { RiRefreshLine } from "@remixicon/react";
|
import { RiRefreshLine } from "@remixicon/react";
|
||||||
|
import { dashboardWidgetListStyles as styles } from "@/features/dashboard/components/dashboard-widget-list-styles";
|
||||||
import type { RecurringExpensesData } from "@/features/dashboard/expenses/recurring-expenses-queries";
|
import type { RecurringExpensesData } from "@/features/dashboard/expenses/recurring-expenses-queries";
|
||||||
import { EstablishmentLogo } from "@/shared/components/entity-avatar";
|
import { EstablishmentLogo } from "@/shared/components/entity-avatar";
|
||||||
import MoneyValues from "@/shared/components/money-values";
|
import MoneyValues from "@/shared/components/money-values";
|
||||||
@@ -36,26 +37,14 @@ export function RecurringExpensesWidget({
|
|||||||
.sort((a, b) => b.amount - a.amount)
|
.sort((a, b) => b.amount - a.amount)
|
||||||
.map((expense) => {
|
.map((expense) => {
|
||||||
return (
|
return (
|
||||||
<div
|
<div key={expense.id} className={styles.row}>
|
||||||
key={expense.id}
|
<div className={styles.main}>
|
||||||
className="flex items-center gap-2 transition-all duration-300 py-1.5"
|
|
||||||
>
|
|
||||||
<EstablishmentLogo name={expense.name} size={37} />
|
<EstablishmentLogo name={expense.name} size={37} />
|
||||||
|
|
||||||
<div className="min-w-0 flex-1">
|
<div className={styles.textStack}>
|
||||||
<div className="flex items-center justify-between">
|
<p className={styles.title}>{expense.name}</p>
|
||||||
<p className="truncate text-foreground text-sm font-medium">
|
<div className={styles.meta}>
|
||||||
{expense.name}
|
<span className="inline-flex min-w-0 items-center gap-1 [&_svg]:size-3.5">
|
||||||
</p>
|
|
||||||
|
|
||||||
<MoneyValues
|
|
||||||
className="font-medium"
|
|
||||||
amount={expense.amount}
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div className="flex items-center justify-between text-xs text-muted-foreground">
|
|
||||||
<span className="inline-flex items-center gap-1 [&_svg]:size-3.5">
|
|
||||||
{getPaymentMethodIcon(expense.paymentMethod)}
|
{getPaymentMethodIcon(expense.paymentMethod)}
|
||||||
{expense.paymentMethod}
|
{expense.paymentMethod}
|
||||||
</span>
|
</span>
|
||||||
@@ -63,6 +52,14 @@ export function RecurringExpensesWidget({
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<div className={styles.trailing}>
|
||||||
|
<MoneyValues
|
||||||
|
className={styles.trailingValue}
|
||||||
|
amount={expense.amount}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
);
|
);
|
||||||
})}
|
})}
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
import { RiStore2Line } from "@remixicon/react";
|
import { RiStore2Line } from "@remixicon/react";
|
||||||
|
import { dashboardWidgetListStyles as styles } from "@/features/dashboard/components/dashboard-widget-list-styles";
|
||||||
import type { TopEstablishmentsData } from "@/features/dashboard/lib/top-establishments-queries";
|
import type { TopEstablishmentsData } from "@/features/dashboard/lib/top-establishments-queries";
|
||||||
import { EstablishmentLogo } from "@/shared/components/entity-avatar";
|
import { EstablishmentLogo } from "@/shared/components/entity-avatar";
|
||||||
import MoneyValues from "@/shared/components/money-values";
|
import MoneyValues from "@/shared/components/money-values";
|
||||||
@@ -30,30 +31,23 @@ export function TopEstablishmentsWidget({
|
|||||||
<div className="flex flex-col">
|
<div className="flex flex-col">
|
||||||
{data.establishments.map((establishment, index) => {
|
{data.establishments.map((establishment, index) => {
|
||||||
return (
|
return (
|
||||||
<div
|
<div key={establishment.id} className={styles.row}>
|
||||||
key={establishment.id}
|
<span className={styles.rank}>{index + 1}</span>
|
||||||
className="flex items-center justify-between gap-2 transition-all duration-300 py-1.5"
|
<div className={styles.main}>
|
||||||
>
|
|
||||||
<span className="w-3 shrink-0 text-left text-xs font-medium text-muted-foreground">
|
|
||||||
{index + 1}
|
|
||||||
</span>
|
|
||||||
<div className="flex min-w-0 flex-1 items-center gap-2">
|
|
||||||
<EstablishmentLogo name={establishment.name} size={37} />
|
<EstablishmentLogo name={establishment.name} size={37} />
|
||||||
|
|
||||||
<div className="min-w-0">
|
<div className={styles.textStack}>
|
||||||
<p className="truncate text-sm font-medium text-foreground">
|
<p className={styles.title}>{establishment.name}</p>
|
||||||
{establishment.name}
|
<p className={styles.meta}>
|
||||||
</p>
|
|
||||||
<p className="text-xs text-muted-foreground">
|
|
||||||
{formatOccurrencesLabel(establishment.occurrences)} ·
|
{formatOccurrencesLabel(establishment.occurrences)} ·
|
||||||
total acumulado
|
total acumulado
|
||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div className="shrink-0 text-foreground">
|
<div className={styles.trailing}>
|
||||||
<MoneyValues
|
<MoneyValues
|
||||||
className="font-medium"
|
className={styles.trailingValue}
|
||||||
amount={establishment.amount}
|
amount={establishment.amount}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
import { RiArrowUpDoubleLine } from "@remixicon/react";
|
import { RiArrowUpDoubleLine } from "@remixicon/react";
|
||||||
import { useMemo } from "react";
|
import { useMemo } from "react";
|
||||||
|
import { dashboardWidgetListStyles as styles } from "@/features/dashboard/components/dashboard-widget-list-styles";
|
||||||
import type {
|
import type {
|
||||||
TopExpense,
|
TopExpense,
|
||||||
TopExpensesData,
|
TopExpensesData,
|
||||||
@@ -49,29 +50,22 @@ export function TopExpensesWidget({ data }: TopExpensesWidgetProps) {
|
|||||||
<div className="flex flex-col">
|
<div className="flex flex-col">
|
||||||
{expenses.map((expense, index) => {
|
{expenses.map((expense, index) => {
|
||||||
return (
|
return (
|
||||||
<div
|
<div key={expense.id} className={styles.row}>
|
||||||
key={expense.id}
|
<span className={styles.rank}>{index + 1}</span>
|
||||||
className="flex items-center justify-between gap-2 transition-all duration-300 py-1.5"
|
<div className={styles.main}>
|
||||||
>
|
|
||||||
<span className="w-3 shrink-0 text-left text-xs font-medium text-muted-foreground">
|
|
||||||
{index + 1}
|
|
||||||
</span>
|
|
||||||
<div className="flex min-w-0 flex-1 items-center gap-2">
|
|
||||||
<EstablishmentLogo name={expense.name} size={37} />
|
<EstablishmentLogo name={expense.name} size={37} />
|
||||||
|
|
||||||
<div className="min-w-0">
|
<div className={styles.textStack}>
|
||||||
<p className="truncate text-sm font-medium text-foreground">
|
<p className={styles.title}>{expense.name}</p>
|
||||||
{expense.name}
|
<p className={styles.meta}>
|
||||||
</p>
|
|
||||||
<p className="text-xs text-muted-foreground">
|
|
||||||
{formatTransactionDate(expense.purchaseDate)}
|
{formatTransactionDate(expense.purchaseDate)}
|
||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div className="shrink-0 text-foreground">
|
<div className={styles.trailing}>
|
||||||
<MoneyValues
|
<MoneyValues
|
||||||
className="font-medium"
|
className={styles.trailingValue}
|
||||||
amount={expense.amount}
|
amount={expense.amount}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -206,32 +206,32 @@ export function InvoiceSummaryCard({
|
|||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Card className="gap-0 py-0">
|
<Card className="gap-0 py-0 space-y-2">
|
||||||
<CardContent className="px-4 py-4 sm:px-5 sm:py-5">
|
<CardContent className="px-4 py-4 sm:px-5 sm:py-5">
|
||||||
<div className="flex flex-col gap-4">
|
<div className="flex flex-col gap-4">
|
||||||
{/* Linha 1 — identidade */}
|
{/* Linha 1 — identidade */}
|
||||||
<div className="flex items-center justify-between gap-3">
|
<div className="flex flex-col gap-4 sm:flex-row sm:items-start sm:justify-between">
|
||||||
<div className="flex min-w-0 items-center gap-3">
|
<div className="flex min-w-0 items-start gap-3">
|
||||||
{logoPath ? (
|
{logoPath ? (
|
||||||
<div className="flex size-12 shrink-0 items-center justify-center overflow-hidden rounded-full">
|
<div className="flex size-12 shrink-0 items-center justify-center overflow-hidden rounded-full">
|
||||||
<Image
|
<Image
|
||||||
src={logoPath}
|
src={logoPath}
|
||||||
alt={`Logo ${cardName}`}
|
alt={`Logo ${cardName}`}
|
||||||
width={42}
|
width={48}
|
||||||
height={42}
|
height={48}
|
||||||
className="h-full w-full object-contain"
|
className="h-full w-full object-contain"
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
) : cardBrand ? (
|
) : cardBrand ? (
|
||||||
<span className="flex size-10 shrink-0 items-center justify-center rounded-full border bg-background text-xs font-medium text-muted-foreground">
|
<span className="flex size-12 shrink-0 items-center justify-center rounded-full border bg-card text-sm font-semibold text-primary">
|
||||||
{cardBrand.slice(0, 2).toUpperCase()}
|
{cardBrand.slice(0, 2).toUpperCase()}
|
||||||
</span>
|
</span>
|
||||||
) : null}
|
) : null}
|
||||||
<div className="min-w-0">
|
<div className="min-w-0 space-y-1">
|
||||||
<h2 className="truncate text-sm font-semibold text-foreground">
|
<h2 className="truncate text-xl font-semibold text-foreground sm:text-2xl">
|
||||||
{cardName}
|
{cardName}
|
||||||
</h2>
|
</h2>
|
||||||
<p className="text-xs text-muted-foreground">
|
<p className="text-sm leading-relaxed text-muted-foreground">
|
||||||
Fatura de {periodLabel}
|
Fatura de {periodLabel}
|
||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -515,6 +515,11 @@ export const toggleSettlementSchema = z.object({
|
|||||||
|
|
||||||
export const convertToInstallmentSchema = z.object({
|
export const convertToInstallmentSchema = z.object({
|
||||||
id: uuidSchema("Lançamento"),
|
id: uuidSchema("Lançamento"),
|
||||||
|
installmentCount: z.coerce
|
||||||
|
.number({ message: "Informe em quantas parcelas dividir." })
|
||||||
|
.int()
|
||||||
|
.min(2, "O parcelamento deve ter ao menos duas parcelas.")
|
||||||
|
.max(60, "Selecione até 60 parcelas."),
|
||||||
});
|
});
|
||||||
|
|
||||||
export const convertToRecurringSchema = z.object({
|
export const convertToRecurringSchema = z.object({
|
||||||
|
|||||||
@@ -484,7 +484,10 @@ export async function convertTransactionToInstallmentAction(
|
|||||||
const data = convertToInstallmentSchema.parse(input);
|
const data = convertToInstallmentSchema.parse(input);
|
||||||
|
|
||||||
const existing = await db.query.transactions.findFirst({
|
const existing = await db.query.transactions.findFirst({
|
||||||
where: and(eq(transactions.id, data.id), eq(transactions.userId, user.id)),
|
where: and(
|
||||||
|
eq(transactions.id, data.id),
|
||||||
|
eq(transactions.userId, user.id),
|
||||||
|
),
|
||||||
});
|
});
|
||||||
|
|
||||||
if (!existing) {
|
if (!existing) {
|
||||||
@@ -512,37 +515,32 @@ export async function convertTransactionToInstallmentAction(
|
|||||||
) {
|
) {
|
||||||
return {
|
return {
|
||||||
success: false,
|
success: false,
|
||||||
error: "Apenas lançamentos à vista de cartão de crédito podem ser convertidos.",
|
error:
|
||||||
|
"Apenas lançamentos à vista de cartão de crédito podem ser convertidos.",
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
if (existing.splitGroupId || existing.isDivided) {
|
if (existing.splitGroupId || existing.isDivided) {
|
||||||
return {
|
return {
|
||||||
success: false,
|
success: false,
|
||||||
error: "Lançamentos divididos ainda não podem ser convertidos em parcelamento.",
|
error:
|
||||||
|
"Lançamentos divididos ainda não podem ser convertidos em parcelamento.",
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
const detected = detectInstallmentFromName(existing.name);
|
const detected = detectInstallmentFromName(existing.name);
|
||||||
if (!detected) {
|
const transactionName =
|
||||||
return {
|
detected?.installmentCount === data.installmentCount
|
||||||
success: false,
|
? detected.name
|
||||||
error:
|
: existing.name;
|
||||||
"Não encontrei um padrão de parcela no nome deste lançamento, como 2/10 ou Parcela 2 de 10.",
|
const amountSign: 1 | -1 = existing.transactionType === "Despesa" ? -1 : 1;
|
||||||
};
|
const totalCents = Math.round(Math.abs(Number(existing.amount)) * 100);
|
||||||
}
|
|
||||||
|
|
||||||
const amountSign: 1 | -1 =
|
|
||||||
existing.transactionType === "Despesa" ? -1 : 1;
|
|
||||||
const totalCents =
|
|
||||||
Math.round(Math.abs(Number(existing.amount)) * 100) *
|
|
||||||
detected.installmentCount;
|
|
||||||
const seriesId = randomUUID();
|
const seriesId = randomUUID();
|
||||||
const records = buildTransactionRecords({
|
const records = buildTransactionRecords({
|
||||||
data: {
|
data: {
|
||||||
purchaseDate: existing.purchaseDate.toISOString().slice(0, 10),
|
purchaseDate: existing.purchaseDate.toISOString().slice(0, 10),
|
||||||
period: existing.period,
|
period: existing.period,
|
||||||
name: detected.name,
|
name: transactionName,
|
||||||
transactionType: existing.transactionType as "Receita" | "Despesa",
|
transactionType: existing.transactionType as "Receita" | "Despesa",
|
||||||
amount: totalCents / 100,
|
amount: totalCents / 100,
|
||||||
condition: "Parcelado",
|
condition: "Parcelado",
|
||||||
@@ -553,8 +551,8 @@ export async function convertTransactionToInstallmentAction(
|
|||||||
cardId: existing.cardId,
|
cardId: existing.cardId,
|
||||||
categoryId: existing.categoryId,
|
categoryId: existing.categoryId,
|
||||||
note: existing.note,
|
note: existing.note,
|
||||||
installmentCount: detected.installmentCount,
|
installmentCount: data.installmentCount,
|
||||||
startInstallment: detected.currentInstallment,
|
startInstallment: 1,
|
||||||
dueDate: existing.dueDate?.toISOString().slice(0, 10),
|
dueDate: existing.dueDate?.toISOString().slice(0, 10),
|
||||||
isSettled: null,
|
isSettled: null,
|
||||||
},
|
},
|
||||||
@@ -600,7 +598,10 @@ export async function convertTransactionToInstallmentAction(
|
|||||||
const limitCheck = await validateCardLimit({
|
const limitCheck = await validateCardLimit({
|
||||||
userId: user.id,
|
userId: user.id,
|
||||||
cardId: existing.cardId,
|
cardId: existing.cardId,
|
||||||
addAmount: records.reduce((acc, row) => acc + Math.abs(Number(row.amount)), 0),
|
addAmount: records.reduce(
|
||||||
|
(acc, row) => acc + Math.abs(Number(row.amount)),
|
||||||
|
0,
|
||||||
|
),
|
||||||
excludeTransactionIds: [existing.id],
|
excludeTransactionIds: [existing.id],
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -625,7 +626,10 @@ export async function convertTransactionToInstallmentAction(
|
|||||||
seriesId,
|
seriesId,
|
||||||
})
|
})
|
||||||
.where(
|
.where(
|
||||||
and(eq(transactions.id, existing.id), eq(transactions.userId, user.id)),
|
and(
|
||||||
|
eq(transactions.id, existing.id),
|
||||||
|
eq(transactions.userId, user.id),
|
||||||
|
),
|
||||||
);
|
);
|
||||||
|
|
||||||
if (rowsToInsert.length > 0) {
|
if (rowsToInsert.length > 0) {
|
||||||
@@ -637,7 +641,7 @@ export async function convertTransactionToInstallmentAction(
|
|||||||
|
|
||||||
return {
|
return {
|
||||||
success: true,
|
success: true,
|
||||||
message: `Lançamento convertido em ${detected.installmentCount} parcelas.`,
|
message: `Lançamento convertido em ${data.installmentCount} parcelas.`,
|
||||||
data: { createdCount: rowsToInsert.length },
|
data: { createdCount: rowsToInsert.length },
|
||||||
};
|
};
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
@@ -653,7 +657,10 @@ export async function convertTransactionToRecurringAction(
|
|||||||
const data = convertToRecurringSchema.parse(input);
|
const data = convertToRecurringSchema.parse(input);
|
||||||
|
|
||||||
const existing = await db.query.transactions.findFirst({
|
const existing = await db.query.transactions.findFirst({
|
||||||
where: and(eq(transactions.id, data.id), eq(transactions.userId, user.id)),
|
where: and(
|
||||||
|
eq(transactions.id, data.id),
|
||||||
|
eq(transactions.userId, user.id),
|
||||||
|
),
|
||||||
});
|
});
|
||||||
|
|
||||||
if (!existing) {
|
if (!existing) {
|
||||||
@@ -677,19 +684,20 @@ export async function convertTransactionToRecurringAction(
|
|||||||
if (existing.condition !== "À vista") {
|
if (existing.condition !== "À vista") {
|
||||||
return {
|
return {
|
||||||
success: false,
|
success: false,
|
||||||
error: "Apenas lançamentos à vista podem ser convertidos em recorrência.",
|
error:
|
||||||
|
"Apenas lançamentos à vista podem ser convertidos em recorrência.",
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
if (existing.splitGroupId || existing.isDivided) {
|
if (existing.splitGroupId || existing.isDivided) {
|
||||||
return {
|
return {
|
||||||
success: false,
|
success: false,
|
||||||
error: "Lançamentos divididos ainda não podem ser convertidos em recorrência.",
|
error:
|
||||||
|
"Lançamentos divididos ainda não podem ser convertidos em recorrência.",
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
const amountSign: 1 | -1 =
|
const amountSign: 1 | -1 = existing.transactionType === "Despesa" ? -1 : 1;
|
||||||
existing.transactionType === "Despesa" ? -1 : 1;
|
|
||||||
const totalCents = Math.round(Math.abs(Number(existing.amount)) * 100);
|
const totalCents = Math.round(Math.abs(Number(existing.amount)) * 100);
|
||||||
const seriesId = randomUUID();
|
const seriesId = randomUUID();
|
||||||
const isCreditCard = existing.paymentMethod === "Cartão de crédito";
|
const isCreditCard = existing.paymentMethod === "Cartão de crédito";
|
||||||
@@ -760,6 +768,22 @@ export async function convertTransactionToRecurringAction(
|
|||||||
)} já estão pagas. Desfaça o pagamento antes de converter este lançamento.`,
|
)} já estão pagas. Desfaça o pagamento antes de converter este lançamento.`,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (existing.transactionType === "Despesa") {
|
||||||
|
const limitCheck = await validateCardLimit({
|
||||||
|
userId: user.id,
|
||||||
|
cardId: existing.cardId,
|
||||||
|
addAmount: records.reduce(
|
||||||
|
(acc, row) => acc + Math.abs(Number(row.amount)),
|
||||||
|
0,
|
||||||
|
),
|
||||||
|
excludeTransactionIds: [existing.id],
|
||||||
|
});
|
||||||
|
|
||||||
|
if (!limitCheck.ok) {
|
||||||
|
return { success: false, error: limitCheck.error };
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
await db.transaction(async (tx: typeof db) => {
|
await db.transaction(async (tx: typeof db) => {
|
||||||
@@ -780,7 +804,10 @@ export async function convertTransactionToRecurringAction(
|
|||||||
seriesId,
|
seriesId,
|
||||||
})
|
})
|
||||||
.where(
|
.where(
|
||||||
and(eq(transactions.id, existing.id), eq(transactions.userId, user.id)),
|
and(
|
||||||
|
eq(transactions.id, existing.id),
|
||||||
|
eq(transactions.userId, user.id),
|
||||||
|
),
|
||||||
);
|
);
|
||||||
|
|
||||||
if (rowsToInsert.length > 0) {
|
if (rowsToInsert.length > 0) {
|
||||||
|
|||||||
@@ -49,6 +49,8 @@ const categoryGroupByTransactionType = {
|
|||||||
income: "receita",
|
income: "receita",
|
||||||
} as const;
|
} as const;
|
||||||
|
|
||||||
|
const normalizeCategoryName = (value: string) => value.trim().toLowerCase();
|
||||||
|
|
||||||
interface ImportPageProps {
|
interface ImportPageProps {
|
||||||
payerOptions: SelectOption[];
|
payerOptions: SelectOption[];
|
||||||
accountOptions: SelectOption[];
|
accountOptions: SelectOption[];
|
||||||
@@ -112,8 +114,9 @@ export function ImportPage({
|
|||||||
categoryMappings[normalizeDescriptionKey(t.description)] ?? null;
|
categoryMappings[normalizeDescriptionKey(t.description)] ?? null;
|
||||||
|
|
||||||
if (t.categoryRaw) {
|
if (t.categoryRaw) {
|
||||||
|
const categoryRaw = normalizeCategoryName(t.categoryRaw);
|
||||||
const matchedOption = categoryOptions.find(
|
const matchedOption = categoryOptions.find(
|
||||||
(opt) => opt.label.toLowerCase() === t.categoryRaw?.toLowerCase()
|
(opt) => normalizeCategoryName(opt.label) === categoryRaw,
|
||||||
);
|
);
|
||||||
if (matchedOption) {
|
if (matchedOption) {
|
||||||
mappedCategoryId = matchedOption.value;
|
mappedCategoryId = matchedOption.value;
|
||||||
|
|||||||
@@ -33,6 +33,7 @@ import {
|
|||||||
} from "@/shared/components/ui/dialog";
|
} from "@/shared/components/ui/dialog";
|
||||||
import { Input } from "@/shared/components/ui/input";
|
import { Input } from "@/shared/components/ui/input";
|
||||||
import { Label } from "@/shared/components/ui/label";
|
import { Label } from "@/shared/components/ui/label";
|
||||||
|
import { formatCurrency } from "@/shared/utils/currency";
|
||||||
import type {
|
import type {
|
||||||
TransactionsExportContext,
|
TransactionsExportContext,
|
||||||
TransactionsPaginationState,
|
TransactionsPaginationState,
|
||||||
@@ -97,6 +98,9 @@ interface TransactionsPageProps {
|
|||||||
importCategoryOptions?: SelectOption[];
|
importCategoryOptions?: SelectOption[];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const pluralize = (count: number, singular: string, plural: string) =>
|
||||||
|
count === 1 ? singular : plural;
|
||||||
|
|
||||||
export function TransactionsPage({
|
export function TransactionsPage({
|
||||||
currentUserId,
|
currentUserId,
|
||||||
transactions: transactionList,
|
transactions: transactionList,
|
||||||
@@ -206,6 +210,8 @@ export function TransactionsPage({
|
|||||||
const [convertInstallmentOpen, setConvertInstallmentOpen] = useState(false);
|
const [convertInstallmentOpen, setConvertInstallmentOpen] = useState(false);
|
||||||
const [transactionToConvert, setTransactionToConvert] =
|
const [transactionToConvert, setTransactionToConvert] =
|
||||||
useState<TransactionItem | null>(null);
|
useState<TransactionItem | null>(null);
|
||||||
|
const [installmentCount, setInstallmentCount] = useState("2");
|
||||||
|
const [installmentPending, setInstallmentPending] = useState(false);
|
||||||
const [convertRecurringOpen, setConvertRecurringOpen] = useState(false);
|
const [convertRecurringOpen, setConvertRecurringOpen] = useState(false);
|
||||||
const [transactionToConvertRecurring, setTransactionToConvertRecurring] =
|
const [transactionToConvertRecurring, setTransactionToConvertRecurring] =
|
||||||
useState<TransactionItem | null>(null);
|
useState<TransactionItem | null>(null);
|
||||||
@@ -564,7 +570,9 @@ export function TransactionsPage({
|
|||||||
};
|
};
|
||||||
|
|
||||||
const handleConvertToInstallment = (item: TransactionItem) => {
|
const handleConvertToInstallment = (item: TransactionItem) => {
|
||||||
|
const detectedInstallment = detectInstallmentFromName(item.name);
|
||||||
setTransactionToConvert(item);
|
setTransactionToConvert(item);
|
||||||
|
setInstallmentCount(String(detectedInstallment?.installmentCount ?? 2));
|
||||||
setConvertInstallmentOpen(true);
|
setConvertInstallmentOpen(true);
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -573,24 +581,32 @@ export function TransactionsPage({
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const count = Number(installmentCount);
|
||||||
|
if (!Number.isInteger(count) || count < 2 || count > 60) {
|
||||||
|
toast.error("Informe um parcelamento entre 2 e 60 parcelas.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
setInstallmentPending(true);
|
||||||
const result = await convertTransactionToInstallmentAction({
|
const result = await convertTransactionToInstallmentAction({
|
||||||
id: transactionToConvert.id,
|
id: transactionToConvert.id,
|
||||||
|
installmentCount: count,
|
||||||
});
|
});
|
||||||
|
|
||||||
if (!result.success) {
|
if (!result.success) {
|
||||||
toast.error(result.error);
|
toast.error(result.error);
|
||||||
throw new Error(result.error);
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
toast.success(result.message);
|
toast.success(result.message);
|
||||||
setConvertInstallmentOpen(false);
|
setConvertInstallmentOpen(false);
|
||||||
setTransactionToConvert(null);
|
setTransactionToConvert(null);
|
||||||
|
} finally {
|
||||||
|
setInstallmentPending(false);
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
const conversionPreview = transactionToConvert
|
|
||||||
? detectInstallmentFromName(transactionToConvert.name)
|
|
||||||
: null;
|
|
||||||
|
|
||||||
const handleConvertToRecurring = (item: TransactionItem) => {
|
const handleConvertToRecurring = (item: TransactionItem) => {
|
||||||
setTransactionToConvertRecurring(item);
|
setTransactionToConvertRecurring(item);
|
||||||
setRecurrenceCount("12");
|
setRecurrenceCount("12");
|
||||||
@@ -628,6 +644,37 @@ export function TransactionsPage({
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const parsedInstallmentCount = Number(installmentCount);
|
||||||
|
const installmentSummary =
|
||||||
|
transactionToConvert &&
|
||||||
|
Number.isInteger(parsedInstallmentCount) &&
|
||||||
|
parsedInstallmentCount >= 2 &&
|
||||||
|
parsedInstallmentCount <= 60
|
||||||
|
? {
|
||||||
|
total: formatCurrency(Math.abs(transactionToConvert.amount)),
|
||||||
|
installmentValue: formatCurrency(
|
||||||
|
Math.abs(transactionToConvert.amount) / parsedInstallmentCount,
|
||||||
|
),
|
||||||
|
count: parsedInstallmentCount,
|
||||||
|
createdCount: parsedInstallmentCount - 1,
|
||||||
|
}
|
||||||
|
: null;
|
||||||
|
|
||||||
|
const parsedRecurrenceCount = Number(recurrenceCount);
|
||||||
|
const recurringSummary =
|
||||||
|
transactionToConvertRecurring &&
|
||||||
|
Number.isInteger(parsedRecurrenceCount) &&
|
||||||
|
parsedRecurrenceCount >= 2 &&
|
||||||
|
parsedRecurrenceCount <= 60
|
||||||
|
? {
|
||||||
|
amount: formatCurrency(
|
||||||
|
Math.abs(transactionToConvertRecurring.amount),
|
||||||
|
),
|
||||||
|
count: parsedRecurrenceCount,
|
||||||
|
createdCount: parsedRecurrenceCount - 1,
|
||||||
|
}
|
||||||
|
: null;
|
||||||
|
|
||||||
const handleAnticipate = (item: TransactionItem) => {
|
const handleAnticipate = (item: TransactionItem) => {
|
||||||
setSelectedForAnticipation(item);
|
setSelectedForAnticipation(item);
|
||||||
setAnticipateOpen(true);
|
setAnticipateOpen(true);
|
||||||
@@ -837,7 +884,7 @@ export function TransactionsPage({
|
|||||||
disabled={!transactionToDelete}
|
disabled={!transactionToDelete}
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<ConfirmActionDialog
|
<Dialog
|
||||||
open={convertInstallmentOpen && !!transactionToConvert}
|
open={convertInstallmentOpen && !!transactionToConvert}
|
||||||
onOpenChange={(open) => {
|
onOpenChange={(open) => {
|
||||||
setConvertInstallmentOpen(open);
|
setConvertInstallmentOpen(open);
|
||||||
@@ -845,17 +892,64 @@ export function TransactionsPage({
|
|||||||
setTransactionToConvert(null);
|
setTransactionToConvert(null);
|
||||||
}
|
}
|
||||||
}}
|
}}
|
||||||
title="Converter em parcelamento?"
|
>
|
||||||
description={
|
<DialogContent className="sm:max-w-md">
|
||||||
conversionPreview
|
<DialogHeader>
|
||||||
? `Este lançamento será convertido para "${conversionPreview.name}" como parcela ${conversionPreview.currentInstallment} de ${conversionPreview.installmentCount}. As próximas parcelas serão criadas automaticamente.`
|
<DialogTitle>Converter em parcelamento?</DialogTitle>
|
||||||
: "Este lançamento será convertido em uma série parcelada."
|
<DialogDescription>
|
||||||
}
|
O lançamento atual será mantido como a primeira parcela e os
|
||||||
confirmLabel="Converter"
|
próximos meses serão criados automaticamente.
|
||||||
pendingLabel="Convertendo..."
|
</DialogDescription>
|
||||||
onConfirm={confirmConvertToInstallment}
|
</DialogHeader>
|
||||||
disabled={!transactionToConvert}
|
|
||||||
|
<div className="space-y-2">
|
||||||
|
<Label htmlFor="installmentCount">Parcelar em</Label>
|
||||||
|
<Input
|
||||||
|
id="installmentCount"
|
||||||
|
type="number"
|
||||||
|
min={2}
|
||||||
|
max={60}
|
||||||
|
value={installmentCount}
|
||||||
|
onChange={(event) => setInstallmentCount(event.target.value)}
|
||||||
/>
|
/>
|
||||||
|
<p className="text-muted-foreground text-sm">
|
||||||
|
Use o total de parcelas da série, incluindo este lançamento.
|
||||||
|
</p>
|
||||||
|
{installmentSummary ? (
|
||||||
|
<p className="rounded-md border bg-muted/40 px-3 py-2 text-muted-foreground text-sm">
|
||||||
|
Resumo: {installmentSummary.total} será dividido em{" "}
|
||||||
|
{installmentSummary.count} parcelas de aproximadamente{" "}
|
||||||
|
{installmentSummary.installmentValue}. Este lançamento vira a
|
||||||
|
primeira parcela e {installmentSummary.createdCount}{" "}
|
||||||
|
{pluralize(
|
||||||
|
installmentSummary.createdCount,
|
||||||
|
"nova parcela será criada",
|
||||||
|
"novas parcelas serão criadas",
|
||||||
|
)}
|
||||||
|
.
|
||||||
|
</p>
|
||||||
|
) : null}
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<DialogFooter>
|
||||||
|
<Button
|
||||||
|
type="button"
|
||||||
|
variant="outline"
|
||||||
|
onClick={() => setConvertInstallmentOpen(false)}
|
||||||
|
disabled={installmentPending}
|
||||||
|
>
|
||||||
|
Cancelar
|
||||||
|
</Button>
|
||||||
|
<Button
|
||||||
|
type="button"
|
||||||
|
onClick={confirmConvertToInstallment}
|
||||||
|
disabled={installmentPending}
|
||||||
|
>
|
||||||
|
{installmentPending ? "Convertendo..." : "Converter"}
|
||||||
|
</Button>
|
||||||
|
</DialogFooter>
|
||||||
|
</DialogContent>
|
||||||
|
</Dialog>
|
||||||
|
|
||||||
<Dialog
|
<Dialog
|
||||||
open={convertRecurringOpen && !!transactionToConvertRecurring}
|
open={convertRecurringOpen && !!transactionToConvertRecurring}
|
||||||
@@ -888,6 +982,18 @@ export function TransactionsPage({
|
|||||||
<p className="text-muted-foreground text-sm">
|
<p className="text-muted-foreground text-sm">
|
||||||
Use o total de meses da série, incluindo este lançamento.
|
Use o total de meses da série, incluindo este lançamento.
|
||||||
</p>
|
</p>
|
||||||
|
{recurringSummary ? (
|
||||||
|
<p className="rounded-md border bg-muted/40 px-3 py-2 text-muted-foreground text-sm">
|
||||||
|
Resumo: este lançamento vira a primeira recorrência e{" "}
|
||||||
|
{recurringSummary.createdCount}{" "}
|
||||||
|
{pluralize(
|
||||||
|
recurringSummary.createdCount,
|
||||||
|
"novo lançamento mensal será criado",
|
||||||
|
"novos lançamentos mensais serão criados",
|
||||||
|
)}{" "}
|
||||||
|
com valor de {recurringSummary.amount}.
|
||||||
|
</p>
|
||||||
|
) : null}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<DialogFooter>
|
<DialogFooter>
|
||||||
|
|||||||
@@ -11,6 +11,7 @@ import {
|
|||||||
RiRefundLine,
|
RiRefundLine,
|
||||||
RiTimeLine,
|
RiTimeLine,
|
||||||
} from "@remixicon/react";
|
} from "@remixicon/react";
|
||||||
|
import { CREDIT_CARD_PAYMENT_METHOD } from "@/features/transactions/lib/constants";
|
||||||
import { Button } from "@/shared/components/ui/button";
|
import { Button } from "@/shared/components/ui/button";
|
||||||
import {
|
import {
|
||||||
DropdownMenu,
|
DropdownMenu,
|
||||||
@@ -20,8 +21,6 @@ import {
|
|||||||
DropdownMenuTrigger,
|
DropdownMenuTrigger,
|
||||||
} from "@/shared/components/ui/dropdown-menu";
|
} from "@/shared/components/ui/dropdown-menu";
|
||||||
import { REFUND_NOTE_PREFIX } from "@/shared/lib/accounts/constants";
|
import { REFUND_NOTE_PREFIX } from "@/shared/lib/accounts/constants";
|
||||||
import { CREDIT_CARD_PAYMENT_METHOD } from "@/features/transactions/lib/constants";
|
|
||||||
import { detectInstallmentFromName } from "@/features/transactions/lib/installment-detection";
|
|
||||||
import { getConditionIcon } from "@/shared/utils/icons";
|
import { getConditionIcon } from "@/shared/utils/icons";
|
||||||
import type { TransactionItem } from "../types";
|
import type { TransactionItem } from "../types";
|
||||||
|
|
||||||
@@ -66,7 +65,6 @@ export function TransactionActionsMenu({
|
|||||||
const showInstallmentActions =
|
const showInstallmentActions =
|
||||||
isOwnData && item.condition === "Parcelado" && item.seriesId;
|
isOwnData && item.condition === "Parcelado" && item.seriesId;
|
||||||
|
|
||||||
const detectedInstallment = detectInstallmentFromName(item.name);
|
|
||||||
const canConvertToInstallment =
|
const canConvertToInstallment =
|
||||||
isOwnData &&
|
isOwnData &&
|
||||||
item.paymentMethod === CREDIT_CARD_PAYMENT_METHOD &&
|
item.paymentMethod === CREDIT_CARD_PAYMENT_METHOD &&
|
||||||
@@ -74,7 +72,6 @@ export function TransactionActionsMenu({
|
|||||||
!item.splitGroupId &&
|
!item.splitGroupId &&
|
||||||
!item.isDivided &&
|
!item.isDivided &&
|
||||||
!item.readonly &&
|
!item.readonly &&
|
||||||
Boolean(detectedInstallment) &&
|
|
||||||
Boolean(onConvertToInstallment);
|
Boolean(onConvertToInstallment);
|
||||||
|
|
||||||
const canConvertToRecurring =
|
const canConvertToRecurring =
|
||||||
@@ -140,18 +137,14 @@ export function TransactionActionsMenu({
|
|||||||
) : null}
|
) : null}
|
||||||
|
|
||||||
{canConvertToInstallment ? (
|
{canConvertToInstallment ? (
|
||||||
<DropdownMenuItem
|
<DropdownMenuItem onSelect={() => onConvertToInstallment?.(item)}>
|
||||||
onSelect={() => onConvertToInstallment?.(item)}
|
|
||||||
>
|
|
||||||
{getConditionIcon("Parcelado")}
|
{getConditionIcon("Parcelado")}
|
||||||
Converter em Parcelamento
|
Converter em Parcelamento
|
||||||
</DropdownMenuItem>
|
</DropdownMenuItem>
|
||||||
) : null}
|
) : null}
|
||||||
|
|
||||||
{canConvertToRecurring ? (
|
{canConvertToRecurring ? (
|
||||||
<DropdownMenuItem
|
<DropdownMenuItem onSelect={() => onConvertToRecurring?.(item)}>
|
||||||
onSelect={() => onConvertToRecurring?.(item)}
|
|
||||||
>
|
|
||||||
{getConditionIcon("Recorrente")}
|
{getConditionIcon("Recorrente")}
|
||||||
Converter em Recorrente
|
Converter em Recorrente
|
||||||
</DropdownMenuItem>
|
</DropdownMenuItem>
|
||||||
|
|||||||
@@ -551,8 +551,12 @@ function buildColumns({
|
|||||||
onRefund={handleRefund}
|
onRefund={handleRefund}
|
||||||
onAnticipate={handleAnticipate}
|
onAnticipate={handleAnticipate}
|
||||||
onViewAnticipationHistory={handleViewAnticipationHistory}
|
onViewAnticipationHistory={handleViewAnticipationHistory}
|
||||||
onConvertToInstallment={onConvertToInstallment ? handleConvertToInstallment : undefined}
|
onConvertToInstallment={
|
||||||
onConvertToRecurring={onConvertToRecurring ? handleConvertToRecurring : undefined}
|
onConvertToInstallment ? handleConvertToInstallment : undefined
|
||||||
|
}
|
||||||
|
onConvertToRecurring={
|
||||||
|
onConvertToRecurring ? handleConvertToRecurring : undefined
|
||||||
|
}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
),
|
),
|
||||||
|
|||||||
Reference in New Issue
Block a user