Пример #1
0
 def save_edit(self):
     ''' add operation '''
     if not self.is_valide():
         return
     print("Save")
     self.member.scoop = self.scoop
     self.member.full_name = self.full_name_field.text()
     self.member.sex = self.sex_box.itemData(self.sex_box.currentIndex())
     self.member.ddn = self.ddn_field.text()
     self.member.addres = self.addres_field.toPlainText()
     self.member.nationality = self.nationality_field.text()
     phone = self.phone_field.text()
     self.member.phone = is_int(phone)
     self.member.poste = self.poste_box.itemData(
         self.poste_box.currentIndex())
     try:
         self.member.save_()
         self.close()
         self.table_p.refresh_()
         self.parent.Notify(
             u"Le membre {} ({}) a été mise à jour".format(
                 self.member.full_name, self.member.poste), "success")
     except peewee.IntegrityError:
         field_error(self.full_name_field,
                     "Ce nom existe dans la basse de donnée.")
Пример #2
0
    def add_or_edit_user(self):
        # print(""" add User """)
        if not self.is_valide():
            print("is not valide")
            return

        username = str(self.username_field.text()).strip()
        password = str(self.password_field.text()).strip()
        phone = str(self.phone_field.text())
        group = self.liste_group[self.box_group.currentIndex()]
        status = False
        if self.checked.checkState() == Qt.Checked:
            status = True

        ow = self.owner
        ow.username = username
        ow.password = Owner().crypt_password(
            password) if self.new else password

        ow.phone = phone
        ow.group = group
        ow.isactive = status
        try:
            ow.save()
            self.close()
            self.accept()
            if self.pp:
                self.pp.refresh_()
                self.parent.Notify("L'identifiant %s a été enregistré" %
                                   ow.username, "success")
        except IntegrityError as e:
            field_error(
                self.name_field, u"L'utilisateurs %s existe déjà dans la base de donnée" % ow.username)
Пример #3
0
 def is_valide(self):
     print("is_valide")
     try:
         self.name_client, self.phone = self.name_client_field.lineEdit().text().split(
             ",")
     except Exception as e:
         # print(e)
         field_error(
             self.name_client_field, "Nom, numéro de téléphone du client")
         return False
     return True
Пример #4
0
 def is_valide(self):
     print("is_valide")
     try:
         self.name_client, self.phone = self.name_client_field.lineEdit(
         ).text().split(",")
     except Exception as e:
         # print(e)
         field_error(self.name_client_field,
                     "Nom, numéro de téléphone du client")
         return False
     return True
Пример #5
0
    def login(self):
        """ """
        if not self.is_valide():
            print("is not valide")
            return

        username = str(self.liste_username[self.box_username.currentIndex()])
        password = Owner().crypt_password(
            str(self.password_field.text()).strip())
        # check completeness

        try:
            Owner.get(
                Owner.username == username, Owner.password == password)
            self.cleaner_db()
        except Exception as e:
            print(e)
            field_error(self.password_field, "Mot de passe incorrect")
            return False
Пример #6
0
    def login(self):
        """ """
        if not self.is_valide():
            print("is not valide")
            return

        username = str(self.liste_username[self.box_username.currentIndex()])
        password = Owner().crypt_password(
            str(self.password_field.text()).strip())
        # check completeness
        for ow in Owner.select().where(Owner.islog == True):
            ow.islog = False
            ow.save()
        try:
            owner = Owner.get(
                Owner.username == username, Owner.password == password)
            owner.islog = True
            owner.save()
        except Exception as e:
            print(e)
            field_error(self.password_field, "Mot de passe incorrect")
            return False
        self.accept()
Пример #7
0
    def add_or_edit_prod(self):

        if not self.is_valide():
            print("is not valide")
            return

        name = str(self.name_field.text())
        category = str(self.category_field.text())
        # number_parts_box = str(self.number_parts_box_field.text())

        product = self.prod
        product.name = name
        # product.number_parts_box = number_parts_box
        product.category = Category.get_or_create(category)

        # try:
        #     if self.path_filename:
        #         fileobj = FileJoin(file_name=self.fileName,
        #                            file_slug=self.path_filename)
        #         fileobj.save()
        #         product.file_join = fileobj
        # except IOError:
        #     self.parent.Notify(u"""<h2>Problème d'import du fichier</h2>
        #         Changer le nom du fichier et reesayé si ça ne fonctionne pas contacté le developper""", "error")
        #     return
        # except Exception as e:
        #     print(e)

        try:
            product.save()
            self.cancel()
            self.table_p.refresh_()
            self.parent.Notify(self.succes_msg, "success")
        except peewee.IntegrityError as e:
            field_error(
                self.name_field, u"""Le produit <b>%s</b> existe déjà dans la basse de donnée.""" % product.name)
            return False
Пример #8
0
    def is_valide(self):
        if check_is_empty(self.denomination_field):
            return False

        if CooperativeCompanie.select().where(
                CooperativeCompanie.denomination ==
                self.denomination_field.text()).exists():
            field_error(
                self.denomination_field,
                "Cette dénomination existe déjà dans la base de données !")
            return False
        if check_is_empty(self.commercial_name_field):
            return False
        if check_is_empty(self.created_date_field):
            return False
        if check_is_empty(self.denomination_field):
            return False
        if check_is_empty(self.apports_numeraire_field):
            return False
        if check_is_empty(self.apports_nature_field):
            return False
        if check_is_empty(self.apports_industrie_field):
            return False
        # if check_is_empty(self.rue_field):
        #     return False
        # if check_is_empty(self.porte_field):
        #     return False
        # print(len(self.tel_field.text()))
        if len(self.tel_field.text()) != 11:
            field_error(self.tel_field, "Numéro requis")
            return False
        # if check_is_empty(self.bp_field):
        #     return False
        # if check_is_empty(self.email_field):
        #     return False
        if check_is_empty(self.duree_statutaire_field):
            return False
        # print(int(self.duree_statutaire_field.text()))
        if int(self.duree_statutaire_field.text()) > 99:
            field_error(
                self.duree_statutaire_field,
                "La durée statutaire ne peut être supérieure à 99 ans")
            return False
        return True
