def end(self): _product_id = self.textbox_id.GetValue() _amount = self.textbox_amount.GetValue() if not _product_id or not _amount: return dialogs.launch_error(self, u'Dados insuficientes!') date, finish_time = core.datetime_today() data = data_types.WasteData() data.product_ID = int(_product_id) data.amount = float(_amount) data.record_date = date data.record_time = finish_time data.ID = self.key db = database.TransactionsDB() if self.key != -1 or self.data: db.edit_waste(data) update_inventory(self.data, undo=True) else: db.insert_waste(data) db.close() update_inventory(data) self.clean() dialogs.Confirmation(self, u"Sucesso", 3)
def end(self): if not self.textbox_description.GetValue(): return dialogs.launch_error(self, u'É necessária uma descrição!') if self.combobox_category.GetSelection() == 0: return dialogs.launch_error(self, u'Selecione uma categoria!') amount_str = self.textbox_amount.GetValue() try: amount = core.amount2float(amount_str) except ValueError: self.textbox_amount.Clear() return dialogs.launch_error(self, u'Quantidade inválida!') rdate, rtime = core.datetime_today() names = strip(self.textbox_description.GetValue()).split() for i in range(0, len(names)): names[i] = names[i].capitalize() namef = ' '.join(names) db = database.InventoryDB() category = db.category_search_name(self.combobox_category.GetValue()) barcode = self.textbox_barcode.GetValue() s = data_types.ProductData() if barcode: s.barcode = barcode s.ID = self.product_id s.description = namef s.price = core.money2float(self.textbox_price.GetValue()) s.amount = int(amount) s.category_ID = category.ID s.supplier = self.textbox_supplier.GetValue() s.obs = self.textbox_observation.GetValue() s.record_time = rtime s.record_date = rdate if self.data: db.edit_product(s) else: db.insert_product(s) db.close() if isinstance(self.parent, sale.Sale): self.parent.database_inventory.insert_product(s) self.parent.database_search(None) if self.data: if isinstance(self.parent, InventoryManager): self.parent.setup(None) return self.exit(None) self.clean() dialogs.Confirmation(self, u'Sucesso', 5)
def end(self): description = self.textbox_description.GetValue().capitalize() val = core.money2float(self.textbox_value.GetValue()) if len(description) == 0 or val == 0: return dialogs.launch_error(self, u'Dados insulficientes') date, finish_time = core.datetime_today() wx_date = self.calendar_date.GetDate() transaction_date = u'%i-%s-%i' % ( wx_date.GetYear(), core.good_show( 'o', str(wx_date.GetMonth() + 1)), wx_date.GetDay()) data = data_types.TransactionData() data.ID = self.key data.description = description data.category = self.categories_ids[ self.combobox_category.GetSelection()] data.value = val data.record_date = date data.record_time = finish_time data.transaction_date = transaction_date data.type = self.transaction_type data.payment_pendant = not self.checkbox_payed.GetValue() db = database.TransactionsDB() if self.key == -1: db.insert_transaction(data) else: db.edit_transaction(data) db.close() parent = self.GetParent() if isinstance(parent, monthly_report.Report): funcs = { EXPENSE: parent.setup_monthly_expenses, INCOME: parent.setup_monthly_incomes } setup = funcs[self.transaction_type] setup(None) if self.key == -1: self.clean() confirmation_option = -1 if self.transaction_type is EXPENSE: confirmation_option = 2 elif self.transaction_type is INCOME: confirmation_option = 7 dialogs.Confirmation(self, u"Sucesso", confirmation_option) else: self.exit(None)
def end(self): w = self.list_update.GetItemCount() if w == 0: return dialogs.launch_error(self, u'Você não adicionou nenhum produto!') update = self.radio_update.GetValue() entry = self.radio_entry.GetValue() db = database.InventoryDB() for i in range(w): products_id = self.list_update.GetItemData(i) amount = core.amount2float(self.list_update.GetItemText(i, 2)) if update: db.update_product_amount(products_id, amount) elif entry: db.update_product_stock(products_id, amount) db.close() self.clean() dialogs.Confirmation(self, u'Sucesso', 6)
def end(self): if not self.textbox_client_name.GetValue(): return dialogs.launch_error(self, u'É necessário o nome, para o cadastro') rdate = core.datetime_today()[0] xname = self.textbox_client_name.GetValue() names = xname.strip().split() for i in range(0, len(names)): names[i] = names[i].capitalize() namef = ' '.join(names) data = data_types.ClientData() data.name = namef data.sex = self.textbox_client_sex.GetValue() data.birth = core.format_date_internal(self.textbox_client_birth.GetValue()) data.email = self.textbox_client_email.GetValue() data.cpf = self.textbox_client_cpf.GetValue().replace('-', '').replace('.', '') data.telephone = self.textbox_client_telephone.GetValue().replace('-', '').replace('(', '').replace(')', '') data.cep = self.textbox_client_cep.GetValue().replace('-', '') data.state = self.textbox_client_state.GetValue() data.city = self.textbox_client_city.GetValue() data.district = self.textbox_client_district.GetValue() data.address = self.textbox_client_address.GetValue() data.obs = self.textbox_client_observations.GetValue() data.record_date = rdate db = database.ClientsDB() db.insert_client(data) db.close() self.clean() parent = self.GetParent() if isinstance(parent, sale.Sale): parent.textbox_client_name.SetValue(data.name) parent.textbox_client_cpf.SetValue(core.format_cpf(data.cpf)) self.exit(None) return dialogs.Confirmation(self, u'Sucesso', 4)
def obs_confirmation(self, tag, title, iconfile, soundfn, btnlist, callfn): dialog = dialogs.Confirmation() self.gui_do(dialog.popup, title, iconfile, soundfn, btnlist, callfn, tag=tag)