def _credit_limit_salary_changed(new_value, store): from stoqlib.domain.person import Client old_value = sysparam(store).CREDIT_LIMIT_SALARY_PERCENT if new_value == old_value: return new_value = Decimal(new_value) Client.update_credit_limit(new_value, store)
def _credit_limit_salary_changed(new_value, store): from stoqlib.domain.person import Client old_value = sysparam.get_decimal('CREDIT_LIMIT_SALARY_PERCENT') if new_value == old_value: return new_value = Decimal(new_value) Client.update_credit_limit(new_value, store)
def _create_client(self, store): from stoqlib.domain.address import Address, CityLocation from stoqlib.domain.person import Client, Person person = Person(name=u'Person', store=store) city = CityLocation.get_default(store) Address(store=store, street=u'Rua Principal', streetnumber=123, postal_code=u'12345-678', is_main_address=True, person=person, city_location=city) client = Client(person=person, store=store) client.credit_limit = currency("1000") return client
def populate(self, person): from stoqlib.domain.person import (Client, Supplier, Transporter, SalesPerson, Branch) store = get_store_for_field(self) person_type = self.person_type if person_type == Supplier: objects = Supplier.get_active_suppliers(store) self.add_button.set_tooltip_text(_("Add a new supplier")) self.edit_button.set_tooltip_text(_("Edit the selected supplier")) elif person_type == Client: objects = Client.get_active_clients(store) self.add_button.set_tooltip_text(_("Add a new client")) self.edit_button.set_tooltip_text(_("Edit the selected client")) elif person_type == Transporter: objects = Transporter.get_active_transporters(store) self.add_button.set_tooltip_text(_("Add a new transporter")) self.edit_button.set_tooltip_text(_("Edit the selected transporter")) elif person_type == SalesPerson: objects = SalesPerson.get_active_salespersons(store) self.add_button.set_tooltip_text(_("Add a new sales person")) self.edit_button.set_tooltip_text(_("Edit the selected sales person")) elif person_type == Branch: objects = Branch.get_active_branches(store) self.add_button.set_tooltip_text(_("Add a new branch")) self.edit_button.set_tooltip_text(_("Edit the selected branch")) else: raise AssertionError(self.person_type) self.widget.prefill(api.for_person_combo(objects)) if person: assert isinstance(person, person_type) self.widget.select(person)
def populate(self, person): from stoqlib.domain.person import (Client, Supplier, Transporter, SalesPerson, Branch) store = get_store_for_field(self) person_type = self.person_type if person_type == Supplier: objects = Supplier.get_active_suppliers(store) self.add_button.set_tooltip_text(_("Add a new supplier")) self.edit_button.set_tooltip_text(_("Edit the selected supplier")) elif person_type == Client: objects = Client.get_active_clients(store) self.add_button.set_tooltip_text(_("Add a new client")) self.edit_button.set_tooltip_text(_("Edit the selected client")) elif person_type == Transporter: objects = Transporter.get_active_transporters(store) self.add_button.set_tooltip_text(_("Add a new transporter")) self.edit_button.set_tooltip_text( _("Edit the selected transporter")) elif person_type == SalesPerson: objects = SalesPerson.get_active_salespersons(store) self.add_button.set_tooltip_text(_("Add a new sales person")) self.edit_button.set_tooltip_text( _("Edit the selected sales person")) elif person_type == Branch: objects = Branch.get_active_branches(store) self.add_button.set_tooltip_text(_("Add a new branch")) self.edit_button.set_tooltip_text(_("Edit the selected branch")) else: raise AssertionError(self.person_type) self.widget.prefill(api.for_person_combo(objects)) if person: assert isinstance(person, person_type) self.widget.select(person)
def _fill_clients_combo(self): # FIXME: This should not be using a normal ProxyComboEntry, # we need a specialized widget that does the searching # on demand. clients = Client.get_active_clients(self.store) self.client.prefill(api.for_person_combo(clients)) self.client.mandatory = True
def _fill_clients_combo(self): # FIXME: This should not be using a normal ProxyComboEntry, # we need a specialized widget that does the searching # on demand. items = Client.get_active_items(self.store) self.client.prefill(items) self.client.mandatory = True
def process_one(self, data, fields, store): person = Person( store=store, name=data.name, phone_number=data.phone_number, mobile_number=data.mobile_number) Individual(person=person, store=store, cpf=data.cpf, rg_number=data.rg) ctloc = CityLocation.get_or_create(store=store, city=data.city, state=data.state, country=data.country) streetnumber = data.streetnumber and int(data.streetnumber) or None Address( is_main_address=True, person=person, city_location=ctloc, store=store, street=data.street, streetnumber=streetnumber, district=data.district ) Client(person=person, store=store)
def test_update_credit_limit(self): client = self.create_client() client.salary = 100 # just setting paramater to a value that won't interfere in # the tests sysparam(self.store).update_parameter(u"CREDIT_LIMIT_SALARY_PERCENT", u"5") # testing if updates Client.update_credit_limit(10, self.store) client.credit_limit = AutoReload self.assertEquals(client.credit_limit, 10) # testing if it does not update client.credit_limit = 200 Client.update_credit_limit(0, self.store) self.assertEquals(client.credit_limit, 200)
def create_client(cls, store, name, cpf, address=None): # TODO: Add phone number person = Person(name=name, store=store) Individual(cpf=cpf, person=person, store=store) if address: cls.create_address(person, address) client = Client(person=person, store=store) return client
def test_generated_file_with_individual(self): individual = self.create_individual() individual.cpf = u'123.123.123-23' client = Client(person=individual.person, store=self.store) self._create_address(individual.person, street=u"Rua dos Tomates", streetnumber=2666, postal_code=u'87654-321') self._test_generated_files(client)
def _fill_clients_combo(self): marker('Filling clients') # FIXME: This should not be using a normal ProxyComboEntry, # we need a specialized widget that does the searching # on demand. clients = Client.get_active_clients(self.store) self.client.prefill(api.for_person_combo(clients)) self.client.set_sensitive(len(self.client.get_model())) marker('Filled clients')
def test_update_credit_limit(self): client = self.create_client() client.salary = 100 # just setting paramater to a value that won't interfere in # the tests sysparam(self.store).update_parameter( u"CREDIT_LIMIT_SALARY_PERCENT", u"5") # testing if updates Client.update_credit_limit(10, self.store) client.credit_limit = AutoReload self.assertEquals(client.credit_limit, 10) # testing if it does not update client.credit_limit = 200 Client.update_credit_limit(0, self.store) self.assertEquals(client.credit_limit, 200)
def _fill_clients_combo(self): # FIXME: This should not be using a normal ProxyComboEntry, # we need a specialized widget that does the searching # on demand. items = Client.get_active_items(self.store) self.client.prefill(items) # TODO: Implement a has_items() in kiwi self.client.set_sensitive(len(self.client.get_model()))
def test_generated_file_with_company(self): company = self.create_company() company.cnpj = u'123.456.789/1234-00' client = Client(person=company.person, store=self.store) self._create_address(company.person, street=u"Rua dos Tomates", streetnumber=2666, postal_code=u'87654-321') self._test_generated_files(client)
def _fill_clients_combo(self): # FIXME: This should not be using a normal ProxyComboEntry, # we need a specialized widget that does the searching # on demand. # This is to keep the clients in cache clients_cache = list(Client.get_active_clients(self.store)) clients_cache # pyflakes # We are using ClientView here to show the fancy name as well clients = ClientView.get_active_clients(self.store) items = [(c.get_description(), c.client) for c in clients] items = locale_sorted(items, key=operator.itemgetter(0)) self.client.prefill(items) # TODO: Implement a has_items() in kiwi self.client.set_sensitive(len(self.client.get_model()))
def _update_sale_client(self): """Update the sale client based on the informed document If the sale does not have a client yet, and the current_document (informed by the ecf plugin) is set, and a person with the given document exists, that client will be associated with this sale. """ if self.model.client or not self.wizard._current_document: return person = Person.get_by_document(self.store, str(self.wizard._current_document)) if not person: return if person.client: self.model.client = person.client else: self.model.client = Client(store=self.store, person=person)
def _create_examples(self): person = Person(name=u'Jonas', store=self.store) Individual(person=person, store=self.store) role = EmployeeRole(store=self.store, name=u'desenvolvedor') Employee(person=person, store=self.store, role=role) self.salesperson = SalesPerson(person=person, store=self.store) Company(person=person, store=self.store) client = Client(person=person, store=self.store) self.branch = Branch(person=person, store=self.store) group = self.create_payment_group() self.sale = Sale(coupon_id=123, client=client, cfop_id=self.sparam.get_object_id('DEFAULT_SALES_CFOP'), group=group, branch=self.branch, salesperson=self.salesperson, store=self.store) self.storable = self.create_storable()
def _fill_clients_combo(self): items = Client.get_active_items(self.store) self.client.prefill(items) self.client.set_sensitive(len(self.client.get_model()))
def _fill_clients_combo(self): clients = Client.get_active_clients(self.store) self.client.prefill(api.for_person_combo(clients))
def create_client(self, name=u'Client'): from stoqlib.domain.person import Client, Individual, Person person = Person(name=name, store=self.store) Individual(person=person, store=self.store) return Client(person=person, store=self.store)
def _fill_clients_combo(self): items = Client.get_active_items(self.store) self.client.prefill(items)
def create_model(self, store): person = BasePersonRoleEditor.create_model(self, store) client = person.client if client is None: client = Client(person=person, store=store) return client