Example #1
0
 def __init__(self, padre):
     self.padre = padre
     arch = leerglade.leer('frm_pagos.glade')
     self.frm = arch.get_object
     self.frm('window1').set_title('Pagos a Proveedores')
     self.frm('window1').set_default_size(800, 600)
     self.entity = OrdenPagos()
     self.detalle_recibos = DetallePagos()
     self.contactos = Contactos()
     self.cuentas = CuentasaPagar()
     self.frm('window1').set_transient_for(self.padre.main('window1'))
     self.frm('window1').set_position(1)
     self.frm('window1').set_border_width(5)
     self.frm('window1').set_modal(True)
     self.frm('window1').show_all()
     arch.connect_signals(self)
     self.inicializar_campos()
Example #2
0
class RegPagos:
    def __init__(self, padre):
        self.padre = padre
        arch = leerglade.leer('frm_pagos.glade')
        self.frm = arch.get_object
        self.frm('window1').set_title('Pagos a Proveedores')
        self.frm('window1').set_default_size(800, 600)
        self.entity = OrdenPagos()
        self.detalle_recibos = DetallePagos()
        self.contactos = Contactos()
        self.cuentas = CuentasaPagar()
        self.frm('window1').set_transient_for(self.padre.main('window1'))
        self.frm('window1').set_position(1)
        self.frm('window1').set_border_width(5)
        self.frm('window1').set_modal(True)
        self.frm('window1').show_all()
        arch.connect_signals(self)
        self.inicializar_campos()
        #self.frm('window1').maximize()

    def inicializar_campos(self):
        self.frm('entry1').set_text('')
        self.frm('liststore1').clear()
        self.frm('label3').set_text('0')
        self.frm('entry1').grab_focus()

    def pegar_clientes(self, widget, event):
        if event.keyval == 65470:
            datos = self.contactos.all()
            busquedas.Buscar(self, datos, widget)


    def set_focus(self, widget):

        if widget == self.frm('entry1'):
            self.cargar_cuentas()
        widget.get_toplevel().child_focus(Gtk.DirectionType.TAB_FORWARD)

    def cargar_cuentas(self):
        if len(self.frm('entry1').get_text()) > 0:
            idcontacto = self.frm('entry1').get_text().split('-')[0]
            self.frm('liststore1').clear()
            for row in self.cuentas.cuentas_all(idcontacto):
                self.frm('liststore1').append([str(row[0]),
                                               str(row[1]),
                                               str(row[2]),
                                               Format.number(row[3]),
                                               row[4]])
        if len(self.frm('liststore1')) == 0:
            msg.errorMsgBox(self.frm('window1'),
                            "Proveedor sin cuentas",
                            "Proveedor sin cuentas pendientes de pago.")
    def sel_toggled(self, widget, path):
        self.frm('liststore1')[path][4] = not self.frm('liststore1')[path][4]
        self.calcular_pago()

    def calcular_pago(self):
        total = 0.0
        for row in self.frm('liststore1'):
            if row[4]:
                total += float(row[3].replace(',', ''))

        self.frm('label3').set_text(Format.number(total))
                                      
    def confirmar_cb(self, widget):
        recibo = self.entity.get_max()
        self.entity.nro_pago = recibo
        self.entity.fecha = datetime.now().strftime("%d/%m/%Y")                            
        if self.entity.save():
            pass
        else:
            print "error al registrar pagos"
            return

        for row in self.frm('liststore1'):
            self.detalle_recibos.nro_pago = recibo
            self.detalle_recibos.nro_factura = row[1]
            self.detalle_recibos.nro_timbrado = row[2]
            self.detalle_recibos.idcontacto = self.frm('entry1').get_text().split('-')[0]
            self.detalle_recibos.monto = row[3].replace(',', '')
            if self.detalle_recibos.save():
                pass
            else:
                print "error guardando datos detalle"
                return

        self.inicializar_campos()



    def cancelar_cb(self, widget):
        self.frm('window1').destroy()