@@ -87,7 +87,10 @@ impl SuspenseAccountDetection {
8787 indicators : indicators. clone ( ) ,
8888 } ;
8989
90- if matches ! ( risk_level, SuspenseRiskLevel :: High | SuspenseRiskLevel :: Critical ) {
90+ if matches ! (
91+ risk_level,
92+ SuspenseRiskLevel :: High | SuspenseRiskLevel :: Critical
93+ ) {
9194 high_risk_accounts. push ( account_code. clone ( ) ) ;
9295 }
9396
@@ -105,10 +108,7 @@ impl SuspenseAccountDetection {
105108 0.0
106109 } else {
107110 ( high_risk_accounts. len ( ) as f64 / candidates. len ( ) . max ( 1 ) as f64 * 50.0
108- + candidates
109- . iter ( )
110- . map ( |c| c. suspense_score )
111- . sum :: < f64 > ( )
111+ + candidates. iter ( ) . map ( |c| c. suspense_score ) . sum :: < f64 > ( )
112112 / candidates. len ( ) . max ( 1 ) as f64 )
113113 . min ( 100.0 )
114114 } ;
@@ -127,16 +127,8 @@ impl SuspenseAccountDetection {
127127
128128 for entry in entries {
129129 // Extract debit and credit accounts
130- let debits: Vec < _ > = entry
131- . lines
132- . iter ( )
133- . filter ( |l| l. debit > 0.0 )
134- . collect ( ) ;
135- let credits: Vec < _ > = entry
136- . lines
137- . iter ( )
138- . filter ( |l| l. credit > 0.0 )
139- . collect ( ) ;
130+ let debits: Vec < _ > = entry. lines . iter ( ) . filter ( |l| l. debit > 0.0 ) . collect ( ) ;
131+ let credits: Vec < _ > = entry. lines . iter ( ) . filter ( |l| l. credit > 0.0 ) . collect ( ) ;
140132
141133 // Create edges between debit and credit accounts
142134 for debit_line in & debits {
@@ -217,10 +209,7 @@ impl SuspenseAccountDetection {
217209 }
218210
219211 /// Calculate suspense score from indicators.
220- fn calculate_suspense_score (
221- indicators : & [ SuspenseIndicator ] ,
222- metrics : & AccountMetrics ,
223- ) -> f64 {
212+ fn calculate_suspense_score ( indicators : & [ SuspenseIndicator ] , metrics : & AccountMetrics ) -> f64 {
224213 let mut score = 0.0 ;
225214
226215 for indicator in indicators {
@@ -403,10 +392,8 @@ impl GaapViolationDetection {
403392 } )
404393 . count ( ) ;
405394
406- let compliance_score = ( 100.0
407- - ( violations. len ( ) as f64 * 2.0 )
408- - ( major_violations as f64 * 10.0 ) )
409- . max ( 0.0 ) ;
395+ let compliance_score =
396+ ( 100.0 - ( violations. len ( ) as f64 * 2.0 ) - ( major_violations as f64 * 10.0 ) ) . max ( 0.0 ) ;
410397
411398 GaapViolationResult {
412399 violations,
@@ -445,8 +432,9 @@ impl GaapViolationDetection {
445432 credit. account_code, debit. account_code
446433 ) ,
447434 severity : GaapViolationSeverity :: Major ,
448- remediation : "Route through retained earnings or appropriate capital account"
449- . to_string ( ) ,
435+ remediation :
436+ "Route through retained earnings or appropriate capital account"
437+ . to_string ( ) ,
450438 } ) ;
451439 }
452440 }
@@ -499,12 +487,17 @@ impl GaapViolationDetection {
499487 }
500488
501489 /// Check for suspense account misuse.
502- fn check_suspense_misuse ( entry : & JournalEntry , config : & GaapDetectionConfig ) -> Option < GaapViolation > {
490+ fn check_suspense_misuse (
491+ entry : & JournalEntry ,
492+ config : & GaapDetectionConfig ,
493+ ) -> Option < GaapViolation > {
503494 let suspense_keywords = [ "suspense" , "clearing" , "holding" , "temporary" ] ;
504495
505496 for line in & entry. lines {
506497 let account_lower = line. account_code . to_lowercase ( ) ;
507- let is_suspense = suspense_keywords. iter ( ) . any ( |kw| account_lower. contains ( kw) ) ;
498+ let is_suspense = suspense_keywords
499+ . iter ( )
500+ . any ( |kw| account_lower. contains ( kw) ) ;
508501
509502 if is_suspense {
510503 let amount = line. debit . max ( line. credit ) ;
@@ -520,8 +513,9 @@ impl GaapViolationDetection {
520513 amount, line. account_code
521514 ) ,
522515 severity : GaapViolationSeverity :: Minor ,
523- remediation : "Clear suspense account to proper account within reporting period"
524- . to_string ( ) ,
516+ remediation :
517+ "Clear suspense account to proper account within reporting period"
518+ . to_string ( ) ,
525519 } ) ;
526520 }
527521 }
@@ -590,8 +584,9 @@ impl GaapViolationDetection {
590584 from, to
591585 ) ,
592586 severity : GaapViolationSeverity :: Critical ,
593- remediation : "Review entries for potential revenue inflation or wash transactions"
594- . to_string ( ) ,
587+ remediation :
588+ "Review entries for potential revenue inflation or wash transactions"
589+ . to_string ( ) ,
595590 } ) ;
596591 }
597592
@@ -722,8 +717,7 @@ impl AccountGraph {
722717
723718 // Calculate average holding period
724719 if metrics. first_activity > 0 && metrics. last_activity > metrics. first_activity {
725- let days =
726- ( metrics. last_activity - metrics. first_activity ) as f64 / 86400.0 ;
720+ let days = ( metrics. last_activity - metrics. first_activity ) as f64 / 86400.0 ;
727721 metrics. avg_holding_days = days / metrics. transaction_count . max ( 1 ) as f64 ;
728722 }
729723
@@ -839,7 +833,11 @@ mod tests {
839833 assert ! ( suspense_candidate. is_some( ) ) ;
840834
841835 let candidate = suspense_candidate. unwrap ( ) ;
842- assert ! ( candidate. indicators. contains( & SuspenseIndicator :: SuspenseNaming ) ) ;
836+ assert ! (
837+ candidate
838+ . indicators
839+ . contains( & SuspenseIndicator :: SuspenseNaming )
840+ ) ;
843841 }
844842
845843 #[ test]
@@ -855,7 +853,12 @@ mod tests {
855853
856854 #[ test]
857855 fn test_gaap_direct_revenue_expense ( ) {
858- let entries = vec ! [ create_test_entry( 1 , "SALARIES_EXPENSE" , "SALES_REVENUE" , 10000.0 ) ] ;
856+ let entries = vec ! [ create_test_entry(
857+ 1 ,
858+ "SALARIES_EXPENSE" ,
859+ "SALES_REVENUE" ,
860+ 10000.0 ,
861+ ) ] ;
859862
860863 let mut account_types = HashMap :: new ( ) ;
861864 account_types. insert ( "SALES_REVENUE" . to_string ( ) , AccountType :: Revenue ) ;
@@ -916,7 +919,12 @@ mod tests {
916919
917920 #[ test]
918921 fn test_gaap_improper_asset_expense ( ) {
919- let entries = vec ! [ create_test_entry( 1 , "OFFICE_EXPENSE" , "EQUIPMENT_ASSET" , 15000.0 ) ] ;
922+ let entries = vec ! [ create_test_entry(
923+ 1 ,
924+ "OFFICE_EXPENSE" ,
925+ "EQUIPMENT_ASSET" ,
926+ 15000.0 ,
927+ ) ] ;
920928
921929 let mut account_types = HashMap :: new ( ) ;
922930 account_types. insert ( "EQUIPMENT_ASSET" . to_string ( ) , AccountType :: Asset ) ;
0 commit comments