
    2njJ                        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
 Zd Zd ZddZddZddZddZdS )    )annotations)Path)confirm_create_budget_account)confirm_create_category)preview_drive_monthly_import) confirm_manual_recurring_payment)build_finance_command_centergenerate_monthly_report)connect_memory)apply_migrationsc                 @    t                      } t          |            | S )N)r   r   )conns    6tests/unit/test_finance_command_center_household_v1.pydbr      s     DTK    c                    t          | dddd          d         }t          | ddd          d         }t          | d	d
d          d         }t          | ddd          d         }||||fS )NHaushaltcashCHF)nameaccount_typecurrency	entity_idzEssen & Haushaltexpense)r   category_typezLohn MarcelincomezElektronische Medien)r   r   )r   accountfoodr   medias        r   setup_budgetr       s    +D:W]kp2q2qrrs~G"42DW`)a)abbcnoD$TMT\+]+]^^_jkF#D3I\e*f*fgghstED&%''r   c                j    |                      d||||||||f           |                                  d S )Na  INSERT INTO budget_transactions (
            budget_transaction_id, account_id, category_id, transaction_date, transaction_type,
            description, amount_original, currency_original, amount_chf, fx_status, status, source_type, created_at, updated_at
        ) VALUES
        ('tx_income', ?, ?, '2026-05-25', 'income', 'Lohn', '100.00', 'CHF', '100.00', 'not_needed', 'confirmed', 'manual', CURRENT_TIMESTAMP, CURRENT_TIMESTAMP),
        ('tx_expense', ?, ?, '2026-05-10', 'expense', 'Haushalt', '-30.00', 'CHF', '-30.00', 'not_needed', 'confirmed', 'manual', CURRENT_TIMESTAMP, CURRENT_TIMESTAMP),
        ('tx_candidate_should_not_count', ?, ?, '2026-05-11', 'expense', 'Candidate-like pending', '-999.00', 'CHF', '-999.00', 'not_needed', 'draft', 'manual', CURRENT_TIMESTAMP, CURRENT_TIMESTAMP),
        ('tx_transfer_should_not_count', ?, ?, '2026-05-12', 'transfer', 'Interner Transfer', '-500.00', 'CHF', '-500.00', 'not_needed', 'confirmed', 'manual', CURRENT_TIMESTAMP, CURRENT_TIMESTAMP)
        )executecommit)r   r   r   r   s       r   seed_confirmed_transactionsr$      sF    LL	 
&'4$F   	KKMMMMMr   returnNonec            
        t                      } t          |           \  }}}}t          | |||           t          | ddddgd||           t	          | d|dd	d
dd           t          | d          }|d         dk    sJ |d         d         dk    sJ |d         d         dk    sJ |d         d         dk    sJ |d         d         dk    sJ |d         d         dk    sJ |d         d         dk    sJ d|vsJ t          d |d         D                       sJ d|d          v sJ |d!         d"         dk    sJ d#|d$         v sJ t          d% |d&         D                       sJ d S )'NvisazVISA_Mai.csvzgTransactionId,CardId,Date,Amount,Currency,MerchantName,Details
T1,C1,2026-05-01,-10.00,CHF,Netflix,Abo
)idr   textF)dry_rundefault_category_idincome_category_idNetflixz10.00r   monthlysubscription)r   category_idexpected_amount_textr   	frequencyrecurring_type2026-05monthpurposefinance_command_center_v1kpisincome_month_chf100.00expense_month_chf30.00net_cashflow_month_chf70.00savings_rate_percentopen_review_candidates   open_review_amount_chfmonthly_closec              3  .   K   | ]}|d          dk    V  dS )sourceVISAN ).0items     r   	<genexpr>z]test_command_center_kpis_grouped_review_imports_todos_and_compact_sections.<locals>.<genexpr>=   s+      LLDtH~'LLLLLLr   import_statustop_overrunsbudget_status_compactfixed_costs_compactactive_subscriptionsasset_allocationportfolio_crypto_compactc              3  :   K   | ]}|d          dv o|d         V  dS )priority>   lowhighmediumlinkNrI   )rJ   todos     r   rL   z]test_command_center_kpis_grouped_review_imports_todos_and_compact_sections.<locals>.<genexpr>A   s7      jjRVtJ#<<Mfjjjjjjr   todos)r   r    r$   r   r   r	   any)r   r   r   r   r   centers         r   Jtest_command_center_kpis_grouped_review_imports_todos_and_compact_sectionsr^   ,   sB   44D#/#5#5 GT65gtV<<< v~  XC  )D  )D  (E  OT  jo  DJ  K  K  K  K$TIemt  CH  W`  tB  ,C  ,C  D  D  D)$i@@@F) ;;;;;&>,-9999&>-.'9999&>23w>>>>&>01W<<<<&>23q8888&>23w>>>>&((((LLF?4KLLLLLLLLV$;<<<<<'()?@AEEEE(B!CCCCCjjZ`ahZijjjjjjjjjjr   c                    t                      } t          |           \  }}}}t          | |||           t          | d          }|d         d         dk    sJ |d         d         dk    sJ |d         d         d	k    sJ d S )
Nr5   r6   r:   r;   r<   r=   r>   r?   r@   )r   r    r$   r	   )r   r   r   r   _mediar]   s         r   Stest_command_center_counts_only_confirmed_actuals_and_excludes_transfers_candidatesra   D   s    44D$0$6$6!GT66gtV<<<)$i@@@F&>,-9999&>-.'9999&>23w>>>>>>r   tmp_pathr   c                   t                      }t          |          \  }}}}t          ||||           t          j                    }| dz  }t          |d||          }t          |d                   }	|d         dk    sJ |	                                sJ ||	j        v sJ ||	j        vsJ |	                                }
d|
v sJ d|
v sJ d	|
v sJ d S )
Nruntime_reportsr5   r7   reports_dir	repo_rootpathformatmarkdownz# Monatsreport 2026-05
Disclaimeru   Preview → Confirm → Audit)	r   r    r$   r   cwdr
   existsparents	read_text)rb   r   r   r   r   r`   rg   runtime_reports_dirreportreport_pathr*   s              r   <test_monthly_report_is_runtime_only_markdown_and_not_in_repors   P   s   44D$0$6$6!GT66gtV<<<

I"%66$TH[gpqqqFvf~&&K(z))))+"55555K/////  ""D#t++++4*d222222r   c                   t                      }t          |          \  }}}}t          ||||           |                    d||f           |                                 t          |d          }|d         d         dk    sJ 	 t          |d| dz  t          j                    	           t          d
          # t          $ r}dt          |          v sJ Y d }~d S d }~ww xY w)Na  INSERT INTO budget_transactions (budget_transaction_id, account_id, category_id, transaction_date, transaction_type, description, amount_original, currency_original, amount_chf, fx_status, status, source_type, created_at, updated_at)
        VALUES ('tx_june_must_not_count', ?, ?, '2026-06-01', 'expense', 'June', '-70.00', 'CHF', '-70.00', 'not_needed', 'confirmed', 'manual', CURRENT_TIMESTAMP, CURRENT_TIMESTAMP)r5   r6   r:   r=   r>   z2026-05/../../evilrd   re   zinvalid month acceptedmonth_must_be_yyyy_mm)r   r    r$   r"   r#   r	   r
   r   rl   AssertionError
ValueErrorstr)rb   r   r   r   r   r`   r]   excs           r   Ltest_month_boundaries_use_exclusive_next_month_and_invalid_month_is_rejectedrz   d   s0   44D$0$6$6!GT66gtV<<<LL	z	$  
 	KKMMM)$i@@@F&>-.'99997,@hYjNjvzv~  wA  wA  	B  	B  	B  	B 5666  3 3 3&#c((22222222223s   'B= =
C%C  C%N)r%   r&   )rb   r   r%   r&   )
__future__r   pathlibr   'jarvis_finance.services.budget_accountsr   )jarvis_finance.services.budget_categoriesr   -jarvis_finance.services.budget_monthly_importr   (jarvis_finance.services.budget_recurringr   .jarvis_finance.services.finance_command_centerr	   r
   jarvis_finance.storage.databaser   !jarvis_finance.storage.migrationsr   r   r    r$   r^   ra   rs   rz   rI   r   r   <module>r      s8   " " " " " "       Q Q Q Q Q Q M M M M M M V V V V V V U U U U U U p p p p p p p p : : : : : : > > > > > >  ( ( (   k k k k0	? 	? 	? 	?3 3 3 3(7 7 7 7 7 7r   