Esempio n. 1
0
    def __init__(self, parent, id, list_sales_current, details_sale):
        # begin wxGlade: RightPanel_view.__init__
        self.statusSale = False
        self.statusSalePending = False
        self.statusDue = True
        self.statusDiscount = True
        self.sale_id = 0 
        self.valid = False
        self.parent = parent
        self.pos = self.parent.GetParent().pos	#Obtiene el padre en este caso es la ventana de opening para sacar el pos
        img_opening = Platform("/img/toolbars/opening.png")
        img_addsale = Platform("/img/toolbars/add.png")
        img_cancel = Platform("/img/toolbars/cancellation.png")



        self.helpers_sale = Sale_helper(self.parent)
        self.list_sales_current = list_sales_current
        self.details_sale = details_sale

        wx.Panel.__init__(self, parent, id)
        self.p_maintoolbar = wx.Panel(self, -1, style=wx.SIMPLE_BORDER|wx.TAB_TRAVERSAL)
        self.bm_opening = wx.BitmapButton(self.p_maintoolbar, -1, wx.Bitmap(img_opening.string, wx.BITMAP_TYPE_ANY))
        self.sl_1 = wx.StaticLine(self.p_maintoolbar, -1)
        self.tc_searchsale = wx.TextCtrl(self.p_maintoolbar, -1, "")
        self.bm_addsale = wx.BitmapButton(self.p_maintoolbar, -1, wx.Bitmap(img_addsale.string, wx.BITMAP_TYPE_ANY))
        self.sl_2 = wx.StaticLine(self.p_maintoolbar, -1)
        self.bm_cancel = wx.BitmapButton(self.p_maintoolbar, -1, wx.Bitmap(img_cancel.string, wx.BITMAP_TYPE_ANY))
        self.p_content = SalesList_view(self, -1)

        self.Bind(wx.EVT_BUTTON, self.new_sale, id = self.bm_addsale.GetId())
        self.Bind(wx.EVT_BUTTON, self.cancel_sale, id = self.bm_cancel.GetId())

        self.__set_properties()
        self.__do_layout()
Esempio n. 2
0
    def __init__(self, parent, id):
        self.parent = parent
        self.list_sales_current = self.parent.list_sales_current
        self.helpers_sale = Sale_helper(self.parent)
        wx.Panel.__init__(self, parent, id)

        self.controller = SalesList(self.parent.pos)
        self.controller.get_sales()
        self.controller.get_total_products()
        self.controller.get_total_all()
                
        self.l_venta = wx.StaticText(self, -1, "Ventas")
        self.lc_saleslist = wx.ListCtrl(self, -1, style=wx.LC_REPORT|wx.SUNKEN_BORDER)
        self.lc_saleslist.InsertColumn(0,'') 
        self.lc_saleslist.InsertColumn(1,'id')
        self.lc_saleslist.InsertColumn(2,'SKU')
        self.lc_saleslist.InsertColumn(3,'Venta')
        self.lc_saleslist.InsertColumn(4,'Productos')
        self.lc_saleslist.InsertColumn(5,'Total')
        self.lc_saleslist.SetColumnWidth(0, 50)
        self.lc_saleslist.SetColumnWidth(1, 50)
        self.lc_saleslist.SetColumnWidth(2, 130)
        self.lc_saleslist.SetColumnWidth(3, 210)
        self.lc_saleslist.SetColumnWidth(4, 100)
        self.lc_saleslist.SetColumnWidth(5, 200)
        
        self.list_sales()

        self.Bind(wx.EVT_LIST_ITEM_ACTIVATED, self.details_sale, self.lc_saleslist)
        
        self.__set_properties()
        self.__do_layout()
Esempio n. 3
0
    def __init__(self, parent, id):
        self.parent = parent	#obtiene el splitter del lado izquierdo
        self.GetParent = self.parent.GetParent()	#Obtiene el padre en este caso es la ventana de opening
        self.controller = Stock()
        self.controller.get_stock(self.GetParent.pos)
        self.controller_sale = Sale()
        self.helpers_sale = Sale_helper(self.GetParent)
        img_logo = Platform("/img/09_64x64.png")
        img_product = Platform("/img/product.png")
        
        wx.Panel.__init__(self, parent, id)
        self.p_info = wx.Panel(self, -1, style=wx.DOUBLE_BORDER|wx.TAB_TRAVERSAL)
        self.notebook = wx.Notebook(self, -1, style=0)
        self.notebook_panel = wx.Panel(self.notebook, -1)
        self.bm_logo = wx.StaticBitmap(self, -1, wx.Bitmap(img_logo.string, wx.BITMAP_TYPE_ANY))
        self.l_japos = wx.StaticText(self, -1, "JAPOS")
        self.tc_search = wx.TextCtrl(self.notebook_panel, -1, "", style=wx.TE_PROCESS_ENTER)
        self.l_search = wx.StaticText(self.notebook_panel, -1, "Search...")
        
        self.lc_products = wx.ListCtrl(self.notebook_panel, -1, style=wx.LC_REPORT|wx.SUNKEN_BORDER)
        self.lc_products.InsertColumn(0,'Nombre') 
        self.lc_products.InsertColumn(1,'Precio')
        self.lc_products.InsertColumn(2,'Disponible')
        self.lc_products.SetColumnWidth(0, 150)
        self.lc_products.SetColumnWidth(1, 50)
        self.lc_products.SetColumnWidth(2, 85)

        self.list_products()
            
        self.l_info = wx.StaticText(self, -1, "Informacion del producto:")
        self.bm_product = wx.StaticBitmap(self.p_info, -1, wx.Bitmap(img_product.string, wx.BITMAP_TYPE_ANY))
        self.l_name = wx.StaticText(self.p_info, -1, "Nombre")
        self.l_available = wx.StaticText(self.p_info, -1, "Disponible: ")
        self.l_barcode = wx.StaticText(self.p_info, -1, "codigo")
        self.l_stock = wx.StaticText(self.p_info, -1, "Existencia: 16")
        self.sl_1 = wx.StaticLine(self.p_info, -1)
        self.l_psale = wx.StaticText(self.p_info, -1, "Precio venta:")
        self.l_vsale = wx.StaticText(self.p_info, -1, "0")
        self.l_discount = wx.StaticText(self.p_info, -1, "Descuento:")
        self.l_vdiscount = wx.StaticText(self.p_info, -1, "0")
        self.l_pbuy = wx.StaticText(self.p_info, -1, "Precio compra:")
        self.l_vbuy = wx.StaticText(self.p_info, -1, "0")
        self.l_tax = wx.StaticText(self.p_info, -1, "Impuesto:")
        self.l_vtax = wx.StaticText(self.p_info, -1, "0")
        self.sl_2 = wx.StaticLine(self.p_info, -1)
        self.l_description = wx.StaticText(self.p_info, -1, "Descripcion del producto aqui")
        
        self.Bind(wx.EVT_LIST_ITEM_SELECTED, self.get_product_info, self.lc_products)
        self.Bind(wx.EVT_LIST_ITEM_ACTIVATED, self.add_product_sale, self.lc_products)
        self.tc_search.Bind(wx.EVT_TEXT_ENTER, self.search)

        self.__set_properties()
        self.__do_layout()
