Example #1
0
    def process(self):
        from the_tale.finances.bank.transaction import Transaction
        from the_tale.finances.bank.relations import ENTITY_TYPE, CURRENCY_TYPE

        if not self.state.is_CREATED:
            raise exceptions.WrongInvoiceStateInProcessingError(invoice_id=self.id, state=self.state)

        if self.test:
            self.state = INVOICE_STATE.SKIPPED_BECOUSE_TEST
            self.save()
            return

        transaction = Transaction.create(recipient_type=ENTITY_TYPE.GAME_ACCOUNT,
                                         recipient_id=self.bank_id,
                                         sender_type=ENTITY_TYPE.XSOLLA,
                                         sender_id=0,
                                         currency=CURRENCY_TYPE.PREMIUM,
                                         amount=self.bank_amount,
                                         description_for_sender='Покупка печенек (через Xsolla)',
                                         description_for_recipient='Покупка печенек (через Xsolla)',
                                         operation_uid='bank-xsolla',
                                         force=True)

        self._model.bank_invoice_id = transaction.invoice_id
        self.state = INVOICE_STATE.PROCESSED
        self.save()
Example #2
0
    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
Example #3
0
    def process(self):
        from the_tale.finances.bank.transaction import Transaction
        from the_tale.finances.bank.relations import ENTITY_TYPE, CURRENCY_TYPE

        if not self.state.is_CREATED:
            raise exceptions.WrongInvoiceStateInProcessingError(
                invoice_id=self.id, state=self.state)

        if self.test:
            self.state = INVOICE_STATE.SKIPPED_BECOUSE_TEST
            self.save()
            return

        transaction = Transaction.create(
            recipient_type=ENTITY_TYPE.GAME_ACCOUNT,
            recipient_id=self.bank_id,
            sender_type=ENTITY_TYPE.XSOLLA,
            sender_id=0,
            currency=CURRENCY_TYPE.PREMIUM,
            amount=self.bank_amount,
            description_for_sender='Покупка печенек (через Xsolla)',
            description_for_recipient='Покупка печенек (через Xsolla)',
            operation_uid='bank-xsolla',
            force=True)

        self._model.bank_invoice_id = transaction.invoice_id
        self.state = INVOICE_STATE.PROCESSED
        self.save()
Example #4
0
    def __init__(self, account_id, transaction, state=None):
        super(BaseBuyTask, self).__init__()

        if state is None:
            state = self.RELATION.TRANSACTION_REQUESTED

        self.account_id = account_id
        self.state = state if isinstance(state, rels.Record) else self.RELATION.index_value[state]
        self.transaction = Transaction.deserialize(transaction) if isinstance(transaction, dict) else transaction
Example #5
0
    def __init__(self, account_id, transaction, state=None):
        super(BaseBuyTask, self).__init__()

        if state is None:
            state = self.RELATION.TRANSACTION_REQUESTED

        self.account_id = account_id
        self.state = state if isinstance(state, rels.Record) else self.RELATION.index_value[state]
        self.transaction = Transaction.deserialize(transaction) if isinstance(transaction, dict) else transaction
Example #6
0
 def create_transaction(self):
     return Transaction.create(recipient_type=ENTITY_TYPE.GAME_ACCOUNT,
                               recipient_id=2,
                               sender_type=ENTITY_TYPE.GAME_LOGIC,
                               sender_id=3,
                               currency=CURRENCY_TYPE.PREMIUM,
                               amount=113,
                               description_for_sender='transaction description for sender',
                               description_for_recipient='transaction description for recipient',
                               operation_uid='transaction-operation-uid')
Example #7
0
def transaction_logic(account, amount, description, uid, force=False):
    return Transaction.create(recipient_type=ENTITY_TYPE.GAME_ACCOUNT,
                              recipient_id=account.id,
                              sender_type=ENTITY_TYPE.GAME_LOGIC,
                              sender_id=0,
                              currency=CURRENCY_TYPE.PREMIUM,
                              amount=amount,
                              description_for_sender=description,
                              description_for_recipient=description,
                              operation_uid=uid,
                              force=force)
Example #8
0
 def create_transaction(self):
     return Transaction.create(
         recipient_type=ENTITY_TYPE.GAME_ACCOUNT,
         recipient_id=2,
         sender_type=ENTITY_TYPE.GAME_LOGIC,
         sender_id=3,
         currency=CURRENCY_TYPE.PREMIUM,
         amount=113,
         description_for_sender='transaction description for sender',
         description_for_recipient='transaction description for recipient',
         operation_uid='transaction-operation-uid')
Example #9
0
def transaction_gm(account, amount, description, game_master):

    return Transaction.create(recipient_type=ENTITY_TYPE.GAME_ACCOUNT,
                              recipient_id=account.id,
                              sender_type=ENTITY_TYPE.GAME_MASTER,
                              sender_id=game_master.id,
                              currency=CURRENCY_TYPE.PREMIUM,
                              amount=amount,
                              description_for_sender=description,
                              description_for_recipient=description,
                              operation_uid='game-master-gift',
                              force=True)
Example #10
0
def transaction_logic(account, amount, description, uid, force=False):
    return Transaction.create(
        recipient_type=ENTITY_TYPE.GAME_ACCOUNT,
        recipient_id=account.id,
        sender_type=ENTITY_TYPE.GAME_LOGIC,
        sender_id=0,
        currency=CURRENCY_TYPE.PREMIUM,
        amount=amount,
        description_for_sender=description,
        description_for_recipient=description,
        operation_uid=uid,
        force=force,
    )
Example #11
0
def transaction_gm(account, amount, description, game_master):

    return Transaction.create(
        recipient_type=ENTITY_TYPE.GAME_ACCOUNT,
        recipient_id=account.id,
        sender_type=ENTITY_TYPE.GAME_MASTER,
        sender_id=game_master.id,
        currency=CURRENCY_TYPE.PREMIUM,
        amount=amount,
        description_for_sender=description,
        description_for_recipient=description,
        operation_uid="game-master-gift",
        force=True,
    )