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