Esempio n. 4
0
    def __init__(self, parent, id):
        self.parent = parent
        img_leave = Platform("/img/toolbars/exit.png")
        img_delete = Platform("/img/toolbars/delete.png")
        img_printer = Platform("/img/toolbars/printer.png")
        img_discount = Platform("/img/toolbars/discount.png")
        img_pay = Platform("/img/toolbars/pay.png")

        self.helpers_sale = Sale_helper(self.parent)

        wx.Panel.__init__(self, parent, id)
        self.p_toolbarinf = wx.Panel(self, -1, style=wx.SIMPLE_BORDER|wx.TAB_TRAVERSAL)
        self.p_total = wx.Panel(self, -1)
        self.l_sale = wx.StaticText(self, -1, "Venta 2009-22")
        self.lc_sale = SaleListCtrl(self, -1, style=wx.LC_REPORT|wx.SUNKEN_BORDER)

        self.lc_sale.InsertColumn(0, "Name")
        self.lc_sale.SetColumnWidth(0, 480)
        self.lc_sale.InsertColumn(1, "Amount")
        self.lc_sale.SetColumnWidth(1, 100)
        self.lc_sale.InsertColumn(2, "Price")
        self.lc_sale.SetColumnWidth(2, 150)
        self.lc_sale.InsertColumn(3, "Total")
        self.lc_sale.SetColumnWidth(3, 150)

        self.l_subtotal = wx.StaticText(self.p_total, -1, "Subtotal:")
        self.l_tax = wx.StaticText(self.p_total, -1, "Impuesto:")
        self.l_total = wx.StaticText(self.p_total, -1, "Total:")
        self.l_vsubtotal = wx.StaticText(self.p_total, -1, "0.000")
        self.l_vstax = wx.StaticText(self.p_total, -1, "0.000")
        self.l_vtotal = wx.StaticText(self.p_total, -1, "0.000")
        self.bm_leave = wx.BitmapButton(self.p_toolbarinf, -1, wx.Bitmap(img_leave.string, wx.BITMAP_TYPE_ANY))
        self.static_line_1 = wx.StaticLine(self.p_toolbarinf, -1)
        self.tc_search = wx.TextCtrl(self.p_toolbarinf, -1, "")
        self.bm_delete = wx.BitmapButton(self.p_toolbarinf, -1, wx.Bitmap(img_delete.string, wx.BITMAP_TYPE_ANY))
        self.static_line_1_copy_1 = wx.StaticLine(self.p_toolbarinf, -1)
        self.bm_printer = wx.BitmapButton(self.p_toolbarinf, -1, wx.Bitmap(img_printer.string, wx.BITMAP_TYPE_ANY))
        self.bm_discount = wx.BitmapButton(self.p_toolbarinf, -1, wx.Bitmap(img_discount.string, wx.BITMAP_TYPE_ANY))
        self.bm_pay = wx.BitmapButton(self.p_toolbarinf, -1, wx.Bitmap(img_pay.string, wx.BITMAP_TYPE_ANY))

        self.Bind(wx.EVT_BUTTON, self.cancel, id = self.bm_delete.GetId())
        self.Bind(wx.EVT_BUTTON, self.leave, id = self.bm_leave.GetId())
        self.Bind(wx.EVT_BUTTON, self.printer, id = self.bm_printer.GetId())
        self.Bind(wx.EVT_BUTTON, self.discount, id = self.bm_discount.GetId())
        self.Bind(wx.EVT_BUTTON, self.pay, id = self.bm_pay.GetId())
        #self.Bind(wx.EVT_LIST_ITEM_DESELECTED, self.delete_product, self.lc_sale)
        self.Bind(wx.EVT_LIST_END_LABEL_EDIT, self.delete_product, self.lc_sale)       

        self.__set_properties()
        self.__do_layout()
