Class s.d.s.Sale(ValidatableDomain):

Part of stoqlib.domain.sale View In Hierarchy

Sale object implementation.
Instance Variablesstatusstatus of the sale
clientwho we sold the sale to
salespersonwho sold the sale
branchbranch where the sale was done
tillThe Till operation where this sale lives. Note that every sale and payment generated are always in a till operation which defines a financial history of a store.
open_datethe date sale was created
close_datethe date sale was closed
confirm_datethe date sale was confirmed
cancel_datethe date sale was cancelled
return_datethe date sale was returned
discount_value
surcharge_value
total_amountthe total value of all the items in the same
notesSome optional additional information related to this sale.
coupon_id
service_invoice_number
cfop
invoice_numberthe sale invoice number.
Class VariablesSTATUS_INITIALThe sale is opened, products or other sellable items might have been added.
STATUS_ORDEREDThe sale is orded, it has sellable items but not any payments yet. This state is mainly used when the parameter CONFIRM_SALES_AT_TILL is enabled.
STATUS_CONFIRMEDThe sale has been confirmed and all payments have been registered, but not necessarily paid.
STATUS_CLOSEDAll the payments of the sale has been confirmed and the client does not owe anything to us.
STATUS_CANCELLEDThe sale has been canceled, this can only happen to an sale which has not yet reached the SALE_CONFIRMED status.
STATUS_RETURNEDThe sale has been returned, all the payments made have been canceled and the client has been compensated for everything already paid.
CLIENT_INDIVIDUALThe sale was done by an individual
CLIENT_COMPANYThe sale was done by a company
Method _create Undocumented
Class Method get_status_name Undocumented
Class Method get_last_confirmed Fetch the last confirmed sale
Class Method get_last_invoice_number Returns the last sale invoice number. If there is not an invoice
Method add_item Undocumented
Method get_items Undocumented
Method remove_item Undocumented
Method can_order Only newly created sales can be ordered
Method can_confirm Only ordered sales can be confirmed
Method can_set_paid Only confirmed sales can be paid
Method can_set_renegotiated Only sales with status confirmed can be renegotiated.
Method can_cancel Only ordered, confirmed, paid and quoting sales can be cancelled.
Method can_return Only confirmed or paid sales can be returned
Method order Orders the sale
Method confirm Confirms the sale
Method set_paid Mark the sale as paid
Method set_renegotiated Set the sale as renegotiated. The sale payments have been
Method cancel Cancel the sale
Method return_ Returns a sale
Method get_total_sale_amount Fetches the total value paid by the client.
Method get_sale_subtotal Fetch the subtotal for the sale, eg the sum of the
Method get_items_total_quantity Fetches the total number of items in the sale
Method get_details_str Returns the sale details. The details are composed by the sale
Method get_order_number_str Undocumented
Method get_salesperson_name Undocumented
Method get_client_name Undocumented
Method get_client_role Fetches the client role
Method only_paid_with_money Find out if the sale is paid using money
Method pay_money_payments Undocumented
Method add_sellable Adds a new sellable item to a sale
Method create_sale_return_adapter Undocumented
Method order_number Undocumented
Method products Undocumented
Method services Undocumented
Method payments Undocumented
Method _get_discount_by_percentage Undocumented
Method _set_discount_by_percentage Undocumented
Method _get_surcharge_by_percentage Undocumented
Method _set_surcharge_by_percentage Undocumented
Method _get_percentage_value Undocumented

Inherited from ValidatableDomain:

Method set_valid Undocumented
Method set_invalid Undocumented
Method get_valid Undocumented
Class Method select Undocumented
Class Method selectBy Undocumented
Class Method selectOne Undocumented
Class Method selectOneBy Undocumented

Inherited from Domain (via ValidatableDomain):

Method __init__ Undocumented
Method user Undocumented
Class Method iselect Like select, but search on the adapter implementing the interface iface
Class Method iselectBy Like selectBy, but search on the adapter implementing the interface iface
Class Method iselectOne Like selectOne, but search on the adapter implementing the interface iface
Class Method iselectOneBy Like selectOneBy, but search on the adapter implementing the interface iface
Class Method iget Like get, but gets on the adapter implementing the interface iface

Inherited from AbstractModel (via ValidatableDomain, Domain, BaseDomain):

Method __ne__ Undocumented
Method __eq__ Undocumented
Method _SO_setValue Undocumented
Method clone Get a persistent copy of an existent object. Remember that we can
Method get_connection Undocumented

Inherited from AdaptableORMObject (via ValidatableDomain, Domain):

Class Method registerFacet Registers a facet for class cls.

