Exemplo n.º 1
0
def bill_new(request):
    """ Create a new bill.
    :param HttpRequest request:
    """
    bill = Facture()
    bill.save()
    return bill_view(request, bill.id)
Exemplo n.º 2
0
def bill_new(request):
    """ Create a new bill.
    :param HttpRequest request:
    """
    context = {'menu_bills': True, }
    bill = Facture()
    bill.save()
    return redirect("bill_view", bill.id)
Exemplo n.º 3
0
 def test_add_product_prize(self):
     facture = Facture()
     facture.save()
     plat = ProduitVendu()
     plat.produit = Produit.objects.get(nom="entrecote")
     facture.add_product_prize(plat)
     self.assertEqual(plat.prix, facture.total_ttc)
     self.assertEqual(plat.prix, facture.restant_a_payer)
Exemplo n.º 4
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.º 5
0
def bill_new(request):
    """Create a new bill"""
    data = get_user(request)
    data['menu_bills'] = True
    bill = Facture()
    bill.save()
    data['facture'] = bill
    return render_to_response('base/bill/bill.html', data,
                              context_instance=RequestContext(request))
Exemplo n.º 6
0
 def test_is_valid_payment(self):
     facture = Facture()
     facture.save()
     self.assertFalse(facture.is_valid_payment(42))
     plat = ProduitVendu()
     plat.produit = Produit.objects.get(nom="entrecote")
     facture.add_product(plat)
     self.assertTrue(facture.is_valid_payment(42))
     facture.restant_a_payer = Decimal("0")
     self.assertFalse(facture.is_valid_payment(42))
Exemplo n.º 7
0
 def test_add_payment(self):
     facture = Facture()
     facture.save()
     plat = ProduitVendu()
     plat.produit = Produit.objects.get(nom="entrecote")
     facture.add_product(plat)
     facture.add_payment(PaiementType.objects.get(nom="CB"), "2")
     self.assertEqual(facture.restant_a_payer, Decimal(str(plat.prix - 2)))
     facture.add_payment(PaiementType.objects.get(nom="Espece"), "10")
     self.assertEqual(facture.restant_a_payer, Decimal(0))
     self.assertEqual(Decimal(str(plat.prix - 12)), \
                      (facture.paiements.all()[2]).montant)
Exemplo n.º 8
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.º 9
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.º 10
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.º 11
0
 def test_is_empty(self):
     facture = Facture()
     facture.save()
     self.assertTrue(facture.is_empty())
     plat = ProduitVendu()
     plat.produit = Produit.objects.get(nom="entrecote")
     facture.add_product(plat)
     self.assertFalse(facture.is_empty())
Exemplo n.º 12
0
 def test_rendre_monnaie(self):
     paiement = Paiement.objects.all()[0]
     facture = Facture()
     facture.save()
     plat = ProduitVendu()
     plat.produit = Produit.objects.get(nom="entrecote")
     facture.add_product(plat)
     facture.rendre_monnaie(paiement)
     self.assertEqual(Decimal("-82.80"), facture.paiements.all()[0].montant)
Exemplo n.º 13
0
 def test_del_product(self):
     facture = Facture()
     facture.save()
     plat = ProduitVendu()
     plat.produit = Produit.objects.get(nom="entrecote")
     facture.add_product(plat)
     facture.del_product(plat)
     self.assertTrue(plat not in facture.produits.iterator())
     self.assertEqual(Decimal("0"), facture.total_ttc)
     self.assertEqual(Decimal("0"), facture.restant_a_payer)
Exemplo n.º 14
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.º 15
0
    def test_add_product(self):
        facture = Facture()
        facture.save()
        self.assertTrue(facture.is_empty())

        plat = ProduitVendu()
        plat.produit = Produit.objects.get(nom="entrecote")
        facture.add_product(plat)
        self.assertTrue(plat in facture.produits.iterator())
        self.assertEqual(plat.prix, facture.total_ttc)
        self.assertEqual(plat.prix, facture.restant_a_payer)
Exemplo n.º 16
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.º 17
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.º 18
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.º 19
0
class Tests_Bill(TestCase):
    fixtures = ["demo.json"]

    def setUp(self):
        TestCase.setUp(self)
        self.facture = Facture()
        self.facture.save()
        self.plat = ProduitVendu()
        self.plat.produit = Produit.objects.get(nom="entrecote")

    def test_is_empty(self):
        self.assertTrue(self.facture.is_empty())
        self.facture.add_product(self.plat)
        self.assertFalse(self.facture.is_empty())

    def test_add_product(self):
        self.assertTrue(self.facture.is_empty())
        self.facture.add_product(self.plat)
        self.facture.update()
        self.assertTrue(self.plat in self.facture.produits.iterator())
        self.assertEqual(self.plat.produit.prix, self.facture.total_ttc)
        self.assertEqual(self.plat.produit.prix, self.facture.restant_a_payer)

    def test_del_payment(self):
        payment = Paiement()
        montant = 42
        valeur_unitaire = 73
        paymentType = PaiementType()
        payment.montant = 73
        payment.type = paymentType
        payment.valeur_unitaire = Decimal(valeur_unitaire)
        payment.montant = Decimal(montant)
        self.facture.add_payment(paymentType, montant, valeur_unitaire)
        self.facture.del_payment(payment)

    def test_is_valid_payment(self):
        self.assertFalse(self.facture.is_valid_payment(42))
        self.facture.add_product(self.plat)
        self.facture.update()
        self.assertTrue(self.facture.is_valid_payment(42))
        self.facture.restant_a_payer = Decimal("0")
        self.assertFalse(self.facture.is_valid_payment(42))

    def test_rendre_monnaie(self):
        payment = Paiement()
        payment.type = PaiementType()
        payment.montant = Decimal("900")
        self.facture.add_product(self.plat)
        self.facture.update()
        self.facture.rendre_monnaie(payment)
        left = self.facture.total_ttc - Decimal("900")
        self.assertEqual(left, self.facture.paiements.all()[0].montant)

    def test_add_payment(self):
        self.facture.add_product(self.plat)
        self.facture.update()
        self.facture.add_payment(PaiementType.objects.get(nom="CB"), "2")
        restant_a_payer = Decimal(str(self.plat.produit.prix - 2))
        self.assertEqual(self.facture.restant_a_payer, restant_a_payer)
        self.facture.add_payment(PaiementType.objects.get(nom="Espece"), "10")
        self.assertEqual(self.facture.restant_a_payer, Decimal(0))
        montant = Decimal(str(self.plat.produit.prix - 12))
        self.assertEqual(montant, (self.facture.paiements.all()[2]).montant)
        # TODO This is done just to execute more code
        # An assertion should be verified
        self.facture.print_ticket_kitchen()
        self.facture.est_un_repas()
        self.facture.print_ticket()
Exemplo n.º 20
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.º 21
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.º 22
0
class Tests_Bill(TestCase):
    fixtures = ['demo.json']

    def setUp(self):
        TestCase.setUp(self)
        self.facture = Facture()
        self.facture.save()
        self.plat = ProduitVendu()
        self.plat.produit = Produit.objects.get(nom="entrecote")

    def test_is_empty(self):
        self.assertTrue(self.facture.is_empty())
        self.facture.add_product(self.plat)
        self.assertFalse(self.facture.is_empty())

    def test_add_product(self):
        self.assertTrue(self.facture.is_empty())
        self.facture.add_product(self.plat)
        self.facture.update()
        self.assertTrue(self.plat in self.facture.produits.iterator())
        self.assertEqual(self.plat.produit.prix, self.facture.total_ttc)
        self.assertEqual(self.plat.produit.prix, self.facture.restant_a_payer)

    def test_del_payment(self):
        payment = Paiement()
        montant = 42
        valeur_unitaire = 73
        paymentType = PaiementType()
        payment.montant = 73
        payment.type = paymentType
        payment.valeur_unitaire = Decimal(valeur_unitaire)
        payment.montant = Decimal(montant)
        self.facture.add_payment(paymentType, montant, valeur_unitaire)
        self.facture.del_payment(payment)

    def test_is_valid_payment(self):
        self.assertFalse(self.facture.is_valid_payment(42))
        self.facture.add_product(self.plat)
        self.facture.update()
        self.assertTrue(self.facture.is_valid_payment(42))
        self.facture.restant_a_payer = Decimal("0")
        self.assertFalse(self.facture.is_valid_payment(42))

    def test_rendre_monnaie(self):
        payment = Paiement()
        payment.type = PaiementType()
        payment.montant = Decimal("900")
        self.facture.add_product(self.plat)
        self.facture.update()
        self.facture.rendre_monnaie(payment)
        left = self.facture.total_ttc - Decimal("900")
        self.assertEqual(left, self.facture.paiements.all()[0].montant)

    def test_add_payment(self):
        self.facture.add_product(self.plat)
        self.facture.update()
        self.facture.add_payment(PaiementType.objects.get(nom="CB"), "2")
        restant_a_payer = Decimal(str(self.plat.produit.prix - 2))
        self.assertEqual(self.facture.restant_a_payer, restant_a_payer)
        self.facture.add_payment(PaiementType.objects.get(nom="Espece"), "10")
        self.assertEqual(self.facture.restant_a_payer, Decimal(0))
        montant = Decimal(str(self.plat.produit.prix - 12))
        self.assertEqual(montant, (self.facture.paiements.all()[2]).montant)
        # TODO This is done just to execute more code
        # An assertion should be verified
        self.facture.print_ticket_kitchen()
        self.facture.est_un_repas()
        self.facture.print_ticket()
Exemplo n.º 23
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.º 24
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.º 25
0
 def test_regroup_produits(self):
     facture = Facture()
     facture.save()
     plat1 = ProduitVendu()
     plat1.produit = Produit.objects.get(nom="entrecote")
     plat2 = ProduitVendu()
     plat2.produit = Produit.objects.get(nom="entrecote")
     plat3 = ProduitVendu()
     plat3.produit = Produit.objects.get(nom="pave de saumon")
     entree = ProduitVendu()
     entree.produit = Produit.objects.get(nom="salade normande")
     menu = ProduitVendu()
     menu.produit = Produit.objects.get(nom="jus abricot")
     facture.add_product(plat1)
     facture.add_product(plat2)
     facture.add_product(plat3)
     facture.add_product(entree)
     facture.add_product(menu)
     resultat = OrderedDict([('salade normande', [(entree.id, entree)]),
                             ('entrecote', [(plat1.id, plat1), \
                                            (plat2.id, plat2)]),
                             ('pave de saumon', [(plat3.id, plat3)]),
                             ('jus abricot', [(menu.id, menu)])])
     self.assertEqual(resultat, facture.regroup_produits())
Exemplo n.º 26
0
                value=60 * month).save()
    MonthlyStat(year=2013, month=month, key='nb_bills',
                value=random.randint(50, 500)).save()
    MonthlyStat(year=2013, month=month, key='guests_nb',
                value=random.randint(50, 500)).save()
    MonthlyStat(year=2013, month=month, key='guests_average',
                value=random.randint(50, 500)).save()
    MonthlyStat(year=2013, month=month, key='bar_nb',
                value=random.randint(50, 500)).save()
    MonthlyStat(year=2013, month=month, key='bar_average',
                value=random.randint(50, 500)).save()

# Création d'une dizaine de facture
for i in xrange(15):
    table = 'T%d' % random.randint(10, 25)
    f = Facture(table=Table.objects.get(nom=table),
                couverts=random.randint(1, 15))
    f.save()
    for produit in [salade, buffet, entrecote, pave, biere]:
        for j in xrange(3):
            p = ProduitVendu(produit=produit)
            p.save()
            f.add_product(p)
    nouveau_menu = ProduitVendu(produit=entree_plat)
    nouveau_menu.save()
    for produit in [salade, pave]:
        p = ProduitVendu(produit=produit)
        p.save()
        nouveau_menu.contient.add(p)
    nouveau_menu.save()
    if i % 2:
        f.send_in_the_kitchen()
Exemplo n.º 27
0
cu.execute("select id,date_creation,date_paiement,ttc,ttc_alcool,id_table,nb_couverts from factures %s" % limit)
pbar = progressbar.ProgressBar(maxval=len(cu.fetchall())).start()
cu.execute("select id,date_creation,date_paiement,ttc,ttc_alcool,id_table,nb_couverts from factures %s" % limit)
count = 1
for id,date_creation,date_paiement,ttc,ttc_alcool,id_table,nb_couverts in cu.fetchall():
    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)
    for id,id_mode_paiement,valeur_unitaire,date,montant_ttc in cu.fetchall():
        olddate = str(date)
        newdate = "%s-%s-%s %s:%s:%s" % (olddate[0:4],olddate[4:6],olddate[6:8],olddate[8:10],olddate[10:12],olddate[12:14])
        type = PaiementType_get(id=id_mode_paiement)
        paiement = Paiement(id=id, type=type, facture=facture, montant=convert_prix(montant_ttc), date=newdate)
        paiement.save()
        paiement.date = newdate
        if paiement.type.fixed_value:
Exemplo n.º 28
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.º 29
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)):
Exemplo n.º 30
0
class TestsBill(TestCase):
    fixtures = ['demo.json']

    def setUp(self):
        TestCase.setUp(self)
        self.facture = Facture()
        self.facture.save()
        self.plat = ProduitVendu()
        self.plat.produit = Produit.objects.get(nom="entrecote")

    def test_is_empty(self):
        self.assertTrue(self.facture.is_empty())
        self.facture.add_product(self.plat)
        self.assertFalse(self.facture.is_empty())

    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])

    def test_add_product(self):
        self.assertTrue(self.facture.is_empty())
        self.facture.add_product(self.plat)
        self.facture.update()
        self.assertTrue(self.plat in self.facture.produits.iterator())
        self.assertTrue(self.facture.est_un_repas())
        self.assertEqual(self.plat.produit.prix, self.facture.total_ttc)
        self.assertEqual(self.plat.produit.prix, self.facture.restant_a_payer)

    def test_del_payment(self):
        payment = Paiement()
        montant = 42
        valeur_unitaire = 73
        paymentType = PaiementType()
        payment.montant = 73
        payment.type = paymentType
        payment.valeur_unitaire = Decimal(valeur_unitaire)
        payment.montant = Decimal(montant)
        self.facture.add_payment(paymentType, montant, valeur_unitaire)
        self.facture.del_payment(payment)

    def test_is_valid_payment(self):
        self.assertFalse(self.facture.is_valid_payment(42))
        self.facture.add_product(self.plat)
        self.facture.update()
        self.assertTrue(self.facture.is_valid_payment(42))
        self.facture.restant_a_payer = Decimal("0")
        self.assertFalse(self.facture.is_valid_payment(42))

    def test_rendre_monnaie(self):
        payment = Paiement()
        payment.type = PaiementType()
        payment.montant = Decimal("900")
        self.facture.add_product(self.plat)
        self.facture.update()
        self.facture.rendre_monnaie(payment)
        left = self.facture.total_ttc - Decimal("900")
        self.assertEqual(left, self.facture.paiements.all()[0].montant)

    def test_add_payment(self):
        self.facture.add_product(self.plat)
        self.facture.update()
        self.facture.add_payment(PaiementType.objects.get(nom="CB"), "2")
        restant_a_payer = Decimal(str(self.plat.produit.prix - 2))
        self.assertEqual(self.facture.restant_a_payer, restant_a_payer)
        self.facture.add_payment(PaiementType.objects.get(nom="Espece"), "10")
        self.assertEqual(self.facture.restant_a_payer, Decimal(0))
        montant = Decimal(str(self.plat.produit.prix - 12))
        self.assertEqual(montant, (self.facture.paiements.all()[2]).montant)
        # An assertion should be verified
        self.facture.print_ticket_kitchen()
        self.facture.print_ticket()
Exemplo n.º 31
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())