• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python prototypes.InvoicePrototype类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中the_tale.finances.bank.prototypes.InvoicePrototype的典型用法代码示例。如果您正苦于以下问题:Python InvoicePrototype类的具体用法?Python InvoicePrototype怎么用?Python InvoicePrototype使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



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

示例1: initialize

    def initialize(self):
        self.initialized = True
        self.next_invoice_process_time = datetime.datetime.now()

        InvoicePrototype.reset_all()

        self.logger.info('BANK PROCESSOR INITIALIZED')
开发者ID:,项目名称:,代码行数:7,代码来源:


示例2: handle

    def handle(self, *args, **options):

        actions = set(AccountPrototype._db_exclude(action_id=None).values_list('action_id', flat=True).order_by('action_id').distinct())

        for action_id in actions:
            print()
            print('----%s----' % action_id)
            registered_ids = set(AccountPrototype._db_filter(action_id=action_id, is_fast=False).values_list('id', flat=True))

            print('registrations: %d' % len(registered_ids))

            payers_ids = set(InvoicePrototype._db_filter(models.Q(state=INVOICE_STATE.CONFIRMED)|models.Q(state=INVOICE_STATE.FORCED),
                                                        sender_type=ENTITY_TYPE.XSOLLA,
                                                        currency=CURRENCY_TYPE.PREMIUM).values_list('recipient_id', flat=True))

            payers_ids &= registered_ids

            print('payers: %d' % len(payers_ids))

            amounts = InvoicePrototype._db_filter(models.Q(state=INVOICE_STATE.CONFIRMED)|models.Q(state=INVOICE_STATE.FORCED),
                                                  sender_type=ENTITY_TYPE.XSOLLA,
                                                  recipient_id__in=payers_ids,
                                                  currency=CURRENCY_TYPE.PREMIUM).values_list('amount', flat=True)

            amount = sum(amounts)

            print('total gold: %d' % amount)

            if registered_ids:
                print('per account: %.2f' % (float(amount) / len(registered_ids)))

            if payers_ids:
                print('per payer: %.2f' % (float(amount) / len(payers_ids)))
开发者ID:,项目名称:,代码行数:33,代码来源:


示例3: test_process__processed

    def test_process__processed(self):
        self.assertEqual(BankInvoicePrototype._db_count(), 0)

        invoice = self.create_invoice(worker_call_count=1)

        self.assertEqual(invoice.bank_invoice_id, None)

        invoice.process()

        invoice.reload()

        self.assertEqual(BankInvoicePrototype._db_count(), 1)

        self.assertTrue(invoice.state.is_PROCESSED)

        bank_invoice = BankInvoicePrototype._db_get_object(0)

        self.assertEqual(bank_invoice.id, invoice.bank_invoice_id)
        self.assertTrue(bank_invoice.recipient_type.is_GAME_ACCOUNT)
        self.assertEqual(bank_invoice.recipient_id, self.fabric.account_id)
        self.assertTrue(bank_invoice.sender_type.is_XSOLLA)
        self.assertEqual(bank_invoice.sender_id, 0)
        self.assertTrue(bank_invoice.state.is_FORCED)
        self.assertTrue(bank_invoice.currency.is_PREMIUM)
        self.assertTrue(bank_invoice.amount, int(self.fabric.payment_sum))
        self.assertEqual(bank_invoice.operation_uid, 'bank-xsolla')
开发者ID:,项目名称:,代码行数:26,代码来源:


示例4: test_get_unprocessed_invoice_success

    def test_get_unprocessed_invoice_success(self):
        for state in INVOICE_STATE.records:
            if not (state.is_REQUESTED or state.is_FORCED):
                continue

            invoice = self.create_invoice(state=state)
            self.assertEqual(InvoicePrototype.get_unprocessed_invoice().id, invoice.id)
            InvoicePrototype._db_all().delete()
开发者ID:lshestov,项目名称:the-tale,代码行数:8,代码来源:test_prototypes.py


示例5: test_check_frozen_expired_invoices__wrong_state

    def test_check_frozen_expired_invoices__wrong_state(self):
        for state in INVOICE_STATE.records:
            if state.is_FROZEN:
                continue

            self.create_invoice(state=state)
            self.assertFalse(InvoicePrototype.check_frozen_expired_invoices())
            InvoicePrototype._db_all().delete()
开发者ID:lshestov,项目名称:the-tale,代码行数:8,代码来源:test_prototypes.py


示例6: test_process__test

    def test_process__test(self):
        self.assertEqual(BankInvoicePrototype._db_count(), 0)

        invoice = self.create_invoice(worker_call_count=1, test='1')
        invoice.process()

        invoice.reload()

        self.assertEqual(BankInvoicePrototype._db_count(), 0)

        self.assertTrue(invoice.state.is_SKIPPED_BECOUSE_TEST)
开发者ID:,项目名称:,代码行数:11,代码来源:


示例7: test_reset_all

    def test_reset_all(self):
        for state in INVOICE_STATE.records:
            invoice = self.create_invoice()
            invoice.state = state
            invoice.save()

        InvoicePrototype.reset_all()

        self.assertEqual(InvoicePrototype._model_class.objects.filter(state=INVOICE_STATE.RESETED).count(), len(INVOICE_STATE.records) - 4)
        self.assertEqual(InvoicePrototype._model_class.objects.filter(state=INVOICE_STATE.CONFIRMED).count(), 1)
        self.assertEqual(InvoicePrototype._model_class.objects.filter(state=INVOICE_STATE.CANCELED).count(), 1)
        self.assertEqual(InvoicePrototype._model_class.objects.filter(state=INVOICE_STATE.REJECTED).count(), 1)
        self.assertEqual(InvoicePrototype._model_class.objects.filter(state=INVOICE_STATE.FORCED).count(), 1)
开发者ID:,项目名称:,代码行数:13,代码来源:


示例8: setUp

    def setUp(self):
        super(_BaseBuyPosponedTaskTests, self).setUp()

        create_test_map()

        self.initial_amount = 500
        self.amount = 130

        result, account_id, bundle_id = register_user('test_user', '[email protected]', '111111')
        self.account = AccountPrototype.get_by_id(account_id)

        self.bank_account = BankAccountPrototype.create(entity_type=ENTITY_TYPE.GAME_ACCOUNT,
                                                        entity_id=self.account.id,
                                                        currency=CURRENCY_TYPE.PREMIUM)
        self.bank_account.amount = self.initial_amount
        self.bank_account.save()

        self.invoice = InvoicePrototype.create(recipient_type=ENTITY_TYPE.GAME_ACCOUNT,
                                               recipient_id=self.account.id,
                                               sender_type=ENTITY_TYPE.GAME_LOGIC,
                                               sender_id=0,
                                               currency=CURRENCY_TYPE.PREMIUM,
                                               amount=-self.amount,
                                               description_for_sender='transaction-description-for-sender',
                                               description_for_recipient='transaction-description-for-recipient',
                                               operation_uid='transaction-operation-ui')

        self.transaction = Transaction(self.invoice.id)

        self.task = None
        self.storage = None
        self.cmd_update_with_account_data__call_count = 1
        self.accounts_manages_worker = True
        self.supervisor_worker = False
开发者ID:Alkalit,项目名称:the-tale,代码行数:34,代码来源:base_buy_task.py


示例9: setUp

    def setUp(self):
        super(_BaseBuyPosponedTaskTests, self).setUp()

        create_test_map()

        self.initial_amount = 500
        self.amount = 130

        self.account = self.accounts_factory.create_account()

        self.bank_account = BankAccountPrototype.create(
            entity_type=ENTITY_TYPE.GAME_ACCOUNT, entity_id=self.account.id, currency=CURRENCY_TYPE.PREMIUM
        )
        self.bank_account.amount = self.initial_amount
        self.bank_account.save()

        self.invoice = InvoicePrototype.create(
            recipient_type=ENTITY_TYPE.GAME_ACCOUNT,
            recipient_id=self.account.id,
            sender_type=ENTITY_TYPE.GAME_LOGIC,
            sender_id=0,
            currency=CURRENCY_TYPE.PREMIUM,
            amount=-self.amount,
            description_for_sender="transaction-description-for-sender",
            description_for_recipient="transaction-description-for-recipient",
            operation_uid="transaction-operation-ui",
        )

        self.transaction = Transaction(self.invoice.id)

        self.task = None
        self.storage = None
        self.cmd_update_with_account_data__call_count = 1
        self.accounts_manages_worker = True
        self.supervisor_worker = False