Inherited from Adaptable (via ValidatableDomain, Domain, AdaptableORMObject):

Class Method getFacetType Fetches a facet type associated with an interface, or raise
Class Method getFacetTypes Returns facet classes for this object
Method addFacet Adds a facet implementing iface for the current object
Method removeFacet Removes a facet from the current object
Method getFacets Gets a list of facets assoicated with the current object.
def _create(self, id, **kw):
Undocumented
@classmethod
def get_status_name(cls, status):
Undocumented
@classmethod
def get_last_confirmed(cls, conn):
Fetch the last confirmed sale
Parametersconna database connection
@classmethod
def get_last_invoice_number(cls, conn):
Returns the last sale invoice number. If there is not an invoice number used, the returned value will be zero.
Parametersconna database connection
Returnsan integer representing the last sale invoice number
@argcheck(SaleItem)
def add_item(self, sale_item):
Undocumented
def get_items(self):
Undocumented
@argcheck(SaleItem)
def remove_item(self, sale_item):
Undocumented
def can_order(self):
Only newly created sales can be ordered
ReturnsTrue if the sale can be ordered, otherwise False
def can_confirm(self):
Only ordered sales can be confirmed
ReturnsTrue if the sale can be confirmed, otherwise False
def can_set_paid(self):
Only confirmed sales can be paid
ReturnsTrue if the sale can be set as paid, otherwise False
def can_set_renegotiated(self):
Only sales with status confirmed can be renegotiated.
ReturnsTrue if the sale can be renegotiated, False otherwise.
def can_cancel(self):
Only ordered, confirmed, paid and quoting sales can be cancelled.
ReturnsTrue if the sale can be cancelled, otherwise False
def can_return(self):
Only confirmed or paid sales can be returned
ReturnsTrue if the sale can be returned, otherwise False
def order(self):
Orders the sale Ordering a sale is the first step done after creating it. The state of the sale will change to Sale.STATUS_ORDERED. To order a sale you need to add sale items to it. A client might also be set for the sale, but it is not necessary.
def confirm(self):
Confirms the sale Confirming a sale means that the customer has confirmed the sale. Sale items containing products are physically received and the payments are agreed upon but not necessarily received.
def set_paid(self):
Mark the sale as paid Marking a sale as paid means that all the payments have been received.
def set_renegotiated(self):
Set the sale as renegotiated. The sale payments have been renegotiated and the operations will be done in other payment group.
def cancel(self):
Cancel the sale You can only cancel an ordered sale.
@argcheck(RenegotiationData)
def return_(self, renegotiation):
Returns a sale Returning a sale means that all the items are returned to the item. A renegotiation object needs to be supplied which contains the invoice number and the eventual penalty
Parametersrenegotiationrenegotiation information (type: RenegotiationData )
def get_total_sale_amount(self):

Fetches the total value paid by the client. It can be calculated as:

   Sale total = Sum(product and service prices) + surcharge +
                    interest - discount
Returnsthe total value
def get_sale_subtotal(self):
Fetch the subtotal for the sale, eg the sum of the prices for of all items
Returnssubtotal
def get_items_total_quantity(self):
Fetches the total number of items in the sale
Returnsnumber of items
def get_details_str(self):
Returns the sale details. The details are composed by the sale notes, the items notes, the delivery address and the estimated fix date.
Returnsthe sale details string.
def get_order_number_str(self):
Undocumented
def get_salesperson_name(self):
Undocumented
def get_client_name(self):
Undocumented
def get_client_role(self):
Fetches the client role
Returnsthe client role (a PersonAdaptToIndividual or a PersonAdaptToCompany) instance or None if the sale haven't a client.
def only_paid_with_money(self):
Find out if the sale is paid using money
ReturnsTrue if the sale was paid with money, otherwise False (type: bool )
def pay_money_payments(self):
Undocumented
def add_sellable(self, sellable, quantity=1, price=None):
Adds a new sellable item to a sale
Parameterssellablethe sellable
quantityquantity to add, defaults to 1
priceoptional, the price, it not set the price from the sellable will be used
def create_sale_return_adapter(self):
Undocumented
@property
def order_number(self):
Undocumented
@property
def products(self):
Undocumented
@property
def services(self):
Undocumented
@property
def payments(self):
Undocumented
def _get_discount_by_percentage(self):
Undocumented
def _set_discount_by_percentage(self, value):
Undocumented
def _get_surcharge_by_percentage(self):
Undocumented
def _set_surcharge_by_percentage(self, value):
Undocumented
def _get_percentage_value(self, percentage):
Undocumented
API Documentation for Stoqlib, generated by pydoctor at 2009-07-14 16:00:32.