@property
    @memoized
    def soh_data_total(self):
        if not self.case_ids:
            return {}
        previous_month_date = (timedelta(days=1) - self.start_date.replace(day=1))
        pm_last_business_day = get_business_day_of_month(previous_month_date.year, previous_month_date.month, -1)
        on_time_date = get_business_day_of_month(self.start_date.year, self.start_date.month, 6)
        cm_last_business_day = get_business_day_of_month(self.start_date.year, self.start_date.month, -1)
        query = """
        SELECT status, COUNT(case_id) FROM
            (
                SELECT DISTINCT ON (case_id) case_id,
                CASE WHEN sr.date::date < %s THEN 'on_time' ELSE 'late' END as status
                FROM stock_stocktransaction st JOIN stock_stockreport sr ON sr.id = st.report_id
                WHERE sr.domain = %s AND sr.date BETWEEN %s AND %s AND case_id IN %s
                AND st.type IN ('stockonhand', 'stockout')
                ORDER BY case_id, sr.date
            )x
        GROUP BY status;
        """
        with connection.cursor() as cursor:
            cursor.execute(query, [
                on_time_date, self.domain, pm_last_business_day,
                cm_last_business_day - timedelta(microseconds=1), self.case_ids
            ])
            rows = cursor.fetchall()
        return dict(rows)
dataset/ETHPy150Open dimagi/commcare-hq/custom/ilsgateway/tanzania/reports/configs/dashboard_config.py/DashboardConfig.soh_data_total/swapped operands of `-`