Esempio n. 5
0
class Sale_view(wx.Panel):
    def __init__(self, parent, id):
        self.parent = parent
        img_leave = Platform("/img/toolbars/exit.png")
        img_delete = Platform("/img/toolbars/delete.png")
        img_printer = Platform("/img/toolbars/printer.png")
        img_discount = Platform("/img/toolbars/discount.png")
        img_pay = Platform("/img/toolbars/pay.png")

        self.helpers_sale = Sale_helper(self.parent)

        wx.Panel.__init__(self, parent, id)
        self.p_toolbarinf = wx.Panel(self, -1, style=wx.SIMPLE_BORDER|wx.TAB_TRAVERSAL)
        self.p_total = wx.Panel(self, -1)
        self.l_sale = wx.StaticText(self, -1, "Venta 2009-22")
        self.lc_sale = SaleListCtrl(self, -1, style=wx.LC_REPORT|wx.SUNKEN_BORDER)

        self.lc_sale.InsertColumn(0, "Name")
        self.lc_sale.SetColumnWidth(0, 480)
        self.lc_sale.InsertColumn(1, "Amount")
        self.lc_sale.SetColumnWidth(1, 100)
        self.lc_sale.InsertColumn(2, "Price")
        self.lc_sale.SetColumnWidth(2, 150)
        self.lc_sale.InsertColumn(3, "Total")
        self.lc_sale.SetColumnWidth(3, 150)

        self.l_subtotal = wx.StaticText(self.p_total, -1, "Subtotal:")
        self.l_tax = wx.StaticText(self.p_total, -1, "Impuesto:")
        self.l_total = wx.StaticText(self.p_total, -1, "Total:")
        self.l_vsubtotal = wx.StaticText(self.p_total, -1, "0.000")
        self.l_vstax = wx.StaticText(self.p_total, -1, "0.000")
        self.l_vtotal = wx.StaticText(self.p_total, -1, "0.000")
        self.bm_leave = wx.BitmapButton(self.p_toolbarinf, -1, wx.Bitmap(img_leave.string, wx.BITMAP_TYPE_ANY))
        self.static_line_1 = wx.StaticLine(self.p_toolbarinf, -1)
        self.tc_search = wx.TextCtrl(self.p_toolbarinf, -1, "")
        self.bm_delete = wx.BitmapButton(self.p_toolbarinf, -1, wx.Bitmap(img_delete.string, wx.BITMAP_TYPE_ANY))
        self.static_line_1_copy_1 = wx.StaticLine(self.p_toolbarinf, -1)
        self.bm_printer = wx.BitmapButton(self.p_toolbarinf, -1, wx.Bitmap(img_printer.string, wx.BITMAP_TYPE_ANY))
        self.bm_discount = wx.BitmapButton(self.p_toolbarinf, -1, wx.Bitmap(img_discount.string, wx.BITMAP_TYPE_ANY))
        self.bm_pay = wx.BitmapButton(self.p_toolbarinf, -1, wx.Bitmap(img_pay.string, wx.BITMAP_TYPE_ANY))

        self.Bind(wx.EVT_BUTTON, self.cancel, id = self.bm_delete.GetId())
        self.Bind(wx.EVT_BUTTON, self.leave, id = self.bm_leave.GetId())
        self.Bind(wx.EVT_BUTTON, self.printer, id = self.bm_printer.GetId())
        self.Bind(wx.EVT_BUTTON, self.discount, id = self.bm_discount.GetId())
        self.Bind(wx.EVT_BUTTON, self.pay, id = self.bm_pay.GetId())
        #self.Bind(wx.EVT_LIST_ITEM_DESELECTED, self.delete_product, self.lc_sale)
        self.Bind(wx.EVT_LIST_END_LABEL_EDIT, self.delete_product, self.lc_sale)       

        self.__set_properties()
        self.__do_layout()

    def __set_properties(self):
        self.l_sale.SetFont(wx.Font(20, wx.DEFAULT, wx.NORMAL, wx.BOLD, 0, ""))
        self.l_subtotal.SetFont(wx.Font(15, wx.DEFAULT, wx.NORMAL, wx.NORMAL, 0, ""))
        self.l_tax.SetFont(wx.Font(15, wx.DEFAULT, wx.NORMAL, wx.NORMAL, 0, "Lucida Grande"))
        self.l_total.SetFont(wx.Font(25, wx.DEFAULT, wx.NORMAL, wx.BOLD, 0, ""))
        self.l_vtotal.SetFont(wx.Font(25, wx.DEFAULT, wx.NORMAL, wx.BOLD, 0, ""))
        self.bm_leave.SetSize(self.bm_leave.GetBestSize())
        self.static_line_1.SetMinSize((1, 70))
        self.tc_search.SetMinSize((350, 30))
        self.bm_delete.SetSize(self.bm_delete.GetBestSize())
        self.static_line_1_copy_1.SetMinSize((1, 70))
        self.bm_printer.SetSize(self.bm_pay.GetBestSize())
        self.bm_discount.SetSize(self.bm_pay.GetBestSize())
        self.bm_pay.SetSize(self.bm_pay.GetBestSize())
        self.p_toolbarinf.SetBackgroundColour(wx.SystemSettings_GetColour(wx.SYS_COLOUR_WINDOWFRAME))

    def __do_layout(self):
        self.s_sale = wx.BoxSizer(wx.VERTICAL)
        sizer_7 = wx.FlexGridSizer(1, 8, 0, 0)
        self.s_total = wx.BoxSizer(wx.HORIZONTAL)
        self.s_values = wx.BoxSizer(wx.VERTICAL)
        self.s_terms = wx.BoxSizer(wx.VERTICAL)
        self.s_sale.Add(self.l_sale, 0, wx.ALL, 10)
        self.s_sale.Add(self.lc_sale, 1, wx.EXPAND, 0)
        self.s_terms.Add(self.l_subtotal, 0, wx.ALIGN_RIGHT, 0)
        self.s_terms.Add(self.l_tax, 0, wx.ALIGN_RIGHT, 0)
        self.s_terms.Add(self.l_total, 0, wx.ALIGN_RIGHT, 0)
        self.s_total.Add(self.s_terms, 1, 0, 0)
        self.s_values.Add(self.l_vsubtotal, 0, wx.ALIGN_RIGHT, 0)
        self.s_values.Add(self.l_vstax, 0, wx.ALIGN_RIGHT, 0)
        self.s_values.Add(self.l_vtotal, 0, wx.ALIGN_RIGHT, 0)
        self.s_total.Add(self.s_values, 1, wx.EXPAND, 0)
        self.p_total.SetSizer(self.s_total)
        self.s_sale.Add(self.p_total, 0, wx.ALL|wx.EXPAND, 10)
        sizer_7.Add(self.bm_leave, 0, wx.ALL|wx.ALIGN_CENTER_VERTICAL, 10)
        sizer_7.Add(self.static_line_1, 1, wx.ALL|wx.ALIGN_CENTER_HORIZONTAL, 10)
        sizer_7.Add(self.tc_search, 0, wx.ALL|wx.ALIGN_CENTER_VERTICAL, 10)
        sizer_7.Add(self.bm_delete, 0, wx.ALL|wx.ALIGN_CENTER_VERTICAL, 10)
        sizer_7.Add(self.static_line_1_copy_1, 1, wx.ALL|wx.ALIGN_CENTER_HORIZONTAL, 10)
        sizer_7.Add(self.bm_printer, 0, wx.ALL|wx.ALIGN_CENTER_VERTICAL, 10)
        sizer_7.Add(self.bm_discount, 0, wx.ALL|wx.ALIGN_CENTER_VERTICAL, 10)
        sizer_7.Add(self.bm_pay, 0, wx.ALL|wx.ALIGN_CENTER_VERTICAL, 10)
        self.p_toolbarinf.SetSizer(sizer_7)
        sizer_7.AddGrowableRow(0)
        sizer_7.AddGrowableCol(1)
        sizer_7.AddGrowableCol(2)
        sizer_7.AddGrowableCol(3)
        self.s_sale.Add(self.p_toolbarinf, 0, wx.EXPAND|wx.ALIGN_CENTER_HORIZONTAL, 0)
        self.SetSizer(self.s_sale)
        self.s_sale.Fit(self)

    def cancel(self, evt):
	    """
	    Cierra la venta actual, no la cancela que es diferente.
	    Solamente nunca ejecuta el evento de venta
	    """
	    self.parent.statusSalePending = False
	    self.parent.statusDue = True
	    self.parent.statusDiscount = True
	    self.parent.cancel_sale(None)

    def leave(self, evt):
	    """
	    Salir de la venta sin eliminar los productos, la
	    guarda temporalmente la venta pero no la registra 
	    hasta que se pague.
	    """
	    current_id =  len(self.parent.list_sales_current) + 1
	    sale_current = self.helpers_sale.get_products_sale(current_id)
	    print "SALE CURRENT", sale_current
	    self.parent.statusSalePending = False
	    self.parent.statusDue = True
	    self.parent.statusDiscount = True
	    self.parent.cancel_sale(sale_current)

    def pay(self, evt):
	    """
	    Muestra el dialogo de pago, en dado caso que el faltante sea igual
	    a cero ya no lo muestra, eso significa que el pago fue realizado
	    """
	    if self.lc_sale.GetItemCount() > 0:
		    if self.parent.statusDue:
			    self.pay = Pay_view(self.parent, -1)
			    self.pay.ShowModal()
		    elif float(self.parent.l_vdue.GetLabelText()) > 0 :
			    self.pay = Pay_view(self.parent, -1)
			    self.pay.ShowModal()

    def discount(self, evt):
	    """
	    Genera el descuento y lo aplica, pero debe ser autorizado
	    por un auditor
	    """
	    if self.lc_sale.GetItemCount() > 0 and self.parent.statusDiscount:
		    print "due", self.parent.statusDue
		    if self.parent.statusDue or self.parent.statusDiscount:
			    self.auth = Auth_view(self.parent, -1)
			    self.auth.ShowModal()

		    if self.parent.valid:
			    self.apply_discount()
		    #else:
			#    print "validfalse"
			#    print self.parent.valid

		
    def apply_discount(self):
	    self.discount = Discount_view(None, -1)
	    self.discount.ShowModal()
	    p = float(self.discount.cb_percentage.GetValue())
	    t = float(self.l_vtotal.GetLabel())
	    self.l_discount = wx.StaticText(self.p_total, -1, "Descuento")
	    v = (t * p) / 100
	    total = float(t) - v
	    self.l_vtotal.SetLabel(str(total))
	    self.l_vdiscount = wx.StaticText(self.p_total, -1, self.discount.cb_percentage.GetValue() + "%")
	    self.s_terms.Insert(2, self.l_discount, 0, wx.ALIGN_RIGHT, 0)
	    self.s_values.Insert(2, self.l_vdiscount, 0, wx.ALIGN_RIGHT, 0)
	    self.parent.p_content.Layout()
	    self.parent.statusDiscount = False

    def printer(self, evt ):
	    """
	    Impresion del ticket de venta
	    """
	    pass

    def delete_product(self, evt):
	    currentItem = evt.m_itemIndex
	    amount  = int(evt.GetItem().Text)
	    print amount
	    self.helpers_sale.update_sale_info(self.lc_sale, currentItem, amount)
	    if amount == 0:
		    index = self.lc_sale.GetFocusedItem()
		    self.lc_sale.DeleteItem(index)
