Пример #1
0
    def test_reminders(self):
        products_reported, products_not_reported = report_status(self.facility.sql_location, days_until_late=1)
        self.assertEqual(len(products_reported), 0)
        self.assertEqual(len(products_not_reported), 0)

        assign_products_to_location(self.facility, [self.commodity])
        products_reported, products_not_reported = report_status(self.facility.sql_location, days_until_late=1)
        self.assertEqual(len(products_reported), 0)

        sql_commodity = SQLProduct.objects.get(product_id=self.commodity.get_id)
        self.assertEqual(products_not_reported[0], sql_commodity)

        sql_commodity2 = SQLProduct.objects.get(product_id=self.commodity2.get_id)

        create_stock_report(self.facility, {'ab': 10})
        products_reported, products_not_reported = report_status(self.facility.sql_location, days_until_late=1)
        self.assertEqual(products_reported[0], sql_commodity)
        self.assertEqual(len(products_not_reported), 0)

        assign_products_to_location(self.facility, [self.commodity, self.commodity2])
        products_reported, products_not_reported = report_status(self.facility.sql_location, days_until_late=1)
        self.assertEqual(products_reported[0], sql_commodity)
        self.assertEqual(products_not_reported[0], sql_commodity2)

        create_stock_report(self.facility, {'cd': 10})
        products_reported, products_not_reported = report_status(self.facility.sql_location, days_until_late=1)
        self.assertTrue(sql_commodity in products_reported)
        self.assertTrue(sql_commodity2 in products_reported)
        self.assertEqual(len(products_not_reported), 0)
Пример #2
0
    def test_reminders(self):
        products_reported, products_not_reported = report_status(self.facility.sql_location, days_until_late=1)
        self.assertEqual(len(products_reported), 0)
        self.assertEqual(len(products_not_reported), 0)

        assign_products_to_location(self.facility, [self.commodity])
        products_reported, products_not_reported = report_status(self.facility.sql_location, days_until_late=1)
        self.assertEqual(len(products_reported), 0)

        sql_commodity = SQLProduct.objects.get(product_id=self.commodity.get_id)
        self.assertEqual(products_not_reported[0], sql_commodity)

        sql_commodity2 = SQLProduct.objects.get(product_id=self.commodity2.get_id)

        create_stock_report(self.facility, {'ab': 10})
        products_reported, products_not_reported = report_status(self.facility.sql_location, days_until_late=1)
        self.assertEqual(products_reported[0], sql_commodity)
        self.assertEqual(len(products_not_reported), 0)

        assign_products_to_location(self.facility, [self.commodity, self.commodity2])
        products_reported, products_not_reported = report_status(self.facility.sql_location, days_until_late=1)
        self.assertEqual(products_reported[0], sql_commodity)
        self.assertEqual(products_not_reported[0], sql_commodity2)

        create_stock_report(self.facility, {'cd': 10})
        products_reported, products_not_reported = report_status(self.facility.sql_location, days_until_late=1)
        self.assertTrue(sql_commodity in products_reported)
        self.assertTrue(sql_commodity2 in products_reported)
        self.assertEqual(len(products_not_reported), 0)
Пример #3
0
    def get_message_for_location(self, location):
        supply_point = SupplyInterface(location.domain).get_by_location(location)
        if not supply_point:
            return None, {}

        on_time_products, missing_products = report_status(location.sql_location, days_until_late=DAYS_UNTIL_LATE)

        if not on_time_products:
            return THIRD_STOCK_ON_HAND_REMINDER, {'facility': location.name}
        elif missing_products:
            products_names = ', '.join([
                product.name
                for product in missing_products
            ])

            return INCOMPLETE_SOH_TO_SUPER, {'facility': location.name, 'products': products_names}

        return None, {}
Пример #4
0
    def get_message_for_location(self, location):
        supply_point = SupplyPointCase.get_by_location(location)
        if not supply_point:
            return

        on_time_products, missing_products = report_status(location.sql_location, days_until_late=DAYS_UNTIL_LATE)

        if not on_time_products:
            return SECOND_STOCK_ON_HAND_REMINDER, {}
        elif missing_products:
            products_names = ', '.join([
                product.name
                for product in missing_products
            ])

            return SECOND_INCOMPLETE_SOH_REMINDER, {'products': products_names}

        return None, {}