Ejemplo n.º 1
0
    def Handle(self, inputs):
        supplier_code = int(inputs[Supplier.code.name])
        supplierCol = self.session.query(Supplier).filter_by(
            code=supplier_code).first()
        contactCol = []
        idCon = 0
        if supplierCol.contact == None and Supplier.contact.name in inputs:
            # Means that the contact is created and going to be updated
            ManContact().Handle(inputs)
            idCon = int(inputs[Supplier.contact.name])
        else:
            # Means that the contact is not created.
            idCon = ManContact().create(inputs)["value"][Contact.code.name]
            inputs[Supplier.contact.name] = idCon
            ManContact().Handle(inputs)

        storeDict = {}
        for column in DBProcess(Supplier.supplier_tbl).getColumnDefinition:
            if column["name"] in inputs:
                storeDict[column["expr"]] = DBProcess(
                    Supplier.supplier_tbl).parse(column,
                                                 inputs[column["name"]])

        self.session.query(Supplier).filter_by(
            code=supplier_code).update(storeDict)
        self.session.commit()
        self.session.close()
        self.connORM.dispose()

        self.type = "application/json"
        self.msg = {"code": supplier_code}
        self.status = 200
        return {"status": self.status, "value": self.msg, "type": self.type}
Ejemplo n.º 2
0
    def Handle(self, inputs):
        # This method will modify an expanse.
        area = int(inputs[Area.code.name])
        storeDict = {}
        #Defining the status
        status = 12
        if "status" in inputs:
            if str(inputs["status"]).lower() == "on":
                status = 11
        inputs["status"] = status

        for column in DBProcess(Area.Area_tbl).getColumnDefinition:
            if column["name"] in inputs:
                storeDict[column["expr"]] = DBProcess(Area.Area_tbl).parse(
                    column, inputs[column["name"]])

        self.session.query(Area).filter_by(code=area).update(storeDict)
        self.session.commit()
        self.session.close()
        self.connORM.dispose()

        return {
            "status": 200,
            "value": {
                Area.code.name: area
            },
            'type': 'application/json'
        }
Ejemplo n.º 3
0
    def Handle(self, inputs):
        # This method will modify an expanse.
        where = ""
        self.msg = {}
        if Tables.tblname.name in inputs and Tables.code.name not in inputs:
            where = and_(Tables.tblname == inputs[Tables.tblname.name])
            self.msg[Tables.tblname.name] = inputs[Tables.tblname.name]
        else:
            where = and_(Tables.code == int(inputs[Tables.code.name]))
            self.msg[Tables.code.name] = inputs[Tables.code.name]

        status = 12
        if Tables.status.name in inputs:
            if str(inputs[Tables.status.name]).lower() == "on":
                status = 11
        inputs[Tables.status.name] = status

        storeDict = {}
        process = DBProcess(Tables.Tables_tbl)
        for column in process.getColumnDefinition:
            if column["name"] in inputs:
                storeDict[column["expr"]] = process.parse(
                    column, inputs[column["name"]])
        self.session.query(Tables).filter(where).update(storeDict)

        self.session.commit()
        self.session.close()
        self.connORM.dispose()

        return {"status": 200, "value": self.msg, 'type': 'application/json'}
Ejemplo n.º 4
0
    def Handle(self, inputs):
        """This function, save and stores or modify the
        contact information.
        As parameter receive:
        Name.
        LastName.
        CellPhone.
        Telephone.
        Address.
        Email.
        Status.
        """

        item = int(inputs[Contact.code.name])
        birthdate = general().date2julian("1900-01-01")
        if "birthdate" in inputs:
            if len(inputs["birthdate"]) == 9:
                birthdate = general.date2julian(inputs["birthdate"])
        inputs[Contact.birthdate.name] = birthdate

        storeDict = {}
        for column in DBProcess(Contact.Contact_tbl).getColumnDefinition:
            if column["name"] in inputs:
                storeDict[column["expr"]] = DBProcess(
                    Contact.Contact_tbl).parse(column, inputs[column["name"]])

        self.session.query(Contact).filter_by(code=item).update(storeDict)
        self.msg = {"code": item}
        self.session.commit()
        self.session.close()
        self.connORM.dispose()
        return {"status": 200, "value": self.msg, 'type': 'application/json'}
Ejemplo n.º 5
0
    def merma_Handle(self, inputs):
        item = int(inputs[Merma.code.name])
        storeDict = {}
        for column in DBProcess(Merma.Merma_tbl).getColumnDefinition:

            if column["name"] in [Merma.created.name] and column["name"] in inputs:
                jdate = general().date2julian(inputs[column["name"]])
                inputs[column["name"]] = jdate

            if column["name"] in inputs:
                storeDict[column["expr"]] = DBProcess(Merma.Merma_tbl).parse(column, inputs[column["name"]])

        self.session.query(Merma).filter_by(code=item).update(storeDict)
        self.session.commit()
        self.session.close()
        self.connORM.dispose()

        creator_profile = login().getProfile(inputs)

        user_rootlst = login().Get({User.usrtype.name: 74})["value"]

        url_merma="http://erpt.sugelico.com/?md=merma&merma="+str(item)
        bodymsg = "<h2>Productos mermados</h2>" \
                  "<p>" + \
                  " Colocado por el usuario: " + creator_profile["value"][0]["name"] \
                  + " Codigo del reverso: <a href='" + url_merma + "'>"+str(item)+"</a></p>"

        for user_root in user_rootlst:
            general().sendMail(user_root[User.username.name], bodymsg)
        return {"status": 200, "value": {Merma.code.name: item}, 'type': 'application/json'}
Ejemplo n.º 6
0
    def Handle(self, inputs):
        # This method will modify an expanse.
        item = int(inputs[category.code.name])
        category_info=self.session.query(category).filter_by(code=item).first()
        logo_path=category_info.avatar
        if category.avatar.name in inputs:

            if inputs[category.avatar.name]["filename"] != 'da39a3ee5e6b4b0d3255bfef95601890afd80709.':
                logo_path = inputs[category.avatar.name]["filename"]
                logo_file = inputs[category.avatar.name]["value"]
                storeDir = inputs["__documentroot__"] + "/resources/site/" + "products/"
                inputs[category.avatar.name] = logo_path
                file = open(storeDir + logo_path, "w", encoding="ISO-8859-1")
                file.write(logo_file.decode("ISO-8859-1"))
                file.close()
            else:
                del inputs[category.avatar.name]

        storeDict = {}
        printer = category_info.printer
        if category.printer.name in inputs:
            printer = printer_reg.objects(code=int(inputs[category.printer.name])).first().name

        inputs[category.printer.name]=printer
        for column in DBProcess(category.category_tbl).getColumnDefinition:
            if column["name"] in inputs:
                storeDict[column["expr"]] = DBProcess(category.category_tbl).parse(column, inputs[column["name"]])



        self.session.query(category).filter_by(code=item).update(storeDict)

        self.session.commit()
        self.session.close()
        return {"status": 200, "value": {category.code.name: item}, 'type': 'application/json'}
Ejemplo n.º 7
0
    def Handle(self, inputs):
        # This method will modify an expanse.
        warehouse_target = int(inputs[WareHouse.code.name])
        storeDict = {}
        #Defining the status
        status = 12
        if "status" in inputs:
            if str(inputs["status"]).lower() == "on":
                status = 11
        mainwarehouse = False
        if "mainwarehouse" in inputs:
            if inputs["mainwarehouse"] == 'on':
                mainwarehouse = True
        inputs["mainwarehouse"] = mainwarehouse
        inputs["status"] = status

        for column in DBProcess(WareHouse.WareHouse_tbl).getColumnDefinition:
            if column["name"] in inputs:
                storeDict[column["expr"]] = DBProcess(
                    WareHouse.WareHouse_tbl).parse(column,
                                                   inputs[column["name"]])

        self.session.query(WareHouse).filter_by(
            code=warehouse_target).update(storeDict)
        self.session.commit()
        self.session.close()
        self.connORM.dispose()

        return {
            "status": 200,
            "value": {
                WareHouse.code.name: warehouse_target
            },
            'type': 'application/json'
        }
Ejemplo n.º 8
0
    def Get(self, inputs):
        # This method gets the data, from the db.
        storeDict = []
        main_query = self.session.query(User, Status.description, Type.tpname,
                                        Contact.contact_name,Contact.lastname).\
            filter(and_(Status.code == User.status, Type.code == User.usrtype)).\
            filter(Contact.code==User.contact)
        if User.username.name in inputs:
            main_query = main_query.\
                filter(User.username.like("%" + inputs[User.username.name] + "%"))

        if User.code.name in inputs:
            main_query = main_query.\
                    filter(User.code == int(inputs[User.code.name]))

        if User.status.name in inputs:
            main_query = main_query.\
                filter(Status.code == int(inputs[User.status.name]))

        if User.usrtype.name in inputs:
            main_query = main_query. \
                filter(Type.code == int(inputs[User.usrtype.name]))

        # The next area is in charge to extract the information,
        # from the store Dict and add it to the dataCol to be returned
        storeDict = main_query
        dataCol = []
        for dataLst in storeDict:
            dicStore = {
                "status_name": dataLst._asdict()[Status.description.name],
                Type.tpname.name: dataLst._asdict()[Type.tpname.name]
            }

            for key in DBProcess(User.user_tbl).getColumnDefinition:
                dataDict = dataLst._asdict()[
                    User.
                    __name__].__dict__  # Getting the dictionary of the list.
                colname = key["name"]  # Getting the column name.
                if colname in dataDict and colname != User.passwd.name:  # Just if the column name is on the dictionary, add it to the dictStore.

                    dicStore[colname] = DBProcess(User.user_tbl).parse2publish(
                        dataDict[colname])

            for key in DBProcess(Contact.Contact_tbl).getColumnDefinition:
                dataDict = dataLst._asdict(
                )  # Getting the dictionary of the list.
                colname = key["name"]  # Getting the column name.
                if colname in dataDict:  # Just if the column name is on the dictionary, add it to the dictStore.

                    dicStore[colname] = DBProcess(
                        Contact.Contact_tbl).parse2publish(dataDict[colname])

            dataCol.append(dicStore)
            # Appending everything to be returned

        self.session.close()
        self.connORM.dispose()

        return {"status": 200, "value": dataCol, 'type': 'application/json'}
Ejemplo n.º 9
0
    def Get(self, inputs):
        dataCol = []
        """The module of find the information of a Client."""
        storeDict = []
        limit = 100
        if "limit" in inputs:
            limit=int(inputs["limit"])
        main_query=self.session.query(Client, Status.description, Contact).\
            outerjoin(Contact, Contact.code==Client.contact)

        if Client.cl_name.name in inputs:
            main_query =main_query.\
                filter(Client.cl_name.ilike("%" + inputs[Client.cl_name.name] + "%"))

        if Client.code.name in inputs:
            main_query =main_query. \
                filter(Client.code == int(inputs[Client.code.name]))

        if Client.rnc.name in inputs:
            main_query =main_query. \
                filter(Client.rnc.ilike("%" + inputs[Client.rnc.name] + "%"))

        if Client.telephone.name in inputs:
            if inputs[Client.telephone.name]!=None and inputs[Client.telephone.name]!="null":
                main_query = main_query. \
                filter(Client.telephone.ilike("%" + inputs[Client.telephone.name] + "%"))

        if Client.contact.name in inputs:
            main_query = main_query.\
                filter(Client.code == int(inputs[Client.contact.name]))
        storeDict=main_query.\
                filter(Status.code == Client.status).limit(limit)

        for dataLst in storeDict:
            dicStore = {"status_name": dataLst._asdict()["description"]}
            for keys in DBProcess(Client.clients_tbl).getColumnDefinition:
                dataDict = dataLst._asdict()[Client.__name__].__dict__  # Getting the dictionary of the list.

                colname = keys["name"]  # Getting the column name.
                if colname in dataDict:  # Just if the column name is on the dictionary, add it to the dictStore.
                    if colname == Client.contact.name and dataDict[colname] ==None:
                        dataDict[colname] = 0
                    dicStore[colname] =  DBProcess(Client.clients_tbl).parse2publish(dataDict[colname])

            if dataLst._asdict()[Client.__name__].__dict__ [Client.contact.name] >0:
                for keys in DBProcess(Contact.Contact_tbl).getColumnDefinition:
                    dataDict = dataLst._asdict()[Contact.__name__].__dict__  # Getting the dictionary of the list.

                    colname = keys["name"]  # Getting the column name.
                    if colname in dataDict and colname != Contact.code.name:  # Just if the column name is on the dictionary, add it to the dictStore.
                        dicStore[colname] = DBProcess(Client.clients_tbl).parse2publish(dataDict[colname])
            dataCol.append(dicStore)
            # Appending everything to be returned
        self.session.close()
        self.connORM.dispose()

        return {"status": 200, "value": dataCol, 'type': 'application/json'}
Ejemplo n.º 10
0
    def RegisterMove(self, inputs):
        # This method register a move of product

        created = general().date2julian()
        inputs["created"] = created
        if ProductsMove.send_date.name in inputs:
            inputs[ProductsMove.send_date.name] = general().date2julian(
                inputs[ProductsMove.send_date.name])

        item = int(inputs[ProductsMove.code.name])

        storeDict = {}
        for column in DBProcess(
                ProductsMove.ProductsMove_tbl).getColumnDefinition:
            if column["name"] in inputs:
                storeDict[column["expr"]] = DBProcess(ProductsMove.ProductsMove_tbl).\
                    parse(column,inputs[column["name"]])

        # Adding the product to the warehouse.
        for product in json.loads(inputs["products"]):

            connection = self.connORM.raw_connection()
            cursor = connection.cursor()

            code = CodeGen().GenCode({
                "table": "Moveproducts",
                "column": "code"
            })

            Moveproducts(code=code,
                         give_by=int(inputs["from_warehouse"]),
                         receive_by=int(inputs["to_warehouse"]),
                         product=int(product["product"]),
                         created_date=general().date2julian(),
                         description=product["item_name"]).save()

            cursor.callproc('products_movement', [
                int(product["product"]),
                Decimal(product["amount"]),
                int(inputs["from_warehouse"]),
                int(inputs["to_warehouse"])
            ])
            cursor.close()

        self.session.commit()
        self.session.close()
        self.connORM.dispose()

        return {
            "status": 200,
            "value": {
                ProductsMove.code.name: item
            },
            'type': 'application/json'
        }
Ejemplo n.º 11
0
    def Get(self, inputs):
        # This method gets the data, from the db.
        storeDict = self.session.query(AccountsTbl, Status.description, Type.tpname).\
            filter(Status.code == AccountsTbl.status).\
            filter(Type.code==AccountsTbl.acc_type)

        if AccountsTbl.code.name in inputs:
            storeDict = storeDict.filter(
                AccountsTbl.code == int(inputs[AccountsTbl.code.name]))

        if AccountsTbl.acc_type.name in inputs:
            storeDict = storeDict.filter(
                AccountsTbl.acc_type == int(inputs[AccountsTbl.acc_type.name]))

        if AccountsTbl.account_name.name in inputs:
            storeDict = storeDict.filter(
                AccountsTbl.account_name.ilike(
                    "%" + str(inputs[AccountsTbl.account_name.name]) + "%"))

        # The next area is in charge to extract the information,
        # from the store Dict and add it to the dataCol to be returned

        dataCol = []
        for dataLst in storeDict:
            dicStore = {
                "status_name": dataLst._asdict()[Status.description.name],
                "cat_tpname": dataLst._asdict()["tpname"]
            }

            for key in DBProcess(AccountsTbl.Accounts_tbl).getColumnDefinition:
                dataDict = dataLst._asdict()[
                    AccountsTbl.
                    __name__].__dict__  # Getting the dictionary of the list.
                colname = key["name"]  # Getting the column name.
                if colname in dataDict:  # Just if the column name is on the dictionary, add it to the dictStore.

                    dicStore[colname] = DBProcess(
                        AccountsTbl.Accounts_tbl).parse2publish(
                            dataDict[colname])

            dataCol.append(dicStore)
            # Appending everything to be returned
        if "wrap_to" in inputs:
            dataCol = General().WrapInfo(
                inputs, dataCol, [{
                    AccountsTbl.code.name: "id"
                }, {
                    AccountsTbl.account_name.name: "text"
                }])
        self.session.close()
        self.connORM.dispose()
        return {"status": 200, "value": dataCol, 'type': 'application/json'}
Ejemplo n.º 12
0
    def Get(self, inputs):
        #This method gets the data, from the db.
        storeDict =[]
        where =and_()
        if buybills.code.name in inputs:
            storeDict = self.session.query(buybills, Status.name, Supplier.sup_name).\
                filter(and_(Status.code == buybills.status, Supplier.code == buybills.supplier,
                            buybills.code== int(inputs[buybills.code.name])))

        elif buybills.supplier.name in inputs and \
                        buybills.generated.name not in inputs and \
                        buybills.expires.name not in inputs:

            storeDict = self.session.query(buybills, Status.name, Supplier.sup_name).\
                filter(and_(Status.code == buybills.status, Supplier.code==buybills.supplier, buybills.supplier
                            == int(inputs[buybills.supplier.name])))

        elif buybills.supplier.name in inputs and \
                 buybills.generated.name in inputs:
            storeDict = self.session.query(buybills, Status.name, Supplier.sup_name). \
                filter(and_(Status.code == buybills.status, buybills.code
                            == int(inputs[buybills.supplier.name])))
        # The next area is in charge to extract the information,
        # from the store Dict and add it to the dataCol to be returned

        dataCol=[]

        for dataLst in storeDict:

            dicStore = {"status_name":dataLst._asdict()["name"],
                        Supplier.sup_name.name: dataLst._asdict()
                        [Supplier.sup_name.name]}

            for key in DBProcess(buybills.buybills_tbl).getColumnDefinition:
                dataDict = dataLst._asdict()[buybills.__name__].__dict__  # Getting the dictionary of the list.
                colname = key["name"]  # Getting the column name.
                if colname in dataDict:  # Just if the column name is on the dictionary, add it to the dictStore.
                    if colname in [buybills.generated.name, buybills.payalert.name, buybills.expires.name]:
                        if dataDict[colname]!=None:
                            jdate = general().julian2date(str(dataDict[colname]))
                            dataDict[colname] = jdate
                        else:
                            dataDict[colname]=" "
                    dicStore[colname] = DBProcess(buybills.buybills_tbl).parse2publish(dataDict[colname])

            dataCol.append(dicStore)
            # Appending everything to be returned

        self.session.close()
        self.connORM.dispose()
        return {"status": 200, "value": dataCol, 'type': 'application/json'}
Ejemplo n.º 13
0
    def getByUser(self, inputs):
        # This method gets the data, from the db.
        profile=login().getProfile({'key':inputs["user_code"]})["value"]
        storeDict = self.session.query(category, Status.description, company._name).\
            filter(Status.code == category.status,Type.code==category.cat_type).\
            filter(company.code == category.company).\
            filter(company.email ==profile["email"] )

        if category.code.name in inputs:
            storeDict = storeDict.filter(category.code == int(inputs[category.code.name]))

        if category.cat_type.name in inputs:
            storeDict = storeDict.filter(category.cat_type == int(inputs[category.cat_type.name]))

        if category.cat_name.name in inputs:
            storeDict = storeDict.filter(category.cat_name.ilike("%" + str(inputs[category.cat_name.name]) + "%"))


        # The next area is in charge to extract the information,
        # from the store Dict and add it to the dataCol to be returned

        dataCol = []
        for dataLst in storeDict:
            dicStore = {"status_name": dataLst._asdict()[Status.description.name],
                        "company_name":dataLst._asdict()[company._name.name]}

            for key in DBProcess(category.category_tbl).getColumnDefinition:
                dataDict = dataLst._asdict()[category.__name__].__dict__  # Getting the dictionary of the list.
                colname = key["name"]  # Getting the column name.
                if colname in dataDict:  # Just if the column name is on the dictionary, add it to the dictStore.

                    dicStore[colname] = DBProcess(category.category_tbl).parse2publish(dataDict[colname])

            product_type = self.session.query(Type).filter_by(code=dicStore[category.type_product.name]).first()
            if product_type!=None:
                dicStore["product_type_name"] = product_type.tpname

            category_type = self.session.query(Type).filter_by(code=dicStore[category.cat_type.name]).first()
            if category_type != None:
                dicStore["categorytp_name"] = category_type.tpname
            if printer_reg.objects(name=dicStore["printer"]).first()!=None:
                dicStore["printer_id"]=printer_reg.objects(name=dicStore["printer"]).first().code
            dataCol.append(dicStore)
            # Appending everything to be returned
        if "wrap_to" in inputs:
            dataCol = General().WrapInfo(inputs, dataCol,
                                         [{category.code.name: "id"},
                                          {category.cat_name.name: "text"}])

        self.session.close()
        return {"status": 200, "value": dataCol, 'type': 'application/json'}
Ejemplo n.º 14
0
    def Get(self, inputs):
        self.msg=[]
        storeDict = self.session.query(HappyHour, Status.description). \
            filter(Status.code == HappyHour.status)

        if HappyHour.code.name in inputs:
            storeDict = storeDict.filter(HappyHour.code == int(inputs[HappyHour.code.name]))

        elif HappyHour.product.name in inputs:
            storeDict = storeDict.filter(HappyHour.product == int(inputs[HappyHour.product.name]))


        for dataLst in storeDict:

            dicStore = {"status_name": dataLst._asdict()[Status.description.name]}
            for key in DBProcess(Status.Status_tbl).getColumnDefinition:

                dataDict = dataLst._asdict()[HappyHour.__name__].__dict__  # Getting the dictionary of the list.
                colname = key["name"]  # Getting the column name.
                if "_sa_" not in colname:  # Just if the column name is on the dictionary, add it to the dictStore.
                    dicStore[colname] = dataDict[colname]

            self.msg.append(dicStore)
            # Appending everything to be returned


        self.session.close()
        self.connORM.dispose()
        return {"status": 200, "value": self.msg, 'type': 'application/json'}
Ejemplo n.º 15
0
    def Get(self, inputs):
        dataCol = []
        """The module of find the information of a Client."""
        storeDict = []
        if Supplier.sup_name.name in inputs:
            storeDict = self.session.query(Supplier, Status.description).\
                filter(Supplier.sup_name.ilike("%" + inputs[Supplier.sup_name.name] + "%")).\
                filter(Supplier.status == Status.code)

        elif Supplier.code.name in inputs:
            storeDict = self.session.query(Supplier, Status.description).\
                filter(Supplier.status == Status.code).\
                filter(Supplier.code == int(inputs[Supplier.code.name]))

        storeDict = storeDict.order_by(Supplier.sup_name.asc())
        for dataLst in storeDict:
            dicStore = {
                "status_name": dataLst._asdict()[Status.description.name]
            }

            for buyBillKey in DBProcess(
                    Supplier.supplier_tbl).getColumnDefinition:
                billDict = dataLst._asdict()[
                    Supplier.
                    __name__].__dict__  # Getting the dictionary of the list.
                colname = buyBillKey["name"]  # Getting the column name.
                if colname in billDict:  # Just if the column name is on the dictionary, add it to the dictStore.
                    dicStore[colname] = billDict[colname]

            dataCol.append(dicStore)
            # Appending everything to be returned
        self.session.close()
        self.connORM.dispose()
        return {"status": 200, "value": dataCol, 'type': 'application/json'}
Ejemplo n.º 16
0
    def Get(self, inputs):
        # This method gets the data, from the db.
        storeDict = []
        if Level.code.name in inputs:
            storeDict = self.session.query(Level). \
                filter(and_(Level.code == int(inputs[Level.code.name])))
        elif Level.level_name.name in inputs:
            storeDict = self.session.query(Level). \
                filter(and_(Level.level_name.like("%" + inputs[Level.level_name.name] + "%")))
        # The next area is in charge to extract the information,
        # from the store Dict and add it to the dataCol to be returned

        dataCol = []

        for dataLst in storeDict:

            dicStore = {"level_name": dataLst._asdict()["level_name"]}
            for key in DBProcess(Level.level_tbl).getColumnDefinition:

                dataDict = dataLst._asdict()[
                    Level.
                    __name__].__dict__  # Getting the dictionary of the list.
                colname = key["name"]  # Getting the column name.
                if "_sa_" not in colname:  # Just if the column name is on the dictionary, add it to the dictStore.
                    dicStore[colname] = dataDict[colname]

            dataCol.append(dicStore)
            # Appending everything to be returned

        self.session.close()
        self.connORM.dispose()
        return {"status": 200, "value": dataCol, 'type': 'application/json'}
Ejemplo n.º 17
0
    def getTableActive(self, inputs):
        # This method will bring the tables with the code of the preorder.
        storeDict = []
        storeDict = self.session.query(Tables, Status.description). \
            filter(and_(Status.code == Tables.status, Tables.area == int(inputs[Tables.area.name])))

        dataCol = []
        for dataLst in storeDict:

            dicStore = {
                "status_name": dataLst._asdict()[Status.description.name]
            }

            for key in DBProcess(Tables.Tables_tbl).getColumnDefinition:
                dataDict = dataLst._asdict()[
                    Tables.
                    __name__].__dict__  # Getting the dictionary of the list.
                colname = key["name"]  # Getting the column name.
                if colname in dataDict:  # Just if the column name is on the dictionary, add it to the dictStore.
                    dicStore[colname] = dataDict[colname]

            area_info = self.session.query(Area).filter(
                Area.code == dicStore[Tables.area.name]).first()
            if area_info != None:
                dicStore["area_name"] = area_info.area_name
            sale_table = PreOrderTable.objects(
                table_code=dicStore[Tables.code.name], status=24).first()
            if sale_table != None:
                dicStore["bill"] = sale_table.preorder
            dataCol.append(dicStore)
            # Appending everything to be returned
        self.session.close()
        self.connORM.dispose()
        return {"status": 200, "value": dataCol, 'type': 'application/json'}
Ejemplo n.º 18
0
    def getFilters(self, inputs, storeDict, table):
        # In developing, this method will create all the filters for the table.
        for key in DBProcess(table).getColumnDefinition:
            if key["name"] in inputs:

                if len(inputs[key["name"]].split("=")) > 1:
                    comparison = inputs[key["name"]].split("=")[0]
                    data = DBProcess(table.Item_tbl).parse(
                        key, inputs[key["name"]].split("=")[1])
                    if comparison == "__gte":
                        storeDict = storeDict.filter(key["expr"] >= data)
                    elif comparison == "__lte":
                        storeDict = storeDict.filter(key["expr"] <= data)

                    elif comparison == "__gt":
                        storeDict = storeDict.filter(key["expr"] > data)
                    elif comparison == "__lt":
                        storeDict = storeDict.filter(key["expr"] < data)
                    elif comparison == "__eq":
                        storeDict = storeDict.filter(key["expr"] == data)
                    elif "__ilike" in comparison or "__like" in comparison:
                        likeStrPre = ""
                        likeStrEnd = ""

                        if data[0] == "%":
                            likeStrPre = data[0]
                            data = data[0:]

                        if data[len(data) - 1] == "%":
                            likeStrEnd = data[len(data) - 1]
                            data = data[len(data) - 1]
                        if comparison == "__ilike":
                            storeDict = storeDict.filter(
                                key["expr"].ilike(likeStrPre +
                                                  str(data).lower() +
                                                  likeStrEnd))
                        elif comparison == "__like":
                            storeDict = storeDict.filter(
                                key["expr"].ilike(likeStrPre + str(data) +
                                                  likeStrEnd))
        self.session.close()
        self.connORM.dispose()
        return storeDict
Ejemplo n.º 19
0
    def Get(self, inputs):
        # This method gets the data, from the db.
        storeDict = []
        if Recipe.code.name in inputs:
            storeDict = self.session.query(Recipe, Status.description,Item.item_name). \
                filter(and_(Status.code == Recipe.status, company.code == Recipe.commerce,
                            Recipe.item == Item.code,
                            Recipe.code == int(inputs[Recipe.code.name])))
        elif Recipe.item_name.name in inputs:
            storeDict = self.session.query(Recipe, Status.description, company.name). \
                filter(and_(Status.code == Recipe.status, company.code==Recipe.commerce,
                            Recipe.item == Item.code,
                            Item.item_name.like("%" + inputs[Item.item_name.name] + "%")))
        # The next area is in charge to extract the information,
        # from the store Dict and add it to the dataCol to be returned

        dataCol = []

        for dataLst in storeDict:
            dicStore = {
                Status.description.name:
                dataLst._asdict()[Status.description.name],
                Type.tpname.name: dataLst._asdict()[Type.tpname.name],
                Item.item_name.name: dataLst._asdict()[Item.item_name.name]
            }

            for key in DBProcess(Recipe.Recepie_tbl).getColumnDefinition:
                dataDict = dataLst._asdict()[
                    Item.
                    __name__].__dict__  # Getting the dictionary of the list.
                colname = key["name"]  # Getting the column name.
                if colname in dataDict:  # Just if the column name is on the dictionary, add it to the dictStore.

                    dicStore[colname] = DBProcess(Item.Item_tbl).parse2publish(
                        dataDict[colname])

            dataCol.append(dicStore)
            # Appending everything to be returned

        self.session.close()
        self.connORM.dispose()
        return {"status": 200, "value": dataCol, 'type': 'application/json'}
Ejemplo n.º 20
0
    def Handle(self, inputs):
        # This method will modify an expanse.
        item = int(inputs[User.code.name])

        if User.passwd.name in inputs:  #Just if the passwd
            inputs[User.passwd.name] = hashlib.md5(
                inputs[User.passwd.name].encode()).hexdigest()

        storeDict = {}
        for column in DBProcess(User.user_tbl).getColumnDefinition:
            if column["name"] in inputs:
                storeDict[column["expr"]] = DBProcess(User.user_tbl).parse(
                    column, inputs[column["name"]])

        self.session.query(User).filter_by(code=item).update(storeDict)

        self.session.commit()
        self.session.close()

        if "waiter_code" in inputs:
            if len(inputs["waiter_code"]) >= 4:
                # Means that the user will be created a key for the waiter.
                waiterKey.objects(user_code=item).update(set__status=12)
                waiterCode = CodeGen().GenCode({
                    "table": "waiterKey",
                    "column": "code"
                })
                waiterKey(code=waiterCode,
                          user_code=item,
                          status=11,
                          key=inputs["waiter_code"],
                          created_by=self.decLoginKey(inputs["key"]),
                          created_date=general().date2julian()).save()

        return {
            "status": 200,
            "value": {
                User.code.name: item
            },
            'type': 'application/json'
        }
Ejemplo n.º 21
0
    def Handle(self, inputs):
        # This method will modify an expanse.
        if buybills.code.name in inputs:
            item = int(inputs[buybills.code.name])
        else:
            item = CodeGen().GenCode({"table": buybills.__tablename__, "column": buybills.code.name})
            self.session.add(buybills(code=item, status=11))

        storeDict = {}
        for column in DBProcess(buybills.buybills_tbl).getColumnDefinition:
            if column["name"] in [buybills.generated.name, buybills.payalert.name, buybills.expires.name]:
                jdate = general().date2julian(inputs[column["name"]])
                inputs[column["name"]]=jdate


            if column["name"] in inputs:
                storeDict[column["expr"]] = DBProcess(buybills.buybills_tbl).parse(column, inputs[column["name"]])

        self.session.query(buybills).filter_by(code=item).update(storeDict)
        if "products" in inputs:
            products = json.loads(inputs["products"])
            for piece in products:

                amount = float(piece["amount"])
                warehose = 0 if "warehouse" not in inputs else int(inputs["warehouse"])
                if "amount" in piece:

                    connection = self.connORM.raw_connection()
                    cursor = connection.cursor()
                    data =cursor.callproc('products_movement', [int(piece["product"]), amount,
                                                          warehose, 0])

                    cursor.close()
                    connection.commit()
        self.session.commit()
        self.session.close()
        self.connORM.dispose()

        return {"status": 200, "value": {buybills.code.name: item}, 'type': 'application/json'}
Ejemplo n.º 22
0
    def HandleClient(self, inputs):
        client = int(inputs[Client.code.name])
        clientCol = self.session.query(Client).filter_by(code=client).first()
        contactCol = []
        idCon=0
        if clientCol.contact == None and Client.cl_name.name not in inputs:
            # Means that the contact is not created.
            idCon = ManContact().create(inputs)["value"][Contact.code.name]
            inputs[Client.contact.name] = idCon
            ManContact().Handle(inputs)
        elif clientCol.contact == None and Client.contact.name in inputs:

            # Means that the contact is created and going to be updated
            if inputs[Client.contact.name] == 0 or inputs[Client.contact.name] == None:
                # This safe zone is because C#, when creates the structure, the default value of the int is 0 and well C#
                # is generating a big mistake.
                idCon = ManContact().create(inputs)["value"][Contact.code.name]
                inputs[Client.contact.name] = idCon
            ManContact().Handle(inputs)
            idCon = int(inputs[Client.contact.name])
        elif clientCol.contact == None and Contact.contact_name.name in inputs:
            idCon = ManContact().create(inputs)["value"][Contact.code.name]
            inputs[Client.contact.name] = idCon
            ManContact().Handle(inputs)
        storeDict = {}
        for column in DBProcess(Client.clients_tbl).getColumnDefinition:
            if column["name"] in inputs:
                storeDict[column["expr"]] = DBProcess(Client.clients_tbl).parse(column, inputs[column["name"]])

        self.session.query(Client).filter_by(code=client).update(storeDict)
        self.session.commit()
        self.session.close()
        self.connORM.dispose()

        self.type = "application/json"
        self.msg = {Client.code.name: client}

        self.status = 200
        return {"status": self.status, "value": self.msg, "type": self.type}
Ejemplo n.º 23
0
    def Handle(self, inputs):
        # This method will modify an expanse.
        item = int(inputs[Type.code.name])
        storeDict = {}

        for column in DBProcess(Type.Type_tbl).getColumnDefinition:
            if column["name"] in inputs:
                storeDict[column["expr"]] = DBProcess(Type.Type_tbl).parse(
                    column, inputs[column["name"]])

        self.session.query(Type).filter_by(code=item).update(storeDict)
        self.session.commit()
        self.session.close()
        self.connORM.dispose()

        return {
            "status": 200,
            "value": {
                Type.code.name: item
            },
            'type': 'application/json'
        }
Ejemplo n.º 24
0
    def Get(self, inputs):
        # This method gets the data, from the db.
        storeDict = []
        if Tables.code.name in inputs:
            storeDict = self.session.query(Tables, Status.description). \
                filter(and_(Status.code == Tables.status, Tables.code
                            == int(inputs["table"])))
        elif Tables.tblname.name in inputs and Tables.area.name not in inputs:
            storeDict = self.session.query(Tables, Status.description). \
                filter(and_(Status.code == Tables.status,
                            Tables.tblname.like("%"+inputs[Tables.tblname.name]+"%")))

        elif Tables.tblname.name in inputs and Tables.area.name in inputs:
            storeDict = self.session.query(Tables, Status.description). \
                filter(and_(Status.code == Tables.status, Tables.area==int(inputs[Tables.area.name]),
                            Tables.tblname.like("%" + inputs[Tables.tblname.name] + "%")))

        # The next area is in charge to extract the information,
        # from the store Dict and add it to the dataCol to be returned

        dataCol = []

        for dataLst in storeDict:

            dicStore = {
                "status_name": dataLst._asdict()[Status.description.name]
            }

            for key in DBProcess(Tables.Tables_tbl).getColumnDefinition:
                dataDict = dataLst._asdict()[
                    Tables.
                    __name__].__dict__  # Getting the dictionary of the list.
                colname = key["name"]  # Getting the column name.
                if colname in dataDict:  # Just if the column name is on the dictionary, add it to the dictStore.
                    dicStore[colname] = dataDict[colname]

            area_info = self.session.query(Area).filter(
                Area.code == dicStore[Tables.area.name]).first()
            if area_info != None:
                dicStore["area_name"] = area_info.area_name
            sale_table = PreOrderTable.objects(
                table_code=dicStore[Tables.code.name], status=24).first()
            if sale_table != None:
                dicStore["bill"] = sale_table.preorder
            dataCol.append(dicStore)
            # Appending everything to be returned

        self.session.close()
        self.connORM.dispose()

        return {"status": 200, "value": dataCol, 'type': 'application/json'}
Ejemplo n.º 25
0
    def Get(self, inputs):
        dataCol = []
        """The module of find the information of a Contact."""
        dataPack = []
        if Contact.contact_name.name in inputs:
            dataPack = self.session.query(Contact, Status.description).\
                filter(and_(Contact.contact_name.like("%"+inputs[Contact.contact_name.name]+"%"), Contact.status==Status.code))

        elif Contact.code.name in inputs:
            dataPack = self.session.query(Contact, Status.description).\
                filter(and_(Contact.code == int(inputs[Contact.code.name]), Contact.status==Status.code))

        for dataLst in dataPack:
            dicStore = {
                "status_name": dataLst._asdict()[Status.description.name]
            }

            for key in DBProcess(Contact.Contact_tbl).getColumnDefinition:
                dataDict = dataLst._asdict()[
                    Contact.
                    __name__].__dict__  # Getting the dictionary of the list.
                colname = key["name"]  # Getting the column name.
                if colname in dataDict:  # Just if the column name is on the dictionary, add it to the dictStore.
                    value = DBProcess(Contact.Contact_tbl).parse2publish(
                        dataDict[colname])

                    if colname == "birthdate":
                        value = general().julian2date(str(dataDict[colname]))

                    dicStore[colname] = value

            dataCol.append(dicStore)
            # Appending everything to be returned

        self.session.close()
        self.connORM.dispose()

        return {"status": 200, "value": dataCol, 'type': 'application/json'}
Ejemplo n.º 26
0
    def Handle(self, inputs):
        # This method will modify an expanse.
        item = int(inputs[company.code.name])

        storeDict = {}
        for column in DBProcess(company.company_tbl).getColumnDefinition:
            if column["name"] in inputs:
                storeDict[column["expr"]] = DBProcess(
                    company.company_tbl).parse(column, inputs[column["name"]])

        self.session.query(company).filter_by(code=item).update(storeDict)

        self.session.commit()
        self.session.close()

        if "__documentroot__" in inputs:
            dirlst = []
            dirlst.append(inputs["__documentroot__"] + "/resources/plates/" +
                          str(self.code))
            dirlst.append(inputs["__documentroot__"] +
                          "/resources/plates/categories/" + str(self.code))
            dirlst.append(inputs["__documentroot__"] + "/resources/ads/" +
                          str(self.code))
            dirlst.append(inputs["__documentroot__"] + "/resources/company/" +
                          str(self.code))

            for directory in dirlst:
                if not os.path.exists(directory):
                    os.makedirs(directory)

        return {
            "status": 200,
            "value": {
                company.code.name: item
            },
            'type': 'application/json'
        }
Ejemplo n.º 27
0
    def Get(self, inputs):
        # This method gets the data, from the db.
        storeDict = self.session.query(company, Status.description, Type.tpname).\
            filter(Status.code == company.status).\
            filter(Type.code == company.cmp_type)

        if company._name.name in inputs:
            storeDict = storeDict.\
                filter(company._name.like("%" + inputs[company._name.name] + "%"))
        elif company.code.name in inputs:
            storeDict = storeDict. \
                filter(company.code == int(inputs[company.code.name]))

        # The next area is in charge to extract the information,
        # from the store Dict and add it to the dataCol to be returned

        dataCol = []
        for dataLst in storeDict:
            dicStore = {
                "status_name": dataLst._asdict()[Status.description.name],
                "tpname": dataLst._asdict()["tpname"]
            }

            for key in DBProcess(company.company_tbl).getColumnDefinition:
                dataDict = dataLst._asdict()[
                    company.
                    __name__].__dict__  # Getting the dictionary of the list.
                colname = key["name"]  # Getting the column name.
                if colname in dataDict:  # Just if the column name is on the dictionary, add it to the dictStore.

                    dicStore[colname] = DBProcess(
                        company.company_tbl).parse2publish(dataDict[colname])

            dataCol.append(dicStore)
            # Appending everything to be returned

        return {"status": 200, "value": dataCol, 'type': 'application/json'}
Ejemplo n.º 28
0
    def Get(self, inputs):
        # This method gets the data, from the db.
        storeDict = []
        if Area.code.name in inputs:
            storeDict = self.session.query(Area, Status.description). \
                filter(and_(Status.code == Area.status, Area.code
                            == int(inputs[Area.code.name])))
        elif Area.area_name.name in inputs:
            storeDict = self.session.query(Area, Status.description). \
                filter(and_(Status.code == Area.status, Area.area_name.like("%"+inputs[Area.area_name.name]+"%")))
        # The next area is in charge to extract the information,
        # from the store Dict and add it to the dataCol to be returned
        dataCol = []
        for dataLst in storeDict:

            dicStore = {
                "status_name": dataLst._asdict()[Status.description.name]
            }

            for key in DBProcess(Area.Area_tbl).getColumnDefinition:
                dataDict = dataLst._asdict()[
                    Area.
                    __name__].__dict__  # Getting the dictionary of the list.
                colname = key["name"]  # Getting the column name.
                if colname in dataDict:  # Just if the column name is on the dictionary, add it to the dictStore.
                    dicStore[colname] = dataDict[colname]
            dicStore["users"] = list(
                UserArea.objects(
                    area=dicStore[Area.code.name]).values_list('user_code'))

            dataCol.append(dicStore)
            # Appending everything to be returned

        self.session.close()
        self.connORM.dispose()
        return {"status": 200, "value": dataCol, 'type': 'application/json'}