Commit e81cdf5
Allow SetAccountCurrency after SetCash without throwing (#9457)
* Allow SetAccountCurrency after SetCash without throwing
Previously, calling SetAccountCurrency after SetCash threw an
InvalidOperationException. The portfolio manager now switches the
base account currency in place: the previous Cash entry (and its
balance) is preserved in the CashBook, and a notice is logged. When
the new account currency matches the existing one, an optional
startingCash overrides the previously set amount and the override
is logged.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
* Simplify SetAccountCurrency remarks and drop unused message
Tightens the XML remarks to two cases (different currency: keep previous
in its own entry; matching currency: override). Also removes the now
unused CannotChangeAccountCurrencyAfterSettingCash string since the
portfolio no longer throws.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
* Simplify in-line comment in SetAccountCurrency
Drops the "Undo that migration" wording (residue from a previous fix
attempt) and just describes what the branch does: keep the previous
balance in its own currency entry while the new account currency starts
at zero.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
* Differentiate implicit vs explicit SetCash on account currency switch
SetCash(decimal) is currency-agnostic: the amount is "this many units of
the (eventual) account currency". Switching the account currency now
re-labels the amount onto the new currency instead of preserving the
previous one. SetCash(symbol, ...) for the current account currency keeps
the old behaviour of preserving the balance in its own CashBook entry.
Splits the existing tests by overload and adds a starting-cash variant
for the explicit case.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
* Mark base cash explicit on any SetCash(symbol, ...) call
Broaden _baseCashSymbolSetExplicitly so any call to the explicit-currency
overload signals the user is committing to named currencies, not just
calls whose symbol matches the current account currency. SetAccountCurrency
then preserves the previous base-currency balance in its own CashBook
entry whenever the user has touched the explicit overload at all.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
---------
Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>1 parent 9d464c0 commit e81cdf5
3 files changed
Lines changed: 130 additions & 30 deletions
File tree
- Common
- Messages
- Securities
- Tests/Common/Securities
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
890 | 890 | | |
891 | 891 | | |
892 | 892 | | |
893 | | - | |
894 | | - | |
| 893 | + | |
| 894 | + | |
895 | 895 | | |
896 | | - | |
897 | | - | |
| 896 | + | |
| 897 | + | |
| 898 | + | |
| 899 | + | |
| 900 | + | |
| 901 | + | |
| 902 | + | |
| 903 | + | |
| 904 | + | |
| 905 | + | |
| 906 | + | |
| 907 | + | |
| 908 | + | |
| 909 | + | |
898 | 910 | | |
899 | 911 | | |
900 | 912 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
36 | 36 | | |
37 | 37 | | |
38 | 38 | | |
| 39 | + | |
39 | 40 | | |
40 | 41 | | |
41 | 42 | | |
| |||
616 | 617 | | |
617 | 618 | | |
618 | 619 | | |
619 | | - | |
| 620 | + | |
620 | 621 | | |
621 | | - | |
622 | | - | |
| 622 | + | |
| 623 | + | |
| 624 | + | |
| 625 | + | |
| 626 | + | |
| 627 | + | |
| 628 | + | |
623 | 629 | | |
624 | 630 | | |
625 | 631 | | |
| |||
645 | 651 | | |
646 | 652 | | |
647 | 653 | | |
648 | | - | |
649 | | - | |
650 | | - | |
651 | | - | |
652 | | - | |
653 | | - | |
654 | | - | |
655 | | - | |
| 654 | + | |
| 655 | + | |
| 656 | + | |
| 657 | + | |
| 658 | + | |
656 | 659 | | |
657 | 660 | | |
658 | 661 | | |
659 | 662 | | |
| 663 | + | |
660 | 664 | | |
661 | 665 | | |
| 666 | + | |
| 667 | + | |
| 668 | + | |
| 669 | + | |
| 670 | + | |
| 671 | + | |
| 672 | + | |
| 673 | + | |
| 674 | + | |
| 675 | + | |
662 | 676 | | |
663 | 677 | | |
664 | | - | |
| 678 | + | |
| 679 | + | |
| 680 | + | |
| 681 | + | |
| 682 | + | |
| 683 | + | |
665 | 684 | | |
| 685 | + | |
| 686 | + | |
666 | 687 | | |
667 | 688 | | |
668 | 689 | | |
| |||
672 | 693 | | |
673 | 694 | | |
674 | 695 | | |
| 696 | + | |
675 | 697 | | |
676 | 698 | | |
677 | 699 | | |
| |||
684 | 706 | | |
685 | 707 | | |
686 | 708 | | |
687 | | - | |
| 709 | + | |
688 | 710 | | |
689 | | - | |
| 711 | + | |
690 | 712 | | |
691 | 713 | | |
692 | 714 | | |
| |||
Lines changed: 78 additions & 12 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2576 | 2576 | | |
2577 | 2577 | | |
2578 | 2578 | | |
2579 | | - | |
2580 | | - | |
2581 | | - | |
| 2579 | + | |
| 2580 | + | |
2582 | 2581 | | |
2583 | 2582 | | |
2584 | | - | |
2585 | | - | |
2586 | | - | |
2587 | | - | |
2588 | | - | |
2589 | | - | |
2590 | | - | |
2591 | | - | |
2592 | | - | |
| 2583 | + | |
| 2584 | + | |
| 2585 | + | |
| 2586 | + | |
| 2587 | + | |
| 2588 | + | |
| 2589 | + | |
| 2590 | + | |
| 2591 | + | |
| 2592 | + | |
| 2593 | + | |
| 2594 | + | |
| 2595 | + | |
| 2596 | + | |
| 2597 | + | |
| 2598 | + | |
| 2599 | + | |
| 2600 | + | |
| 2601 | + | |
| 2602 | + | |
| 2603 | + | |
| 2604 | + | |
| 2605 | + | |
| 2606 | + | |
| 2607 | + | |
| 2608 | + | |
| 2609 | + | |
| 2610 | + | |
| 2611 | + | |
| 2612 | + | |
| 2613 | + | |
| 2614 | + | |
| 2615 | + | |
| 2616 | + | |
| 2617 | + | |
| 2618 | + | |
| 2619 | + | |
| 2620 | + | |
| 2621 | + | |
| 2622 | + | |
| 2623 | + | |
| 2624 | + | |
| 2625 | + | |
| 2626 | + | |
| 2627 | + | |
| 2628 | + | |
| 2629 | + | |
| 2630 | + | |
| 2631 | + | |
| 2632 | + | |
| 2633 | + | |
| 2634 | + | |
| 2635 | + | |
| 2636 | + | |
| 2637 | + | |
| 2638 | + | |
| 2639 | + | |
| 2640 | + | |
| 2641 | + | |
| 2642 | + | |
| 2643 | + | |
| 2644 | + | |
| 2645 | + | |
| 2646 | + | |
| 2647 | + | |
| 2648 | + | |
| 2649 | + | |
| 2650 | + | |
| 2651 | + | |
| 2652 | + | |
| 2653 | + | |
| 2654 | + | |
| 2655 | + | |
| 2656 | + | |
| 2657 | + | |
| 2658 | + | |
2593 | 2659 | | |
2594 | 2660 | | |
2595 | 2661 | | |
| |||
0 commit comments