Get the sum of all transaction legs in to_account during given billing cycle
4323
def get_amount_arrears_transactions(self, billing_cycle):
        """"""
        previous_billing_cycle = billing_cycle.get_previous()
        if not previous_billing_cycle:
            return Decimal(0)
        return self.to_account.balance(
            transaction__date__lt=previous_billing_cycle.date_range.upper,
            transaction__date__gte=previous_billing_cycle.date_range.lower,
        )
30700
def sum_transactions(transactions):
    
    workdays_per_year = 250
    previous_date = None
    rate = 0
    day_sum = 0
    for transaction in transactions:
        date, action, value = _parse_transaction_entry(transaction)
        if previous_date is None:
            previous_date = date
        elapsed = workdays.networkdays(previous_date, date, stat_holidays()) - 1

        if action == 'rate':
            rate = float(value) / workdays_per_year
        elif action == 'off':
            elapsed -= 1  # Didn't work that day
            day_sum -= 1  # And we used a day
        day_sum += rate * elapsed

        if action == 'days':
            day_sum = value  # Fixed value as of this entry

        previous_date = date

    return day_sum
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)
285927
def __get_holding_accounts_query(self):
        
        query = (
            self.book.session.query(Account)
            .filter(Account.commodity == self.security)
            .filter(Account.type != AccountType.trading.value)
        )
        # generic.print_sql(query)
        return query
692897
def paid_totals_for(self, year, month):
		""""""
		return (
			self.during(year, month)
			.filter(paid=True)
			.aggregate(
				total_amount=models.Sum("amount"), total_refunded=models.Sum("amount_refunded")
			)
		)
1003947
def total_transactions_by_subacct(self, subaccount):
        
        return sum(
            t.amount for t in self.transactions if t.subaccount == subaccount)
1214538
def get_balance_on(self, on_date: datetime) -> Decimal:
        
        assert isinstance(on_date, datetime)

        total = Decimal(0)

        splits = self.get_splits_up_to(on_date)

        for split in splits:
            total += split.quantity * self.account.sign
        return total
807595
def get_totals_by_payee(self, account, start_date=None, end_date=None):
        
        qs = Transaction.objects.filter(account=account, parent__isnull=True)
        qs = qs.values('payee').annotate(models.Sum('value_gross'))
        qs = qs.order_by('payee__name')
        return qs
718165
def add_transaction_to_list(tx)
      k = RLP.encode @transaction_count
      @transactions[k] = RLP.encode(tx)

      r = mk_transaction_receipt tx
      @receipts[k] = RLP.encode(r)

      self.bloom |= r.bloom
      @transaction_count += 1
    end
815740
public static TransactionImpl[] getAllTransactions()
    {
        if (tc.isEntryEnabled()) Tr.entry(tc, "getAllTransactions");

        final Collection<TransactionImpl> txns = localTIDMap.values();

        if (txns != null)
        {
            if (tc.isEntryEnabled()) Tr.exit(tc, "getAllTransactions", txns);
            return txns.toArray(noTxns);
        }

        if (tc.isEntryEnabled()) Tr.exit(tc, "getAllTransactions", noTxns);
        return noTxns;
    }
267679
def sum_to_balance(self):
        
        result = self.values("amount_currency").annotate(total=models.Sum("amount"))
        return Balance([Money(r["total"], r["amount_currency"]) for r in result])
42397
def balance(ctx, accounts):
    
    t = PrettyTable(["Account", "Amount"])
    t.align = "r"
    for a in accounts:
        account = Account(a, peerplays_instance=ctx.peerplays)
        for b in account.balances:
            t.add_row([str(a), str(b)])
    click.echo(str(t))
1359606
public function totalAmountCharged()
    {
        $qb = $this->getQueryBuilder()
            ->select('SUM(t.totalPrice)')
            ->innerJoin('t.items', 'i')
            ->innerJoin('i.product', 'p')
            ->where('p.priceType = 0')
            ->andWhere('t.status = :status OR t.status = :status2 OR t.status = :status3')
            ->setParameter('status', Transaction::STATUS_PAID)
            ->setParameter('status2', Transaction::STATUS_COMPLETED)
            ->setParameter('status3', Transaction::STATUS_DELIVERED)
                ;
                
        if(is_null($qb->getQuery()->getSingleScalarResult())) return '0';
                
        return $qb->getQuery()
            ->getSingleScalarResult();
    }
1074908
def total_stored(self, wanted, slots=None):
        
        if slots is None:
            slots = self.window.slots
        wanted = make_slot_check(wanted)
        return sum(slot.amount for slot in slots if wanted(slot))
1125714
def _transactions(self):
        ""
        transactions = getattr(self._state, "transactions", None)
        if transactions is None:
            transactions = self._state.transactions = []
        return transactions
943260
def balance(self):
        """"""
        self.check()
        if not sum(map(lambda x: x.amount, self.src)) == -self.amount:
            raise XnBalanceError("Sum of source amounts "
                                 "not equal to transaction amount")
        if not sum(map(lambda x: x.amount, self.dst)) == self.amount:
            raise XnBalanceError("Sum of destination amounts "
                                 "not equal to transaction amount")
        return True
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))