-
Notifications
You must be signed in to change notification settings - Fork 0
fix: ancorar término de parcelas em nextChargeMonth, não no mês atual (closes #114) #132
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Draft
Guiroos
wants to merge
4
commits into
main
Choose a base branch
from
claude/quirky-johnson-a64mgd
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
af914a7
fix: ancorar termino de parcelas em nextChargeMonth, nao no mes atual…
claude de435b3
fix: cobrir ancora de nextChargeMonth e ordenar lastEnd por YYYY-MM
claude a26955c
fix: ordenar "Termina mais cedo" por endYM, não por remainingInstallm…
claude 71d59ea
fix: entrada ja ordenada deixava o 2o teste de applySort passar com o…
claude File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,63 @@ | ||
| import { describe, it, expect } from 'vitest' | ||
| import { applySort } from '@/components/parcelas/ParcelasToolbar' | ||
|
|
||
| type Group = Parameters<typeof applySort>[0][number] | ||
|
|
||
| const group = (id: string, overrides: Partial<Group> = {}): Group => ({ | ||
| id, | ||
| name: `Grupo ${id}`, | ||
| categoryId: 'cat-1', | ||
| accountId: 'acc-1', | ||
| accountName: 'Conta', | ||
| categoryName: 'Categoria', | ||
| startDate: '2026-01-01', | ||
| nextChargeMonth: null, | ||
| nextChargeDate: null, | ||
| totalAmount: 0, | ||
| totalInstallments: 1, | ||
| paidInstallments: 0, | ||
| remainingInstallments: 1, | ||
| installmentAmount: 0, | ||
| remainingAmount: 0, | ||
| ...overrides, | ||
| }) | ||
|
|
||
| describe('applySort', () => { | ||
| it('soonest-end ordena por endYM (data real de término), não por remainingInstallments', () => { | ||
| // A: termina antes (out/26) mas tem mais parcelas restantes que B. | ||
| // B: termina depois (nov/26) mas tem menos parcelas restantes que A — a 1a | ||
| // parcela de B só cai em 2026-10, então "menos parcelas restantes" não significa | ||
| // "termina mais cedo" quando cada grupo parte de um nextChargeMonth diferente. | ||
| const a = group('A', { remainingInstallments: 3, endYM: '2026-10' }) | ||
| const b = group('B', { remainingInstallments: 2, endYM: '2026-11' }) | ||
|
|
||
| // Ordenar por remainingInstallments (o bug) devolveria [B, A] — B tem menos | ||
| // parcelas restantes (2 < 3) e apareceria primeiro, embora termine depois. | ||
| const sorted = applySort([b, a], 'soonest-end') | ||
|
|
||
| expect(sorted.map((g) => g.id)).toEqual(['A', 'B']) | ||
| }) | ||
|
|
||
| it('soonest-end com endYM ausente cai para string vazia (não quebra o sort)', () => { | ||
| const a = group('A', { endYM: undefined }) | ||
| const b = group('B', { endYM: '2026-01' }) | ||
|
|
||
| const sorted = applySort([b, a], 'soonest-end') | ||
|
|
||
| expect(sorted.map((g) => g.id)).toEqual(['A', 'B']) | ||
| }) | ||
|
|
||
| it('expensive ordena por installmentAmount decrescente', () => { | ||
| const a = group('A', { installmentAmount: 50 }) | ||
| const b = group('B', { installmentAmount: 100 }) | ||
|
|
||
| expect(applySort([a, b], 'expensive').map((g) => g.id)).toEqual(['B', 'A']) | ||
| }) | ||
|
|
||
| it('highest-balance ordena por remainingAmount decrescente', () => { | ||
| const a = group('A', { remainingAmount: 200 }) | ||
| const b = group('B', { remainingAmount: 500 }) | ||
|
|
||
| expect(applySort([a, b], 'highest-balance').map((g) => g.id)).toEqual(['B', 'A']) | ||
| }) | ||
| }) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.