Books a current invoice. The given number will be assigned to the
 resulting Economic::Invoice.

 Returns the resulting Economic::Invoice object
552101
def book_with_number(number)
      response = request(
        :book_with_number,
        "currentInvoiceHandle" => handle.to_hash,
        "number" => number
      )

      # Find the created Invoice
      session.invoices.find(response[:number])
    end
1264787
function parseAccountOrder(address: string, order: Object): Object {
  const direction = (order.flags & flags.Sell) === 0 ? 'buy' : 'sell'
  const takerGetsAmount = parseAmount(order.taker_gets)
  const takerPaysAmount = parseAmount(order.taker_pays)
  const quantity = (direction === 'buy') ? takerPaysAmount : takerGetsAmount
  const totalPrice = (direction === 'buy') ? takerGetsAmount : takerPaysAmount

  // note: immediateOrCancel and fillOrKill orders cannot enter the order book
  // so we can omit those flags here
  const specification = utils.removeUndefined({
    direction: direction,
    quantity: quantity,
    totalPrice: totalPrice,
    passive: ((order.flags & flags.Passive) !== 0) || undefined,
    // rippled currently does not provide "expiration" in account_offers
    expirationTime: utils.parseTimestamp(order.expiration)
  })

  const makerExchangeRate = order.quality ?
      utils.adjustQualityForZXC(order.quality.toString(),
        takerGetsAmount.currency, takerPaysAmount.currency) :
      computeQuality(takerGetsAmount, takerPaysAmount)
  const properties = {
    maker: address,
    sequence: order.seq,
    makerExchangeRate: makerExchangeRate
  }

  return {specification, properties}
}
150698
def query(self):
        
        query = (
            self.book.session.query(Commodity)
            .filter(Commodity.namespace != "CURRENCY",
                    Commodity.namespace != "template")
        )
        return query
242844
def total_charges(self):
        
        selected_charges = Charge.objects \
            .filter(invoice=self) \
            .charges() \
            .exclude(product_code=CARRIED_FORWARD)
        return total_amount(selected_charges)
345423
def create_from_item(cls, amount, item_description, **kwargs):
        '''
        
        '''
        submissionUser = kwargs.pop('submissionUser', None)
        collectedByUser = kwargs.pop('collectedByUser', None)
        calculate_taxes = kwargs.pop('calculate_taxes', False)
        grossTotal = kwargs.pop('grossTotal',None)

        new_invoice = cls(
            grossTotal=grossTotal or amount,
            total=amount,
            submissionUser=submissionUser,
            collectedByUser=collectedByUser,
            buyerPaysSalesTax=getConstant('registration__buyerPaysSalesTax'),
            data=kwargs,
        )

        if calculate_taxes:
            new_invoice.calculateTaxes()

        new_invoice.save()

        InvoiceItem.objects.create(
            invoice=new_invoice,
            grossTotal=grossTotal or amount,
            total=amount,
            taxes=new_invoice.taxes,
            description=item_description,
        )
        return new_invoice
1324774
def trading_pnl(self):
        
        last_price = self._data_proxy.get_last_price(self._order_book_id)
        return self._contract_multiplier * (self._trade_quantity * last_price - self._trade_cost)
1367161
def set_invoices(invoices_attributes)
      @invoices = invoices_attributes.map.with_index do |invoice_attributes, index|
        existing_invoice = invoices[index]

        if existing_invoice
          existing_invoice.assign_all_attributes(invoice_attributes)
        else
          Invoice.new_from_json(invoice_attributes)
        end
      end
    end
554900
def get_total_paid(self) -> Decimal:
        
        query = (
            self.get_splits_query()
        )
        splits = query.all()

        total = Decimal(0)
        for split in splits:
            total += split.value

        return total
943529
def securities(self):
        
        if not self.__securities_aggregate:
            self.__securities_aggregate = SecuritiesAggregate(self.book)
        return self.__securities_aggregate
384465
def get_orderbook(self):
        
        if self in self.parent.books.keys():
            return self.parent.books[self]

        return {
            "bid": [0], "bidsize": [0],
            "ask": [0], "asksize": [0]
        }
204011
def build_invoice(invoice = {})
      case invoice
        when Invoice then     invoice.gateway = self
        when Hash then        invoice = Invoice.new(invoice.merge(:gateway => self))
      end
      invoice
    end
605252
def fetch_order_book(self) -> OrderBook:
        """"""
        return self._fetch('order book', self.market.code)(self._order_book)()
1336076
def currentRecord(self):
        
        item = self.currentItem()
        if isinstance(item, XOrbRecordItem):
            return item.record()
        return None
1313145
def query(self):
        
        query = (
            self.book.session.query(Account)
            .join(Commodity)
            .filter(Commodity.namespace != "template")
            .filter(Account.type != AccountType.root.value)
        )
        return query
390941
def due(self):
        
        invoice_charges = Charge.objects.filter(invoice=self)
        invoice_transactions = Transaction.successful.filter(invoice=self)
        return total_amount(invoice_charges) - total_amount(invoice_transactions)
1289442
public static BitfinexOrderBookSymbol rawOrderBook(final String currency, final String profitCurrency) {
        final String currencyNonNull = Objects.requireNonNull(currency).toUpperCase();
        final String profitCurrencyNonNull = Objects.requireNonNull(profitCurrency).toUpperCase();
        
        return rawOrderBook(BitfinexCurrencyPair.of(currencyNonNull, profitCurrencyNonNull));
    }
978560
def all(self, data={}, **kwargs):
        "
        return super(Invoice, self).all(data, **kwargs)