Exemplo n.º 1
0
def bill_home(request):
    """Get current list of bills, and set a parameter to indicate
    long time bill without activities

    :param HttpRequest request:
    """
    request = remove_edition(request)
    context = {'menu_bills': True, }
    context['need_auto_refresh'] = 45
    context['factures'] = Facture().non_soldees()
    for bill in context['factures']:
        sec = bill.get_last_change()
        if sec > settings.CRITICAL:
            bill.alert = "alert-danger"
        elif sec > settings.WARNING:
            bill.alert = "alert-warning"
        elif sec > settings.INFO:
            bill.alert = "alert-info"
        else:
            bill.alert = "alert-success"
    context['critical'] = int(settings.CRITICAL) / 60
    context['warning'] = int(settings.WARNING) / 60
    context['info'] = int(settings.INFO) / 60
    context['count'] = len(context['factures'])
    return render(request, 'bill/facture_list.html', context)
Exemplo n.º 2
0
def kitchen(request):
    ''' Affiche la liste plats qui ne sont pas encore
    préparés
    :param HttpRequest request:
    :return rtype: HttpResponse
    '''
    context = {
        'menu_kitchen': True,
    }
    liste = []
    for bill in Facture().non_soldees():
        if bill.following.count():
            bill.follow = bill.following.latest()
            if not bill.follow.done:
                # on enlève les ProduitVendu de type menu
                todo = bill.follow.produits.\
                    filter(produit__categories_ok__isnull=True)
                bill.todo = bill.reduced_sold_list(todo, full=True)
                if bill.category_to_follow:
                    category_to_follow = bill.category_to_follow
                    after = bill.get_products_for_category(category_to_follow)
                    bill.after = bill.reduced_sold_list(after, full=True)
                liste.append(bill)
    context['factures'] = liste
    context['need_auto_refresh'] = 60
    return render(request, 'kitchen/home.html', context)
Exemplo n.º 3
0
def bill_new(request):
    """ Create a new bill.
    :param HttpRequest request:
    """
    bill = Facture()
    bill.save()
    return bill_view(request, bill.id)
Exemplo n.º 4
0
def bill_home(request):
    request = remove_edition(request)
    context = {
        'menu_bills': True,
    }
    context['need_auto_refresh'] = 30
    context['factures'] = Facture().non_soldees()
    return render(request, 'bill/home.html', context)
Exemplo n.º 5
0
def bill_new(request):
    """Create a new bill"""
    context = {
        'menu_bills': True,
    }
    bill = Facture()
    bill.save()
    return redirect("bill_view", bill.id)
Exemplo n.º 6
0
def archives(request):
    context = { 'menu_manager': True, }
    if request.method == 'POST':
        try:
            year = int(request.POST.get('date_year'))
            month = int(request.POST.get('date_month'))
            day = int(request.POST.get('date_day'))
            date = datetime.datetime(year, month, day)
        except:
            messages.add_message(request, messages.ERROR,
                                 _("The date is not valid"))
            date = datetime.datetime.today()
    else:
        date = datetime.datetime.today()
    context['date_form'] = DateForm({'date': date, })
    context['factures'] = Facture().get_bills_for(date)
    context['date'] = date
    return render(request, 'base/manager/archives/home.html', context)
Exemplo n.º 7
0
 def test_product_sold_order(self):
     facture = Facture()
     facture.save()
     entree = ProduitVendu()
     entree.produit = Produit.objects.get(nom="salade normande")
     facture.add_product(entree)
     plat = ProduitVendu()
     plat.produit = Produit.objects.get(nom="entrecote")
     facture.add_product(plat)
     entree = ProduitVendu()
     entree.produit = Produit.objects.get(nom="buffet")
     facture.add_product(entree)
     entree = ProduitVendu()
     entree.produit = Produit.objects.get(nom="salade normande")
     facture.add_product(entree)
     liste_triee = facture.reduced_sold_list(facture.produits.all())
     resultat = [str(p.produit) for p in liste_triee]
     attendu = ['buffet', 'salade normande', 'entrecote']
     self.assertEqual(resultat, attendu)
     self.assertEqual([p.count for p in liste_triee], [1, 2, 1])
Exemplo n.º 8
0
def archives(request):
    '''
    :param HttpRequest request:
    :return rtype: HttpResponse
    '''
    context = {
        'menu_manager': True,
    }
    context = init_borders(context)
    date = datetime.datetime.today()
    if request.method == 'POST':
        try:
            date = datetime.datetime.strptime(request.POST.get('date'),
                                              "%Y-%m-%d").date()
        except:
            messages.add_message(request, messages.ERROR,
                                 _("Date is not valid"))


#    context['date_form'] = DateForm({'date': date, })
    context['factures'] = Facture().get_bills_for(date)
    context['date'] = date
    return render(request, 'manager/archives/facture_list.html', context)
Exemplo n.º 9
0
def create_bill(finish=True):
    """Create a bill
    """
    table = 'T%d' % random.randint(10, 25)
    bill = Facture(table=Table.objects.get(nom=table))
    bill.save()
    produits_bar = [biere, pomme, abricot]
    produits_guests = [salade, buffet, entrecote, pave]
    payments = ['CB', 'Espece', 'Cheque']
    if random.randint(1, 2) == 1:
        # guests part
        produits = produits_guests
        bill.couverts = random.randint(1, 15)
    else:
        produits = produits_bar
    nb_produits = random.randint(1, 6)
    for i in xrange(nb_produits):
        # random number of products
        nb_max = len(produits) - 1
        produit = produits[random.randint(0, nb_max)]
        sold = ProduitVendu(produit=produit)
        sold.save()
        bill.add_product(sold)
    #nouveau_menu = ProduitVendu(produit=entree_plat)
    #nouveau_menu.save()
    #for produit in [salade, pave]:
    #sold = ProduitVendu(produit=produit)
    #sold.save()
    #nouveau_menu.contient.add(sold)
    #nouveau_menu.save()
    bill.update()
    if finish:
        nb_max = len(payments) - 1
        name = payments[random.randint(0, nb_max)]
        type_payment = PaiementType.objects.get(nom=name)
        bill.add_payment(type_payment, bill.total_ttc)
    return bill
Exemplo n.º 10
0
#
#    Copyright 2009, 2010, 2011 Sébastien Bonnegent
#
#    This file is part of POSSUM.
#
#    POSSUM is free software: you can redistribute it and/or modify
#    it under the terms of the GNU General Public License as published by
#    the Free Software Foundation, either version 3 of the License, or
#    (at your option) any later version.
#
#    POSSUM is distributed in the hope that it will be useful,
#    but WITHOUT ANY WARRANTY; without even the implied warranty of
#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#    GNU General Public License for more details.
#
#    You should have received a copy of the GNU General Public License
#    along with POSSUM.  If not, see <http://www.gnu.org/licenses/>.
#
import sys, os
sys.path.append('/home/pos')
os.environ['DJANGO_SETTINGS_MODULE'] = 'possum.settings'

from possum.base.models import Accompagnement, Sauce, Etat, \
    Categorie, Couleur, Cuisson, Facture, Log, LogType, Paiement, \
    PaiementType, Produit, ProduitVendu, Suivi, Table, Zone

from datetime import datetime

date = datetime(2011,1,9)
Facture().rapport_jour(date)
Exemplo n.º 11
0
 def setUp(self):
     TestCase.setUp(self)
     self.facture = Facture()
     self.facture.save()
     self.plat = ProduitVendu()
     self.plat.produit = Produit.objects.get(nom="entrecote")