Esempio n. 6
0
class LeftPanel_view(wx.Panel):
    def __init__(self, parent, id):
        self.parent = parent	#obtiene el splitter del lado izquierdo
        self.GetParent = self.parent.GetParent()	#Obtiene el padre en este caso es la ventana de opening
        self.controller = Stock()
        self.controller.get_stock(self.GetParent.pos)
        self.controller_sale = Sale()
        self.helpers_sale = Sale_helper(self.GetParent)
        img_logo = Platform("/img/09_64x64.png")
        img_product = Platform("/img/product.png")
        
        wx.Panel.__init__(self, parent, id)
        self.p_info = wx.Panel(self, -1, style=wx.DOUBLE_BORDER|wx.TAB_TRAVERSAL)
        self.notebook = wx.Notebook(self, -1, style=0)
        self.notebook_panel = wx.Panel(self.notebook, -1)
        self.bm_logo = wx.StaticBitmap(self, -1, wx.Bitmap(img_logo.string, wx.BITMAP_TYPE_ANY))
        self.l_japos = wx.StaticText(self, -1, "JAPOS")
        self.tc_search = wx.TextCtrl(self.notebook_panel, -1, "", style=wx.TE_PROCESS_ENTER)
        self.l_search = wx.StaticText(self.notebook_panel, -1, "Search...")
        
        self.lc_products = wx.ListCtrl(self.notebook_panel, -1, style=wx.LC_REPORT|wx.SUNKEN_BORDER)
        self.lc_products.InsertColumn(0,'Nombre') 
        self.lc_products.InsertColumn(1,'Precio')
        self.lc_products.InsertColumn(2,'Disponible')
        self.lc_products.SetColumnWidth(0, 150)
        self.lc_products.SetColumnWidth(1, 50)
        self.lc_products.SetColumnWidth(2, 85)

        self.list_products()
            
        self.l_info = wx.StaticText(self, -1, "Informacion del producto:")
        self.bm_product = wx.StaticBitmap(self.p_info, -1, wx.Bitmap(img_product.string, wx.BITMAP_TYPE_ANY))
        self.l_name = wx.StaticText(self.p_info, -1, "Nombre")
        self.l_available = wx.StaticText(self.p_info, -1, "Disponible: ")
        self.l_barcode = wx.StaticText(self.p_info, -1, "codigo")
        self.l_stock = wx.StaticText(self.p_info, -1, "Existencia: 16")
        self.sl_1 = wx.StaticLine(self.p_info, -1)
        self.l_psale = wx.StaticText(self.p_info, -1, "Precio venta:")
        self.l_vsale = wx.StaticText(self.p_info, -1, "0")
        self.l_discount = wx.StaticText(self.p_info, -1, "Descuento:")
        self.l_vdiscount = wx.StaticText(self.p_info, -1, "0")
        self.l_pbuy = wx.StaticText(self.p_info, -1, "Precio compra:")
        self.l_vbuy = wx.StaticText(self.p_info, -1, "0")
        self.l_tax = wx.StaticText(self.p_info, -1, "Impuesto:")
        self.l_vtax = wx.StaticText(self.p_info, -1, "0")
        self.sl_2 = wx.StaticLine(self.p_info, -1)
        self.l_description = wx.StaticText(self.p_info, -1, "Descripcion del producto aqui")
        
        self.Bind(wx.EVT_LIST_ITEM_SELECTED, self.get_product_info, self.lc_products)
        self.Bind(wx.EVT_LIST_ITEM_ACTIVATED, self.add_product_sale, self.lc_products)
        self.tc_search.Bind(wx.EVT_TEXT_ENTER, self.search)

        self.__set_properties()
        self.__do_layout()
        # end wxGlade

    def __set_properties(self):
        # begin wxGlade: LeftPanel_view.__set_properties
        self.l_japos.SetForegroundColour(wx.Colour(255, 255, 255))
        self.l_japos.SetFont(wx.Font(11, wx.DEFAULT, wx.NORMAL, wx.NORMAL, 0, "Lucida Grande"))
        self.l_search.SetForegroundColour(wx.Colour(255, 255, 255))
        self.l_info.SetForegroundColour(wx.Colour(255, 255, 255))
        self.l_info.SetFont(wx.Font(15, wx.DEFAULT, wx.NORMAL, wx.NORMAL, 0, ""))
        self.l_name.SetFont(wx.Font(11, wx.DEFAULT, wx.NORMAL, wx.BOLD, 0, ""))
        self.l_available.SetFont(wx.Font(11, wx.DEFAULT, wx.NORMAL, wx.NORMAL, 0, "Lucida Grande"))
        self.l_barcode.SetFont(wx.Font(11, wx.DEFAULT, wx.NORMAL, wx.NORMAL, 0, "Lucida Grande"))
        self.l_stock.SetFont(wx.Font(11, wx.DEFAULT, wx.NORMAL, wx.NORMAL, 0, "Lucida Grande"))
        self.l_psale.SetFont(wx.Font(11, wx.DEFAULT, wx.NORMAL, wx.NORMAL, 0, "Lucida Grande"))
        self.l_vsale.SetFont(wx.Font(11, wx.DEFAULT, wx.NORMAL, wx.NORMAL, 0, "Lucida Grande"))
        self.l_discount.SetFont(wx.Font(11, wx.DEFAULT, wx.NORMAL, wx.NORMAL, 0, "Lucida Grande"))
        self.l_vdiscount.SetFont(wx.Font(11, wx.DEFAULT, wx.NORMAL, wx.NORMAL, 0, "Lucida Grande"))
        self.l_pbuy.SetFont(wx.Font(11, wx.DEFAULT, wx.NORMAL, wx.NORMAL, 0, "Lucida Grande"))
        self.l_vbuy.SetFont(wx.Font(11, wx.DEFAULT, wx.NORMAL, wx.NORMAL, 0, "Lucida Grande"))
        self.l_tax.SetFont(wx.Font(11, wx.DEFAULT, wx.NORMAL, wx.NORMAL, 0, "Lucida Grande"))
        self.l_vtax.SetFont(wx.Font(11, wx.DEFAULT, wx.NORMAL, wx.NORMAL, 0, "Lucida Grande"))
        self.p_info.SetBackgroundColour(wx.Colour(255, 255, 255))
        # end wxGlade

    def __do_layout(self):
        # begin wxGlade: LeftPanel_view.__do_layout
        s_left = wx.BoxSizer(wx.VERTICAL)
        s_info = wx.BoxSizer(wx.VERTICAL)
        gs_row2 = wx.FlexGridSizer(2, 4, 0, 0)
        s_info_nombre = wx.BoxSizer(wx.HORIZONTAL)
        gs_row1 = wx.FlexGridSizer(2, 2, 0, 0)
        s_products = wx.BoxSizer(wx.VERTICAL)
        s_left.Add(self.bm_logo, 0, wx.ALL|wx.ALIGN_CENTER_HORIZONTAL, 5)
        s_left.Add(self.l_japos, 0, wx.ALIGN_CENTER_HORIZONTAL, 0)
        s_products.Add(self.tc_search, 0, wx.LEFT|wx.RIGHT|wx.EXPAND, 10)
        s_products.Add(self.l_search, 0, wx.LEFT|wx.RIGHT|wx.BOTTOM|wx.EXPAND, 10)
        s_products.Add(self.lc_products, 1, wx.LEFT|wx.RIGHT|wx.BOTTOM|wx.EXPAND|wx.ALIGN_CENTER_VERTICAL, 10)
        self.notebook_panel.SetSizer(s_products)
        self.notebook.AddPage(self.notebook_panel, "Productos")
        s_left.Add(self.notebook, 2, wx.ALL|wx.EXPAND|wx.ALIGN_CENTER_VERTICAL, 10)
        s_left.Add(self.l_info, 0, wx.LEFT|wx.RIGHT|wx.EXPAND, 10)
        s_info_nombre.Add(self.bm_product, 0, wx.LEFT|wx.TOP|wx.BOTTOM|wx.ALIGN_CENTER_VERTICAL, 5)
        gs_row1.Add(self.l_name, 0, wx.RIGHT|wx.EXPAND, 10)
        gs_row1.Add(self.l_available, 0, wx.RIGHT|wx.ALIGN_RIGHT, 15)
        gs_row1.Add(self.l_barcode, 0, wx.RIGHT|wx.EXPAND, 15)
        gs_row1.Add(self.l_stock, 0, wx.RIGHT|wx.ALIGN_RIGHT, 15)
        gs_row1.AddGrowableCol(0)
        gs_row1.AddGrowableCol(2)
        s_info_nombre.Add(gs_row1, 1, wx.ALL|wx.ALIGN_CENTER_VERTICAL, 10)
        s_info.Add(s_info_nombre, 0, wx.EXPAND, 0)
        s_info.Add(self.sl_1, 0, wx.LEFT|wx.RIGHT|wx.BOTTOM|wx.EXPAND, 10)
        gs_row2.Add(self.l_psale, 0, 0, 10)
        gs_row2.Add(self.l_vsale, 0, 0, 10)
        gs_row2.Add(self.l_discount, 0, 0, 10)
        gs_row2.Add(self.l_vdiscount, 0, wx.RIGHT|wx.ALIGN_RIGHT, 10)
        gs_row2.Add(self.l_pbuy, 0, 0, 0)
        gs_row2.Add(self.l_vbuy, 0, 0, 0)
        gs_row2.Add(self.l_tax, 0, 0, 0)
        gs_row2.Add(self.l_vtax, 0, 0, 0)
        gs_row2.AddGrowableCol(1)
        s_info.Add(gs_row2, 0, wx.LEFT|wx.RIGHT|wx.EXPAND, 10)
        s_info.Add(self.sl_2, 0, wx.ALL|wx.EXPAND, 10)
        s_info.Add(self.l_description, 0, wx.LEFT|wx.RIGHT|wx.BOTTOM|wx.EXPAND, 10)
        self.p_info.SetSizer(s_info)
        s_left.Add(self.p_info, 0, wx.ALL|wx.EXPAND, 10)
        self.SetSizer(s_left)
        s_left.Fit(self)
        # end wxGlade

    def search(self, evt):
        self.lc_products.DeleteAllItems()
        name = self.tc_search.GetValue()
        self.controller.get_stock(self.GetParent.pos, name)
        self.list_products()

    def list_products(self):
        for data in self.controller.values:
            index = self.lc_products.InsertStringItem(0, data[0])
            self.lc_products.SetStringItem(index,1, data[1])
            self.lc_products.SetStringItem(index,2, data[2])
            
    def get_product_info(self, evt):
	    """
	    Selecciona un producto y muestra su informacion a detalle
	    """
	    self.currentItem = evt.m_itemIndex
	    name = self.lc_products.GetItemText(self.currentItem)
	    self.set_info_product(name)

    def add_product_sale(self, evt):
	    """
	    Agrega un producto a la venta, cuando presionan enter sobre el producto
	    o al dar doble click sobre el.
	    """
	    if self.GetParent.wp_right.statusSale or self.GetParent.wp_right.statusSalePending:
		    self.currentItem = evt.m_itemIndex
		    name = self.lc_products.GetItemText(self.currentItem)
		    price = self.helpers_sale.get_column_text(self.lc_products, self.currentItem,1)
		    stock = self.helpers_sale.get_column_text(self.lc_products, self.currentItem,2)
		    amount = self.helpers_sale.insert_product(self.currentItem, name, price)
		    print "Agregando el producto..."
	    else:
			print "Crear venta"

    def set_info_product(self, name):
        self.controller.get_info_product(name)
        self.p_info.Layout()
        self.l_name.SetLabel(self.controller.info_product.product.name)
        self.l_available.SetLabel(" Disponible "+str(self.controller.info_product.product.stock))
        self.l_barcode.SetLabel(str(self.controller.info_product.product.barcode))
        self.l_stock.SetLabel(" Existencia " + str(self.controller.info_product.stock))
        self.l_vsale.SetLabel(str(self.controller.info_product.price))
        self.l_vdiscount.SetLabel(str(self.controller.info_product.product.discount))
        self.l_vbuy.SetLabel(str(self.controller.info_product.product.purchase_price))
        self.l_vtax.SetLabel(str(self.controller.info_product.tax))
        self.l_description.SetLabel(str(self.controller.info_product.product.description))
Esempio n. 7
0
class RightPanel_view(wx.Panel):
    def __init__(self, parent, id, list_sales_current, details_sale):
        # begin wxGlade: RightPanel_view.__init__
        self.statusSale = False
        self.statusSalePending = False
        self.statusDue = True
        self.statusDiscount = True
        self.sale_id = 0 
        self.valid = False
        self.parent = parent
        self.pos = self.parent.GetParent().pos	#Obtiene el padre en este caso es la ventana de opening para sacar el pos
        img_opening = Platform("/img/toolbars/opening.png")
        img_addsale = Platform("/img/toolbars/add.png")
        img_cancel = Platform("/img/toolbars/cancellation.png")



        self.helpers_sale = Sale_helper(self.parent)
        self.list_sales_current = list_sales_current
        self.details_sale = details_sale

        wx.Panel.__init__(self, parent, id)
        self.p_maintoolbar = wx.Panel(self, -1, style=wx.SIMPLE_BORDER|wx.TAB_TRAVERSAL)
        self.bm_opening = wx.BitmapButton(self.p_maintoolbar, -1, wx.Bitmap(img_opening.string, wx.BITMAP_TYPE_ANY))
        self.sl_1 = wx.StaticLine(self.p_maintoolbar, -1)
        self.tc_searchsale = wx.TextCtrl(self.p_maintoolbar, -1, "")
        self.bm_addsale = wx.BitmapButton(self.p_maintoolbar, -1, wx.Bitmap(img_addsale.string, wx.BITMAP_TYPE_ANY))
        self.sl_2 = wx.StaticLine(self.p_maintoolbar, -1)
        self.bm_cancel = wx.BitmapButton(self.p_maintoolbar, -1, wx.Bitmap(img_cancel.string, wx.BITMAP_TYPE_ANY))
        self.p_content = SalesList_view(self, -1)

        self.Bind(wx.EVT_BUTTON, self.new_sale, id = self.bm_addsale.GetId())
        self.Bind(wx.EVT_BUTTON, self.cancel_sale, id = self.bm_cancel.GetId())

        self.__set_properties()
        self.__do_layout()
        # end wxGlade

    def __set_properties(self):
        # begin wxGlade: RightPanel_view.__set_properties
        self.bm_opening.SetSize(self.bm_opening.GetBestSize())
        self.sl_1.SetMinSize((1, 70))
        self.tc_searchsale.SetMinSize((450, 30))
        self.bm_addsale.SetSize(self.bm_addsale.GetBestSize())
        self.sl_2.SetMinSize((1, 70))
        self.bm_cancel.SetSize(self.bm_cancel.GetBestSize())
        self.p_maintoolbar.SetBackgroundColour(wx.SystemSettings_GetColour(wx.SYS_COLOUR_WINDOWFRAME))
        # end wxGlade

    def __do_layout(self):
        # begin wxGlade: RightPanel_view.__do_layout
        self.s_right = wx.BoxSizer(wx.VERTICAL)
        s_maintoolbar = wx.FlexGridSizer(1, 6, 0, 0)
        s_maintoolbar.Add(self.bm_opening, 0, wx.ALL|wx.ALIGN_CENTER_VERTICAL, 10)
        s_maintoolbar.Add(self.sl_1, 1, wx.ALL|wx.ALIGN_CENTER_HORIZONTAL, 10)
        s_maintoolbar.Add(self.tc_searchsale, 0, wx.ALL|wx.ALIGN_CENTER_VERTICAL, 10)
        s_maintoolbar.Add(self.bm_addsale, 0, wx.ALL|wx.ALIGN_CENTER_VERTICAL, 10)
        s_maintoolbar.Add(self.sl_2, 1, wx.ALL|wx.ALIGN_CENTER_HORIZONTAL, 10)
        s_maintoolbar.Add(self.bm_cancel, 0, wx.ALL|wx.ALIGN_CENTER_VERTICAL, 10)
        self.p_maintoolbar.SetSizer(s_maintoolbar)
        s_maintoolbar.AddGrowableRow(0)
        s_maintoolbar.AddGrowableCol(1)
        s_maintoolbar.AddGrowableCol(2)
        s_maintoolbar.AddGrowableCol(3)
        self.s_right.Add(self.p_maintoolbar, 0, wx.EXPAND|wx.ALIGN_CENTER_HORIZONTAL, 0)
        self.s_right.Add(self.p_content, 1, wx.EXPAND, 10)
        self.SetSizer(self.s_right)
        self.s_right.Fit(self)

    def new_sale(self, evt):
	    self.statusSale = True
	    self.statusDue = True
	    self.statusDiscount = True
	
	    self.bm_addsale.Disable()
	    self.p_content.Destroy()
	    self.p_content = Sale_view(self, -1)
	    self.s_right.Add(self.p_content, 1, wx.EXPAND, 10)
	    self.Layout()

    def close_sale_list(self):
	    self.bm_addsale.Disable()
	    wx.CallAfter(self.set_details_sale)

    def set_details_sale(self):
	    """
	    Elimina el panel que contiene la lista de ventas
	    actuales y carga la informacion de la venta selecciona
	    al panel de venta.
	    """
	    self.statusSale = False
	    self.statusSalePending = True
	    self.p_content.Destroy()
	    self.p_content = Sale_view(self, -1)
	    self.s_right.Add(self.p_content, -1, wx.EXPAND, 10)
	    self.Layout()

	    lc = self.p_content.lc_sale	
	    for item in self.details_sale:
		    index = lc.InsertStringItem(0, unicode(item['name']))
		    lc.SetStringItem(index,1, unicode(item['amount']))
		    lc.SetStringItem(index,2, unicode(item['price']))
		    lc.SetStringItem(index,3, unicode(item['total']))

	    subtotal = self.helpers_sale.get_subtotal(lc, self.p_content.l_vsubtotal)
	    taxTotal = self.helpers_sale.get_tax_total(lc, self.p_content.l_vstax)
	    self.helpers_sale.get_total_sale(taxTotal, subtotal, self.p_content.l_vtotal)
	
    def cancel_sale(self, sale_current):
	    self.bm_addsale.Enable()
	    self.statusSale = False
	    self.p_content.Destroy()
	    self.p_content = SalesList_view(self, -1)
	    self.s_right.Add(self.p_content, 1, wx.EXPAND, 10)
	    self.get_sale_list(sale_current)
	    self.Layout()

    def pay_close(self):
	    """
	    Se usa para cerrar el dialogo una vez que el pago se completo
	    y agrega la venta pagada a list_sales_current obteniendola desde
	    la bd, por eso a get_sale_list se le debe pasar None
	    """
	    self.bm_addsale.Enable()
	    #self.statusSale = False
	    #self.statusDue = True
	    #self.statusDiscount = True
	    self.p_content.Destroy()
	    self.p_content = SalesList_view(self, -1)
	    self.s_right.Add(self.p_content, 1, wx.EXPAND, 10)
	    self.get_sale_list(None)
	    self.Layout()
		

    def get_sale_list(self, sale_current):
	    """
	    Obtiene la lista de ventas con productos pagadas o pendientes
	    que es el resultado de la lista actual mas una venta pagada o pendiente.
	    Si sale_current es None regresara las ventas pagadas solamente.
	    """
	    if sale_current:
		    self.p_content.list_sales_current.append(sale_current)
		    self.set_sale_list(self.p_content.list_sales_current)
	    else:
		    self.set_sale_list(self.p_content.list_sales_current)
	    print "GET_SALE_LIST", self.p_content.list_sales_current
		
    def set_sale_list(self, sales_current):
	    """
	    Actualiza la lista de ventas actuales
	    """
	    self.p_content.lc_saleslist.DeleteAllItems()
	    for item in sales_current:
		    index = self.p_content.lc_saleslist.InsertStringItem(0, '')
		    self.p_content.lc_saleslist.SetStringItem(index,1, unicode(item['id']))
		    self.p_content.lc_saleslist.SetStringItem(index,2, unicode(item['sku']))
		    self.p_content.lc_saleslist.SetStringItem(index,3, unicode(item['sale']))
		    self.p_content.lc_saleslist.SetStringItem(index,4, unicode(item['amount']))
		    self.p_content.lc_saleslist.SetStringItem(index,5, unicode(item['total']))
Esempio n. 8
0
class SalesList_view(wx.Panel):
    def __init__(self, parent, id):
        self.parent = parent
        self.list_sales_current = self.parent.list_sales_current
        self.helpers_sale = Sale_helper(self.parent)
        wx.Panel.__init__(self, parent, id)

        self.controller = SalesList(self.parent.pos)
        self.controller.get_sales()
        self.controller.get_total_products()
        self.controller.get_total_all()
                
        self.l_venta = wx.StaticText(self, -1, "Ventas")
        self.lc_saleslist = wx.ListCtrl(self, -1, style=wx.LC_REPORT|wx.SUNKEN_BORDER)
        self.lc_saleslist.InsertColumn(0,'') 
        self.lc_saleslist.InsertColumn(1,'id')
        self.lc_saleslist.InsertColumn(2,'SKU')
        self.lc_saleslist.InsertColumn(3,'Venta')
        self.lc_saleslist.InsertColumn(4,'Productos')
        self.lc_saleslist.InsertColumn(5,'Total')
        self.lc_saleslist.SetColumnWidth(0, 50)
        self.lc_saleslist.SetColumnWidth(1, 50)
        self.lc_saleslist.SetColumnWidth(2, 130)
        self.lc_saleslist.SetColumnWidth(3, 210)
        self.lc_saleslist.SetColumnWidth(4, 100)
        self.lc_saleslist.SetColumnWidth(5, 200)
        
        self.list_sales()

        self.Bind(wx.EVT_LIST_ITEM_ACTIVATED, self.details_sale, self.lc_saleslist)
        
        self.__set_properties()
        self.__do_layout()

    def __set_properties(self):
        self.l_venta.SetFont(wx.Font(20, wx.DEFAULT, wx.NORMAL, wx.BOLD, 0, ""))

    def __do_layout(self):
        self.s_saleslist = wx.BoxSizer(wx.VERTICAL)
        self.s_saleslist.Add(self.l_venta, 0, wx.ALL, 10)
        self.s_saleslist.Add(self.lc_saleslist, 1, wx.EXPAND, 10)
        self.SetSizer(self.s_saleslist)
        self.s_saleslist.Fit(self)

    def list_sales(self):
	    """
	    Obtiene la lista de ventas por pos al iniciar el turno
	    y crea la lista que guardara la lista de ventas actuales
	    """
	    list_sale_current_temp = []
	    if not self.list_sales_current:
		    """
		    Cuando la venta se realiza al momento, sin tener ventas pendientes ni vendidas
		    """
		    for i in range(0, len(self.controller.sales)):
			    sku = unicode(self.controller.sales[i][1])
			    sale = unicode(self.controller.sales[i][2])
			    amount = unicode(self.controller.total_products[i]['amount__sum'])
			    total = unicode(self.controller.total[i])
			    ids = i+1
			    if  not self.list_sales_current:
				    self.list_sales_current.append({'id': ids,'sku': sku, 'sale': sale, 'amount': amount, 'total': total, 'products': []})
	    else:
		    print "self.controller.sales", self.controller.sales
		    for i in range(0, len(self.controller.sales)):
			    sku = unicode(self.controller.sales[i][1])
			    sale = unicode(self.controller.sales[i][2])
			    amount = unicode(self.controller.total_products[i]['amount__sum'])
			    total = unicode(self.controller.total[i])
			    ids = i+1
			    #print "self.list_sales_current", self.list_sales_current
			    for item in self.list_sales_current:
				    if item['id'] != ids and item['sku'] != '--': #and not item['total'] == total and not item['amount'] == int(amount):
					    """
					    Cuando la venta se realiza al momento, sin tener ventas pendientes listadas solo vendidas
					    """
					    try:
						    self.list_sales_current.index({'id': ids,'sku': sku, 'sale': sale, 'amount': amount, 'total': total, 'products': item['products']})
					    except:
						    try:
							    list_sale_current_temp.index({'id': ids,'sku': sku, 'sale': sale, 'amount': amount, 'total': total, 'products': item['products']})
						    except:
							    list_sale_current_temp.append({'id': ids,'sku': sku, 'sale': sale, 'amount': amount, 'total': total, 'products': item['products']})
				    elif item['sku'] == '--' and item['total'] == total and item['amount'] == int(amount):
					    """
					    Cuando la venta pendiente se termina de hacer con listado de ventas realizadas
					    """
					    self.list_sales_current.remove(item)
		    
		    for item in list_sale_current_temp:
			    self.list_sales_current.append(item)
		    
	    self.lc_saleslist.DeleteAllItems()

	    for item in self.list_sales_current:
		    index = self.lc_saleslist.InsertStringItem(0, '')
		    self.lc_saleslist.SetStringItem(index,1, unicode(item['id']))
		    self.lc_saleslist.SetStringItem(index,2, unicode(item['sku']))
		    self.lc_saleslist.SetStringItem(index,3, unicode(item['sale']))
		    self.lc_saleslist.SetStringItem(index,4, unicode(item['amount']))
		    self.lc_saleslist.SetStringItem(index,5, unicode(item['total']))

    def details_sale(self, evt):
	    currentItem = evt.m_itemIndex
	    current_id = int(self.helpers_sale.get_column_text(self.lc_saleslist, currentItem, 1))
	    self.parent.sale_id = current_id
	    self.helpers_sale.get_details_sale(self.list_sales_current, current_id)