Example #1
0
def get_beers_sells(request):
    """
	Obtention des ventes dans la journée courante des ids mis en paramètres
	Méthode utilisée publique, utilisée pour le duel des brasseurs en A19 
	"""
    beers = request.data['beers']
    response = dict()

    current_date = (datetime.now()).strftime('%Y-%m-%d')
    start_date = current_date + "T00:00:01.000Z"
    end_date = current_date + "T23:59:59.000Z"

    p = PayutcClient()
    p.login_admin()

    duels = beers.keys()
    for duel in duels:
        response[duel] = dict()
        duel_beers = beers[duel].keys()
        for beer in duel_beers:
            beer_id = beers[duel][beer]['id']
            nb_sells = p.get_nb_sell(obj_id=beer_id,
                                     start=start_date,
                                     end=end_date)
            response[duel][beer] = dict()
            response[duel][beer]['id'] = beers[duel][beer]['id']
            response[duel][beer]['quantity'] = nb_sells

    return JsonResponse({'beers': response}, status=200)
Example #2
0
 def update_sales(self):
     from core.services.payutc import PayutcClient
     p = PayutcClient()
     p.login_admin()
     rep = p.get_nb_sell(obj_id=self.id_payutc)
     self.ventes = rep
     self.ventes_last_update = timezone.now()
     self.save()
     return self.ventes