Пример #9
0
    def save_b(self):
        ''' add operation '''
        # entete de la facture
        print("save")
        if not self.is_valide():
            return
        invoice_date = unicode(self.invoice_date.text())
        num_invoice = int(self.num_invoice.text())
        invoice_type = self.liste_type_invoice[
            self.box_type_inv.currentIndex()]
        lis_error = []
        invoice = Invoice()
        try:
            self.owner = Owner.get(Owner.islog == True)
        except:
            lis_error.append("Aucun utilisateur est connecté <br/>")
        paid_amount = int(self.table_invoice.paid_amount_field.text())
        try:
            clt = ProviderOrClient.get_or_create(
                self.name_client, int(self.phone.replace(" ", "")), ProviderOrClient.CLT)
        except ValueError:
            field_error(
                self.name_client_field, "Nom, numéro de téléphone du client")
        invoice.number = num_invoice
        invoice.owner = self.owner
        invoice.client = clt
        invoice.location = "Bamako"
        invoice.type_ = invoice_type
        invoice.subject = ""
        invoice.paid_amount = paid_amount
        invoice.tax = False
        try:
            invoice.save()
            if int(paid_amount) != 0 or invoice_type == Invoice.TYPE_BON:
                Refund(type_=Refund.DT, owner=self.owner, amount=paid_amount,
                       date=date_to_datetime(invoice_date), provider_client=clt,
                       invoice=Invoice.get(number=num_invoice)).save()
        except Exception as e:
            invoice.deletes_data()
            lis_error.append(
                "Erreur sur l'enregistrement d'entête de facture<br/>")
            return False
        # Save invoiceitems
        invoice = Invoice.get(Invoice.number == num_invoice)
        for name, qty, price in self.table_invoice.get_table_items():
            rep = Report()
            product = Product.get(Product.name == name)
            rep.store = 1
            rep.product = product
            rep.invoice = invoice
            rep.type_ = Report.S
            rep.cost_buying = int(product.last_report.cost_buying)
            rep.date = date_to_datetime(invoice_date)
            rep.qty = int(qty)
            rep.selling_price = int(price)
            try:
                rep.save()
            except Exception as e:
                lis_error.append(e)
        if lis_error != []:
            invoice.delete_instance()
            self.parent.Notify(lis_error, "error")
            return False
        else:
            self.parent.Notify("Facture Enregistrée avec succès", "success")

            self.change_main_context(ShowInvoiceViewWidget,
                                     invoice_num=invoice.number)
Пример #10
0
 def save_b(self):
     ''' add operation '''
     # entete de la facture
     print("save")
     if not self.is_valide():
         return
     invoice_date = unicode(self.invoice_date.text())
     num_invoice = int(self.num_invoice.text())
     invoice_type = self.liste_type_invoice[
         self.box_type_inv.currentIndex()]
     lis_error = []
     invoice = Invoice()
     try:
         self.owner = Owner.get(Owner.islog == True)
     except:
         lis_error.append("Aucun utilisateur est connecté <br/>")
     paid_amount = int(self.table_invoice.paid_amount_field.text())
     try:
         clt = ProviderOrClient.get_or_create(
             self.name_client, int(self.phone.replace(" ", "")),
             ProviderOrClient.CLT)
     except ValueError:
         field_error(self.name_client_field,
                     "Nom, numéro de téléphone du client")
     invoice.number = num_invoice
     invoice.owner = self.owner
     invoice.client = clt
     invoice.location = "Bamako"
     invoice.type_ = invoice_type
     invoice.subject = ""
     invoice.paid_amount = paid_amount
     invoice.tax = False
     try:
         invoice.save()
         if int(paid_amount) != 0 or invoice_type == Invoice.TYPE_BON:
             Refund(type_=Refund.DT,
                    owner=self.owner,
                    amount=paid_amount,
                    date=date_to_datetime(invoice_date),
                    provider_client=clt,
                    invoice=Invoice.get(number=num_invoice)).save()
     except Exception as e:
         invoice.deletes_data()
         lis_error.append(
             "Erreur sur l'enregistrement d'entête de facture<br/>")
         return False
     # Save invoiceitems
     invoice = Invoice.get(Invoice.number == num_invoice)
     for name, qty, price in self.table_invoice.get_table_items():
         rep = Report()
         product = Product.get(Product.name == name)
         rep.store = 1
         rep.product = product
         rep.invoice = invoice
         rep.type_ = Report.S
         rep.cost_buying = int(product.last_report.cost_buying)
         rep.date = date_to_datetime(invoice_date)
         rep.qty = int(qty)
         rep.selling_price = int(price)
         try:
             rep.save()
         except Exception as e:
             lis_error.append(e)
     if lis_error != []:
         invoice.delete_instance()
         self.parent.Notify(lis_error, "error")
         return False
     else:
         self.parent.Notify("Facture Enregistrée avec succès", "success")
         self.table_invoice._reset()
         try:
             self.parent.open_dialog(ShowInvoiceViewWidget,
                                     modal=True,
                                     opacity=100,
                                     table_p=self,
                                     invoice_num=invoice.number)
         except Exception as e:
             print(e)