refactor: enhance routing and state management in CoopBuilder, add migration checks on startup, and update Tailwind configuration for improved component styling
This commit is contained in:
parent
848386e3dd
commit
4cea1f71fe
55 changed files with 4053 additions and 1486 deletions
52
composables/usePayrollAllocation.ts
Normal file
52
composables/usePayrollAllocation.ts
Normal file
|
|
@ -0,0 +1,52 @@
|
|||
import { computed } from 'vue'
|
||||
import { storeToRefs } from 'pinia'
|
||||
import { allocatePayroll } from '~/types/members'
|
||||
|
||||
export function usePayrollAllocation() {
|
||||
const membersStore = useMembersStore()
|
||||
const policiesStore = usePoliciesStore()
|
||||
const budgetStore = useBudgetStore()
|
||||
|
||||
const { members, payPolicy } = storeToRefs(membersStore)
|
||||
const { equalHourlyWage, payrollOncostPct } = storeToRefs(policiesStore)
|
||||
const { capacityTotals } = storeToRefs(membersStore)
|
||||
|
||||
// Calculate base payroll budget from hours and wage
|
||||
const basePayrollBudget = computed(() => {
|
||||
const totalHours = capacityTotals.value.targetHours || 0
|
||||
const wage = equalHourlyWage.value || 0
|
||||
return totalHours * wage
|
||||
})
|
||||
|
||||
// Allocate payroll to members based on policy
|
||||
const allocatedMembers = computed(() => {
|
||||
if (members.value.length === 0 || basePayrollBudget.value === 0) {
|
||||
return members.value
|
||||
}
|
||||
|
||||
return allocatePayroll(
|
||||
members.value,
|
||||
payPolicy.value,
|
||||
basePayrollBudget.value
|
||||
)
|
||||
})
|
||||
|
||||
// Total payroll with oncosts
|
||||
const totalPayrollWithOncosts = computed(() => {
|
||||
return basePayrollBudget.value * (1 + payrollOncostPct.value / 100)
|
||||
})
|
||||
|
||||
// Update member planned pay when allocation changes
|
||||
watchEffect(() => {
|
||||
allocatedMembers.value.forEach(member => {
|
||||
membersStore.setPlannedPay(member.id, member.monthlyPayPlanned || 0)
|
||||
})
|
||||
})
|
||||
|
||||
return {
|
||||
basePayrollBudget,
|
||||
allocatedMembers,
|
||||
totalPayrollWithOncosts,
|
||||
payPolicy
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue