def can_remove(self): if sysparam.compare_object("DELIVERY_SERVICE", self): # The delivery item cannot be deleted as it's important # for creating deliveries. return False return super(Service, self).can_remove()
def _setup_widgets(self): self._test_button = gtk.Button(_("Print a test bill")) self._test_button.connect('clicked', self._on_test_button__clicked) self.parent_accounts = AccountTree(with_code=False, create_mode=True) self.parent_accounts.connect('selection-changed', self._on_parent_accounts__selection_changed) self.tree_box.pack_start(self.parent_accounts) self.tree_box.reorder_child(self.parent_accounts, 0) if sysparam.compare_object('IMBALANCE_ACCOUNT', self.model): self.account_type.set_sensitive(False) self.account_type.prefill(Account.account_type_descriptions) account_type = self.model.account_type self.parent_accounts.insert_initial(self.store, edited_account=self.model) if self.parent_account: account = self.parent_accounts.get_account_by_id( self.parent_account.id) self.parent_accounts.select(account) if not self.existing: account_type = account.account_type self.account_type.select(account_type) self.parent_accounts.show()
def _setup_widgets(self): self._test_button = Gtk.Button(_("Print a test bill")) self._test_button.connect('clicked', self._on_test_button__clicked) self.parent_accounts = AccountTree(with_code=False, create_mode=True) self.parent_accounts.connect( 'selection-changed', self._on_parent_accounts__selection_changed) self.tree_box.pack_start(self.parent_accounts, True, True, 0) self.tree_box.reorder_child(self.parent_accounts, 0) if sysparam.compare_object('IMBALANCE_ACCOUNT', self.model): self.account_type.set_sensitive(False) self.account_type.prefill(Account.account_type_descriptions) account_type = self.model.account_type self.parent_accounts.insert_initial(self.store, edited_account=self.model) if self.parent_account: account = self.parent_accounts.get_account_by_id( self.parent_account.id) self.parent_accounts.select(account) if not self.existing: account_type = account.account_type self.account_type.select(account_type) self.parent_accounts.show()
def can_remove(self): if sysparam.compare_object('DELIVERY_SERVICE', self): # The delivery item cannot be deleted as it's important # for creating deliveries. return False return super(Service, self).can_remove()
def is_available(self): """Whether the sellable is available and can be sold. :returns: ``True`` if the item can be sold, ``False`` otherwise. """ # FIXME: Perhaps this should be done elsewhere. Johan 2008-09-26 if sysparam.compare_object('DELIVERY_SERVICE', self.service): return True return self.status == self.STATUS_AVAILABLE
def can_remove(self): """If the account can be removed. Not all accounts can be removed, some are internal to Stoq and cannot be removed""" # Can't remove accounts that are used in a parameter if (sysparam.compare_object('IMBALANCE_ACCOUNT', self) or sysparam.compare_object('TILLS_ACCOUNT', self) or sysparam.compare_object('BANKS_ACCOUNT', self)): return False # Can't remove station accounts if self.station: return False # Can't remove an account which has children if self.has_child_accounts(): return False return True
def can_remove(self): if sysparam.compare_object('DELIVERY_SERVICE', self): # The delivery item cannot be deleted as it's important # for creating deliveries. return False # False if the service is used in a production. if self.store.find(ProductionService, service=self).count(): return False return True
def can_remove(self): """If the account can be removed. Not all accounts can be removed, some are internal to Stoq and cannot be removed""" # Can't remove accounts that are used in a parameter if (sysparam.compare_object('IMBALANCE_ACCOUNT', self) or sysparam.compare_object('TILLS_ACCOUNT', self) or sysparam.compare_object('BANKS_ACCOUNT', self)): return False # Can't remove station accounts if self.station: return False # When we remove this Account, all the related AccountTransaction will # be assigned to the IMBALANCE_ACCOUNT and BankAccount will be removed, # so we need to skip them here return super(Account, self).can_remove( skip=[('account_transaction', 'account_id'), ('account_transaction', 'source_account_id'), ('bank_account', 'account_id')])
def _edit_sale_item(self, sale_item): if sale_item.service: if sysparam.compare_object('DELIVERY_SERVICE', sale_item.service): self._edit_delivery() return with api.new_store() as store: model = self.run_dialog(ServiceItemEditor, store, sale_item) if model: self.sale_items.update(sale_item) else: # Do not raise any exception here, since this method can be called # when the user activate a row with product in the sellables list. return
def get_data(self): sheets = {} for account in Account.get_children_for(self.store, parent=None): if sysparam.compare_object('IMBALANCE_ACCOUNT', account): continue columns = [] for start, end in get_month_intervals_for_year(self.year): column = [] self._prepare_items(column, account, start, end) columns.append(column) # Skip empty sheets if sum(item[1] for c in columns for item in c) == 0: continue sheets[account.description] = columns return sheets
def _update_widgets(self): has_sale_items = len(self.sale_items) >= 1 self.set_sensitive((self.checkout_button, self.remove_item_button, self.NewDelivery, self.ConfirmOrder), has_sale_items) # We can cancel an order whenever we have a coupon opened. self.set_sensitive([self.CancelOrder], self._sale_started) has_products = False has_services = False for sale_item in self.sale_items: if sale_item and sale_item.sellable.product: has_products = True if sale_item and sale_item.service: has_services = True if has_products and has_services: break self.set_sensitive([self.delivery_button], has_products) self.set_sensitive([self.NewDelivery], has_sale_items) sale_item = self.sale_items.get_selected() if sale_item is not None and sale_item.service: # We are fetching DELIVERY_SERVICE into the sale_items' store # instead of the default store to avoid accidental commits. can_edit = not sysparam.compare_object('DELIVERY_SERVICE', sale_item.service) else: can_edit = False self.set_sensitive([self.edit_item_button], can_edit) self.set_sensitive([self.remove_item_button], sale_item is not None and sale_item.can_remove) self.set_sensitive((self.checkout_button, self.ConfirmOrder), has_products or has_services) self.till_status_box.props.visible = not self._sale_started self.sale_items.props.visible = self._sale_started self._update_totals() self._update_buttons()
def can_close(self): # The delivery item cannot be closed as it will be # used for deliveries. return not sysparam.compare_object('DELIVERY_SERVICE', self)
def process_item(self, store, i): t = self.tp.transactions[i] date = self._parse_date(t["dtposted"]) # Do not import transactions with broken dates if date is None: self.skipped += 1 return False value = self._parse_number(t["trnamt"]) description = self._parse_string(t["memo"]) if value == 0: self.skipped += 1 # We can't import transactions without a value = 0, skip it. return False elif value > 0: operation_type = AccountTransaction.TYPE_IN source_account = store.get(Account, self.source_account_id) account = store.get(Account, self.account_id) elif value < 0: # Only register absolute values - Indicating positive/negative values, # using the operation type. value = abs(value) operation_type = AccountTransaction.TYPE_OUT source_account = store.get(Account, self.account_id) account = store.get(Account, self.source_account_id) code = self._parse_string(t["checknum"]) if not store.find(AccountTransaction, date=date, code=code, value=value).is_empty(): # Skip already present transactions self.skipped += 1 return False # TODO: Check if value and code are enough to consider a match. existing = list( store.find( AccountTransaction, And( AccountTransaction.value == value, Trim(u"LEADING", u"0", AccountTransaction.code) == code.lstrip("0"), ), ) ) if len(existing) == 1: t = existing[0] t.description = description t.date = date # Categorize the transaction if it was still on imbalance if sysparam.compare_object("IMBALANCE_ACCOUNT", t.source_account): t.source_account = source_account if sysparam.compare_object("IMBALANCE_ACCOUNT", t.account): t.account = account else: t = AccountTransaction( store=store, source_account=source_account, account=account, description=description, code=code, value=value, date=date, operation_type=operation_type, ) store.flush() return True
def _is_default_salesperson_role(self): return sysparam.compare_object('DEFAULT_SALESPERSON_ROLE', self.model.role)
def _is_default_salesperson_role(self): return sysparam.compare_object("DEFAULT_SALESPERSON_ROLE", self.model.role)
def can_close(self): # The delivery item cannot be closed as it will be # used for deliveries. return not sysparam.compare_object("DELIVERY_SERVICE", self)
def process_item(self, store, i): t = self.tp.transactions[i] date = self._parse_date(t['dtposted']) # Do not import transactions with broken dates if date is None: self.skipped += 1 return False value = self._parse_number(t['trnamt']) description = self._parse_string(t['memo']) if value == 0: self.skipped += 1 # We can't import transactions without a value = 0, skip it. return False elif value > 0: operation_type = AccountTransaction.TYPE_IN source_account = store.get(Account, self.source_account_id) account = store.get(Account, self.account_id) elif value < 0: # Only register absolute values - Indicating positive/negative values, # using the operation type. value = abs(value) operation_type = AccountTransaction.TYPE_OUT source_account = store.get(Account, self.account_id) account = store.get(Account, self.source_account_id) code = self._parse_string(t['checknum']) if not store.find( AccountTransaction, date=date, code=code, value=value).is_empty(): # Skip already present transactions self.skipped += 1 return False # TODO: Check if value and code are enough to consider a match. existing = list( store.find( AccountTransaction, And( AccountTransaction.value == value, Trim(u'LEADING', u'0', AccountTransaction.code) == code.lstrip('0')))) if len(existing) == 1: t = existing[0] t.description = description t.date = date # Categorize the transaction if it was still on imbalance if sysparam.compare_object('IMBALANCE_ACCOUNT', t.source_account): t.source_account = source_account if sysparam.compare_object('IMBALANCE_ACCOUNT', t.account): t.account = account else: t = AccountTransaction(store=store, source_account=source_account, account=account, description=description, code=code, value=value, date=date, operation_type=operation_type) store.flush() return True