示例#1
0
 def consumption_entry(case_id, product_id, section_id):
     consumption_value = compute_consumption_or_default(
         case_id,
         product_id,
         datetime.utcnow(),
         section_id,
         self.stock_settings.consumption_config
     )
     if consumption_value is not None:
         return entry_xml(product_id, consumption_value)
示例#2
0
 def consumption_entry(case_id, product_id, section_id):
     consumption_value = compute_consumption_or_default(
         case_id,
         product_id,
         datetime.utcnow(),
         section_id,
         self.stock_settings.consumption_config
     )
     if consumption_value is not None:
         return entry_xml(product_id, consumption_value)
    def testDefaultValue(self):
        self._stock_report(25, 5)
        self._stock_report(10, 0)

        self.assertEqual(None, compute_consumption(self.case_id, self.product_id,
                                                   now, configuration=ConsumptionConfiguration(min_periods=4)))
        _ten = lambda case_id, product_id: 10
        self.assertAlmostEqual(10., compute_consumption_or_default(
            self.case_id,
            self.product_id,
            now,
            configuration=ConsumptionConfiguration(
                min_periods=4,
                default_monthly_consumption_function=_ten
            )
        ))
示例#4
0
    def testDefaultValue(self):
        self._stock_report(25, 5)
        self._stock_report(10, 0)

        self.assertEqual(None, compute_daily_consumption(
            self.domain.name, self.case_id, self.product_id,
            now, configuration=ConsumptionConfiguration(min_periods=4))
        )
        _ten = lambda case_id, product_id: 10
        self.assertAlmostEqual(10., compute_consumption_or_default(
            self.domain.name,
            self.case_id,
            self.product_id,
            now,
            configuration=ConsumptionConfiguration(
                min_periods=4,
                default_monthly_consumption_function=_ten
            )
        ))