Skip to content

Commit

Permalink
Fix in crosstab when compute remainder is False
Browse files Browse the repository at this point in the history
  • Loading branch information
Ramez Ashraf committed May 28, 2023
1 parent a5cf80a commit 47d73ca
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
4 changes: 3 additions & 1 deletion slick_reporting/generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -827,7 +827,9 @@ def get_crosstab_parsed_columns(self):
"ref": magic_field_class,
"id": id,
"model": self.crosstab_model,
"is_remainder": counter == ids_length,
"is_remainder": counter == ids_length
if self.crosstab_compute_remainder
else False,
"source": "magic_field" if magic_field_class else "",
"is_summable": magic_field_class.is_summable,
}
Expand Down
10 changes: 10 additions & 0 deletions tests/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -302,6 +302,16 @@ def test_productclientsalesmatrix(self):
self.assertEqual(data[0]["__total__CT%s" % self.client2.pk], 600)
self.assertEqual(data[0]["__total__CT----"], 900)

def test_productclientsalesmatrix_no_remainder(self):
report = report_generators.ProductClientSalesMatrix(
crosstab_ids=[self.client1.pk, self.client2.pk],
crosstab_compute_remainder=False,
)
data = report.get_report_data()
self.assertEqual(data[0]["__total__CT%s" % self.client1.pk], 300)
self.assertEqual(data[0]["__total__CT%s" % self.client2.pk], 600)
# self.assertEqual(data[0]["__total__CT----"], 900)

def test_show_empty_records(self):
report = report_generators.ClientTotalBalance()
data = report.get_report_data()
Expand Down

0 comments on commit 47d73ca

Please sign in to comment.