开发者ID:Tiendil,项目名称:the-tale,代码行数:35,代码来源:base_buy_task.py


示例10: test_buy

    def test_buy(self):
        self.assertEqual(PostponedTaskPrototype._model_class.objects.all().count(), 0)
        self.assertEqual(InvoicePrototype._model_class.objects.all().count(), 0)

        with mock.patch('the_tale.common.postponed_tasks.prototypes.PostponedTaskPrototype.cmd_wait') as cmd_wait:
            self.purchase.buy(account=self.account)

        self.assertEqual(cmd_wait.call_count, 1)

        self.assertEqual(PostponedTaskPrototype._model_class.objects.all().count(), 1)
        self.assertEqual(InvoicePrototype._model_class.objects.all().count(), 1)

        postponed_logic = PostponedTaskPrototype._db_get_object(0).internal_logic

        self.assertTrue(isinstance(postponed_logic, BuyPremium))
        self.assertEqual(postponed_logic.account_id, self.account.id)
        self.assertEqual(postponed_logic.days, self.days)

        invoice = InvoicePrototype.get_by_id(postponed_logic.transaction.invoice_id)

        self.assertEqual(invoice.recipient_type, ENTITY_TYPE.GAME_ACCOUNT)
        self.assertEqual(invoice.recipient_id, self.account.id)
        self.assertEqual(invoice.sender_type, ENTITY_TYPE.GAME_LOGIC)
        self.assertEqual(invoice.sender_id, 0)
        self.assertEqual(invoice.currency, CURRENCY_TYPE.PREMIUM)
        self.assertEqual(invoice.amount, -self.cost)
        self.assertEqual(invoice.description_for_sender, 'premium-days-transaction-description')
        self.assertEqual(invoice.description_for_recipient, 'premium-days-transaction-description')
开发者ID:,项目名称:,代码行数:28,代码来源:


示例11: test_history

    def test_history(self):
        self.create_bank_account(self.account.id)
        history = self.create_entity_history(self.account.id)
        invoices = BankInvoicePrototype._db_all()

        histroy_ids = [invoice.id for invoice in history]

        texts = [('pgf-no-history-message', 0)]

        for invoice in invoices:
            if invoice.id in histroy_ids:
                continue

            if invoice.recipient_id == self.account.id:
                texts.append((invoice.description_for_recipient, 0))
            else:
                texts.append((invoice.description_for_sender, 0))

        for invoice in history:
            if invoice.recipient_id == self.account.id:
                texts.append((invoice.description_for_recipient, 1))
                texts.append((invoice.description_for_sender, 0))
            else:
                texts.append((invoice.description_for_recipient, 0))
                texts.append((invoice.description_for_sender, 1))

        self.check_html_ok(self.request_html(self.page_url), texts=texts)
开发者ID:Alkalit,项目名称:the-tale,代码行数:27,代码来源:test_requests.py


示例12: test_get_unprocessed_invoice__no_invoice

    def test_get_unprocessed_invoice__no_invoice(self):
        for state in INVOICE_STATE.records:
            if state.is_REQUESTED or state.is_FORCED:
                continue
            self.create_invoice(state=state)

        self.assertEqual(InvoicePrototype.get_unprocessed_invoice(), None)
开发者ID:lshestov,项目名称:the-tale,代码行数:7,代码来源:test_prototypes.py


示例13: get_value

    def get_value(self, date):
        query = AccountPrototype._db_filter(is_fast=False, is_bot=False)

        # do not use accounts registered before payments turn on
        query = query.filter(self.db_date_interval('created_at', date=date, days=-self.PERIOD),
                             self.db_date_gte('created_at', date=statistics_settings.PAYMENTS_START_DATE.date()))
        accounts = dict(query.values_list('id', 'created_at'))

        invoices = list(InvoicePrototype._db_filter(ACCEPTED_INVOICE_FILTER,
                                                    sender_type=ENTITY_TYPE.XSOLLA,
                                                    currency=CURRENCY_TYPE.PREMIUM,
                                                    recipient_id__in=list(accounts.keys())).values_list('created_at', 'recipient_id'))

        account_ids = [id_ for created_at, id_ in invoices]

        if not account_ids:
            return 0

        delays = {account_id: min([(created_at - accounts[account_id])
                                   for created_at, id_ in invoices
                                   if id_==account_id])
                  for account_id in account_ids}

        total_time = reduce(lambda s, v: s+v, list(delays.values()), datetime.timedelta(seconds=0))

        days = float(total_time.total_seconds()) / len(account_ids) / (24*60*60)

        return days
开发者ID:,项目名称:,代码行数:28,代码来源:


示例14: create_invoice

    def create_invoice(self,
                       recipient_type=ENTITY_TYPE.GAME_ACCOUNT,
                       recipient_id=3,
                       sender_type=ENTITY_TYPE.GAME_LOGIC,
                       sender_id=8,
                       currency=CURRENCY_TYPE.PREMIUM,
                       amount=317,
                       state=None,
                       description_for_sender='invoice-description-for-sender',
                       description_for_recipient='invoice-description-for-recipient',
                       operation_uid='test-uid',
                       force=False):
        invoice = InvoicePrototype.create(recipient_type=recipient_type,
                                          recipient_id=recipient_id,
                                          sender_type=sender_type,
                                          sender_id=sender_id,
                                          currency=currency,
                                          amount=amount,
                                          description_for_sender=description_for_sender,
                                          description_for_recipient=description_for_recipient,
                                          operation_uid=operation_uid,
                                          force=force)
        if state is not None:
            invoice.state = state
            invoice.save()

        return invoice
开发者ID:Alkalit,项目名称:the-tale,代码行数:27,代码来源:helpers.py


示例15: test_success

    def test_success(self):
        self.assertEqual(BankInvoicePrototype._db_count(), 0)
        response = self.post_ajax_json(url('shop:give-money', account=self.account.id), self.post_data(amount=5))
        self.assertEqual(BankInvoicePrototype._db_count(), 1)

        invoice = BankInvoicePrototype._db_get_object(0)

        self.assertTrue(invoice.recipient_type.is_GAME_ACCOUNT)
        self.assertEqual(invoice.recipient_id, self.account.id)
        self.assertTrue(invoice.sender_type.is_GAME_MASTER)
        self.assertEqual(invoice.sender_id, self.superuser.id)
        self.assertTrue(invoice.currency.is_PREMIUM)
        self.assertEqual(invoice.amount, 5)
        self.assertEqual(invoice.description_for_recipient, u'bla-bla')
        self.assertTrue(invoice.state.is_FORCED)

        self.check_ajax_ok(response)
开发者ID:Alkalit,项目名称:the-tale,代码行数:17,代码来源:test_requests.py


示例16: get_invoice_intervals_count

 def get_invoice_intervals_count(self, days, date):
     starts = list(InvoicePrototype._db_filter(models.Q(state=INVOICE_STATE.CONFIRMED)|models.Q(state=INVOICE_STATE.FORCED),
                                               operation_uid__contains='<%s%d' % (GOODS_GROUP.PREMIUM.uid_prefix, days),
                                               sender_type=ENTITY_TYPE.GAME_LOGIC,
                                               currency=CURRENCY_TYPE.PREMIUM).values_list('created_at', flat=True))
     return len([True
                 for created_at in starts
                 if created_at <= datetime.datetime.combine(date, datetime.time()) < created_at + datetime.timedelta(days=days)] )
开发者ID:Alkalit,项目名称:the-tale,代码行数:8,代码来源:actual.py


示例17: check_frozen_expired_invoices

    def check_frozen_expired_invoices(self):

        if time.time() - float(settings.get(bank_settings.SETTINGS_LAST_FROZEN_EXPIRED_CHECK_KEY, 0)) < bank_settings.FROZEN_INVOICE_EXPIRED_CHECK_TIMEOUT:
            return

        settings[bank_settings.SETTINGS_LAST_FROZEN_EXPIRED_CHECK_KEY] = str(time.time())

        if not InvoicePrototype.check_frozen_expired_invoices():
            return

        self.logger.error('We have some expired frozen invoices. Please, check them and remove or find error.')
开发者ID:,项目名称:,代码行数:11,代码来源:


示例18: test_create

    def test_create(self):
        with mock.patch('the_tale.finances.bank.workers.bank_processor.Worker.cmd_init_invoice') as cmd_init_invoice:
            transaction = self.create_transaction()
        self.assertEqual(cmd_init_invoice.call_count, 1)

        self.assertEqual(InvoicePrototype._model_class.objects.all().count(), 1)

        invoice = InvoicePrototype._db_get_object(0)

        self.assertEqual(transaction.invoice_id, InvoicePrototype._db_get_object(0).id)

        self.assertTrue(invoice.state.is_REQUESTED)
        self.assertEqual(invoice.recipient_type, ENTITY_TYPE.GAME_ACCOUNT)
        self.assertEqual(invoice.recipient_id, 2)
        self.assertEqual(invoice.sender_type, ENTITY_TYPE.GAME_LOGIC)
        self.assertEqual(invoice.sender_id, 3)
        self.assertEqual(invoice.currency, CURRENCY_TYPE.PREMIUM)
        self.assertEqual(invoice.amount, 113)
        self.assertEqual(invoice.description_for_sender, 'transaction description for sender')
        self.assertEqual(invoice.description_for_recipient, 'transaction description for recipient')
        self.assertEqual(invoice.operation_uid, 'transaction-operation-uid')
开发者ID:Alkalit,项目名称:the-tale,代码行数:21,代码来源:test_transaction.py


示例19: _create_outcoming_invoice

 def _create_outcoming_invoice(self, amount, state=INVOICE_STATE.FROZEN):
     invoice = InvoicePrototype.create(sender_type=self.account.entity_type,
                                       sender_id=self.account.entity_id,
                                       recipient_type=ENTITY_TYPE.GAME_LOGIC,
                                       recipient_id=0,
                                       currency=CURRENCY_TYPE.PREMIUM,
                                       amount=amount,
                                       description_for_sender='outcoming invoice for sender',
                                       description_for_recipient='outcoming invoice for recipient',
                                       operation_uid='outcoming-operation-uid')
     invoice.state = state
     invoice.save()
开发者ID:,项目名称:,代码行数:12,代码来源:


示例20: test_process__wait_confirmation__transaction_confirmed__with_referal

    def test_process__wait_confirmation__transaction_confirmed__with_referal(self):
        self.invoice.state = INVOICE_STATE.CONFIRMED
        self.invoice.save()

        result, account_id, bundle_id = register_user('test_user_2', '[email protected]', '111111')
        self.account._model.referral_of_id = account_id
        self.account.save()

        self.task.state = self.task.RELATION.WAIT_TRANSACTION_CONFIRMATION

        self.assertEqual(self.task.process(main_task=mock.Mock()), POSTPONED_TASK_LOGIC_RESULT.SUCCESS)

        self.assertEqual(InvoicePrototype._db_count(), 2)

        referral_invoice = InvoicePrototype._db_get_object(1)

        self.assertTrue(referral_invoice.amount > 0)
        self.assertTrue(referral_invoice.amount < self.amount)
        self.assertEqual(referral_invoice.recipient_id, account_id)
        self.assertTrue(referral_invoice.state.is_FORCED)

        self.assertTrue(self.task.state.is_SUCCESSED)
开发者ID:Alkalit,项目名称:the-tale,代码行数:22,代码来源:base_buy_task.py



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python prototypes.PostPrototype类代码示例发布时间:2022-05-27
下一篇:
Python permissions.sync_group函数代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap