@@ -55,6 +55,14 @@ def setUp(self):
55
55
"account_type" : "income" ,
56
56
}
57
57
)
58
+ self .account_in_no_data = self .account_model .create (
59
+ {
60
+ "company_id" : self .company .id ,
61
+ "code" : "700INNODATA" ,
62
+ "name" : "Income (no data)" ,
63
+ "account_type" : "income" ,
64
+ }
65
+ )
58
66
# create journal
59
67
self .journal = self .journal_model .create (
60
68
{
@@ -103,6 +111,7 @@ def setUp(self):
103
111
self .aep .parse_expr ("crdp[700I%]" )
104
112
self .aep .parse_expr ("bali[400%]" )
105
113
self .aep .parse_expr ("bale[700%]" )
114
+ self .aep .parse_expr ("balp[700I%]" )
106
115
self .aep .parse_expr ("fldp.quantity[700%]" )
107
116
self .aep .parse_expr ("balp[]" "[('account_id.code', '=', '400AR')]" )
108
117
self .aep .parse_expr (
@@ -306,6 +315,17 @@ def test_aep_by_account(self):
306
315
end = self ._eval_by_account_id ("bale[]" )
307
316
self .assertEqual (end , {self .account_ar .id : 900 , self .account_in .id : - 800 })
308
317
318
+ def test_aep_by_account_no_data (self ):
319
+ """Test that accounts with no data are not returned."""
320
+ self .aep .done_parsing ()
321
+ self ._do_queries (
322
+ datetime .date (self .curr_year , 3 , 1 ), datetime .date (self .curr_year , 3 , 31 )
323
+ )
324
+ variation = self ._eval ("balp[700I%]" )
325
+ self .assertEqual (variation , - 500 )
326
+ variation_by_account = self ._eval_by_account_id ("balp[700I%]" )
327
+ self .assertEqual (variation_by_account , {self .account_in .id : - 500 })
328
+
309
329
def test_aep_convenience_methods (self ):
310
330
initial = AEP .get_balances_initial (self .company , time .strftime ("%Y" ) + "-03-01" )
311
331
self .assertEqual (
@@ -358,10 +378,13 @@ def test_get_account_ids_for_expr(self):
358
378
self .assertEqual (account_ids , {self .account_in .id })
359
379
expr = "balp[700%]"
360
380
account_ids = self .aep .get_account_ids_for_expr (expr )
361
- self .assertEqual (account_ids , {self .account_in .id })
381
+ self .assertEqual (account_ids , {self .account_in .id , self . account_in_no_data . id })
362
382
expr = "bali[400%], bale[700%]" # subkpis combined expression
363
383
account_ids = self .aep .get_account_ids_for_expr (expr )
364
- self .assertEqual (account_ids , {self .account_in .id , self .account_ar .id })
384
+ self .assertEqual (
385
+ account_ids ,
386
+ {self .account_in .id , self .account_ar .id , self .account_in_no_data .id },
387
+ )
365
388
366
389
def test_get_aml_domain_for_expr (self ):
367
390
self .aep .done_parsing ()
0 commit comments