def data_edit(self, event): _product_id = self.textbox_product_id.GetValue() if not _product_id: return dialogs.launch_error( self, u'Eh necessário especificar o ID do produto!') product_id = int(_product_id) product = self.database_inventory.inventory_search_id(product_id) if not product: return dialogs.launch_error(self, u'ID inválido!') _amount = core.amount2float(self.textbox_product_amount.GetValue()) try: amount = float(_amount) except ValueError: self.textbox_product_amount.Clear() return dialogs.launch_error(self, u'Quantidade inválida!') unit_price = core.format_cash_user(product.price, currency=True) unit = self.textbox_product_unit.GetValue() self.list_update.SetStringItem(self.item, 0, core.format_id_user(product.ID)) self.list_update.SetStringItem(self.item, 1, product.description) self.list_update.SetStringItem( self.item, 2, core.format_amount_user(amount, unit=unit)) self.list_update.SetStringItem(self.item, 3, unit_price) self.list_update.SetItemData(self.item, product_id) self.data_editor_disable(event)
def data_insert(self, event): _product_id = self.textbox_product_id.GetValue() if not _product_id: return dialogs.launch_error( self, u'Eh necessário especificar o ID do produto!') product_id = int(_product_id) product = self.database_inventory.inventory_search_id(product_id) if not product: return dialogs.launch_error(self, u'ID inválido!') _amount = self.textbox_product_amount.GetValue() try: amount = core.amount2float(_amount) except ValueError: self.textbox_product_amount.Clear() return dialogs.launch_error(self, u'Quantidade inválida!') unit = self.textbox_product_unit.GetValue() unit_price = core.format_cash_user(product.price, currency=True) item = self.list_update.Append( (core.format_id_user(product.ID), product.description, core.format_amount_user(amount, unit=unit), unit_price)) self.list_update.SetItemData(item, product_id) self.textbox_product_amount.Clear() self.textbox_product_id.Clear() self.textbox_product_description.Clear() self.textbox_product_price.SetValue(u"0,00") self.textbox_product_unit.Clear()
def imposto_122741(category_id=None, data=None, origin=None): """ coleta os dados de imposto de um determinado produto :param category_id: id do produto :param data: Produto a ter o imposto coletado :param origin: Frame de origem :type category_id: int :type data: data_types.ProductCategoryData :type origin: wx.Window :return: produto :rtype: data_types.ProductData """ import ibptws.provisoes import ibptws.excecoes import database from ibptws import conf import requests conf.token = '797XZCfo2HY0TtThIPLPiMds9JzUrCDvUVhiPaJ_Jq7OFawH1OdSq3kJkOSsxPpI' conf.cnpj = '16678899000136' conf.estado = 'SP' if not data and not category_id: return False db = database.InventoryDB() if not data: data = db.categories_search_id(category_id) calc = ibptws.provisoes.SemProvisao() try: p = calc.get_produto(data.ncm, 0) data.imposto_federal = float(p.aliquota_nacional + p.aliquota_importado) data.imposto_estadual = float(p.aliquota_estadual) data.imposto_total = data.imposto_federal + data.imposto_estadual except ibptws.excecoes.ErroProdutoNaoEncontrado: import dialogs import categories dialogs.launch_error( origin, u'O NCM da categoria "%s" é inválido!' % data.category) if not isinstance(origin, categories.ProductCategoryData): categories.ProductCategoryData(origin, title=data.category, category_id=category_id, data=data) raise exception.ExceptionNCM except requests.ConnectionError: db.insert_category_fila(data.ID) raise exception.ExceptionInternet return data
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): _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_client_name.GetValue(): return dialogs.launch_error(self, u'É necessário o nome, para o cadastro') 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.ID = self.client_id 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() db = database.ClientsDB() db.edit_client(data) db.close() if isinstance(self.parent, ClientManager): self.parent.setup(None) self.exit(None)
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)