def _stock_report(case_id, product_id, amount, days_ago): report = StockReport.objects.create(form_id=uuid.uuid4().hex, date=ago(days_ago), type=const.REPORT_TYPE_BALANCE) txn = StockTransaction( report=report, section_id=const.SECTION_TYPE_STOCK, type=const.TRANSACTION_TYPE_STOCKONHAND, case_id=case_id, product_id=product_id, stock_on_hand=Decimal(amount), ) txn._test_config = ConsumptionConfiguration.test_config() txn.quantity = 0 txn.save()