0dff0beaba
* test: tests for correct get_period_date_ranges * fix: stock analytics report date range issues - Upon selecting second half of month with Monthly filter, data from that period was missing. - Solution: "round down" the date as per expected frequency. * chore: drop py2 and fix misleading docstring * test: fix test to avoid FY clash * feat: add company filter in stock analytics report [skip ci] Co-authored-by: Marica <maricadsouza221197@gmail.com>
36 lines
1006 B
Python
36 lines
1006 B
Python
import datetime
|
|
import unittest
|
|
|
|
from frappe import _dict
|
|
from erpnext.accounts.utils import get_fiscal_year
|
|
|
|
from erpnext.stock.report.stock_analytics.stock_analytics import get_period_date_ranges
|
|
|
|
|
|
class TestStockAnalyticsReport(unittest.TestCase):
|
|
def test_get_period_date_ranges(self):
|
|
|
|
filters = _dict(range="Monthly", from_date="2020-12-28", to_date="2021-02-06")
|
|
|
|
ranges = get_period_date_ranges(filters)
|
|
|
|
expected_ranges = [
|
|
[datetime.date(2020, 12, 1), datetime.date(2020, 12, 31)],
|
|
[datetime.date(2021, 1, 1), datetime.date(2021, 1, 31)],
|
|
[datetime.date(2021, 2, 1), datetime.date(2021, 2, 6)],
|
|
]
|
|
|
|
self.assertEqual(ranges, expected_ranges)
|
|
|
|
def test_get_period_date_ranges_yearly(self):
|
|
|
|
filters = _dict(range="Yearly", from_date="2021-01-28", to_date="2021-02-06")
|
|
|
|
ranges = get_period_date_ranges(filters)
|
|
first_date = get_fiscal_year("2021-01-28")[1]
|
|
expected_ranges = [
|
|
[first_date, datetime.date(2021, 2, 6)],
|
|
]
|
|
|
|
self.assertEqual(ranges, expected_ranges)
|