Retrieve the total recurring fee of the items prices
494838
def _build_receipt_table(result, billing="hourly", test=False):
    """"""
    title = "OrderId: %s" % (result.get('orderId', 'No order placed'))
    table = formatting.Table(['Cost', 'Description'], title=title)
    table.align['Cost'] = 'r'
    table.align['Description'] = 'l'
    total = 0.000
    if test:
        prices = result['prices']
    else:
        prices = result['orderDetails']['prices']

    for item in prices:
        rate = 0.000
        if billing == "hourly":
            rate += float(item.get('hourlyRecurringFee', 0.000))
        else:
            rate += float(item.get('recurringFee', 0.000))
        total += rate
        table.add_row([rate, item['item']['description']])
    table.add_row(["%.3f" % total, "Total %s cost" % billing])
    return table
726896
def _matches_billing(price, hourly):
    """"""
    return any([hourly and price.get('hourlyRecurringFee') is not None,
                not hourly and price.get('recurringFee') is not None])
223993
def getTotalPrice(self):
        
        price, vat = self.getAnalysisProfilePrice(), self.getVATAmount()
        return float(price) + float(vat)
256938
def current_hold_price(self):
        
        
        def weights(x):
            n=len(x)
            res=1
            while res>0 or res<0:
                res=sum(x[:n]['amount'])
                n=n-1
            
            x=x[n+1:]     
            
            if sum(x['amount']) != 0:
                return np.average(
                    x['price'],
                    weights=x['amount'],
                    returned=True
                )
            else:
                return np.nan
        return self.history_table.set_index(
            'datetime',
            drop=False
        ).sort_index().groupby('code').apply(weights).dropna()
858585
def get_price(self):
        
        for cond in self.conditions:
            for p in cond.parameters:
                if p.name == '_amount':
                    return p.value
68350
def payments(self):
        """"""
        payments = self.client.subscription_payments.on(self).list()
        return payments
341065
def ajax_recalculate_prices(self):
        
        # When the option "Include and display pricing information" in
        # Bika Setup Accounting tab is not selected
        if not self.show_recalculate_prices():
            return {}

        # The sorted records from the request
        records = self.get_records()

        client = self.get_client()
        bika_setup = api.get_bika_setup()

        member_discount = float(bika_setup.getMemberDiscount())
        member_discount_applies = False
        if client:
            member_discount_applies = client.getMemberDiscountApplies()

        prices = {}
        for n, record in enumerate(records):
            ardiscount_amount = 0.00
            arservices_price = 0.00
            arprofiles_price = 0.00
            arprofiles_vat_amount = 0.00
            arservice_vat_amount = 0.00
            services_from_priced_profile = []

            profile_uids = record.get("Profiles_uid", "").split(",")
            profile_uids = filter(lambda x: x, profile_uids)
            profiles = map(self.get_object_by_uid, profile_uids)
            services = map(self.get_object_by_uid, record.get("Analyses", []))

            # ANALYSIS PROFILES PRICE
            for profile in profiles:
                use_profile_price = profile.getUseAnalysisProfilePrice()
                if not use_profile_price:
                    continue

                profile_price = float(profile.getAnalysisProfilePrice())
                arprofiles_price += profile_price
                arprofiles_vat_amount += profile.getVATAmount()
                profile_services = profile.getService()
                services_from_priced_profile.extend(profile_services)

            # ANALYSIS SERVICES PRICE
            for service in services:
                if service in services_from_priced_profile:
                    continue
                service_price = float(service.getPrice())
                # service_vat = float(service.getVAT())
                service_vat_amount = float(service.getVATAmount())
                arservice_vat_amount += service_vat_amount
                arservices_price += service_price

            base_price = arservices_price + arprofiles_price

            # Calculate the member discount if it applies
            if member_discount and member_discount_applies:
                logger.info("Member discount applies with {}%".format(
                    member_discount))
                ardiscount_amount = base_price * member_discount / 100

            subtotal = base_price - ardiscount_amount
            vat_amount = arprofiles_vat_amount + arservice_vat_amount
            total = subtotal + vat_amount

            prices[n] = {
                "discount": "{0:.2f}".format(ardiscount_amount),
                "subtotal": "{0:.2f}".format(subtotal),
                "vat": "{0:.2f}".format(vat_amount),
                "total": "{0:.2f}".format(total),
            }
            logger.info("Prices for AR {}: Discount={discount} "
                        "VAT={vat} Subtotal={subtotal} total={total}"
                        .format(n, **prices[n]))

        return prices
811268
def get_last_available_price(self) -> PriceModel:
        
        price_db = PriceDbApplication()
        symbol = SecuritySymbol(self.security.namespace, self.security.mnemonic)
        result = price_db.get_latest_price(symbol)
        return result
730157
def calculate_total_amt(self, items={}):
        """"""
        _items = items.items() or self.items.items()
        return sum(float(x[1].total_price) for x in _items)
427098
def getSubtotal(self):
        
        if self.supplyorder_lineitems:
            return sum(
                [(Decimal(obj['Quantity']) * Decimal(obj['Price'])) for obj in self.supplyorder_lineitems])
        return 0
355826
def get_previous_price_list(self, currency, start_date, end_date):
        
        start = start_date.strftime('%Y-%m-%d')
        end = end_date.strftime('%Y-%m-%d')
        url = (
            'https://api.coindesk.com/v1/bpi/historical/close.json'
            '?start={}&end={}&currency={}'.format(
                   start, end, currency
               )
        )
        response = requests.get(url)
        if response.status_code == 200:
            data = self._decode_rates(response)
            price_dict = data.get('bpi', {})
            return price_dict
        return {}
1022419
def get_billing_items(self, identifier):
        

        mask = """mask[
            id, description, hostName, domainName, oneTimeAfterTaxAmount, recurringAfterTaxAmount, createDate,
            categoryCode,
            category[name],
            location[name],
            children[id, category[name], description, oneTimeAfterTaxAmount, recurringAfterTaxAmount]
        ]"""
        return self.client.call(
            'Billing_Invoice',
            'getInvoiceTopLevelItems',
            id=identifier,
            mask=mask,
            iter=True,
            limit=100
        )
1012176
def get_balance(self, t: datetime):
        
        return sum_queryset(self.accountentry_set.all().filter(timestamp__lt=t))
258042
def parse_price(price_string):
    
    return float(re.sub('[£,]', '', price_string))

    match = re.match('(?P<amount>-?£[\d,]+(\.\d{2})?)', price_string)
    if not match:
        raise ValueError("Charge not in format '(-)£16,000(.00)' : {}".format(
            repr(price_string)))
    return float(re.sub('[£,]', '', match.group('amount')))
280766
def has_enacted(self, billing_cycle):
        """"""
        return RecurredCost.objects.filter(
            recurring_cost=self,
            billing_cycle=billing_cycle,
        ).exists()
476091
def _get_price(self, package):
        """"""

        for price in package['prices']:
            if not price.get('locationGroupId'):
                return price['id']

        raise SoftLayer.SoftLayerError("Could not find valid price")
984931
def calculate_fee(self, input_values):
        '''
        
        '''
        return \
            sum(input_values) \
            - sum([utils.le2i(o.value) for o in self.tx_outs])