Enforce positive=CREDIT for all BANK account uploads

Instead of relying on per-profile invertAmountSign settings, the upload
route now overrides invertAmountSign: true for any BANK account using
Strategy A. This ensures positive CSV amounts always map to CREDIT
(deposits) regardless of which bank or whether profile was auto-detected.
Credit card logic is unchanged.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-04-22 09:39:14 -04:00
parent 948ac2afe6
commit 1400aa99d6
2 changed files with 7 additions and 1 deletions

View File

@@ -74,6 +74,12 @@ export async function POST(req: Request) {
config = result.data
}
// For all BANK accounts using a single amount column, positive = deposit (CREDIT),
// negative = withdrawal (DEBIT). Override whatever the profile or manual mapping says.
if (account.type === 'BANK' && config.strategy === 'A') {
config = { ...config, invertAmountSign: true }
}
const normalized = normalizeRows(allRows, accountId, config)
// Apply transfer rules first, then budget rules (transfer takes priority)

View File

@@ -53,7 +53,7 @@ export const bankProfiles: BankProfile[] = [
descriptionColumn: 'Description',
amountColumn: 'Amount',
invertAmountSign: true, // negative = DEBIT (withdrawal), positive = CREDIT (deposit)
detectColumns: ['Date', 'Description', 'Amount'],
detectColumns: ['Date', 'Description', 'Amount', 'Split', 'Tags'],
},
{
id: 'fidelity',