Beispiel #1
0
    def get(self):
        args = request.args
        good_id = args['good_id']
        price_post = args['price_post']

        good = GoodService.get_good(good_id)
        commodity = good.commodity
        try:
            prices = PriceService.prices_parish_to_commodity_price(
                commodity, float(price_post))
        # TODO - кажется тут не вылетит никогда исключение
        # PriceServiceException
        except PriceServiceException as exc:
            debug(unicode(exc))
            error(u"Это случилось. resource/price.py")
            abort(404, message=unicode(exc), code=1)
        else:
            return {'items': [{
                'invoice_id': x.invoice_id,
                'invoice_str': unicode(x.invoice),
                'provider_id': x.invoice.provider_id,
                'provider_str': x.invoice.provider.name,
                'number_local_from': x.number_local_from,
                'number_global_from': x.number_global_from,
                'date_from': x.date_from,
                'price_post': x.price_post,
                'price_retail': x.price.price_retail,
                'price_gross': x.price.price_gross
            } for x in prices]}