Commit b90bf90
committed
Preserve source iteration order in cloneCustomUnitWithNewIDs
The previous version inserted non-default rates first and the rebound
default last. When a non-default source rate had no `index` field
(treated as CONST.DEFAULT_NUMBER_ID = 0 by getDefaultMileageRate's
sort), it tied with the default's index 0, and JavaScript's stable
sort then placed whichever came first in iteration order. With
non-defaults inserted first, the default fell behind — so the rate
the expense flow treated as default in the duplicated workspace was
the no-index rate, not the original default.
Iterate source rates in their original order and just swap the
default's key to newDefaultRateID. The default keeps its first-tied
position in the rates dict, getDefaultMileageRate's stable sort
behaves as it does on the source, and the original default is picked.1 parent b52c6b5 commit b90bf90
2 files changed
Lines changed: 51 additions & 5 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
306 | 306 | | |
307 | 307 | | |
308 | 308 | | |
| 309 | + | |
| 310 | + | |
| 311 | + | |
309 | 312 | | |
310 | 313 | | |
311 | 314 | | |
312 | 315 | | |
313 | 316 | | |
314 | 317 | | |
315 | 318 | | |
316 | | - | |
| 319 | + | |
| 320 | + | |
| 321 | + | |
317 | 322 | | |
318 | | - | |
319 | | - | |
320 | | - | |
321 | | - | |
322 | 323 | | |
323 | 324 | | |
324 | 325 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
433 | 433 | | |
434 | 434 | | |
435 | 435 | | |
| 436 | + | |
| 437 | + | |
| 438 | + | |
| 439 | + | |
| 440 | + | |
| 441 | + | |
| 442 | + | |
| 443 | + | |
| 444 | + | |
| 445 | + | |
| 446 | + | |
| 447 | + | |
| 448 | + | |
| 449 | + | |
| 450 | + | |
| 451 | + | |
| 452 | + | |
| 453 | + | |
| 454 | + | |
| 455 | + | |
| 456 | + | |
| 457 | + | |
| 458 | + | |
| 459 | + | |
| 460 | + | |
| 461 | + | |
| 462 | + | |
| 463 | + | |
| 464 | + | |
| 465 | + | |
| 466 | + | |
| 467 | + | |
| 468 | + | |
| 469 | + | |
| 470 | + | |
| 471 | + | |
| 472 | + | |
| 473 | + | |
| 474 | + | |
| 475 | + | |
| 476 | + | |
| 477 | + | |
| 478 | + | |
| 479 | + | |
| 480 | + | |
436 | 481 | | |
437 | 482 | | |
438 | 483 | | |
| |||
0 commit comments