mirror of
https://github.com/felipegcoutinho/openmonetis.git
synced 2026-07-09 19:36:02 +00:00
Compare commits
4 Commits
be6fa6dcfc
...
01f161f011
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
01f161f011 | ||
|
|
4741087feb | ||
|
|
32b190ab4e | ||
|
|
d06bac5624 |
@@ -16,7 +16,7 @@
|
||||
3. **Periods** usam formato `YYYY-MM` (ex: `"2025-11"`). Utils em `src/shared/utils/period/`.
|
||||
4. **Moeda**: R$ com 2 decimais. DB: `numeric(12, 2)`. Utils em `src/shared/utils/currency.ts`.
|
||||
5. **Revalidation**: usar `revalidateForEntity("entity")` de `src/shared/lib/actions/helpers.ts` apos mutations.
|
||||
6. **Versionamento e publicação**: registrar mudancas no `CHANGELOG.md` seguindo Keep a Changelog, também alterar o `package.json` e o badge de versão do `README.md`. Cada versão deve ter um parágrafo introdutório em linguagem humana logo abaixo do cabeçalho `## [x.y.z]`, antes das seções `### Adicionado/Alterado/Removido` — descrevendo em prosa o que a versão representa (ex: "Esta versão foca em polimento visual e reorganização interna..."). A `main` executa somente a CI; imagens Docker e GitHub Releases são publicadas exclusivamente por tags SemVer no formato `vX.Y.Z`. Antes de criar a tag, confirmar que a CI da `main` passou e que tag, `package.json`, `CHANGELOG.md` e badge do `README.md` usam a mesma versão. A tag deve apontar para o commit validado. Criar ou enviar uma tag dispara publicação externa (`X.Y.Z`, `X.Y`, `X` e `latest` no Docker Hub, seguida da GitHub Release), portanto agentes nunca devem criar ou fazer push de tags sem autorização explícita do usuário. Não voltar a publicar `latest` diretamente de pushes na `main`.
|
||||
6. **Versionamento e publicação**: registrar mudancas no `CHANGELOG.md` seguindo Keep a Changelog, também alterar o `package.json` e o badge de versão do `README.md`. Cada versão deve ter um parágrafo introdutório em linguagem humana logo abaixo do cabeçalho `## [x.y.z]`, antes das seções `### Adicionado/Alterado/Removido` — descrevendo em prosa o que a versão representa (ex: "Esta versão foca em polimento visual e reorganização interna..."). A `main` executa somente a CI; imagens Docker e GitHub Releases são publicadas exclusivamente por tags SemVer no formato `vX.Y.Z`. Antes de criar a tag, confirmar que a CI da `main` passou e que tag, `package.json`, `CHANGELOG.md` e badge do `README.md` usam a mesma versão. A tag deve apontar para o commit validado. Criar ou enviar uma tag dispara publicação externa (`X.Y.Z`, `X.Y`, `X` e `latest` no Docker Hub, seguida da GitHub Release), portanto agentes nunca devem criar ou fazer push de tags sem autorização explícita do usuário. Quando o usuário pedir **"commit e push"** em uma mudança que prepara uma nova versão, isso conta como autorização explícita para executar o fluxo completo: commitar, enviar a `main`, aguardar a CI da `main` passar, criar a tag SemVer correspondente à versão preparada e enviar essa tag. Se não houver versão preparada ou se houver divergência entre `package.json`, `CHANGELOG.md`, badge do `README.md` e tag pretendida, parar e pedir confirmação. Não voltar a publicar `latest` diretamente de pushes na `main`.
|
||||
7. **Comunicacao**: responder em portugues clara e direta com o time.
|
||||
8. **Commit messages**: agrupar por natureza. em pt-br. seguindo o padrao do sistema.
|
||||
9. **README.md**: sempre que fizer alteracoes significativas, atualize o README.md.
|
||||
|
||||
10
CHANGELOG.md
10
CHANGELOG.md
@@ -5,6 +5,16 @@ 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/),
|
||||
e este projeto adere ao [Versionamento Semântico](https://semver.org/lang/pt-BR/).
|
||||
|
||||
## [2.7.10] - 2026-06-27
|
||||
|
||||
Esta versão ajusta a experiência de leitura dos lançamentos parcelados após antecipações, permitindo esconder parcelas já liquidadas por antecipação sem perder o histórico quando ele ainda for necessário.
|
||||
|
||||
### Adicionado
|
||||
- Ajustes: nova preferência `Ocultar parcelas antecipadas` para remover da tabela lançamentos marcados como parcela antecipada.
|
||||
|
||||
### Alterado
|
||||
- Lançamentos: a preferência passa a ser aplicada nas listagens principais, extratos de conta, faturas de cartão, detalhes de pessoa, detalhes de categoria e exportação de lançamentos, preservando paginação e contagens visíveis.
|
||||
|
||||
## [2.7.9] - 2026-06-21
|
||||
|
||||
Esta versão torna a publicação mais previsível ao separar a validação contínua da entrega de versões oficiais. Pull requests e a branch principal continuam sendo verificadas, enquanto imagens Docker e releases passam a ser produzidas somente a partir de uma tag SemVer validada.
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
3. **Periods** usam formato `YYYY-MM` (ex: `"2025-11"`). Utils em `src/shared/utils/period/`.
|
||||
4. **Moeda**: R$ com 2 decimais. DB: `numeric(12, 2)`. Utils em `src/shared/utils/currency.ts`.
|
||||
5. **Revalidation**: usar `revalidateForEntity("entity")` de `src/shared/lib/actions/helpers.ts` apos mutations.
|
||||
6. **Versionamento**: registrar mudancas no `CHANGELOG.md` seguindo Keep a Changelog, também altere o `package.json` e `readme.md` (Badges do README.md). Cada versão deve ter um parágrafo introdutório em linguagem humana logo abaixo do cabeçalho `## [x.y.z]`, antes das seções `### Adicionado/Alterado/Removido` — descrevendo em prosa o que a versão representa (ex: "Esta versão foca em polimento visual e reorganização interna...").
|
||||
6. **Versionamento e publicação**: registrar mudancas no `CHANGELOG.md` seguindo Keep a Changelog, também alterar o `package.json` e o badge de versão do `README.md`. Cada versão deve ter um parágrafo introdutório em linguagem humana logo abaixo do cabeçalho `## [x.y.z]`, antes das seções `### Adicionado/Alterado/Removido` — descrevendo em prosa o que a versão representa (ex: "Esta versão foca em polimento visual e reorganização interna..."). A `main` executa somente a CI; imagens Docker e GitHub Releases são publicadas exclusivamente por tags SemVer no formato `vX.Y.Z`. Antes de criar a tag, confirmar que a CI da `main` passou e que tag, `package.json`, `CHANGELOG.md` e badge do `README.md` usam a mesma versão. A tag deve apontar para o commit validado. Criar ou enviar uma tag dispara publicação externa (`X.Y.Z`, `X.Y`, `X` e `latest` no Docker Hub, seguida da GitHub Release), portanto agentes nunca devem criar ou fazer push de tags sem autorização explícita do usuário. Quando o usuário pedir **"commit e push"** em uma mudança que prepara uma nova versão, isso conta como autorização explícita para executar o fluxo completo: commitar, enviar a `main`, aguardar a CI da `main` passar, criar a tag SemVer correspondente à versão preparada e enviar essa tag. Se não houver versão preparada ou se houver divergência entre `package.json`, `CHANGELOG.md`, badge do `README.md` e tag pretendida, parar e pedir confirmação. Não voltar a publicar `latest` diretamente de pushes na `main`.
|
||||
7. **Comunicacao**: responder em portugues clara e direta com o time.
|
||||
8. **Commit messages**: agrupar por natureza. em pt-br. seguindo o padrao do sistema.
|
||||
9. **README.md**: sempre que fizer alteracoes significativas, atualize o README.md.
|
||||
|
||||
@@ -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.
|
||||
|
||||
[](CHANGELOG.md)
|
||||
[](CHANGELOG.md)
|
||||
[](https://nextjs.org/)
|
||||
[](https://www.typescriptlang.org/)
|
||||
[](https://www.postgresql.org/)
|
||||
@@ -628,8 +628,8 @@ Antes de começar, leia o [`CLAUDE.md`](CLAUDE.md) — ele documenta a arquitetu
|
||||
As validações rodam em pull requests e em cada push na `main`. A publicação só começa quando uma tag SemVer aponta para um commit validado e a versão da tag corresponde ao `package.json` e ao `CHANGELOG.md`.
|
||||
|
||||
```bash
|
||||
git tag -a v2.7.9 -m "v2.7.9"
|
||||
git push origin v2.7.9
|
||||
git tag -a v2.7.10 -m "v2.7.10"
|
||||
git push origin v2.7.10
|
||||
```
|
||||
|
||||
O workflow da tag valida o código, publica as imagens Docker versionadas e `latest` e, somente depois, cria a GitHub Release com as notas do changelog.
|
||||
|
||||
1
drizzle/0032_bumpy_spencer_smythe.sql
Normal file
1
drizzle/0032_bumpy_spencer_smythe.sql
Normal file
@@ -0,0 +1 @@
|
||||
ALTER TABLE "preferencias_usuario" ADD COLUMN "ocultar_parcelas_antecipadas" boolean DEFAULT false NOT NULL;
|
||||
2995
drizzle/meta/0032_snapshot.json
Normal file
2995
drizzle/meta/0032_snapshot.json
Normal file
File diff suppressed because it is too large
Load Diff
@@ -218,6 +218,13 @@
|
||||
"when": 1782051007412,
|
||||
"tag": "0031_lame_cerise",
|
||||
"breakpoints": true
|
||||
},
|
||||
{
|
||||
"idx": 32,
|
||||
"version": "7",
|
||||
"when": 1782569103402,
|
||||
"tag": "0032_bumpy_spencer_smythe",
|
||||
"breakpoints": true
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
40
package.json
40
package.json
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "openmonetis",
|
||||
"version": "2.7.9",
|
||||
"version": "2.7.10",
|
||||
"private": true,
|
||||
"packageManager": "pnpm@11.1.3",
|
||||
"scripts": {
|
||||
@@ -31,32 +31,32 @@
|
||||
"mockup": "tsx scripts/mock-data.ts"
|
||||
},
|
||||
"dependencies": {
|
||||
"@ai-sdk/anthropic": "^3.0.81",
|
||||
"@ai-sdk/google": "^3.0.80",
|
||||
"@ai-sdk/openai": "^3.0.67",
|
||||
"@ai-sdk/openai-compatible": "^2.0.48",
|
||||
"@aws-sdk/client-s3": "^3.1059.0",
|
||||
"@aws-sdk/s3-request-presigner": "^3.1059.0",
|
||||
"@better-auth/passkey": "^1.6.14",
|
||||
"@ai-sdk/anthropic": "^3.0.88",
|
||||
"@ai-sdk/google": "^3.0.85",
|
||||
"@ai-sdk/openai": "^3.0.76",
|
||||
"@ai-sdk/openai-compatible": "^2.0.53",
|
||||
"@aws-sdk/client-s3": "^3.1075.0",
|
||||
"@aws-sdk/s3-request-presigner": "^3.1075.0",
|
||||
"@better-auth/passkey": "^1.6.22",
|
||||
"@dnd-kit/core": "^6.3.1",
|
||||
"@dnd-kit/sortable": "^10.0.0",
|
||||
"@dnd-kit/utilities": "^3.2.2",
|
||||
"@openrouter/ai-sdk-provider": "^2.9.0",
|
||||
"@openrouter/ai-sdk-provider": "^2.10.0",
|
||||
"@radix-ui/react-alert-dialog": "1.1.15",
|
||||
"@radix-ui/react-avatar": "1.1.11",
|
||||
"@radix-ui/react-checkbox": "1.3.3",
|
||||
"@radix-ui/react-collapsible": "1.1.12",
|
||||
"@radix-ui/react-dialog": "1.1.15",
|
||||
"@radix-ui/react-dropdown-menu": "2.1.16",
|
||||
"@radix-ui/react-hover-card": "^1.1.15",
|
||||
"@radix-ui/react-hover-card": "^1.1.17",
|
||||
"@radix-ui/react-label": "2.1.8",
|
||||
"@radix-ui/react-navigation-menu": "^1.2.14",
|
||||
"@radix-ui/react-popover": "^1.1.15",
|
||||
"@radix-ui/react-navigation-menu": "^1.2.16",
|
||||
"@radix-ui/react-popover": "^1.1.17",
|
||||
"@radix-ui/react-progress": "1.1.8",
|
||||
"@radix-ui/react-radio-group": "^1.3.8",
|
||||
"@radix-ui/react-radio-group": "^1.4.1",
|
||||
"@radix-ui/react-select": "2.2.6",
|
||||
"@radix-ui/react-separator": "1.1.8",
|
||||
"@radix-ui/react-slider": "^1.3.6",
|
||||
"@radix-ui/react-slider": "^1.4.1",
|
||||
"@radix-ui/react-slot": "1.2.4",
|
||||
"@radix-ui/react-switch": "1.2.6",
|
||||
"@radix-ui/react-tabs": "1.1.13",
|
||||
@@ -64,11 +64,11 @@
|
||||
"@radix-ui/react-toggle-group": "1.1.11",
|
||||
"@radix-ui/react-tooltip": "1.2.8",
|
||||
"@remixicon/react": "4.9.0",
|
||||
"@tanstack/react-query": "^5.101.0",
|
||||
"@tanstack/react-query": "^5.101.1",
|
||||
"@tanstack/react-table": "8.21.3",
|
||||
"@tanstack/react-virtual": "^3.14.2",
|
||||
"ai": "^6.0.195",
|
||||
"better-auth": "1.6.14",
|
||||
"@tanstack/react-virtual": "^3.14.4",
|
||||
"ai": "^6.0.213",
|
||||
"better-auth": "1.6.22",
|
||||
"canvas-confetti": "^1.9.4",
|
||||
"class-variance-authority": "0.7.1",
|
||||
"clsx": "2.1.1",
|
||||
@@ -86,7 +86,7 @@
|
||||
"react-day-picker": "^10.0.1",
|
||||
"react-dom": "19.2.7",
|
||||
"recharts": "3.8.1",
|
||||
"resend": "^6.12.4",
|
||||
"resend": "^6.16.0",
|
||||
"sonner": "2.0.7",
|
||||
"tailwind-merge": "3.6.0",
|
||||
"tw-animate-css": "^1.4.0",
|
||||
@@ -105,7 +105,7 @@
|
||||
"babel-plugin-react-compiler": "^1.0.0",
|
||||
"dotenv": "^17.4.2",
|
||||
"drizzle-kit": "0.31.10",
|
||||
"knip": "^6.15.0",
|
||||
"knip": "^6.22.0",
|
||||
"tailwindcss": "4.3.0",
|
||||
"tsx": "4.22.4",
|
||||
"typescript": "6.0.3"
|
||||
|
||||
2673
pnpm-lock.yaml
generated
2673
pnpm-lock.yaml
generated
File diff suppressed because it is too large
Load Diff
@@ -109,6 +109,8 @@ export default async function Page({ params, searchParams }: PageProps) {
|
||||
filters: searchFilters,
|
||||
slugMaps,
|
||||
accountId: account.id,
|
||||
hideAnticipatedInstallments:
|
||||
userPreferences?.hideAnticipatedInstallments ?? false,
|
||||
});
|
||||
|
||||
const transactionsPage = await fetchAccountTransactionsPage(
|
||||
|
||||
@@ -82,6 +82,8 @@ export default async function Page({ params, searchParams }: PageProps) {
|
||||
filters: searchFilters,
|
||||
slugMaps,
|
||||
cardId: card.id,
|
||||
hideAnticipatedInstallments:
|
||||
userPreferences?.hideAnticipatedInstallments ?? false,
|
||||
});
|
||||
|
||||
const transactionRows = await fetchCardTransactions(filters);
|
||||
|
||||
@@ -41,13 +41,17 @@ export default async function Page({ params, searchParams }: PageProps) {
|
||||
const periodoParam = getSingleParam(resolvedSearchParams, "periodo");
|
||||
const { period: selectedPeriod } = parsePeriodParam(periodoParam);
|
||||
|
||||
const [detail, filterSources, estabelecimentos, userPreferences] =
|
||||
await Promise.all([
|
||||
fetchCategoryDetails(userId, categoryId, selectedPeriod),
|
||||
fetchTransactionFilterSources(userId),
|
||||
fetchRecentEstablishments(userId),
|
||||
fetchUserPreferences(userId),
|
||||
]);
|
||||
const [filterSources, estabelecimentos, userPreferences] = await Promise.all([
|
||||
fetchTransactionFilterSources(userId),
|
||||
fetchRecentEstablishments(userId),
|
||||
fetchUserPreferences(userId),
|
||||
]);
|
||||
const detail = await fetchCategoryDetails(
|
||||
userId,
|
||||
categoryId,
|
||||
selectedPeriod,
|
||||
userPreferences?.hideAnticipatedInstallments ?? false,
|
||||
);
|
||||
|
||||
if (!detail) {
|
||||
notFound();
|
||||
|
||||
@@ -131,6 +131,7 @@ export default async function Page({ params, searchParams }: PageProps) {
|
||||
...EMPTY_FILTERS,
|
||||
searchFilter: allSearchFilters.searchFilter, // Permitir busca mesmo em modo read-only
|
||||
};
|
||||
const userPreferences = await fetchUserPreferences(userId);
|
||||
|
||||
let filterSources: Awaited<
|
||||
ReturnType<typeof fetchTransactionFilterSources>
|
||||
@@ -163,6 +164,8 @@ export default async function Page({ params, searchParams }: PageProps) {
|
||||
filters: searchFilters,
|
||||
slugMaps,
|
||||
payerId: pagador.id,
|
||||
hideAnticipatedInstallments:
|
||||
userPreferences?.hideAnticipatedInstallments ?? false,
|
||||
});
|
||||
|
||||
const sharesPromise = canEdit
|
||||
@@ -184,7 +187,6 @@ export default async function Page({ params, searchParams }: PageProps) {
|
||||
shareRows,
|
||||
currentUserShare,
|
||||
estabelecimentos,
|
||||
userPreferences,
|
||||
] = await Promise.all([
|
||||
fetchPayerTransactions(filters),
|
||||
fetchPayerMonthlyBreakdown({
|
||||
@@ -220,7 +222,6 @@ export default async function Page({ params, searchParams }: PageProps) {
|
||||
sharesPromise,
|
||||
currentUserSharePromise,
|
||||
fetchRecentEstablishments(userId),
|
||||
fetchUserPreferences(userId),
|
||||
]);
|
||||
|
||||
const mappedTransactions = mapTransactionsData(transactionRows);
|
||||
|
||||
@@ -85,6 +85,9 @@ export default async function Page() {
|
||||
showTransactionSummary={
|
||||
userPreferences?.showTransactionSummary ?? true
|
||||
}
|
||||
hideAnticipatedInstallments={
|
||||
userPreferences?.hideAnticipatedInstallments ?? false
|
||||
}
|
||||
/>
|
||||
</div>
|
||||
</Card>
|
||||
|
||||
@@ -53,6 +53,8 @@ export default async function Page({ searchParams }: PageProps) {
|
||||
period: selectedPeriod,
|
||||
filters: searchFilters,
|
||||
slugMaps,
|
||||
hideAnticipatedInstallments:
|
||||
userPreferences?.hideAnticipatedInstallments ?? false,
|
||||
});
|
||||
|
||||
const [transactionsPage, estabelecimentos] = await Promise.all([
|
||||
|
||||
@@ -157,6 +157,9 @@ export const userPreferences = pgTable("preferencias_usuario", {
|
||||
showTransactionSummary: boolean("mostrar_resumo_lancamento")
|
||||
.notNull()
|
||||
.default(true),
|
||||
hideAnticipatedInstallments: boolean("ocultar_parcelas_antecipadas")
|
||||
.notNull()
|
||||
.default(false),
|
||||
dashboardWidgets: jsonb("dashboard_widgets").$type<{
|
||||
order: string[];
|
||||
hidden: string[];
|
||||
|
||||
@@ -36,6 +36,7 @@ export async function fetchCategoryDetails(
|
||||
userId: string,
|
||||
categoryId: string,
|
||||
period: string,
|
||||
hideAnticipatedInstallments = false,
|
||||
): Promise<CategoryDetailData | null> {
|
||||
const category = await db.query.categories.findFirst({
|
||||
where: and(eq(categories.userId, userId), eq(categories.id, categoryId)),
|
||||
@@ -63,6 +64,14 @@ export async function fetchCategoryDetails(
|
||||
eq(transactions.transactionType, transactionType),
|
||||
eq(transactions.period, period),
|
||||
eq(transactions.payerId, adminPayerId),
|
||||
...(hideAnticipatedInstallments
|
||||
? [
|
||||
or(
|
||||
isNull(transactions.isAnticipated),
|
||||
eq(transactions.isAnticipated, false),
|
||||
),
|
||||
]
|
||||
: []),
|
||||
...(isInvoiceCategory ? [] : [sanitizedNote]),
|
||||
),
|
||||
with: {
|
||||
|
||||
@@ -69,6 +69,7 @@ const updatePreferencesSchema = z.object({
|
||||
transactionsColumnOrder: z.array(z.string()).nullable(),
|
||||
attachmentMaxSizeMb: z.number().int().min(1).max(100),
|
||||
showTransactionSummary: z.boolean(),
|
||||
hideAnticipatedInstallments: z.boolean(),
|
||||
});
|
||||
|
||||
type ResettableUser = {
|
||||
@@ -584,6 +585,7 @@ export async function updatePreferencesAction(
|
||||
transactionsColumnOrder: validated.transactionsColumnOrder,
|
||||
attachmentMaxSizeMb: validated.attachmentMaxSizeMb,
|
||||
showTransactionSummary: validated.showTransactionSummary,
|
||||
hideAnticipatedInstallments: validated.hideAnticipatedInstallments,
|
||||
updatedAt: new Date(),
|
||||
})
|
||||
.where(eq(schema.userPreferences.userId, session.user.id));
|
||||
@@ -595,6 +597,7 @@ export async function updatePreferencesAction(
|
||||
transactionsColumnOrder: validated.transactionsColumnOrder,
|
||||
attachmentMaxSizeMb: validated.attachmentMaxSizeMb,
|
||||
showTransactionSummary: validated.showTransactionSummary,
|
||||
hideAnticipatedInstallments: validated.hideAnticipatedInstallments,
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -43,6 +43,7 @@ interface PreferencesFormProps {
|
||||
transactionsColumnOrder: string[] | null;
|
||||
attachmentMaxSizeMb: number;
|
||||
showTransactionSummary: boolean;
|
||||
hideAnticipatedInstallments: boolean;
|
||||
}
|
||||
|
||||
function SortableColumnItem({ id }: { id: string }) {
|
||||
@@ -87,6 +88,7 @@ export function PreferencesForm({
|
||||
transactionsColumnOrder: initialColumnOrder,
|
||||
attachmentMaxSizeMb: initialAttachmentMaxSizeMb,
|
||||
showTransactionSummary: initialShowTransactionSummary,
|
||||
hideAnticipatedInstallments: initialHideAnticipatedInstallments,
|
||||
}: PreferencesFormProps) {
|
||||
const router = useRouter();
|
||||
const [isPending, startTransition] = useTransition();
|
||||
@@ -109,6 +111,8 @@ export function PreferencesForm({
|
||||
const [showTransactionSummary, setShowTransactionSummary] = useState(
|
||||
initialShowTransactionSummary,
|
||||
);
|
||||
const [hideAnticipatedInstallments, setHideAnticipatedInstallments] =
|
||||
useState(initialHideAnticipatedInstallments);
|
||||
|
||||
const sensors = useSensors(
|
||||
useSensor(PointerSensor, { activationConstraint: { distance: 8 } }),
|
||||
@@ -135,6 +139,7 @@ export function PreferencesForm({
|
||||
transactionsColumnOrder: columnOrder,
|
||||
attachmentMaxSizeMb,
|
||||
showTransactionSummary,
|
||||
hideAnticipatedInstallments,
|
||||
});
|
||||
|
||||
if (result.success) {
|
||||
@@ -198,6 +203,26 @@ export function PreferencesForm({
|
||||
|
||||
<Separator />
|
||||
|
||||
<section className="flex items-center justify-between max-w-md gap-4">
|
||||
<div className="space-y-2">
|
||||
<Label htmlFor="hide-anticipated-installments" className="text-sm">
|
||||
Ocultar parcelas antecipadas
|
||||
</Label>
|
||||
<p className="text-sm text-muted-foreground">
|
||||
Quando ativo, parcelas já antecipadas não aparecem na tabela de
|
||||
lançamentos.
|
||||
</p>
|
||||
</div>
|
||||
<Switch
|
||||
id="hide-anticipated-installments"
|
||||
checked={hideAnticipatedInstallments}
|
||||
onCheckedChange={setHideAnticipatedInstallments}
|
||||
disabled={isPending}
|
||||
/>
|
||||
</section>
|
||||
|
||||
<Separator />
|
||||
|
||||
<section className="space-y-2 max-w-md">
|
||||
<Label className="text-sm">Ordem das colunas</Label>
|
||||
<p className="text-sm text-muted-foreground">
|
||||
|
||||
@@ -7,6 +7,7 @@ interface UserPreferences {
|
||||
transactionsColumnOrder: string[] | null;
|
||||
attachmentMaxSizeMb: number;
|
||||
showTransactionSummary: boolean;
|
||||
hideAnticipatedInstallments: boolean;
|
||||
}
|
||||
|
||||
interface ApiToken {
|
||||
@@ -36,6 +37,8 @@ export async function fetchUserPreferences(
|
||||
transactionsColumnOrder: schema.userPreferences.transactionsColumnOrder,
|
||||
attachmentMaxSizeMb: schema.userPreferences.attachmentMaxSizeMb,
|
||||
showTransactionSummary: schema.userPreferences.showTransactionSummary,
|
||||
hideAnticipatedInstallments:
|
||||
schema.userPreferences.hideAnticipatedInstallments,
|
||||
})
|
||||
.from(schema.userPreferences)
|
||||
.where(eq(schema.userPreferences.userId, userId))
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
|
||||
import { z } from "zod";
|
||||
import { fetchAccountTransactions } from "@/features/accounts/statement-queries";
|
||||
import { fetchUserPreferences } from "@/features/settings/queries";
|
||||
import type { TransactionsExportContext } from "@/features/transactions/lib/export-types";
|
||||
import {
|
||||
buildSluggedFilters,
|
||||
@@ -60,7 +61,10 @@ export async function exportTransactionsDataAction(
|
||||
try {
|
||||
const userId = await getUserId();
|
||||
const validated = exportTransactionsSchema.parse(input);
|
||||
const filterSources = await fetchTransactionFilterSources(userId);
|
||||
const [filterSources, userPreferences] = await Promise.all([
|
||||
fetchTransactionFilterSources(userId),
|
||||
fetchUserPreferences(userId),
|
||||
]);
|
||||
const sluggedFilters = buildSluggedFilters(filterSources);
|
||||
const slugMaps = buildSlugMaps(sluggedFilters);
|
||||
|
||||
@@ -72,6 +76,8 @@ export async function exportTransactionsDataAction(
|
||||
accountId: validated.accountId ?? undefined,
|
||||
cardId: validated.cardId ?? undefined,
|
||||
payerId: validated.payerId ?? undefined,
|
||||
hideAnticipatedInstallments:
|
||||
userPreferences?.hideAnticipatedInstallments ?? false,
|
||||
});
|
||||
|
||||
const rows =
|
||||
|
||||
@@ -6,6 +6,7 @@ import {
|
||||
ilike,
|
||||
inArray,
|
||||
isNotNull,
|
||||
isNull,
|
||||
lte,
|
||||
or,
|
||||
sql,
|
||||
@@ -384,6 +385,7 @@ export const buildTransactionWhere = ({
|
||||
cardId,
|
||||
accountId,
|
||||
payerId,
|
||||
hideAnticipatedInstallments = false,
|
||||
}: {
|
||||
userId: string;
|
||||
period: string;
|
||||
@@ -392,6 +394,7 @@ export const buildTransactionWhere = ({
|
||||
cardId?: string;
|
||||
accountId?: string;
|
||||
payerId?: string;
|
||||
hideAnticipatedInstallments?: boolean;
|
||||
}): SQL[] => {
|
||||
const where: SQL[] = [eq(transactions.userId, userId)];
|
||||
|
||||
@@ -421,6 +424,15 @@ export const buildTransactionWhere = ({
|
||||
where.push(eq(transactions.payerId, payerId));
|
||||
}
|
||||
|
||||
if (hideAnticipatedInstallments) {
|
||||
where.push(
|
||||
or(
|
||||
isNull(transactions.isAnticipated),
|
||||
eq(transactions.isAnticipated, false),
|
||||
) as SQL,
|
||||
);
|
||||
}
|
||||
|
||||
if (cardId) {
|
||||
where.push(eq(transactions.cardId, cardId));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user