Fix/bank sync bas (#1284)
* fix(year-end): stop revaluing FX items that were not on the balance sheet The year-end close ran currency revaluation as an unconditional step before the irreversible close, and the revaluation queried LIVE open invoices with no date scoping. An invoice issued after balansdagen, settled before it, or never booked at all was therefore revalued into the year being closed, writing down a 1510/2440 that stood at zero. Because the entry lands inside the same run that closes the period, the only remedy left was a rattelse in the following year. The population is now measured as of balansdagen, reusing the reconstruction the reskontra reports already use (fetchPaymentsAsOf / outstandingAsOf): the invoice_date ceiling is unconditional (post-dated invoices make the bug reachable for a current period too) and the widening to 'paid' applies only to a historical date, where a since-settled invoice was still open then. Rows that carry no balance-sheet exposure are skipped per row rather than per company: an unbooked registration is not on 1510/2440. Deliberately NOT keyed on accounting_method, since BFL 5 kap 2 § 3 st requires kontantmetoden companies to book their outstanding fordringar/skulder at balansdagen, and those converted rows are genuine exposure that ARL 4 kap. 13 § must value. The readiness warning stays ungated on purpose: an unbooked FX row is exactly what deserves a warning, because /book still posts it into the year about to close and lockPeriod/closePeriod then removes that remedy for good. The wizard preview now lists the per-invoice revaluation rows it will post instead of three aggregate numbers, so the user approves line-level content before the close. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> * fix(bookkeeping): reach accounts outside BAS 2026 from a verifikat rattelse A user could not move a verifikat line to konto 8022: the picker reported no such account and offered no way forward. 8022 was dropped from BAS 2026 (it is in BAS 2018), so it is a legitimate company-specific underkonto rather than a catalog gap. Verified against the official bas.se kontoplan that our BAS reference already matches BAS 2026, so 8022 is deliberately NOT added to it: seeding a retired account would push it onto every company. StrikeLinesDialog and CorrectionEntryDialog were the only account pickers in the app that never passed onCreateAccount, so their combobox rendered a dead empty state. Both now open AddAccountDialog prefilled, then refetch the chart and select the new account on the initiating line, leaving the half-finished rattelse intact. AccountCombobox closed its dropdown on the fourth digit of any committed number, which hid the empty state before it was ever painted and made the create affordance unreachable for exactly the numbers that need it. It now closes only when the number matches something, so focus still advances to the belopp field for real accounts. No change to posting rules: correct_entry_lines_inline validates chart membership, not BAS membership, and account creation already required the same write role. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> * fix(vacation): adjust vacation accrual calculations for mid-year hires and update related logic --------- Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 5
parent
108f348c84
commit
3bbf2a051b
@@ -36,8 +36,10 @@ export interface SalaryCalculationInput {
|
||||
semestertillaggRate: number
|
||||
/** Work-schedule daily-rate divisor (arbetsschema-lite). Defaults to the
|
||||
* legacy 21 (5-day week); callers with a part-time schedule pass
|
||||
* dailyDivisor(workdays_per_week) from lib/salary/work-schedule. Used by
|
||||
* the sammalöneregeln day valuation. */
|
||||
* dailyDivisor(workdays_per_week) from lib/salary/work-schedule. Feeds the
|
||||
* daily-rate absence paths only. Deliberately NOT the sammalöneregeln
|
||||
* accrual: semestertillägg is a share of the monthly salary per vacation
|
||||
* day and does not vary with workdays per week. */
|
||||
dailyDivisor?: number
|
||||
|
||||
/** Växa-stöd */
|
||||
@@ -545,19 +547,36 @@ export function calculateSalary(
|
||||
})
|
||||
} else {
|
||||
// Sammalöneregeln (§16a): employee keeps regular salary during vacation
|
||||
// + semestertillägg per day (min 0.43%, often 0.8% per CBA)
|
||||
// + semestertillägg per vacation day (min 0.43%, often 0.8% per CBA)
|
||||
// Accrual = tillägg only (salary cost is already in normal monthly expense)
|
||||
// The liability (2920) for sammalöneregeln is the tillägg portion,
|
||||
// since the base salary is expensed monthly regardless of vacation.
|
||||
//
|
||||
// The tillägg is a share of the MONTHLY salary per vacation day, never of
|
||||
// the dagslön. Valuing it off a daily rate under-provisioned 2920 by the
|
||||
// whole divisor, while absence-calculator.ts relieves that same 2920 at
|
||||
// the correct monthly base when a day is taken, so the liability drifted
|
||||
// further negative with every taken day.
|
||||
//
|
||||
// Only the month's earned share accrues. The full annual entitlement used
|
||||
// to be booked in every single run; the two errors partly cancelled, which
|
||||
// is why the monthly total looked plausible while both halves were wrong.
|
||||
//
|
||||
// Use baseSalary (degree-adjusted): a 50% part-timer's tillägg should be
|
||||
// half a full-timer's, not the same.
|
||||
const dailyRate = r(baseSalary / (input.dailyDivisor ?? 21))
|
||||
const tillagg = r(dailyRate * input.semestertillaggRate * input.vacationDaysPerYear)
|
||||
// half a full-timer's, not the same. The schedule divisor deliberately
|
||||
// plays no part: semestertillägg does not depend on workdays per week.
|
||||
const daysEarnedThisMonth = input.vacationDaysPerYear / 12
|
||||
const tillagg = r(baseSalary * input.semestertillaggRate * daysEarnedThisMonth)
|
||||
vacationAccrual = tillagg
|
||||
steps.push({
|
||||
label: `Semesteravsättning (sammalöneregeln, tillägg ${fmtPct(input.semestertillaggRate)})`,
|
||||
formula: `dagslön × ${fmtPct(input.semestertillaggRate)} × semesterdagar`,
|
||||
input: { daily_rate: dailyRate, semestertillagg_rate: input.semestertillaggRate, vacation_days: input.vacationDaysPerYear },
|
||||
formula: `månadslön × ${fmtPct(input.semestertillaggRate)} × semesterdagar / 12`,
|
||||
input: {
|
||||
monthly_base: baseSalary,
|
||||
semestertillagg_rate: input.semestertillaggRate,
|
||||
vacation_days_per_year: input.vacationDaysPerYear,
|
||||
days_earned_this_month: r(daysEarnedThisMonth),
|
||||
},
|
||||
output: vacationAccrual,
|
||||
})
|
||||
}
|
||||
@@ -775,8 +794,6 @@ export function calculateVacationAccrual(params: {
|
||||
vacationDaysPerYear: number
|
||||
semestertillaggRate: number
|
||||
vacationBasis: number
|
||||
/** Arbetsschema-lite daily-rate divisor; legacy 21 when omitted. */
|
||||
dailyDivisor?: number
|
||||
}): { accrual: number; steps: CalculationStep[] } {
|
||||
const steps: CalculationStep[] = []
|
||||
|
||||
@@ -811,15 +828,23 @@ export function calculateVacationAccrual(params: {
|
||||
})
|
||||
return { accrual, steps }
|
||||
} else {
|
||||
// Sammalöneregeln: tillägg per vacation day. Use vacationBasis as the
|
||||
// degree-adjusted reference: callers must pass the part-time-adjusted
|
||||
// monthly amount, never the raw full-time monthlySalary.
|
||||
const dailyRate = r(params.vacationBasis / (params.dailyDivisor ?? 21))
|
||||
const accrual = r(dailyRate * params.semestertillaggRate * params.vacationDaysPerYear)
|
||||
// Sammalöneregeln: tillägg per vacation day, valued on the MONTHLY salary
|
||||
// and accrued one month's earned share at a time. See the mirrored branch
|
||||
// in calculateSalary for why neither a dagslön base nor the full annual
|
||||
// entitlement belongs here. Use vacationBasis as the degree-adjusted
|
||||
// reference: callers must pass the part-time-adjusted monthly amount,
|
||||
// never the raw full-time monthlySalary.
|
||||
const daysEarnedThisMonth = params.vacationDaysPerYear / 12
|
||||
const accrual = r(params.vacationBasis * params.semestertillaggRate * daysEarnedThisMonth)
|
||||
steps.push({
|
||||
label: `Semesteravsättning (sammalöneregeln ${fmtPct(params.semestertillaggRate)})`,
|
||||
formula: `dagslön × ${fmtPct(params.semestertillaggRate)} × semesterdagar`,
|
||||
input: { daily_rate: dailyRate, rate: params.semestertillaggRate, days: params.vacationDaysPerYear },
|
||||
formula: `månadslön × ${fmtPct(params.semestertillaggRate)} × semesterdagar / 12`,
|
||||
input: {
|
||||
monthly_base: params.vacationBasis,
|
||||
rate: params.semestertillaggRate,
|
||||
vacation_days_per_year: params.vacationDaysPerYear,
|
||||
days_earned_this_month: r(daysEarnedThisMonth),
|
||||
},
|
||||
output: accrual,
|
||||
})
|
||||
return { accrual, steps }
|
||||
|
||||
Reference in New Issue
Block a user