當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。