def office_group_box(self): self.organGroupBoxBtt = QGroupBox( self.tr("Configuration des localités")) self.office_box = QComboBox() self.office_box.currentIndexChanged.connect(self.change_select_office) self.office_list = get_offices() self.region_box = QComboBox() self.region_label = FLabel() self.cercle_label = FLabel() self.phone_field = IntLineEdit() self.phone_field.setInputMask('## ## ## ##') self.bp = LineEdit() self.adress_org = QTextEdit() self.email_org = LineEdit() for index, value in enumerate(self.office_list): self.office_box.addItem("{}".format(office_name(value)), value) formbox = QFormLayout() formbox.addRow(FormLabel(u"Nom service :"), self.office_box) formbox.addRow(FormLabel(u"Région"), self.region_label) formbox.addRow(FormLabel(u"Cercle"), self.cercle_label) formbox.addRow(FormLabel(u"Tel :"), self.phone_field) formbox.addRow(FormLabel(u"B.P :"), self.bp) formbox.addRow(FormLabel(u"E-mail :"), self.email_org) formbox.addRow(FormLabel(u"Adresse complete :"), self.adress_org) butt = Button_save(u"Enregistrer") butt.clicked.connect(self.save_edit) formbox.addRow("", butt) self.organGroupBoxBtt.setLayout(formbox)
def __init__(self, table_p, parent, provid_clt=None, type_=None, refund=None, *args, **kwargs): QDialog.__init__(self, parent, *args, **kwargs) self.type_ = type_ self.refund = refund self.parent = parent self.table_p = table_p self.provid_clt = provid_clt self.new = True if self.refund: self.new = False self.last_r = self.refund self.type_ = refund.type_ self.refund_date_field = FormatDate(self.refund.date) self.refund_date_field.setEnabled(False) self.title = u"Modification de {} {}".format(self.refund.type_, self.refund.invoice.client) self.succes_msg = u"{} a été bien mise à jour".format( self.refund.type_) self.amount = refund.amount self.provid_clt = refund.provider_client else: self.refund_date_field = FormatDate(QDate.currentDate()) self.succes_msg = u"Client a été bien enregistré" self.title = u"Création d'un nouvel client" self.amount = "" self.refund = Refund() self.last_r = Refund.select().where( Refund.provider_client == provid_clt).order_by(Refund.date.desc()).get() self.setWindowTitle(self.title) self.amount_field = IntLineEdit(unicode(self.amount)) vbox = QVBoxLayout() self.last_remaining = self.last_r.refund_remaing() # try: # self.last_r.refund_remaing() # self.remaining = self.last_r.remaining # except Exception as e: # self # print("last_r except ", e) # self.last_r = None # self.close() formbox = QFormLayout() formbox.addRow(FormLabel("Client :"), FormLabel(self.provid_clt.name)) formbox.addRow(FormLabel("Dette restante :"), FormLabel(str(formatted_number(self.last_remaining)))) formbox.addRow(FormLabel(u"Date : *"), self.refund_date_field) formbox.addRow(FormLabel(u"Montant : *"), self.amount_field) butt = ButtonSave(u"Enregistrer") butt.clicked.connect(self.save_edit) formbox.addRow("", butt) # formbox.addRow("", "Le client {} n'est pas endetté") vbox.addLayout(formbox) self.setLayout(vbox)
def _item_for_data(self, row, column, data, context=None): if column == 1 or column == 2: self.line_edit = IntLineEdit(u"%s" % data) self.line_edit.textChanged.connect(self.changed_value) self.line_edit.setAlignment(Qt.AlignRight) return self.line_edit return super(InvoiceTableWidget, self)._item_for_data(row, column, data, context)
def __init__(self, parent, dmd=None, *args, **kwargs): super(ImmatriculationSCoopViewWidget, self).__init__( parent=parent, *args, **kwargs) self.parent = parent self.parentWidget().set_window_title("FORMULAIRE D’IMMATRICULATION") self.dmd = dmd self.scoop = self.dmd.scoop self.name_declarant_field = QLineEdit() self.name_declarant_field.setPlaceholderText("M. / Mme") self.name_declarant_field.setMaximumWidth(600) self.procuration_field = QLineEdit() self.procuration_field.setPlaceholderText( "Réf.de la Procuration le cas échéant") self.procuration_field.setMaximumWidth(600) self.quality_box = QComboBox() self.quality_box.setMaximumWidth(600) self.quality_box.currentIndexChanged.connect(self.change_select) self.qualities_list = get_qualities() for index, value in enumerate(self.qualities_list): self.quality_box.addItem( "{}".format(self.qualities_list.get(value).upper()), value) self.type_box = QComboBox() self.type_box.setMaximumWidth(600) self.type_lists = Immatriculation.TYPES for index, value in enumerate(self.type_lists): print(value) self.type_box.addItem("{}".format(value[1], index)) self.tel_declarant_field = IntLineEdit() self.tel_declarant_field.setInputMask('## ## ## ##') self.tel_declarant_field.setMaximumWidth(600) self.btn = Button_save("Sauvegarder") self.btn.setMaximumWidth(600) self.btn.clicked.connect(self.save) declarant_formbox = QFormLayout() declarant_formbox.addRow(FLabel("<strong>Type de d'immatriculation *: </strong>"), self.type_box) declarant_formbox.addRow(FLabel("<strong>Nom et prénom du declarant *: </strong>"), self.name_declarant_field) declarant_formbox.addRow(FLabel("<strong>En qualité de *: </strong>"), self.quality_box) declarant_formbox.addRow(FLabel("<strong>Procuration *: </strong>"), self.procuration_field) declarant_formbox.addRow(FLabel("<strong>Numéro tel. du declarant *: </strong>"), self.tel_declarant_field) declarant_formbox.addRow(FLabel(""), self.btn) self.declarantGroupBox = QGroupBox("Info. du déclarant de la {} *".format(self.scoop.denomination)) self.declarantGroupBox.setStyleSheet(CSS_CENTER) self.declarantGroupBox.setLayout(declarant_formbox) vbox = QVBoxLayout() # vbox.addWidget(self.infoGroupBox) vbox.addWidget(self.declarantGroupBox) # vbox.addLayout(editbox) self.setLayout(vbox)
def organization_group_box(self): self.organGroupBoxBtt = QGroupBox(self.tr("Nouvelle Organisation")) self.liste_devise = Organization.DEVISE # Combobox widget self.box_devise = QComboBox() for index in self.liste_devise: self.box_devise.addItem("{} {}".format( self.liste_devise[index], index)) self.checked = QCheckBox("Active") self.checked.setChecked(True) self.checked.setToolTip(u"""Cocher si vous voulez pour deactive le login continue à utiliser le systeme""") self.name_orga = LineEdit() self.phone = IntLineEdit() self.bp = LineEdit() self.adress_org = QTextEdit() self.email_org = LineEdit() formbox = QFormLayout() formbox.addRow(FormLabel(u"Nom de l'organisation *"), self.name_orga) formbox.addRow(FormLabel(u"Tel *"), self.phone) formbox.addRow( FormLabel(u"Activer la saisie de mot de passe"), self.checked) formbox.addRow(FormLabel(u"Devise"), self.box_devise) formbox.addRow(FormLabel(u"B.P"), self.bp) formbox.addRow(FormLabel(u"E-mail:"), self.email_org) formbox.addRow(FormLabel(u"Adresse complete:"), self.adress_org) butt = Button_save(u"Enregistrer") butt.clicked.connect(self.save_edit) formbox.addRow("", butt) self.organGroupBoxBtt.setLayout(formbox)
def __init__(self, table_p, parent, provid_clt=None, type_=None, refund=None, *args, **kwargs): QDialog.__init__(self, parent, *args, **kwargs) self.type_ = type_ self.refund = refund self.parent = parent self.table_p = table_p self.provid_clt = provid_clt self.new = True if self.refund: self.new = False self.last_r = self.refund self.type_ = refund.type_ self.refund_date_field = FormatDate(self.refund.date) self.refund_date_field.setEnabled(False) self.title = u"Modification de {} {}".format(self.refund.type_, self.refund.invoice.client) self.succes_msg = u"{} a été bien mise à jour".format( self.refund.type_) self.amount = refund.amount self.provid_clt = refund.provider_client else: self.refund_date_field = FormatDate(QDate.currentDate()) self.succes_msg = u"Client a été bien enregistré" self.title = u"Création d'un nouvel client" self.amount = "" self.refund = Refund() self.last_r = Refund.select().where( Refund.provider_client == provid_clt).order_by(Refund.date.desc()).get() self.setWindowTitle(self.title) self.amount_field = IntLineEdit(unicode(self.amount)) vbox = QVBoxLayout() self.last_remaining = self.last_r.refund_remaing() print(self.last_remaining) # try: # self.last_r.refund_remaing() # self.remaining = self.last_r.remaining # except Exception as e: # self # print("last_r except ", e) # self.last_r = None # self.close() formbox = QFormLayout() formbox.addRow(FormLabel("Client :"), FormLabel(self.provid_clt.name)) formbox.addRow(FormLabel("Dette restante :"), FormLabel(str(formatted_number(self.last_remaining)) + Config.DEVISE)) formbox.addRow(FormLabel(u"Date : *"), self.refund_date_field) formbox.addRow(FormLabel(u"Montant : *"), self.amount_field) butt = Button_save(u"Enregistrer") butt.clicked.connect(self.save_edit) formbox.addRow("", butt) # formbox.addRow("", "Le client {} n'est pas endetté") vbox.addLayout(formbox) self.setLayout(vbox)
def _item_for_data(self, row, column, data, context=None): if column == 1 or column == 2 or column == 3: self.line_edit = IntLineEdit(u"%s" % data) self.line_edit.textChanged.connect(self.changed_value) return self.line_edit return super(BuyTableWidget, self)._item_for_data(row, column, data, context)
def __init__(self, table_p, parent, product=None, *args, **kwargs): QDialog.__init__(self, parent, *args, **kwargs) self.table_p = table_p self.prod = product self.parent = parent self.filename = "Parcourire ..." self.path_filename = None if self.prod: self.title = u"Modification de l'article {}".format(self.prod.name) self.succes_msg = u"L'article <b>%s</b> a été mise à jour" % self.prod.name try: self.filename = self.prod.file_join.file_name except: pass else: self.succes_msg = u"L'article a été bien enregistré" self.title = u"Ajout de nouvel article" self.prod = Product() self.setWindowTitle(self.title) # self.code = LineEdit(self.prod.code) self.name_field = LineEdit(self.prod.name) try: self.category_name = Category.select().where( Category.name == self.prod.category.name).get().name except: self.category_name = "" self.category_field = LineEdit(self.category_name) self.number_parts_box_field = IntLineEdit( str(self.prod.number_parts_box)) self.number_parts_box_field.setValidator(QIntValidator()) completion_values = [catg.name for catg in Category.all()] completer = QCompleter(completion_values, parent=self) completer.setCaseSensitivity(Qt.CaseInsensitive) completer.setCompletionMode(QCompleter.UnfilteredPopupCompletion) self.category_field.setCompleter(completer) vbox = QVBoxLayout() formbox = QFormLayout() formbox.addRow(FLabel(u"Nom"), self.name_field) formbox.addRow(FLabel(u"Categorie"), self.category_field) # formbox.addRow( # FLabel(u"Quantité (carton)"), self.number_parts_box_field) self.butt_parco = QPushButton( QIcon.fromTheme('document-open', QIcon('')), self.filename) self.butt_parco.clicked.connect(self.import_image) butt_cancel = Warning_btt(u"Annuler") butt_cancel.clicked.connect(self.cancel) # formbox.addRow(FLabel(u"Image"), self.butt_parco) butt = Button_save(u"&Enregistrer") butt.clicked.connect(self.add_or_edit_prod) formbox.addRow(butt_cancel, butt) vbox.addLayout(formbox) self.setLayout(vbox)
def __init__(self, pp=None, owner=None, parent=None, *args, **kwargs): QDialog.__init__(self, parent, *args, **kwargs) self.setWindowTitle(u"Nouvel utilisateur") self.parent = parent self.pp = pp self.owner = owner vbox = QVBoxLayout() formbox = QFormLayout() self.checked = QCheckBox("Active") self.error_mssg = "" if self.owner: self.new = False self.title = u"Modification de l'utilisateur {}".format( self.owner.username) self.succes_msg = u"L'utilisateur a été bien mise à jour" if self.owner.isactive: self.checked.setCheckState(Qt.Checked) else: self.checked.setCheckState(Qt.Checked) self.new = True self.succes_msg = u"L'utilisateur a été bien enregistré" self.title = u"Création d'un nouvel utilisateur" self.owner = Owner() # self.checked.setToolTip(msg) self.setWindowTitle(self.title) self.username_field = LineEdit(self.owner.username) self.username_field.setEnabled(self.new) self.password_field = LineEdit() self.password_field.setEchoMode(LineEdit.PasswordEchoOnEdit) self.password_field_v = LineEdit() self.password_field_v.setEchoMode(LineEdit.PasswordEchoOnEdit) self.password_field_v.textChanged.connect( self.check_password_is_valide) self.phone_field = IntLineEdit(self.owner.phone) self.liste_group = [Owner.ADMIN, Owner.USER] # Combobox widget self.box_group = QComboBox() for index in self.liste_group: self.box_group.addItem(u'%(group)s' % {'group': index}) butt = Button_save(u"Enregistrer") butt.clicked.connect(self.add_or_edit_user) cancel_but = Button(u"Annuler") cancel_but.clicked.connect(self.cancel) formbox.addRow(FLabel(u"Identifiant"), self.username_field) formbox.addRow(FLabel(u"Mot de passe"), self.password_field) if self.new: formbox.addRow( FLabel(u"Verification du Mot de passe"), self.password_field_v) formbox.addRow(FLabel(u"Numero de Téléphone"), self.phone_field) formbox.addRow(FLabel(u"Groupe"), self.box_group) formbox.addRow(cancel_but, butt) vbox.addWidget(self.checked) vbox.addLayout(formbox) self.setLayout(vbox)
def __init__(self, table_p, parent, type_=None, payment=None, *args, **kwargs): QDialog.__init__(self, parent, *args, **kwargs) self.type_ = type_ self.payment = payment self.parent = parent self.table_p = table_p if self.payment: self.new = False self.type_ = payment.type_ self.payment_date_field = FormatDate(self.payment.date) self.payment_date_field.setEnabled(False) self.title = u"Modification de {} {}".format(self.payment.type_, self.payment.libelle) self.succes_msg = u"{} a été bien mise à jour".format( self.payment.type_) if self.type_ == Payment.CREDIT: amount = payment.credit elif self.type_ == Payment.DEBIT: amount = payment.debit else: self.new = True amount = "" self.payment_date_field = FormatDate(QDate.currentDate()) self.succes_msg = u"Client a été bien enregistré" self.title = u"Création d'un nouvel client" self.payment = Payment() self.setWindowTitle(self.title) self.amount_field = IntLineEdit(unicode(amount)) self.libelle_field = QTextEdit(self.payment.libelle) vbox = QVBoxLayout() formbox = QFormLayout() formbox.addRow(FormLabel(u"Date : *"), self.payment_date_field) formbox.addRow(FormLabel(u"Libelle :"), self.libelle_field) formbox.addRow(FormLabel(u"Montant : *"), self.amount_field) butt = ButtonSave(u"Enregistrer") butt.clicked.connect(self.save_edit) formbox.addRow("", butt) vbox.addLayout(formbox) self.setLayout(vbox)
def __init__(self, parent, *args, **kwargs): QDialog.__init__(self, parent, *args, **kwargs) vbox = QVBoxLayout() vbox.addWidget(FBoxTitle(u"<h3>Ajout de contact </h3>")) self.combo_grp = QComboBox() groups = Group() groups.name = "Aucun" self.list_grp = Group.all() self.list_grp.append(groups) self.list_grp.reverse() for index in self.list_grp: sentence = u"%(name)s" % {'name': index.name} self.combo_grp.addItem(sentence) self.full_name = LineEdit() self.msg_e_or_c = FLabel("") self.full_name.setFont(QFont("Arial", 16)) self.phone_number = IntLineEdit() self.phone_number.setInputMask("D9.99.99.99") self.phone_number.setAlignment(Qt.AlignCenter) self.phone_number.setFont(QFont("Arial", 16)) send_butt = Button(u"Enregistrer") send_butt.clicked.connect(self.save_form) cancel_but = Button(u"Fermer") cancel_but.clicked.connect(self.cancel) formbox = QGridLayout() formbox.addWidget(FLabel(u"Groupes:"), 0, 0) formbox.addWidget(self.combo_grp, 1, 0) formbox.addWidget(FLabel(u"Nom complèt: "), 0, 1) formbox.addWidget(self.full_name, 1, 1) formbox.addWidget(FLabel(u"Numéro: "), 0, 2) formbox.addWidget(self.phone_number, 1, 2) formbox.addWidget(send_butt, 2, 1) formbox.addWidget(cancel_but, 2, 0) formbox.addWidget(self.msg_e_or_c, 3, 0, 3, 2) vbox.addLayout(formbox) self.setLayout(vbox)
def extend_rows(self): nb_rows = self.rowCount() self.setRowCount(nb_rows + 3) self.setItem(nb_rows, 2, TotalsWidget(u"Montant")) monttc = TotalsWidget(formatted_number(u"%d" % 0)) self.setItem(nb_rows, 3, monttc) nb_rows += 1 bicon = QIcon.fromTheme('', QIcon(u"{}save.png".format(Config.img_media))) self.button = QPushButton(bicon, u"Enregistrer") self.button.released.connect(self.parent.save_b) self.button.setEnabled(False) self.setItem(nb_rows, 2, TotalsWidget(u"Reste à payer")) self.paid_amount_field = IntLineEdit() self.setCellWidget(nb_rows, 3, self.paid_amount_field) self.setCellWidget(nb_rows + 1, 3, self.button) self.setSpan(nb_rows - 1, 0, 3, 2) pw = self.parent.parent.page_width() / 7 self.setColumnWidth(0, pw * 2) self.setColumnWidth(1, pw) self.setColumnWidth(2, pw)
def _item_for_data(self, row, column, data, context=None): if column == 0: # create check box as our editor. editor = QCheckBox() # editor.itemClicked.connect(self.save_order) if data == 2: editor.setCheckState(2) self.connect(editor, SIGNAL('stateChanged(int)'), self.save_order) return editor if column == 1: line_edit = IntLineEdit(u"%s" % data) line_edit.textChanged.connect(self.save_order) return line_edit return super(OrederTableWidget, self)._item_for_data(row, column, data, context)
def __init__(self, table_p, parent, type_=None, payment=None, *args, **kwargs): QDialog.__init__(self, parent, *args, **kwargs) self.type_ = type_ self.payment = payment self.parent = parent self.table_p = table_p if self.payment: self.new = False self.type_ = payment.type_ self.payment_date_field = FormatDate(self.payment.date) self.payment_date_field.setEnabled(False) self.title = u"Modification de {} {}".format(self.payment.type_, self.payment.libelle) self.succes_msg = u"{} a été bien mise à jour".format( self.payment.type_) if self.type_ == Payment.CREDIT: amount = payment.credit elif self.type_ == Payment.DEBIT: amount = payment.debit else: self.new = True amount = "" self.payment_date_field = FormatDate(QDate.currentDate()) self.succes_msg = u"Client a été bien enregistré" self.title = u"Création d'un nouvel client" self.payment = Payment() self.setWindowTitle(self.title) self.amount_field = IntLineEdit(unicode(amount)) self.libelle_field = QTextEdit(self.payment.libelle) vbox = QVBoxLayout() formbox = QFormLayout() formbox.addRow(FormLabel(u"Date : *"), self.payment_date_field) formbox.addRow(FormLabel(u"Libelle :"), self.libelle_field) formbox.addRow(FormLabel(u"Montant : *"), self.amount_field) butt = Button_save(u"Enregistrer") butt.clicked.connect(self.save_edit) formbox.addRow("", butt) vbox.addLayout(formbox) self.setLayout(vbox)
def __init__(self, parent, *args, **kwargs): super(FWidget, self).__init__(parent=parent, *args, **kwargs) self.organization = Organization().get(id=1) print(self.organization) self.parent = parent vbox = QVBoxLayout() # vbox.addWidget(FPageTitle(u"Utilisateur: %s " % # self.organisation.name_orga)) self.liste_devise = Organization.DEVISE # Combobox widget self.box_devise = QComboBox() for index, value in enumerate(self.liste_devise): self.box_devise.addItem( "{} {}".format(self.liste_devise[value], value)) if self.organization.devise == value: self.box_devise.setCurrentIndex(index) self.checked = QCheckBox("Active") if self.organization.is_login: self.checked.setCheckState(Qt.Checked) self.checked.setToolTip(u"""Cocher si vous voulez pour deactive le login continue à utiliser le systeme""") self.name_orga = LineEdit(self.organization.name_orga) self.phone = IntLineEdit(str(self.organization.phone)) self.bp = LineEdit(self.organization.bp) self.adress_org = QTextEdit(self.organization.adress_org) self.email_org = LineEdit(self.organization.email_org) formbox = QFormLayout() formbox.addRow(FormLabel(u"Nom de l'organisation:"), self.name_orga) formbox.addRow(FormLabel(u"Tel:"), self.phone) formbox.addRow(FormLabel(u"Activer le login"), self.checked) formbox.addRow(FormLabel(u"Devise :"), self.box_devise) formbox.addRow(FormLabel(u"B.P:"), self.bp) formbox.addRow(FormLabel(u"E-mail:"), self.email_org) formbox.addRow(FormLabel(u"Adresse complete:"), self.adress_org) butt = Button_save(u"Enregistrer") butt.clicked.connect(self.save_edit) formbox.addRow("", butt) vbox.addLayout(formbox) self.setLayout(vbox)
def extend_rows(self): nb_rows = self.rowCount() self.setRowCount(nb_rows + 3) self.setItem(nb_rows, 2, TotalsWidget(u"Montant")) monttc = TotalsWidget(formatted_number(u"%d" % 0)) self.setItem(nb_rows, 3, monttc) nb_rows += 1 bicon = QIcon.fromTheme( '', QIcon(u"{}save.png".format(Config.img_media))) self.button = QPushButton(bicon, u"Enregistrer") self.button.released.connect(self.parent.save_b) self.button.setEnabled(False) self.setItem(nb_rows, 2, TotalsWidget(u"Reste à payer")) self.paid_amount_field = IntLineEdit() self.setCellWidget(nb_rows, 3, self.paid_amount_field) self.setCellWidget(nb_rows + 1, 3, self.button) self.setSpan(nb_rows - 1, 0, 3, 2) pw = self.parent.parent.page_width() / 7 self.setColumnWidth(0, pw * 2) self.setColumnWidth(1, pw) self.setColumnWidth(2, pw)
def __init__(self, product="", parent=0, *args, **kwargs): super(InvoiceViewWidget, self).__init__(parent=parent, *args, **kwargs) self.parentWidget().setWindowTitle(Config.APP_NAME + u" Ventes") self.parent = parent vbox = QVBoxLayout() # hbox = QHBoxLayout(self) editbox = QGridLayout() try: next_number = int(Invoice.select().order_by( Invoice.number.desc()).get().number) + 1 except: next_number = 1 self.num_invoice = IntLineEdit(str(next_number)) self.num_invoice.setToolTip(u"Le numéro") self.num_invoice.setMaximumSize( 40, self.num_invoice.maximumSize().height()) self.invoice_date = FormatDate(QDate.currentDate()) # self.name_client_field = LineEdit() self.string_list = [""] + [ "{},{}".format(clt.name, clt.phone) for clt in ProviderOrClient.select().where( ProviderOrClient.type_ == ProviderOrClient.CLT).order_by( ProviderOrClient.name.desc()) ] # self.name_client_field_new = "" self.name_client_field = ExtendedComboBox() self.name_client_field.addItems(self.string_list) self.name_client_field.setMaximumSize( 200, self.name_client_field.maximumSize().height()) self.name_client_field.setToolTip("Nom, numero du client") self.add_clt_btt = BttSmall(u"+") self.add_clt_btt.clicked.connect(self.add_clt) self.add_clt_btt.setFixedWidth(50) # Combobox widget for add store self.liste_type_invoice = [ Invoice.TYPE_FACT, Invoice.TYPE_BON, Invoice.TYPE_PROF ] self.box_type_inv = QComboBox() for index in range(0, len(self.liste_type_invoice)): op = self.liste_type_invoice[index] sentence = u"%(name)s" % {'name': op} self.box_type_inv.addItem(sentence, op) self.search_field = LineEdit() self.search_field.setPlaceholderText("Rechercher un article") self.search_field.textChanged.connect(self.finder) # self.search_field.setFixedWidth(250) self.search_field.setMaximumHeight(40) self.table_invoice = InvoiceTableWidget(parent=self) self.table_resultat = ResultatTableWidget(parent=self) self.table_info = InfoTableWidget(parent=self) self.table_resultat.refresh_("") editbox.addWidget(self.box_type_inv, 0, 2) editbox.addWidget(self.num_invoice, 0, 3) editbox.addWidget(FLabel(u"Doit :"), 1, 2) editbox.addWidget(self.name_client_field, 1, 3) # editbox.addWidget(self.add_clt_btt, 1, 4) editbox.addWidget(self.invoice_date, 0, 6) editbox.setColumnStretch(0, 1) editbox.setColumnStretch(5, 1) splitter = QSplitter(Qt.Horizontal) splitter_left = QSplitter(Qt.Vertical) splitter_left.addWidget(self.search_field) splitter_left.addWidget(self.table_resultat) # splitter_down.resize(15, 20) splitter_down = QSplitter(Qt.Vertical) splitter_down.addWidget(self.table_info) splitter_rigth = QSplitter(Qt.Vertical) # splitter_rigth.setLayout(editbox) splitter_rigth.addWidget(self.table_invoice) splitter_rigth.resize(800, 900) splitter_left.addWidget(splitter_down) splitter.addWidget(splitter_left) splitter.addWidget(splitter_rigth) vbox.addLayout(editbox) vbox.addWidget(splitter) self.setLayout(vbox)
class ContactNewViewWidget(QDialog, FWidget): def __init__(self, parent, *args, **kwargs): QDialog.__init__(self, parent, *args, **kwargs) vbox = QVBoxLayout() vbox.addWidget(FBoxTitle(u"<h3>Ajout de contact </h3>")) self.combo_grp = QComboBox() groups = Group() groups.name = "Aucun" self.list_grp = Group.all() self.list_grp.append(groups) self.list_grp.reverse() for index in self.list_grp: sentence = u"%(name)s" % {'name': index.name} self.combo_grp.addItem(sentence) self.full_name = LineEdit() self.msg_e_or_c = FLabel("") self.full_name.setFont(QFont("Arial", 16)) self.phone_number = IntLineEdit() self.phone_number.setInputMask("D9.99.99.99") self.phone_number.setAlignment(Qt.AlignCenter) self.phone_number.setFont(QFont("Arial", 16)) send_butt = Button(u"Enregistrer") send_butt.clicked.connect(self.save_form) cancel_but = Button(u"Fermer") cancel_but.clicked.connect(self.cancel) formbox = QGridLayout() formbox.addWidget(FLabel(u"Groupes:"), 0, 0) formbox.addWidget(self.combo_grp, 1, 0) formbox.addWidget(FLabel(u"Nom complèt: "), 0, 1) formbox.addWidget(self.full_name, 1, 1) formbox.addWidget(FLabel(u"Numéro: "), 0, 2) formbox.addWidget(self.phone_number, 1, 2) formbox.addWidget(send_butt, 2, 1) formbox.addWidget(cancel_but, 2, 0) formbox.addWidget(self.msg_e_or_c, 3, 0, 3, 2) vbox.addLayout(formbox) self.setLayout(vbox) def cancel(self): self.close() def iscomplet(self): self.phone_number.setStyleSheet("") self.msg_e_or_c.setText("") self.msg_e_or_c.setStyleSheet("") try: int(self.phone_number.text().replace('.', '')) except: self.phone_number.setStyleSheet("border-bottom: 3px solid red;" "background-color:#AFAFAF;") self.phone_number.setToolTip(u"Ce champ est obligatoire.") return False return True def save_form(self): if not self.iscomplet(): return full_name = unicode(self.full_name.text()) phone_number = int(self.phone_number.text().replace('.', '')) try: Contact(number=phone_number, name=full_name).save() except: self.msg_e_or_c.setText(u"Ce numéro existe déjà") self.msg_e_or_c.setStyleSheet("color: red") return grp = unicode(self.list_grp[self.combo_grp.currentIndex()]) if not grp == "Aucun": grp = Group.select().where(Group.name == grp).get() contact = Contact.select().where( Contact.number == phone_number).get() ContactGroup(group=grp.id, contact=contact).save() self.full_name.setText("") self.phone_number.setText("") self.msg_e_or_c.setText( u"Le numéro (<b>{}</b>) à éte bien enregistré".format( phone_number))
def __init__(self, table_p, report, parent, *args, **kwargs): QDialog.__init__(self, parent, *args, **kwargs) self.setWindowTitle(u"Modification") self.table_p = table_p self.rpt = report self.parent = parent self.out_op = True if self.rpt.type_ == Report.E: self.out_op = False self.selling_price_field = IntLineEdit(unicode(self.rpt.selling_price)) self.cost_buying_field = IntLineEdit(unicode(self.rpt.cost_buying)) self.qty_field = IntLineEdit(unicode(self.rpt.qty)) self.date_field = FormatDate(QDate(self.rpt.date)) self.date_field.setEnabled(False) butt = Button(u"Mise à jour") butt.clicked.connect(self.edit_report) cancel_but = Button(u"Annuler") cancel_but.clicked.connect(self.cancel) # Combobox widget i = 0 self.liste_type = [Report.E, Report.S] self.box_type = QComboBox() self.box_type.setEnabled(False) for index in xrange(0, len(self.liste_type)): ty = self.liste_type[index] if ty == self.rpt.type_: i = index sentence = u"%(ty)s" % {'ty': ty} self.box_type.addItem(sentence, ty) self.box_type.setCurrentIndex(i) # Combobox widget # self.liste_store = Store.order_by(desc(Store.id)).all() # self.box_mag = QComboBox() # for index in xrange(0, len(self.liste_store)): # op = self.liste_store[index] # sentence = u"%(name)s" % {'name': op.name} # self.box_mag.addItem(sentence, QVariant(op.id)) # Combobox widget self.liste_product = Product.all() self.box_prod_field = QComboBox() self.box_prod_field.setEnabled(False) for index in xrange(0, len(self.liste_product)): prod = self.liste_product[index] if prod.name == self.rpt.product.name: i = index sentence = u"%(name)s" % {'name': prod.name} self.box_prod_field.addItem(sentence, prod.id) self.box_prod_field.setCurrentIndex(i) vbox = QVBoxLayout() formbox = QFormLayout() # editbox.addWidget(FormLabel((_(u"Store"))), 0, 1) # editbox.addWidget(self.box_mag, 1, 1) formbox.addRow(FormLabel(u"Type"), FormLabel(self.rpt.type_)) formbox.addRow(FormLabel(u"Désignation"), self.box_prod_field) formbox.addRow(FormLabel(u"Quantité"), self.qty_field) formbox.addRow(FormLabel("Prix d'achat"), self.cost_buying_field) formbox.addRow(FormLabel("Prix vente"), self.selling_price_field) formbox.addRow(FormLabel(u"Date"), self.date_field) formbox.addRow(butt, cancel_but) vbox.addLayout(formbox) self.setLayout(vbox)
class ContactNewViewWidget(QDialog, FWidget): def __init__(self, parent, *args, **kwargs): QDialog.__init__(self, parent, *args, **kwargs) vbox = QVBoxLayout() vbox.addWidget(FBoxTitle(u"<h3>Ajout de contact </h3>")) self.combo_grp = QComboBox() groups = Group() groups.name = "Aucun" self.list_grp = Group.all() self.list_grp.append(groups) self.list_grp.reverse() for index in self.list_grp: sentence = u"%(name)s" % {'name': index.name} self.combo_grp.addItem(sentence) self.full_name = LineEdit() self.msg_e_or_c = FLabel("") self.full_name.setFont(QFont("Arial", 16)) self.phone_number = IntLineEdit() self.phone_number.setInputMask("D9.99.99.99") self.phone_number.setAlignment(Qt.AlignCenter) self.phone_number.setFont(QFont("Arial", 16)) send_butt = Button(u"Enregistrer") send_butt.clicked.connect(self.save_form) cancel_but = Button(u"Fermer") cancel_but.clicked.connect(self.cancel) formbox = QGridLayout() formbox.addWidget(FLabel(u"Groupes:"), 0, 0) formbox.addWidget(self.combo_grp, 1, 0) formbox.addWidget(FLabel(u"Nom complèt: "), 0, 1) formbox.addWidget(self.full_name, 1, 1) formbox.addWidget(FLabel(u"Numéro: "), 0, 2) formbox.addWidget(self.phone_number, 1, 2) formbox.addWidget(send_butt, 2, 1) formbox.addWidget(cancel_but, 2, 0) formbox.addWidget(self.msg_e_or_c, 3, 0, 3, 2) vbox.addLayout(formbox) self.setLayout(vbox) def cancel(self): self.close() def iscomplet(self): self.phone_number.setStyleSheet("") self.msg_e_or_c.setText("") self.msg_e_or_c.setStyleSheet("") try: int(self.phone_number.text().replace('.', '')) except: self.phone_number.setStyleSheet("border-bottom: 3px solid red;" "background-color:#AFAFAF;") self.phone_number.setToolTip(u"Ce champ est obligatoire.") return False return True def save_form(self): if not self.iscomplet(): return full_name = unicode(self.full_name.text()) phone_number = int(self.phone_number.text().replace('.', '')) try: Contact(number=phone_number, name=full_name).save() except: self.msg_e_or_c.setText(u"Ce numéro existe déjà") self.msg_e_or_c.setStyleSheet("color: red") return grp = unicode(self.list_grp[self.combo_grp.currentIndex()]) if not grp == "Aucun": grp = Group.select().where(Group.name == grp).get() contact = Contact.select().where(Contact.number == phone_number).get() ContactGroup(group=grp.id, contact=contact).save() self.full_name.setText("") self.phone_number.setText("") self.msg_e_or_c.setText(u"Le numéro (<b>{}</b>) à éte bien enregistré" .format(phone_number))
class EditOrAddProductsDialog(QDialog, FWidget): def __init__(self, table_p, parent, product=None, *args, **kwargs): QDialog.__init__(self, parent, *args, **kwargs) self.table_p = table_p self.prod = product self.parent = parent self.filename = "Parcourire ..." self.path_filename = None if self.prod: self.title = u"Modification de l'article {}".format(self.prod.name) self.succes_msg = u"L'article <b>%s</b> a été mise à jour" % self.prod.name try: self.filename = self.prod.file_join.file_name except: pass else: self.succes_msg = u"L'article a été bien enregistré" self.title = u"Ajout de nouvel article" self.prod = Product() self.setWindowTitle(self.title) # self.code = LineEdit(self.prod.code) self.name_field = LineEdit(self.prod.name) try: self.category_name = Category.select().where( Category.name == self.prod.category.name).get().name except: self.category_name = "" self.category_field = LineEdit(self.category_name) self.number_parts_box_field = IntLineEdit( str(self.prod.number_parts_box)) self.number_parts_box_field.setValidator(QIntValidator()) completion_values = [catg.name for catg in Category.all()] completer = QCompleter(completion_values, parent=self) completer.setCaseSensitivity(Qt.CaseInsensitive) completer.setCompletionMode(QCompleter.UnfilteredPopupCompletion) self.category_field.setCompleter(completer) vbox = QVBoxLayout() formbox = QFormLayout() formbox.addRow(FLabel(u"Nom"), self.name_field) formbox.addRow(FLabel(u"Categorie"), self.category_field) # formbox.addRow( # FLabel(u"Quantité (carton)"), self.number_parts_box_field) self.butt_parco = QPushButton( QIcon.fromTheme('document-open', QIcon('')), self.filename) self.butt_parco.clicked.connect(self.import_image) butt_cancel = Warning_btt(u"Annuler") butt_cancel.clicked.connect(self.cancel) # formbox.addRow(FLabel(u"Image"), self.butt_parco) butt = Button_save(u"&Enregistrer") butt.clicked.connect(self.add_or_edit_prod) formbox.addRow(butt_cancel, butt) vbox.addLayout(formbox) self.setLayout(vbox) def import_image(self): """ """ self.path_filename = QFileDialog.getOpenFileName(self, "Open Image", "", "Documents ({})".format(Config.DOC_SUPPORT),) if self.path_filename: self.fileName = str( os.path.basename(u"{}".format(self.path_filename))) self.butt_parco.setText(self.fileName) def cancel(self): self.close() def is_valide(self): flag = True if (check_is_empty(self.name_field) or check_is_empty(self.category_field) # or check_is_empty(self.number_parts_box_field) ): flag = False return flag 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
class InvoiceTableWidget(FTableWidget): def __init__(self, parent, *args, **kwargs): FTableWidget.__init__(self, parent=parent, *args, **kwargs) self.parent = parent self.pparent = parent.parent self.hheaders = [u"Modeles", u"Quantité", u"Prix Unitaire", u"Montant"] self.setContextMenuPolicy(Qt.CustomContextMenu) self.customContextMenuRequested.connect(self.popup) self.stretch_columns = [0, 2] self.align_map = {3: 'r'} self.display_vheaders = False self.display_fixed = True self.refresh_() self.isvalid = False def refresh_(self, choix=None): if choix: self.row = [u"%s" % choix.name, "", ""] if not [row for row in self.data if self.row[0] in row]: self.set_data_for() self.refresh() def set_data_for(self): self._reset() self.data.extend([self.row]) self.refresh() def popup(self, pos): row = self.selectionModel().selection().indexes()[0].row() if (len(self.data) - 1) < row: return False menu = QMenu() quitAction = menu.addAction("Supprimer cette ligne") action = menu.exec_(self.mapToGlobal(pos)) if action == quitAction: try: self.data.pop(row) except IndexError: pass self.refresh() def extend_rows(self): nb_rows = self.rowCount() self.setRowCount(nb_rows + 3) self.setItem(nb_rows, 2, TotalsWidget(u"Montant")) monttc = TotalsWidget(formatted_number(u"%d" % 0)) self.setItem(nb_rows, 3, monttc) nb_rows += 1 bicon = QIcon.fromTheme('', QIcon(u"{}save.png".format(Config.img_media))) self.button = QPushButton(bicon, u"Enregistrer") self.button.released.connect(self.parent.save_b) self.button.setEnabled(False) self.setItem(nb_rows, 2, TotalsWidget(u"Reste à payer")) self.paid_amount_field = IntLineEdit() self.setCellWidget(nb_rows, 3, self.paid_amount_field) self.setCellWidget(nb_rows + 1, 3, self.button) self.setSpan(nb_rows - 1, 0, 3, 2) pw = self.parent.parent.page_width() / 7 self.setColumnWidth(0, pw * 2) self.setColumnWidth(1, pw) self.setColumnWidth(2, pw) def _update_data(self, row_num, new_data): self.data[row_num] = (self.data[row_num][0], new_data[0], new_data[1], new_data[2]) def _item_for_data(self, row, column, data, context=None): if column == 1 or column == 2: self.line_edit = IntLineEdit(u"%s" % data) self.line_edit.textChanged.connect(self.changed_value) self.line_edit.setAlignment(Qt.AlignRight) return self.line_edit return super(InvoiceTableWidget, self)._item_for_data(row, column, data, context) def get_table_items(self): """ Recupère les elements du tableau """ list_invoice = [] for i in range(self.rowCount() - 3): liste_item = [] row_data = self.data[i] try: liste_item.append(unicode(row_data[0])) liste_item.append(int(row_data[1])) liste_item.append(int(row_data[2])) list_invoice.append(liste_item) except AttributeError: raise liste_item.append("") return list_invoice def changed_value(self, refresh=False): """ Calcule les Resultat """ self.mtt_ht = 0 # self.button.setEnabled(False) for row_num in xrange(0, self.data.__len__()): product = Product.get( Product.name == unicode(self.item(row_num, 0).text())) last_report = product.last_report last_price = product.last_price() qtremaining = last_report.remaining selling_price = last_price invoice_date = unicode(self.parent.invoice_date.text()) qtsaisi = is_int(self.cellWidget(row_num, 1).text()) pusaisi = is_int(self.cellWidget(row_num, 2).text()) if check_is_empty(self.parent.num_invoice): return if check_is_empty(self.parent.name_client_field.lineEdit()): return # if check_field(self.parent.invoice_date, # "Le {} est Inférieure à la date de la dernière rapport (<b>{}</b>)".format(date_to_datetime(invoice_date), last_report.date), (last_report.date > date_to_datetime(invoice_date))): # return if (pusaisi and check_is_empty(self.cellWidget(row_num, 1))): return if (pusaisi and check_is_empty(self.cellWidget(row_num, 2))): return if check_field( self.cellWidget(row_num, 1), u"<b>{}</b> est supérieur à la quantité restante (<b>{}</b>)" .format(qtsaisi, qtremaining), qtremaining < qtsaisi): return if check_field( self.cellWidget(row_num, 2), u"<b>{}</b> est inférieure au prix minimum de vente<b> {} CFA</b>" .format(pusaisi, selling_price), pusaisi < selling_price): print("E") # return montant = (qtsaisi * pusaisi) self.mtt_ht += montant self.setItem(row_num, 3, TotalsWidget(formatted_number(montant))) self._update_data(row_num, [qtsaisi, pusaisi, self.mtt_ht]) self.setItem(row_num + 1, 3, TotalsWidget(formatted_number(self.mtt_ht))) typ = self.parent.liste_type_invoice[ self.parent.box_type_inv.currentIndex()] self.paid_amount_field.setText( str(self.mtt_ht) if typ == Invoice.TYPE_BON else "0") self.button.setEnabled(True)
class InvoiceViewWidget(FWidget): def __init__(self, product="", parent=0, *args, **kwargs): super(InvoiceViewWidget, self).__init__(parent=parent, *args, **kwargs) self.parentWidget().setWindowTitle(Config.APP_NAME + u" Ventes") self.parent = parent vbox = QVBoxLayout() # hbox = QHBoxLayout(self) editbox = QGridLayout() try: next_number = int(Invoice.select().order_by( Invoice.number.desc()).get().number) + 1 except: next_number = 1 self.num_invoice = IntLineEdit(str(next_number)) self.num_invoice.setToolTip(u"Le numéro") self.num_invoice.setMaximumSize( 40, self.num_invoice.maximumSize().height()) self.invoice_date = FormatDate(QDate.currentDate()) # self.name_client_field = LineEdit() self.string_list = [""] + [ "{},{}".format(clt.name, clt.phone) for clt in ProviderOrClient.select().where( ProviderOrClient.type_ == ProviderOrClient.CLT).order_by( ProviderOrClient.name.desc()) ] # self.name_client_field_new = "" self.name_client_field = ExtendedComboBox() self.name_client_field.addItems(self.string_list) self.name_client_field.setMaximumSize( 200, self.name_client_field.maximumSize().height()) self.name_client_field.setToolTip("Nom, numero du client") self.add_clt_btt = BttSmall(u"+") self.add_clt_btt.clicked.connect(self.add_clt) self.add_clt_btt.setFixedWidth(50) # Combobox widget for add store self.liste_type_invoice = [ Invoice.TYPE_FACT, Invoice.TYPE_BON, Invoice.TYPE_PROF ] self.box_type_inv = QComboBox() for index in range(0, len(self.liste_type_invoice)): op = self.liste_type_invoice[index] sentence = u"%(name)s" % {'name': op} self.box_type_inv.addItem(sentence, op) self.search_field = LineEdit() self.search_field.setPlaceholderText("Rechercher un article") self.search_field.textChanged.connect(self.finder) # self.search_field.setFixedWidth(250) self.search_field.setMaximumHeight(40) self.table_invoice = InvoiceTableWidget(parent=self) self.table_resultat = ResultatTableWidget(parent=self) self.table_info = InfoTableWidget(parent=self) self.table_resultat.refresh_("") editbox.addWidget(self.box_type_inv, 0, 2) editbox.addWidget(self.num_invoice, 0, 3) editbox.addWidget(FLabel(u"Doit :"), 1, 2) editbox.addWidget(self.name_client_field, 1, 3) # editbox.addWidget(self.add_clt_btt, 1, 4) editbox.addWidget(self.invoice_date, 0, 6) editbox.setColumnStretch(0, 1) editbox.setColumnStretch(5, 1) splitter = QSplitter(Qt.Horizontal) splitter_left = QSplitter(Qt.Vertical) splitter_left.addWidget(self.search_field) splitter_left.addWidget(self.table_resultat) # splitter_down.resize(15, 20) splitter_down = QSplitter(Qt.Vertical) splitter_down.addWidget(self.table_info) splitter_rigth = QSplitter(Qt.Vertical) # splitter_rigth.setLayout(editbox) splitter_rigth.addWidget(self.table_invoice) splitter_rigth.resize(800, 900) splitter_left.addWidget(splitter_down) splitter.addWidget(splitter_left) splitter.addWidget(splitter_rigth) vbox.addLayout(editbox) vbox.addWidget(splitter) self.setLayout(vbox) def add_clt(self): from GCommon.ui.provider_client_edit_add import EditOrAddClientOrProviderDialog self.open_dialog(EditOrAddClientOrProviderDialog, modal=True, prov_clt=None, table_p=self) def finder(self): search_term = self.search_field.text() value = unicode(search_term) self.table_resultat.refresh_(value) 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 def refresh_(self): pass 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)
class InvoiceTableWidget(FTableWidget): def __init__(self, parent, *args, **kwargs): FTableWidget.__init__(self, parent=parent, *args, **kwargs) self.parent = parent self.pparent = parent.parent self.hheaders = [u"Modeles", u"Quantité", u"Prix Unitaire", u"Montant"] self.setContextMenuPolicy(Qt.CustomContextMenu) self.customContextMenuRequested.connect(self.popup) self.stretch_columns = [0, 2] self.align_map = {3: 'r'} self.display_vheaders = False self.display_fixed = True self.refresh_() self.isvalid = False def refresh_(self, choix=None): if choix: self.row = [u"%s" % choix.name, "", ""] if not [row for row in self.data if self.row[0] in row]: self.set_data_for() self.refresh() def set_data_for(self): self._reset() self.data.extend([self.row]) self.refresh() def popup(self, pos): row = self.selectionModel().selection().indexes()[0].row() if (len(self.data) - 1) < row: return False menu = QMenu() quitAction = menu.addAction("Supprimer cette ligne") action = menu.exec_(self.mapToGlobal(pos)) if action == quitAction: try: self.data.pop(row) except IndexError: pass self.refresh() def extend_rows(self): nb_rows = self.rowCount() self.setRowCount(nb_rows + 3) self.setItem(nb_rows, 2, TotalsWidget(u"Montant")) monttc = TotalsWidget(formatted_number(u"%d" % 0)) self.setItem(nb_rows, 3, monttc) nb_rows += 1 bicon = QIcon.fromTheme( '', QIcon(u"{}save.png".format(Config.img_media))) self.button = QPushButton(bicon, u"Enregistrer") self.button.released.connect(self.parent.save_b) self.button.setEnabled(False) self.setItem(nb_rows, 2, TotalsWidget(u"Reste à payer")) self.paid_amount_field = IntLineEdit() self.setCellWidget(nb_rows, 3, self.paid_amount_field) self.setCellWidget(nb_rows + 1, 3, self.button) self.setSpan(nb_rows - 1, 0, 3, 2) pw = self.parent.parent.page_width() / 7 self.setColumnWidth(0, pw * 2) self.setColumnWidth(1, pw) self.setColumnWidth(2, pw) def _update_data(self, row_num, new_data): self.data[row_num] = (self.data[row_num][0], new_data[0], new_data[1], new_data[2]) def _item_for_data(self, row, column, data, context=None): if column == 1 or column == 2: self.line_edit = IntLineEdit(u"%s" % data) self.line_edit.textChanged.connect(self.changed_value) self.line_edit.setAlignment(Qt.AlignRight) return self.line_edit return super(InvoiceTableWidget, self)._item_for_data(row, column, data, context) def get_table_items(self): """ Recupère les elements du tableau """ list_invoice = [] for i in range(self.rowCount() - 3): liste_item = [] row_data = self.data[i] try: liste_item.append(unicode(row_data[0])) liste_item.append(int(row_data[1])) liste_item.append(int(row_data[2])) list_invoice.append(liste_item) except AttributeError: raise liste_item.append("") return list_invoice def changed_value(self, refresh=False): """ Calcule les Resultat """ self.mtt_ht = 0 # self.button.setEnabled(False) for row_num in xrange(0, self.data.__len__()): product = Product.get( Product.name == unicode(self.item(row_num, 0).text())) last_report = product.last_report last_price = product.last_price() qtremaining = last_report.remaining selling_price = last_price invoice_date = unicode(self.parent.invoice_date.text()) qtsaisi = is_int(self.cellWidget(row_num, 1).text()) pusaisi = is_int(self.cellWidget(row_num, 2).text()) if check_is_empty(self.parent.num_invoice): return if check_is_empty(self.parent.name_client_field.lineEdit()): return # if check_field(self.parent.invoice_date, # "Le {} est Inférieure à la date de la dernière rapport (<b>{}</b>)".format(date_to_datetime(invoice_date), last_report.date), (last_report.date > date_to_datetime(invoice_date))): # return if (pusaisi and check_is_empty(self.cellWidget(row_num, 1))): return if (pusaisi and check_is_empty(self.cellWidget(row_num, 2))): return if check_field(self.cellWidget(row_num, 1), u"<b>{}</b> est supérieur à la quantité restante (<b>{}</b>)".format( qtsaisi, qtremaining), qtremaining < qtsaisi): return if check_field(self.cellWidget(row_num, 2), u"<b>{}</b> est inférieure au prix minimum de vente<b> {} CFA</b>".format( pusaisi, selling_price), pusaisi < selling_price): print("E") # return montant = (qtsaisi * pusaisi) self.mtt_ht += montant self.setItem(row_num, 3, TotalsWidget(formatted_number(montant))) self._update_data(row_num, [qtsaisi, pusaisi, self.mtt_ht]) self.setItem( row_num + 1, 3, TotalsWidget(formatted_number(self.mtt_ht))) typ = self.parent.liste_type_invoice[ self.parent.box_type_inv.currentIndex()] self.paid_amount_field.setText( str(self.mtt_ht) if typ == Invoice.TYPE_BON else "0") self.button.setEnabled(True)
class InvoiceViewWidget(FWidget): def __init__(self, product="", parent=0, *args, **kwargs): super(InvoiceViewWidget, self).__init__(parent=parent, *args, **kwargs) self.parentWidget().setWindowTitle(Config.NAME_ORGA + u" FACTURATION") self.parent = parent vbox = QVBoxLayout(self) hbox = QHBoxLayout(self) editbox = QGridLayout() self.num_invoice = IntLineEdit("%d" % (Invoice.select().count() + 1)) self.num_invoice.setToolTip(u"Le numéro de la facture") self.num_invoice.setMaximumSize(40, self.num_invoice.maximumSize().height()) self.num_invoice_error = ErrorLabel("") self.invoice_date = FormatDate(QDate.currentDate()) self.name_client = QLineEdit() self.name_client.setMaximumSize(200, self.name_client.maximumSize().height()) self.name_client.setToolTip("Taper le nom du client") self.name_client_error = ErrorLabel("") self.search_field = QLineEdit() self.search_field.setMaximumSize(200, self.search_field.maximumSize().height()) self.search_field.textChanged.connect(self.finder) self.vline = QFrame() self.vline.setFrameShape(QFrame.VLine) self.vline.setFrameShadow(QFrame.Sunken) self.table_invoice = OrderTableWidget(parent=self) self.table_resultat = ResultatTableWidget(parent=self) self.table_info = InfoTableWidget(parent=self) self.table_resultat.refresh_("") editbox.addWidget(FormLabel(u"Recherche:"), 0, 0) editbox.addWidget(self.search_field, 1, 0) editbox.addWidget(self.vline, 0, 1, 2, 5) editbox.addWidget(FormLabel(u"Facture N°:"), 0, 2) editbox.addWidget(self.num_invoice, 0, 3) editbox.addWidget(self.num_invoice_error, 0, 4) editbox.addWidget(FormLabel(u"Doit:"), 1, 2) editbox.addWidget(self.name_client, 1, 3) editbox.addWidget(self.name_client_error, 1, 4) editbox.addWidget(FormLabel(u"Date:"), 0, 5) editbox.addWidget(self.invoice_date, 0, 6) splitter = QSplitter(Qt.Horizontal) splitter_left = QSplitter(Qt.Vertical) splitter_down = QSplitter(Qt.Vertical) splitter_left.addWidget(FBoxTitle(u"Les resultats")) splitter_left.addWidget(self.table_resultat) splitter_down.resize(15, 20) splitter_down.addWidget(self.table_info) splitter_rigth = QSplitter(Qt.Vertical) splitter_rigth.addWidget(FBoxTitle(u"Les produits vendus")) splitter_rigth.addWidget(self.table_invoice) splitter_rigth.resize(500, 900) splitter_left.addWidget(splitter_down) splitter.addWidget(splitter_left) splitter.addWidget(splitter_rigth) hbox.addWidget(splitter) vbox.addLayout(editbox) vbox.addLayout(hbox) self.setLayout(vbox) def finder(self): completion_values = [] search_term = self.search_field.text() # try: # products = Product.select().where(Product.name.icontains(search_term)) # except ValueError: # pass # for product in products: # last_r = product.last_report_by_prod() # try: # completion_values.append(last_r.product.__str__()) # except: # pass # completer = QCompleter(completion_values, parent=self) # completer.setCaseSensitivity(Qt.CaseInsensitive) # completer.setCompletionMode(QCompleter.UnfilteredPopupCompletion) # self.search_field.setCompleter(completer) self.table_resultat.refresh_(search_term) def save_b(self): ''' add operation ''' # entete de la facture if not self.table_invoice.isvalid: return False try: num_invoice = int(self.num_invoice.text()) self.num_invoice_error.setText(u"") except: self.pixmap = QPixmap(u"{img_media}{img}".format(img_media=Config.img_media, img="warning.png")) self.num_invoice.setStyleSheet("background-color: rgb(255, 235, 235);") self.num_invoice_error.setToolTip(u"Le numero de facture est obligatoire.") self.num_invoice_error.setPixmap(self.pixmap) invoice_date = str(self.invoice_date.text()) name_client = str(self.name_client.text()) datetime_ = date_to_datetime(invoice_date) values_t = self.table_invoice.get_table_items() if name_client == "": self.name_client.setStyleSheet("background-color: rgb(255, 235, 235);") self.pixmap = QPixmap(u"{img_media}{img}".format(img_media=Config.img_media, img="decline.png")) self.name_client_error.setToolTip(u"Nom du client est obligatoire.") self.name_client_error.setPixmap(self.pixmap) return False # if num_invoice > Config.credit: # raise_error(("Avertisement"), u"<h2>Veuillez payer la reste de la licence</h2>") # return False invoice = Invoice() try: invoice.owner = Owner.get(islog=True) except: if Config.DEBUG: invoice.owner = Owner.get(username='******') else: return False invoice.number = num_invoice invoice.date_ord = datetime_ invoice.client = name_client.capitalize() invoice.location = "Bamako" invoice.type_ = "Facture" invoice.subject = "" invoice.tax = False invoice.otax_rate = 18 try: invoice.save() except: raise_error("Erreur", u"Impossible d'enregistrer l'entête de la facture") return False # Save orderitems try: order = Invoice.get(number=num_invoice) except: return False for i in values_t: qty, name, price = i description = Product.filter(name=name).get() item = InvoiceItem() item.invoices = invoice.id item.quantity = int(i[0]) item.description = description item.price = int(i[2]) try: item.save() self.name_client.clear() self.num_invoice.clear() except Exception as e: print(e) invoice.delete_instance() raise_error("Erreur", u"Ce mouvement n'a pas pu etre " u"enregistré dans les rapports") return False self.change_main_context(ShowInvoiceViewWidget, invoice=invoice)
class NewOrEditOfficeViewWidget(QDialog, FWidget): def __init__(self, pp=None, owner=None, parent=None, *args, **kwargs): QDialog.__init__(self, parent, *args, **kwargs) self.setWindowTitle(u"Nouvel Organisation") self.parent = parent vbox = QVBoxLayout() self.office_group_box() vbox.addWidget(self.organGroupBoxBtt) self.setLayout(vbox) def office_group_box(self): self.organGroupBoxBtt = QGroupBox( self.tr("Configuration des localités")) self.office_box = QComboBox() self.office_box.currentIndexChanged.connect(self.change_select_office) self.office_list = get_offices() self.region_box = QComboBox() self.region_label = FLabel() self.cercle_label = FLabel() self.phone_field = IntLineEdit() self.phone_field.setInputMask('## ## ## ##') self.bp = LineEdit() self.adress_org = QTextEdit() self.email_org = LineEdit() for index, value in enumerate(self.office_list): self.office_box.addItem("{}".format(office_name(value)), value) formbox = QFormLayout() formbox.addRow(FormLabel(u"Nom service :"), self.office_box) formbox.addRow(FormLabel(u"Région"), self.region_label) formbox.addRow(FormLabel(u"Cercle"), self.cercle_label) formbox.addRow(FormLabel(u"Tel :"), self.phone_field) formbox.addRow(FormLabel(u"B.P :"), self.bp) formbox.addRow(FormLabel(u"E-mail :"), self.email_org) formbox.addRow(FormLabel(u"Adresse complete :"), self.adress_org) butt = Button_save(u"Enregistrer") butt.clicked.connect(self.save_edit) formbox.addRow("", butt) self.organGroupBoxBtt.setLayout(formbox) def change_select_office(self): select_o = self.office_box.itemData(self.office_box.currentIndex()) self.r_select = office_region(select_o) self.c_select = office_cercle(select_o) self.region_label.setText(get_entity_name(self.r_select)) self.cercle_label.setText(get_entity_name(self.c_select)) def is_valide(self): if check_is_empty(self.phone_field): return False return True def save_edit(self): ''' add operation ''' if not self.is_valide(): return office = Office() office.slug = self.office_box.itemData(self.office_box.currentIndex()) office.slug_region = self.r_select office.slug_cercle = self.c_select office.phone = is_int(self.phone_field.text()) office.email_org = str(self.email_org.text()) office.bp = str(self.bp.text()) office.adress_org = str(self.adress_org.toPlainText()) office.save_() self.accept()
class EditOrAddMemberDialog(QDialog, FWidget): def __init__(self, table_p, parent, scoop=None, member=None, *args, **kwargs): FWidget.__init__(self, parent, *args, **kwargs) self.table_p = table_p self.member = member self.scoop = scoop self.parent = parent full_name = "" self.ddn_field = FormatDate(QDate(QDate.currentDate())) addres = "" nationality = "" phone = "" if self.member: self.new = False full_name = self.member.full_name mddn = self.member.ddn if mddn: day, month, year = mddn.split("/") ddn = datetime.strptime(mddn, '%d/%m/%Y') self.ddn_field.setDate(QDate(ddn)) addres = self.member.addres nationality = self.member.nationality phone = str(self.member.phone or "") self.title = u"Modification de {}".format(self.member) self.succes_msg = u"{} a été bien mise à jour".format(self.member) else: self.new = True self.succes_msg = u"Client a été bien enregistré" self.title = u"Ajout nouveau membre" self.member = CooperativeMember() self.setWindowTitle(self.title) vbox = QVBoxLayout() # vbox.addWidget(FPageTitle(u"Utilisateur: %s " % self.member.name)) self.full_name_field = LineEdit(full_name) self.sex_list = CooperativeMember.SEX.items() # Combobox widget self.sex_box = QComboBox() for index, value in enumerate(self.sex_list): # form = self.sex_list[index] self.sex_box.addItem("{}".format(value[1].upper()), value[0]) if self.member.sex == value[0]: self.sex_box.setCurrentIndex(index) # print("DE", ddn) # self.ddn_field.setDate(ddn) # self.ddn_field = QDateEdit(QDate(ddn)) self.addres_field = QTextEdit(addres) self.nationality_field = LineEdit(nationality) self.phone_field = IntLineEdit(phone) self.phone_field.setInputMask("## ## ## ##") self.poste_list = get_postes() self.poste_box = QComboBox() for index, value in enumerate(self.poste_list): self.poste_box.addItem( "{}".format(self.poste_list.get(value).upper()), value) if self.member.poste == value: print(value) self.poste_box.setCurrentIndex(index) formbox = QFormLayout() formbox.addRow(FormLabel(u"Nom complet : *"), self.full_name_field) formbox.addRow(FormLabel(u"Sexe *:"), self.sex_box) formbox.addRow(FormLabel(u"Date de naissance *:"), self.ddn_field) formbox.addRow(FormLabel(u"Poste occupé *:"), self.poste_box) formbox.addRow(FormLabel(u"Nationalité *:"), self.nationality_field) formbox.addRow(FormLabel(u"Téléphone :"), self.phone_field) formbox.addRow(FormLabel(u"Adresse :"), self.addres_field) butt = Button(u"Enregistrer") butt.clicked.connect(self.save_edit) formbox.addRow("", butt) vbox.addLayout(formbox) self.setLayout(vbox) def is_valide(self): if check_is_empty(self.full_name_field): return False if check_is_empty(self.ddn_field): return False if check_is_empty(self.nationality_field): return False if check_is_empty(self.phone_field): return False return True 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.")
def __init__(self, product="", parent=0, *args, **kwargs): super(InvoiceViewWidget, self).__init__(parent=parent, *args, **kwargs) self.parentWidget().setWindowTitle(Config.NAME_ORGA + u" FACTURATION") self.parent = parent vbox = QVBoxLayout(self) hbox = QHBoxLayout(self) editbox = QGridLayout() self.num_invoice = IntLineEdit("%d" % (Invoice.select().count() + 1)) self.num_invoice.setToolTip(u"Le numéro de la facture") self.num_invoice.setMaximumSize(40, self.num_invoice.maximumSize().height()) self.num_invoice_error = ErrorLabel("") self.invoice_date = FormatDate(QDate.currentDate()) self.name_client = QLineEdit() self.name_client.setMaximumSize(200, self.name_client.maximumSize().height()) self.name_client.setToolTip("Taper le nom du client") self.name_client_error = ErrorLabel("") self.search_field = QLineEdit() self.search_field.setMaximumSize(200, self.search_field.maximumSize().height()) self.search_field.textChanged.connect(self.finder) self.vline = QFrame() self.vline.setFrameShape(QFrame.VLine) self.vline.setFrameShadow(QFrame.Sunken) self.table_invoice = OrderTableWidget(parent=self) self.table_resultat = ResultatTableWidget(parent=self) self.table_info = InfoTableWidget(parent=self) self.table_resultat.refresh_("") editbox.addWidget(FormLabel(u"Recherche:"), 0, 0) editbox.addWidget(self.search_field, 1, 0) editbox.addWidget(self.vline, 0, 1, 2, 5) editbox.addWidget(FormLabel(u"Facture N°:"), 0, 2) editbox.addWidget(self.num_invoice, 0, 3) editbox.addWidget(self.num_invoice_error, 0, 4) editbox.addWidget(FormLabel(u"Doit:"), 1, 2) editbox.addWidget(self.name_client, 1, 3) editbox.addWidget(self.name_client_error, 1, 4) editbox.addWidget(FormLabel(u"Date:"), 0, 5) editbox.addWidget(self.invoice_date, 0, 6) splitter = QSplitter(Qt.Horizontal) splitter_left = QSplitter(Qt.Vertical) splitter_down = QSplitter(Qt.Vertical) splitter_left.addWidget(FBoxTitle(u"Les resultats")) splitter_left.addWidget(self.table_resultat) splitter_down.resize(15, 20) splitter_down.addWidget(self.table_info) splitter_rigth = QSplitter(Qt.Vertical) splitter_rigth.addWidget(FBoxTitle(u"Les produits vendus")) splitter_rigth.addWidget(self.table_invoice) splitter_rigth.resize(500, 900) splitter_left.addWidget(splitter_down) splitter.addWidget(splitter_left) splitter.addWidget(splitter_rigth) hbox.addWidget(splitter) vbox.addLayout(editbox) vbox.addLayout(hbox) self.setLayout(vbox)
class EditOrAddPaymentrDialog(QDialog, FWidget): def __init__(self, table_p, parent, type_=None, payment=None, *args, **kwargs): QDialog.__init__(self, parent, *args, **kwargs) self.type_ = type_ self.payment = payment self.parent = parent self.table_p = table_p if self.payment: self.new = False self.type_ = payment.type_ self.payment_date_field = FormatDate(self.payment.date) self.payment_date_field.setEnabled(False) self.title = u"Modification de {} {}".format(self.payment.type_, self.payment.libelle) self.succes_msg = u"{} a été bien mise à jour".format( self.payment.type_) if self.type_ == Payment.CREDIT: amount = payment.credit elif self.type_ == Payment.DEBIT: amount = payment.debit else: self.new = True amount = "" self.payment_date_field = FormatDate(QDate.currentDate()) self.succes_msg = u"Client a été bien enregistré" self.title = u"Création d'un nouvel client" self.payment = Payment() self.setWindowTitle(self.title) self.amount_field = IntLineEdit(unicode(amount)) self.libelle_field = QTextEdit(self.payment.libelle) vbox = QVBoxLayout() formbox = QFormLayout() formbox.addRow(FormLabel(u"Date : *"), self.payment_date_field) formbox.addRow(FormLabel(u"Libelle :"), self.libelle_field) formbox.addRow(FormLabel(u"Montant : *"), self.amount_field) butt = Button_save(u"Enregistrer") butt.clicked.connect(self.save_edit) formbox.addRow("", butt) vbox.addLayout(formbox) self.setLayout(vbox) def save_edit(self): ''' add operation ''' if check_is_empty(self.amount_field): return payment_date = unicode(self.payment_date_field.text()) libelle = unicode(self.libelle_field.toPlainText()) amount = int(self.amount_field.text().replace(" ", "")) payment = self.payment payment.type_ = self.type_ payment.libelle = libelle if self.new: payment.date = date_to_datetime(payment_date) if self.type_ == Payment.CREDIT: payment.credit = amount elif self.type_ == Payment.DEBIT: payment.debit = amount try: payment.save() self.close() self.parent.Notify(u"le {type} {lib} à été enregistré avec succès".format( type=self.type_, lib=libelle), "success") self.table_p.refresh_() except Exception as e: self.parent.Notify(e, "error")
class InvoiceViewWidget(FWidget): def __init__(self, product="", parent=0, *args, **kwargs): super(InvoiceViewWidget, self).__init__(parent=parent, *args, **kwargs) self.parentWidget().setWindowTitle( Config.APP_NAME + u" Ventes") self.parent = parent vbox = QVBoxLayout(self) # hbox = QHBoxLayout(self) editbox = QGridLayout(self) try: next_number = int( Invoice.select().order_by(Invoice.number.desc()).get().number) + 1 except: next_number = 1 self.num_invoice = IntLineEdit(str(next_number)) self.num_invoice.setToolTip(u"Le numéro") self.num_invoice.setMaximumSize( 40, self.num_invoice.maximumSize().height()) self.invoice_date = FormatDate(QDate.currentDate()) # self.name_client_field = LineEdit() self.string_list = [""] + ["{},{}".format(clt.name, clt.phone) for clt in ProviderOrClient.select().where( ProviderOrClient.type_ == ProviderOrClient.CLT).order_by(ProviderOrClient.name.desc())] # self.name_client_field_new = "" self.name_client_field = ExtendedComboBox() self.name_client_field.addItems(self.string_list) self.name_client_field.setMaximumSize( 200, self.name_client_field.maximumSize().height()) self.name_client_field.setToolTip("Nom, numero du client") self.add_clt_btt = BttSmall(u"+") self.add_clt_btt.clicked.connect(self.add_clt) self.add_clt_btt.setFixedWidth(50) # Combobox widget for add store self.liste_type_invoice = [Invoice.TYPE_FACT, Invoice.TYPE_BON] self.box_type_inv = QComboBox() for index in range(0, len(self.liste_type_invoice)): op = self.liste_type_invoice[index] sentence = u"%(name)s" % {'name': op} self.box_type_inv.addItem(sentence, op) self.search_field = LineEdit() self.search_field.setPlaceholderText("Rechercher un article") self.search_field.textChanged.connect(self.finder) # self.search_field.setFixedWidth(250) self.table_invoice = InvoiceTableWidget(parent=self) self.table_resultat = ResultatTableWidget(parent=self) self.table_info = InfoTableWidget(parent=self) self.table_resultat.refresh_("") editbox.addWidget(self.box_type_inv, 0, 2) editbox.addWidget(self.num_invoice, 0, 3) editbox.addWidget(FLabel(u"Doit :"), 1, 2) editbox.addWidget(self.name_client_field, 1, 3) # editbox.addWidget(self.add_clt_btt, 1, 4) editbox.addWidget(self.invoice_date, 0, 6) editbox.setColumnStretch(0, 1) editbox.setColumnStretch(5, 1) splitter = QSplitter(Qt.Horizontal) splitter_left = QSplitter(Qt.Vertical) splitter_left.addWidget(self.search_field) splitter_left.addWidget(self.table_resultat) # splitter_down.resize(15, 20) splitter_down = QSplitter(Qt.Vertical) splitter_down.addWidget(self.table_info) splitter_rigth = QSplitter(Qt.Vertical) # splitter_rigth.setLayout(editbox) splitter_rigth.addWidget(self.table_invoice) splitter_rigth.resize(800, 900) splitter_left.addWidget(splitter_down) splitter.addWidget(splitter_left) splitter.addWidget(splitter_rigth) vbox.addLayout(editbox) vbox.addWidget(splitter) self.setLayout(vbox) def add_clt(self): from GCommon.ui.provider_client_edit_add import EditOrAddClientOrProviderDialog self.open_dialog(EditOrAddClientOrProviderDialog, modal=True, prov_clt=None, table_p=self) def finder(self): search_term = self.search_field.text() value = unicode(search_term) self.table_resultat.refresh_(value) 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 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)
class RefundEditAddDialog(QDialog, FWidget): def __init__(self, table_p, parent, provid_clt=None, type_=None, refund=None, *args, **kwargs): QDialog.__init__(self, parent, *args, **kwargs) self.type_ = type_ self.refund = refund self.parent = parent self.table_p = table_p self.provid_clt = provid_clt self.new = True if self.refund: self.new = False self.last_r = self.refund self.type_ = refund.type_ self.refund_date_field = FormatDate(self.refund.date) self.refund_date_field.setEnabled(False) self.title = u"Modification de {} {}".format(self.refund.type_, self.refund.invoice.client) self.succes_msg = u"{} a été bien mise à jour".format( self.refund.type_) self.amount = refund.amount self.provid_clt = refund.provider_client else: self.refund_date_field = FormatDate(QDate.currentDate()) self.succes_msg = u"Client a été bien enregistré" self.title = u"Création d'un nouvel client" self.amount = "" self.refund = Refund() self.last_r = Refund.select().where( Refund.provider_client == provid_clt).order_by(Refund.date.desc()).get() self.setWindowTitle(self.title) self.amount_field = IntLineEdit(unicode(self.amount)) vbox = QVBoxLayout() self.last_remaining = self.last_r.refund_remaing() print(self.last_remaining) # try: # self.last_r.refund_remaing() # self.remaining = self.last_r.remaining # except Exception as e: # self # print("last_r except ", e) # self.last_r = None # self.close() formbox = QFormLayout() formbox.addRow(FormLabel("Client :"), FormLabel(self.provid_clt.name)) formbox.addRow(FormLabel("Dette restante :"), FormLabel(str(formatted_number(self.last_remaining)) + Config.DEVISE)) formbox.addRow(FormLabel(u"Date : *"), self.refund_date_field) formbox.addRow(FormLabel(u"Montant : *"), self.amount_field) butt = Button_save(u"Enregistrer") butt.clicked.connect(self.save_edit) formbox.addRow("", butt) # formbox.addRow("", "Le client {} n'est pas endetté") vbox.addLayout(formbox) self.setLayout(vbox) def save_edit(self): ''' add operation ''' if check_is_empty(self.amount_field): return amount = int(self.amount_field.text()) refund_date = unicode(self.refund_date_field.text()) # self.remaining = self.last_r.remaining if check_field( self.amount_field, "Ce montant ne peut être supperieur au dettes restante {}.".format( self.last_remaining), amount > self.last_remaining): return refund = self.refund refund.type_ = self.type_ refund.invoice = self.last_r.invoice refund.amount = amount if self.new: refund.provider_client = self.provid_clt refund.date = date_to_datetime(refund_date) try: refund.save() self.close() self.parent.Notify(u"le {type} {lib} à été enregistré avec succès".format( type=self.type_, lib=amount), "success") self.table_p.refresh_(self.provid_clt.id) except Exception as e: self.parent.Notify(e, "error")
def __init__(self, parent=0, *args, **kwargs): super(RegistrationViewWidget, self).__init__(parent=parent, *args, **kwargs) self.parent = parent self.parentWidget().set_window_title("FORMULAIRE D’IMMATRICULATION") self.title = FLabel("<h3>FORMULAIRE D’IMMATRICULATION</h3>") self.office = Office.select().where(Office.id == 1).get() self.created_date_field = FormatDate(QDate.currentDate()) self.created_date_field.setMaximumWidth(130) # self.created_date_field.setInputMask('##/##/####') self.rue_field = IntLineEdit() self.porte_field = IntLineEdit() self.tel_field = IntLineEdit() self.tel_field.setInputMask('## ## ## ##') self.tel2_field = IntLineEdit() self.tel2_field.setInputMask('## ## ## ##') self.bp_field = IntLineEdit() self.email_field = LineEdit() self.denomination_field = LineEdit() self.commercial_name_field = LineEdit() self.declaration_date_field = FormatDate(QDate.currentDate()) self.declaration_date_field.setMaximumWidth(130) self.amount_capital_social_initial = FLabel() self.amount_part_social_field = IntLineEdit() self.apports_numeraire_field = IntLineEdit() self.apports_numeraire_field.textChanged.connect(self.cal_total) self.apports_nature_field = IntLineEdit() self.apports_nature_field.textChanged.connect(self.cal_total) self.apports_industrie_field = IntLineEdit() self.apports_industrie_field.textChanged.connect(self.cal_total) self.duree_statutaire_field = IntLineEdit() self.duree_statutaire_field.setMaximumWidth(80) self.spinneret_box = QComboBox() self.spinneret_box.setMaximumWidth(800) self.activites_box = QComboBox() self.activites_box.setMaximumWidth(800) self.activites_box.currentIndexChanged.connect(self.sp_change_select) self.activities_list = get_activities() for index, value in enumerate(self.activities_list): self.activites_box.addItem( "{}".format(self.activities_list.get(value).upper()), value) # if self.store and self.store.name == op.name: # self.box_store.setCurrentIndex(index) self.formes_box = QComboBox() self.formes_box.setMaximumWidth(800) self.formes_list = get_formes() for index, value in enumerate(self.formes_list): self.formes_box.addItem( "{}".format(self.formes_list.get(value).upper()), value) self.commune_list = entity_children(self.office.slug_cercle).items() self.commune_box = ExtendedComboBox() for index, value in enumerate(self.commune_list): self.commune_box.addItem("{}".format(value[1].upper()), value[0]) # self.commune_box.addItems(self.commune_list) self.commune_box.setToolTip("commune") self.commune_box.currentIndexChanged.connect(self.c_change_select) # self.vfq_list = self.get_vfq_list() self.vfq_box = ExtendedComboBox() self.vfq_list = self.get_vfq_list() for index, value in enumerate(self.vfq_list): self.vfq_box.addItem("{}".format(self.vfq_list.get(value).upper()), value) self.vfq_box.setToolTip("vfq") formbox = QFormLayout() formbox.addRow(FLabel(DATE_DEMANTE), self.declaration_date_field) formbox.addRow(FLabel("1. " + DENOMINATION_S_SC), self.denomination_field) formbox.addRow(FLabel("2. " + NOM_COMMERCIAL), self.commercial_name_field) formbox.addRow(FLabel("3. " + DATE_CREATION_SC), self.created_date_field) formbox.addRow(FLabel("4. " + ACTIVITES_E), self.activites_box) formbox.addRow(FLabel("5. " + FILIERE), self.spinneret_box) formbox.addRow(FLabel("6. " + FORME_SC), self.formes_box) # Capital Social Initial capital_formbox = QFormLayout() capital_formbox.addRow(FLabel("7.1. " + MONTANT_PART_S), self.amount_part_social_field) capital_formbox.addRow(FLabel("7.2. " + MONTANT_APPORTS_NUM), self.apports_numeraire_field) capital_formbox.addRow(FLabel("7.3. " + MONTANT_APPORTS_NAT), self.apports_nature_field) capital_formbox.addRow(FLabel("7.4. " + MONTANT_APPORTS_INDU), self.apports_industrie_field) self.capitalSGroupBox = QGroupBox("7. " + MONTANT_CAPITAL_SI) self.capitalSGroupBox.setLayout(capital_formbox) self.capitalSGroupBox.setStyleSheet(CSS) # self.capitalSGroupBox.setMaximumWidth(1300) # Adresse du siège social self.vline = QFrame() self.vline.setFrameShape(QFrame.VLine) self.vline.setFrameShadow(QFrame.Sunken) self.addresGroupBox = QGroupBox("8. " + ADRESSE_SS) self.addresGroupBox.setStyleSheet(CSS) addres_gribox = QGridLayout() addres_gribox.addWidget(FRLabel(CERCLE), 0, 0) addres_gribox.addWidget(FLabel(self.office.cercle_name()), 0, 1) addres_gribox.addWidget(FRLabel(COMMUNE), 1, 0) addres_gribox.addWidget(self.commune_box, 1, 1) # addres_gribox.addWidget(self.vline, 0, 3, 2, 5) addres_gribox.addWidget(FRLabel(VFQ), 2, 0) addres_gribox.addWidget(self.vfq_box, 2, 1) addres_gribox.addWidget(FRLabel(RUE), 0, 2) addres_gribox.addWidget(self.rue_field, 0, 3) addres_gribox.addWidget(FRLabel(PORTE), 1, 2) addres_gribox.addWidget(self.porte_field, 1, 3) addres_gribox.addWidget(FRLabel(BP), 0, 4) addres_gribox.addWidget(self.bp_field, 0, 5) addres_gribox.addWidget(FRLabel(EMAIL), 1, 4) addres_gribox.addWidget(self.email_field, 1, 5) addres_gribox.addWidget(FRLabel(TEL), 2, 2) addres_gribox.addWidget(self.tel_field, 2, 3) addres_gribox.addWidget(FRLabel(TEL2), 2, 4) addres_gribox.addWidget(self.tel2_field, 2, 5) # addres_gribox.setColumnStretch(6, 5) self.addresGroupBox.setLayout(addres_gribox) # self.addresGroupBox.setMaximumWidth(1300) # Durée statutaire de la société coopérative duree_fbox = QFormLayout() duree_fbox.addRow(FLabel("9. " + DUREE_STATUTAIRE_SC), self.duree_statutaire_field) butt = Button_save(SAVE) butt.clicked.connect(self.save_and_goto_manager) butt_and_continous = Button_save(SAVE_AND_CONTINNUES) butt_and_continous.clicked.connect(self.save_and_goto_add_member) butt_and_continous.setMaximumWidth(300) duree_fbox.addRow(FLabel(""), FLabel("")) duree_fbox.addRow(butt, butt_and_continous) vbox = QVBoxLayout() vbox.addLayout(formbox) vbox.addWidget(self.capitalSGroupBox) vbox.addWidget(self.addresGroupBox) vbox.addLayout(duree_fbox) self.setLayout(vbox)
class ImmatriculationSCoopViewWidget(FWidget): def __init__(self, parent, dmd=None, *args, **kwargs): super(ImmatriculationSCoopViewWidget, self).__init__( parent=parent, *args, **kwargs) self.parent = parent self.parentWidget().set_window_title("FORMULAIRE D’IMMATRICULATION") self.dmd = dmd self.scoop = self.dmd.scoop self.name_declarant_field = QLineEdit() self.name_declarant_field.setPlaceholderText("M. / Mme") self.name_declarant_field.setMaximumWidth(600) self.procuration_field = QLineEdit() self.procuration_field.setPlaceholderText( "Réf.de la Procuration le cas échéant") self.procuration_field.setMaximumWidth(600) self.quality_box = QComboBox() self.quality_box.setMaximumWidth(600) self.quality_box.currentIndexChanged.connect(self.change_select) self.qualities_list = get_qualities() for index, value in enumerate(self.qualities_list): self.quality_box.addItem( "{}".format(self.qualities_list.get(value).upper()), value) self.type_box = QComboBox() self.type_box.setMaximumWidth(600) self.type_lists = Immatriculation.TYPES for index, value in enumerate(self.type_lists): print(value) self.type_box.addItem("{}".format(value[1], index)) self.tel_declarant_field = IntLineEdit() self.tel_declarant_field.setInputMask('## ## ## ##') self.tel_declarant_field.setMaximumWidth(600) self.btn = Button_save("Sauvegarder") self.btn.setMaximumWidth(600) self.btn.clicked.connect(self.save) declarant_formbox = QFormLayout() declarant_formbox.addRow(FLabel("<strong>Type de d'immatriculation *: </strong>"), self.type_box) declarant_formbox.addRow(FLabel("<strong>Nom et prénom du declarant *: </strong>"), self.name_declarant_field) declarant_formbox.addRow(FLabel("<strong>En qualité de *: </strong>"), self.quality_box) declarant_formbox.addRow(FLabel("<strong>Procuration *: </strong>"), self.procuration_field) declarant_formbox.addRow(FLabel("<strong>Numéro tel. du declarant *: </strong>"), self.tel_declarant_field) declarant_formbox.addRow(FLabel(""), self.btn) self.declarantGroupBox = QGroupBox("Info. du déclarant de la {} *".format(self.scoop.denomination)) self.declarantGroupBox.setStyleSheet(CSS_CENTER) self.declarantGroupBox.setLayout(declarant_formbox) vbox = QVBoxLayout() # vbox.addWidget(self.infoGroupBox) vbox.addWidget(self.declarantGroupBox) # vbox.addLayout(editbox) self.setLayout(vbox) def change_select(self): self.qlt_select = self.quality_box.itemData( self.quality_box.currentIndex()) self.procuration_field.setEnabled(False) if self.qlt_select == Immatriculation.TP: self.procuration_field.setEnabled(True) # if check_is_empty(self.procuration_field): # return False def is_not_valide(self): # print(check_is_empty(self.name_declarant_field)) if self.quality_box.itemData(self.quality_box.currentIndex()) == Immatriculation.TP: if check_is_empty(self.procuration_field) or check_is_empty(self.tel_declarant_field): return True return check_is_empty(self.name_declarant_field) or check_is_empty(self.tel_declarant_field) def save(self): if self.is_not_valide(): return False imma = Immatriculation() imma.scoop = self.scoop imma.typ_imm = self.type_lists[self.type_box.currentIndex()][0] imma.name_declarant = self.name_declarant_field.text() imma.quality = self.quality_box.itemData(self.quality_box.currentIndex()) imma.procuration = self.procuration_field.text() imma.tel_declarant = self.tel_declarant_field.text() imma.save_ident() self.dmd.status = self.dmd.ENDPROCCES self.dmd.save_() self.parent.change_context(ResgistrationManagerWidget)
def __init__(self, product="", parent=0, *args, **kwargs): super(InvoiceViewWidget, self).__init__(parent=parent, *args, **kwargs) self.parentWidget().setWindowTitle( Config.APP_NAME + u" Ventes") self.parent = parent vbox = QVBoxLayout(self) # hbox = QHBoxLayout(self) editbox = QGridLayout(self) try: next_number = int( Invoice.select().order_by(Invoice.number.desc()).get().number) + 1 except: next_number = 1 self.num_invoice = IntLineEdit(str(next_number)) self.num_invoice.setToolTip(u"Le numéro") self.num_invoice.setMaximumSize( 40, self.num_invoice.maximumSize().height()) self.invoice_date = FormatDate(QDate.currentDate()) # self.name_client_field = LineEdit() self.string_list = [""] + ["{},{}".format(clt.name, clt.phone) for clt in ProviderOrClient.select().where( ProviderOrClient.type_ == ProviderOrClient.CLT).order_by(ProviderOrClient.name.desc())] # self.name_client_field_new = "" self.name_client_field = ExtendedComboBox() self.name_client_field.addItems(self.string_list) self.name_client_field.setMaximumSize( 200, self.name_client_field.maximumSize().height()) self.name_client_field.setToolTip("Nom, numero du client") self.add_clt_btt = BttSmall(u"+") self.add_clt_btt.clicked.connect(self.add_clt) self.add_clt_btt.setFixedWidth(50) # Combobox widget for add store self.liste_type_invoice = [Invoice.TYPE_FACT, Invoice.TYPE_BON] self.box_type_inv = QComboBox() for index in range(0, len(self.liste_type_invoice)): op = self.liste_type_invoice[index] sentence = u"%(name)s" % {'name': op} self.box_type_inv.addItem(sentence, op) self.search_field = LineEdit() self.search_field.setPlaceholderText("Rechercher un article") self.search_field.textChanged.connect(self.finder) # self.search_field.setFixedWidth(250) self.table_invoice = InvoiceTableWidget(parent=self) self.table_resultat = ResultatTableWidget(parent=self) self.table_info = InfoTableWidget(parent=self) self.table_resultat.refresh_("") editbox.addWidget(self.box_type_inv, 0, 2) editbox.addWidget(self.num_invoice, 0, 3) editbox.addWidget(FLabel(u"Doit :"), 1, 2) editbox.addWidget(self.name_client_field, 1, 3) # editbox.addWidget(self.add_clt_btt, 1, 4) editbox.addWidget(self.invoice_date, 0, 6) editbox.setColumnStretch(0, 1) editbox.setColumnStretch(5, 1) splitter = QSplitter(Qt.Horizontal) splitter_left = QSplitter(Qt.Vertical) splitter_left.addWidget(self.search_field) splitter_left.addWidget(self.table_resultat) # splitter_down.resize(15, 20) splitter_down = QSplitter(Qt.Vertical) splitter_down.addWidget(self.table_info) splitter_rigth = QSplitter(Qt.Vertical) # splitter_rigth.setLayout(editbox) splitter_rigth.addWidget(self.table_invoice) splitter_rigth.resize(800, 900) splitter_left.addWidget(splitter_down) splitter.addWidget(splitter_left) splitter.addWidget(splitter_rigth) vbox.addLayout(editbox) vbox.addWidget(splitter) self.setLayout(vbox)
class NewOrEditUserViewWidget(QDialog, FWidget): def __init__(self, pp=None, owner=None, parent=None, *args, **kwargs): QDialog.__init__(self, parent, *args, **kwargs) self.setWindowTitle(u"Nouvel utilisateur") self.parent = parent self.pp = pp self.owner = owner vbox = QVBoxLayout() formbox = QFormLayout() self.checked = QCheckBox("Active") self.error_mssg = "" if self.owner: self.new = False self.title = u"Modification de l'utilisateur {}".format( self.owner.username) self.succes_msg = u"L'utilisateur a été bien mise à jour" if self.owner.isactive: self.checked.setCheckState(Qt.Checked) else: self.checked.setCheckState(Qt.Checked) self.new = True self.succes_msg = u"L'utilisateur a été bien enregistré" self.title = u"Création d'un nouvel utilisateur" self.owner = Owner() # self.checked.setToolTip(msg) self.setWindowTitle(self.title) self.username_field = LineEdit(self.owner.username) self.username_field.setEnabled(self.new) self.password_field = LineEdit() self.password_field.setEchoMode(LineEdit.PasswordEchoOnEdit) self.password_field_v = LineEdit() self.password_field_v.setEchoMode(LineEdit.PasswordEchoOnEdit) self.password_field_v.textChanged.connect( self.check_password_is_valide) self.phone_field = IntLineEdit(self.owner.phone) self.liste_group = [Owner.ADMIN, Owner.USER] # Combobox widget self.box_group = QComboBox() for index in self.liste_group: self.box_group.addItem(u'%(group)s' % {'group': index}) butt = Button_save(u"Enregistrer") butt.clicked.connect(self.add_or_edit_user) cancel_but = Button(u"Annuler") cancel_but.clicked.connect(self.cancel) formbox.addRow(FLabel(u"Identifiant"), self.username_field) formbox.addRow(FLabel(u"Mot de passe"), self.password_field) if self.new: formbox.addRow( FLabel(u"Verification du Mot de passe"), self.password_field_v) formbox.addRow(FLabel(u"Numero de Téléphone"), self.phone_field) formbox.addRow(FLabel(u"Groupe"), self.box_group) formbox.addRow(cancel_but, butt) vbox.addWidget(self.checked) vbox.addLayout(formbox) self.setLayout(vbox) def cancel(self): self.close() def is_valide(self): # print("isactive") if (check_is_empty(self.username_field)): return False if (check_is_empty(self.password_field)): return False if (self.new and check_is_empty(self.password_field_v)): return False if (not self.check_password_is_valide()): return False return True def check_password_is_valide(self): self.password = str(self.password_field.text()) self.password_v = str( self.password_field_v.text()) if self.new else self.owner.password if is_valide_codition_field( self.password_field_v, "Les mots de passe sont differents" if self.new else "Mot de passe incorrect", self.password != self.password_v): return return True 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)
class NewOrEditOrganizationViewWidget(QDialog, FWidget): def __init__(self, pp=None, owner=None, parent=None, *args, **kwargs): QDialog.__init__(self, parent, *args, **kwargs) self.setWindowTitle(u"Nouvel Organisation") self.parent = parent self.pp = pp self.owner = owner vbox = QVBoxLayout() self.organization_group_box() vbox.addWidget(self.organGroupBoxBtt) self.setLayout(vbox) def organization_group_box(self): self.organGroupBoxBtt = QGroupBox(self.tr("Nouvelle Organisation")) self.liste_devise = Organization.DEVISE # Combobox widget self.box_devise = QComboBox() for index in self.liste_devise: self.box_devise.addItem("{} {}".format( self.liste_devise[index], index)) self.checked = QCheckBox("Active") self.checked.setChecked(True) self.checked.setToolTip(u"""Cocher si vous voulez pour deactive le login continue à utiliser le systeme""") self.name_orga = LineEdit() self.phone = IntLineEdit() self.bp = LineEdit() self.adress_org = QTextEdit() self.email_org = LineEdit() formbox = QFormLayout() formbox.addRow(FormLabel(u"Nom de l'organisation *"), self.name_orga) formbox.addRow(FormLabel(u"Tel *"), self.phone) formbox.addRow( FormLabel(u"Activer la saisie de mot de passe"), self.checked) formbox.addRow(FormLabel(u"Devise"), self.box_devise) formbox.addRow(FormLabel(u"B.P"), self.bp) formbox.addRow(FormLabel(u"E-mail:"), self.email_org) formbox.addRow(FormLabel(u"Adresse complete:"), self.adress_org) butt = Button_save(u"Enregistrer") butt.clicked.connect(self.save_edit) formbox.addRow("", butt) self.organGroupBoxBtt.setLayout(formbox) def save_edit(self): ''' add operation ''' if check_is_empty(self.name_orga): return if check_is_empty(self.phone): return name_orga = str(self.name_orga.text()) device = str(self.box_devise.currentText().split()[1]) bp = str(self.bp.text()) email_org = str(self.email_org.text()) phone = str(self.phone.text()) adress_org = str(self.adress_org.toPlainText()) org = Organization() org.phone = phone org.device = device org.name_orga = name_orga org.email_org = email_org org.bp = bp org.adress_org = adress_org org.is_login = True if self.checked.checkState( ) == Qt.Checked else False org.save() self.accept()
def __init__(self, parent=0, dmd=None, *args, **kwargs): super(CheckListViewWidget, self).__init__( parent=parent, *args, **kwargs) self.parent = parent self.dmd = dmd self.check_list = self.dmd.check_list self.parentWidget().set_window_title("Check-list") row = 0 self.piecesGroupBox = QGroupBox("") # self.piecesGroupBox.setStyleSheet("color: gray; background:#fff") pieces_v_gribox = QGridLayout() css = "font-size:26px;border: 3px solid #000;background: black;color: white;" pieces_v_gribox.addWidget(FHeader( "I. Pièces à vérifier (au dépôt)", css), row, 0, 1, 6) row += 1 self.qualite_declarant_check = self.check_box(QCheckBox()) self.qualite_declarant_check.setChecked( self.check_list.qualite_declarant_check) pieces_v_gribox.addWidget(FRLabel( "Qualité du déclarant (Président, mandataire ou auxiliaire de Justice) "), row, 0) pieces_v_gribox.addWidget(self.qualite_declarant_check, row, 1) # row += 1 self.status_check = self.check_box(QCheckBox("(4)")) self.status_check.setChecked(self.check_list.status_check) pieces_v_gribox.addWidget(FRLabel("Statuts "), row, 2) pieces_v_gribox.addWidget(self.status_check, row, 3) self.pieces_check = self.check_box(QCheckBox("(4)")) self.pieces_check.setChecked(self.check_list.pieces_check) pieces_v_gribox.addWidget( FRLabel("Règlement Intérieur "), row, 4) pieces_v_gribox.addWidget(self.pieces_check, row, 5) row += 1 self.autorisation_pre_immt_check = self.check_box(QCheckBox()) self.autorisation_pre_immt_check.setChecked( self.check_list.autorisation_pre_immt_check) pieces_v_gribox.addWidget(FRLabel( "Autorisations préalables pour les activités réglementées "), row, 0) pieces_v_gribox.addWidget(self.autorisation_pre_immt_check, row, 1) self.demande_immt_check = self.check_box(QCheckBox("(2)")) self.demande_immt_check.setChecked(self.check_list.demande_immt_check) pieces_v_gribox.addWidget( FRLabel("Demande d’Immatriculation "), row, 2) pieces_v_gribox.addWidget(self.demande_immt_check, row, 3) self.pv_check = self.check_box(QCheckBox("(4)")) self.pv_check.setChecked(self.check_list.pv_check) pieces_v_gribox.addWidget(FRLabel("PV "), row, 4) pieces_v_gribox.addWidget(self.pv_check, row, 5) row = 0 pieces_gribox = QGridLayout() self.chronologique_check = self.check_box(QCheckBox()) self.chronologique_check.setChecked( self.check_list.chronologique_check) pieces_gribox.addWidget(FLabel( "Vérifier l’existence du registre des membres tenu par ordre chronologique "), row, 0) pieces_gribox.addWidget(self.chronologique_check, row, 1) pieces_gribox.addWidget(FHeader( "SCOOPS Art 235 et 236 COOP-CA Art 320, 321, 322 et 323", "font-size:15px"), row, 2) row += 1 self.compte_check = self.check_box(QCheckBox()) self.compte_check.setChecked(self.check_list.compte_check) pieces_gribox.addWidget(FLabel( "Vérifier l’existence d’un compte bancaire / Institution de Micro Finance"), row, 0) pieces_gribox.addWidget(self.compte_check, row, 1) pieces_gribox.addWidget(FHeader( "Art 213", "font-size:15px"), row, 2) row += 1 self.dispositions_check = self.check_box(QCheckBox()) self.dispositions_check.setChecked(self.check_list.dispositions_check) pieces_gribox.addWidget(FLabel( "Vérifier le respect des dispositions sur le non cumul des mandats"), row, 0) pieces_gribox.addWidget(self.dispositions_check, row, 1) pieces_gribox.addWidget(FHeader( "Art 300 et 326", "font-size:15px"), row, 2) row += 1 self.pv_delib_ca_check = self.check_box(QCheckBox()) self.pv_delib_ca_check.setChecked(self.check_list.pv_delib_ca_check) pieces_gribox.addWidget(FLabel( "Vérifier l’existence du registre des procès- verbaux de délibération du CA <br/> des COOP-CA coté et paraphé par le tribunal civil compétent"), row, 0) pieces_gribox.addWidget(self.pv_delib_ca_check, row, 1) pieces_gribox.addWidget(FHeader( "Art : 235, (d’ordre général) et COOP-CA 320", "font-size:15px"), row, 2) pieces_gribox.setColumnStretch(row, 2) row = 0 mentions_gribox = QGridLayout() mentions_gribox.addWidget(FHeader( " II. Mentions à vérifier dans les Statuts et le Règlement Intérieur", css), row, 0, 1, 4) row += 1 css = "color:blue;font-size:26px;border: 1px solid #000;background: black;color: white;" mentions_gribox.addWidget(FHeader("Mentions", css=css), row, 0) mentions_gribox.addWidget( FHeader("N° Art des Statuts", css=css), row, 1) mentions_gribox.addWidget(FHeader("N° Art du R.I", css=css), row, 2) mentions_gribox.addWidget( FHeader("Référence OHADA", css=css), row, 3) row += 1 self.forme_scoop_status_field = IntLineEdit(self.rest_d( self.check_list.forme_scoop_status)) self.forme_scoop_ri_field = IntLineEdit(self.rest_d( self.check_list.forme_scoop_ri)) self.add_element(mentions_gribox, row, "<b>01.</b> La forme de la société coopérative", self.forme_scoop_status_field, self.forme_scoop_ri_field, "Art 204 ,215 et 216 Pour la SCOOPS / Art 267 et de 271 à 290 Pour la COOP-CA") row += 1 self.denomination_status_field = IntLineEdit(self.rest_d( self.check_list.denomination_status)) self.denomination_ri_field = IntLineEdit(self.rest_d( self.check_list.denomination_ri)) self.add_element(mentions_gribox, row, "<b>02.</b> Sa dénomination suivie, le cas échéant, de son sigle", self.denomination_status_field, self.denomination_ri_field, "Art 19 et Art 205 Pour la SCOOPS<br/> Art 19 et 205 Pour COOP-CA") row += 1 self.nature_domaine_status_field = IntLineEdit(self.rest_d( self.check_list.nature_domaine_status)) self.nature_domaine_ri_field = IntLineEdit(self.rest_d( self.check_list.nature_domaine_ri)) self.add_element(mentions_gribox, row, "<b>03.</b> La nature et le domaine de son activité et qui forment son objet social", self.nature_domaine_status_field, self.nature_domaine_ri_field, "Art 5, Art 20 et 21 Pour toutes les formes<br/> de Sociétés Coopératives") row += 1 self.duree_status_field = IntLineEdit(self.rest_d( self.check_list.duree_status)) self.duree_ri_field = IntLineEdit(self.rest_d( self.check_list.duree_ri)) self.add_element(mentions_gribox, row, "<b>04.</b> Son siège et sa durée", self.duree_status_field, self.duree_ri_field, "Pour le Siège : Art 22 ,23 et 24 et Pour<br/> la Durée : Art 25, 26, 27et 28") row += 1 self.lien_commun_status_field = IntLineEdit(self.rest_d( self.check_list.lien_commun_status)) self.lien_commun_ri_field = IntLineEdit(self.rest_d( self.check_list.lien_commun_ri)) self.add_element(mentions_gribox, row, "<b>05.</b> Le lien commun qui réunit les membres,", self.lien_commun_status_field, self.lien_commun_ri_field, "Art 8") row += 1 self.coord_initiateur_status_field = IntLineEdit(self.rest_d( self.check_list.coord_initiateur_status)) self.coord_initiateur_ri_field = IntLineEdit(self.rest_d( self.check_list.coord_initiateur_ri)) self.add_element(mentions_gribox, row, "<b>06.</b> Les noms, prénoms et adresse résidentielle de chaque initiateur", self.coord_initiateur_status_field, self.coord_initiateur_ri_field, "Art 87") row += 1 self.max_min_admin_cg_status_field = IntLineEdit(self.rest_d( self.check_list.max_min_admin_cg_status)) self.max_min_admin_cg_ri_field = IntLineEdit(self.rest_d( self.check_list.max_min_admin_cg_ri)) self.add_element(mentions_gribox, row, "<b>07. a.</b> Le nombre précis ou les nombres minimal et maximal de ses administrateurs <br/> ou membres du comité de gestion</p>", self.max_min_admin_cg_status_field, self.max_min_admin_cg_ri_field, "Art 204 et Art 223 Pour la SCOOPS : <br/> (Effectif : 5 Pers au mini : CG=3 au plus si adh de 5 à 99 et CG = 5 si adh de 100 et +.") row += 1 self.max_min_admin_ca_status_field = IntLineEdit(self.rest_d( self.check_list.max_min_admin_ca_status)) self.max_min_admin_ca_ri_field = IntLineEdit(self.rest_d( self.check_list.max_min_admin_ca_ri)) self.add_element(mentions_gribox, row, "<b>07. b.</b> Le nombre précis ou les nombres minimal et maximal de ses <br/> administrateurs ou membres du Conseil d’Administration;", self.max_min_admin_ca_status_field, self.max_min_admin_ca_ri_field, "Art 207 et Art 223 Pour la COOP-CA: (Effectif : 15 Pers au mini : CA=3 au moins et 12 au plus.") row += 1 self.dispositions_cg_status_field = IntLineEdit(self.rest_d( self.check_list.dispositions_cg_status)) self.dispositions_cg_ri_field = IntLineEdit(self.rest_d( self.check_list.dispositions_cg_ri)) self.add_element(mentions_gribox, row, "<b>07. c.</b> Les dispositions portant limitation des pouvoirs des <br/> administrateurs ou membres du comité de gestion", self.dispositions_cg_status_field, self.dispositions_cg_ri_field, "Art 224 à Art 230 Pour la SCOOPS") row += 1 self.dispositions_ca_status_field = IntLineEdit(self.rest_d( self.check_list.dispositions_ca_status)) self.dispositions_ca_ri_field = IntLineEdit(self.rest_d( self.check_list.dispositions_ca_ri)) self.add_element(mentions_gribox, row, "<b>07. d.</b> Les dispositions portant limitation des pouvoirs des administrateurs ou <br/>membres du Conseil d’Administration", self.dispositions_ca_status_field, self.dispositions_ca_ri_field, "Art 296 à Art 307 Pour la COOP-CA et autres pouvoirs de l’Art 314 à l’Art 333") row += 1 self.max_min_cs_s_status_field = IntLineEdit(self.rest_d( self.check_list.max_min_cs_s_status)) self.max_min_cs_s_ri_field = IntLineEdit(self.rest_d( self.check_list.max_min_cs_s_ri)) self.add_element(mentions_gribox, row, "<b>08.</b> Le nombre précis ou les nombres minimal et maximal des membres de la <br/>Commission de Surveillance", self.max_min_cs_s_status_field, self.max_min_cs_s_ri_field, "Art 258 Pour la SCOOPS (de 3 à 5 Pers)") row += 1 self.max_min_cs_ca_status_field = IntLineEdit(self.rest_d( self.check_list.max_min_cs_ca_status)) self.max_min_cs_ca_ri_field = IntLineEdit(self.rest_d( self.check_list.max_min_cs_ca_ri)) self.add_element(mentions_gribox, row, "<b>08. a.</b> Le nombre précis ou les nombres minimal et maximal des membres du <br/>Conseil de Surveillance", self.max_min_cs_ca_status_field, self.max_min_cs_ca_ri_field, "Art 335 Pour la COOP-CA (de 3 à 5 Pers)") row += 1 self.dispositions_mo_status_field = IntLineEdit(self.rest_d( self.check_list.dispositions_mo_status)) self.dispositions_mo_ri_field = IntLineEdit(self.rest_d( self.check_list.dispositions_mo_ri)) self.add_element(mentions_gribox, row, "<b>08. b.</b> Les dispositions relatives à l’exercice efficace des missions de ces organes", self.dispositions_mo_status_field, self.dispositions_mo_ri_field, "Art 263 Pour la SCOOPS /Art 341 Pour la COOP-CA") row += 1 self.mandat_cs_status_field = IntLineEdit(self.rest_d( self.check_list.mandat_cs_status)) self.mandat_cs_ri_field = IntLineEdit(self.rest_d( self.check_list.mandat_cs_ri)) self.add_element(mentions_gribox, row, "<b>09.</b> La durée du mandat des membres du comité de gestion, du conseil d’administration, <br/> du comité de surveillance et du conseil de surveillance", self.mandat_cs_status_field, self.mandat_cs_ri_field, "Art 224 (Réf aux statuts) Pour la SCOOPS /Art 295 Pour la COOP-CA (Réf aux statuts)") row += 1 self.parts_sociales_status_field = IntLineEdit(self.rest_d( self.check_list.parts_sociales_status)) self.parts_sociales_ri_field = IntLineEdit(self.rest_d( self.check_list.parts_sociales_ri)) self.add_element(mentions_gribox, row, "<b>10.</b> Toute limite relative au pourcentage maximal de parts sociales que peut détenir <br/> un seul membre Pour la SCOOPS", self.parts_sociales_status_field, self.parts_sociales_ri_field, "Art 210 Réf aux statuts et ne peut excéder 5 fois <br/> le montant des parts sociales souscrites) Pour la COOP-CA Art 371") row += 1 self.declatation_status_field = IntLineEdit(self.rest_d( self.check_list.declatation_status)) self.declatation_ri_field = IntLineEdit(self.rest_d( self.check_list.declatation_ri)) self.add_element(mentions_gribox, row, "<b>11.</b> Une déclaration précisant que la société coopérative est organisée et exploitée <br/> et exerce ses activités selon les principes coopératifs et le rappel de ces principes", self.declatation_status_field, self.declatation_ri_field, "Art 6") row += 1 self.id_apport_numeraire_status_field = IntLineEdit(self.rest_d( self.check_list.id_apport_numeraire_status)) self.id_apport_numeraire_ri_field = IntLineEdit(self.rest_d( self.check_list.id_apport_numeraire_ri)) self.add_element(mentions_gribox, row, "<b>12.</b> L’identité des apporteurs en numéraires avec pour chacun d’eux le montant des <br/> apports, le nombre et la valeur des parts sociales remis en contrepartie de chaque apport", self.id_apport_numeraire_status_field, self.id_apport_numeraire_ri_field, "Art 30, 31, 32, 33,35, 36,") row += 1 self.id_apport_nature_status_field = IntLineEdit(self.rest_d( self.check_list.id_apport_nature_status)) self.id_apport_nature_ri_field = IntLineEdit(self.rest_d( self.check_list.id_apport_nature_ri)) self.add_element(mentions_gribox, row, "<b>13. a.</b> L’identité des apporteurs en nature", self.id_apport_nature_status_field, self.id_apport_nature_ri_field, "Point 12 de l’Art 18") row += 1 self.evaluation_apport_status_field = IntLineEdit(self.rest_d( self.check_list.evaluation_apport_status)) self.evaluation_apport_ri_field = IntLineEdit(self.rest_d( self.check_list.evaluation_apport_ri)) self.add_element(mentions_gribox, row, "<b>13. b.</b> La nature et l’évaluation de l’apport effectué par chacun d’eux, le nombre et la valeur <br/>des parts sociales remises en contrepartie de chaque apport, Le régime des biens ou valeurs apportés <br/>lorsque leur valeur excède celle des apports exigés ;", self.evaluation_apport_status_field, self.evaluation_apport_ri_field, "Point 13 de l’Art 18") row += 1 self.capital_social_status_field = IntLineEdit(self.rest_d( self.check_list.capital_social_status)) self.capital_social_ri_field = IntLineEdit(self.rest_d( self.check_list.capital_social_ri)) self.add_element(mentions_gribox, row, "<b>14. a.</b> Le montant du capital social, les limitations minimales et maximales y afférentes", self.capital_social_status_field, self.capital_social_ri_field, "Art 53, 57 et 58 en général. Art 207 Pour la SCOOPS et 269 Pour la COOP-CA") row += 1 self.valeur_nominale_status_field = IntLineEdit(self.rest_d( self.check_list.valeur_nominale_status)) self.valeur_nominale_ri_field = IntLineEdit(self.rest_d( self.check_list.valeur_nominale_ri)) self.add_element(mentions_gribox, row, "<b>14. b.</b> La valeur nominale des diverses catégories de parts, les conditions précises de leur émission<br/> ou souscription ;", self.valeur_nominale_status_field, self.valeur_nominale_ri_field, "Art 44 et 45 en général. Pour la COOP-CA Art 376 et 377") row += 1 self.stipulations_status_field = IntLineEdit(self.rest_d( self.check_list.stipulations_status)) self.stipulations_ri_field = IntLineEdit(self.rest_d( self.check_list.stipulations_ri)) self.add_element(mentions_gribox, row, "<b>15.</b> Les stipulations relatives à la répartition du résultat et notamment, des excédents<br/> et des réserves ;", self.stipulations_status_field, self.stipulations_ri_field, "Art 46 alinéa en général. Pour SCOOPS alinéa 2 de l’Art 209 Pour la COOP-CA Art 363 alinéa 4") row += 1 self.modalite_status_field = IntLineEdit(self.rest_d( self.check_list.modalite_status)) self.modalite_ri_field = IntLineEdit(self.rest_d( self.check_list.modalite_ri)) self.add_element(mentions_gribox, row, "<b>16.</b> Les modalités de fonctionnement de la société coopérative ;", self.modalite_status_field, self.modalite_ri_field, "Art 95 à 121 en général .Pour SCOOPS art 217 à 263 Pour la COOP-CA Art 291 à 368") row += 1 self.signature_int_status_field = IntLineEdit(self.rest_d( self.check_list.signature_int_status)) self.signature_int_ri_field = IntLineEdit(self.rest_d( self.check_list.signature_int_ri)) self.add_element(mentions_gribox, row, "<b>17.</b> La signature des initiateurs ou l’apposition de leur empreinte digitale", self.signature_int_status_field, self.signature_int_ri_field, "Point 17 de l’Art 18") row += 1 self.etendue_status_field = IntLineEdit(self.rest_d( self.check_list.etendue_status)) self.etendue_ri_field = IntLineEdit(self.rest_d( self.check_list.etendue_ri)) self.add_element(mentions_gribox, row, "<b>18.</b> L’étendue des transactions avec les usagers non coopérateurs, tout en ayant en vue<br/>la sauvegarde de l’autonomie de la société coopérative ;", self.etendue_status_field, self.etendue_ri_field, "Art 4 al. 2") row += 1 qss = "padding:5px;padding-left:25px;padding-right:25px;background: gray;font-size:30px;color:#fff" mentions_gribox.addWidget(FHeader( "Les mentions facultatives", qss), row, 0, 1, 4) row += 1 self.rendement_status_field = IntLineEdit(self.rest_d( self.check_list.rendement_status)) self.rendement_ri_field = IntLineEdit(self.rest_d( self.check_list.rendement_ri)) self.add_element(mentions_gribox, row, "<b>1. a.</b> Le taux de rendement maximal qui peut être appliqué aux prêts et aux épargnes des membres", self.rendement_status_field, self.rendement_ri_field, "Art 18. 1bis alinéa 1") row += 1 self.remuneration_status_field = IntLineEdit(self.rest_d( self.check_list.remuneration_status)) self.remuneration_ri_field = IntLineEdit(self.rest_d( self.check_list.remuneration_ri)) self.add_element(mentions_gribox, row, "<b>1. b.</b> Le taux de rémunération maximale qui peut être appliqué aux parts de membres ;", self.remuneration_status_field, self.remuneration_ri_field, "Art 239 ; 240 alinéa4 et 231(Art 18. 1bis alinéa 1)") row += 1 self.limite_imposee_status_field = IntLineEdit(self.rest_d( self.check_list.limite_imposee_status)) self.limite_imposee_ri_field = IntLineEdit(self.rest_d( self.check_list.limite_imposee_ri)) self.add_element(mentions_gribox, row, "<b>2.</b> Toute limite imposée aux activités commerciales de la société coopérative.", self.limite_imposee_status_field, self.limite_imposee_ri_field, "COOP–CA Art 313,SCOOPS Art 258 et 259") row += 1 mentions_gribox.addWidget(FHeader( "Règlement Intérieur, outre les mentions obligatoires des statuts, le règlement intérieur contient les prescriptions suivantes :", qss), row, 0, 1, 4) row += 1 self.indemnit_status_field = IntLineEdit(self.rest_d( self.check_list.indemnit_status)) self.indemnit_ri_field = IntLineEdit(self.rest_d( self.check_list.indemnit_ri)) self.add_element(mentions_gribox, row, "<b>1.</b> Les conditions de paiement d’indemnités aux membres du conseil d’administration ou du comité<br/> de gestion, du conseil ou du comité de surveillance, définies dans le respect des dispositions<br/> des articles 225 et 305 ;", self.indemnit_status_field, self.indemnit_ri_field, "Scoops : Art 225; Scoop-CA : Art 305") row += 1 self.souscription_status_field = IntLineEdit(self.rest_d( self.check_list.souscription_status)) self.souscription_ri_field = IntLineEdit(self.rest_d( self.check_list.souscription_ri)) self.add_element(mentions_gribox, row, "<b>2.</b> La souscription de parts sociales supplémentaires et leur nombre par coopérateur ;", self.souscription_status_field, self.souscription_ri_field, "Pour la SCOOPS Art 210 Réf aux statuts et ne peut excéder <br/>5 fois le montant des parts sociales souscrites) Pour la COOP-CA Art 371") row += 1 self.suspension_status_field = IntLineEdit(self.rest_d( self.check_list.suspension_status)) self.suspension_ri_field = IntLineEdit(self.rest_d( self.check_list.suspension_ri)) self.add_element(mentions_gribox, row, "<b>3.</b> Les critères et conditions de suspension des coopérateurs;", self.suspension_status_field, self.suspension_ri_field, "Statut (initiateurs)") row += 1 self.attribution_status_field = IntLineEdit(self.rest_d( self.check_list.attribution_status)) self.attribution_ri_field = IntLineEdit(self.rest_d( self.check_list.attribution_ri)) self.add_element(mentions_gribox, row, "<b>4.</b> La possibilité d’attribution d’un droit de vote plural dans le cas des unions, des fédérations et<br/>des confédérations ;", self.attribution_status_field, self.attribution_ri_field, "Art 138") row += 1 self.prescriptions_status_field = IntLineEdit(self.rest_d( self.check_list.prescriptions_status)) self.prescriptions_ri_field = IntLineEdit(self.rest_d( self.check_list.prescriptions_ri)) self.add_element(mentions_gribox, row, "<b>5.</b> Toutes autres prescriptions jugées nécessaires pour la réalisation de l’objet de la société <br/>coopérative et conformes aux principes coopératifs et aux dispositions impératives du présent<br/> Acte uniforme.", self.prescriptions_status_field, self.prescriptions_ri_field, "AUSCOOP") vbox = QVBoxLayout() vbox.addLayout(pieces_v_gribox) vbox.addLayout(pieces_gribox) vbox.addLayout(mentions_gribox) self.piecesGroupBox.setLayout(vbox) # Durée statutaire de la société coopérative duree_fbox = QFormLayout() self.butt_continous = Button_save(u"Continuer") self.butt_continous.clicked.connect(self.goto_immatriculation) self.butt_continous.setMaximumWidth(200) duree_fbox.addRow("", self.butt_continous) if not self.check_integrity_validation(): self.butt_continous.setEnabled(False) scroll = QScrollArea(self) scroll.setVerticalScrollBarPolicy(Qt.ScrollBarAlwaysOn) scroll.setHorizontalScrollBarPolicy(Qt.ScrollBarAlwaysOn) scroll.setWidgetResizable(True) # scroll.setFixedHeight(200) vbox = QVBoxLayout() vbox.addWidget(FHeader( "<h2>Check-list de Contrôle de dossiers des sociétés coopératives avant l’immatriculation et l’enregistrement par le SLDS-ES</h2>", css="color:green")) vbox.addWidget(FHeader( "<h4>Société Coopérative : {} </h4>".format(self.dmd.scoop))) scroll.setWidget(self.piecesGroupBox) vbox.addWidget(scroll) vbox.addLayout(duree_fbox) self.setLayout(vbox)
class RegistrationViewWidget(FWidget): """ Shows the home page """ def __init__(self, parent=0, *args, **kwargs): super(RegistrationViewWidget, self).__init__(parent=parent, *args, **kwargs) self.parent = parent self.parentWidget().set_window_title("FORMULAIRE D’IMMATRICULATION") self.title = FLabel("<h3>FORMULAIRE D’IMMATRICULATION</h3>") self.office = Office.select().where(Office.id == 1).get() self.created_date_field = FormatDate(QDate.currentDate()) self.created_date_field.setMaximumWidth(130) # self.created_date_field.setInputMask('##/##/####') self.rue_field = IntLineEdit() self.porte_field = IntLineEdit() self.tel_field = IntLineEdit() self.tel_field.setInputMask('## ## ## ##') self.tel2_field = IntLineEdit() self.tel2_field.setInputMask('## ## ## ##') self.bp_field = IntLineEdit() self.email_field = LineEdit() self.denomination_field = LineEdit() self.commercial_name_field = LineEdit() self.declaration_date_field = FormatDate(QDate.currentDate()) self.declaration_date_field.setMaximumWidth(130) self.amount_capital_social_initial = FLabel() self.amount_part_social_field = IntLineEdit() self.apports_numeraire_field = IntLineEdit() self.apports_numeraire_field.textChanged.connect(self.cal_total) self.apports_nature_field = IntLineEdit() self.apports_nature_field.textChanged.connect(self.cal_total) self.apports_industrie_field = IntLineEdit() self.apports_industrie_field.textChanged.connect(self.cal_total) self.duree_statutaire_field = IntLineEdit() self.duree_statutaire_field.setMaximumWidth(80) self.spinneret_box = QComboBox() self.spinneret_box.setMaximumWidth(800) self.activites_box = QComboBox() self.activites_box.setMaximumWidth(800) self.activites_box.currentIndexChanged.connect(self.sp_change_select) self.activities_list = get_activities() for index, value in enumerate(self.activities_list): self.activites_box.addItem( "{}".format(self.activities_list.get(value).upper()), value) # if self.store and self.store.name == op.name: # self.box_store.setCurrentIndex(index) self.formes_box = QComboBox() self.formes_box.setMaximumWidth(800) self.formes_list = get_formes() for index, value in enumerate(self.formes_list): self.formes_box.addItem( "{}".format(self.formes_list.get(value).upper()), value) self.commune_list = entity_children(self.office.slug_cercle).items() self.commune_box = ExtendedComboBox() for index, value in enumerate(self.commune_list): self.commune_box.addItem("{}".format(value[1].upper()), value[0]) # self.commune_box.addItems(self.commune_list) self.commune_box.setToolTip("commune") self.commune_box.currentIndexChanged.connect(self.c_change_select) # self.vfq_list = self.get_vfq_list() self.vfq_box = ExtendedComboBox() self.vfq_list = self.get_vfq_list() for index, value in enumerate(self.vfq_list): self.vfq_box.addItem("{}".format(self.vfq_list.get(value).upper()), value) self.vfq_box.setToolTip("vfq") formbox = QFormLayout() formbox.addRow(FLabel(DATE_DEMANTE), self.declaration_date_field) formbox.addRow(FLabel("1. " + DENOMINATION_S_SC), self.denomination_field) formbox.addRow(FLabel("2. " + NOM_COMMERCIAL), self.commercial_name_field) formbox.addRow(FLabel("3. " + DATE_CREATION_SC), self.created_date_field) formbox.addRow(FLabel("4. " + ACTIVITES_E), self.activites_box) formbox.addRow(FLabel("5. " + FILIERE), self.spinneret_box) formbox.addRow(FLabel("6. " + FORME_SC), self.formes_box) # Capital Social Initial capital_formbox = QFormLayout() capital_formbox.addRow(FLabel("7.1. " + MONTANT_PART_S), self.amount_part_social_field) capital_formbox.addRow(FLabel("7.2. " + MONTANT_APPORTS_NUM), self.apports_numeraire_field) capital_formbox.addRow(FLabel("7.3. " + MONTANT_APPORTS_NAT), self.apports_nature_field) capital_formbox.addRow(FLabel("7.4. " + MONTANT_APPORTS_INDU), self.apports_industrie_field) self.capitalSGroupBox = QGroupBox("7. " + MONTANT_CAPITAL_SI) self.capitalSGroupBox.setLayout(capital_formbox) self.capitalSGroupBox.setStyleSheet(CSS) # self.capitalSGroupBox.setMaximumWidth(1300) # Adresse du siège social self.vline = QFrame() self.vline.setFrameShape(QFrame.VLine) self.vline.setFrameShadow(QFrame.Sunken) self.addresGroupBox = QGroupBox("8. " + ADRESSE_SS) self.addresGroupBox.setStyleSheet(CSS) addres_gribox = QGridLayout() addres_gribox.addWidget(FRLabel(CERCLE), 0, 0) addres_gribox.addWidget(FLabel(self.office.cercle_name()), 0, 1) addres_gribox.addWidget(FRLabel(COMMUNE), 1, 0) addres_gribox.addWidget(self.commune_box, 1, 1) # addres_gribox.addWidget(self.vline, 0, 3, 2, 5) addres_gribox.addWidget(FRLabel(VFQ), 2, 0) addres_gribox.addWidget(self.vfq_box, 2, 1) addres_gribox.addWidget(FRLabel(RUE), 0, 2) addres_gribox.addWidget(self.rue_field, 0, 3) addres_gribox.addWidget(FRLabel(PORTE), 1, 2) addres_gribox.addWidget(self.porte_field, 1, 3) addres_gribox.addWidget(FRLabel(BP), 0, 4) addres_gribox.addWidget(self.bp_field, 0, 5) addres_gribox.addWidget(FRLabel(EMAIL), 1, 4) addres_gribox.addWidget(self.email_field, 1, 5) addres_gribox.addWidget(FRLabel(TEL), 2, 2) addres_gribox.addWidget(self.tel_field, 2, 3) addres_gribox.addWidget(FRLabel(TEL2), 2, 4) addres_gribox.addWidget(self.tel2_field, 2, 5) # addres_gribox.setColumnStretch(6, 5) self.addresGroupBox.setLayout(addres_gribox) # self.addresGroupBox.setMaximumWidth(1300) # Durée statutaire de la société coopérative duree_fbox = QFormLayout() duree_fbox.addRow(FLabel("9. " + DUREE_STATUTAIRE_SC), self.duree_statutaire_field) butt = Button_save(SAVE) butt.clicked.connect(self.save_and_goto_manager) butt_and_continous = Button_save(SAVE_AND_CONTINNUES) butt_and_continous.clicked.connect(self.save_and_goto_add_member) butt_and_continous.setMaximumWidth(300) duree_fbox.addRow(FLabel(""), FLabel("")) duree_fbox.addRow(butt, butt_and_continous) vbox = QVBoxLayout() vbox.addLayout(formbox) vbox.addWidget(self.capitalSGroupBox) vbox.addWidget(self.addresGroupBox) vbox.addLayout(duree_fbox) self.setLayout(vbox) def get_vfq_list(self): # c_dic = {} co_select = self.commune_box.itemData(self.commune_box.currentIndex()) return entity_children(co_select) def c_change_select(self): self.vfq_box.clear() self.vfq_list = self.get_vfq_list() for index, value in enumerate(self.vfq_list): self.vfq_box.addItem("{}".format(self.vfq_list.get(value).upper()), value) def get_spinneret_list(self): # c_dic = {} r_select = self.activites_box.itemData( self.activites_box.currentIndex()) return get_spinneret_activites(r_select) def sp_change_select(self): self.spinneret_box.clear() self.spinneret_list = self.get_spinneret_list() for index, value in enumerate(self.spinneret_list): self.spinneret_box.addItem( "{}".format(self.spinneret_list.get(value).upper()), value) 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 def save(self): if not self.is_valide(): return self.scoop = CooperativeCompanie() self.scoop.office = self.office self.scoop.created_date = str(self.created_date_field.text()) self.scoop.denomination = str(self.denomination_field.text()) self.scoop.commercial_name = str(self.commercial_name_field.text()) self.scoop.activity = self.activites_box.itemData( self.activites_box.currentIndex()) self.scoop.spinneret = self.spinneret_box.itemData( self.spinneret_box.currentIndex()) self.scoop.forme = self.formes_box.itemData( self.formes_box.currentIndex()) self.scoop.amount_part_social = is_int( self.amount_part_social_field.text()) self.scoop.apports_numeraire = is_int( self.apports_numeraire_field.text()) self.scoop.apports_nature = is_int(self.apports_nature_field.text()) self.scoop.apports_industrie = is_int( self.apports_industrie_field.text()) self.scoop.region = self.office.slug_region self.scoop.cercle = self.office.slug_cercle self.scoop.commune = self.commune_box.itemData( self.commune_box.currentIndex()) self.scoop.vfq = self.vfq_box.itemData(self.vfq_box.currentIndex()) self.scoop.rue = is_int(self.rue_field.text()) self.scoop.porte = is_int(self.porte_field.text()) self.scoop.tel = is_int(self.tel_field.text()) self.scoop.tel2 = is_int(self.tel2_field.text()) self.scoop.bp = is_int(self.bp_field.text()) self.scoop.email = self.email_field.text() self.scoop.duree_statutaire = is_int( self.duree_statutaire_field.text()) self.scoop.save_() check_list = CheckList() check_list.save_() self.dmd = Demande() self.dmd.check_list = check_list self.dmd.declaration_date = str(self.declaration_date_field.text()) self.dmd.scoop = self.scoop self.dmd.status = self.dmd.ADDMEMBER self.dmd.save_() return True def save_and_goto_add_member(self): if self.save(): from ui.member_manager import MemberManagerWidget self.parent.change_context(MemberManagerWidget, dmd=self.dmd) def save_and_goto_manager(self): if self.save(): self.parent.change_context(ResgistrationManagerWidget) def cal_total(self): total = is_int(self.apports_numeraire_field.text() or 0) + is_int( self.apports_nature_field.text() or 0) + is_int( self.apports_industrie_field.text() or 0) self.capitalSGroupBox.setTitle("7. {} : {}".format( MONTANT_CAPITAL_SI, device_amount(total)))
class RefundEditAddDialog(QDialog, FWidget): def __init__(self, table_p, parent, provid_clt=None, type_=None, refund=None, *args, **kwargs): QDialog.__init__(self, parent, *args, **kwargs) self.type_ = type_ self.refund = refund self.parent = parent self.table_p = table_p self.provid_clt = provid_clt self.new = True if self.refund: self.new = False self.last_r = self.refund self.type_ = refund.type_ self.refund_date_field = FormatDate(self.refund.date) self.refund_date_field.setEnabled(False) self.title = u"Modification de {} {}".format(self.refund.type_, self.refund.invoice.client) self.succes_msg = u"{} a été bien mise à jour".format( self.refund.type_) self.amount = refund.amount self.provid_clt = refund.provider_client else: self.refund_date_field = FormatDate(QDate.currentDate()) self.succes_msg = u"Client a été bien enregistré" self.title = u"Création d'un nouvel client" self.amount = "" self.refund = Refund() self.last_r = Refund.select().where( Refund.provider_client == provid_clt).order_by(Refund.date.desc()).get() self.setWindowTitle(self.title) self.amount_field = IntLineEdit(unicode(self.amount)) vbox = QVBoxLayout() self.last_remaining = self.last_r.refund_remaing() # try: # self.last_r.refund_remaing() # self.remaining = self.last_r.remaining # except Exception as e: # self # print("last_r except ", e) # self.last_r = None # self.close() formbox = QFormLayout() formbox.addRow(FormLabel("Client :"), FormLabel(self.provid_clt.name)) formbox.addRow(FormLabel("Dette restante :"), FormLabel(str(formatted_number(self.last_remaining)))) formbox.addRow(FormLabel(u"Date : *"), self.refund_date_field) formbox.addRow(FormLabel(u"Montant : *"), self.amount_field) butt = ButtonSave(u"Enregistrer") butt.clicked.connect(self.save_edit) formbox.addRow("", butt) # formbox.addRow("", "Le client {} n'est pas endetté") vbox.addLayout(formbox) self.setLayout(vbox) def save_edit(self): ''' add operation ''' if check_is_empty(self.amount_field): return amount = int(self.amount_field.text()) refund_date = unicode(self.refund_date_field.text()) # self.remaining = self.last_r.remaining if check_field( self.amount_field, "Ce montant ne peut être supperieur au dettes restante {}.".format( self.last_remaining), amount > self.last_remaining): return refund = self.refund refund.type_ = self.type_ refund.invoice = self.last_r.invoice refund.amount = amount if self.new: refund.provider_client = self.provid_clt refund.date = date_to_datetime(refund_date) try: refund.save() self.close() self.parent.Notify(u"le {type} {lib} à été enregistré avec succès".format( type=self.type_, lib=amount), "success") self.table_p.refresh_(provid_clt_id=self.provid_clt.id) except Exception as e: self.parent.Notify(e, "error")
class OrganizationTableWidget(FWidget): def __init__(self, parent, *args, **kwargs): super(FWidget, self).__init__(parent=parent, *args, **kwargs) self.organization = Organization().get(id=1) print(self.organization) self.parent = parent vbox = QVBoxLayout() # vbox.addWidget(FPageTitle(u"Utilisateur: %s " % # self.organisation.name_orga)) self.liste_devise = Organization.DEVISE # Combobox widget self.box_devise = QComboBox() for index, value in enumerate(self.liste_devise): self.box_devise.addItem( "{} {}".format(self.liste_devise[value], value)) if self.organization.devise == value: self.box_devise.setCurrentIndex(index) self.checked = QCheckBox("Active") if self.organization.is_login: self.checked.setCheckState(Qt.Checked) self.checked.setToolTip(u"""Cocher si vous voulez pour deactive le login continue à utiliser le systeme""") self.name_orga = LineEdit(self.organization.name_orga) self.phone = IntLineEdit(str(self.organization.phone)) self.bp = LineEdit(self.organization.bp) self.adress_org = QTextEdit(self.organization.adress_org) self.email_org = LineEdit(self.organization.email_org) formbox = QFormLayout() formbox.addRow(FormLabel(u"Nom de l'organisation:"), self.name_orga) formbox.addRow(FormLabel(u"Tel:"), self.phone) formbox.addRow(FormLabel(u"Activer le login"), self.checked) formbox.addRow(FormLabel(u"Devise :"), self.box_devise) formbox.addRow(FormLabel(u"B.P:"), self.bp) formbox.addRow(FormLabel(u"E-mail:"), self.email_org) formbox.addRow(FormLabel(u"Adresse complete:"), self.adress_org) butt = Button_save(u"Enregistrer") butt.clicked.connect(self.save_edit) formbox.addRow("", butt) vbox.addLayout(formbox) self.setLayout(vbox) def save_edit(self): ''' add operation ''' name_orga = unicode(self.name_orga.text()) if check_is_empty(self.name_orga): return if check_is_empty(self.phone): return orga = Organization().get(id=1) orga.name_orga = name_orga orga.phone = unicode(self.phone.text()) orga.is_login = True if self.checked.checkState() == Qt.Checked else False orga.devise = str(self.box_devise.currentText().split()[1]) orga.email_org = unicode(self.email_org.text()) orga.bp = unicode(self.bp.text()) orga.adress_org = unicode(self.adress_org.toPlainText()) orga.save() print(orga.is_login) self.parent.parent.Notify(u"Le Compte %s a été mise à jour" % orga.name_orga, "success")
def __init__(self, table_p, parent, scoop=None, member=None, *args, **kwargs): FWidget.__init__(self, parent, *args, **kwargs) self.table_p = table_p self.member = member self.scoop = scoop self.parent = parent full_name = "" self.ddn_field = FormatDate(QDate(QDate.currentDate())) addres = "" nationality = "" phone = "" if self.member: self.new = False full_name = self.member.full_name mddn = self.member.ddn if mddn: day, month, year = mddn.split("/") ddn = datetime.strptime(mddn, '%d/%m/%Y') self.ddn_field.setDate(QDate(ddn)) addres = self.member.addres nationality = self.member.nationality phone = str(self.member.phone or "") self.title = u"Modification de {}".format(self.member) self.succes_msg = u"{} a été bien mise à jour".format(self.member) else: self.new = True self.succes_msg = u"Client a été bien enregistré" self.title = u"Ajout nouveau membre" self.member = CooperativeMember() self.setWindowTitle(self.title) vbox = QVBoxLayout() # vbox.addWidget(FPageTitle(u"Utilisateur: %s " % self.member.name)) self.full_name_field = LineEdit(full_name) self.sex_list = CooperativeMember.SEX.items() # Combobox widget self.sex_box = QComboBox() for index, value in enumerate(self.sex_list): # form = self.sex_list[index] self.sex_box.addItem("{}".format(value[1].upper()), value[0]) if self.member.sex == value[0]: self.sex_box.setCurrentIndex(index) # print("DE", ddn) # self.ddn_field.setDate(ddn) # self.ddn_field = QDateEdit(QDate(ddn)) self.addres_field = QTextEdit(addres) self.nationality_field = LineEdit(nationality) self.phone_field = IntLineEdit(phone) self.phone_field.setInputMask("## ## ## ##") self.poste_list = get_postes() self.poste_box = QComboBox() for index, value in enumerate(self.poste_list): self.poste_box.addItem( "{}".format(self.poste_list.get(value).upper()), value) if self.member.poste == value: print(value) self.poste_box.setCurrentIndex(index) formbox = QFormLayout() formbox.addRow(FormLabel(u"Nom complet : *"), self.full_name_field) formbox.addRow(FormLabel(u"Sexe *:"), self.sex_box) formbox.addRow(FormLabel(u"Date de naissance *:"), self.ddn_field) formbox.addRow(FormLabel(u"Poste occupé *:"), self.poste_box) formbox.addRow(FormLabel(u"Nationalité *:"), self.nationality_field) formbox.addRow(FormLabel(u"Téléphone :"), self.phone_field) formbox.addRow(FormLabel(u"Adresse :"), self.addres_field) butt = Button(u"Enregistrer") butt.clicked.connect(self.save_edit) formbox.addRow("", butt) vbox.addLayout(formbox) self.setLayout(vbox)
class EditOrAddPaymentrDialog(QDialog, FWidget): def __init__(self, table_p, parent, type_=None, payment=None, *args, **kwargs): QDialog.__init__(self, parent, *args, **kwargs) self.type_ = type_ self.payment = payment self.parent = parent self.table_p = table_p if self.payment: self.new = False self.type_ = payment.type_ self.payment_date_field = FormatDate(self.payment.date) self.payment_date_field.setEnabled(False) self.title = u"Modification de {} {}".format(self.payment.type_, self.payment.libelle) self.succes_msg = u"{} a été bien mise à jour".format( self.payment.type_) if self.type_ == Payment.CREDIT: amount = payment.credit elif self.type_ == Payment.DEBIT: amount = payment.debit else: self.new = True amount = "" self.payment_date_field = FormatDate(QDate.currentDate()) self.succes_msg = u"Client a été bien enregistré" self.title = u"Création d'un nouvel client" self.payment = Payment() self.setWindowTitle(self.title) self.amount_field = IntLineEdit(unicode(amount)) self.libelle_field = QTextEdit(self.payment.libelle) vbox = QVBoxLayout() formbox = QFormLayout() formbox.addRow(FormLabel(u"Date : *"), self.payment_date_field) formbox.addRow(FormLabel(u"Libelle :"), self.libelle_field) formbox.addRow(FormLabel(u"Montant : *"), self.amount_field) butt = ButtonSave(u"Enregistrer") butt.clicked.connect(self.save_edit) formbox.addRow("", butt) vbox.addLayout(formbox) self.setLayout(vbox) def save_edit(self): ''' add operation ''' if check_is_empty(self.amount_field): return payment_date = unicode(self.payment_date_field.text()) libelle = unicode(self.libelle_field.toPlainText()) amount = int(self.amount_field.text().replace(" ", "")) payment = self.payment payment.type_ = self.type_ payment.libelle = libelle if self.new: payment.date = date_to_datetime(payment_date) if self.type_ == Payment.CREDIT: payment.credit = amount elif self.type_ == Payment.DEBIT: payment.debit = amount try: payment.save() self.close() self.parent.Notify(u"le {type} {lib} à été enregistré avec succès".format( type=self.type_, lib=libelle), "success") self.table_p.refresh_() except Exception as e: self.parent.Notify(e, "error")