def get_order_item(self, sellable, price, quantity, batch=None, parent=None): if parent: if parent.sellable.product.is_package: component = self.get_component(parent, sellable) quantity = parent.quantity * component.quantity price = component.price else: # Do not add the components if its not a package product return if batch is not None: batch = StorableBatch.get_or_create( self.store, storable=sellable.product_storable, batch_number=batch) item = ReturnedSaleItem(store=self.store, quantity=quantity, price=price, sellable=sellable, batch=batch, returned_sale=self.model, parent_item=parent) _adjust_returned_sale_item(item) WizardAddSellableEvent.emit(self.wizard, item) return item
def get_order_item(self, sellable, price, quantity, batch=None, parent=None): if parent: if parent.sellable.product.is_package: component = self.get_component(parent, sellable) quantity = parent.quantity * component.quantity price = component.price else: # Do not add the components if its not a package product return if batch is not None: batch = StorableBatch.get_or_create( self.store, storable=sellable.product_storable, batch_number=batch) item = ReturnedSaleItem( store=self.store, quantity=quantity, price=price, sellable=sellable, batch=batch, returned_sale=self.model, parent_item=parent ) _adjust_returned_sale_item(item) WizardAddSellableEvent.emit(self.wizard, item) return item
def get_order_item(self, sellable, cost, quantity, batch=None, parent=None): item = self.model.add_sellable(sellable, cost, quantity, batch=batch) WizardAddSellableEvent.emit(self.wizard, item) return item
def get_order_item(self, sellable, price, quantity, batch=None, parent=None): """ :param sellable: the |sellable| :param price: the price the sellable is being sold :param quantity: the quantity for that is being sold :param batch: the |storable_batch| if exists :param parent: |sale_item|'s parent_item if exists """ if parent: component = self.get_component(parent, sellable) quantity = parent.quantity * component.quantity price = component.price else: if sellable.product and sellable.product.is_package: # XXX Sending package products with price 0 (zero) price = Decimal(0) item = self.model.add_sellable(sellable, quantity=quantity, price=price, batch=batch, parent=parent) # Save temporarily the stock quantity and lead_time so we can show a # warning if there is not enough quantity for the sale. if not parent: item._stock_quantity = self.proxy.model.stock_quantity # When the product does not have stock control. Use the # sellable cost information item.average_cost = sellable.cost else: storable = sellable.product_storable stock_item = self.store.find(ProductStockItem, storable=storable, batch=batch, branch=self.model.branch).one() # FIXME: Currently uses the cost of the supplier or cost sellable. # Implement batch control for the cost of the lot not the product. if stock_item is not None: item.average_cost = stock_item.stock_cost stock = storable.get_balance_for_branch(self.model.branch) item._stock_quantity = stock # FIXME: deliver is used by the DeliveryEditor. Idealy we shouldn't # have to add this here since it could lead to unpredicted errors # in the future (e.g. someone could add a 'deliver' column on item) item.deliver = False item.update_tax_values() WizardAddSellableEvent.emit(self.wizard, item) return item
def get_order_item(self, sellable, price, quantity, batch=None, parent=None): item = self.model.add_sellable(sellable, quantity, price, batch=batch) item._stock_quantity = self.proxy.model.stock_quantity WizardAddSellableEvent.emit(self.wizard, item) return item
def get_order_item(self, sellable, cost, quantity, batch=None, parent=None): item = self.model.add_sellable(sellable, cost, quantity, batch=batch) # FIXME this attibute is used by DeliveyEditor item.deliver = False WizardAddSellableEvent.emit(self.wizard, item) return item