Post a credit of 'amount' and a debit of -amount against this account and credit_account respectively.

        note amount must be non-negative.
498955
def credit(self, amount, debit_account, description, debit_memo="", credit_memo="", datetime=None):
        
        assert amount >= 0
        return self.post(-amount, debit_account, description, self_memo=credit_memo, other_memo=debit_memo, datetime=datetime)
436916
def GET_account_balance(self, path_info, account_addr, token_type):
        
        if not check_account_address(account_addr):
            return self._reply_json({'error': 'Invalid address'}, status_code=400)

        if not check_token_type(token_type):
            return self._reply_json({'error': 'Invalid token type'}, status_code=400)

        blockstackd_url = get_blockstackd_url()
        res = blockstackd_client.get_account_balance(account_addr, token_type, hostport=blockstackd_url)
        if json_is_error(res):
            log.error("Failed to get account balance for {} {}: {}".format(account_addr, token_type, res['error']))
            return self._reply_json({'error': 'Failed to get balance of {} for {}: {}'.format(token_type, account_addr, res['error'])}, status_code=res.get('http_status', 500))

        self._reply_json({'balance': str(res)})     # NOTE: use a string, since this can be too big for js clients to parse
        return
455030
def balance(self):
        """"""
        while self.recNum > self.shpNum:
            self.null()
        while self.recNum < self.shpNum:
            self.record()
223766
def note(self, info):
        
        if self.recording:
            if self.notes is None:
                raise ValueError("This report has already been submitted")
            self.notes.extend(self._to_notes(info))
159979
def validate_accounting_equation(cls):
        """"""
        balances = [account.balance(raw=True) for account in Account.objects.root_nodes()]
        if sum(balances, Balance()) != 0:
            raise exceptions.AccountingEquationViolationError(
                "Account balances do not sum to zero. They sum to {}".format(sum(balances))
            )
556570
def credits(params = {})
      request_params = params.merge(access_params)
      request = Requests::Credit::List.new(request_params)
      request.call!
    end
153138
def balance(ctx, accounts):
    
    t = [["Account", "Amount"]]
    for a in accounts:
        account = Account(a, bitshares_instance=ctx.bitshares)
        for b in account.balances:
            t.append([str(a), str(b)])
    print_table(t)
463991
protected function checkMissingAmount()
    {
        // Check if we are missing an amount and, if so, add a line for it.
        $this->completeLineTotals();
        $areTotalsEqual = $this->areTotalsEqual();
        if ($areTotalsEqual === false) {
            $this->addMissingAmountLine();
        }
    }
586834
def submit(cls, client, direction, legs, price, quantity, time_in_force,
               trigger, order_type, run_validations=True):
        '''
        
        '''

        if run_validations:
            assert(direction in ["debit", "credit"])
            assert(type(price) is str)
            assert(type(quantity) is int)
            assert(time_in_force in ["gfd", "gtc"])
            assert(trigger in ["immediate"])
            assert(order_type in ["limit", "market"])
            assert(cls._validate_legs(legs) is True)

        payload = json.dumps({
            "account": client.account_url,
            "direction": direction,
            "legs": legs,
            "price": price,
            "quantity": quantity,
            "time_in_force": time_in_force,
            "trigger": trigger,
            "type": order_type,
            "override_day_trade_checks": False,
            "override_dtbp_checks": False,
            "ref_id": str(uuid.uuid4())
        })

        request_url = "https://api.robinhood.com/options/orders/"
        data = client.post(request_url, payload=payload)
        return data
668432
public InvoiceCollection postAccountInvoice(final String accountCode, final Invoice invoice) {
        return doPOST(Accounts.ACCOUNTS_RESOURCE + "/" + accountCode + Invoices.INVOICES_RESOURCE, invoice, InvoiceCollection.class);
    }
188941
def get_payments_of_credit_note_per_page(self, credit_note_id, per_page=1000, page=1):
        
        return self._get_resource_per_page(
            resource=CREDIT_NOTE_PAYMENTS,
            per_page=per_page,
            page=page,
            params={'credit_note_id': credit_note_id},
        )
791901
def credits(self):
        
        if self.cred[0] == self.cred[1]:
            return self.cred[0]
        return self.cred
1050169
def balance(self) -> Decimal:
        
        return sum_queryset(AccountEntry.objects.filter(account=self.account, timestamp__lte=self.timestamp).exclude(timestamp=self.timestamp, id__gt=self.id))
798405
def SubtractFromBalance(self, assetId, fixed8_val):
        
        found = False
        for key, balance in self.Balances.items():
            if key == assetId:
                self.Balances[assetId] = self.Balances[assetId] - fixed8_val
                found = True
        if not found:
            self.Balances[assetId] = fixed8_val * Fixed8(-1)
1037653
def get_deposit(self, account_id, deposit_id, **params):
        """"""
        response = self._get(
            'v2', 'accounts', account_id, 'deposits', deposit_id, params=params)
        return self._make_api_object(response, Deposit)
317680
def get_unpaid_items(self, acc: Account) -> list:
        
        unpaid_items = []
        for item, bal in self.get_item_balances(acc):
            assert isinstance(item, AccountEntry)
            if self.type == INVOICE_DEFAULT:
                if bal > Decimal(0):
                    unpaid_items.append((item.type.payback_priority, item, bal))
            elif self.type == INVOICE_CREDIT_NOTE:
                if bal < Decimal(0):
                    unpaid_items.append((item.type.payback_priority, item, bal))
            else:
                raise Exception('jacc.models.Invoice.get_unpaid_items() unimplemented for invoice type {}'.format(self.type))
        return [i[1:] for i in sorted(unpaid_items, key=lambda x: x[0])]
137833
def account_balance_after(self):
        """"""
        # TODO: Consider moving to annotation, particularly once we can count on Django 1.11's subquery support
        transaction_date = self.transaction.date
        return self.account.balance(
            leg_query=(
                models.Q(transaction__date__lt=transaction_date)
                | (
                    models.Q(transaction__date=transaction_date)
                    & models.Q(transaction_id__lte=self.transaction_id)
                )
            )
        )