
    ojfp                    J   d dl mZ d dlZd dlmc mZ d dlm	Z	 d dl
mZ d dlmZ d dlmZ d dlmZ d dlmZ d dlmZ d d	lmZmZ d d
lmZ d dlmZ d dlmZ dZ d Z!dddd4dZ"dddd5d!Z#d" Z$d# Z%d$ Z&d% Z'd& Z(d' Z)d( Z*d) Z+d* Z,d+ Z-d, Z.d- Z/d. Z0d/ Z1d0 Z2d1 Z3d2 Z4d3 Z5dS )6    )annotationsNDecimalSimpleNamespace)wealth_cockpit)CashSnapshotConfirmRequest)WealthCockpitResponse)confirm_cash_snapshot)!set_performance_cashflow_coverage$set_performance_scope_classification)build_portfolio_performance)connect_memory)apply_migrations2026-08-01T12:00:00+00:00c                     t                      } t          |            |                     dt          f           |                     dt          f           |                     dt          f           |                     dt          f           | S )Nz_INSERT INTO platforms(platform_id,name,platform_type,created_at) VALUES('bank','Bank','bank',?)zeINSERT INTO platforms(platform_id,name,platform_type,created_at) VALUES('broker','Broker','broker',?)zINSERT INTO accounts(account_id,platform_id,account_name,account_type,currency,performance_included,is_active,created_at)
           VALUES('bank-a','bank','Household bank','cash','CHF',0,1,?)zINSERT INTO accounts(account_id,platform_id,account_name,account_type,currency,performance_included,is_active,created_at)
           VALUES('depot','broker','Investment account','brokerage','CHF',0,1,?))r   r   executeNOWconns    M/home/agent/.hermes/repos/FinanceManager/tests/unit/test_wealth_cockpit_v1.pybase_dbr      s    DTLLi	   	LLo	   	LL	J	  
 	LL	T	  
 K    
2026-03-01)groupattx_idstr
account_idkindamountr   
str | Noner   c               `    |                      d||||||||ddddd| t          |f           d S )Na~  INSERT INTO transactions(
             transaction_id,transaction_type,activity_kind,account_id,trade_date,booking_date,
             event_timestamp,net_amount_original,currency_original,fx_rate_to_chf,source_type,
             source_id,row_hash,is_confirmed,is_voided,quality_status,created_at,internal_transfer_group_id)
           VALUES(?,?,?,?,?,?,?,?,?,?,?,?,?,1,0,'ok',?,?)CHF1synthetic_importfixturezhash-r   r   )r   r   r   r    r!   r   r   s          r   add_activityr)   .   s`    LL	=
 
dJBFE3HZ\egvotgvgvx{  ~C  	D    r   r$   r%   currencyfxsnapshot_idvaluer+   r,   c               V    |                      d|ddd||||t          d| f
           d S )Na  INSERT INTO portfolio_valuation_snapshots(
             snapshot_id,scope_kind,scope_id,account_id,value_original,currency,base_currency,
             fx_rate_to_base,fx_direction,valuation_at,source,captured_at,snapshot_version,
             source_reference,quality_status,reason_codes_json)
           VALUES(?,?,?,?,?,?,'CHF',?,'original_to_base',?,'synthetic',?,1,?,'complete','[]')accountdepotzref-r(   )r   r-   r   r.   r+   r,   s         r   add_valuationr2   9   sW     	LL	a  ;  	
    r   c                    t                      } t          | ddddd           t          | dddd	d           t          | d
dd
dd           t          | ddddd           t          | ddddd           t          j        | ddgddt                    }t          j        | dgddt                    }g }||k    }|st          j        d|fd||f          dt          j                    v st          j	        |          rt          j
        |          ndt          j
        |          dz  }dd|iz  }t          t          j        |                    d x}}dddd g}||k    }|st          j        d|fd||f          d!t          j                    v st          j	        |          rt          j
        |          nd!t          j
        |          dz  }dd|iz  }t          t          j        |                    d x}}d S )"Nzbank-legbank-ainternal_transferz-1000zpair-1)r   z	depot-legr1   1000buyz-700z
2026-03-02r   sell300z
2026-03-03dividend50z
2026-03-04
2026-01-01
2026-12-31)account_ids	from_dateto_datedata_cutoff==z%(py0)s == %(py3)s	householdpy0py3assert %(py5)spy5r   external_deposit1000.00)r   r    
amount_chfinvestments)r   r)   cockpitscope_cashflowsr   
@pytest_ar_call_reprcompare@py_builtinslocals_should_repr_global_name	_safereprAssertionError_format_explanation)r   rF   rO   @py_assert2@py_assert1@py_format4@py_format6s          r   dtest_scope_boundary_keeps_household_transfer_neutral_but_counts_portfolio_deposit_and_ignores_tradesr^   W   s   99Dz8-@'QYZZZZ{G-@&PXYYYYugufFFFFvw,GGGGz7JNNNN'w'  I )I  K 9?999%7yQQ ;         ;                                              r   c            
     Z   t                      } t          | dddddt                     t          | dddd	dd
t                     t	          | ddd           t	          | ddd           t	          | ddd           t          | ddddd           t          | dddt                    }t          | dddt                    }||k    }|st          j        d|fd||f          dt          j
                    v st          j        |          rt          j        |          nddt          j
                    v st          j        |          rt          j        |          nddz  }dd|iz  }t          t          j        |                    d }|d          d!         }d}||k    }|slt          j        d|fd"||f          t          j        |          t          j        |          d#z  }d$d%|iz  }	t          t          j        |	                    d x}x}}|d          d&         }d'}||k    }|slt          j        d|fd"||f          t          j        |          t          j        |          d#z  }d$d%|iz  }	t          t          j        |	                    d x}x}}|d          d(         }d }||u}|slt          j        d)|fd*||f          t          j        |          t          j        |          d#z  }d$d%|iz  }	t          t          j        |	                    d x}x}}d S )+Nr1   Tcrypto_portfoliotestzsynthetic complete portfolior   includedclassification_rolesourcenoteclassified_atr=   r>   completesynthetic complete historyr   coverage_fromcoverage_tostatusre   rf   recorded_atopen10000boundaryr   11000close13000depositrL   r6   r8   twrr@   rA   methodrB   rC   z%(py0)s == %(py2)sfirstsecondrH   py2assert %(py4)spy4summarynet_external_cashflowsz%(py1)s == %(py4)spy1r   assert %(py6)spy6investment_result2000ttwror_cumulative)is not)z%(py1)s is not %(py4)s)r   r   r   r   r2   r)   r   rR   rS   rT   rU   rV   rW   rX   rY   )
r   rz   r{   r[   @py_format3@py_format5@py_assert0@py_assert3rZ   @py_format7s
             r   `test_canonical_performance_engine_adjusts_investment_result_for_net_deposit_and_is_deterministicr   t   s   99D(.+    &" )	 	 	 	 $g666$
L':::$w777y'+=v,WWWW'l5VY  E )l5VY  F F?5F55FF45??5??????????5?????5???????????????????????????????/0:F:0F::::::::::0F:::::0::::F:::::::::::::::::::::::::::/0<<0<<<<<<<<<<0<<<<<0<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<r   c            
     "   t                      } t          | dddddt                     t          | dddd	dd
t                     t	          | ddd           t          | dddt                    }|d         d         }d }||u }|slt          j        d|fd||f          t          j        |          t          j        |          dz  }dd|iz  }t          t          j
        |                    d x}x}}|d         d         }d }||u }|slt          j        d|fd||f          t          j        |          t          j        |          dz  }dd|iz  }t          t          j
        |                    d x}x}}d}|d         d         d         }||v }|slt          j        d|fd||f          t          j        |          t          j        |          dz  }dd|iz  }t          t          j
        |                    d x}x}}d S )Nr1   Tr`   ra   zsynthetic incomplete portfoliorb   r=   r>   rh   ri   rj   rs   rt   rv   rw   r   r   isz%(py1)s is %(py4)sr   r   r   r   missing_opening_valuationqualityttwrorreason_codesinz%(py1)s in %(py4)sr   r   r   r   r2   r   rR   rS   rW   rX   rY   )r   resultr   r   rZ   r   r   s          r   5test_missing_opening_value_never_creates_false_returnr      s   99D(.-    &" )	 	 	 	 $w777(l5VY  F )019T91T99999999991T9999919999T999999999999999999999999999)019T91T99999999991T9999919999T999999999999999999999999999&U&*;H*En*UU&*UUUUUUUUUUU&*UUUUUU&UUUU*UUUUUUUUUUUUUUUUUUUUUUUUUUUUUUr   c            
     z   t                      } t          | dddddt                     t          | dddd	dd
t                     t	          | ddddd           t	          | ddddd           t          | dddt                    }|d         d         }d}||k    }|slt          j        d|fd||f          t          j        |          t          j        |          dz  }dd|iz  }t          t          j
        |                    d x}x}}|d         d         }d}||k    }|slt          j        d|fd||f          t          j        |          t          j        |          dz  }dd|iz  }t          t          j
        |                    d x}x}}t                      }t          |ddddd t                     t          |dddd	dd
t                     t	          |d!dddd            t	          |d"dddd            t          |dddt                    }|d         d#         }d }||u }|slt          j        d$|fd%||f          t          j        |          t          j        |          dz  }dd|iz  }t          t          j
        |                    d x}x}}d&}|d'         d(         d)         }||v }|slt          j        d*|fd+||f          t          j        |          t          j        |          dz  }dd|iz  }t          t          j
        |                    d x}x}}d S ),Nr1   Tr`   ra   zsynthetic FX portfoliorb   r=   r>   rh   ri   rj   zeur-openrp   EURz0.9r*   z	eur-closerr   z1.0rv   rw   r   opening_valuez9000.0rC   r   r   r   r   closing_valuez11000.0zsynthetic missing FX portfoliozmissing-openzmissing-closer   r   r   
missing_fxr   r   r   r   r   r   )	r   r   r   r   rZ   r   r   missingunavailables	            r   Otest_fx_uses_stored_canonical_rate_at_each_stichtag_and_missing_fx_fails_closedr      sH   99D(.%    &" )	 	 	 	 $
L'EeTTTT$\7UuUUUU(l5VY  F )_-99-9999999999-99999-9999999999999999999999999999999)_-::-::::::::::-:::::-:::::::::::::::::::::::::::::::iiG(.-    &" )	 	 	 	 '><5UYZZZZ'?L'EVZ[[[[-<eY\  K y!"56>$>6$>>>>>>>>>>6$>>>>>6>>>>$>>>>>>>>>>>>>>>>>>>>>>>>>>>K;y1(;NKK<KKKKKKKKKKK<KKKKKK<KKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKr   c                v   t          dddd d          |                     t          dfd           |                     t          dd	            |                     t          d
d            |                     t          dd            |                     t          dd            t          j        t	                      t          j        ddd                    }|d         }d}t          |          }||k    }|st          j        d|fd||f          t          j	        |          dt          j                    v st          j        t                    rt          j	        t                    ndt          j	        |          t          j	        |          dz  }dd|iz  }t          t          j        |                    d x}x}x}}|d         }d}t          |          }||k    }|st          j        d|fd||f          t          j	        |          dt          j                    v st          j        t                    rt          j	        t                    ndt          j	        |          t          j	        |          dz  }dd|iz  }t          t          j        |                    d x}x}x}}d |d         D             }t          |          }	|d         }|	|k    }
|
st          j        d|
fd |	|f          d!t          j                    v st          j        t                    rt          j	        t                    nd!t          j	        |          t          j	        |	          t          j	        |          d"z  }dd|iz  }t          t          j        |                    d x}x}	x}
}d# |d         D             }|j        }d$} ||          }d}||k    }|st          j        d|fd%||f          t          j	        |          t          j	        |          t          j	        |          t          j	        |          t          j	        |          d&z  }d'd(|iz  }t          t          j        |                    d x}x}x}x}x}}d) |d         D             }t#          |          }	|	sd*d+t          j                    v st          j        t"                    rt          j	        t"                    nd+t          j	        |          t          j	        |	          d,z  }t          t          j        |                    d x}}	t%          d- |d.         D                       d/         }d0}	||	k    }|slt          j        d|fd1||	f          t          j	        |          t          j	        |	          d2z  }d3d4|iz  }t          t          j        |                    d x}x}}	d5 |d.         D             }t'          |          }	|	sd*d6t          j                    v st          j        t&                    rt          j	        t&                    nd6t          j	        |          t          j	        |	          d,z  }t          t          j        |                    d x}}	d S )7N
Raiffeisen100.00
2026-07-31Aktuell)platformrN   last_manual_reconciliationlast_imported_bookingrm   get_cash_summaryc                (    t          dg          S )Nr   cash_chf	positionsr   )r   cash_positions    r   <lambda>zjtest_current_distribution_counts_truewealth_once_keeps_unassigned_visible_and_reconciles.<locals>.<lambda>   s    /[cp}o~BBB r   get_equity_summaryc                (    t          dddd          S )N200.00Tr   r   valued_partial_chfcoverage_completeunvalued_positionsas_ofr   r   s    r   r   zjtest_current_distribution_counts_truewealth_once_keeps_unassigned_visible_and_reconciles.<locals>.<lambda>   s'    _TXmn  wC  D  D  D r   list_crypto_positionsc                &    t          dd          gS )N50.00r   market_value_chflast_price_updater   r   s    r   r   zjtest_current_distribution_counts_truewealth_once_keeps_unassigned_visible_and_reconciles.<locals>.<lambda>  s    owRmnnno r   _truewealthc                $    t          d          dfS )Nr:   r   r   r   s    r   r   zjtest_current_distribution_counts_truewealth_once_keeps_unassigned_visible_and_reconciles.<locals>.<lambda>  s    gennl=[ r   _unassigned_valuesc                .    t          d          ddddgfS )N25u   Bestätigter weiterer Wert25.00r   )label	value_chfr   r   r   s    r   r   zjtest_current_distribution_counts_truewealth_once_keeps_unassigned_visible_and_reconciles.<locals>.<lambda>
  s!    gdmm0L[bmy&z&z%{| r           r   totalz675.00rC   )z0%(py1)s == %(py7)s
{%(py7)s = %(py3)s(%(py5)s)
}r   )r   rI   rK   py7assert %(py9)spy9rO   z575.00c              3  @   K   | ]}t          |d                    V  dS )r   Nr   .0rows     r   	<genexpr>zktest_current_distribution_counts_truewealth_once_keeps_unassigned_visible_and_reconciles.<locals>.<genexpr>  s/      LLSws;'((LLLLLLr   distributionz0%(py4)s
{%(py4)s = %(py0)s(%(py2)s)
} == %(py7)ssumrH   r}   r   r   c                    g | ]
}|d          S )key r   s     r   
<listcomp>zltest_current_distribution_counts_truewealth_once_keeps_unassigned_visible_and_reconciles.<locals>.<listcomp>  s    :::3CJ:::r   
truewealth)zL%(py7)s
{%(py7)s = %(py3)s
{%(py3)s = %(py1)s.count
}(%(py5)s)
} == %(py10)s)r   rI   rK   r   py10zassert %(py12)spy12c              3  F   K   | ]}|d          dk    o|d         dk    V  dS )r   otherr   r   Nr   r   s     r   r   zktest_current_distribution_counts_truewealth_once_keeps_unassigned_visible_and_reconciles.<locals>.<genexpr>  s:      hhs5zW$D[)9W)Dhhhhhhr   ,assert %(py4)s
{%(py4)s = %(py0)s(%(py2)s)
}anyrH   r}   r   c              3  2   K   | ]}|d          dk    |V  dS r   cryptoNr   r   s     r   r   zktest_current_distribution_counts_truewealth_once_keeps_unassigned_visible_and_reconciles.<locals>.<genexpr>  s0      LLSZ85K5K5K5K5K5KLLr   sourcesfreshness_statusfreshr   r   r   r   c              3  B   K   | ]}|d          dv |d         dk    V  dS )r   >   postfinance-investmentsr   r   reconciliation_statusnot_assessableNr   r   s     r   r   zktest_current_distribution_counts_truewealth_once_keeps_unassigned_visible_and_reconciles.<locals>.<genexpr>  sJ        u:LLL 	#$(88LLLL r   all)r   setattrrP   _current_valuesr   dater   rR   rS   rW   rT   rU   rV   rX   rY   r   countr   nextr   )monkeypatchcurrentr   @py_assert4@py_assert6rZ   @py_format8@py_format10r[   r   @py_assert5@py_assert9@py_assert8@py_format11@py_format13r   r   r   s                    @r   Xtest_current_distribution_counts_truewealth_once_keeps_unassigned_visible_and_reconcilesr     s   ##/"  M !35555  A  A  A 	D  	D  
 oo  
 0[0[\\\||   %giiw|D!Q7O7OPPPG70x0wx0000000000000000000000000000000w00000w000000x0000000000000000000000000000000000=!6X6WX%6%66!%66666666666!%666666!66666666666W66666W666666X6666%666666666666666666666666666666LLGN4KLLL`3LLL`PWX_P``LP```````````LP`````````````3`````3``````L````L````P``````````````````````````````::'."9:::S:@SS@@NNSRSSNRSSSSSSSSSSSNRSSSSSS:SSSS@SSSSSSSSNSSSSRSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSShhPWXfPghhhh3hhhhhhhhhhhhhhhh3hhhhh3hhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhLLwy1LLLLLM_`kdkk`dkkkkkkkkkkk`dkkkkkk`kkkkdkkkkkkkkkkkkkkkkkkkkkkkkkkkk 9%   3         	    	     	      	   	        	           r   c                   t          d          t          d          t          d          dddddd	d
ddddddddddgg dddg d
ddddddg diddddgd|                     t          dfd            |                     t          d!d"            |                     t          d#d$            |                     t          d%fd&           |                     t          d'd(            |                     t          d)d*            |                     t          d+d,            |                     t          d-d.            t          j        t	                      d/d0t
          1          }t          j        t	                      d/d0t
          1          }||k    }|st          j        d2|fd3||f          d4t          j	                    v st          j
        |          rt          j        |          nd4d5t          j	                    v st          j
        |          rt          j        |          nd5d6z  }d7d8|iz  }t          t          j        |                    d }|d9         d:         }d;}||k    }|slt          j        d2|fd<||f          t          j        |          t          j        |          d=z  }d>d?|iz  }	t          t          j        |	                    d x}x}}|d@         }dAddBdCdD}||k    }|slt          j        d2|fd<||f          t          j        |          t          j        |          d=z  }d>d?|iz  }	t          t          j        |	                    d x}x}}|dE         dF         }dG}||k    }|slt          j        d2|fd<||f          t          j        |          t          j        |          d=z  }d>d?|iz  }	t          t          j        |	                    d x}x}}|dE         dH         }dI}||k    }|slt          j        d2|fd<||f          t          j        |          t          j        |          d=z  }d>d?|iz  }	t          t          j        |	                    d x}x}}|dE         dJ         }d}||k    }|slt          j        d2|fd<||f          t          j        |          t          j        |          d=z  }d>d?|iz  }	t          t          j        |	                    d x}x}}|dK         }t          |          }dL}
||
k    }|st          j        d2|fdM||
f          dNt          j	                    v st          j
        t                    rt          j        t                    ndNt          j        |          t          j        |          t          j        |
          dOz  }dPdQ|iz  }t          t          j        |                    d x}x}x}}
|dR         }t          |          }dS}
||
k    }|st          j        dT|fdU||
f          dNt          j	                    v st          j
        t                    rt          j        t                    ndNt          j        |          t          j        |          t          j        |
          dOz  }dPdQ|iz  }t          t          j        |                    d x}x}x}}
d S )VNr6   700r:   TcashBankguthaben300.00)r   r   r   equityzAktien und ETFs700.00r   True Wealth0.00r      Kryptowährungenr   r   )
r   rO   r  rh   r   r   
data_as_ofunpriced_countmissing_cash_countunassigned_itemsr<   100z0.05)r   r   r   r   rh   )rm   r   r   rL   )r   r    r!   )r   r   external_cashflowsr   c                    S Nr   )r   r   r   s     r   r   zYtest_cockpit_keeps_planning_separate_and_quality_dimensions_independent.<locals>.<lambda>7  s     r   _latest_data_cutoffc                    t           S r  )r   r   s    r   r   zYtest_cockpit_keeps_planning_separate_and_quality_dimensions_independent.<locals>.<lambda>8  s    S r   _latest_valuation_datec                    |S r  r   )r   fallbacks     r   r   zYtest_cockpit_keeps_planning_separate_and_quality_dimensions_independent.<locals>.<lambda>9  s    RZ r   r   c                     S r  r   )argskwargsperfs     r   r   zYtest_cockpit_keeps_planning_separate_and_quality_dimensions_independent.<locals>.<lambda>:  s    X\ r   rQ   c                     g S r  r   r  r  s     r   r   zYtest_cockpit_keeps_planning_separate_and_quality_dimensions_independent.<locals>.<lambda>;  s    B r   build_reconciliation_snapshotc                    dddigg dS )Nstalerm   
difference)data_quality_statusreconciliations	snapshotsr   )r   nows     r   r   zYtest_cockpit_keeps_planning_separate_and_quality_dimensions_independent.<locals>.<lambda>?  s    #*!)< 89
 
 r   _policy_comparisonc                    dd g d dS )NF)
configuredversionrowscontributionr   )r   r   s     r   r   zYtest_cockpit_keeps_planning_separate_and_quality_dimensions_independent.<locals>.<lambda>E  s"    \anr|~  QU  NV  NV r   get_annual_budget_assistantc                     ddddgiS )Nsummary_kpisfree_after_special500.00r   r   r   r!  s     r   r   zYtest_cockpit_keeps_planning_separate_and_quality_dimensions_independent.<locals>.<lambda>I  s    :N]e2f2f1g h r   ytd
2026-08-01)periodr   rB   rC   ry   rz   r{   r|   r~   r   totalscaptured_wealth_chfrM   r   r   r   r   planningr4  z/planning/budget/planningF)free_plannable_chf	availablelinkincluded_in_wealthdata_qualityr   r   r   r%  performance_statuskpis   r   lenr   r   r   hints   )<=)z0%(py4)s
{%(py4)s = %(py0)s(%(py2)s)
} <= %(py7)s)r   r   rP   build_wealth_cockpitr   r   rR   rS   rT   rU   rV   rW   rX   rY   rD  )r   rz   r{   r[   r   r   r   r   rZ   r   r   r   r   r   r   r  s                 @@r   Gtest_cockpit_keeps_planning_separate_and_quality_dimensions_independentrI    s   u~~^(KK'8xPP =vNN'9OO	
 " G& "&&+!'
 

 RHHI&2<NZ_``a D !24O4O4O4OPPP!68H8HIII!9;Z;Z[[[!>@\@\@\@\]]]!24N4NOOO'	
 	
   !5  8V  8V  W  W  W%hh   (5befffE)'))EcfgggFF?5F55FF?01>Y>1Y>>>>>>>>>>1Y>>>>>1>>>>Y>>>>>>>>>>>>>>>>>>>>>>>>>>> &+#	! !  !     
    !    
    
!              
             !34EE4EEEEEEEEEE4EEEEE4EEEEEEEEEEEEEEEEEEEEEEEEEEEEEEE !89I\I9\IIIIIIIIII9\IIIII9IIII\IIIIIIIIIIIIIIIIIIIIIIIIIII !56D*D6*DDDDDDDDDD6*DDDDD6DDDD*DDDDDDDDDDDDDDDDDDDDDDDDDDDV}"3}""""""""""""""""""""""""3"""""3""""""}"""""""""""""""""""""""""""""""""""""W~#3~#!#!##########!############3#####3######~########!###############################r   c                V   |                      t          dd            dt          d          ddddd	dd
dddddgd}t          j        t	                      |          }|d         }d}||k    }|slt          j        d|fd||f          t          j        |          t          j        |          dz  }dd|iz  }t          t          j	        |                    d x}x}}|d         }ddd}||k    }|slt          j        d|fd||f          t          j        |          t          j        |          dz  }dd|iz  }t          t          j	        |                    d x}x}}d |d         D             }t          |          }|sddt          j                    v st          j        t                    rt          j        t                    ndt          j        |          t          j        |          dz  }t          t          j	        |                    d x}}d S )Nactive_policyc           	     ,    ddddddddd	d
dddgddS )NTrF  r4  r  302040)asset_class
target_pct	lower_pct	upper_pctr
  706080)r-  monthly_contributionallocations)r,  policyr   r   s    r   r   zhtest_existing_versioned_policy_supports_contribution_orientation_without_schema_change.<locals>.<lambda>b  sF    (0$*$T`dee$,Dtbfgg  

 

 r   Tr6   r  r	  r5  r
  r  r   r  r   rh   r   r   r-  rF  rC   r   r   r   r   r/  r4  z6000.00)monthly_target_chfannual_target_chfc              3  .   K   | ]}|d          dk    V  dS )rm   within_rangeNr   r   s     r   r   zitest_existing_versioned_policy_supports_contribution_orientation_without_schema_change.<locals>.<genexpr>~  s+      II3s8}.IIIIIIr   r.  r   r   r   )r   rP   r   r*  r   rR   rS   rW   rX   rY   r   rT   rU   rV   )	r   r   rY  r   r   rZ   r   r   r[   s	            r   Vtest_existing_versioned_policy_supports_contribution_orientation_without_schema_changer_  ^  s   
	
 
	
    22844 v66622	
	 	G '		7;;F)!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!.! &&& & ! &        ! &     "   &                          JI&.IIII3IIIIIIIIIIIIIIII3IIIII3IIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIr   c                    t                      } t          j        }d}t          j        }d}d}d} ||||          } || ||          }t          j        ddd          t          j        ddd          f}	||	k    }
|
st	          j        d|
fd||	f          dt          j                    v st	          j        t                    rt	          j	        t                    ndt	          j	        |          d	t          j                    v st	          j        |           rt	          j	        |           nd	t	          j	        |          dt          j                    v st	          j        t                    rt	          j	        t                    ndt	          j	        |          t	          j	        |          t	          j	        |          t	          j	        |          t	          j	        |          t	          j	        |          t	          j	        |	          d
z  }dd|iz  }t          t	          j        |                    d x}x}x}x}x}x}x}x}x}
}	t          j        }d}t          j        }d}d}d} ||||          } || ||          }t          j        ddd          t          j        ddd          f}	||	k    }
|
st	          j        d|
fd||	f          dt          j                    v st	          j        t                    rt	          j	        t                    ndt	          j	        |          d	t          j                    v st	          j        |           rt	          j	        |           nd	t	          j	        |          dt          j                    v st	          j        t                    rt	          j	        t                    ndt	          j	        |          t	          j	        |          t	          j	        |          t	          j	        |          t	          j	        |          t	          j	        |          t	          j	        |	          d
z  }dd|iz  }t          t	          j        |                    d x}x}x}x}x}x}x}x}x}
}	t          j        }d}t          j        }d}d}d} ||||          } || ||          }t          j        ddd          t          j        ddd          f}	||	k    }
|
st	          j        d|
fd||	f          dt          j                    v st	          j        t                    rt	          j	        t                    ndt	          j	        |          d	t          j                    v st	          j        |           rt	          j	        |           nd	t	          j	        |          dt          j                    v st	          j        t                    rt	          j	        t                    ndt	          j	        |          t	          j	        |          t	          j	        |          t	          j	        |          t	          j	        |          t	          j	        |          t	          j	        |	          d
z  }dd|iz  }t          t	          j        |                    d x}x}x}x}x}x}x}x}x}
}	d S )Nr6  r   r   r   r8  r   rC   )z%(py18)s
{%(py18)s = %(py2)s
{%(py2)s = %(py0)s.period_bounds
}(%(py3)s, period=%(py5)s, as_of=%(py16)s
{%(py16)s = %(py8)s
{%(py8)s = %(py6)s.date
}(%(py10)s, %(py12)s, %(py14)s)
})
} == %(py21)srP   r   )rH   r}   rI   rK   r   py8r   r   py14py16py18py21zassert %(py23)spy23previous_yeari        12m)r   rP   period_boundsr   rR   rS   rT   rU   rV   rW   rX   rY   )r   r[   r   @py_assert7r   @py_assert11@py_assert13@py_assert15@py_assert17@py_assert20@py_assert19@py_format22@py_format24s                r   ?test_period_boundaries_cover_year_change_and_last_twelve_monthsrv    s
   99D  e 7<  a QR <<aQR;S;S   e;STTT T1a  T1a  Y T Y        T Y                     !         "&     "&      /4         <C     <C      <H    IM    OP    RS    <T    U   Y                                          o W\ RV XY [\ \\RVXY[\E]E]   oE]^^^ T1a  T2r""c ^ c        ^ c                     !         "&     "&      />         FM     FM      FR    SW    YZ    \]    F^    _   c                                          e 7<  a QR <<aQR;S;S   e;STTT T1a  T1a  Y T Y        T Y                     !         "&     "&      /4         <C     <C      <H    IM    OP    RS    <T    U   Y                                         r   c                 
   t                      } t          j        | t          j        ddd                    }t	          d |d         D                       }t	          d |d         D                       }|d	         }d }||u }|slt          j        d
|fd||f          t          j        |          t          j        |          dz  }dd|iz  }t          t          j	        |                    d x}x}}t	          d |d         D                       d	         }d }||u }|slt          j        d
|fd||f          t          j        |          t          j        |          dz  }dd|iz  }t          t          j	        |                    d x}x}}t	          d |d         D                       d	         }d }||u }|slt          j        d
|fd||f          t          j        |          t          j        |          dz  }dd|iz  }t          t          j	        |                    d x}x}}|d         }d }||u }|slt          j        d
|fd||f          t          j        |          t          j        |          dz  }dd|iz  }t          t          j	        |                    d x}x}}|d         }d}||k    }|slt          j        d|fd||f          t          j        |          t          j        |          dz  }dd|iz  }t          t          j	        |                    d x}x}}|d         }d}||k    }|slt          j        d|fd||f          t          j        |          t          j        |          dz  }dd|iz  }t          t          j	        |                    d x}x}}d |d         D             }	t          |	          }|sddt          j                    v st          j        t                    rt          j        t                    ndt          j        |	          t          j        |          dz  }t          t          j	        |                    d x}	}|d         }d}||k    }|slt          j        d|fd||f          t          j        |          t          j        |          dz  }dd|iz  }t          t          j	        |                    d x}x}}|d         }d}||u }|slt          j        d
|fd||f          t          j        |          t          j        |          dz  }dd|iz  }t          t          j	        |                    d x}x}}d S )Nr   r   r   r   c              3  2   K   | ]}|d          dk    |V  dS )r   r  Nr   r   s     r   r   zStest_cash_account_without_snapshot_or_import_is_missing_not_zero.<locals>.<genexpr>  s0      SSCc%jF>R>RC>R>R>R>RSSr   r   c              3  2   K   | ]}|d          dk    |V  dS )r    r  Nr   r   s     r   r   zStest_cash_account_without_snapshot_or_import_is_missing_not_zero.<locals>.<genexpr>  s0      ZZsCK><Y<Ys<Y<Y<Y<YZZr   r   r   r   r   r   r   r   c              3  2   K   | ]}|d          dk    |V  dS )r   r
  Nr   r   s     r   r   zStest_cash_account_without_snapshot_or_import_is_missing_not_zero.<locals>.<genexpr>  0      QQ#e*:P:P:P:P:P:PQQr   c              3  2   K   | ]}|d          dk    |V  dS r   r   r   s     r   r   zStest_cash_account_without_snapshot_or_import_is_missing_not_zero.<locals>.<genexpr>  r{  r   current_value_chfcurrent_value_status	not_readyrC   r   r   r   c              3  .   K   | ]}|d          dk    V  dS )r   zInvestment accountNr   )r   re   s     r   r   zStest_cash_account_without_snapshot_or_import_is_missing_not_zero.<locals>.<genexpr>  s,      XX6vg"66XXXXXXr   r   r   r   r  rh   F)r   rP   r   r   r   rR   rS   rW   rX   rY   r   rT   rU   rV   )
r   r   cash_rowbank_sourcer   r   rZ   r   r   r[   s
             r   @test_cash_account_without_snapshot_or_import_is_missing_not_zeror    s   99D%d',tQ2J2JKKKGSS7>#:SSSSSHZZgi&8ZZZZZKK (D( D(((((((((( D((((( ((((D(((((((((((((((((((((((((((QQw~6QQQQQ 	 	        	                               QQw~6QQQQQ 	 	        	                               *+3t3+t3333333333+t33333+3333t333333333333333333333333333-.=+=.+==========.+=====.====+===========================./C3CC/3CCCCCCCCCCC/3CCCCCC/CCCC3CCCCCCCCCCCCCCCCCCCCCCCCCCCCXXWYEWXXXX3XXXXXXXXXXXXXXXX3XXXXX3XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX'(-A-(A----------(A-----(----A---------------------------:'%'%''''''''''%'''''''''%'''''''''''''''''''''''''''''r   c                    t                      } dD ],\  }}t          | t          dd||dd| d                     -dt          d          d	d
dddddd ddddgd}t	          j        | t	          j        ddd          t	          j        ddd          |t	          j        ddd                    \  }}ddddd
dg}||k    }|st          j        d|fd||f          dt          j
                    v st          j        |          rt          j        |          ndt          j        |          dz  }dd|iz  }	t          t          j        |	                    d x}}d}
|
|v }|st          j        d |fd!|
|f          t          j        |
          d"t          j
                    v st          j        |          rt          j        |          nd"d#z  }dd|iz  }	t          t          j        |	                    d x}
}d S )$N))r=   r   )r7  120.00r4   manual_balance	syntheticzpreview-T)r   snapshot_typebalance_daterN   rf   
preview_idconfirm120r  r  r5  r
  r  r   r   rZ  r   r   r   r@   rA   r   r   r=   r   r   r   r7  rC   rE   pointsrG   rJ   rK      nicht ergänztr   z%(py1)s in %(py3)sreasonr   rI   )r   r   r	   r   rP   _household_historyr   rR   rS   rT   rU   rV   rW   rX   rY   )r   dayr.   r   r  r  rZ   r[   r\   r]   r   s              r   Rtest_household_history_uses_only_complete_exact_stichtags_and_supports_year_changer    s$   99DJ 
 

U&#.   +c++  	
 	
 	
 	
 22622 t44622	
	 	G /,tQ**T1a((l4A&&  NFF (33(33 6         6                                             %v%%%%%%%%%%v%%%%%%%%%%%%%%%%v%%%%%v%%%%%%%%%%%%%%%%%%%%%%%%%%%%%r   c                 h   t                      } |                     d           t          | dddddt                     t	          | dd	d
dd           t	          | ddddd           t          j        | t          j        ddd          t          j        ddd          dt          d          dd ddd ddd ddddgdt          j        ddd                    \  }}d	dddddg}||k    }|st          j
        d |fd!||f          d"t          j                    v st          j        |          rt          j        |          nd"t          j        |          d#z  }d$d%|iz  }t          t          j        |                    d x}}d&}||v }|st          j
        d'|fd(||f          t          j        |          d)t          j                    v st          j        |          rt          j        |          nd)d*z  }d$d%|iz  }t          t          j        |                    d x}}d S )+Nz9UPDATE accounts SET is_active=0 WHERE account_id='bank-a'r1   Tr`   ra   zsynthetic classified accountrb   zfx-openr=   r  r   2r*   zfx-closer7  r  r   r   r   F240r  r5  r
  r   r   z240.00rZ  r  r   r  rC   rE   r  rG   rJ   rK   r  r   r  r  r  )r   r   r   r   r2   rP   r  r   r   rR   rS   rT   rU   rV   rW   rX   rY   )r   r  r  rZ   r[   r\   r]   r   s           r   Ctest_household_history_uses_canonical_snapshot_value_and_fx_columnsr    s8   99DLLLMMM(.+    $	<3OOOO$
L%%CPPPP/,tQ**T1a((U^^T22 t44$488 x88		
 	
 l4A&&  NFF$ (33(33 6         6                                             %v%%%%%%%%%%v%%%%%%%%%%%%%%%%v%%%%%v%%%%%%%%%%%%%%%%%%%%%%%%%%%%%r   c           	        dd l }d }|                     |j         d|           t                      }|j        }t	          dd|          }|d         }t          |          }d}||k    }	|	st          j        d	|	fd
||f          dt          j	                    v st          j
        t
                    rt          j        t
                    ndt          j        |          t          j        |          t          j        |          dz  }
dd|
iz  }t          t          j        |                    d x}x}x}	}|d         }d}||u }|slt          j        d|fd||f          t          j        |          t          j        |          dz  }dd|iz  }t          t          j        |                    d x}x}}|d         d         }d}||u }|slt          j        d|fd||f          t          j        |          t          j        |          dz  }dd|iz  }t          t          j        |                    d x}x}}t          j        |          }|j        }|j        }|j        }	|	j        }h d}||v }|st          j        d|fd||f          dt          j	                    v st          j
        |          rt          j        |          ndt          j        |          t          j        |          t          j        |	          t          j        |          t          j        |          dz  }dd|iz  }t          t          j        |                    d x}x}x}	x}x}}|j        }||k    }|st          j        d	|fd ||f          d!t          j	                    v st          j
        |          rt          j        |          nd!t          j        |          d"t          j	                    v st          j
        |          rt          j        |          nd"d#z  }dd|iz  }t          t          j        |                    d x}}d S )$Nr   c                      t          d          )Nz:normal wealth rendering must not open a network connection)rX   r!  s     r   reject_provider_callz\test_normal_cockpit_get_is_read_only_and_uses_only_stored_data.<locals>.reject_provider_call  s    YZZZr   connectr6  r7  )r8  r   r   rB  rC  rC   r   rD  r   r   r   not_net_worthTr   r   r   r   r   r;  r?  F>   readypartialr  r   )z%(py8)s
{%(py8)s = %(py6)s
{%(py6)s = %(py4)s
{%(py4)s = %(py2)s
{%(py2)s = %(py0)s.readiness
}.dimensions
}.current_value
}.status
} in %(py11)s	validated)rH   r}   r   r   rb  py11zassert %(py13)spy13)z5%(py2)s
{%(py2)s = %(py0)s.total_changes
} == %(py4)sr   beforer   )socketr   r   total_changeswealth_cockpit_endpointrD  rR   rS   rT   rU   rV   rW   rX   rY   r
   model_validate	readiness
dimensionscurrent_valuerm   )r   r  r  r   r  payloadr[   r   r   r   r   r   r   rZ   r   r   r  rm  @py_assert10r   @py_format12@py_format14s                         r   >test_normal_cockpit_get_is_read_only_and_uses_only_stored_datar    s   MMM[ [ [ y2FGGG99DF%Lt  G v$3$1$1$$$$$$$$$$1$$$$$$$$$$$$3$$$$$3$$$$$$$$$$$$$$1$$$$$$$$$$$$$$$$$$$$$$$$$$$$$?#+t+#t++++++++++#t+++++#++++t+++++++++++++++++++++++++++:34==4==========4=====4===============================%4W==I ) )7 7>  C C C > C     	   > C     	    	     	      	    	 *   	 8   	 ?   	C              	                 
 '''''''''''''''''''''''4'''''4'''''''''''''''''''''''''''''''''''''''''''''''''''r   c                   t                      }i t          j        d d dfd
}|                     t          d|           t          j        |dd           ddd}|k    }|st          j        d	|fd
|f          dt          j                    v st          j	                  rt          j
                  ndt          j
        |          dz  }dd|iz  }t          t          j        |                    d x}}d S )Nr@   rA   c               N                         ||            | ||          S )Nr  )update)r   r@   rA   observedoriginals      r   capture_coveragezRtest_previous_year_coverage_uses_the_selected_period_end.<locals>.capture_coverage  s0    )W===x	7CCCCr   build_performance_coveragerh  
2026-08-02ra  z
2025-01-01z
2025-12-31rC   rE   r  rG   rJ   rK   )r   rP   r  r   rH  rR   rS   rT   rU   rV   rW   rX   rY   )	r   r   r  rZ   r[   r\   r]   r  r  s	          @@r   8test_previous_year_coverage_uses_the_selected_period_endr    sc   99D&(H1H,0$ D D D D D D D D !=?OPPP     &2lKKK8KKKKKKKKKKK8KKKKKKKKKKKKK8KKKKK8KKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKr   c                 
   ddddddddd d	d
dgd} dd dD             i}t          j        | |ddidddddddddid g d	  	        }|d         }|d         d         }d}||k    }|slt          j        d|fd||f          t          j        |          t          j        |          d z  }d!d"|iz  }t          t          j        |                    d x}x}}|d#         d         }d}||k    }|slt          j        d|fd||f          t          j        |          t          j        |          d z  }d!d"|iz  }t          t          j        |                    d x}x}}|d$         d         }d	}||k    }|slt          j        d|fd||f          t          j        |          t          j        |          d z  }d!d"|iz  }t          t          j        |                    d x}x}}|d%         d         }d}||k    }|slt          j        d|fd||f          t          j        |          t          j        |          d z  }d!d"|iz  }t          t          j        |                    d x}x}}|d         d&         d         }d'}||k    }|slt          j        d|fd||f          t          j        |          t          j        |          d z  }d!d"|iz  }t          t          j        |                    d x}x}}t          d( |d)         D                       d         }d}||k    }|slt          j        d|fd||f          t          j        |          t          j        |          d z  }d!d"|iz  }t          t          j        |                    d x}x}}t          d* |d)         D                       }	|	d         }d}||k    }|slt          j        d|fd||f          t          j        |          t          j        |          d z  }d!d"|iz  }t          t          j        |                    d x}x}}|	d+         }g d,}||k    }|slt          j        d|fd||f          t          j        |          t          j        |          d z  }d!d"|iz  }t          t          j        |                    d x}x}}|	d-         }g }||k    }|slt          j        d|fd||f          t          j        |          t          j        |          d z  }d!d"|iz  }t          t          j        |                    d x}x}}d S ).NFr   zKnown sourcer   r  r   )r   r}  r~  r   zMissing sourcer  r   )rh   r  r   r.  c           	          g | ]}|d d d d d dS )rh   )scopettwror_statusxirr_statusattribution_statusscope_classification_statuscashflow_coverage_statusr   )r   r  s     r   r   zWtest_current_value_performance_and_policy_readiness_are_independent.<locals>.<listcomp>6  sC     

 

 

  !+)&0/9,6 

 

 

r   )postfinancer   r   r,  r6  r=   r  presetfromto10.005.00)r   r   rm   rh   r%  )	r   coveragerY  r8  r   ttwror_qualityhousehold_changehistory_pointsr   r  r  r  rC   r   r   r   r   	freshnessreconciliationperformancerY  not_applicablec              3  2   K   | ]}|d          dk    |V  dS )r   r   Nr   r   s     r   r   zVtest_current_value_performance_and_policy_readiness_are_independent.<locals>.<genexpr>W  s0      NNs5zX7M7M7M7M7M7MNNr   metricsc              3  2   K   | ]}|d          dk    |V  dS )r   net_contributionsNr   r   s     r   r   zVtest_current_value_performance_and_policy_readiness_are_independent.<locals>.<genexpr>Z  s1      XXsc%jDW6W6Ws6W6W6W6WXXr   included_sources)PostFinancer  r  missing_sources)rP   _build_readinessrR   rS   rW   rX   rY   r   )
r   r  r  r  r   r   rZ   r   r   nets
             r   Ctest_current_value_performance_and_policy_readiness_are_independentr  "  s   " (%-(/$+	  *%)(3$1	 
 G& 	 

 

 A

 

 

H (e$\JJ&-!'
 
 !*-*  I <(Jo&x0=I=0I==========0I=====0====I===========================k"8,9	9,	9999999999,	99999,9999	999999999999999999999999999&'1@[@1[@@@@@@@@@@1[@@@@@1@@@@[@@@@@@@@@@@@@@@@@@@@@@@@@@@m$X.9'9.'9999999999.'99999.9999'999999999999999999999999999\"8,X6J:JJ6:JJJJJJJJJJJ6:JJJJJJ6JJJJ:JJJJJJJJJJJJJJJJJJJJJJJJJJJJNNy3NNNNN 	 	        	                               XXi	2XXX
X
XCx=#G#=G##########=G#####=####G###########################!"X&X&X&XX"&XXXXXXXXXXX"&XXXXXX"XXXX&XXXXXXXXXXXXXXXXXXXXXXXXXXXX !'R'!R''''''''''!R'''''!''''R'''''''''''''''''''''''''''''r   c                    t           j        } dddd} | |          }d}||k    }|st          j        d|fd||f          dt	          j                    v st          j        t                     rt          j        t                     ndt          j        |           t          j        |          t          j        |          t          j        |          dz  }d	d
|iz  }t          t          j	        |                    d x} x}x}x}}d S )Nrh   r   )r  r  r  r  rC   )z_%(py6)s
{%(py6)s = %(py2)s
{%(py2)s = %(py0)s._performance_scope_status
}(%(py4)s)
} == %(py9)srP   )rH   r}   r   r   r   zassert %(py11)sr  )
rP   _performance_scope_statusrR   rS   rT   rU   rV   rW   rX   rY   )r[   r   r   r  rm  r   r  s          r   Jtest_source_performance_status_is_partial_when_only_some_metrics_are_readyr  `  s   , '("/	
 	
,,	
   
  
          
               
       
 -    
	
   
    
                              r   c            	        ddddd dddddd ddddd	d
ddgi} ddddgddddgddd dgdgi}t          j        | |ddidddd          }d |D             }t          |          }t          |          }||k    }|sxt          j        d|fd||f          dt          j                    v st          j        t                    rt          j        t                    nddt          j                    v st          j        |          rt          j        |          ndt          j        |          dt          j                    v st          j        t                    rt          j        t                    ndd t          j                    v st          j        |          rt          j        |          nd t          j        |          d!z  }d"d#|iz  }t          t          j
        |                    d x}x}}d$ |D             }	t          |	          }
d%}|
|k    }|st          j        d|fd&|
|f          d't          j                    v st          j        t                    rt          j        t                    nd't          j        |	          t          j        |
          t          j        |          d(z  }d)d*|iz  }t          t          j
        |                    d x}	x}
x}}t          d+ |D                       }|d,         }dg}
||
k    }|slt          j        d|fd-||
f          t          j        |          t          j        |
          d.z  }d/d0|iz  }t          t          j
        |                    d x}x}}
d1 |D             }	t          |	          }
|
sd2d3t          j                    v st          j        t                    rt          j        t                    nd3t          j        |	          t          j        |
          d4z  }t          t          j
        |                    d x}	}
d S )5Nr   AKB HaushaltskontoAKBr  r   )r   provider_labelr    r}  r      AKB Rückstellungenr  Anlager  r$  r.  r  z
2026-05-01!external_cashflow_history_missing)r  valuation_fromr   r   z
2026-06-01r   r,  Fr6  r=   r  r  )r   r  rY  r8  c                V    h | ]&}|d          t          |d                   |d         f'S )	dimensionaffected_sourcesreason_code)tupler   s     r   	<setcomp>zVtest_diagnostics_name_sources_deduplicate_and_limit_prominent_hints.<locals>.<setcomp>  sG        
[	5%7!8993};MN  r   rC   )zN%(py3)s
{%(py3)s = %(py0)s(%(py1)s)
} == %(py8)s
{%(py8)s = %(py5)s(%(py6)s)
}rD  
identitiesdiagnostics)rH   r   rI   rK   r   rb  zassert %(py10)sr   c              3  &   K   | ]}|d          V  dS )	prominentNr   r   s     r   r   zVtest_diagnostics_name_sources_deduplicate_and_limit_prominent_hints.<locals>.<genexpr>  s'      77Cs;777777r   rF  r   r   r   r   r   c              3  2   K   | ]}|d          dk    |V  dS )r  current_bank_balance_missingNr   r   s     r   r   zVtest_diagnostics_name_sources_deduplicate_and_limit_prominent_hints.<locals>.<genexpr>  s2      ccc-.@Db.b.b.b.b.b.bccr   r  r   r   r   r   c              3  >   K   | ]}|d          p|d         dk    V  dS )r  r  rY  Nr   r   s     r   r   zVtest_diagnostics_name_sources_deduplicate_and_limit_prominent_hints.<locals>.<genexpr>  s7      ^^3s%&F#k*:h*F^^^^^^r   r   r   r   )rP   _build_diagnosticsrD  rR   rS   rT   rU   rV   rW   rX   rY   r   r   r   )r   r  r  r  rZ   rm  r   @py_format9r  r[   r   r   r   r   r   bankr   r   r   s                      r   Ctest_diagnostics_name_sources_deduplicate_and_limit_prominent_hintsr  j  s9   -"'&%)$1  /"'&%)$1  ,"4 %+$+ 
G4 	&".!D E  &".!D E  ""&!D E 
H& ,e$\JJ	  K   J z??.c+...?...........?.............3.....3.............z.....z......?...........c.....c.............+.....+..................................77;777<3777<1<71<<<<<<<<<<71<<<<<<<<<<<<3<<<<<3<<<<<<7<<<<7<<<<1<<<<<<<<<<<<<<<<<<<<<<<<<<<<<cc{cccccD"#.w.#w..........#w.....#....w...........................^^R]^^^^3^^^^^^^^^^^^^^^^3^^^^^3^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^r   c                  	 t          ddddd dd          t          ddddd dd          t          dd	d
dd dd          g	|                     t          d	fd           |                     t          dd            |                     t          dd            |                     t          dd            |                     t          dd            t          j        t	                      t          j        ddd                    }d |d         D             }d |D             }dd	g}||k    }|slt          j        d|fd||f          t          j        |          t          j        |          dz  }dd |iz  }t          t          j
        |                    d x}x}}|d!         d"         }d#}||k    }|slt          j        d|fd||f          t          j        |          t          j        |          dz  }dd |iz  }t          t          j
        |                    d x}x}}|d!         d$         }d%}||k    }|slt          j        d|fd||f          t          j        |          t          j        |          dz  }dd |iz  }t          t          j
        |                    d x}x}}d& |D             }t          |          }|sd'd(t          j                    v st          j        t                    rt          j        t                    nd(t          j        |          t          j        |          d)z  }t          t          j
        |                    d x}}d S )*Nr  r  r  r7  r   r(  )r   account_labelrN   r   r   rm   balance_modez2.00r  z3.00r   c                &    t          d          S )Nz15.00r   r   )r   r   s    r   r   zQtest_cash_sources_group_currencies_by_real_account_not_provider.<locals>.<lambda>  s    _gKKK r   r   c                (    t          dddd           S Nr  Tr   r   r   r   s    r   r   zQtest_cash_sources_group_currencies_by_real_account_not_provider.<locals>.<lambda>  !    _%" 	
 
 
 r   r   c                    g S r  r   r   s    r   r   zQtest_cash_sources_group_currencies_by_real_account_not_provider.<locals>.<lambda>  s    r r   r   c                    dS N)NNr   r   s    r   r   zQtest_cash_sources_group_currencies_by_real_account_not_provider.<locals>.<lambda>      \ r   r   c                $    t          d          g fS N0r   r   s    r   r   zQtest_cash_sources_group_currencies_by_real_account_not_provider.<locals>.<lambda>      WS\\SUDV r   r   r      r   c                *    g | ]}|d          dk    |S )r    r  r   r   s     r   r   zStest_cash_sources_group_currencies_by_real_account_not_provider.<locals>.<listcomp>  s&    WWWCV9V9VC9V9V9Vr   r   c                    g | ]
}|d          S )r   r   r   s     r   r   zStest_cash_sources_group_currencies_by_real_account_not_provider.<locals>.<listcomp>  s    111SCL111r   rC   r   r   r   r   r   r}  z12.00r~  r  c              3  .   K   | ]}|d          dk    V  dS )source_roler0   Nr   r   s     r   r   zRtest_cash_sources_group_currencies_by_real_account_not_provider.<locals>.<genexpr>  s,      GG3s=!Y.GGGGGGr   r   r   r   )r   r   rP   r   r   r   rR   rS   rW   rX   rY   r   rT   rU   rV   )
r   r   bank_sourcesr   r   rZ   r   r   r[   r   s
            @r   ?test_cash_sources_group_currencies_by_real_account_not_providerr    s   .'3"&$	
 	
 	
 	.'3"&$	
 	
 	
 	/'3"&$	
 	
 	
'I: KKKK  
 	
 	
	 	 	 !8//JJJ0I0IJJJ!57V7VWWW%giiw|D!Q7O7OPPPGWW79#5WWWL11L111 6 1 6        1 6     2   6                          ?./:7:/7::::::::::/7:::::/::::7:::::::::::::::::::::::::::?12=g=2g==========2g=====2====g===========================GG,GGGG3GGGGGGGGGGGGGGGG3GGGGG3GGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGr   c                   |                      t          dd            |                      t          dd            |                      t          dd            |                      t          dd            |                      t          d	d
            t          j        t                      t          j        ddd                    }t          d |d         D                       }|d         }d}||k    }|slt          j        d|fd||f          t          j        |          t          j        |          dz  }dd|iz  }t          t          j
        |                    d x}x}}|d         }d}||k    }|slt          j        d|fd||f          t          j        |          t          j        |          dz  }dd|iz  }t          t          j
        |                    d x}x}}|d         }d}||k    }|slt          j        d|fd||f          t          j        |          t          j        |          dz  }dd|iz  }t          t          j
        |                    d x}x}}|d         }d}||k    }|slt          j        d|fd||f          t          j        |          t          j        |          dz  }dd|iz  }t          t          j
        |                    d x}x}}d S )Nr   c                $    t          dg           S )Nr  r   r   r   s    r   r   zRtest_known_stale_crypto_value_remains_visible_with_business_date.<locals>.<lambda>  s    _fCCC r   r   c                (    t          dddd           S r  r   r   s    r   r   zRtest_known_stale_crypto_value_remains_visible_with_business_date.<locals>.<lambda>  r  r   r   c                &    t          dd          gS )Nr   2026-05-15T12:00:00+00:00r   r   r   s    r   r   zRtest_known_stale_crypto_value_remains_visible_with_business_date.<locals>.<lambda>  s!    !("=  
 r   r   c                    dS r  r   r   s    r   r   zRtest_known_stale_crypto_value_remains_visible_with_business_date.<locals>.<lambda>   r  r   r   c                $    t          d          g fS r  r   r   s    r   r   zRtest_known_stale_crypto_value_remains_visible_with_business_date.<locals>.<lambda>  r  r   r   r   r  r   c              3  2   K   | ]}|d          dk    |V  dS r   r   r   s     r   r   zStest_known_stale_crypto_value_remains_visible_with_business_date.<locals>.<genexpr>  s0      NN#s5zX7M7M#7M7M7M7MNNr   r   r}  r   rC   r   r   r   r   r~  r  r   r  r   r$  )r   rP   r   r   r   r   rR   rS   rW   rX   rY   )r   r   r   r   r   rZ   r   r   s           r   @test_known_stale_crypto_value_remains_visible_with_business_dater    s   CC  
 	
 	
	 	 	 	
 	
	 	 	 0I0IJJJ!57V7VWWW%giiw|D!Q7O7OPPPGNN!3NNNNNF%&1'1&'1111111111&'11111&1111'111111111111111111111111111()4W4)W4444444444)W44444)4444W444444444444444444444444444'?999?99999999999?999999?99999999999999999999999999999999$%00%0000000000%00000%000000000000000000000000000000000r   )r   r   r   r   r    r   r!   r   r   r"   r   r   )
r-   r   r   r   r.   r   r+   r   r,   r"   )6
__future__r   builtinsrT   _pytest.assertion.rewrite	assertionrewriterR   decimalr   typesr   #jarvis_finance.api.routers.overviewr   r  $jarvis_finance.api.schemas.positionsr	   )jarvis_finance.api.schemas.wealth_cockpitr
   jarvis_finance.servicesrP   $jarvis_finance.services.cash_servicer   )jarvis_finance.services.performance_scoper   r   -jarvis_finance.services.portfolio_performancer   jarvis_finance.storage.databaser   !jarvis_finance.storage.migrationsr   r   r   r)   r2   r^   r   r   r   r  rI  r_  rv  r  r  r  r  r  r  r  r  r  r  r   r   r   <module>r(     s   " " " " " "                     ! ! ! ! ! ! Y Y Y Y Y Y K K K K K K K K K K K K = = = = = = F F F F F F        V U U U U U : : : : : : > > > > > >!  0 dhs      "      <  :$= $= $=NV V V<7L 7L 7Lt& & &R?$ ?$ ?$D J  J  JF   ( ( ((&& && &&R$& $& $&N( ( (2L L L(;( ;( ;(|  <_ <_ <_~:H :H :Hz#1 #1 #1 #1 #1r   