当前位置: 首页>>代码示例>>Python>>正文


Python LedgerAccessorSQL.delete_ledger_values方法代码示例

本文整理汇总了Python中corehq.form_processor.backends.sql.dbaccessors.LedgerAccessorSQL.delete_ledger_values方法的典型用法代码示例。如果您正苦于以下问题:Python LedgerAccessorSQL.delete_ledger_values方法的具体用法?Python LedgerAccessorSQL.delete_ledger_values怎么用?Python LedgerAccessorSQL.delete_ledger_values使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在corehq.form_processor.backends.sql.dbaccessors.LedgerAccessorSQL的用法示例。


在下文中一共展示了LedgerAccessorSQL.delete_ledger_values方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: hard_rebuild_ledgers

# 需要导入模块: from corehq.form_processor.backends.sql.dbaccessors import LedgerAccessorSQL [as 别名]
# 或者: from corehq.form_processor.backends.sql.dbaccessors.LedgerAccessorSQL import delete_ledger_values [as 别名]
 def hard_rebuild_ledgers(case_id, section_id=None, entry_id=None):
     transactions = LedgerAccessorSQL.get_ledger_transactions_for_case(case_id, section_id, entry_id)
     if not transactions:
         LedgerAccessorSQL.delete_ledger_values(case_id, section_id, entry_id)
         return
     ledger_value = LedgerAccessorSQL.get_ledger_value(case_id, section_id, entry_id)
     ledger_value = LedgerProcessorSQL._rebuild_ledger_value_from_transactions(ledger_value, transactions)
     LedgerAccessorSQL.save_ledger_values([ledger_value])
     publish_ledger_v2_saved(ledger_value)
开发者ID:dimagi,项目名称:commcare-hq,代码行数:11,代码来源:ledger.py

示例2: delete_all_ledgers

# 需要导入模块: from corehq.form_processor.backends.sql.dbaccessors import LedgerAccessorSQL [as 别名]
# 或者: from corehq.form_processor.backends.sql.dbaccessors.LedgerAccessorSQL import delete_ledger_values [as 别名]
 def delete_all_ledgers(domain):
     if should_use_sql_backend(domain):
         for case_id in CaseAccessorSQL.get_case_ids_in_domain(domain):
             transactions = LedgerAccessorSQL.get_ledger_transactions_for_case(case_id)
             form_ids = {tx.form_id for tx in transactions}
             for form_id in form_ids:
                 LedgerAccessorSQL.delete_ledger_transactions_for_form([case_id], form_id)
             LedgerAccessorSQL.delete_ledger_values(case_id)
     else:
         from casexml.apps.stock.models import StockReport
         from casexml.apps.stock.models import StockTransaction
         stock_report_ids = StockReport.objects.filter(domain=domain).values_list('id', flat=True)
         StockReport.objects.filter(domain=domain).delete()
         StockTransaction.objects.filter(report_id__in=stock_report_ids).delete()
开发者ID:saketkanth,项目名称:commcare-hq,代码行数:16,代码来源:utils.py

示例3: test_delete_ledger_values_case_section

# 需要导入模块: from corehq.form_processor.backends.sql.dbaccessors import LedgerAccessorSQL [as 别名]
# 或者: from corehq.form_processor.backends.sql.dbaccessors.LedgerAccessorSQL import delete_ledger_values [as 别名]
    def test_delete_ledger_values_case_section(self):
        from corehq.apps.commtrack.tests.util import get_single_balance_block
        form_id = self._submit_ledgers([
            get_single_balance_block(self.case_one.case_id, product_id, 10)
            for product_id in [self.product_a._id, self.product_b._id]
        ])
        ledger_values = LedgerAccessorSQL.get_ledger_values_for_case(self.case_one.case_id)
        self.assertEqual(2, len(ledger_values))

        LedgerAccessorSQL.delete_ledger_transactions_for_form([self.case_one.case_id], form_id)
        deleted = LedgerAccessorSQL.delete_ledger_values(self.case_one.case_id, 'stock')
        self.assertEqual(2, deleted)

        ledger_values = LedgerAccessorSQL.get_ledger_values_for_case(self.case_one.case_id)
        self.assertEqual(0, len(ledger_values))
开发者ID:dimagi,项目名称:commcare-hq,代码行数:17,代码来源:test_ledger_dbaccessor.py

示例4: test_delete_ledger_values_case_section_1

# 需要导入模块: from corehq.form_processor.backends.sql.dbaccessors import LedgerAccessorSQL [as 别名]
# 或者: from corehq.form_processor.backends.sql.dbaccessors.LedgerAccessorSQL import delete_ledger_values [as 别名]
    def test_delete_ledger_values_case_section_1(self):
        from corehq.apps.commtrack.tests import get_single_balance_block
        form_id = self._submit_ledgers([
            get_single_balance_block(self.case_one.case_id, self.product_a._id, 10, section_id=section_id)
            for section_id in ['stock', 'consumption']
        ])
        ledger_values = LedgerAccessorSQL.get_ledger_values_for_case(self.case_one.case_id)
        self.assertEqual(2, len(ledger_values))

        LedgerAccessorSQL.delete_ledger_transactions_for_form([self.case_one.case_id], form_id)
        deleted = LedgerAccessorSQL.delete_ledger_values(self.case_one.case_id, 'stock')
        self.assertEqual(1, deleted)

        ledger_values = LedgerAccessorSQL.get_ledger_values_for_case(self.case_one.case_id)
        self.assertEqual(1, len(ledger_values))
        self.assertEqual('consumption', ledger_values[0].section_id)
开发者ID:saketkanth,项目名称:commcare-hq,代码行数:18,代码来源:test_ledger_dbaccessor.py

示例5: test_delete_ledger_values_raise_error_case

# 需要导入模块: from corehq.form_processor.backends.sql.dbaccessors import LedgerAccessorSQL [as 别名]
# 或者: from corehq.form_processor.backends.sql.dbaccessors.LedgerAccessorSQL import delete_ledger_values [as 别名]
 def test_delete_ledger_values_raise_error_case(self):
     with self.assertRaisesRegexp(LedgerSaveError, '.*still has transactions.*'):
         LedgerAccessorSQL.delete_ledger_values(self.case.case_id)
开发者ID:dimagi,项目名称:commcare-hq,代码行数:5,代码来源:test_ledger_dbaccessor.py

示例6: test_delete_ledger_values_raise_error_case_section_entry

# 需要导入模块: from corehq.form_processor.backends.sql.dbaccessors import LedgerAccessorSQL [as 别名]
# 或者: from corehq.form_processor.backends.sql.dbaccessors.LedgerAccessorSQL import delete_ledger_values [as 别名]
 def test_delete_ledger_values_raise_error_case_section_entry(self):
     with self.assertRaisesRegexp(LedgerSaveError, '.*still has transactions.*'):
         LedgerAccessorSQL.delete_ledger_values(self.case.case_id, 'stock', self.product._id)
开发者ID:dimagi,项目名称:commcare-hq,代码行数:5,代码来源:test_ledger_dbaccessor.py


注:本文中的corehq.form_processor.backends.sql.dbaccessors.LedgerAccessorSQL.delete_ledger_values方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。