Example #1
0
 def descontarCantidad(self,detalle,producto,cantidad):
     """
         Actualiza el stock en una determinada cantidad,
         de un producto dado
     :param detalle Detalle de la Factura :
     :param producto Codigo de barra del producto:
     :param cantidad Cantidad a descontar:
     :return:
     """
     query=LoteModel.obtenerLoteProducto(producto,self.sesion)
     valores=[]
     for a in query:
         loteProducto=LoteProductoModel.buscarLoteProducto(self.sesion,producto,a.codigo).first()
         if cantidad<=loteProducto.cantidad:
             loteProducto.descontarCantidad(cantidad)
             loteProducto.modificar(self.sesion)
             valores.append([loteProducto,cantidad])
             break
         else:
             cantidad-=loteProducto.cantidad
             valores.append([loteProducto,loteProducto.cantidad])
             loteProducto.descontarCantidad(loteProducto.cantidad)
             loteProducto.modificar(self.sesion)
     self.lotesVentas[detalle]=valores
     detalle.agregarLotes(self.sesion,self.lotesVentas[detalle])
Example #2
0
 def descontarCantidad(self,detalle,producto,cantidad):
     """
         Descuenta la cantidad especificada de un
         determinado producto
     :param detalle Detalle Remito:
     :param producto Codigo de Barra del producto:
     :param cantidad Cantidad del Producto:
     :return:
     """
     query=LoteModel.obtenerLoteProducto(producto,self.sesion)
     valores=[]
     for a in query:
         loteProducto=LoteProductoModel.buscarLoteProducto(self.sesion,producto,a.codigo).first()
         if cantidad<=loteProducto.cantidad:
             loteProducto.descontarCantidad(cantidad)
             loteProducto.modificar(self.sesion)
             valores.append([loteProducto,cantidad])
             break
         else:
             cantidad-=loteProducto.cantidad
             valores.append([loteProducto,loteProducto.cantidad])
             loteProducto.descontarCantidad(loteProducto.cantidad)
             loteProducto.modificar(self.sesion)
     self.lotesVentas[detalle]=valores
     detalle.agregarLotes(self.sesion,self.lotesVentas[detalle])
Example #3
0
 def devolverDetalle(self):
     itemActual = self.tableFactura.currentItem()
     ok = QtGui.QMessageBox.information(self, "Confirmacion",
                                        "¿Desea devolver este detalle?")
     if ok:
         producto = int(self.tableFactura.item(itemActual.row(), 0).text())
         cantOriginal = cantidadFactura = int(
             self.tableFactura.item(itemActual.row(), 1).text())
         finalizeActualizacion = False
         if self.productosSeleccionados == 0:
             self.notaCredito = NotaCreditoModel(
                 NotaCreditoModel.generarNumero(self.sesion))
             self.notaCredito.guardar(self.sesion)
         while not finalizeActualizacion:
             cantidad, ok = QtGui.QInputDialog.getInt(
                 self, "Cantidad", "Ingrese cantidad del producto", 1, 1,
                 2000, 5)
             if not ok:
                 QtGui.QMessageBox.information(self, "Aviso",
                                               "No se ingreso cantidad")
             else:
                 if cantidad > cantidadFactura:
                     QtGui.QMessageBox.information(
                         self, "Aviso",
                         "La cantidad ingresada supera la esperada")
                 else:
                     lote, ok = QtGui.QInputDialog.getText(
                         self, "Lote", "Ingrese lote")
                     if not ok:
                         QtGui.QMessageBox.information(
                             self, "Aviso", "No se ingreso lote")
                     else:
                         loteP = LoteProductoModel.buscarLoteProducto(
                             self.sesion, producto, str(lote)).first()
                         if loteP == None:
                             QtGui.QMessageBox.information(
                                 self, "Aviso",
                                 "El lote ingresado no se corresponde con el producto"
                             )
                         else:
                             loteP.aumentarCantidad(cantidad)
                             loteP.modificar(self.sesion)
                             self.lotesDevueltos[loteP] = cantidad
                             cantidadFactura -= cantidad
                             self.tableFactura.item(
                                 itemActual.row(),
                                 1).setText(str(cantidadFactura))
                             if cantidadFactura == 0:
                                 finalizeActualizacion = True
                                 self.productosSeleccionados += 1
         self.armarItem(self.obtenerValoresItem(itemActual.row()),
                        cantOriginal, self.productosSeleccionados)
         self.tableFactura.removeRow(itemActual.row())
     else:
         return
Example #4
0
    def eliminarDetalle(self):
        itemActual = self.tableDetalles.currentItem()
        ok = QtGui.QMessageBox.information(self, "Confirmacion",
                                           "¿Desea eliminar este item?")
        if ok:
            linea = int(self.tableDetalles.item(itemActual.row(), 0).text())
            producto = int(self.tableDetalles.item(itemActual.row(), 1).text())
            cantidadRemito = int(
                self.tableDetalles.item(itemActual.row(), 2).text())
            finalizeActualizacion = False
            while not finalizeActualizacion:
                cantidad, ok = QtGui.QInputDialog.getInt(
                    self, "Cantidad", "Ingrese cantidad del producto", 1, 1,
                    2000, 5)
                if not ok:
                    QtGui.QMessageBox.information(self, "Aviso",
                                                  "No se ingreso cantidad")
                else:
                    if cantidad > cantidadRemito:
                        QtGui.QMessageBox.information(
                            self, "Aviso",
                            "La cantidad ingresada supera la esperada")
                    else:
                        lote, ok = QtGui.QInputDialog.getText(
                            self, "Lote", "Ingrese lote")
                        if not ok:
                            QtGui.QMessageBox.information(
                                self, "Aviso", "No se ingreso lote")
                        else:
                            loteP = LoteProductoModel.buscarLoteProducto(
                                self.sesion, producto, str(lote)).first()
                            if loteP == None:
                                QtGui.QMessageBox.information(
                                    self, "Aviso",
                                    "El lote ingresado no se corresponde con el producto"
                                )
                            else:
                                loteP.aumentarCantidad(cantidad)
                                loteP.modificar(self.sesion)
                                cantidadRemito -= cantidad
                                self.tableDetalles.item(
                                    itemActual.row(),
                                    2).setText(str(cantidadRemito))
                                if cantidadRemito == 0:
                                    finalizeActualizacion = True
            detalle = RemitoModel.getDetalle(int(self.lineNumero.text()),
                                             int(linea), self.sesion).first()
            detalle.borrar(self.sesion)
            self.tableDetalles.removeRow(itemActual.row())

        else:
            return
Example #5
0
 def devolver(self,sesion):
     """
         Devuelve el detalle correspondiente
         :param sesion Sesion actual con la Base de Datos:
         :return:
     """
     lotes_detalle = self.devolverLotes(sesion)
     for lote in lotes_detalle:
         loteP = LoteProducto.buscarLoteProducto(sesion,self.producto,lote).first()
         loteP.aumentarCantidad(lotes_detalle[lote])
         loteP.modificar(sesion)
     self.eliminarLotesAsociados(sesion)
     self.borrar(sesion)
Example #6
0
 def descontarCantidad(self,detalle,producto,cantidad):
     query=LoteModel.obtenerLoteProducto(producto,self.sesion)
     valores=[]
     for a in query:
         loteProducto=LoteProductoModel.buscarLoteProducto(self.sesion,producto,a.codigo).first()
         if cantidad<=loteProducto.cantidad:
             loteProducto.descontarCantidad(cantidad)
             loteProducto.modificar(self.sesion)
             valores.append([loteProducto,cantidad])
             break
         else:
             cantidad-=loteProducto.cantidad
             valores.append([loteProducto,loteProducto.cantidad])
             loteProducto.descontarCantidad(loteProducto.cantidad)
             loteProducto.modificar(self.sesion)
     self.lotesVentas[detalle]=valores
Example #7
0
 def descontarCantidad(self, detalle, producto, cantidad):
     query = LoteModel.obtenerLoteProducto(producto, self.sesion)
     valores = []
     for a in query:
         loteProducto = LoteProductoModel.buscarLoteProducto(
             self.sesion, producto, a.codigo).first()
         if cantidad <= loteProducto.cantidad:
             loteProducto.descontarCantidad(cantidad)
             loteProducto.modificar(self.sesion)
             valores.append([loteProducto, cantidad])
             break
         else:
             cantidad -= loteProducto.cantidad
             valores.append([loteProducto, loteProducto.cantidad])
             loteProducto.descontarCantidad(loteProducto.cantidad)
             loteProducto.modificar(self.sesion)
     self.lotesVentas[detalle] = valores
Example #8
0
 def devolverDetalle(self):
     itemActual=self.tableFactura.currentItem()
     ok=QtGui.QMessageBox.information(self,"Confirmacion","¿Desea devolver este detalle?")
     if ok:
         producto=int(self.tableFactura.item(itemActual.row(),0).text())
         cantOriginal=cantidadFactura=int(self.tableFactura.item(itemActual.row(),1).text())
         finalizeActualizacion=False
         if self.productosSeleccionados==0:
             self.notaCredito=NotaCreditoModel(NotaCreditoModel.generarNumero(self.sesion))
             self.notaCredito.guardar(self.sesion)
         while not finalizeActualizacion:
             cantidad, ok=QtGui.QInputDialog.getInt(self,"Cantidad","Ingrese cantidad del producto",1,1,2000,5)
             if not ok:
                 QtGui.QMessageBox.information(self,"Aviso","No se ingreso cantidad")
             else:
                 if cantidad > cantidadFactura:
                     QtGui.QMessageBox.information(self,"Aviso","La cantidad ingresada supera la esperada")
                 else:
                     lote, ok=QtGui.QInputDialog.getText(self,"Lote","Ingrese lote")
                     if not ok:
                         QtGui.QMessageBox.information(self,"Aviso","No se ingreso lote")
                     else:
                         loteP=LoteProductoModel.buscarLoteProducto(self.sesion,producto,str(lote)).first()
                         if loteP==None:
                             QtGui.QMessageBox.information(self,"Aviso","El lote ingresado no se corresponde con el producto")
                         else:
                             loteP.aumentarCantidad(cantidad)
                             loteP.modificar(self.sesion)
                             self.lotesDevueltos[loteP]=cantidad
                             cantidadFactura-=cantidad
                             self.tableFactura.item(itemActual.row(),1).setText(str(cantidadFactura))
                             if cantidadFactura==0:
                                 finalizeActualizacion=True
                                 self.productosSeleccionados+=1
         self.armarItem(self.obtenerValoresItem(itemActual.row()),cantOriginal,self.productosSeleccionados)
         self.tableFactura.removeRow(itemActual.row())
     else:
         return
Example #9
0
    def eliminarDetalle(self):
        itemActual=self.tableDetalles.currentItem()
        ok=QtGui.QMessageBox.information(self,"Confirmacion","¿Desea eliminar este item?")
        if ok:
            linea=int(self.tableDetalles.item(itemActual.row(),0).text())
            producto=int(self.tableDetalles.item(itemActual.row(),1).text())
            cantidadRemito=int(self.tableDetalles.item(itemActual.row(),2).text())
            finalizeActualizacion=False
            while not finalizeActualizacion:
                cantidad, ok=QtGui.QInputDialog.getInt(self,"Cantidad","Ingrese cantidad del producto",1,1,2000,5)
                if not ok:
                    QtGui.QMessageBox.information(self,"Aviso","No se ingreso cantidad")
                else:
                    if cantidad > cantidadRemito:
                        QtGui.QMessageBox.information(self,"Aviso","La cantidad ingresada supera la esperada")
                    else:
                        lote, ok=QtGui.QInputDialog.getText(self,"Lote","Ingrese lote")
                        if not ok:
                            QtGui.QMessageBox.information(self,"Aviso","No se ingreso lote")
                        else:
                            loteP=LoteProductoModel.buscarLoteProducto(self.sesion,producto,str(lote)).first()
                            if loteP==None:
                                QtGui.QMessageBox.information(self,"Aviso","El lote ingresado no se corresponde con el producto")
                            else:
                                loteP.aumentarCantidad(cantidad)
                                loteP.modificar(self.sesion)
                                cantidadRemito-=cantidad
                                self.tableDetalles.item(itemActual.row(),2).setText(str(cantidadRemito))
                                if cantidadRemito==0:
                                    finalizeActualizacion=True
            detalle=RemitoModel.getDetalle(int(self.lineNumero.text()),int(linea),self.sesion).first()
            detalle.borrar(self.sesion)
            self.tableDetalles.removeRow(itemActual.row())

        else:
            return