
    pjd                        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
mZ d dlmZ d dlmZ d Zd	 ZddZddZddZdS )    )annotations)Path)confirm_create_budget_account)confirm_create_category)generate_report_v1list_reports_v1preview_report_v1)connect_memory)apply_migrationsc                 @    t                      } t          |            | S )N)r
   r   )conns    tests/unit/test_reports_v1.pydbr      s    D-d333D[    c                .   t          | dddd          d         }t          | dddd          d         }t          | d	d
d          d         }|                     d||||||||f           |                     d           |                                  d S )NHaushaltcashCHF)nameaccount_typecurrency	entity_idexpense100.00)r   category_typemonthly_budgetLohnincome)r   r   a  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
    ('income_ok', ?, ?, '2026-05-01', 'income', 'Lohn', '100.00', 'CHF', '100.00', 'not_needed', 'confirmed', 'manual', CURRENT_TIMESTAMP, CURRENT_TIMESTAMP),
    ('expense_ok', ?, ?, '2026-05-02', 'expense', 'Haushalt Laden', '-30.00', 'CHF', '-30.00', 'not_needed', 'confirmed', 'manual', CURRENT_TIMESTAMP, CURRENT_TIMESTAMP),
    ('candidate_no_count', ?, ?, '2026-05-03', 'expense', 'Pending', '-999.00', 'CHF', '-999.00', 'not_needed', 'draft', 'manual', CURRENT_TIMESTAMP, CURRENT_TIMESTAMP),
    ('transfer_no_count', ?, ?, '2026-05-04', 'transfer', 'Transfer', '-500.00', 'CHF', '-500.00', 'not_needed', 'confirmed', 'manual', CURRENT_TIMESTAMP, CURRENT_TIMESTAMP)
    a  INSERT INTO budget_transaction_candidates (transaction_candidate_id, source_type, source_file_label, transaction_date, description, amount_original, currency_original, status, classification, requires_review, created_at, updated_at)
    VALUES
    ('cand_review', 'visa_credit_card', 'visa.csv', '2026-05-05', 'Review', '-10.00', 'CHF', 'needs_review', 'expense_candidate', 1, CURRENT_TIMESTAMP, CURRENT_TIMESTAMP),
    ('cand_dup', 'migros_purchase', 'migros.csv', '2026-05-06', 'Dup', '-11.00', 'CHF', 'duplicate_candidate', 'expense_candidate', 1, CURRENT_TIMESTAMP, CURRENT_TIMESTAMP),
    ('cand_covered', 'migros_purchase', 'migros.csv', '2026-05-07', 'Covered', '-12.00', 'CHF', 'covered_by_source', 'expense_candidate', 0, CURRENT_TIMESTAMP, CURRENT_TIMESTAMP)
    )r   r   executecommit)r   accountexpense_cat
income_cats       r   seedr$      s    +D:W]kp2q2qrrs~G)$V_s{0|0|}}  J  KK(QY/Z/Z[[\ghJLL  :wWk7T_	`b b b 	LL  	 	 	 	KKMMMMMr   tmp_pathr   returnNonec           	        t                      }t          |           t          j                    }| dz  }g d}|D ]}t	          ||dd||          }t          |d                   }|d         du sJ |d	         d
         |k    sJ |                                sJ ||j        v sJ ||j        vsJ |j        dk    sJ d|                    d          v sJ t          |          }t          |          t          |          k    sJ |dz  }	|	                                sJ |	                    d                              d          t          |          k    sJ d S )Nruntime_reports)budget_monthlycashflow_householdbudget_review_statuscrypto_statusportfolio_status2026-05html)report_typeperiodformatreports_dir	repo_rootpathruntime_onlyTmetadatar1   z.htmlu   Datenqualitätzutf-8)encoding)r4   zreport_events.jsonlreport_generated)r   r$   r   cwdr   existsparentssuffix	read_textr   lencount)
r%   r   repor4   report_typeskindresultr6   listedaudits
             r   Btest_reports_v1_generate_all_types_runtime_only_metadata_and_auditrH   $   s   44Dd8::D..KxxxL 	D 	D#Dd9U[it  AE  F  F  FF6N##n%----j!-0D8888{{}}}dl****4<''''{g%%%%4>>7>#C#CCCCCC555Fv;;#l++++++//E<<>>>??G?,,223EFF#lJ[J[[[[[[[r   c                   t                      }t          |           t          |dd          }|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         sJ dt          |          vsJ dt          |          vsJ d S )Nr*   r/   r1   r2   totals
income_chfr   expense_chfz30.00net_cashflow_chfz70.00review
open_total   possible_duplicatescovered_by_sourcesectionstop_categoriesz999.00z500.00)r   r$   r	   str)r%   r   previews      r   Jtest_budget_monthly_report_counts_confirmed_only_and_candidates_separatelyrX   <   s   44Dd2B9UUUG8\*h66668]+w66668/0G;;;;8\*a////823q8888801Q6666:/00003w<<''''3w<<''''''r   c                 `   t                      } t          |            t          | dd          }t          | dd          }|d         d         sJ d|d         v sJ d	|d
         v sJ d|d
         v sJ |d         d         sJ |d         d         dk    sJ |d         d         dk    sJ d S )Nr+   2026rJ   r,   r/   rT   monthly_cashflowtransfers_separatesavings_rate_percentrK   fixed_cost_ratio_percentcandidates_by_sourcerO   rR   rQ   rS   )r   r$   r	   )r   cashflowrO   s      r   9test_cashflow_and_review_reports_expose_required_sectionsra   K   s    44Dd 3GPVWWWHt1GPYZZZFJ 233338J#77777!Xh%77777%();;;;;*45555(12a7777(/0A555555r   N)r%   r   r&   r'   )r&   r'   )
__future__r   pathlibr   'jarvis_finance.services.budget_accountsr   )jarvis_finance.services.budget_categoriesr   "jarvis_finance.services.reports_v1r   r   r	   jarvis_finance.storage.databaser
   !jarvis_finance.storage.migrationsr   r   r$   rH   rX   ra    r   r   <module>rj      s    " " " " " "       Q Q Q Q Q Q M M M M M M e e e e e e e e e e : : : : : : > > > > > >A A A  (\ \ \ \0( ( ( (6 6 6 6 6 6r   