Commit 5551676
committed
fix(expenses): Ensure shares are consistent for 'EVENLY' split mode
This commit addresses a data inconsistency issue where expenses with a split mode of 'EVENLY' could have non-normalized shares, leading to calculation errors in features like CSV exports.
This is a comprehensive fix that includes two parts:
1. **Application-level fix:**
The createExpense and updateExpense functions in src/lib/api.ts are updated to explicitly check if the split mode is 'EVENLY'. If it is, the shares for all participants are normalized to 1, ensuring that all new and updated expenses are stored with consistent data.
2. **Data migration:**
A new data migration is introduced to clean up existing inconsistent data. The migration updates the shares to 1 for all ExpensePaidFor entries associated with an Expense where splitMode is 'EVENLY'.
Together, these changes guarantee data integrity for all 'EVENLY' split expenses, both past and future.1 parent 3b83a5f commit 5551676
2 files changed
+30
-3
lines changedLines changed: 11 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
64 | 64 | | |
65 | 65 | | |
66 | 66 | | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
67 | 75 | | |
68 | 76 | | |
69 | 77 | | |
| |||
87 | 95 | | |
88 | 96 | | |
89 | 97 | | |
90 | | - | |
| 98 | + | |
91 | 99 | | |
92 | 100 | | |
93 | 101 | | |
| |||
204 | 212 | | |
205 | 213 | | |
206 | 214 | | |
| 215 | + | |
| 216 | + | |
| 217 | + | |
| 218 | + | |
| 219 | + | |
| 220 | + | |
| 221 | + | |
| 222 | + | |
207 | 223 | | |
208 | 224 | | |
209 | 225 | | |
| |||
218 | 234 | | |
219 | 235 | | |
220 | 236 | | |
221 | | - | |
| 237 | + | |
222 | 238 | | |
223 | 239 | | |
224 | 240 | | |
| |||
229 | 245 | | |
230 | 246 | | |
231 | 247 | | |
232 | | - | |
| 248 | + | |
233 | 249 | | |
234 | 250 | | |
235 | 251 | | |
| |||
0 commit comments