Exemplo n.º 12
0
    pbar.update(count)
    count += 1

    olddate_creation = str(date_creation)
    newdate_creation = "%s-%s-%s %s:%s:%s" % (
        olddate_creation[0:4], olddate_creation[4:6], olddate_creation[6:8],
        olddate_creation[8:10], olddate_creation[10:12],
        olddate_creation[12:14])
    #    olddate_paiement = str(date_paiement)
    #    newdate_paiement = "%s-%s-%s %s:%s:%s" % (olddate_paiement[0:4],olddate_paiement[4:6],olddate_paiement[6:8],olddate_paiement[8:10],olddate_paiement[10:12],olddate_paiement[12:14])
    if id_table:
        table = Table_get(id=id_table)
        #        facture = Facture(id=id, date_creation=newdate_creation, date_paiement=newdate_paiement, montant_normal=ttc, montant_alcool=ttc_alcool, table=table, couverts=nb_couverts)
        facture = Facture(id=id,
                          date_creation=newdate_creation,
                          montant_normal=convert_prix(ttc),
                          montant_alcool=convert_prix(ttc_alcool),
                          table=table,
                          couverts=nb_couverts)
    else:
        #        facture = Facture(id=id, date_creation=newdate_creation, date_paiement=newdate_paiement, montant_normal=ttc, montant_alcool=ttc_alcool, couverts=nb_couverts)
        facture = Facture(id=id,
                          date_creation=newdate_creation,
                          montant_normal=convert_prix(ttc),
                          montant_alcool=convert_prix(ttc_alcool),
                          couverts=nb_couverts)
    facture.save()
    facture.date_creation = newdate_creation

    cu.execute(
        "select id,id_mode_paiement,valeur_unitaire,date,montant_ttc from paiements where id_facture=%d"
        % facture.id)
Exemplo n.º 13
0
# -*- coding: utf-8 -*-
#
#    Copyright 2009, 2010, 2011 Sébastien Bonnegent
#
#    This file is part of POSSUM.
#
#    POSSUM is free software: you can redistribute it and/or modify
#    it under the terms of the GNU General Public License as published by
#    the Free Software Foundation, either version 3 of the License, or
#    (at your option) any later version.
#
#    POSSUM is distributed in the hope that it will be useful,
#    but WITHOUT ANY WARRANTY; without even the implied warranty of
#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#    GNU General Public License for more details.
#
#    You should have received a copy of the GNU General Public License
#    along with POSSUM.  If not, see <http://www.gnu.org/licenses/>.
#
import sys, os
sys.path.append('/home/pos')
os.environ['DJANGO_SETTINGS_MODULE'] = 'possum.settings'

from possum.base.models import Accompagnement, Sauce, Etat, \
    Categorie, Couleur, Cuisson, Facture, Log, LogType, Paiement, \
    PaiementType, Produit, ProduitVendu, Suivi, Table, Zone

from datetime import datetime

Facture().rapport_mois(datetime.today())
Exemplo n.º 14
0
#    along with POSSUM.  If not, see <http://www.gnu.org/licenses/>.
#
import sys, os
sys.path.append('/home/pos')
os.environ['DJANGO_SETTINGS_MODULE'] = 'possum.settings'

from possum.base.models import Accompagnement, Sauce, Etat, \
    Categorie, Couleur, Cuisson, Facture, Log, LogType, Paiement, \
    PaiementType, Produit, ProduitVendu, Suivi, Table, Zone

from datetime import datetime
from decimal import Decimal

montant_alcool = Decimal("0")
montant_normal = Decimal("0")
for facture in Facture().get_factures_du_jour(datetime(2011,1,27)).iterator():
    montant_alcool += facture.montant_alcool
    montant_normal += facture.montant_normal

#tva_normal = montant_normal - (montant_normal / Decimal("1.055"))
#tva_alcool = montant_alcool - (montant_alcool / Decimal("1.196"))
tva_normal = montant_normal * (Decimal("0.055") / Decimal("1.055"))
tva_alcool = montant_alcool * (Decimal("0.196") / Decimal("1.196"))

print "Montant normal: % 6.2f => TVA: % 6.2f" % (montant_normal, tva_normal)
print "Montant alcool: % 6.2f => TVA: % 6.2f" % (montant_alcool, tva_alcool)
print "-------------------------------------"
for ligne in Facture().rapport_jour(datetime(2011,1,27)):
    print ligne
print "-------------------------------------"
for ligne in Facture().rapport_mois(datetime(2011,1,27)):