refactor: remove deprecated components and streamline member coverage calculations, enhance budget management with improved payroll handling, and update UI elements for better clarity
This commit is contained in:
parent
983aeca2dc
commit
09d8794d72
42 changed files with 2166 additions and 2974 deletions
|
|
@ -4,17 +4,17 @@ export const useCoopBuilderStore = defineStore("coop", {
|
|||
state: () => ({
|
||||
operatingMode: "min" as "min" | "target",
|
||||
|
||||
// Currency preference
|
||||
currency: "EUR" as string,
|
||||
|
||||
// Flag to track if data was intentionally cleared
|
||||
_wasCleared: false,
|
||||
|
||||
members: [] as Array<{
|
||||
id: string;
|
||||
name: string;
|
||||
role?: string;
|
||||
hoursPerMonth?: number;
|
||||
minMonthlyNeeds: number;
|
||||
targetMonthlyPay: number;
|
||||
externalMonthlyIncome: number;
|
||||
monthlyPayPlanned: number;
|
||||
}>,
|
||||
|
||||
|
|
@ -22,6 +22,8 @@ export const useCoopBuilderStore = defineStore("coop", {
|
|||
id: string;
|
||||
label: string;
|
||||
monthly: number;
|
||||
annual?: number;
|
||||
amountType?: 'monthly' | 'annual';
|
||||
category?: string;
|
||||
certainty?: string;
|
||||
}>,
|
||||
|
|
@ -35,7 +37,6 @@ export const useCoopBuilderStore = defineStore("coop", {
|
|||
// Scenario and stress test state
|
||||
scenario: "current" as
|
||||
| "current"
|
||||
| "quit-jobs"
|
||||
| "start-production"
|
||||
| "custom",
|
||||
stress: {
|
||||
|
|
@ -46,8 +47,7 @@ export const useCoopBuilderStore = defineStore("coop", {
|
|||
|
||||
// Policy settings
|
||||
policy: {
|
||||
relationship: "equal-pay" as "equal-pay" | "needs-weighted" | "hours-weighted" | "role-banded",
|
||||
roleBands: {} as Record<string, number>,
|
||||
relationship: "equal-pay" as "equal-pay" | "needs-weighted" | "hours-weighted",
|
||||
},
|
||||
equalHourlyWage: 50,
|
||||
payrollOncostPct: 25,
|
||||
|
|
@ -63,6 +63,8 @@ export const useCoopBuilderStore = defineStore("coop", {
|
|||
id?: string;
|
||||
name: string;
|
||||
amount: number;
|
||||
annualAmount?: number;
|
||||
amountType?: 'monthly' | 'annual';
|
||||
category?: string;
|
||||
}>,
|
||||
}),
|
||||
|
|
@ -110,10 +112,19 @@ export const useCoopBuilderStore = defineStore("coop", {
|
|||
// Stream actions
|
||||
upsertStream(s: any) {
|
||||
const i = this.streams.findIndex((x) => x.id === s.id);
|
||||
|
||||
// Calculate monthly value based on amount type
|
||||
let monthlyValue = s.monthly || s.targetMonthlyAmount || 0;
|
||||
if (s.amountType === 'annual' && s.annual) {
|
||||
monthlyValue = Math.round(s.annual / 12);
|
||||
}
|
||||
|
||||
const withDefaults = {
|
||||
id: s.id || Date.now().toString(),
|
||||
label: s.label || s.name || "",
|
||||
monthly: s.monthly || s.targetMonthlyAmount || 0,
|
||||
monthly: monthlyValue,
|
||||
annual: s.annual || s.targetAnnualAmount || monthlyValue * 12,
|
||||
amountType: s.amountType || 'monthly',
|
||||
category: s.category ?? "",
|
||||
certainty: s.certainty ?? "Probable",
|
||||
};
|
||||
|
|
@ -148,7 +159,7 @@ export const useCoopBuilderStore = defineStore("coop", {
|
|||
|
||||
// Scenario
|
||||
setScenario(
|
||||
scenario: "current" | "quit-jobs" | "start-production" | "custom"
|
||||
scenario: "current" | "start-production" | "custom"
|
||||
) {
|
||||
this.scenario = scenario;
|
||||
},
|
||||
|
|
@ -159,14 +170,10 @@ export const useCoopBuilderStore = defineStore("coop", {
|
|||
},
|
||||
|
||||
// Policy updates
|
||||
setPolicy(relationship: "equal-pay" | "needs-weighted" | "hours-weighted" | "role-banded") {
|
||||
setPolicy(relationship: "equal-pay" | "needs-weighted" | "hours-weighted") {
|
||||
this.policy.relationship = relationship;
|
||||
},
|
||||
|
||||
setRoleBands(bands: Record<string, number>) {
|
||||
this.policy.roleBands = bands;
|
||||
},
|
||||
|
||||
setEqualWage(wage: number) {
|
||||
this.equalHourlyWage = wage;
|
||||
},
|
||||
|
|
@ -175,12 +182,24 @@ export const useCoopBuilderStore = defineStore("coop", {
|
|||
this.payrollOncostPct = pct;
|
||||
},
|
||||
|
||||
setCurrency(currency: string) {
|
||||
this.currency = currency;
|
||||
},
|
||||
|
||||
// Overhead costs
|
||||
addOverheadCost(cost: any) {
|
||||
// Calculate monthly value based on amount type
|
||||
let monthlyValue = cost.amount || 0;
|
||||
if (cost.amountType === 'annual' && cost.annualAmount) {
|
||||
monthlyValue = Math.round(cost.annualAmount / 12);
|
||||
}
|
||||
|
||||
const withDefaults = {
|
||||
id: cost.id || Date.now().toString(),
|
||||
name: cost.name || "",
|
||||
amount: cost.amount || 0,
|
||||
amount: monthlyValue,
|
||||
annualAmount: cost.annualAmount || monthlyValue * 12,
|
||||
amountType: cost.amountType || 'monthly',
|
||||
category: cost.category ?? "",
|
||||
};
|
||||
this.overheadCosts.push(withDefaults);
|
||||
|
|
@ -188,10 +207,19 @@ export const useCoopBuilderStore = defineStore("coop", {
|
|||
|
||||
upsertOverheadCost(cost: any) {
|
||||
const i = this.overheadCosts.findIndex((c) => c.id === cost.id);
|
||||
|
||||
// Calculate monthly value based on amount type
|
||||
let monthlyValue = cost.amount || 0;
|
||||
if (cost.amountType === 'annual' && cost.annualAmount) {
|
||||
monthlyValue = Math.round(cost.annualAmount / 12);
|
||||
}
|
||||
|
||||
const withDefaults = {
|
||||
id: cost.id || Date.now().toString(),
|
||||
name: cost.name || "",
|
||||
amount: cost.amount || 0,
|
||||
amount: monthlyValue,
|
||||
annualAmount: cost.annualAmount || monthlyValue * 12,
|
||||
amountType: cost.amountType || 'monthly',
|
||||
category: cost.category ?? "",
|
||||
};
|
||||
if (i === -1) {
|
||||
|
|
@ -218,6 +246,7 @@ export const useCoopBuilderStore = defineStore("coop", {
|
|||
// Reset ALL state to initial empty values
|
||||
this._wasCleared = true;
|
||||
this.operatingMode = "min";
|
||||
this.currency = "EUR";
|
||||
this.members = [];
|
||||
this.streams = [];
|
||||
this.milestones = [];
|
||||
|
|
@ -229,7 +258,6 @@ export const useCoopBuilderStore = defineStore("coop", {
|
|||
};
|
||||
this.policy = {
|
||||
relationship: "equal-pay",
|
||||
roleBands: {},
|
||||
};
|
||||
this.equalHourlyWage = 0;
|
||||
this.payrollOncostPct = 0;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue