Fix/user feedback (#210)

* Add delete policies for provider consent tokens and provider OTC

* Add trade name support for companies in settings and documents

* Resolved currency selection issue

* Enhance invoice line display with foreign currency support and update delivery date schema to allow empty values

* Add currency display for journal entries and include currency metadata in transaction creation

* Add trade_name column to company_settings for external display
This commit is contained in:
Mattsson
2026-04-09 16:22:51 +02:00
committed by GitHub
parent b484e9a7b4
commit bb336eba88
31 changed files with 452 additions and 87 deletions
@@ -11,6 +11,7 @@ import JournalEntryForm from '@/components/bookkeeping/JournalEntryForm'
import DocumentUploadZone from '@/components/bookkeeping/DocumentUploadZone'
import type { UploadedFile } from '@/components/bookkeeping/DocumentUploadZone'
import type { FormLine } from '@/components/bookkeeping/JournalEntryForm'
import { resolveSekAmount, buildCurrencyMetadata } from '@/lib/bookkeeping/currency-utils'
import type { TransactionWithInvoice } from './transaction-types'
interface TransactionBookingDialogProps {
@@ -21,21 +22,40 @@ interface TransactionBookingDialogProps {
}
function buildInitialLines(transaction: TransactionWithInvoice): FormLine[] {
const amount = Math.round(Math.abs(transaction.amount_sek ?? transaction.amount) * 100) / 100
const amountStr = amount.toFixed(2)
const sekAmount = Math.round(Math.abs(resolveSekAmount(
transaction.amount,
transaction.amount_sek,
transaction.currency,
transaction.exchange_rate
)) * 100) / 100
const amountStr = sekAmount.toFixed(2)
const isExpense = transaction.amount < 0
if (isExpense) {
return [
{ account_number: '1930', debit_amount: '', credit_amount: amountStr, line_description: 'Företagskonto' },
{ account_number: '', debit_amount: amountStr, credit_amount: '', line_description: '' },
]
const isForeign = !!transaction.currency && transaction.currency !== 'SEK'
const currencyMeta = isForeign
? buildCurrencyMetadata(
transaction.currency,
Math.abs(transaction.amount),
transaction.exchange_rate
)
: {}
const bankLine: FormLine = {
account_number: '1930',
debit_amount: isExpense ? '' : amountStr,
credit_amount: isExpense ? amountStr : '',
line_description: 'Företagskonto',
...currencyMeta,
}
return [
{ account_number: '1930', debit_amount: amountStr, credit_amount: '', line_description: 'Företagskonto' },
{ account_number: '', debit_amount: '', credit_amount: amountStr, line_description: '' },
]
const counterLine: FormLine = {
account_number: '',
debit_amount: isExpense ? amountStr : '',
credit_amount: isExpense ? '' : amountStr,
line_description: '',
}
return isExpense ? [bankLine, counterLine] : [bankLine, counterLine]
}
export default function TransactionBookingDialog({