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
94
utils/testDataConsistency.ts
Normal file
94
utils/testDataConsistency.ts
Normal file
|
|
@ -0,0 +1,94 @@
|
|||
/**
|
||||
* Test Data Consistency Utilities
|
||||
*
|
||||
* Functions to verify that data is consistent across all interfaces
|
||||
* after setup completion and synchronization
|
||||
*/
|
||||
|
||||
export const testDataConsistency = () => {
|
||||
const coopStore = useCoopBuilderStore()
|
||||
const streamsStore = useStreamsStore()
|
||||
const membersStore = useMembersStore()
|
||||
const policiesStore = usePoliciesStore()
|
||||
|
||||
const issues: string[] = []
|
||||
|
||||
// Test streams consistency
|
||||
if (coopStore.streams.length > 0 && streamsStore.streams.length > 0) {
|
||||
if (coopStore.streams.length !== streamsStore.streams.length) {
|
||||
issues.push(`Stream count mismatch: CoopBuilder(${coopStore.streams.length}) vs Legacy(${streamsStore.streams.length})`)
|
||||
}
|
||||
|
||||
// Check if stream data matches
|
||||
coopStore.streams.forEach(coopStream => {
|
||||
const legacyStream = streamsStore.streams.find(s => s.id === coopStream.id)
|
||||
if (!legacyStream) {
|
||||
issues.push(`CoopBuilder stream "${coopStream.label}" not found in legacy store`)
|
||||
} else {
|
||||
if (legacyStream.name !== coopStream.label) {
|
||||
issues.push(`Stream name mismatch for ${coopStream.id}: "${legacyStream.name}" vs "${coopStream.label}"`)
|
||||
}
|
||||
if (legacyStream.targetMonthlyAmount !== coopStream.monthly) {
|
||||
issues.push(`Stream amount mismatch for ${coopStream.id}: ${legacyStream.targetMonthlyAmount} vs ${coopStream.monthly}`)
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
// Test members consistency
|
||||
if (coopStore.members.length > 0 && membersStore.members.length > 0) {
|
||||
if (coopStore.members.length !== membersStore.members.length) {
|
||||
issues.push(`Member count mismatch: CoopBuilder(${coopStore.members.length}) vs Legacy(${membersStore.members.length})`)
|
||||
}
|
||||
|
||||
// Check if member data matches
|
||||
coopStore.members.forEach(coopMember => {
|
||||
const legacyMember = membersStore.members.find(m => m.id === coopMember.id)
|
||||
if (!legacyMember) {
|
||||
issues.push(`CoopBuilder member "${coopMember.name}" not found in legacy store`)
|
||||
} else {
|
||||
if (legacyMember.displayName !== coopMember.name) {
|
||||
issues.push(`Member name mismatch for ${coopMember.id}: "${legacyMember.displayName}" vs "${coopMember.name}"`)
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
// Test policies consistency
|
||||
if (coopStore.equalHourlyWage > 0 && policiesStore.equalHourlyWage > 0) {
|
||||
if (coopStore.equalHourlyWage !== policiesStore.equalHourlyWage) {
|
||||
issues.push(`Hourly wage mismatch: CoopBuilder(${coopStore.equalHourlyWage}) vs Legacy(${policiesStore.equalHourlyWage})`)
|
||||
}
|
||||
if (coopStore.payrollOncostPct !== policiesStore.payrollOncostPct) {
|
||||
issues.push(`Oncost percentage mismatch: CoopBuilder(${coopStore.payrollOncostPct}) vs Legacy(${policiesStore.payrollOncostPct})`)
|
||||
}
|
||||
}
|
||||
|
||||
return {
|
||||
isConsistent: issues.length === 0,
|
||||
issues,
|
||||
summary: issues.length === 0
|
||||
? 'All data is consistent across interfaces'
|
||||
: `${issues.length} consistency issues found`
|
||||
}
|
||||
}
|
||||
|
||||
export const logDataConsistency = () => {
|
||||
const result = testDataConsistency()
|
||||
|
||||
console.group('🔄 Data Consistency Check')
|
||||
console.log('Status:', result.isConsistent ? '✅ Consistent' : '❌ Issues Found')
|
||||
console.log('Summary:', result.summary)
|
||||
|
||||
if (result.issues.length > 0) {
|
||||
console.group('Issues:')
|
||||
result.issues.forEach((issue, index) => {
|
||||
console.log(`${index + 1}. ${issue}`)
|
||||
})
|
||||
console.groupEnd()
|
||||
}
|
||||
|
||||
console.groupEnd()
|
||||
|
||||
return result
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue