@@ -48,6 +48,14 @@ def setUp(self):
48
48
"account_type" : "income" ,
49
49
}
50
50
)
51
+ self .account_in_no_data = self .account_model .create (
52
+ {
53
+ "company_id" : self .company .id ,
54
+ "code" : "700INNODATA" ,
55
+ "name" : "Income (no data)" ,
56
+ "account_type" : "income" ,
57
+ }
58
+ )
51
59
# create journal
52
60
self .journal = self .journal_model .create (
53
61
{
@@ -96,6 +104,7 @@ def setUp(self):
96
104
self .aep .parse_expr ("crdp[700I%]" )
97
105
self .aep .parse_expr ("bali[400%]" )
98
106
self .aep .parse_expr ("bale[700%]" )
107
+ self .aep .parse_expr ("balp[700I%]" )
99
108
self .aep .parse_expr ("fldp.quantity[700%]" )
100
109
self .aep .parse_expr ("balp[]" "[('account_id.code', '=', '400AR')]" )
101
110
self .aep .parse_expr (
@@ -299,6 +308,17 @@ def test_aep_by_account(self):
299
308
end = self ._eval_by_account_id ("bale[]" )
300
309
self .assertEqual (end , {self .account_ar .id : 900 , self .account_in .id : - 800 })
301
310
311
+ def test_aep_by_account_no_data (self ):
312
+ """Test that accounts with no data are not returned."""
313
+ self .aep .done_parsing ()
314
+ self ._do_queries (
315
+ datetime .date (self .curr_year , 3 , 1 ), datetime .date (self .curr_year , 3 , 31 )
316
+ )
317
+ variation = self ._eval ("balp[700I%]" )
318
+ self .assertEqual (variation , - 500 )
319
+ variation_by_account = self ._eval_by_account_id ("balp[700I%]" )
320
+ self .assertEqual (variation_by_account , {self .account_in .id : - 500 })
321
+
302
322
def test_aep_convenience_methods (self ):
303
323
initial = AEP .get_balances_initial (self .company , time .strftime ("%Y" ) + "-03-01" )
304
324
self .assertEqual (
@@ -351,10 +371,13 @@ def test_get_account_ids_for_expr(self):
351
371
self .assertEqual (account_ids , {self .account_in .id })
352
372
expr = "balp[700%]"
353
373
account_ids = self .aep .get_account_ids_for_expr (expr )
354
- self .assertEqual (account_ids , {self .account_in .id })
374
+ self .assertEqual (account_ids , {self .account_in .id , self . account_in_no_data . id })
355
375
expr = "bali[400%], bale[700%]" # subkpis combined expression
356
376
account_ids = self .aep .get_account_ids_for_expr (expr )
357
- self .assertEqual (account_ids , {self .account_in .id , self .account_ar .id })
377
+ self .assertEqual (
378
+ account_ids ,
379
+ {self .account_in .id , self .account_ar .id , self .account_in_no_data .id },
380
+ )
358
381
359
382
def test_get_aml_domain_for_expr (self ):
360
383
self .aep .done_parsing ()
0 commit comments